5002 lines
4.7 MiB
Text
5002 lines
4.7 MiB
Text
|
,input,is_correct,expected_cond,predicted_cond,score
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
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
|
||
|
518,"def _process_include ( cmd, _model, _data, _default, options = None ) : <TAB> if len ( cmd ) == 1 : <TAB> <TAB> raise IOError ( ""Cannot execute 'include' command without a filename"" ) <TAB> if len ( cmd ) > 2 : <TAB> <TAB> raise IOError ( ""The 'include' command only accepts a single filename"" ) <TAB> global Filename <TAB> Filename = cmd [ 1 ] <TAB> global Lineno <TAB> Lineno = 0 <TAB> try : <TAB> <TAB> scenarios = parse_data_commands ( filename = cmd [ 1 ] ) <TAB> except IOError : <TAB> <TAB> raise <TAB> <TAB> err = sys. exc_info ( ) [ 1 ] <TAB> <TAB> raise IOError ( ""Error parsing file '%s': %s"" % ( Filename, str ( err ) ) ) <TAB> if scenarios is None : <TAB> <TAB> return False <TAB> for scenario in scenarios : <TAB> <TAB> for cmd in scenarios [ scenario ] : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> _data [ scenario ] = { } <TAB> <TAB> <TAB> if cmd [ 0 ] in ( ""include"", ""import"", ""load"" ) : <TAB> <TAB> <TAB> <TAB> _tmpdata = { } <TAB> <TAB> <TAB> <TAB> _process_data ( cmd, _model, _tmpdata, _default, Filename, Lineno ) <TAB> <TAB> <TAB> <TAB> if scenario is None : <TAB> <TAB> <TAB> <TAB> <TAB> for key in _tmpdata : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if key in _data : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> _data [ key ]. update ( _tmpdata [ key ] ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> _data [ key ] = _tmpdata [ key ] <TAB> <TAB> <",False,scenario not in _data,cmd[0] == 'include',0.6651172041893005
|
||
|
519,"def add_channels ( cls, voucher, add_channels ) : <TAB> for add_channel in add_channels : <TAB> <TAB> channel = add_channel [ ""channel"" ] <TAB> <TAB> defaults = { ""currency"" : channel. currency_code } <TAB> <TAB> if ""discount_value"" in add_channel. keys ( ) : <TAB> <TAB> <TAB> defaults [ ""discount_value"" ] = add_channel. get ( ""discount_value"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> defaults [ ""min_spent_amount"" ] = add_channel. get ( ""min_amount_spent"", None ) <TAB> <TAB> models. VoucherChannelListing. objects. update_or_create ( <TAB> <TAB> <TAB> voucher = voucher, <TAB> <TAB> <TAB> channel = channel, <TAB> <TAB> <TAB> defaults = defaults, <TAB> <TAB> )",True,'min_amount_spent' in add_channel.keys(),'min_amount_spent' in add_channel.keys(),0.6495001316070557
|
||
|
520,"def unknown_starttag ( self, tag, attrs ) : <TAB> <TAB> <TAB> <TAB> uattrs = [ ] <TAB> strattrs = """" <TAB> if attrs : <TAB> <TAB> for key, value in attrs : <TAB> <TAB> <TAB> value = ( <TAB> <TAB> <TAB> <TAB> value. replace ( "">"", "">"" ). replace ( ""<"", ""<"" ). replace ( '""', """"" ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> value = self. bare_ampersand. sub ( ""&"", value ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> value = value. decode ( self. encoding, ""ignore"" ) <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> uattrs. append ( ( unicode ( key, self. encoding ), value ) ) <TAB> <TAB> <TAB> except TypeError : <TAB> <TAB> <TAB> <TAB> uattrs. append ( ( key, value ) ) <TAB> <TAB> strattrs = u"""". join ( [ u' %s=""%s""' % ( key, value ) for key, value in uattrs ] ) <TAB> <TAB> if self. encoding : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> strattrs = strattrs. encode ( self. encoding ) <TAB> <TAB> <TAB> except ( UnicodeEncodeError, LookupError ) : <TAB> <TAB> <TAB> <TAB> pass <TAB> if tag in self. elements_no_end_tag : <TAB> <TAB> self. pieces. append ( ""<%s%s />"" % ( tag, strattrs ) ) <TAB> else : <TAB> <TAB> self. pieces. append ( ""<%s%s>"" % ( tag, strattrs ) )",False,"not isinstance(value, unicode)",self.encoding,0.6460530757904053
|
||
|
521,"def serialize_content_range ( value ) : <TAB> if isinstance ( value, ( tuple, list ) ) : <TAB> <TAB> if len ( value ) not in ( 2, 3 ) : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""When setting content_range to a list/tuple, it must "" <TAB> <TAB> <TAB> <TAB> ""be length 2 or 3 (not %r)"" % value <TAB> <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> begin, end = value <TAB> <TAB> <TAB> length = None <TAB> <TAB> else : <TAB> <TAB> <TAB> begin, end, length = value <TAB> <TAB> value = ContentRange ( begin, end, length ) <TAB> value = str ( value ). strip ( ) <TAB> if not value : <TAB> <TAB> return None <TAB> return value",False,len(value) == 2,"isinstance(value, ContentRange)",0.6565661430358887
|
||
|
522,"def aggregate_to_full_tokens ( attn, tokens, token_starts, token_ends, attention = True ) : <TAB> to_combine = [ ] <TAB> spacy_attn = [ ] <TAB> spacy_token_starts = [ ] <TAB> spacy_token_ends = [ ] <TAB> spacy_start = None <TAB> for token, prob, start, end in zip ( tokens, attn, token_starts, token_ends ) : <TAB> <TAB> to_combine. append ( prob ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> spacy_start = start <TAB> <TAB> if token. endswith ( ""</w>"" ) : <TAB> <TAB> <TAB> if attention : <TAB> <TAB> <TAB> <TAB> spacy_attn. append ( np. max ( to_combine, 0 ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> spacy_attn. append ( to_combine [ - 1 ] ) <TAB> <TAB> <TAB> spacy_token_starts. append ( spacy_start ) <TAB> <TAB> <TAB> spacy_token_ends. append ( end ) <TAB> <TAB> <TAB> to_combine = [ ] <TAB> <TAB> <TAB> spacy_start = None <TAB> if attention : <TAB> <TAB> spacy_attn = spacy_attn / sum ( spacy_attn ) <TAB> <TAB> key = ""attention_weights"" <TAB> else : <TAB> <TAB> key = ""explanation"" <TAB> return { <TAB> <TAB> key : spacy_attn, <TAB> <TAB> ""token_starts"" : spacy_token_starts, <TAB> <TAB> ""token_ends"" : spacy_token_ends, <TAB> }",False,spacy_start is None,"token.endswith('</w>"")",0.6620572209358215
|
||
|
523,"def _get_next_segment ( self, segment_path, page_size, segment_cursor = None ) : <TAB> if segment_path : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return None <TAB> <TAB> return Segment ( self. client, segment_path, page_size, segment_cursor ) <TAB> return None",False,self.end_time and self._is_later_than_end_time(segment_path),not self.client.has_segment(segment_path),0.6470015048980713
|
||
|
524,"def update_completion ( self ) : <TAB> """"""Update completion model with exist tags"""""" <TAB> orig_text = self. widget. text ( ) <TAB> text = "", "". join ( orig_text. replace ( "", "", "","" ). split ( "","" ) [ : - 1 ] ) <TAB> tags = [ ] <TAB> for tag in self. tags_list : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if orig_text [ - 1 ] not in ( "","", "" "" ) : <TAB> <TAB> <TAB> <TAB> tags. append ( ""%s,%s"" % ( text, tag ) ) <TAB> <TAB> <TAB> tags. append ( ""%s, %s"" % ( text, tag ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> tags. append ( tag ) <TAB> if tags!= self. completer_model. stringList ( ) : <TAB> <TAB> self. completer_model. setStringList ( tags )",False,"',' in orig_text",tag != text,0.6616669297218323
|
||
|
525,"def configure_httpretty ( sitedir ) : <TAB> httpretty. enable ( ) <TAB> dir = Path ( f""tests/test_sites/data/test_{sitedir}/"" ) <TAB> data_file = dir / ""data.json"" <TAB> data = None <TAB> with open ( data_file ) as f : <TAB> <TAB> data = json. load ( f ) <TAB> for obj in data : <TAB> <TAB> method = httpretty. POST <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> method = httpretty. GET <TAB> <TAB> with open ( dir / obj [ ""file"" ] ) as f : <TAB> <TAB> <TAB> httpretty. register_uri ( <TAB> <TAB> <TAB> <TAB> method, <TAB> <TAB> <TAB> <TAB> obj [ ""url"" ], <TAB> <TAB> <TAB> <TAB> f. read ( ), <TAB> <TAB> <TAB> )",False,obj['method'] == 'GET','file' in obj,0.6592972278594971
|
||
|
526,"def __call__ ( self, x, y, axes = 2 ) : <TAB> xnd = x. ndimension ( ) <TAB> ynd = y. ndimension ( ) <TAB> <TAB> if isinstance ( axes, int ) : <TAB> <TAB> axes = range ( xnd - axes, xnd ), range ( axes ) <TAB> <TAB> if isinstance ( axes [ 0 ], int ) : <TAB> <TAB> axes = ( axes [ 0 ], ), axes [ 1 ] <TAB> if isinstance ( axes [ 1 ], int ) : <TAB> <TAB> axes = axes [ 0 ], ( axes [ 1 ], ) <TAB> <TAB> x_ix = [ None ] * xnd <TAB> y_ix = [ None ] * ynd <TAB> out_ix = [ ] <TAB> <TAB> available_ix = iter ( EINSUM_SYMBOLS_BASE ) <TAB> for ax1, ax2 in zip ( * axes ) : <TAB> <TAB> repeat = next ( available_ix ) <TAB> <TAB> x_ix [ ax1 ] = repeat <TAB> <TAB> y_ix [ ax2 ] = repeat <TAB> <TAB> for i in range ( xnd ) : <TAB> <TAB> if x_ix [ i ] is None : <TAB> <TAB> <TAB> leave = next ( available_ix ) <TAB> <TAB> <TAB> x_ix [ i ] = leave <TAB> <TAB> <TAB> out_ix. append ( leave ) <TAB> for i in range ( ynd ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> leave = next ( available_ix ) <TAB> <TAB> <TAB> y_ix [ i ] = leave <TAB> <TAB> <TAB> out_ix. append ( leave ) <TAB> <TAB> einsum_str = ""{},{}->{}"". format ( * map ( """". join, ( x_ix, y_ix, out_ix ) ) ) <TAB> return self. einsum ( einsum_str, x, y )",False,y_ix[i] is None,x_ix[i] is None,0.655064582824707
|
||
|
527,def insert_broken_add_sometimes ( node ) : <TAB> if node. op == theano. tensor. add : <TAB> <TAB> last_time_replaced [ 0 ] = not last_time_replaced [ 0 ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return [ off_by_half ( * node. inputs ) ] <TAB> return False,False,last_time_replaced[0],node.inputs and last_time_replaced[0],0.6536835432052612
|
||
|
528,"def __test_using_best_weights ( self, ckpt_path, test_dataloaders ) : <TAB> model = self. lightning_module <TAB> <TAB> if ckpt_path == ""best"" and not self. checkpoint_callback. best_model_path : <TAB> <TAB> raise MisconfigurationException ( <TAB> <TAB> <TAB> 'ckpt_path is ""best"", but ModelCheckpoint is not configured to save the best model.' <TAB> <TAB> ) <TAB> <TAB> if ckpt_path is not None : <TAB> <TAB> <TAB> <TAB> if ckpt_path == ""best"" : <TAB> <TAB> <TAB> ckpt_path = self. checkpoint_callback. best_model_path <TAB> <TAB> if len ( ckpt_path ) == 0 : <TAB> <TAB> <TAB> rank_zero_warn ( <TAB> <TAB> <TAB> <TAB> f"".test() found no path for the best weights, {ckpt_path}. Please "" <TAB> <TAB> <TAB> <TAB> f""specify a path for a checkpoint.test(ckpt_path=PATH)"" <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> return { } <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. accelerator. barrier ( ) <TAB> <TAB> ckpt = pl_load ( ckpt_path, map_location = lambda storage, loc : storage ) <TAB> <TAB> model. load_state_dict ( ckpt [ ""state_dict"" ] ) <TAB> <TAB> if test_dataloaders is not None : <TAB> <TAB> self. data_connector. attach_dataloaders ( model, test_dataloaders = test_dataloaders ) <TAB> <TAB> self. tested_ckpt_path = ckpt_path <TAB> results = self. fit ( model ) <TAB> <TAB> if self. is_function_implemented ( ""teardown"" ) : <TAB> <TAB> model_ref = self. lightning_module <TAB> <TAB> model_ref. teardown ( ""test"" ) <TAB> return",False,not self._device_type == DeviceType.TPU,self.accelerator is not None,0.6573450565338135
|
||
|
529,"def __call__ ( self, gradients ) : <TAB> """"""Accumulates :obj:`gradients` on the current replica."""""" <TAB> if not self. _gradients : <TAB> <TAB> _ = self. step <TAB> <TAB> self. _gradients. extend ( <TAB> <TAB> <TAB> [ <TAB> <TAB> <TAB> <TAB> tf. Variable ( <TAB> <TAB> <TAB> <TAB> <TAB> tf. zeros_like ( gradient ), <TAB> <TAB> <TAB> <TAB> <TAB> trainable = False, <TAB> <TAB> <TAB> <TAB> <TAB> synchronization = tf. VariableSynchronization. ON_READ, <TAB> <TAB> <TAB> <TAB> <TAB> aggregation = tf. VariableAggregation. ONLY_FIRST_REPLICA, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> else gradient <TAB> <TAB> <TAB> <TAB> for gradient in gradients <TAB> <TAB> <TAB> ] <TAB> <TAB> ) <TAB> if len ( gradients )!= len ( self. _gradients ) : <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> ""Expected %s gradients, but got %d"" % ( len ( self. _gradients ), len ( gradients ) ) <TAB> <TAB> ) <TAB> for accum_gradient, gradient in zip ( self. _gradients, gradients ) : <TAB> <TAB> if accum_gradient is not None and gradient is not None : <TAB> <TAB> <TAB> accum_gradient. assign_add ( gradient ) <TAB> self. _accum_steps. assign_add ( 1 )",False,gradient is not None,"isinstance(gradients, dict)",0.6660048961639404
|
||
|
530,"def handle_startendtag ( self, tag, attrs ) : <TAB> for i, attr in enumerate ( attrs ) : <TAB> <TAB> attrname, attrvalue = attr <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. addhtmlblock ( attrvalue ) <TAB> <TAB> <TAB> attrs [ i ] = ( <TAB> <TAB> <TAB> <TAB> attrname, <TAB> <TAB> <TAB> <TAB> self. callback ( normalize_html ( attrvalue ). replace ( ""\n"", "" "" ) ), <TAB> <TAB> <TAB> ) <TAB> if self. currenttag is not None : <TAB> <TAB> self. currentblock += self. get_starttag_text ( ) <TAB> <TAB> self. currentsrc += self. get_starttag_text ( ) <TAB> else : <TAB> <TAB> self. filesrc += self. buildtag ( tag, attrs, startend = True )",False,attrname in self.INCLUDEATTRS and self.currentblock == '',i % 3,0.6535142064094543
|
||
|
531,"def act_mapping ( self, items, actions, mapping ) : <TAB> """"""Executes all the actions on the list of pods."""""" <TAB> success = True <TAB> for action in actions : <TAB> <TAB> for key, method in mapping. items ( ) : <TAB> <TAB> <TAB> if key in action : <TAB> <TAB> <TAB> <TAB> params = action. get ( key ) <TAB> <TAB> <TAB> <TAB> ret = method ( items, params ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> success = False <TAB> return success",True,not ret,not ret,0.6718182563781738
|
||
|
532,"def check_twobit_file ( dbkey, GALAXY_DATA_INDEX_DIR ) : <TAB> twobit_file = ""%s/twobit.loc"" % GALAXY_DATA_INDEX_DIR <TAB> twobit_path = """" <TAB> twobits = { } <TAB> for i, line in enumerate ( open ( twobit_file ) ) : <TAB> <TAB> line = line. rstrip ( ""\r\n"" ) <TAB> <TAB> if line and not line. startswith ( ""#"" ) : <TAB> <TAB> <TAB> fields = line. split ( ""\t"" ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> twobits [ ( fields [ 0 ] ) ] = fields [ 1 ] <TAB> if dbkey in twobits : <TAB> <TAB> twobit_path = twobits [ ( dbkey ) ] <TAB> return twobit_path",False,len(fields) < 2,len(fields) > 1,0.6576115489006042
|
||
|
533,"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. STRING : <TAB> <TAB> <TAB> <TAB> self. key = iprot. readString ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> if ftype == TType. STRUCT : <TAB> <TAB> <TAB> <TAB> self. column_path = ColumnPath ( ) <TAB> <TAB> <TAB> <TAB> self. column_path. read ( iprot ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif fid == 3 : <TAB> <TAB> <TAB> if ftype == TType. I32 : <TAB> <TAB> <TAB> <TAB> self. consistency_level = iprot. readI32 ( ) <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.6763397455215454
|
||
|
534,"def beginRendering ( self, canvasRegion ) : <TAB> if None!= self. canvas : <TAB> <TAB> if None == canvasRegion : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. canvas. resize ( 0, 0 ) <TAB> <TAB> <TAB> self. canvasWidth = self. canvasHeight = 0 <TAB> <TAB> else : <TAB> <TAB> <TAB> width = int ( round ( canvasRegion. width ) ) <TAB> <TAB> <TAB> height = int ( round ( canvasRegion. height ) ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. canvas. clear ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. canvas. resize ( width, height ) <TAB> <TAB> <TAB> <TAB> self. canvasWidth = width <TAB> <TAB> <TAB> <TAB> self. canvasHeight = height <TAB> <TAB> <TAB> self. x0 = int ( round ( canvasRegion. x ) ) <TAB> <TAB> <TAB> self. y0 = int ( round ( canvasRegion. y ) ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if self. x0 == - 1 and self. y0 == - 1 : <TAB> <TAB> <TAB> <TAB> self. x0 = 0 <TAB> <TAB> <TAB> self. canvasPanel. setWidgetPosition ( self. canvas, self. x0, self. y0 ) <TAB> self. imageIndex = 0",False,width == self.canvasWidth and height == self.canvasHeight,None == self.canvas,0.6608942747116089
|
||
|
535,"def limits ( self, value, square = False ) : <TAB> """"""TODO: doc + server side implementation"""""" <TAB> if isinstance ( value, six. string_types ) : <TAB> <TAB> import re <TAB> <TAB> match = re. match ( r""(\d*)(\D*)"", value ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""do not understand limit specifier %r, examples are 90%, 3sigma"" <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> value, type = match. groups ( ) <TAB> <TAB> <TAB> import ast <TAB> <TAB> <TAB> value = ast. literal_eval ( value ) <TAB> <TAB> <TAB> type = type. strip ( ) <TAB> <TAB> <TAB> if type in [ ""s"", ""sigma"" ] : <TAB> <TAB> <TAB> <TAB> return self. limits_sigma ( value ) <TAB> <TAB> <TAB> elif type in [ ""ss"", ""sigmasquare"" ] : <TAB> <TAB> <TAB> <TAB> return self. limits_sigma ( value, square = True ) <TAB> <TAB> <TAB> elif type in [ ""%"", ""percent"" ] : <TAB> <TAB> <TAB> <TAB> return self. limits_percentage ( value ) <TAB> <TAB> <TAB> elif type in [ ""%s"", ""%square"", ""percentsquare"" ] : <TAB> <TAB> <TAB> <TAB> return self. limits_percentage ( value, square = True ) <TAB> if value is None : <TAB> <TAB> return self. limits_percentage ( square = square ) <TAB> else : <TAB> <TAB> return value",False,match is None,not match,0.6622588634490967
|
||
|
536,"def load_coll ( self, name, coll_config ) : <TAB> if coll_config == ""$all"" and self. auto_handler : <TAB> <TAB> return self. auto_handler <TAB> if isinstance ( coll_config, str ) : <TAB> <TAB> index = coll_config <TAB> <TAB> archive_paths = None <TAB> <TAB> acl_paths = None <TAB> <TAB> default_access = self. default_access <TAB> elif isinstance ( coll_config, dict ) : <TAB> <TAB> index = coll_config. get ( ""index"" ) <TAB> <TAB> if not index : <TAB> <TAB> <TAB> index = coll_config. get ( ""index_paths"" ) <TAB> <TAB> archive_paths = coll_config. get ( ""archive_paths"" ) <TAB> <TAB> acl_paths = coll_config. get ( ""acl_paths"" ) <TAB> <TAB> default_access = coll_config. get ( ""default_access"", self. default_access ) <TAB> else : <TAB> <TAB> raise Exception ( ""collection config must be string or dict"" ) <TAB> <TAB> if index : <TAB> <TAB> agg = init_index_agg ( { name : index } ) <TAB> else : <TAB> <TAB> if not isinstance ( coll_config, dict ) : <TAB> <TAB> <TAB> raise Exception ( ""collection config missing"" ) <TAB> <TAB> sequence = coll_config. get ( ""sequence"" ) <TAB> <TAB> if sequence : <TAB> <TAB> <TAB> return self. init_sequence ( name, sequence ) <TAB> <TAB> index_group = coll_config. get ( ""index_group"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise Exception ( ""no index, index_group or sequence found"" ) <TAB> <TAB> timeout = int ( coll_config. get ( ""timeout"", 0 ) ) <TAB> <TAB> agg = init_index_agg ( index_group, True, timeout ) <TAB> <TAB> if not archive_paths : <TAB> <TAB> archive_paths = self. config. get ( """,False,not index_group,index_group is None or index_group is None,0.656926155090332
|
||
|
537,"def getOptions ( self, section = None, ignoreWrong = True ) : <TAB> """"""Reads configuration for jail(s) and adds enabled jails to __jails"""""" <TAB> opts = [ ] <TAB> self. __opts = ConfigReader. getOptions ( self, ""Definition"", opts ) <TAB> if section is None : <TAB> <TAB> sections = self. sections ( ) <TAB> else : <TAB> <TAB> sections = [ section ] <TAB> <TAB> parse_status = 0 <TAB> for sec in sections : <TAB> <TAB> if sec == ""INCLUDES"" : <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> jail = JailReader ( <TAB> <TAB> <TAB> sec, <TAB> <TAB> <TAB> force_enable = self. __force_enable, <TAB> <TAB> <TAB> share_config = self. share_config, <TAB> <TAB> <TAB> use_config = self. _cfg, <TAB> <TAB> ) <TAB> <TAB> ret = jail. getOptions ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if jail. isEnabled ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> parse_status |= 1 <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. __jails. append ( jail ) <TAB> <TAB> else : <TAB> <TAB> <TAB> logSys. error ( <TAB> <TAB> <TAB> <TAB> ""Errors in jail %r.%s"", sec, "" Skipping..."" if ignoreWrong else """" <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> self. __jails. append ( jail ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> parse_status |= 2 <TAB> return ( ignoreWrong and parse_status & 1 ) or not ( parse_status & 2 )",False,ret,ret & 1,0.6952841281890869
|
||
|
538,"def write_Leo_file ( self, fileName, outlineOnlyFlag, toString = False, toOPML = False ) : <TAB> """"""Write the.leo file."""""" <TAB> c, fc = self. c, self <TAB> structure_errors = c. checkOutline ( ) <TAB> if structure_errors : <TAB> <TAB> g. error ( ""Major structural errors! outline not written"" ) <TAB> <TAB> return False <TAB> if not outlineOnlyFlag or toOPML : <TAB> <TAB> g. app. recentFilesManager. writeRecentFilesFile ( c ) <TAB> <TAB> fc. writeAllAtFileNodesHelper ( ) <TAB> if fc. isReadOnly ( fileName ) : <TAB> <TAB> return False <TAB> if g. SQLITE and fileName and fileName. endswith ( "".db"" ) : <TAB> <TAB> return fc. exportToSqlite ( fileName ) <TAB> try : <TAB> <TAB> fc. putCount = 0 <TAB> <TAB> fc. toString = toString <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> ok = fc. writeToStringHelper ( fileName ) <TAB> <TAB> else : <TAB> <TAB> <TAB> ok = fc. writeToFileHelper ( fileName, toOPML ) <TAB> finally : <TAB> <TAB> fc. outputFile = None <TAB> <TAB> fc. toString = False <TAB> return ok",False,toString,toOPML,0.6930158138275146
|
||
|
539,"def _send_internal ( self, bytes_ ) : <TAB> <TAB> if self. pendings : <TAB> <TAB> self. pendings += bytes_ <TAB> <TAB> bytes_ = self. pendings <TAB> try : <TAB> <TAB> <TAB> <TAB> self. _reconnect ( ) <TAB> <TAB> <TAB> <TAB> self. socket. sendall ( bytes_ ) <TAB> <TAB> <TAB> <TAB> self. pendings = None <TAB> except Exception : <TAB> <TAB> <TAB> <TAB> self. _close ( ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. pendings = None <TAB> <TAB> else : <TAB> <TAB> <TAB> self. pendings = bytes_",False,self.pendings and len(self.pendings) > self.bufmax,self.send_response,0.6528598666191101
|
||
|
540,"def get_profile_cutoff ( profile_id ) : <TAB> cutoff_language = None <TAB> if not len ( profile_id_list ) : <TAB> <TAB> update_profile_id_list ( ) <TAB> if profile_id : <TAB> <TAB> cutoff_language = [ ] <TAB> <TAB> for profile in profile_id_list : <TAB> <TAB> <TAB> profileId, name, cutoff, items = profile. values ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> if profileId == int ( profile_id ) : <TAB> <TAB> <TAB> <TAB> <TAB> for item in ast. literal_eval ( items ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if item [ ""id"" ] == cutoff : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return [ item ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> elif cutoff == 65535 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> cutoff_language. append ( item ) <TAB> <TAB> if not len ( cutoff_language ) : <TAB> <TAB> <TAB> cutoff_language = None <TAB> return cutoff_language",False,cutoff,len(items),0.6935614943504333
|
||
|
541,"def assert_conll_writer_output ( <TAB> dataset : InternalBioNerDataset, <TAB> expected_output : List [ str ], <TAB> sentence_splitter : SentenceSplitter = None, ) : <TAB> outfile_path = tempfile. mkstemp ( ) [ 1 ] <TAB> try : <TAB> <TAB> sentence_splitter = ( <TAB> <TAB> <TAB> sentence_splitter <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> else NoSentenceSplitter ( tokenizer = SpaceTokenizer ( ) ) <TAB> <TAB> ) <TAB> <TAB> writer = CoNLLWriter ( sentence_splitter = sentence_splitter ) <TAB> <TAB> writer. write_to_conll ( dataset, Path ( outfile_path ) ) <TAB> <TAB> contents = [ l. strip ( ) for l in open ( outfile_path ). readlines ( ) if l. strip ( ) ] <TAB> finally : <TAB> <TAB> os. remove ( outfile_path ) <TAB> assert contents == expected_output",False,sentence_splitter,sentence_splitter is None,0.6725471019744873
|
||
|
542,"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 ftype == TType. LIST : <TAB> <TAB> <TAB> <TAB> self. success = [ ] <TAB> <TAB> <TAB> <TAB> ( _etype987, _size984 ) = iprot. readListBegin ( ) <TAB> <TAB> <TAB> <TAB> for _i988 in xrange ( _size984 ) : <TAB> <TAB> <TAB> <TAB> <TAB> _elem989 = iprot. readString ( ) <TAB> <TAB> <TAB> <TAB> <TAB> self. success. append ( _elem989 ) <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<mask> : <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.STRUCT,self.o1 is None,0.6632502675056458
|
||
|
543,"def get_versions ( *, all = False, quiet = None ) : <TAB> import bonobo <TAB> from bonobo. util. pkgs import bonobo_packages <TAB> yield _format_version ( bonobo, quiet = quiet ) <TAB> if all : <TAB> <TAB> for name in sorted ( bonobo_packages ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> mod = __import__ ( name. replace ( ""-"", ""_"" ) ) <TAB> <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> yield _format_version ( mod, name = name, quiet = quiet ) <TAB> <TAB> <TAB> <TAB> <TAB> except Exception as exc : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> yield ""{} ({})"". format ( name, exc ) <TAB> <TAB> <TAB> <TAB> except ImportError as exc : <TAB> <TAB> <TAB> <TAB> <TAB> yield ""{} is not importable ({})."". format ( name, exc )",False,name != 'bonobo',name.startswith('bonobo_'),0.6598379015922546
|
||
|
544,"def visit_type_type ( self, t : TypeType ) -> ProperType : <TAB> if isinstance ( self. s, TypeType ) : <TAB> <TAB> typ = self. meet ( t. item, self. s. item ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> typ = TypeType. make_normalized ( typ, line = t. line ) <TAB> <TAB> return typ <TAB> elif isinstance ( self. s, Instance ) and self. s. type. fullname == ""builtins.type"" : <TAB> <TAB> return t <TAB> elif isinstance ( self. s, CallableType ) : <TAB> <TAB> return self. meet ( t, self. s ) <TAB> else : <TAB> <TAB> return self. default ( self. s )",False,"not isinstance(typ, NoneType)","isinstance(self.s, NormalizeType)",0.6546109914779663
|
||
|
545,"def get_ou_from_path ( client, path ) : <TAB> ou = client. list_roots ( ) [ ""Roots"" ] [ 0 ] <TAB> if path == ""/"" : <TAB> <TAB> ou [ ""Path"" ] = path <TAB> <TAB> return ou <TAB> ou_pager = client. get_paginator ( ""list_organizational_units_for_parent"" ) <TAB> for part in path. strip ( ""/"" ). split ( ""/"" ) : <TAB> <TAB> found = False <TAB> <TAB> for page in ou_pager. paginate ( ParentId = ou [ ""Id"" ] ) : <TAB> <TAB> <TAB> for child in page. get ( ""OrganizationalUnits"" ) : <TAB> <TAB> <TAB> <TAB> if child [ ""Name"" ] == part : <TAB> <TAB> <TAB> <TAB> <TAB> found = True <TAB> <TAB> <TAB> <TAB> <TAB> ou = child <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> if found : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( ""No OU named:%r found in path: %s"" % ( path, path ) ) <TAB> ou [ ""Path"" ] = path <TAB> return ou",False,found is False,not ou,0.662794828414917
|
||
|
546,"def hash_path ( <TAB> path, algorithm = ""blake2b"", suffix_len = None, num_orig_chars = None, constant_len = False ) : <TAB> <TAB> path = Path ( path ) <TAB> if suffix_len is None : <TAB> <TAB> suffix_len = len ( path. suffix ) <TAB> stem = str ( path. stem ) <TAB> replaced_stem = stem. replace ( "" "", ""_"" ) <TAB> replaced_stem = replaced_stem. replace ( ""-"", ""_"" ) <TAB> filtered_stem = non_word_pattern. sub ( """", replaced_stem ) <TAB> if len ( filtered_stem ) == len ( stem ) : <TAB> <TAB> return replaced_stem <TAB> path = str ( path ) <TAB> if algorithm == ""blake2b"" : <TAB> <TAB> <TAB> <TAB> hashstr = hashlib. blake2b ( path. encode ( ), digest_size = 16 ). hexdigest ( ) <TAB> elif algorithm == ""md5"" : <TAB> <TAB> hashstr = hashlib. md5 ( path. encode ( ) ). hexdigest ( ) <TAB> else : <TAB> <TAB> raise ValueError ( ""Unsupported algorithm {}"". format ( algorithm ) ) <TAB> <TAB> max_orig_chars = PATH_MAXLEN - ( len ( hashstr ) + 1 ) - suffix_len <TAB> orig_take_chars = ( <TAB> <TAB> max_orig_chars <TAB> <TAB> if num_orig_chars is None <TAB> <TAB> else min ( num_orig_chars, max_orig_chars ) <TAB> ) <TAB> if orig_take_chars > 0 : <TAB> <TAB> trunc_stem = filtered_stem [ : orig_take_chars ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> trunc_stem = trunc_stem. ljust ( orig_take_chars, ""_"" ) <TAB> <TAB> new_stem = ""{}_{}"". format ( trunc_stem, hashstr ) <TAB> else : <TAB> <TAB> new_stem = hashstr <TAB> return new_stem",False,num_orig_chars and constant_len,constant_len,0.6487576365470886
|
||
|
547,"def profile_by_id ( request, user_id ) : <TAB> user = User. objects. get ( pk = user_id ) <TAB> if request. method == ""POST"" : <TAB> <TAB> form = ProfileForm ( request. POST, request. FILES ) <TAB> <TAB> if form. is_valid ( ) : <TAB> <TAB> <TAB> print ( ""made it!"" ) <TAB> <TAB> <TAB> if request. POST. get ( ""username"" )!= user. username : <TAB> <TAB> <TAB> <TAB> user. username = request. POST. get ( ""username"" ) <TAB> <TAB> <TAB> if request. POST. get ( ""first_name"" )!= user. first_name : <TAB> <TAB> <TAB> <TAB> user. first_name = request. POST. get ( ""first_name"" ) <TAB> <TAB> <TAB> if request. POST. get ( ""last_name"" )!= user. last_name : <TAB> <TAB> <TAB> <TAB> user. last_name = request. POST. get ( ""last_name"" ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> user. email = request. POST. get ( ""email"" ) <TAB> <TAB> <TAB> if request. POST. get ( ""password"" ) : <TAB> <TAB> <TAB> <TAB> user. set_password ( request. POST. get ( ""password"" ) ) <TAB> <TAB> <TAB> if request. FILES : <TAB> <TAB> <TAB> <TAB> user. userprofile. image = store_uploaded_file ( <TAB> <TAB> <TAB> <TAB> <TAB> user. username + ""."" + request. FILES [ ""picture"" ]. name. split ( ""."" ) [ - 1 ], <TAB> <TAB> <TAB> <TAB> <TAB> request. FILES [ ""picture"" ], <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> user. userprofile. save ( ) <TAB> <TAB> <TAB> user. save ( ) <TAB> <",False,request.POST.get('email') != user.email,request.POST.get('email'),0.6517688035964966
|
||
|
548,"def __call__ ( self, list_data ) : <TAB> coords, feats, labels = list ( zip ( * list_data ) ) <TAB> coords_batch, feats_batch, labels_batch = [ ], [ ], [ ] <TAB> batch_num_points = 0 <TAB> for batch_id, _ in enumerate ( coords ) : <TAB> <TAB> num_points = coords [ batch_id ]. shape [ 0 ] <TAB> <TAB> batch_num_points += num_points <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> num_full_points = sum ( len ( c ) for c in coords ) <TAB> <TAB> <TAB> num_full_batch_size = len ( coords ) <TAB> <TAB> <TAB> logging. warning ( <TAB> <TAB> <TAB> <TAB> f""\tCannot fit {num_full_points} points into"" <TAB> <TAB> <TAB> <TAB> "" {self.limit_numpoints} points limit. Truncating batch "" <TAB> <TAB> <TAB> <TAB> f""size at {batch_id} out of {num_full_batch_size} with "" <TAB> <TAB> <TAB> <TAB> f""{batch_num_points - num_points}."" <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> break <TAB> <TAB> coords_batch. append ( coords [ batch_id ] ) <TAB> <TAB> feats_batch. append ( feats [ batch_id ] ) <TAB> <TAB> labels_batch. append ( labels [ batch_id ] ) <TAB> <TAB> return sparse_collate ( <TAB> <TAB> coords_batch, <TAB> <TAB> feats_batch, <TAB> <TAB> labels_batch, <TAB> <TAB> dtype = self. dtype, <TAB> <TAB> device = self. device, <TAB> )",False,self.limit_numpoints > 0 and batch_num_points > self.limit_numpoints,num_points > self.max_points,0.6534451246261597
|
||
|
549,"def dtdwrite ( dtdfile, entities, force = False ) : <TAB> if not entities : <TAB> <TAB> return <TAB> dtdEntities = [ <TAB> <TAB> '<!ENTITY %s ""%s"">' % ( id, escape ( val, entitydefs ) ) <TAB> <TAB> for id, val in entities. items ( ) <TAB> ] <TAB> dtdEntities. sort ( ) <TAB> dtdFileData = ""\n"". join ( dtdEntities ) + ""\n"" <TAB> if type ( dtdfile ) in types. StringTypes : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if force : <TAB> <TAB> <TAB> <TAB> os. remove ( dtdfile ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> raise DTDGenError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""dtd '%s' already exists, use '--force' to "" <TAB> <TAB> <TAB> <TAB> <TAB> ""allow overwrite"" % dtdfile <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> dtdf = open ( dtdfile, ""w"" ) <TAB> else : <TAB> <TAB> dtdf = dtdfile <TAB> dtdf. write ( dtdFileData ) <TAB> if dtdf!= dtdfile : <TAB> <TAB> dtdf. close ( )",True,os.path.exists(dtdfile),os.path.exists(dtdfile),0.6584407091140747
|
||
|
550,"def _mixture_ ( self ) -> Sequence [ Tuple [ float, np. ndarray ] ] : <TAB> ps = [ ] <TAB> for pauli in self. _error_probabilities : <TAB> <TAB> Pi = np. identity ( 1 ) <TAB> <TAB> for gate in pauli : <TAB> <TAB> <TAB> if gate == ""I"" : <TAB> <TAB> <TAB> <TAB> Pi = np. kron ( Pi, protocols. unitary ( identity. I ) ) <TAB> <TAB> <TAB> elif gate == ""X"" : <TAB> <TAB> <TAB> <TAB> Pi = np. kron ( Pi, protocols. unitary ( pauli_gates. X ) ) <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> Pi = np. kron ( Pi, protocols. unitary ( pauli_gates. Y ) ) <TAB> <TAB> <TAB> elif gate == ""Z"" : <TAB> <TAB> <TAB> <TAB> Pi = np. kron ( Pi, protocols. unitary ( pauli_gates. Z ) ) <TAB> <TAB> ps. append ( Pi ) <TAB> return tuple ( zip ( self. _error_probabilities. values ( ), ps ) )",True,gate == 'Y',gate == 'Y',0.6620485782623291
|
||
|
551,"def newtodolink ( self, url, origin ) : <TAB> <TAB> <TAB> if self. todo. has_key ( url ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. todo [ url ]. append ( origin ) <TAB> <TAB> self. note ( 3, "" Seen todo link %s"", self. format_url ( url ) ) <TAB> else : <TAB> <TAB> self. todo [ url ] = [ origin ] <TAB> <TAB> self. note ( 3, "" New todo link %s"", self. format_url ( url ) )",False,origin not in self.todo[url],url in self.todo[url],0.6547436714172363
|
||
|
552,"def checkpoint ( self, metrics_dict, iteration, model, optimizer, lr_scheduler ) : <TAB> <TAB> if self. checkpoint_runway : <TAB> <TAB> if iteration < self. checkpoint_runway : <TAB> <TAB> <TAB> return <TAB> <TAB> elif iteration == self. checkpoint_runway : <TAB> <TAB> <TAB> print ( ""Checkpoint runway has been met. Checkpointing will now occur."" ) <TAB> if ( <TAB> <TAB> self. checkpoint_every <TAB> <TAB> and iteration > 0 <TAB> <TAB> and iteration % self. checkpoint_every == 0 <TAB> ) : <TAB> <TAB> <TAB> <TAB> score = None <TAB> <TAB> state = self. bundle_state ( iteration, score, model, optimizer, lr_scheduler ) <TAB> <TAB> checkpoint_path = f""{self.checkpoint_dir}/model_checkpoint_{iteration}.pth"" <TAB> <TAB> torch. save ( state, checkpoint_path ) <TAB> if self. checkpoint_best and self. checkpoint_metric in metrics_dict : <TAB> <TAB> score = metrics_dict [ self. checkpoint_metric ] <TAB> <TAB> if self. is_best ( score ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> <TAB> f""Saving model at iteration {iteration:.2f} with best "" <TAB> <TAB> <TAB> <TAB> <TAB> f""({self.checkpoint_metric_mode}) score "" <TAB> <TAB> <TAB> <TAB> <TAB> f""{self.checkpoint_metric}={score:.3f}"" <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> self. best_model_found = True <TAB> <TAB> <TAB> self. best_iteration = iteration <TAB> <TAB> <TAB> self. best_score = score <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> state = self. bundle_state ( iteration, score, model, optimizer, lr_scheduler ) <TAB> <TAB> <TAB> checkpoint",False,self.verbose,self.best_model_found,0.6675825119018555
|
||
|
553,"def format_bpe_text ( symbols, delimiter = b""@@"" ) : <TAB> """"""Convert a sequence of bpe words into sentence."""""" <TAB> words = [ ] <TAB> word = b"""" <TAB> if isinstance ( symbols, str ) : <TAB> <TAB> symbols = symbols. encode ( ) <TAB> delimiter_len = len ( delimiter ) <TAB> for symbol in symbols : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> word += symbol [ : - delimiter_len ] <TAB> <TAB> else : <TAB> <TAB> <TAB> word += symbol <TAB> <TAB> <TAB> words. append ( word ) <TAB> <TAB> <TAB> word = b"""" <TAB> return b"" "". join ( words )",False,len(symbol) >= delimiter_len and symbol[-delimiter_len:] == delimiter,delimiter_len > 0,0.6539909839630127
|
||
|
554,"def configure_slurm_ddp ( self ) : <TAB> <TAB> <TAB> <TAB> if self. use_ddp or self. use_ddp2 : <TAB> <TAB> num_requested_gpus = self. num_gpus * self. num_nodes <TAB> <TAB> num_slurm_tasks = 0 <TAB> <TAB> try : <TAB> <TAB> <TAB> num_slurm_tasks = int ( os. environ [ ""SLURM_NTASKS"" ] ) <TAB> <TAB> <TAB> self. is_slurm_managing_tasks = num_slurm_tasks == num_requested_gpus <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if num_requested_gpus == 0 : <TAB> <TAB> <TAB> <TAB> self. is_slurm_managing_tasks = num_slurm_tasks == self. num_processes <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> job_name = os. environ [ ""SLURM_JOB_NAME"" ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. is_slurm_managing_tasks = False <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. is_slurm_managing_tasks = False <TAB> <TAB> try : <TAB> <TAB> should_fake = int ( os. environ [ ""FAKE_SLURM_MANAGING_TASKS"" ] ) <TAB> <TAB> if should_fake : <TAB> <TAB> <TAB> self. is_slurm_managing_tasks = True <TAB> except Exception : <TAB> <TAB> pass <TAB> <TAB> if self. is_slurm_managing_tasks : <TAB> <TAB> rank_zero_info ( ""Multi-processing is handled by Slurm."" )",False,job_name == 'bash',job_name in os.environ[SLURM_JOB_NAME],0.6583789587020874
|
||
|
555,"def _build_dom ( cls, content, mode ) : <TAB> assert mode in ( ""html"", ""xml"" ) <TAB> if mode == ""html"" : <TAB> <TAB> if not hasattr ( THREAD_STORAGE, ""html_parser"" ) : <TAB> <TAB> <TAB> THREAD_STORAGE. html_parser = HTMLParser ( ) <TAB> <TAB> dom = defusedxml. lxml. parse ( <TAB> <TAB> <TAB> StringIO ( content ), parser = THREAD_STORAGE. html_parser <TAB> <TAB> ) <TAB> <TAB> return dom. getroot ( ) <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> THREAD_STORAGE. xml_parser = XMLParser ( ) <TAB> <TAB> dom = defusedxml. lxml. parse ( BytesIO ( content ), parser = THREAD_STORAGE. xml_parser ) <TAB> <TAB> return dom. getroot ( )",True,"not hasattr(THREAD_STORAGE, 'xml_parser')","not hasattr(THREAD_STORAGE, 'xml_parser')",0.649681806564331
|
||
|
556,"def useful ( self, pos ) : <TAB> global TIMESTAMP <TAB> TIMESTAMP += 1 <TAB> square = self. squares [ pos ] <TAB> if self. useful_fast ( square ) : <TAB> <TAB> return True <TAB> old_hash = self. zobrist. hash <TAB> self. zobrist. update ( square, self. color ) <TAB> empties = opps = weak_opps = neighs = weak_neighs = 0 <TAB> for neighbour in square. neighbours : <TAB> <TAB> neighcolor = neighbour. color <TAB> <TAB> if neighcolor == EMPTY : <TAB> <TAB> <TAB> empties += 1 <TAB> <TAB> <TAB> continue <TAB> <TAB> neighbour_ref = neighbour. find ( ) <TAB> <TAB> if neighbour_ref. timestamp!= TIMESTAMP : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> neighs += 1 <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> opps += 1 <TAB> <TAB> <TAB> neighbour_ref. timestamp = TIMESTAMP <TAB> <TAB> <TAB> neighbour_ref. temp_ledges = neighbour_ref. ledges <TAB> <TAB> neighbour_ref. temp_ledges -= 1 <TAB> <TAB> if neighbour_ref. temp_ledges == 0 : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> weak_neighs += 1 <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> weak_opps += 1 <TAB> <TAB> <TAB> <TAB> neighbour_ref. remove ( neighbour_ref, update = False ) <TAB> dupe = self. zobrist. dupe ( ) <TAB> self. zobrist. hash = old_hash <TAB> strong_neighs = neighs - weak_neighs <TAB> strong_opps = opps - weak_opps <TAB> return not dupe and ( <TAB> <TAB> empties or weak_opps or ( strong_neigh",False,neighcolor == self.color,negate_ref.update != False,0.6684244871139526
|
||
|
557,"def __call__ ( self, engine : Optional [ Engine ], name : Optional [ str ] = None ) -> None : <TAB> value = self. get_param ( ) <TAB> if isinstance ( value, list ) : <TAB> <TAB> if len ( value )!= len ( self. optimizer_param_groups ) : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""size of value is different than optimizer_param_groups "" <TAB> <TAB> <TAB> <TAB> f""{len(value)}!= {len(self.optimizer_param_groups)}"" <TAB> <TAB> <TAB> ) <TAB> <TAB> for i, param_group in enumerate ( self. optimizer_param_groups ) : <TAB> <TAB> <TAB> param_group [ self. param_name ] = value [ i ] <TAB> else : <TAB> <TAB> for i, param_group in enumerate ( self. optimizer_param_groups ) : <TAB> <TAB> <TAB> param_group [ self. param_name ] = value <TAB> if name is None : <TAB> <TAB> name = self. param_name <TAB> if self. save_history and engine : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> setattr ( engine. state, ""param_history"", { } ) <TAB> <TAB> engine. state. param_history. setdefault ( name, [ ] ) <TAB> <TAB> values = [ pg [ self. param_name ] for pg in self. optimizer_param_groups ] <TAB> <TAB> engine. state. param_history [ name ]. append ( values ) <TAB> self. event_index += 1",False,"not hasattr(engine.state, 'param_history') or engine.state.param_history is None",name is None,0.6503086090087891
|
||
|
558,"def getitem_tuple_lower ( context, builder, sig, args ) : <TAB> tupty, idx = sig. args <TAB> idx = idx. literal_value <TAB> tup, _ = args <TAB> if isinstance ( idx, int ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> idx += len ( tupty ) <TAB> <TAB> if not 0 <= idx < len ( tupty ) : <TAB> <TAB> <TAB> raise IndexError ( ""cannot index at %d in %s"" % ( idx, tupty ) ) <TAB> <TAB> res = builder. extract_value ( tup, idx ) <TAB> elif isinstance ( idx, slice ) : <TAB> <TAB> items = cgutils. unpack_tuple ( builder, tup ) [ idx ] <TAB> <TAB> res = context. make_tuple ( builder, sig. return_type, items ) <TAB> else : <TAB> <TAB> raise NotImplementedError ( ""unexpected index %r for %s"" % ( idx, sig. args [ 0 ] ) ) <TAB> return impl_ret_borrowed ( context, builder, sig. return_type, res )",False,idx < 0,tup[0] == 0,0.6798169016838074
|
||
|
559,"def migrate_InternalTip ( self ) : <TAB> for old_obj in self. session_old. query ( self. model_from [ ""InternalTip"" ] ) : <TAB> <TAB> new_obj = self. model_to [ ""InternalTip"" ] ( ) <TAB> <TAB> for key in new_obj. __table__. columns. _data. keys ( ) : <TAB> <TAB> <TAB> new_obj. status = ""antani!"" <TAB> <TAB> <TAB> if key == ""status"" or key == ""substatus"" : <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> setattr ( new_obj, key, getattr ( old_obj, key ) ) <TAB> <TAB> self. session_new. add ( new_obj ) <TAB> <TAB> if old_obj. receipt_hash : <TAB> <TAB> <TAB> new_wbtip = self. model_to [ ""WhistleblowerTip"" ] ( ) <TAB> <TAB> <TAB> new_wbtip. id = old_obj. id <TAB> <TAB> <TAB> new_wbtip. tid = old_obj. tid <TAB> <TAB> <TAB> new_wbtip. receipt_hash = old_obj. receipt_hash <TAB> <TAB> <TAB> self. session_new. add ( new_wbtip )",False,key in old_obj.__table__.columns._data.keys(),"hasattr(old_obj, key)",0.6521081924438477
|
||
|
560,"def postprocess_element ( elements, processed ) : <TAB> """"""Fix unresolved references"""""" <TAB> <TAB> <TAB> <TAB> if elements in processed : <TAB> <TAB> return <TAB> processed. append ( elements ) <TAB> for k, v in elements. items ( ) : <TAB> <TAB> if isinstance ( v, Struct ) : <TAB> <TAB> <TAB> if v!= elements : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> postprocess_element ( v, processed ) <TAB> <TAB> <TAB> <TAB> except RuntimeError as e : <TAB> <TAB> <TAB> <TAB> <TAB> warnings. warn ( unicode ( e ), RuntimeWarning ) <TAB> <TAB> <TAB> if v. refers_to : <TAB> <TAB> <TAB> <TAB> if isinstance ( v. refers_to, dict ) : <TAB> <TAB> <TAB> <TAB> <TAB> extend_element ( v, v. refers_to ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> v. refers_to = None <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> elements [ k ] = v. refers_to <TAB> <TAB> <TAB> if v. array : <TAB> <TAB> <TAB> <TAB> elements [ k ] = [ v ] <TAB> <TAB> if isinstance ( v, list ) : <TAB> <TAB> <TAB> for n in v : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> postprocess_element ( n, processed )",False,"isinstance(n, (Struct, list))",n != n,0.6580489873886108
|
||
|
561,"def _open ( file_, mode = ""r"" ) : <TAB> """"""Open file object given filenames, open files or even archives."""""" <TAB> if isinstance ( file_, string_types ) : <TAB> <TAB> _, ext = path. splitext ( file_ ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> s = tarfile. open ( file_ ) <TAB> <TAB> <TAB> return s. extractfile ( s. next ( ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return open ( file_, mode ) <TAB> return file_",False,"ext in {'.bz2', '.gz'}",ext.lower() == '.tar',0.6605916023254395
|
||
|
562,"def d3_box_overlap_kernel ( boxes, qboxes, rinc, criterion = - 1 ) : <TAB> <TAB> <TAB> N, K = boxes. shape [ 0 ], qboxes. shape [ 0 ] <TAB> for i in numba. prange ( N ) : <TAB> <TAB> for j in numba. prange ( K ) : <TAB> <TAB> <TAB> if rinc [ i, j ] > 0 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> iw = min ( boxes [ i, 1 ], qboxes [ j, 1 ] ) - max ( <TAB> <TAB> <TAB> <TAB> <TAB> boxes [ i, 1 ] - boxes [ i, 4 ], qboxes [ j, 1 ] - qboxes [ j, 4 ] <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> area1 = boxes [ i, 3 ] * boxes [ i, 4 ] * boxes [ i, 5 ] <TAB> <TAB> <TAB> <TAB> <TAB> area2 = qboxes [ j, 3 ] * qboxes [ j, 4 ] * qboxes [ j, 5 ] <TAB> <TAB> <TAB> <TAB> <TAB> inc = iw * rinc [ i, j ] <TAB> <TAB> <TAB> <TAB> <TAB> if criterion == - 1 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ua = area1 + area2 - inc <TAB> <TAB> <TAB> <TAB> <TAB> elif criterion == 0 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ua = area1 <TAB> <TAB> <TAB> <TAB> <TAB> elif criterion == 1 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ua = area2 <TAB> <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ua = inc <",False,iw > 0,rinc[j] > 0,0.6861975193023682
|
||
|
563,"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. STRUCT : <TAB> <TAB> <TAB> <TAB> self. hiveObject = HiveObjectRef ( ) <TAB> <TAB> <TAB> <TAB> self. hiveObject. read ( iprot ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif fid == 2 : <TAB> <TAB> <TAB> if ftype == TType. STRING : <TAB> <TAB> <TAB> <TAB> self. principalName = iprot. readString ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif fid == 3 : <TAB> <TAB> <TAB> if ftype == TType. I32 : <TAB> <TAB> <TAB> <TAB> self. principalType = iprot. readI32 ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> if ftype == TType. STRUCT : <TAB> <TAB> <TAB> <TAB> self. grantInfo = PrivilegeGrantInfo",True,fid == 4,fid == 4,0.676572322845459
|
||
|
564,"def _recv_value ( self, server, flags, rlen ) : <TAB> rlen += 2 <TAB> buf = server. recv ( rlen ) <TAB> if len ( buf )!= rlen : <TAB> <TAB> raise _Error ( ""received %d bytes when expecting %d"" % ( len ( buf ), rlen ) ) <TAB> if len ( buf ) == rlen : <TAB> <TAB> buf = buf [ : - 2 ] <TAB> if flags & Client. _FLAG_COMPRESSED : <TAB> <TAB> buf = zlib. decompress ( buf ) <TAB> if flags == 0 or flags == Client. _FLAG_COMPRESSED : <TAB> <TAB> <TAB> <TAB> val = buf <TAB> elif flags & Client. _FLAG_INTEGER : <TAB> <TAB> val = int ( buf ) <TAB> elif flags & Client. _FLAG_LONG : <TAB> <TAB> val = long ( buf ) <TAB> elif flags & Client. _FLAG_PICKLE : <TAB> <TAB> try : <TAB> <TAB> <TAB> file = BytesIO ( buf ) <TAB> <TAB> <TAB> unpickler = self. unpickler ( file ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> unpickler. persistent_load = self. persistent_load <TAB> <TAB> <TAB> val = unpickler. load ( ) <TAB> <TAB> except Exception as e : <TAB> <TAB> <TAB> self. debuglog ( ""Pickle error: %s\n"" % e ) <TAB> <TAB> <TAB> return None <TAB> else : <TAB> <TAB> self. debuglog ( ""unknown flags on get: %x\n"" % flags ) <TAB> <TAB> raise ValueError ( ""Unknown flags on get: %x"" % flags ) <TAB> return val",False,self.persistent_load,unpickler.persistent_load is not None,0.6598360538482666
|
||
|
565,def isFinished ( self ) : <TAB> <TAB> if self. count > self. epiLen : <TAB> <TAB> self. res ( ) <TAB> <TAB> return True <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. pertGlasPos ( 0 ) <TAB> <TAB> if self. count == self. epiLen / 2 + 1 : <TAB> <TAB> <TAB> self. env. reset ( ) <TAB> <TAB> <TAB> self. pertGlasPos ( 1 ) <TAB> <TAB> self. count += 1 <TAB> <TAB> return False,False,self.count == 1,self.count > 0,0.6627359390258789
|
||
|
566,"def group_by_heading ( lines ) : <TAB> from collections import OrderedDict <TAB> ret = OrderedDict ( ) <TAB> k = [ ] <TAB> ret [ ""No Category"" ] = k <TAB> for line_type, line_args, line_kwargs in lines : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> k = [ ] <TAB> <TAB> <TAB> ret [ line_args [ 0 ] ] = k <TAB> <TAB> else : <TAB> <TAB> <TAB> k. append ( ( line_type, line_args, line_kwargs ) ) <TAB> return ret",False,line_type == 'add_heading',line_type == 'Category',0.6528555154800415
|
||
|
567,"def create_paddle_predictor ( args ) : <TAB> config = Config ( args. model_file, args. params_file ) <TAB> if args. use_gpu : <TAB> <TAB> config. enable_use_gpu ( args. gpu_mem, 0 ) <TAB> else : <TAB> <TAB> config. disable_gpu ( ) <TAB> <TAB> if args. enable_mkldnn : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> config. set_mkldnn_cache_capacity ( 10 ) <TAB> <TAB> <TAB> config. enable_mkldnn ( ) <TAB> config. set_cpu_math_library_num_threads ( args. cpu_num_threads ) <TAB> if args. enable_profile : <TAB> <TAB> config. enable_profile ( ) <TAB> config. disable_glog_info ( ) <TAB> config. switch_ir_optim ( args. ir_optim ) <TAB> if args. use_tensorrt : <TAB> <TAB> config. enable_tensorrt_engine ( <TAB> <TAB> <TAB> precision_mode = Config. Precision. Half <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> else Config. Precision. Float32, <TAB> <TAB> <TAB> max_batch_size = args. batch_size, <TAB> <TAB> ) <TAB> config. enable_memory_optim ( ) <TAB> <TAB> config. switch_use_feed_fetch_ops ( False ) <TAB> predictor = create_predictor ( config ) <TAB> return predictor",False,args.use_fp16,args.batch_size > 0,0.6535663604736328
|
||
|
568,"def do_debug ( self, args ) : <TAB> """"""Implementation of 'coverage debug'."""""" <TAB> if not args : <TAB> <TAB> show_help ( ""What information would you like: config, data, sys, premain?"" ) <TAB> <TAB> return ERR <TAB> for info in args : <TAB> <TAB> if info == ""sys"" : <TAB> <TAB> <TAB> sys_info = self. coverage. sys_info ( ) <TAB> <TAB> <TAB> print ( info_header ( ""sys"" ) ) <TAB> <TAB> <TAB> for line in info_formatter ( sys_info ) : <TAB> <TAB> <TAB> <TAB> print ( "" %s"" % line ) <TAB> <TAB> elif info == ""data"" : <TAB> <TAB> <TAB> self. coverage. load ( ) <TAB> <TAB> <TAB> data = self. coverage. get_data ( ) <TAB> <TAB> <TAB> print ( info_header ( ""data"" ) ) <TAB> <TAB> <TAB> print ( ""path: %s"" % self. coverage. get_data ( ). data_filename ( ) ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> print ( ""has_arcs: %r"" % data. has_arcs ( ) ) <TAB> <TAB> <TAB> <TAB> summary = line_counts ( data, fullpath = True ) <TAB> <TAB> <TAB> <TAB> filenames = sorted ( summary. keys ( ) ) <TAB> <TAB> <TAB> <TAB> print ( ""\n%d files:"" % len ( filenames ) ) <TAB> <TAB> <TAB> <TAB> for f in filenames : <TAB> <TAB> <TAB> <TAB> <TAB> line = ""%s: %d lines"" % ( f, summary [ f ] ) <TAB> <TAB> <TAB> <TAB> <TAB> plugin = data. file_tracer ( f ) <TAB> <TAB> <TAB> <TAB> <TAB> if plugin : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> line += "" [%s]"" % plugin <TAB",True,data,data,0.6876575350761414
|
||
|
569,"def _execute_mock_call ( self, /, * args, ** kwargs ) : <TAB> <TAB> <TAB> _call = _Call ( ( args, kwargs ), two = True ) <TAB> self. await_count += 1 <TAB> self. await_args = _call <TAB> self. await_args_list. append ( _call ) <TAB> effect = self. side_effect <TAB> if effect is not None : <TAB> <TAB> if _is_exception ( effect ) : <TAB> <TAB> <TAB> raise effect <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> result = next ( effect ) <TAB> <TAB> <TAB> except StopIteration : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> raise StopAsyncIteration <TAB> <TAB> <TAB> if _is_exception ( result ) : <TAB> <TAB> <TAB> <TAB> raise result <TAB> <TAB> elif iscoroutinefunction ( effect ) : <TAB> <TAB> <TAB> result = await effect ( * args, ** kwargs ) <TAB> <TAB> else : <TAB> <TAB> <TAB> result = effect ( * args, ** kwargs ) <TAB> <TAB> if result is not DEFAULT : <TAB> <TAB> <TAB> return result <TAB> if self. _mock_return_value is not DEFAULT : <TAB> <TAB> return self. return_value <TAB> if self. _mock_wraps is not None : <TAB> <TAB> if iscoroutinefunction ( self. _mock_wraps ) : <TAB> <TAB> <TAB> return await self. _mock_wraps ( * args, ** kwargs ) <TAB> <TAB> return self. _mock_wraps ( * args, ** kwargs ) <TAB> return self. return_value",False,not _callable(effect),_is_async_iteration(effect),0.6560366153717041
|
||
|
570,"def createform ( self, xfields ) : <TAB> formstyle = self. formstyle <TAB> if isinstance ( formstyle, basestring ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> formstyle = SQLFORM. formstyles [ formstyle ] <TAB> <TAB> else : <TAB> <TAB> <TAB> raise RuntimeError ( ""formstyle not found"" ) <TAB> if callable ( formstyle ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> table = formstyle ( self, xfields ) <TAB> <TAB> <TAB> for id, a, b, c in xfields : <TAB> <TAB> <TAB> <TAB> self. field_parent [ id ] = ( <TAB> <TAB> <TAB> <TAB> <TAB> getattr ( b, ""parent"", None ) if isinstance ( b, XmlComponent ) else None <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> except TypeError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> table = TABLE ( ) <TAB> <TAB> <TAB> for id, a, b, c in xfields : <TAB> <TAB> <TAB> <TAB> newrows = formstyle ( id, a, b, c ) <TAB> <TAB> <TAB> <TAB> self. field_parent [ id ] = ( <TAB> <TAB> <TAB> <TAB> <TAB> getattr ( b, ""parent"", None ) if isinstance ( b, XmlComponent ) else None <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> if type ( newrows ). __name__!= ""tuple"" : <TAB> <TAB> <TAB> <TAB> <TAB> newrows = [ newrows ] <TAB> <TAB> <TAB> <TAB> for newrow in newrows : <TAB> <TAB> <TAB> <TAB> <TAB> table. append ( newrow ) <TAB> else : <TAB> <TAB> raise RuntimeError ( ""formstyle not supported"" ) <TAB> return table",False,formstyle in SQLFORM.formstyles,"hasattr(formstyle, '__formstyle__')",0.661724328994751
|
||
|
571,"def push_solution_to_instance ( self ) : <TAB> scenario_instance = self. _instance <TAB> scenariotree_sm_bySymbol = scenario_instance. _ScenarioTreeSymbolMap. bySymbol <TAB> for tree_node in self. _node_list : <TAB> <TAB> stage_name = tree_node. _stage. name <TAB> <TAB> cost_variable_name, cost_variable_index = tree_node. _stage. _cost_variable <TAB> <TAB> stage_cost_component = self. _instance. find_component ( cost_variable_name ) [ <TAB> <TAB> <TAB> cost_variable_index <TAB> <TAB> ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if not stage_cost_component. is_expression ( ) : <TAB> <TAB> <TAB> stage_cost_component. value = self. _stage_costs [ stage_name ] <TAB> for tree_node in self. _node_list : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for variable_id, var_value in iteritems ( self. _x [ tree_node. _name ] ) : <TAB> <TAB> <TAB> compdata = scenariotree_sm_bySymbol [ variable_id ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> compdata. value = var_value <TAB> <TAB> for variable_id in self. _fixed [ tree_node. _name ] : <TAB> <TAB> <TAB> vardata = scenariotree_sm_bySymbol [ variable_id ] <TAB> <TAB> <TAB> vardata. fix ( ) <TAB> <TAB> for variable_id in self. _stale [ tree_node. _name ] : <TAB> <TAB> <TAB> vardata = scenariotree_sm_bySymbol [ variable_id ] <TAB> <TAB> <TAB> vardata. stale = True",False,not compdata.is_expression(),self._fixed,0.6484264135360718
|
||
|
572,"def change_sel ( self ) : <TAB> """"""Change the view's selections."""""" <TAB> if self. alter_select and len ( self. sels ) > 0 : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. view. show ( self. sels [ 0 ] ) <TAB> <TAB> self. view. sel ( ). clear ( ) <TAB> <TAB> self. view. sel ( ). add_all ( self. sels )",False,self.multi_select is False,len(self.sels) > 0,0.6536827087402344
|
||
|
573,"def get_type ( type_ref ) : <TAB> kind = type_ref. get ( ""kind"" ) <TAB> if kind == TypeKind. LIST : <TAB> <TAB> item_ref = type_ref. get ( ""ofType"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise Exception ( ""Decorated type deeper than introspection query."" ) <TAB> <TAB> return GraphQLList ( get_type ( item_ref ) ) <TAB> elif kind == TypeKind. NON_NULL : <TAB> <TAB> nullable_ref = type_ref. get ( ""ofType"" ) <TAB> <TAB> if not nullable_ref : <TAB> <TAB> <TAB> raise Exception ( ""Decorated type deeper than introspection query."" ) <TAB> <TAB> return GraphQLNonNull ( get_type ( nullable_ref ) ) <TAB> return get_named_type ( type_ref [ ""name"" ] )",True,not item_ref,not item_ref,0.6661830544471741
|
||
|
574,"def gotAvatar ( avatar ) : <TAB> if avatar. realm is not None : <TAB> <TAB> raise ewords. AlreadyLoggedIn ( ) <TAB> for iface in interfaces : <TAB> <TAB> facet = iface ( avatar, None ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> avatar. loggedIn ( self, mind ) <TAB> <TAB> <TAB> mind. name = avatarId <TAB> <TAB> <TAB> mind. realm = self <TAB> <TAB> <TAB> mind. avatar = avatar <TAB> <TAB> <TAB> return iface, facet, self. logoutFactory ( avatar, facet ) <TAB> raise NotImplementedError ( self, interfaces )",False,facet is not None,facet.name != self.name,0.6652309894561768
|
||
|
575,def contains_only_whitespace ( node ) : <TAB> if is_tag ( node ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if not any ( [ unicode ( s ). strip ( ) for s in node. contents ] ) : <TAB> <TAB> <TAB> <TAB> return True <TAB> return False,False,not any([not is_text(s) for s in node.contents]),node.contents and node.contents[0] != '\n',0.6514248251914978
|
||
|
576,"def validate_cell ( self, cell ) : <TAB> super ( MetadataValidatorV2, self ). validate_cell ( cell ) <TAB> if ""nbgrader"" not in cell. metadata : <TAB> <TAB> return <TAB> meta = cell. metadata [ ""nbgrader"" ] <TAB> grade = meta [ ""grade"" ] <TAB> solution = meta [ ""solution"" ] <TAB> locked = meta [ ""locked"" ] <TAB> <TAB> if ""cell_type"" in meta : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. log. warning ( <TAB> <TAB> <TAB> <TAB> ""Cell type has changed from {} to {}!"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> meta [ ""cell_type"" ], cell. cell_type <TAB> <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> <TAB> cell, <TAB> <TAB> <TAB> ) <TAB> <TAB> if grade or solution or locked : <TAB> <TAB> if ""grade_id"" not in meta : <TAB> <TAB> <TAB> raise ValidationError ( <TAB> <TAB> <TAB> <TAB> ""nbgrader cell does not have a grade_id: {}"". format ( cell. source ) <TAB> <TAB> <TAB> ) <TAB> <TAB> if meta [ ""grade_id"" ] == """" : <TAB> <TAB> <TAB> raise ValidationError ( ""grade_id is empty"" ) <TAB> <TAB> if grade : <TAB> <TAB> if ""points"" not in meta : <TAB> <TAB> <TAB> raise ValidationError ( <TAB> <TAB> <TAB> <TAB> ""nbgrader cell '{}' does not have points"". format ( meta [ ""grade_id"" ] ) <TAB> <TAB> <TAB> ) <TAB> <TAB> if cell. cell_type == ""markdown"" and grade and not solution : <TAB> <TAB> raise ValidationError ( <TAB> <TAB> <TAB> ""Markdown grade cell '{}' is not marked as a solution cell"". format ( <TAB> <TAB> <TAB> <TAB> meta [ ""grade_id"" ] <TAB> <TAB>",False,meta['cell_type'] != cell.cell_type,locked,0.6515710949897766
|
||
|
577,"def __method_playback ( self, symbol, * args, ** dargs ) : <TAB> if self. _debug : <TAB> <TAB> print >> sys. __stdout__, ( <TAB> <TAB> <TAB> "" * Mock call: "" + _dump_function_call ( symbol, args, dargs ) <TAB> <TAB> ) <TAB> if len ( self. recording )!= 0 : <TAB> <TAB> <TAB> <TAB> func_call = self. recording [ 0 ] <TAB> <TAB> if func_call. symbol!= symbol : <TAB> <TAB> <TAB> msg = ""Unexpected call: %s\nExpected: %s"" % ( <TAB> <TAB> <TAB> <TAB> _dump_function_call ( symbol, args, dargs ), <TAB> <TAB> <TAB> <TAB> func_call, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> self. _append_error ( msg ) <TAB> <TAB> <TAB> return None <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> msg = ""Incorrect call: %s\nExpected: %s"" % ( <TAB> <TAB> <TAB> <TAB> _dump_function_call ( symbol, args, dargs ), <TAB> <TAB> <TAB> <TAB> func_call, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> self. _append_error ( msg ) <TAB> <TAB> <TAB> return None <TAB> <TAB> <TAB> <TAB> self. recording. popleft ( ) <TAB> <TAB> if func_call. error : <TAB> <TAB> <TAB> raise func_call. error <TAB> <TAB> else : <TAB> <TAB> <TAB> return func_call. return_obj <TAB> else : <TAB> <TAB> msg = ""unexpected call: %s"" % ( _dump_function_call ( symbol, args, dargs ) ) <TAB> <TAB> self. _append_error ( msg ) <TAB> <TAB> return None",False,"not func_call.match(*args, **dargs)",symbol.has_terminal(),0.6471517086029053
|
||
|
578,"def __next__ ( self ) : <TAB> if not self. has_catalogs : <TAB> <TAB> raise StopIteration ( ""No catalogs"" ) <TAB> if self. current_catalog_index >= len ( self. manifest. catalog_paths ) : <TAB> <TAB> raise StopIteration ( ""No more catalogs"" ) <TAB> if self. current_catalog is None : <TAB> <TAB> current_catalog_path = os. path. join ( <TAB> <TAB> <TAB> self. manifest. base_path, <TAB> <TAB> <TAB> self. manifest. catalog_paths [ self. current_catalog_index ], <TAB> <TAB> ) <TAB> <TAB> self. current_catalog = Catalog ( <TAB> <TAB> <TAB> current_catalog_path, read_only = self. manifest. read_only <TAB> <TAB> ) <TAB> <TAB> self. current_catalog. seekable. seek_line_start ( 1 ) <TAB> contents = self. current_catalog. seekable. readline ( ) <TAB> if contents is not None and len ( contents ) > 0 : <TAB> <TAB> <TAB> <TAB> current_index = self. current_index <TAB> <TAB> self. current_index += 1 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return self. __next__ ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> record = json. loads ( contents ) <TAB> <TAB> <TAB> <TAB> return record <TAB> <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> <TAB> print ( ""Ignoring record at index %s"" % ( current_index ) ) <TAB> <TAB> <TAB> <TAB> return self. __next__ ( ) <TAB> else : <TAB> <TAB> self. current_catalog = None <TAB> <TAB> self. current_catalog_index += 1 <TAB> <TAB> return self. __next__ ( )",False,current_index in self.manifest.deleted_indexes,contents == None,0.6504038572311401
|
||
|
579,"def TryMerge ( self, d ) : <TAB> while d. avail ( ) > 0 : <TAB> <TAB> tt = d. getVarInt32 ( ) <TAB> <TAB> if tt == 10 : <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. add_subscription ( ). TryMerge ( tmp ) <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.6789340972900391
|
||
|
580,"def filter_errors ( self, errors : List [ str ] ) -> List [ str ] : <TAB> real_errors : List [ str ] = list ( ) <TAB> current_file = __file__ <TAB> current_path = os. path. split ( current_file ) <TAB> for line in errors : <TAB> <TAB> line = line. strip ( ) <TAB> <TAB> if not line : <TAB> <TAB> <TAB> continue <TAB> <TAB> fn, lno, lvl, msg = self. parse_trace_line ( line ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> _path = os. path. split ( fn ) <TAB> <TAB> <TAB> if _path [ - 1 ]!= current_path [ - 1 ] : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> real_errors. append ( line ) <TAB> return real_errors",False,fn is not None,fn,0.6597561240196228
|
||
|
581,"def parser_info ( self, video, info, stream, lvid, uid ) : <TAB> if not ""allot"" in info or lvid!= info [ ""id"" ] : <TAB> <TAB> return <TAB> stream_id = self. types_2_id [ stream ] <TAB> stream_profile = self. id_2_profile [ stream_id ] <TAB> host = info [ ""allot"" ] <TAB> data = info [ ""data"" ] <TAB> size = sum ( map ( int, data [ ""clipsBytes"" ] ) ) <TAB> urls = [ ] <TAB> assert len ( data [ ""clipsURL"" ] ) == len ( data [ ""clipsBytes"" ] ) == len ( data [ ""su"" ] ) <TAB> for ( <TAB> <TAB> new, <TAB> <TAB> ck, <TAB> ) in zip ( data [ ""su"" ], data [ ""ck"" ] ) : <TAB> <TAB> params = { <TAB> <TAB> <TAB> ""ch"" : data [ ""ch"" ], <TAB> <TAB> <TAB> ""num"" : data [ ""num"" ], <TAB> <TAB> <TAB> ""new"" : new, <TAB> <TAB> <TAB> ""key"" : ck, <TAB> <TAB> <TAB> ""uid"" : uid, <TAB> <TAB> <TAB> ""prod"" : ""h5n"", <TAB> <TAB> <TAB> ""pt"" : 1, <TAB> <TAB> <TAB> ""pg"" : 2, <TAB> <TAB> } <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> cdnurl = ""https://{}/ip?{}"". format ( host, urlencode ( params ) ) <TAB> <TAB> <TAB> url = json. loads ( get_content ( cdnurl ) ) [ ""servers"" ] [ 0 ] [ ""url"" ] <TAB> <TAB> else : <TAB> <TAB> <TAB> url = new <TAB> <TAB> urls. append ( url ) <TAB> video. streams [ stream_id ] = { <TAB> <TAB> ""container"" : ""mp4"", <TAB> <TAB> ""video_profile",False,urlparse(new).netloc == '',host,0.6574864983558655
|
||
|
582,"def parseImpl ( self, instring, loc, doActions = True ) : <TAB> try : <TAB> <TAB> loc, tokens = self. expr. _parse ( instring, loc, doActions, callPreParse = False ) <TAB> except ( ParseException, IndexError ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if self. expr. resultsName : <TAB> <TAB> <TAB> <TAB> tokens = ParseResults ( [ self. defaultValue ] ) <TAB> <TAB> <TAB> <TAB> tokens [ self. expr. resultsName ] = self. defaultValue <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> tokens = [ self. defaultValue ] <TAB> <TAB> else : <TAB> <TAB> <TAB> tokens = [ ] <TAB> return loc, tokens",False,self.defaultValue is not self.__optionalNotMatched,self.defaultValue,0.6559591293334961
|
||
|
583,"def validate_configuration ( self, configuration : Optional [ ExpectationConfiguration ] ) : <TAB> """"""Validating that user has inputted a value set and that configuration has been initialized"""""" <TAB> super ( ). validate_configuration ( configuration ) <TAB> try : <TAB> <TAB> assert ""value_set"" in configuration. kwargs, ""value_set is required"" <TAB> <TAB> assert isinstance ( <TAB> <TAB> <TAB> configuration. kwargs [ ""value_set"" ], ( list, set, dict ) <TAB> <TAB> ), ""value_set must be a list or a set"" <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> assert ( <TAB> <TAB> <TAB> <TAB> ""$PARAMETER"" in configuration. kwargs [ ""value_set"" ] <TAB> <TAB> <TAB> ), 'Evaluation Parameter dict for value_set kwarg must have ""$PARAMETER"" key' <TAB> except AssertionError as e : <TAB> <TAB> raise InvalidExpectationConfigurationError ( str ( e ) ) <TAB> return True",False,"isinstance(configuration.kwargs['value_set'], dict)",configuration.kwargs and 'value_set' in configuration.kwargs,0.6528669595718384
|
||
|
584,"def post ( self, request, * args, ** kwargs ) : <TAB> settings_form = self. get_settings_form ( ) <TAB> children_formset = self. get_children_formset ( ) <TAB> data = request. POST. copy ( ) <TAB> if settings_form : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> settings = settings_form. cleaned_data <TAB> <TAB> <TAB> data [ ""settings"" ] = self. module. dump_settings ( settings ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return self. form_invalid ( self. get_form ( self. get_form_class ( ) ) ) <TAB> if children_formset : <TAB> <TAB> if children_formset. is_valid ( ) : <TAB> <TAB> <TAB> self. module. children = self. clean_children_data ( <TAB> <TAB> <TAB> <TAB> children_formset. cleaned_data <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> data [ ""children"" ] = self. module. dump_children ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return self. form_invalid ( self. get_form ( self. get_form_class ( ) ) ) <TAB> request. POST = data <TAB> return super ( UpdateDashboardModuleView, self ). post ( request, * args, ** kwargs )",True,settings_form.is_valid(),settings_form.is_valid(),0.6488329172134399
|
||
|
585,"def _safe_coalesce ( t ) : <TAB> tc = t. coalesce ( ) <TAB> value_map = { } <TAB> for idx, val in zip ( t. _indices ( ). t ( ), t. _values ( ) ) : <TAB> <TAB> idx_tup = tuple ( idx ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> value_map [ idx_tup ] += val <TAB> <TAB> else : <TAB> <TAB> <TAB> value_map [ idx_tup ] = val. clone ( ) if torch. is_tensor ( val ) else val <TAB> new_indices = sorted ( list ( value_map. keys ( ) ) ) <TAB> new_values = [ value_map [ idx ] for idx in new_indices ] <TAB> if t. _values ( ). dim ( ) < 2 : <TAB> <TAB> new_values = t. _values ( ). new_tensor ( new_values ) <TAB> else : <TAB> <TAB> new_values = torch. stack ( new_values ) <TAB> new_indices = t. _indices ( ). new_tensor ( new_indices ). t ( ) <TAB> tg = t. new ( new_indices, new_values, t. size ( ) ) <TAB> assert ( tc. _indices ( ) == tg. _indices ( ) ). all ( ) <TAB> assert ( tc. _values ( ) == tg. _values ( ) ). all ( ) <TAB> return tg",True,idx_tup in value_map,idx_tup in value_map,0.6547656059265137
|
||
|
586,"def updateToolForHostInformation ( self, update = True ) : <TAB> <TAB> if self. validateCommandTabs ( <TAB> <TAB> self. hostActionNameText, self. hostLabelText, self. hostCommandText <TAB> ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> pass <TAB> <TAB> else : <TAB> <TAB> <TAB> self. updateHostActions ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. hostTableRow = self. toolForHostsTableWidget. currentRow ( ) <TAB> <TAB> self. hostLabelText. setReadOnly ( False ) <TAB> <TAB> if self. toolForHostsTableWidget. item ( self. hostTableRow, 0 ) is not None : <TAB> <TAB> <TAB> key = self. toolForHostsTableWidget. item ( self. hostTableRow, 0 ). text ( ) <TAB> <TAB> <TAB> for tool in self. settings. hostActions : <TAB> <TAB> <TAB> <TAB> if tool [ 1 ] == key : <TAB> <TAB> <TAB> <TAB> <TAB> self. hostActionNameText. setText ( tool [ 1 ] ) <TAB> <TAB> <TAB> <TAB> <TAB> self. hostLabelText. setText ( tool [ 0 ] ) <TAB> <TAB> <TAB> <TAB> <TAB> self. hostCommandText. setText ( tool [ 2 ] ) <TAB> else : <TAB> <TAB> self. toolForHostsTableWidget. selectRow ( self. hostTableRow )",False,self.hostTableRow == -1 or update == False,update,0.6565169095993042
|
||
|
587,"def slo ( environ, start_response, user ) : <TAB> <TAB> client = environ [ ""repoze.who.plugins"" ] [ ""saml2auth"" ] <TAB> sc = client. saml_client <TAB> if ""QUERY_STRING"" in environ : <TAB> <TAB> query = parse_qs ( environ [ ""QUERY_STRING"" ] ) <TAB> <TAB> logger. info ( ""query: %s"", query ) <TAB> <TAB> try : <TAB> <TAB> <TAB> response = sc. parse_logout_request_response ( <TAB> <TAB> <TAB> <TAB> query [ ""SAMLResponse"" ] [ 0 ], binding = BINDING_HTTP_REDIRECT <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> logger. info ( ""LOGOUT response parsed OK"" ) <TAB> <TAB> except KeyError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> response = None <TAB> <TAB> if response is None : <TAB> <TAB> <TAB> request = sc. lo <TAB> headers = [ ] <TAB> delco = delete_cookie ( environ, ""pysaml2"" ) <TAB> if delco : <TAB> <TAB> headers. append ( delco ) <TAB> resp = Redirect ( ""/done"", headers = headers ) <TAB> return resp ( environ, start_response )",False,response,response is True,0.6979637145996094
|
||
|
588,"def _probe ( self ) : <TAB> """"""Copy all probed signals to buffers."""""" <TAB> self. _probe_step_time ( ) <TAB> for probe in self. model. probes : <TAB> <TAB> period = 1 if probe. sample_every is None else probe. sample_every / self. dt <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> tmp = self. signals [ self. model. sig [ probe ] [ ""in"" ] ]. copy ( ) <TAB> <TAB> <TAB> self. _probe_outputs [ probe ]. append ( tmp )",False,self.n_steps % period < 1,period > 0,0.6609293222427368
|
||
|
589,"def services_to_report ( self ) : <TAB> services = self. _parse_services ( self. default ( ""REPORT_SERVICES"", """" ), None ) <TAB> for service in services : <TAB> <TAB> if service. protocol == ""rpc"" : <TAB> <TAB> <TAB> raise ServiceError ( f""bad protocol for REPORT_SERVICES: {service.protocol}"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> ip_addr = service. host <TAB> <TAB> <TAB> if ( <TAB> <TAB> <TAB> <TAB> ip_addr. is_multicast <TAB> <TAB> <TAB> <TAB> or ip_addr. is_unspecified <TAB> <TAB> <TAB> <TAB> or ( ip_addr. is_private and self. peer_announce ) <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> raise ServiceError ( f""bad IP address for REPORT_SERVICES: {ip_addr}"" ) <TAB> <TAB> elif service. host. lower ( ) == ""localhost"" : <TAB> <TAB> <TAB> raise ServiceError ( f""bad host for REPORT_SERVICES: {service.host}"" ) <TAB> return services",False,"isinstance(service.host, (IPv4Address, IPv6Address))",service.host == None,0.6529442071914673
|
||
|
590,"def next_ohlcv ( self ) -> pd. DataFrame : <TAB> if self. _has_loaded_historical : <TAB> <TAB> frame = self. data_frame [ self. _current_index ] <TAB> <TAB> self. _current_index += 1 <TAB> <TAB> return frame <TAB> data = self. exchange. fetchOHLCV ( <TAB> <TAB> symbol = self. symbol_pair, <TAB> <TAB> timeframe = self. timeframe, <TAB> <TAB> since = self. _current_index, <TAB> <TAB> limit = 1, <TAB> ) <TAB> if len ( data ) : <TAB> <TAB> self. _current_index = data [ len ( data ) - 1 ] [ ""timestamp"" ] <TAB> <TAB> frame = pd. DataFrame ( data, columns = self. in_columns ) <TAB> <TAB> frame = self. prepare_data ( frame ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. data_frame = pd. DataFrame ( None, columns = self. columns ) <TAB> <TAB> self. data_frame = self. data_frame. append ( frame, ignore_index = True ) <TAB> <TAB> return frame <TAB> return None",True,self.data_frame is None,self.data_frame is None,0.653052806854248
|
||
|
591,"def _handle_loaded ( objs ) : <TAB> try : <TAB> <TAB> data_locations = storage_client. get_data_locations ( session_id, keys_to_fetch ) <TAB> <TAB> shared_quota_keys = [ ] <TAB> <TAB> inproc_keys = [ ] <TAB> <TAB> inproc_quota_keys = [ ] <TAB> <TAB> context_dict. update ( zip ( keys_to_fetch, objs ) ) <TAB> <TAB> for k, locations in zip ( keys_to_fetch, data_locations ) : <TAB> <TAB> <TAB> quota_key = build_quota_key ( session_id, k, owner = self. proc_id ) <TAB> <TAB> <TAB> if ( self. proc_id, DataStorageDevice. PROC_MEMORY ) not in locations : <TAB> <TAB> <TAB> <TAB> shared_quota_keys. append ( quota_key ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> inproc_keys. append ( k ) <TAB> <TAB> <TAB> <TAB> inproc_quota_keys. append ( quota_key ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _mem_quota_ref. hold_quotas ( shared_quota_keys, _tell = True ) <TAB> <TAB> if inproc_keys : <TAB> <TAB> <TAB> self. _mem_quota_ref. hold_quotas ( inproc_quota_keys, _tell = True ) <TAB> <TAB> <TAB> if self. _remove_intermediate : <TAB> <TAB> <TAB> <TAB> storage_client. delete ( <TAB> <TAB> <TAB> <TAB> <TAB> session_id, inproc_keys, [ self. _calc_intermediate_device ] <TAB> <TAB> <TAB> <TAB> ) <TAB> finally : <TAB> <TAB> objs [ : ] = [ ]",True,shared_quota_keys,shared_quota_keys,0.6616040468215942
|
||
|
592,"def _cobra_getsock ( self, thr = None ) : <TAB> if self. _cobra_spoolcnt : <TAB> <TAB> sock = self. _cobra_sockpool. get ( ) <TAB> else : <TAB> <TAB> if not thr : <TAB> <TAB> <TAB> thr = currentThread ( ) <TAB> <TAB> tsocks = getattr ( thr, ""cobrasocks"", None ) <TAB> <TAB> if tsocks is None : <TAB> <TAB> <TAB> tsocks = { } <TAB> <TAB> <TAB> thr. cobrasocks = tsocks <TAB> <TAB> sock = tsocks. get ( self. _cobra_slookup ) <TAB> if not sock or sock. trashed : <TAB> <TAB> <TAB> <TAB> sock = self. _cobra_newsock ( ) <TAB> <TAB> <TAB> <TAB> authinfo = self. _cobra_kwargs. get ( ""authinfo"" ) <TAB> <TAB> if authinfo is not None : <TAB> <TAB> <TAB> mtype, rver, data = sock. cobraTransaction ( COBRA_AUTH, """", authinfo ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise CobraAuthException ( ""Authentication Failed!"" ) <TAB> <TAB> if not self. _cobra_spoolcnt : <TAB> <TAB> <TAB> tsocks [ self. _cobra_slookup ] = sock <TAB> return sock",False,mtype != COBRA_AUTH,rver or rver != 0,0.6569886207580566
|
||
|
593,"def get_other ( self, data, items ) : <TAB> is_tuple = False <TAB> if type ( data ) == tuple : <TAB> <TAB> data = list ( data ) <TAB> <TAB> is_tuple = True <TAB> if type ( data ) == list : <TAB> <TAB> m_items = items. copy ( ) <TAB> <TAB> for idx, item in enumerate ( items ) : <TAB> <TAB> <TAB> if item < 0 : <TAB> <TAB> <TAB> <TAB> m_items [ idx ] = len ( data ) - abs ( item ) <TAB> <TAB> for i in sorted ( set ( m_items ), reverse = True ) : <TAB> <TAB> <TAB> if i < len ( data ) and i > - 1 : <TAB> <TAB> <TAB> <TAB> del data [ i ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return tuple ( data ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return data <TAB> else : <TAB> <TAB> return None",True,is_tuple,is_tuple,0.6593594551086426
|
||
|
594,"def __init__ ( self, document_data ) : <TAB> self. document_data = document_data <TAB> self. field_paths = [ ] <TAB> self. deleted_fields = [ ] <TAB> self. server_timestamps = [ ] <TAB> self. array_removes = { } <TAB> self. array_unions = { } <TAB> self. increments = { } <TAB> self. minimums = { } <TAB> self. maximums = { } <TAB> self. set_fields = { } <TAB> self. empty_document = False <TAB> prefix_path = FieldPath ( ) <TAB> iterator = self. _get_document_iterator ( prefix_path ) <TAB> for field_path, value in iterator : <TAB> <TAB> if field_path == prefix_path and value is _EmptyDict : <TAB> <TAB> <TAB> self. empty_document = True <TAB> <TAB> elif value is transforms. DELETE_FIELD : <TAB> <TAB> <TAB> self. deleted_fields. append ( field_path ) <TAB> <TAB> elif value is transforms. SERVER_TIMESTAMP : <TAB> <TAB> <TAB> self. server_timestamps. append ( field_path ) <TAB> <TAB> elif isinstance ( value, transforms. ArrayRemove ) : <TAB> <TAB> <TAB> self. array_removes [ field_path ] = value. values <TAB> <TAB> elif isinstance ( value, transforms. ArrayUnion ) : <TAB> <TAB> <TAB> self. array_unions [ field_path ] = value. values <TAB> <TAB> elif isinstance ( value, transforms. Increment ) : <TAB> <TAB> <TAB> self. increments [ field_path ] = value. value <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> self. maximums [ field_path ] = value. value <TAB> <TAB> elif isinstance ( value, transforms. Minimum ) : <TAB> <TAB> <TAB> self. minimums [ field_path ] = value. value <TAB> <TAB> else : <TAB> <TAB> <TAB> self. field_paths. append ( field_path ) <TAB> <TAB> <TAB> set_field",True,"isinstance(value, transforms.Maximum)","isinstance(value, transforms.Maximum)",0.6532870531082153
|
||
|
595,"def _ParseAndCheckSubOpts ( self ) : <TAB> <TAB> delta = None <TAB> method = ""GET"" <TAB> content_type = """" <TAB> passwd = None <TAB> for o, v in self. sub_opts : <TAB> <TAB> if o == ""-d"" : <TAB> <TAB> <TAB> if delta is not None : <TAB> <TAB> <TAB> <TAB> delta += _DurationToTimeDelta ( v ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> delta = _DurationToTimeDelta ( v ) <TAB> <TAB> elif o == ""-m"" : <TAB> <TAB> <TAB> method = v <TAB> <TAB> elif o == ""-c"" : <TAB> <TAB> <TAB> content_type = v <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> passwd = v <TAB> <TAB> else : <TAB> <TAB> <TAB> self. RaiseInvalidArgumentException ( ) <TAB> if delta is None : <TAB> <TAB> delta = timedelta ( hours = 1 ) <TAB> expiration = calendar. timegm ( ( datetime. utcnow ( ) + delta ). utctimetuple ( ) ) <TAB> if method not in [ ""GET"", ""PUT"", ""DELETE"", ""HEAD"" ] : <TAB> <TAB> raise CommandException ( ""HTTP method must be one of [GET|HEAD|PUT|DELETE]"" ) <TAB> return method, expiration, content_type, passwd",False,o == '-p',o == '-passwd',0.6747341156005859
|
||
|
596,"def exe ( self, ret ) : <TAB> if not ret : <TAB> <TAB> self. assertEqual ( ret, """" ) <TAB> else : <TAB> <TAB> assert os. path. isabs ( ret ), ret <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if POSIX : <TAB> <TAB> <TAB> assert os. path. isfile ( ret ), ret <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. assertTrue ( os. access ( ret, os. X_OK ) )",False,"hasattr(os, 'access') and hasattr(os, 'X_OK')",os.path.isfile(ret),0.6477186679840088
|
||
|
597,"def package_exists ( self, pref ) : <TAB> try : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> path = self. server_store. package ( pref ) <TAB> <TAB> else : <TAB> <TAB> <TAB> path = self. test_server. server_store. package_revisions_root ( pref ) <TAB> <TAB> return self. test_server. server_store. path_exists ( path ) <TAB> except NotFoundException : <TAB> <TAB> return False",False,pref.revision,self.server_store is None,0.6656686067581177
|
||
|
598,"def find_subdomains ( domain, data ) : <TAB> subdomains = set ( ) <TAB> js_urls = set ( ) <TAB> db = Database ( ) <TAB> for infos in data : <TAB> <TAB> jump_history = infos. get ( ""history"" ) <TAB> <TAB> req_url = infos. get ( ""url"" ) <TAB> <TAB> subdomains. update ( find_in_history ( domain, req_url, jump_history ) ) <TAB> <TAB> rsp_html = db. get_resp_by_url ( domain, req_url ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> logger. log ( <TAB> <TAB> <TAB> <TAB> ""DEBUG"", f""an abnormal response occurred in the request {req_url}"" <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> continue <TAB> <TAB> subdomains. update ( find_in_resp ( domain, req_url, rsp_html ) ) <TAB> <TAB> js_urls. update ( find_js_urls ( domain, req_url, rsp_html ) ) <TAB> req_data = convert_to_dict ( js_urls ) <TAB> resp_data = request. bulk_request ( domain, req_data, ret = True ) <TAB> while not resp_data. empty ( ) : <TAB> <TAB> _, resp = resp_data. get ( ) <TAB> <TAB> if not isinstance ( resp, Response ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> text = utils. decode_resp_text ( resp ) <TAB> <TAB> subdomains. update ( find_in_resp ( domain, resp. url, text ) ) <TAB> return subdomains",False,not rsp_html,rsp_html,0.6653605103492737
|
||
|
599,"def _allocate_nbd ( self ) : <TAB> if not os. path. exists ( ""/sys/block/nbd0"" ) : <TAB> <TAB> self. error = _ ( ""nbd unavailable: module not loaded"" ) <TAB> <TAB> return None <TAB> while True : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. error = _ ( ""No free nbd devices"" ) <TAB> <TAB> <TAB> return None <TAB> <TAB> device = self. _DEVICES. pop ( ) <TAB> <TAB> if not os. path. exists ( ""/sys/block/%s/pid"" % os. path. basename ( device ) ) : <TAB> <TAB> <TAB> break <TAB> return device",True,not self._DEVICES,not self._DEVICES,0.6696393489837646
|
||
|
600,"def __setattr__ ( self, name, value ) : <TAB> self. __lock__. acquire ( ) <TAB> try : <TAB> <TAB> ident = get_ident ( ) <TAB> <TAB> storage = self. __storage__ <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> storage [ ident ] [ name ] = value <TAB> <TAB> else : <TAB> <TAB> <TAB> storage [ ident ] = { name : value } <TAB> finally : <TAB> <TAB> self. __lock__. release ( )",True,ident in storage,ident in storage,0.6794613599777222
|
||
|
601,"def get_price_list_rate ( args, item_doc, out ) : <TAB> meta = frappe. get_meta ( args. parenttype or args. doctype ) <TAB> if meta. get_field ( ""currency"" ) or args. get ( ""currency"" ) : <TAB> <TAB> pl_details = get_price_list_currency_and_exchange_rate ( args ) <TAB> <TAB> args. update ( pl_details ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> validate_conversion_rate ( args, meta ) <TAB> <TAB> price_list_rate = get_price_list_rate_for ( args, item_doc. name ) or 0 <TAB> <TAB> <TAB> <TAB> if not price_list_rate and item_doc. variant_of : <TAB> <TAB> <TAB> price_list_rate = get_price_list_rate_for ( args, item_doc. variant_of ) <TAB> <TAB> <TAB> <TAB> if not price_list_rate : <TAB> <TAB> <TAB> if args. price_list and args. rate : <TAB> <TAB> <TAB> <TAB> insert_item_price ( args ) <TAB> <TAB> <TAB> return { } <TAB> <TAB> out. price_list_rate = ( <TAB> <TAB> <TAB> flt ( price_list_rate ) <TAB> <TAB> <TAB> * flt ( args. plc_conversion_rate ) <TAB> <TAB> <TAB> / flt ( args. conversion_rate ) <TAB> <TAB> ) <TAB> <TAB> if not out. price_list_rate and args. transaction_type == ""buying"" : <TAB> <TAB> <TAB> from erpnext. stock. doctype. item. item import get_last_purchase_details <TAB> <TAB> <TAB> out. update ( <TAB> <TAB> <TAB> <TAB> get_last_purchase_details ( <TAB> <TAB> <TAB> <TAB> <TAB> item_doc. name, args. name, args. conversion_rate <TAB> <TAB> <TAB> <TAB",False,meta.get_field('currency'),item_doc.variant_of,0.6538912057876587
|
||
|
602,"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 ftype == TType. STRUCT : <TAB> <TAB> <TAB> <TAB> self. success = ExecStats. ttypes. TExecSummary ( ) <TAB> <TAB> <TAB> <TAB> self. success. read ( iprot ) <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. error = beeswaxd. ttypes. QueryNotFoundException ( ) <TAB> <TAB> <TAB> <TAB> self. error. read ( iprot ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> if ftype == TType. STRUCT : <TAB> <TAB> <TAB> <TAB> self. error2 = beeswaxd. ttypes. BeeswaxException ( ) <TAB> <TAB> <TAB> <TAB> self. error2. read ( iprot ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <",True,fid == 2,fid == 2,0.6789374351501465
|
||
|
603,"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. id = iprot. readI64 ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif fid == 2 : <TAB> <TAB> <TAB> if ftype == TType. I32 : <TAB> <TAB> <TAB> <TAB> self. state = iprot. readI32 ( ) <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. user = 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. hostname = iprot. readString ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <",False,ftype == TType.STRING,fid == 5,0.6610672473907471
|
||
|
604,"def validate_arguments ( args ) : <TAB> if args. num_pss < 1 : <TAB> <TAB> print ( ""Value error: must have ore than one parameter servers."" ) <TAB> <TAB> exit ( 1 ) <TAB> if not GPU_IDS : <TAB> <TAB> num_cpus = multiprocessing. cpu_count ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> ""Value error: there are %s available CPUs but you are requiring %s."" <TAB> <TAB> <TAB> <TAB> % ( num_cpus, args. cpu_trainers ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> exit ( 1 ) <TAB> if not os. path. isfile ( args. file ) : <TAB> <TAB> print ( ""Value error: model trainning file does not exist"" ) <TAB> <TAB> exit ( 1 )",False,args.cpu_trainers > num_cpus,args.num_cpus > 0 and args.cpu_trainers > 0,0.6555589437484741
|
||
|
605,"def KoUserEnviron ( startupEnvFileName = None ) : <TAB> koEnviron = components. classes [ ""@activestate.com/koUserEnviron;1"" ]. createInstance ( <TAB> <TAB> components. interfaces. koIUserEnviron <TAB> ) <TAB> if startupEnvFileName : <TAB> <TAB> environ = UnwrapObject ( koEnviron ) <TAB> <TAB> environ. __init__ ( startupEnvFileName ) <TAB> <TAB> current_encoding = locale. getlocale ( ) [ 1 ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if sys. platform. startswith ( ""win"" ) : <TAB> <TAB> <TAB> <TAB> current_encoding = ""mbcs"" <TAB> <TAB> <TAB> elif sys. platform. startswith ( ""darwin"" ) : <TAB> <TAB> <TAB> <TAB> current_encoding = ""mac-roman"" <TAB> <TAB> <TAB> elif sys. platform. startswith ( ""linux"" ) : <TAB> <TAB> <TAB> <TAB> current_encoding = ""utf-8"" <TAB> <TAB> environ. startupEnvironEncoding = current_encoding <TAB> return koEnviron",False,not current_encoding,current_encoding,0.6557108163833618
|
||
|
606,"def make_table ( items ) : <TAB> if isinstance ( items, dict ) : <TAB> <TAB> items = items. items ( ) <TAB> <TAB> items. sort ( ) <TAB> rows = [ ] <TAB> i = 0 <TAB> for name, value in items : <TAB> <TAB> i += 1 <TAB> <TAB> out = StringIO ( ) <TAB> <TAB> try : <TAB> <TAB> <TAB> pprint. pprint ( value, out ) <TAB> <TAB> except Exception as e : <TAB> <TAB> <TAB> print ( ""Error: %s"" % e, file = out ) <TAB> <TAB> value = html_quote ( out. getvalue ( ) ) <TAB> <TAB> if len ( value ) > 100 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> orig_value = value <TAB> <TAB> <TAB> value = value [ : 100 ] <TAB> <TAB> <TAB> value += '<a class=""switch_source"" style=""background-color: #999"" href=""#"" onclick=""return expandLong(this)"">...</a>' <TAB> <TAB> <TAB> value += '<span style=""display: none"">%s</span>' % orig_value [ 100 : ] <TAB> <TAB> value = formatter. make_wrappable ( value ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> attr ='class=""even""' <TAB> <TAB> else : <TAB> <TAB> <TAB> attr ='class=""odd""' <TAB> <TAB> rows. append ( <TAB> <TAB> <TAB> '<tr%s style=""vertical-align: top;""><td>' <TAB> <TAB> <TAB> '<b>%s</b></td><td style=""overflow: auto"">%s<td></tr>' <TAB> <TAB> <TAB> % ( attr, html_quote ( name ), preserve_whitespace ( value, quote = False ) ) <TAB> <TAB> ) <TAB> return ""<table>%s</table>"" % ( ""\n"". join ( rows ) )",False,i % 2,"hasattr(value, '__html__')",0.6779868006706238
|
||
|
607,"def test_ml_sigma ( ) : <TAB> if debug_mode : <TAB> <TAB> if ""Sigma_u"" not in to_test : <TAB> <TAB> <TAB> return <TAB> <TAB> print ( ""\n\nSIGMA_U"", 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> exog = results_sm_exog [ ds ] [ dt ]. exog is not None <TAB> <TAB> <TAB> exog_coint = results_sm_exog_coint [ ds ] [ dt ]. exog_coint is not None <TAB> <TAB> <TAB> err_msg = build_err_msg ( ds, dt, ""Sigma_u"" ) <TAB> <TAB> <TAB> obtained = results_sm [ ds ] [ dt ]. sigma_u <TAB> <TAB> <TAB> obtained_exog = results_sm_exog [ ds ] [ dt ]. sigma_u <TAB> <TAB> <TAB> obtained_exog_coint = results_sm_exog_coint [ ds ] [ dt ]. sigma_u <TAB> <TAB> <TAB> desired = results_ref [ ds ] [ dt ] [ ""est"" ] [ ""Sigma_u"" ] <TAB> <TAB> <TAB> assert_allclose ( obtained, desired, rtol, atol, False, err_msg ) <TAB> <TAB> <TAB> if exog : <TAB> <TAB> <TAB> <TAB> assert_equal ( obtained_exog, obtained, ""WITH EXOG"" + err_msg ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> assert_equal ( obtained_exog_coint, obtained, ""WITH EXOG_COINT"" + err_msg )",False,exog_coint,coint,0.666644811630249
|
||
|
608,"def test_sortagrad_trainable_with_batch_bins ( module ) : <TAB> args = make_arg ( sortagrad = 1 ) <TAB> idim = 10 <TAB> odim = 5 <TAB> dummy_json = make_dummy_json ( 2, [ 3, 5 ], [ 3, 5 ], idim = idim, odim = odim ) <TAB> if module == ""pytorch"" : <TAB> <TAB> import espnet. nets. pytorch_backend. e2e_asr as m <TAB> else : <TAB> <TAB> import espnet. nets. chainer_backend. e2e_asr as m <TAB> batch_elems = 2000 <TAB> batchset = make_batchset ( dummy_json, batch_bins = batch_elems, shortest_first = True ) <TAB> for batch in batchset : <TAB> <TAB> n = 0 <TAB> <TAB> for uttid, info in batch : <TAB> <TAB> <TAB> ilen = int ( info [ ""input"" ] [ 0 ] [ ""shape"" ] [ 0 ] ) <TAB> <TAB> <TAB> olen = int ( info [ ""output"" ] [ 0 ] [ ""shape"" ] [ 0 ] ) <TAB> <TAB> <TAB> n += ilen * idim + olen * odim <TAB> <TAB> assert olen < batch_elems <TAB> model = m. E2E ( idim, odim, args ) <TAB> for batch in batchset : <TAB> <TAB> loss = model ( * convert_batch ( batch, module, idim = idim, odim = odim ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> loss [ 0 ]. backward ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> loss. backward ( ) <TAB> with torch. no_grad ( ), chainer. no_backprop_mode ( ) : <TAB> <TAB> in_data = np. random. randn ( 10, idim ) <TAB> <TAB> model. recognize ( in_data, args, args. char",False,"isinstance(loss, tuple)",sortagrad == 1,0.6531214714050293
|
||
|
609,"def handleEvent ( self, event ) : <TAB> eventName = event. eventType <TAB> srcModuleName = event. module <TAB> eventData = event. data <TAB> parentEvent = event <TAB> if self. errorState : <TAB> <TAB> return None <TAB> self. sf. debug ( f""Received event, {eventName}, from {srcModuleName}"" ) <TAB> if self. opts [ ""api_key"" ] == """" : <TAB> <TAB> self. sf. error ( ""You enabled sfp_honeypot but did not set an API key!"" ) <TAB> <TAB> self. errorState = True <TAB> <TAB> return None <TAB> if eventData in self. results : <TAB> <TAB> return None <TAB> self. results [ eventData ] = True <TAB> if eventName == ""NETBLOCK_OWNER"" : <TAB> <TAB> if not self. opts [ ""netblocklookup"" ] : <TAB> <TAB> <TAB> return None <TAB> <TAB> else : <TAB> <TAB> <TAB> if IPNetwork ( eventData ). prefixlen < self. opts [ ""maxnetblock"" ] : <TAB> <TAB> <TAB> <TAB> self. sf. debug ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Network size bigger than permitted: "" <TAB> <TAB> <TAB> <TAB> <TAB> + str ( IPNetwork ( eventData ). prefixlen ) <TAB> <TAB> <TAB> <TAB> <TAB> + "" > "" <TAB> <TAB> <TAB> <TAB> <TAB> + str ( self. opts [ ""maxnetblock"" ] ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> return None <TAB> if eventName == ""NETBLOCK_MEMBER"" : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return None <TAB> <TAB> else : <TAB> <TAB> <TAB> if IPNetwork ( eventData ). prefixlen < self. opts [ ""maxsubnet"" ] : <TAB> <TAB> <TAB> <TAB> self. sf. debug ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Network size bigger",False,not self.opts['subnetlookup'],not self.opts['netsubnet'],0.6654548645019531
|
||
|
610,"def get_state ( self ) : <TAB> """"""See class definition."""""" <TAB> obs = { } <TAB> <TAB> max_speed = self. k. scenario. max_speed ( ) <TAB> max_length = self. k. scenario. length ( ) <TAB> for rl_id in self. k. vehicle. get_rl_ids ( ) : <TAB> <TAB> this_speed = self. k. vehicle. get_speed ( rl_id ) <TAB> <TAB> lead_id = self. k. vehicle. get_leader ( rl_id ) <TAB> <TAB> follower = self. k. vehicle. get_follower ( rl_id ) <TAB> <TAB> if lead_id in [ """", None ] : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> lead_speed = max_speed <TAB> <TAB> <TAB> lead_head = max_length <TAB> <TAB> else : <TAB> <TAB> <TAB> lead_speed = self. k. vehicle. get_speed ( lead_id ) <TAB> <TAB> <TAB> lead_head = self. k. vehicle. get_headway ( lead_id ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> follow_speed = 0 <TAB> <TAB> <TAB> follow_head = max_length <TAB> <TAB> else : <TAB> <TAB> <TAB> follow_speed = self. k. vehicle. get_speed ( follower ) <TAB> <TAB> <TAB> follow_head = self. k. vehicle. get_headway ( follower ) <TAB> <TAB> observation = np. array ( <TAB> <TAB> <TAB> [ <TAB> <TAB> <TAB> <TAB> this_speed / max_speed, <TAB> <TAB> <TAB> <TAB> ( lead_speed - this_speed ) / max_speed, <TAB> <TAB> <TAB> <TAB> lead_head / max_length, <TAB> <TAB> <TAB> <TAB> ( this_speed - follow_speed ) / max_speed, <TAB> <TAB> <TAB> <TAB>",True,"follower in ['', None]","follower in ['', None]",0.6593718528747559
|
||
|
611,"def _real_extract ( self, url ) : <TAB> dj_id = self. _match_id ( url ) <TAB> name = None <TAB> desc = None <TAB> entries = [ ] <TAB> for offset in compat_itertools_count ( start = 0, step = self. _PAGE_SIZE ) : <TAB> <TAB> info = self. query_api ( <TAB> <TAB> <TAB> ""dj/program/byradio?asc=false&limit=%d&radioId=%s&offset=%d"" <TAB> <TAB> <TAB> % ( self. _PAGE_SIZE, dj_id, offset ), <TAB> <TAB> <TAB> dj_id, <TAB> <TAB> <TAB> ""Downloading dj programs - %d"" % offset, <TAB> <TAB> ) <TAB> <TAB> entries. extend ( <TAB> <TAB> <TAB> [ <TAB> <TAB> <TAB> <TAB> self. url_result ( <TAB> <TAB> <TAB> <TAB> <TAB> ""http://music.163.com/#/program?id=%s"" % program [ ""id"" ], <TAB> <TAB> <TAB> <TAB> <TAB> ""NetEaseMusicProgram"", <TAB> <TAB> <TAB> <TAB> <TAB> program [ ""id"" ], <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> for program in info [ ""programs"" ] <TAB> <TAB> <TAB> ] <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> radio = info [ ""programs"" ] [ 0 ] [ ""radio"" ] <TAB> <TAB> <TAB> name = radio [ ""name"" ] <TAB> <TAB> <TAB> desc = radio [ ""desc"" ] <TAB> <TAB> if not info [ ""more"" ] : <TAB> <TAB> <TAB> break <TAB> return self. playlist_result ( entries, dj_id, name, desc )",False,name is None,len(info) > 0,0.6688082218170166
|
||
|
612,"def _test_configuration ( self ) : <TAB> config_path = self. _write_config ( ) <TAB> try : <TAB> <TAB> self. _log. debug ( ""testing configuration"" ) <TAB> <TAB> verboseflag = ""-Q"" <TAB> <TAB> if self. _log. isEnabledFor ( logging. DEBUG ) : <TAB> <TAB> <TAB> verboseflag = ""-v"" <TAB> <TAB> p = subprocess. Popen ( [ self. PATH_SLAPTEST, verboseflag, ""-f"", config_path ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise RuntimeError ( ""configuration test failed"" ) <TAB> <TAB> self. _log. debug ( ""configuration seems ok"" ) <TAB> finally : <TAB> <TAB> os. remove ( config_path )",False,p.wait() != 0,p.returncode != 0,0.660539984703064
|
||
|
613,"def __new__ ( cls, key, secret = None, api_version = DEFAULT_API_VERSION, ** kwargs ) : <TAB> if cls is OpenNebulaNodeDriver : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> cls = OpenNebula_1_4_NodeDriver <TAB> <TAB> elif api_version in [ ""2.0"", ""2.2"" ] : <TAB> <TAB> <TAB> cls = OpenNebula_2_0_NodeDriver <TAB> <TAB> elif api_version in [ ""3.0"" ] : <TAB> <TAB> <TAB> cls = OpenNebula_3_0_NodeDriver <TAB> <TAB> elif api_version in [ ""3.2"" ] : <TAB> <TAB> <TAB> cls = OpenNebula_3_2_NodeDriver <TAB> <TAB> elif api_version in [ ""3.6"" ] : <TAB> <TAB> <TAB> cls = OpenNebula_3_6_NodeDriver <TAB> <TAB> elif api_version in [ ""3.8"" ] : <TAB> <TAB> <TAB> cls = OpenNebula_3_8_NodeDriver <TAB> <TAB> <TAB> if ""plain_auth"" not in kwargs : <TAB> <TAB> <TAB> <TAB> kwargs [ ""plain_auth"" ] = cls. plain_auth <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> cls. plain_auth = kwargs [ ""plain_auth"" ] <TAB> <TAB> else : <TAB> <TAB> <TAB> raise NotImplementedError ( <TAB> <TAB> <TAB> <TAB> ""No OpenNebulaNodeDriver found for API version %s"" % ( api_version ) <TAB> <TAB> <TAB> ) <TAB> <TAB> return super ( OpenNebulaNodeDriver, cls ). __new__ ( cls )",False,api_version in ['1.4'],api_version == DEFAULT_API_VERSION,0.6551579236984253
|
||
|
614,"def wait_for_image_to_analyze ( image_id, api_conf : callable ) : <TAB> status = ""analyzing"" <TAB> start_time_sec = time. time ( ) <TAB> while status!= ""analyzed"" and time. time ( ) - start_time_sec < WAIT_TIMEOUT_SEC : <TAB> <TAB> resp = http_get ( [ ""images"", ""by_id"", image_id ], config = api_conf ) <TAB> <TAB> status = resp. body [ 0 ]. get ( ""analysis_status"", None ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> _logger. info ( <TAB> <TAB> <TAB> <TAB> ""Waiting for Image Analysis to complete. Elapsed Time={}sec"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> int ( time. time ( ) - start_time_sec ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> time. sleep ( 5 ) <TAB> if time. time ( ) - start_time_sec >= WAIT_TIMEOUT_SEC : <TAB> <TAB> raise TimeoutError ( <TAB> <TAB> <TAB> ""Timed out waiting for Image to Analyze (timeout={}sec)"". format ( <TAB> <TAB> <TAB> <TAB> WAIT_TIMEOUT_SEC <TAB> <TAB> <TAB> ) <TAB> <TAB> ) <TAB> else : <TAB> <TAB> _logger. info ( <TAB> <TAB> <TAB> ""Image Analysis Complete, wait time: {}sec"". format ( <TAB> <TAB> <TAB> <TAB> int ( time. time ( ) - start_time_sec ) <TAB> <TAB> <TAB> ) <TAB> <TAB> )",False,status != 'analyzed',status != 'cancel',0.6683658957481384
|
||
|
615,"def provider_forms ( self ) -> list : <TAB> providers = [ ] <TAB> responses = register_ticket_outputs. send ( self. request. event ) <TAB> for receiver, response in responses : <TAB> <TAB> provider = response ( self. request. event ) <TAB> <TAB> provider. form = ProviderForm ( <TAB> <TAB> <TAB> obj = self. request. event, <TAB> <TAB> <TAB> settingspref = ""ticketoutput_%s_"" % provider. identifier, <TAB> <TAB> <TAB> data = ( self. request. POST if self. request. method == ""POST"" else None ), <TAB> <TAB> <TAB> files = ( self. request. FILES if self. request. method == ""POST"" else None ), <TAB> <TAB> ) <TAB> <TAB> provider. form. fields = OrderedDict ( <TAB> <TAB> <TAB> [ <TAB> <TAB> <TAB> <TAB> ( ""ticketoutput_%s_%s"" % ( provider. identifier, k ), v ) <TAB> <TAB> <TAB> <TAB> for k, v in provider. settings_form_fields. items ( ) <TAB> <TAB> <TAB> ] <TAB> <TAB> ) <TAB> <TAB> provider. settings_content = provider. settings_content_render ( self. request ) <TAB> <TAB> provider. form. prepare_fields ( ) <TAB> <TAB> provider. evaluated_preview_allowed = True <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> provider. evaluated_preview_allowed = False <TAB> <TAB> else : <TAB> <TAB> <TAB> for k, v in provider. settings_form_fields. items ( ) : <TAB> <TAB> <TAB> <TAB> if v. required and not self. request. event. settings. get ( <TAB> <TAB> <TAB> <TAB> <TAB> ""ticketoutput_%s_%s"" % ( provider. identifier, k ) <TAB> <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> <TAB> provider. evaluated_preview_allowed = False <TAB> <TAB> <TAB> <TAB>",False,not provider.preview_allowed,self.request.method == 'POST',0.6531155705451965
|
||
|
616,"def books ( self ) : <TAB> """"""The list of KoboBook objects in the library."""""" <TAB> if len ( self. _books )!= 0 : <TAB> <TAB> return self. _books <TAB> """"""Drm-ed kepub"""""" <TAB> for row in self. __cursor. execute ( <TAB> <TAB> ""SELECT DISTINCT volumeid, Title, Attribution, Series FROM content_keys, content WHERE contentid = volumeid"" <TAB> ) : <TAB> <TAB> self. _books. append ( <TAB> <TAB> <TAB> KoboBook ( <TAB> <TAB> <TAB> <TAB> row [ 0 ], <TAB> <TAB> <TAB> <TAB> row [ 1 ], <TAB> <TAB> <TAB> <TAB> self. __bookfile ( row [ 0 ] ), <TAB> <TAB> <TAB> <TAB> ""kepub"", <TAB> <TAB> <TAB> <TAB> self. __cursor, <TAB> <TAB> <TAB> <TAB> author = row [ 2 ], <TAB> <TAB> <TAB> <TAB> series = row [ 3 ], <TAB> <TAB> <TAB> ) <TAB> <TAB> ) <TAB> <TAB> self. _volumeID. append ( row [ 0 ] ) <TAB> """"""Drm-free"""""" <TAB> for f in os. listdir ( self. bookdir ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> row = self. __cursor. execute ( <TAB> <TAB> <TAB> <TAB> ""SELECT Title, Attribution, Series FROM content WHERE ContentID = '"" <TAB> <TAB> <TAB> <TAB> + f <TAB> <TAB> <TAB> <TAB> + ""'"" <TAB> <TAB> <TAB> ). fetchone ( ) <TAB> <TAB> <TAB> if row is not None : <TAB> <TAB> <TAB> <TAB> fTitle = row [ 0 ] <TAB> <TAB> <TAB> <TAB> self. _books. append ( <TAB> <TAB> <TAB> <TAB> <TAB> KoboBook ( <TAB> <TAB> <TAB> <TAB> <",False,f not in self._volumeID,len(f) > 0,0.6642298698425293
|
||
|
617,"def end_object ( self, obj ) : <TAB> fields = self. selected_fields <TAB> if fields is not None : <TAB> <TAB> missing = set ( fields ). difference ( self. _current. keys ( ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> _nothing = object ( ) <TAB> <TAB> <TAB> for f in missing : <TAB> <TAB> <TAB> <TAB> fs = f. split ( ""__"" ) <TAB> <TAB> <TAB> <TAB> value = obj <TAB> <TAB> <TAB> <TAB> while fs : <TAB> <TAB> <TAB> <TAB> <TAB> value = getattr ( value, fs. pop ( 0 ), _nothing ) <TAB> <TAB> <TAB> <TAB> if value is not _nothing : <TAB> <TAB> <TAB> <TAB> <TAB> self. _current [ f ] = value <TAB> return super ( ). end_object ( obj )",True,missing,missing,0.6811259984970093
|
||
|
618,"def main ( client ) : <TAB> <TAB> placement_service = client. GetService ( ""PlacementService"", version = ""v202008"" ) <TAB> <TAB> statement = ( <TAB> <TAB> ad_manager. StatementBuilder ( version = ""v202008"" ) <TAB> <TAB>. Where ( ""status = :status"" ) <TAB> <TAB>. WithBindVariable ( ""status"", ""ACTIVE"" ) <TAB> ) <TAB> <TAB> <TAB> while True : <TAB> <TAB> response = placement_service. getPlacementsByStatement ( statement. ToStatement ( ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> for placement in response [ ""results"" ] : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> <TAB> 'Placement with ID ""%d"" and name ""%s"" was found.\n' <TAB> <TAB> <TAB> <TAB> <TAB> % ( placement [ ""id"" ], placement [ ""name"" ] ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> statement. offset += statement. limit <TAB> <TAB> else : <TAB> <TAB> <TAB> break <TAB> print ( ""\nNumber of results found: %s"" % response [ ""totalResultSetSize"" ] )",False,'results' in response and len(response['results']),response[0],0.6575170159339905
|
||
|
619,"def _LazyAddAttr_ ( self, attr ) : <TAB> if self. _lazydata_ is None : <TAB> <TAB> return 0 <TAB> res = 0 <TAB> typeinfo, typecomp = self. _lazydata_ <TAB> olerepr = self. _olerepr_ <TAB> <TAB> <TAB> <TAB> <TAB> for i in ALL_INVOKE_TYPES : <TAB> <TAB> try : <TAB> <TAB> <TAB> x, t = typecomp. Bind ( attr, i ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> x, t = typecomp. Bind ( attr [ 3 : ], i ) <TAB> <TAB> <TAB> if x == 1 : <TAB> <TAB> <TAB> <TAB> r = olerepr. _AddFunc_ ( typeinfo, t, 0 ) <TAB> <TAB> <TAB> elif x == 2 : <TAB> <TAB> <TAB> <TAB> r = olerepr. _AddVar_ ( typeinfo, t, 0 ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> r = None <TAB> <TAB> <TAB> if not r is None : <TAB> <TAB> <TAB> <TAB> key, map = r [ 0 ], r [ 1 ] <TAB> <TAB> <TAB> <TAB> item = map [ key ] <TAB> <TAB> <TAB> <TAB> if map == olerepr. propMapPut : <TAB> <TAB> <TAB> <TAB> <TAB> olerepr. _propMapPutCheck_ ( key, item ) <TAB> <TAB> <TAB> <TAB> elif map == olerepr. propMapGet : <TAB> <TAB> <TAB> <TAB> <TAB> olerepr. _propMapGetCheck_ ( key, item ) <TAB> <TAB> <TAB> <TAB> res = 1 <TAB> <TAB> except : <TAB> <TAB> <TAB> pass <TAB> return res",False,"x == 0 and attr[:3] in ('Set', 'Get')",x == 0,0.6554028987884521
|
||
|
620,"def _convert ( self, value, context ) : <TAB> if value is None : <TAB> <TAB> return None <TAB> if self. is_allowed_model ( value ) : <TAB> <TAB> return value <TAB> if not isinstance ( value, dict ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> instanceof_msg = ""one of: {}"". format ( <TAB> <TAB> <TAB> <TAB> "", "". join ( cls. __name__ for cls in self. model_classes ) <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> instanceof_msg = self. model_classes [ 0 ]. __name__ <TAB> <TAB> raise ConversionError ( <TAB> <TAB> <TAB> ""Please use a mapping for this field or "" <TAB> <TAB> <TAB> ""an instance of {}"". format ( instanceof_msg ) <TAB> <TAB> ) <TAB> model_class = self. find_model ( value ) <TAB> return model_class ( value, context = context )",False,len(self.model_classes) > 1,self.model_classes,0.6559975147247314
|
||
|
621,"def _establish ( self ) : <TAB> <TAB> self. fsm. change ( FSM. ACTIVE ) <TAB> if not self. proto : <TAB> <TAB> for action in self. _connect ( ) : <TAB> <TAB> <TAB> if action in ACTION. ALL : <TAB> <TAB> <TAB> <TAB> yield action <TAB> self. fsm. change ( FSM. CONNECT ) <TAB> <TAB> if self. neighbor. local_as : <TAB> <TAB> for sent_open in self. _send_open ( ) : <TAB> <TAB> <TAB> if sent_open in ACTION. ALL : <TAB> <TAB> <TAB> <TAB> yield sent_open <TAB> <TAB> self. proto. negotiated. sent ( sent_open ) <TAB> <TAB> self. fsm. change ( FSM. OPENSENT ) <TAB> <TAB> for received_open in self. _read_open ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> yield received_open <TAB> self. proto. negotiated. received ( received_open ) <TAB> self. proto. connection. msg_size = self. proto. negotiated. msg_size <TAB> <TAB> if not self. neighbor. local_as : <TAB> <TAB> for sent_open in self. _send_open ( ) : <TAB> <TAB> <TAB> if sent_open in ACTION. ALL : <TAB> <TAB> <TAB> <TAB> yield sent_open <TAB> <TAB> self. proto. negotiated. sent ( sent_open ) <TAB> <TAB> self. fsm. change ( FSM. OPENSENT ) <TAB> self. proto. validate_open ( ) <TAB> self. fsm. change ( FSM. OPENCONFIRM ) <TAB> self. recv_timer = ReceiveTimer ( <TAB> <TAB> self. proto. connection. session, self. proto. negotiated. holdtime, 4, 0 <TAB> ) <TAB> for action in self. _send_ka ( ) : <TAB> <TAB> yield action <TAB> for action in self. _read_ka ( ) : <TAB> <TAB> yield action <TAB> self. fsm. change ( FSM",True,received_open in ACTION.ALL,received_open in ACTION.ALL,0.6625270843505859
|
||
|
622,"def aggregate ( cls, dataset, dimensions, function, ** kwargs ) : <TAB> data = dataset. data <TAB> cols = [ d. name for d in dataset. kdims if d in dimensions ] <TAB> vdims = dataset. dimensions ( ""value"", label = ""name"" ) <TAB> dtypes = data. dtypes <TAB> numeric = [ <TAB> <TAB> c <TAB> <TAB> for c, dtype in zip ( dtypes. index, dtypes. values ) <TAB> <TAB> if dtype. kind in ""iufc"" and c in vdims <TAB> ] <TAB> reindexed = data [ cols + numeric ] <TAB> inbuilts = { <TAB> <TAB> ""amin"" : ""min"", <TAB> <TAB> ""amax"" : ""max"", <TAB> <TAB> ""mean"" : ""mean"", <TAB> <TAB> ""std"" : ""std"", <TAB> <TAB> ""sum"" : ""sum"", <TAB> <TAB> ""var"" : ""var"", <TAB> } <TAB> if len ( dimensions ) : <TAB> <TAB> groups = reindexed. groupby ( cols ) <TAB> <TAB> if function. __name__ in inbuilts : <TAB> <TAB> <TAB> agg = getattr ( groups, inbuilts [ function. __name__ ] ) ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> agg = groups. apply ( function ) <TAB> <TAB> df = agg. reset_index ( ) <TAB> else : <TAB> <TAB> if function. __name__ in inbuilts : <TAB> <TAB> <TAB> agg = getattr ( reindexed, inbuilts [ function. __name__ ] ) ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise NotImplementedError <TAB> <TAB> df = pd. DataFrame ( agg. compute ( ) ). T <TAB> dropped = [ ] <TAB> for vd in vdims : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> dropped. append ( vd ) <TAB> return df, dropped",False,vd not in df.columns,vd not in df,0.6690123081207275
|
||
|
623,"def checkbox_callback ( checked_value ) : <TAB> global search_box_area, phrases_area <TAB> group_info_box. text = """" <TAB> if 0 in checked_value : <TAB> <TAB> annotation_layout. children = [ <TAB> <TAB> <TAB> annotation_input, <TAB> <TAB> <TAB> annotate_button, <TAB> <TAB> <TAB> annotation_output, <TAB> <TAB> ] <TAB> else : <TAB> <TAB> annotation_layout. children = [ ] <TAB> <TAB> annotation_output. text = """" <TAB> if 1 in checked_value : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> working_label. text = fetching_text <TAB> <TAB> <TAB> get_vocab ( ) <TAB> <TAB> if not phrases_list. options : <TAB> <TAB> <TAB> working_label. text = working_text <TAB> <TAB> <TAB> phrases_list. options = list ( cut_vocab_dict. keys ( ) ) [ <TAB> <TAB> <TAB> <TAB> 0 : max_visible_phrases <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> <TAB> phrases_area. children = [ search_input_box, search_working_label, phrases_list ] <TAB> <TAB> working_label. text = """" <TAB> else : <TAB> <TAB> <TAB> <TAB> phrases_area. children = [ ] <TAB> <TAB> group_info_box. text = """"",False,vocab is None,cut_vocab_dict.keys(),0.6771036386489868
|
||
|
624,"def get_tokens_unprocessed ( self, text ) : <TAB> bashlexer = BashLexer ( ** self. options ) <TAB> pos = 0 <TAB> curcode = """" <TAB> insertions = [ ] <TAB> for match in line_re. finditer ( text ) : <TAB> <TAB> line = match. group ( ) <TAB> <TAB> m = re. match ( <TAB> <TAB> <TAB> r""^((?:\(\S+\))?(?:|sh\S*?|\w+\S+[@:]\S+(?:\s+\S+)"" <TAB> <TAB> <TAB> r""?|\[\S+[@:][^\n]+\].+)[$#%])(.*\n?)"", <TAB> <TAB> <TAB> line, <TAB> <TAB> ) <TAB> <TAB> if m : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if not insertions : <TAB> <TAB> <TAB> <TAB> pos = match. start ( ) <TAB> <TAB> <TAB> insertions. append ( ( len ( curcode ), [ ( 0, Generic. Prompt, m. group ( 1 ) ) ] ) ) <TAB> <TAB> <TAB> curcode += m. group ( 2 ) <TAB> <TAB> elif line. startswith ( "">"" ) : <TAB> <TAB> <TAB> insertions. append ( ( len ( curcode ), [ ( 0, Generic. Prompt, line [ : 1 ] ) ] ) ) <TAB> <TAB> <TAB> curcode += line [ 1 : ] <TAB> <TAB> else : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> toks = bashlexer. get_tokens_unprocessed ( curcode ) <TAB> <TAB> <TAB> <TAB> for i, t, v in do_insertions ( insertions, toks ) : <TAB> <TAB> <TAB> <TAB> <TAB> yield pos + i, t, v <TAB> <TAB> <TAB> yield match. start ( ), Generic. Output, line <TAB> <TAB> <TAB> insertions = [ ]",False,insertions,self.options.options.get('no_token'),0.691433310508728
|
||
|
625,"def display_list_by_prefix ( names_list, starting_spaces = 0 ) : <TAB> """"""Creates a help string for names_list grouped by prefix."""""" <TAB> cur_prefix, result_lines = None, [ ] <TAB> space = "" "" * starting_spaces <TAB> for name in sorted ( names_list ) : <TAB> <TAB> split = name. split ( ""_"", 1 ) <TAB> <TAB> prefix = split [ 0 ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> result_lines. append ( space + prefix + "":"" ) <TAB> <TAB> <TAB> cur_prefix = prefix <TAB> <TAB> result_lines. append ( space + "" * "" + name ) <TAB> return ""\n"". join ( result_lines )",True,cur_prefix != prefix,cur_prefix != prefix,0.6608850955963135
|
||
|
626,"def interact ( show_tokens = False ) : <TAB> try : <TAB> <TAB> import readline <TAB> except ImportError : <TAB> <TAB> pass <TAB> sys. modules [ ""__main__"" ] = global_env <TAB> while True : <TAB> <TAB> buffer = """" <TAB> <TAB> continuation_flag = False <TAB> <TAB> tokens = [ ] <TAB> <TAB> while True : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> s = input ( ""... "" ) <TAB> <TAB> <TAB> <TAB> <TAB> if s == ""\n"" : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> <TAB> buffer = buffer + ""\n"" + s <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> s = input ( "">>> "" ) <TAB> <TAB> <TAB> <TAB> <TAB> if s == ""\n"" : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> <TAB> buffer = s <TAB> <TAB> <TAB> except EOFError : <TAB> <TAB> <TAB> <TAB> print ( ) <TAB> <TAB> <TAB> <TAB> sys. exit ( ) <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> lexer = lex ( buffer, repl_mode = True, debug = show_tokens ) <TAB> <TAB> <TAB> <TAB> for last in lexer : <TAB> <TAB> <TAB> <TAB> <TAB> tokens. append ( last ) <TAB> <TAB> <TAB> <TAB> if len ( tokens ) == 0 : <TAB> <TAB> <TAB> <TAB> <TAB> buffer = """" <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> if ( <TAB> <TAB> <TAB> <TAB> <",False,continuation_flag,show_tokens,0.6654371023178101
|
||
|
627,"def incr_and_sum ( self, key, keys, amount, maximum, ttl ) : <TAB> ttl = int ( ttl / 1000 ) <TAB> with self. pool. reserve ( block = True ) as client : <TAB> <TAB> client. add ( key, 0, time = ttl ) <TAB> <TAB> while True : <TAB> <TAB> <TAB> value, cid = client. gets ( key ) <TAB> <TAB> <TAB> if cid is None : <TAB> <TAB> <TAB> <TAB> return False <TAB> <TAB> <TAB> value += amount <TAB> <TAB> <TAB> if value > maximum : <TAB> <TAB> <TAB> <TAB> return False <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> key_list = keys ( ) if callable ( keys ) else keys <TAB> <TAB> <TAB> mapping = client. get_multi ( key_list ) <TAB> <TAB> <TAB> total = amount + sum ( mapping. values ( ) ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return False <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> swapped = client. cas ( key, value, cid, ttl ) <TAB> <TAB> <TAB> <TAB> if swapped : <TAB> <TAB> <TAB> <TAB> <TAB> return True <TAB> <TAB> <TAB> except NotFound : <TAB> <TAB> <TAB> <TAB> continue",True,total > maximum,total > maximum,0.684869647026062
|
||
|
628,"def _validate_cfg ( self ) : <TAB> if not isinstance ( self. paramwise_cfg, dict ) : <TAB> <TAB> raise TypeError ( <TAB> <TAB> <TAB> ""paramwise_cfg should be None or a dict, "" <TAB> <TAB> <TAB> f""but got {type(self.paramwise_cfg)}"" <TAB> <TAB> ) <TAB> if ""custom_keys"" in self. paramwise_cfg : <TAB> <TAB> if not isinstance ( self. paramwise_cfg [ ""custom_keys"" ], dict ) : <TAB> <TAB> <TAB> raise TypeError ( <TAB> <TAB> <TAB> <TAB> ""If specified, custom_keys must be a dict, "" <TAB> <TAB> <TAB> <TAB> f'but got {type(self.paramwise_cfg[""custom_keys""])}' <TAB> <TAB> <TAB> ) <TAB> <TAB> if self. base_wd is None : <TAB> <TAB> <TAB> for key in self. paramwise_cfg [ ""custom_keys"" ] : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> raise ValueError ( ""base_wd should not be None"" ) <TAB> <TAB> <TAB> if ( <TAB> <TAB> ""bias_decay_mult"" in self. paramwise_cfg <TAB> <TAB> or ""norm_decay_mult"" in self. paramwise_cfg <TAB> <TAB> or ""dwconv_decay_mult"" in self. paramwise_cfg <TAB> ) : <TAB> <TAB> if self. base_wd is None : <TAB> <TAB> <TAB> raise ValueError ( ""base_wd should not be None"" )",False,'decay_mult' in self.paramwise_cfg['custom_keys'][key],self.base_wd is None,0.6486297845840454
|
||
|
629,"def tile ( cls, op : ""DataFrameToSQLTable"" ) : <TAB> inp = op. inputs [ 0 ] <TAB> out = op. outputs [ 0 ] <TAB> if inp. ndim == 2 : <TAB> <TAB> inp = inp. rechunk ( { 1 : ( inp. shape [ 1 ], ) } ). _inplace_tile ( ) <TAB> chunks = [ ] <TAB> for c in inp. chunks : <TAB> <TAB> new_op = op. copy ( ). reset_key ( ) <TAB> <TAB> new_op. _if_exists = ""append"" <TAB> <TAB> index_value = parse_index ( c. index_value. to_pandas ( ) [ : 0 ], c ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> columns_value = parse_index ( <TAB> <TAB> <TAB> <TAB> c. columns_value. to_pandas ( ) [ : 0 ], store_data = True <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> chunks. append ( <TAB> <TAB> <TAB> <TAB> new_op. new_chunk ( <TAB> <TAB> <TAB> <TAB> <TAB> [ c ], <TAB> <TAB> <TAB> <TAB> <TAB> shape = ( 0, 0 ), <TAB> <TAB> <TAB> <TAB> <TAB> index = c. index, <TAB> <TAB> <TAB> <TAB> <TAB> dtypes = out. dtypes, <TAB> <TAB> <TAB> <TAB> <TAB> index_value = index_value, <TAB> <TAB> <TAB> <TAB> <TAB> columns_value = columns_value, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> chunks. append ( <TAB> <TAB> <TAB> <TAB> new_op. new_chunk ( <TAB> <TAB> <TAB> <TAB> <TAB> [ c ], <TAB> <TAB> <TAB> <TAB> <TAB> shape = ( 0, ), <TAB>",False,c.ndim == 2,new_op._if_exists,0.6627962589263916
|
||
|
630,"def tokenize ( self, s ) : <TAB> """"""Tokenize comments, strings, identifiers, whitespace and operators."""""" <TAB> i, result = 0, [ ] <TAB> while i < len ( s ) : <TAB> <TAB> <TAB> <TAB> j = i <TAB> <TAB> ch = s [ i ] <TAB> <TAB> if ch in ""@\n"" : <TAB> <TAB> <TAB> j += 1 <TAB> <TAB> elif ch == ""#"" : <TAB> <TAB> <TAB> j = g. skip_to_end_of_line ( s, i ) <TAB> <TAB> elif ch in "" \t"" : <TAB> <TAB> <TAB> j = g. skip_ws ( s, i ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> j = g. skip_c_id ( s, i ) <TAB> <TAB> elif g. match ( s, i, ""//"" ) : <TAB> <TAB> <TAB> j = g. skip_line ( s, i ) <TAB> <TAB> elif g. match ( s, i, ""/*"" ) : <TAB> <TAB> <TAB> j = self. skip_block_comment ( s, i ) <TAB> <TAB> elif ch in ""'\"""" : <TAB> <TAB> <TAB> j = g. skip_string ( s, i ) <TAB> <TAB> else : <TAB> <TAB> <TAB> j += 1 <TAB> <TAB> assert j > i <TAB> <TAB> result. append ( """". join ( s [ i : j ] ) ) <TAB> <TAB> i = j <TAB> return result",False,ch.isalpha() or ch == '_',"g.match(s, i)",0.6549491882324219
|
||
|
631,"def _check_init_script ( path, sentinel ) : <TAB> if not os. path. exists ( path ) : <TAB> <TAB> return <TAB> lines = open ( path ). readlines ( ) <TAB> for i, line in enumerate ( lines ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> cli. out ( <TAB> <TAB> <TAB> <TAB> ""Guild completion is already installed in %s on line %i:\n %s"" <TAB> <TAB> <TAB> <TAB> % ( util. format_dir ( path ), i + 1, line. rstrip ( ) ), <TAB> <TAB> <TAB> <TAB> err = True, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> raise SystemExit ( 0 )",False,sentinel in line,sentinel,0.6660369634628296
|
||
|
632,"def postprocess_slice ( slicename, skipped ) : <TAB> pngsliceFName = slicename + "".png"" <TAB> hotsliceFName = slicename + "".hotspot.png"" <TAB> for i, size in enumerate ( sizes ) : <TAB> <TAB> subdir = ""bitmaps/{}x{}"". format ( size, size ) <TAB> <TAB> relslice = ""{}/{}"". format ( subdir, pngsliceFName ) <TAB> <TAB> csize = get_csize ( i, size ) <TAB> <TAB> if relslice not in skipped : <TAB> <TAB> <TAB> new_base = cropalign ( csize, relslice ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> hotrelslice = ""{}/{}"". format ( subdir, hotsliceFName ) <TAB> <TAB> <TAB> <TAB> cropalign_hotspot ( new_base, csize, hotrelslice ) <TAB> <TAB> for scale in scale_pairs : <TAB> <TAB> <TAB> subdir = ""bitmaps/{}x{}_{}"". format ( size, size, scale [ 1 ] ) <TAB> <TAB> <TAB> relslice = ""{}/{}"". format ( subdir, pngsliceFName ) <TAB> <TAB> <TAB> if relslice not in skipped : <TAB> <TAB> <TAB> <TAB> new_base = cropalign ( csize, relslice ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> hotrelslice = ""{}/{}"". format ( subdir, hotsliceFName ) <TAB> <TAB> <TAB> <TAB> <TAB> cropalign_hotspot ( new_base, csize, hotrelslice )",False,options.hotspots,hotrelslice not in skipped,0.6548711657524109
|
||
|
633,def remove ( self ) : <TAB> <TAB> for collector in self. __collectors [ : ] : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> collector. remove ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> collector. decouple_from_home_building ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> collector. remove ( ) <TAB> assert not [ c for c in self. __collectors ] <TAB> super ( ). remove ( ) <TAB> self. __collectors = None <TAB> self. path_nodes = None,False,not collector.is_ship,self.home_building,0.6545703411102295
|
||
|
634,"def get_error_diagnostics ( self ) : <TAB> diagnostics = [ ] <TAB> class_name = self. __class__. __name__ <TAB> if self. stdout is not None : <TAB> <TAB> with open ( self. stdout. name ) as fds : <TAB> <TAB> <TAB> contents = fds. read ( ). strip ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> diagnostics. append ( class_name + "" STDOUT:\n"" + contents ) <TAB> if self. stderr is not None : <TAB> <TAB> with open ( self. stderr. name ) as fds : <TAB> <TAB> <TAB> contents = fds. read ( ). strip ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> diagnostics. append ( class_name + "" STDERR:\n"" + contents ) <TAB> return diagnostics",True,contents,contents,0.6944578289985657
|
||
|
635,"def PyJs_anonymous_1469_ ( that, key, this, arguments, var = var ) : <TAB> var = Scope ( <TAB> <TAB> { u""this"" : this, u""arguments"" : arguments, u""key"" : key, u""that"" : that }, var <TAB> ) <TAB> var. registers ( [ u""index"", u""that"", u""key"", u""entry"" ] ) <TAB> var. put ( u""index"", var. get ( u""fastKey"" ) ( var. get ( u""key"" ) ) ) <TAB> if PyJsStrictNeq ( var. get ( u""index"" ), Js ( u""F"" ) ) : <TAB> <TAB> return var. get ( u""that"" ). get ( u""_i"" ). get ( var. get ( u""index"" ) ) <TAB> <TAB> var. put ( u""entry"", var. get ( u""that"" ). get ( u""_f"" ) ) <TAB> while var. get ( u""entry"" ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return var. get ( u""entry"" ) <TAB> <TAB> finally : <TAB> <TAB> <TAB> var. put ( u""entry"", var. get ( u""entry"" ). get ( u""n"" ) )",False,var.get(u'entry').get(u'k') == var.get(u'key'),var.get(u'entry'),0.649939775466919
|
||
|
636,"def _format ( node ) : <TAB> if isinstance ( node, AST ) : <TAB> <TAB> fields = [ ( a, _format ( b ) ) for a, b in iter_fields ( node ) ] <TAB> <TAB> rv = ""%s(%s"" % ( <TAB> <TAB> <TAB> node. __class__. __name__, <TAB> <TAB> <TAB> "", "". join ( <TAB> <TAB> <TAB> <TAB> ( ""%s=%s"" % field for field in fields ) <TAB> <TAB> <TAB> <TAB> if annotate_fields <TAB> <TAB> <TAB> <TAB> else ( b for a, b in fields ) <TAB> <TAB> <TAB> ), <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> rv += fields and "", "" or "" "" <TAB> <TAB> <TAB> rv += "", "". join ( <TAB> <TAB> <TAB> <TAB> ""%s=%s"" % ( a, _format ( getattr ( node, a ) ) ) for a in node. _attributes <TAB> <TAB> <TAB> ) <TAB> <TAB> return rv + "")"" <TAB> elif isinstance ( node, list ) : <TAB> <TAB> return ""[%s]"" % "", "". join ( _format ( x ) for x in node ) <TAB> return repr ( node )",False,include_attributes and node._attributes,"hasattr(node, '_attributes')",0.6536455750465393
|
||
|
637,"def expandWithRefs ( self, s, varname ) : <TAB> if not isinstance ( s, str ) : <TAB> <TAB> return VariableParse ( varname, self, s ) <TAB> if varname and varname in self. expand_cache : <TAB> <TAB> return self. expand_cache [ varname ] <TAB> varparse = VariableParse ( varname, self ) <TAB> while s. find ( ""${"" )!= - 1 : <TAB> <TAB> olds = s <TAB> <TAB> try : <TAB> <TAB> <TAB> s = __expand_var_regexp__. sub ( varparse. var_sub, s ) <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> s = __expand_python_regexp__. sub ( varparse. python_sub, s ) <TAB> <TAB> <TAB> except SyntaxError as e : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> raise <TAB> <TAB> <TAB> if s == olds : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> except ExpansionError : <TAB> <TAB> <TAB> raise <TAB> <TAB> except bb. parse. SkipRecipe : <TAB> <TAB> <TAB> raise <TAB> <TAB> except Exception as exc : <TAB> <TAB> <TAB> raise ExpansionError ( varname, s, exc ) from exc <TAB> varparse. value = s <TAB> if varname : <TAB> <TAB> self. expand_cache [ varname ] = varparse <TAB> return varparse",False,e.msg != 'EOL while scanning string literal',s == None,0.6579976081848145
|
||
|
638,"def check_network ( self ) -> NetworkStatus : <TAB> try : <TAB> <TAB> loop = asyncio. get_event_loop ( ) <TAB> <TAB> async with aiohttp. ClientSession ( <TAB> <TAB> <TAB> loop = loop, connector = aiohttp. TCPConnector ( verify_ssl = False ) <TAB> <TAB> ) as session : <TAB> <TAB> <TAB> async with session. get ( self. log_server_url ) as resp : <TAB> <TAB> <TAB> <TAB> status_text = await resp. text ( ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> raise Exception ( ""Log proxy server is down."" ) <TAB> except asyncio. CancelledError : <TAB> <TAB> raise <TAB> except Exception : <TAB> <TAB> return NetworkStatus. NOT_CONNECTED <TAB> return NetworkStatus. CONNECTED",False,status_text != 'OK',status_text != 'DOWN',0.6585826873779297
|
||
|
639,"def main ( client, key_id ) : <TAB> <TAB> custom_targeting_service = client. GetService ( <TAB> <TAB> ""CustomTargetingService"", version = ""v202008"" <TAB> ) <TAB> statement = ( <TAB> <TAB> ad_manager. StatementBuilder ( version = ""v202008"" ) <TAB> <TAB>. Where ( ""customTargetingKeyId = :keyId"" ) <TAB> <TAB>. WithBindVariable ( ""keyId"", int ( key_id ) ) <TAB> ) <TAB> while True : <TAB> <TAB> <TAB> <TAB> response = custom_targeting_service. getCustomTargetingValuesByStatement ( <TAB> <TAB> <TAB> statement. ToStatement ( ) <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> updated_values = [ ] <TAB> <TAB> <TAB> for value in response [ ""results"" ] : <TAB> <TAB> <TAB> <TAB> if not value [ ""displayName"" ] : <TAB> <TAB> <TAB> <TAB> <TAB> value [ ""displayName"" ] = value [ ""name"" ] <TAB> <TAB> <TAB> <TAB> value [ ""displayName"" ] += "" (Deprecated)"" <TAB> <TAB> <TAB> <TAB> updated_values. append ( value ) <TAB> <TAB> <TAB> values = custom_targeting_service. updateCustomTargetingValues ( <TAB> <TAB> <TAB> <TAB> updated_values <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for value in values : <TAB> <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> <TAB> 'Custom targeting value with id ""%s"", name ""%s"", and display' <TAB> <TAB> <TAB> <TAB> <TAB>'name ""%s"" was updated.' <TAB> <TAB> <TAB> <TAB> <TAB> % ( value [ ""id"" ], value [ ""name"" ], value [ ""displayName"" ] ) <TAB> <TAB> <TAB",False,'results' in response and len(response['results']),response[0],0.6568959951400757
|
||
|
640,"def check_app_config_brackets ( self ) : <TAB> for sn, app in cherrypy. tree. apps. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> if not app. config : <TAB> <TAB> <TAB> continue <TAB> <TAB> for key in app. config. keys ( ) : <TAB> <TAB> <TAB> if key. startswith ( ""["" ) or key. endswith ( ""]"" ) : <TAB> <TAB> <TAB> <TAB> warnings. warn ( <TAB> <TAB> <TAB> <TAB> <TAB> ""The application mounted at %r has config "" <TAB> <TAB> <TAB> <TAB> <TAB> ""section names with extraneous brackets: %r. "" <TAB> <TAB> <TAB> <TAB> <TAB> ""Config *files* need brackets; config *dicts* "" <TAB> <TAB> <TAB> <TAB> <TAB> ""(e.g. passed to tree.mount) do not."" % ( sn, key ) <TAB> <TAB> <TAB> <TAB> )",False,"not isinstance(app, cherrypy.Application)",not app,0.6531991958618164
|
||
|
641,"def printErrors ( self ) : <TAB> <TAB> if self. errors or self. failures : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. stream. writeln ( ) <TAB> <TAB> self. printErrorList ( ""ERROR"", self. errors ) <TAB> <TAB> self. printErrorList ( ""FAIL"", self. failures )",False,self.dots or self.showAll,self.stream and self.stream.isatty(),0.65559983253479
|
||
|
642,"def _check_connectivity ( self ) -> None : <TAB> """"""Check system connectivity."""""" <TAB> value = self. _cache. get ( ""connectivity"", 0 ) <TAB> <TAB> if value >= 600 : <TAB> <TAB> pass <TAB> elif ( <TAB> <TAB> self. sys_supervisor. connectivity and self. sys_host. network. connectivity is None <TAB> ) or ( <TAB> <TAB> self. sys_supervisor. connectivity <TAB> <TAB> and self. sys_host. network. connectivity is not None <TAB> <TAB> and self. sys_host. network. connectivity <TAB> ) : <TAB> <TAB> self. _cache [ ""connectivity"" ] = value + RUN_CHECK_CONNECTIVITY <TAB> <TAB> return <TAB> <TAB> try : <TAB> <TAB> await self. sys_supervisor. check_connectivity ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> await self. sys_host. network. check_connectivity ( ) <TAB> finally : <TAB> <TAB> self. _cache [ ""connectivity"" ] = 0",False,HostFeature.NETWORK in self.sys_host.features,value >= 600,0.6530295610427856
|
||
|
643,"def set_active_tools ( tools_to_activate, permanently_activate, system ) : <TAB> tools_to_activate = process_tool_list ( tools_to_activate, log_errors = True ) <TAB> if tools_to_activate : <TAB> <TAB> tools = [ x for x in tools_to_activate if not x. is_sdk ] <TAB> <TAB> print ( <TAB> <TAB> <TAB> ""Setting the following tools as active:\n "" <TAB> <TAB> <TAB> + ""\n "". join ( map ( lambda x : str ( x ), tools ) ) <TAB> <TAB> ) <TAB> <TAB> print ( """" ) <TAB> generate_dot_emscripten ( tools_to_activate ) <TAB> <TAB> <TAB> <TAB> <TAB> if WINDOWS : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> env_vars_to_add = get_env_vars_to_add ( <TAB> <TAB> <TAB> tools_to_activate, system, user = permanently_activate <TAB> <TAB> ) <TAB> <TAB> env_string = construct_env_with_vars ( env_vars_to_add ) <TAB> <TAB> write_set_env_script ( env_string ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> win_set_environment_variables ( <TAB> <TAB> <TAB> <TAB> env_vars_to_add, system, user = permanently_activate <TAB> <TAB> <TAB> ) <TAB> return tools_to_activate",False,permanently_activate,WINDOWS,0.659022867679596
|
||
|
644,"def _getnameinfo ( sockaddr, flags = 0 ) : <TAB> host = sockaddr [ 0 ] <TAB> port = sockaddr [ 1 ] <TAB> if len ( sockaddr ) == 4 : <TAB> <TAB> scope = sockaddr [ 3 ] <TAB> <TAB> family = socket. AF_INET6 <TAB> else : <TAB> <TAB> scope = None <TAB> <TAB> family = socket. AF_INET <TAB> tuples = _getaddrinfo ( host, port, family, socket. SOCK_STREAM, socket. SOL_TCP, 0 ) <TAB> if len ( tuples ) > 1 : <TAB> <TAB> raise socket. error ( ""sockaddr resolved to multiple addresses"" ) <TAB> addr = tuples [ 0 ] [ 4 ] [ 0 ] <TAB> if flags & socket. NI_DGRAM : <TAB> <TAB> pname = ""udp"" <TAB> else : <TAB> <TAB> pname = ""tcp"" <TAB> qname = dns. reversename. from_address ( addr ) <TAB> if flags & socket. NI_NUMERICHOST == 0 : <TAB> <TAB> try : <TAB> <TAB> <TAB> answer = _resolver. resolve ( qname, ""PTR"" ) <TAB> <TAB> <TAB> hostname = answer. rrset [ 0 ]. target. to_text ( True ) <TAB> <TAB> except ( dns. resolver. NXDOMAIN, dns. resolver. NoAnswer ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise socket. gaierror ( socket. EAI_NONAME, ""Name or service not known"" ) <TAB> <TAB> <TAB> hostname = addr <TAB> <TAB> <TAB> if scope is not None : <TAB> <TAB> <TAB> <TAB> hostname += ""%"" + str ( scope ) <TAB> else : <TAB> <TAB> hostname = addr <TAB> <TAB> if scope is not None : <TAB> <TAB> <TAB> hostname += ""%"" + str ( scope ) <TAB> if flags & socket. NI_NUMERICSERV : <TAB> <TAB> service = str ( port ) <TAB> else : <TAB> <TAB> service = socket",False,flags & socket.NI_NAMEREQD,not addr,0.651248574256897
|
||
|
645,"def parse_many ( self, values ) : <TAB> for value in values : <TAB> <TAB> try : <TAB> <TAB> <TAB> yield self. parse ( value ) <TAB> <TAB> except KeyError : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> yield None <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> raise",False,self._ignore_missing_keys,self.has_empty_tab(),0.6538208723068237
|
||
|
646,"def __new__ ( meta, cls_name, bases, cls_dict ) : <TAB> func = cls_dict. get ( ""func"" ) <TAB> monad_cls = super ( FuncMonadMeta, meta ). __new__ ( meta, cls_name, bases, cls_dict ) <TAB> if func : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> functions = func <TAB> <TAB> else : <TAB> <TAB> <TAB> functions = ( func, ) <TAB> <TAB> for func in functions : <TAB> <TAB> <TAB> registered_functions [ func ] = monad_cls <TAB> return monad_cls",False,type(func) is tuple,"hasattr(func, '__call__')",0.6527308225631714
|
||
|
647,"def mergeHiLo ( self, x_stats ) : <TAB> """"""Merge the highs and lows of another accumulator into myself."""""" <TAB> if x_stats. min is not None : <TAB> <TAB> if self. min is None or x_stats. min < self. min : <TAB> <TAB> <TAB> self. min = x_stats. min <TAB> <TAB> <TAB> self. mintime = x_stats. mintime <TAB> if x_stats. max is not None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. max = x_stats. max <TAB> <TAB> <TAB> self. maxtime = x_stats. maxtime <TAB> if x_stats. lasttime is not None : <TAB> <TAB> if self. lasttime is None or x_stats. lasttime >= self. lasttime : <TAB> <TAB> <TAB> self. lasttime = x_stats. lasttime <TAB> <TAB> <TAB> self. last = x_stats. last",False,self.max is None or x_stats.max > self.max,self.max is None or x_stats.maxtime is not None,0.653265118598938
|
||
|
648,"def get_attribute_value ( self, nodeid, attr ) : <TAB> with self. _lock : <TAB> <TAB> self. logger. debug ( ""get attr val: %s %s"", nodeid, attr ) <TAB> <TAB> if nodeid not in self. _nodes : <TAB> <TAB> <TAB> dv = ua. DataValue ( ) <TAB> <TAB> <TAB> dv. StatusCode = ua. StatusCode ( ua. StatusCodes. BadNodeIdUnknown ) <TAB> <TAB> <TAB> return dv <TAB> <TAB> node = self. _nodes [ nodeid ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> dv = ua. DataValue ( ) <TAB> <TAB> <TAB> dv. StatusCode = ua. StatusCode ( ua. StatusCodes. BadAttributeIdInvalid ) <TAB> <TAB> <TAB> return dv <TAB> <TAB> attval = node. attributes [ attr ] <TAB> <TAB> if attval. value_callback : <TAB> <TAB> <TAB> return attval. value_callback ( ) <TAB> <TAB> return attval. value",True,attr not in node.attributes,attr not in node.attributes,0.656838059425354
|
||
|
649,"def _eval ( self, code, ns, pos ) : <TAB> <TAB> try : <TAB> <TAB> try : <TAB> <TAB> <TAB> value = eval ( code, self. default_namespace, ns ) <TAB> <TAB> except SyntaxError as e : <TAB> <TAB> <TAB> raise SyntaxError ( ""invalid syntax in expression: %s"" % code ) <TAB> <TAB> return value <TAB> except : <TAB> <TAB> exc_info = sys. exc_info ( ) <TAB> <TAB> e = exc_info [ 1 ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> arg0 = e. args [ 0 ] <TAB> <TAB> else : <TAB> <TAB> <TAB> arg0 = coerce_text ( e ) <TAB> <TAB> e. args = ( self. _add_line_info ( arg0, pos ), ) <TAB> <TAB> if PY3 : <TAB> <TAB> <TAB> raise ( e ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise ( exc_info [ 1 ], e, exc_info [ 2 ] )",False,"getattr(e, 'args', None)",e.args and len(e.args) > 0,0.6512769460678101
|
||
|
650,"def _build_initiator_target_map ( self, target_wwns, connector ) : <TAB> """"""Build the target_wwns and the initiator target map."""""" <TAB> init_targ_map = { } <TAB> if self. _lookup_service : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> dev_map = self. _lookup_service. get_device_mapping_from_network ( <TAB> <TAB> <TAB> connector [ ""wwpns"" ], target_wwns <TAB> <TAB> ) <TAB> <TAB> for fabric_name in dev_map : <TAB> <TAB> <TAB> fabric = dev_map [ fabric_name ] <TAB> <TAB> <TAB> for initiator in fabric [ ""initiator_port_wwn_list"" ] : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> init_targ_map [ initiator ] = [ ] <TAB> <TAB> <TAB> <TAB> init_targ_map [ initiator ] += fabric [ ""target_port_wwn_list"" ] <TAB> <TAB> <TAB> <TAB> init_targ_map [ initiator ] = list ( set ( init_targ_map [ initiator ] ) ) <TAB> else : <TAB> <TAB> init_targ_map = dict. fromkeys ( connector [ ""wwpns"" ], target_wwns ) <TAB> return init_targ_map",False,initiator not in init_targ_map,init_targ_map is None,0.6574866771697998
|
||
|
651,"def scan_options ( self ) : <TAB> """"""Set all configuration-related ivars."""""" <TAB> if not self. config_fn : <TAB> <TAB> return <TAB> self. parser = parser = self. create_parser ( ) <TAB> s = self. get_config_string ( ) <TAB> self. init_parser ( s ) <TAB> if self. files : <TAB> <TAB> <TAB> <TAB> files = self. files <TAB> elif parser. has_section ( ""Global"" ) : <TAB> <TAB> <TAB> <TAB> files = parser. get ( ""Global"", ""files"" ) <TAB> <TAB> files = [ z. strip ( ) for z in files. split ( ""\n"" ) if z. strip ( ) ] <TAB> else : <TAB> <TAB> return <TAB> files2 = [ ] <TAB> for z in files : <TAB> <TAB> files2. extend ( glob. glob ( self. finalize ( z ) ) ) <TAB> self. files = [ z for z in files2 if z and os. path. exists ( z ) ] <TAB> if ""output_directory"" in parser. options ( ""Global"" ) : <TAB> <TAB> s = parser. get ( ""Global"", ""output_directory"" ) <TAB> <TAB> output_dir = self. finalize ( s ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. output_directory = output_dir <TAB> <TAB> <TAB> if self. verbose : <TAB> <TAB> <TAB> <TAB> print ( ""output directory: %s\n"" % output_dir ) <TAB> <TAB> else : <TAB> <TAB> <TAB> print ( ""output directory not found: %s\n"" % output_dir ) <TAB> <TAB> <TAB> self. output_directory = None <TAB> if ""prefix_lines"" in parser. options ( ""Global"" ) : <TAB> <TAB> prefix = parser. get ( ""Global"", ""prefix_lines"" ) <TAB> <TAB> self. prefix_lines = prefix. split ( ""\n"" )",False,os.path.exists(output_dir),output_dir is not None,0.647266149520874
|
||
|
652,"def parse_known_args ( self, args = None, namespace = None ) : <TAB> <TAB> if args is None : <TAB> <TAB> args = _sys. argv [ 1 : ] <TAB> <TAB> if namespace is None : <TAB> <TAB> namespace = Namespace ( ) <TAB> <TAB> for action in self. _actions : <TAB> <TAB> if action. dest is not SUPPRESS : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> if action. default is not SUPPRESS : <TAB> <TAB> <TAB> <TAB> <TAB> setattr ( namespace, action. dest, action. default ) <TAB> <TAB> for dest in self. _defaults : <TAB> <TAB> if not hasattr ( namespace, dest ) : <TAB> <TAB> <TAB> setattr ( namespace, dest, self. _defaults [ dest ] ) <TAB> <TAB> try : <TAB> <TAB> namespace, args = self. _parse_known_args ( args, namespace ) <TAB> <TAB> if hasattr ( namespace, _UNRECOGNIZED_ARGS_ATTR ) : <TAB> <TAB> <TAB> args. extend ( getattr ( namespace, _UNRECOGNIZED_ARGS_ATTR ) ) <TAB> <TAB> <TAB> delattr ( namespace, _UNRECOGNIZED_ARGS_ATTR ) <TAB> <TAB> return namespace, args <TAB> except ArgumentError : <TAB> <TAB> err = _sys. exc_info ( ) [ 1 ] <TAB> <TAB> self. error ( str ( err ) )",False,"not hasattr(namespace, action.dest)",action.default is None,0.6544973254203796
|
||
|
653,"def test_canonicalise ( self ) : <TAB> from quodlibet. util. path import normalize_path as norm <TAB> f, path = tempfile. mkstemp ( ) <TAB> path = os. path. realpath ( path ) <TAB> os. close ( f ) <TAB> path = norm ( path ) <TAB> link_dir = mkdtemp ( ) <TAB> link = None <TAB> if not is_win : <TAB> <TAB> link = os. path. join ( link_dir, str ( uuid. uuid4 ( ) ) ) <TAB> <TAB> os. symlink ( path, link ) <TAB> try : <TAB> <TAB> self. failUnlessEqual ( norm ( path, canonicalise = True ), path ) <TAB> <TAB> self. failUnlessEqual ( norm ( os. path. join ( path, ""foo"", "".."" ), True ), path ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. failUnlessEqual ( norm ( link, True ), path ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. failIfEqual ( norm ( link, False ), path ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> unnormalised_path = os. path. join ( link, ""foo"", "".."" ) <TAB> <TAB> <TAB> self. failUnlessEqual ( norm ( unnormalised_path, True ), path ) <TAB> finally : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> os. remove ( link ) <TAB> <TAB> os. remove ( path ) <TAB> <TAB> os. rmdir ( link_dir )",False,link,norm,0.6871761679649353
|
||
|
654,"def testLimit ( self ) : <TAB> ""Verify that CPU limits are within a 2% tolerance of limit for each scheduler"" <TAB> p = pexpect. spawn ( ""python -m mininet.examples.limit"" ) <TAB> opts = [ <TAB> <TAB> ""\*\*\* Testing network ([\d\.]+) Mbps"", <TAB> <TAB> ""\*\*\* Results: \[([\d\., ]+)\]"", <TAB> <TAB> pexpect. EOF, <TAB> ] <TAB> count = 0 <TAB> bw = 0 <TAB> tolerance = 2 <TAB> while True : <TAB> <TAB> index = p. expect ( opts ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> bw = float ( p. match. group ( 1 ) ) <TAB> <TAB> <TAB> count += 1 <TAB> <TAB> elif index == 1 : <TAB> <TAB> <TAB> results = p. match. group ( 1 ) <TAB> <TAB> <TAB> for x in results. split ( "","" ) : <TAB> <TAB> <TAB> <TAB> result = float ( x ) <TAB> <TAB> <TAB> <TAB> self. assertTrue ( result < bw + tolerance ) <TAB> <TAB> <TAB> <TAB> self. assertTrue ( result > bw - tolerance ) <TAB> <TAB> else : <TAB> <TAB> <TAB> break <TAB> self. assertTrue ( count > 0 )",True,index == 0,index == 0,0.6702772974967957
|
||
|
655,"def _real_extract ( self, url ) : <TAB> course_name = self. _match_id ( url ) <TAB> webpage = self. _download_webpage ( url, course_name ) <TAB> props = self. _parse_json ( <TAB> <TAB> self. _search_regex ( r""data\s*=\s*({.+?})\s*;"", webpage, ""data"" ), course_name <TAB> ) [ ""initialProps"" ] <TAB> entries = [ ] <TAB> for chapter_num, chapter in enumerate ( props [ ""concepts"" ], 1 ) : <TAB> <TAB> if not isinstance ( chapter, dict ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> materials = chapter. get ( ""materials"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> chapter_title = chapter. get ( ""title"" ) <TAB> <TAB> chapter_id = str_or_none ( chapter. get ( ""id"" ) ) <TAB> <TAB> for material in materials : <TAB> <TAB> <TAB> if not isinstance ( material, dict ) : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if material. get ( ""material_type"" )!= ""video"" : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> video_url = urljoin ( url, material. get ( ""url"" ) ) <TAB> <TAB> <TAB> if not video_url : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> entries. append ( <TAB> <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> <TAB> ""_type"" : ""url_transparent"", <TAB> <TAB> <TAB> <TAB> <TAB> ""url"" : video_url, <TAB> <TAB> <TAB> <TAB> <TAB> ""title"" : str_or_none ( material. get ( ""name"" ) ), <TAB> <TAB> <TAB> <TAB> <TAB> ""id"" : str_or_",False,"not materials or not isinstance(materials, list)",not materials,0.6594485640525818
|
||
|
656,"def perform_search ( self, dir, s = None, start = None, update_search_start = False ) : <TAB> self. cancel_highlight ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> s = self. last_search_string <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. ui. message ( ""No previous search term."" ) <TAB> <TAB> <TAB> return False <TAB> else : <TAB> <TAB> self. last_search_string = s <TAB> if start is None : <TAB> <TAB> start = self. search_start <TAB> case_insensitive = s. lower ( ) == s <TAB> if start > len ( self. ui. source ) : <TAB> <TAB> start = 0 <TAB> i = ( start + dir ) % len ( self. ui. source ) <TAB> if i >= len ( self. ui. source ) : <TAB> <TAB> i = 0 <TAB> while i!= start : <TAB> <TAB> sline = self. ui. source [ i ]. text <TAB> <TAB> if case_insensitive : <TAB> <TAB> <TAB> sline = sline. lower ( ) <TAB> <TAB> if s in sline : <TAB> <TAB> <TAB> sl = self. ui. source [ i ] <TAB> <TAB> <TAB> sl. set_highlight ( True ) <TAB> <TAB> <TAB> self. highlight_line = sl <TAB> <TAB> <TAB> self. ui. source. set_focus ( i ) <TAB> <TAB> <TAB> if update_search_start : <TAB> <TAB> <TAB> <TAB> self. search_start = i <TAB> <TAB> <TAB> return True <TAB> <TAB> i = ( i + dir ) % len ( self. ui. source ) <TAB> return False",True,s is None,s is None,0.6601827144622803
|
||
|
657,"def acquire ( cls, node, floating = None ) : <TAB> if isinstance ( node, Gaffer. ScriptNode ) : <TAB> <TAB> script = node <TAB> else : <TAB> <TAB> script = node. scriptNode ( ) <TAB> scriptWindow = GafferUI. ScriptWindow. acquire ( script ) <TAB> if floating in ( None, False ) : <TAB> <TAB> for editor in scriptWindow. getLayout ( ). editors ( type = cls ) : <TAB> <TAB> <TAB> if node. isSame ( editor. _lastAddedNode ( ) ) : <TAB> <TAB> <TAB> <TAB> editor. reveal ( ) <TAB> <TAB> <TAB> <TAB> return editor <TAB> if floating in ( None, True ) : <TAB> <TAB> childWindows = scriptWindow. childWindows ( ) <TAB> <TAB> for window in childWindows : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> if ( <TAB> <TAB> <TAB> <TAB> <TAB> isinstance ( window. getChild ( ), cls ) <TAB> <TAB> <TAB> <TAB> <TAB> and node in window. getChild ( ). getNodeSet ( ) <TAB> <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> <TAB> window. setVisible ( True ) <TAB> <TAB> <TAB> <TAB> <TAB> return window. getChild ( ) <TAB> editor = cls ( script ) <TAB> editor. setNodeSet ( Gaffer. StandardSet ( [ node ] ) ) <TAB> if floating is False : <TAB> <TAB> scriptWindow. getLayout ( ). addEditor ( editor ) <TAB> else : <TAB> <TAB> window = _EditorWindow ( scriptWindow, editor ) <TAB> <TAB> <TAB> <TAB> scriptWindow. menuBar ( ). addShortcutTarget ( window ) <TAB> <TAB> window. setVisible ( True ) <TAB> <TAB> if isinstance ( editor, GafferUI. NodeEditor ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB",False,"isinstance(window, _EditorWindow)",window.hasChild(),0.652677059173584
|
||
|
658,"def PyJs_updateScopeInfo_823_ ( this, arguments, var = var ) : <TAB> var = Scope ( <TAB> <TAB> { <TAB> <TAB> <TAB> u""this"" : this, <TAB> <TAB> <TAB> u""arguments"" : arguments, <TAB> <TAB> <TAB> u""updateScopeInfo"" : PyJs_updateScopeInfo_823_, <TAB> <TAB> }, <TAB> <TAB> var, <TAB> ) <TAB> var. registers ( [ u""letRefs"", u""binding"", u""key"", u""parentScope"", u""scope"", u""ref"" ] ) <TAB> var. put ( u""scope"", var. get ( u""this"" ). get ( u""scope"" ) ) <TAB> var. put ( u""parentScope"", var. get ( u""scope"" ). callprop ( u""getFunctionParent"" ) ) <TAB> var. put ( u""letRefs"", var. get ( u""this"" ). get ( u""letReferences"" ) ) <TAB> for PyJsTemp in var. get ( u""letRefs"" ) : <TAB> <TAB> var. put ( u""key"", PyJsTemp ) <TAB> <TAB> var. put ( u""ref"", var. get ( u""letRefs"" ). get ( var. get ( u""key"" ) ) ) <TAB> <TAB> var. put ( <TAB> <TAB> <TAB> u""binding"", <TAB> <TAB> <TAB> var. get ( u""scope"" ). callprop ( u""getBinding"", var. get ( u""ref"" ). get ( u""name"" ) ), <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> if PyJsStrictEq ( var. get ( u""binding"" ). get ( u""kind"" ), Js ( u""let"" ) ) or PyJsStrictEq ( <TAB> <TAB> <TAB> var. get ( u""binding"" ). get ( u""kind"" ), Js ( u""const"" ) <TAB> <TAB> )",False,var.get(u'binding').neg(),"hasattr(var, '__getitem__')",0.6478897929191589
|
||
|
659,"def validate_cpu ( self, value ) : <TAB> for k, v in value. viewitems ( ) : <TAB> <TAB> if v is None : <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise serializers. ValidationError ( ""Process types can only contain [a-z]"" ) <TAB> <TAB> shares = re. match ( CPUSHARE_MATCH, str ( v ) ) <TAB> <TAB> if not shares : <TAB> <TAB> <TAB> raise serializers. ValidationError ( ""CPU shares must be an integer"" ) <TAB> <TAB> for v in shares. groupdict ( ). viewvalues ( ) : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> i = int ( v ) <TAB> <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> <TAB> raise serializers. ValidationError ( ""CPU shares must be an integer"" ) <TAB> <TAB> <TAB> if i > 1024 or i < 0 : <TAB> <TAB> <TAB> <TAB> raise serializers. ValidationError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""CPU shares must be between 0 and 1024"" <TAB> <TAB> <TAB> <TAB> ) <TAB> return value",False,"not re.match(PROCTYPE_MATCH, k)","k in ['cpu_types', 'a-z']",0.6512911319732666
|
||
|
660,"def tables_size ( results ) : <TAB> print ( ""\nSIZE RESULTS\n"" ) <TAB> sizes_per_datatype = { } <TAB> for ser in results : <TAB> <TAB> for datatype in results [ ser ] [ ""sizes"" ] : <TAB> <TAB> <TAB> size = results [ ser ] [ ""sizes"" ] [ datatype ] <TAB> <TAB> <TAB> if datatype not in sizes_per_datatype : <TAB> <TAB> <TAB> <TAB> sizes_per_datatype [ datatype ] = [ ] <TAB> <TAB> <TAB> sizes_per_datatype [ datatype ]. append ( ( size, ser ) ) <TAB> sizes_per_datatype = { <TAB> <TAB> datatype : sorted ( sizes ) for datatype, sizes in sizes_per_datatype. items ( ) <TAB> } <TAB> for dt in sorted ( sizes_per_datatype ) : <TAB> <TAB> print ( dt ) <TAB> <TAB> for pos, ( size, serializer ) in enumerate ( sizes_per_datatype [ dt ] ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> size = ""unsupported"" <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> size = ""%8d"" % size <TAB> <TAB> <TAB> print ( "" %2d: %-8s %s"" % ( pos + 1, serializer, size ) ) <TAB> print ( )",False,size == no_result,pos == 0,0.6601654887199402
|
||
|
661,"def _get_sources ( self ) : <TAB> server_links = { <TAB> <TAB> ""mp4upload"" : ""https://www.mp4upload.com/embed-{}.html"", <TAB> <TAB> ""trollvid"" : ""https://trollvid.net/embed/{}"", <TAB> } <TAB> resp = helpers. soupify ( helpers. get ( self. url ). text ). find_all ( ""script"" ) <TAB> for i in resp : <TAB> <TAB> if i. string : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> res = i. string <TAB> hosts = json. loads ( re. search ( r""(\[[^)]+\])"", res ). group ( 1 ) ) <TAB> logger. debug ( ""Hosts: {}"". format ( hosts ) ) <TAB> sources_list = [ ] <TAB> for i in hosts : <TAB> <TAB> for j in server_links : <TAB> <TAB> <TAB> if i. get ( ""host"" ) in j and i. get ( ""source"" ) : <TAB> <TAB> <TAB> <TAB> sources_list. append ( <TAB> <TAB> <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""extractor"" : j, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""url"" : server_links [ j ]. format ( i [ ""source"" ] ), <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""server"" : j, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""version"" : i [ ""source"" ], <TAB> <TAB> <TAB> <TAB> <TAB> } <TAB> <TAB> <TAB> <TAB> ) <TAB> return self. sort_sources ( sources_list )",False,'sources' in i.string,i.string[1] not in'<TAB > <TAB >'',0.6623613238334656
|
||
|
662,"def get_command ( cls ) : <TAB> ifconfig_cmd = ""ifconfig"" <TAB> for path in [ ""/sbin"", ""/usr/sbin"", ""/bin"", ""/usr/bin"" ] : <TAB> <TAB> if os. path. exists ( os. path. join ( path, ifconfig_cmd ) ) : <TAB> <TAB> <TAB><mask> : <TAB> <TAB> <TAB> break <TAB> ifconfig_cmd = ifconfig_cmd + "" -a"" <TAB> return ifconfig_cmd",False,"ifconfig_cmd = os.path.join(path, ifconfig_cmd)","os.path.exists(os.path.join(path, ifconfig_cmd))",0.6442980170249939
|
||
|
663,"def registerExtensions ( self, extensions, configs ) : <TAB> if not configs : <TAB> <TAB> configs = { } <TAB> for ext in extensions : <TAB> <TAB> extension_module_name = ""mdx_"" + ext <TAB> <TAB> try : <TAB> <TAB> <TAB> module = __import__ ( extension_module_name ) <TAB> <TAB> except : <TAB> <TAB> <TAB> message ( <TAB> <TAB> <TAB> <TAB> CRITICAL, <TAB> <TAB> <TAB> <TAB> ""couldn't load extension %s (looking for %s module)"" <TAB> <TAB> <TAB> <TAB> % ( ext, extension_module_name ), <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> configs_for_ext = configs [ ext ] <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> configs_for_ext = [ ] <TAB> <TAB> <TAB> extension = module. makeExtension ( configs_for_ext ) <TAB> <TAB> <TAB> extension. extendMarkdown ( self, globals ( ) )",False,configs.has_key(ext),ext in configs,0.6512950658798218
|
||
|
664,"def eventloop ( self ) : <TAB> poll = select. poll ( ) <TAB> event_read_mask = self. errorevents | self. readevents <TAB> poll. register ( self. serversock. fileno ( ) ) <TAB> poll. register ( self. readpipe, event_read_mask ) <TAB> breakout = False <TAB> self. running = True <TAB> self. logger. debug ( ""Starting thread event loop"" ) <TAB> while not breakout : <TAB> <TAB> events = poll. poll ( ) <TAB> <TAB> for event in events : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if event [ 1 ] & self. errorevents : <TAB> <TAB> <TAB> <TAB> raise Exception ( self. stringify_event ( event [ 1 ] ) ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if self. readpipe == event [ 0 ] : <TAB> <TAB> <TAB> <TAB> self. logger. debug ( ""Stop event received"" ) <TAB> <TAB> <TAB> <TAB> breakout = True <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> self. logger. debug ( ""Connection request received"" ) <TAB> <TAB> <TAB> <TAB> self. readsock, _ = self. serversock. accept ( ) <TAB> <TAB> <TAB> <TAB> self. readsock. setblocking ( 0 ) <TAB> <TAB> <TAB> <TAB> poll. unregister ( self. serversock. fileno ( ) ) <TAB> <TAB> <TAB> <TAB> poll. register ( self. readsock. fileno ( ), event_read_mask ) <TAB> <TAB> <TAB> <TAB> self. logger. debug ( ""Setting connection established event"" ) <TAB> <TAB> <TAB> <TAB> self. connection_established. set ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> elif self. readsock. fileno ( ) == event [ 0 ] : <",False,self.serversock.fileno() == event[0],self.connection_established == event[0],0.6566035151481628
|
||
|
665,"def _list_item_sub ( self, match ) : <TAB> item = match. group ( 4 ) <TAB> leading_line = match. group ( 1 ) <TAB> if leading_line or ""\n\n"" in item or self. _last_li_endswith_two_eols : <TAB> <TAB> item = self. _run_block_gamut ( self. _outdent ( item ) ) <TAB> else : <TAB> <TAB> <TAB> <TAB> item = self. _do_lists ( self. _outdent ( item ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> item = item [ : - 1 ] <TAB> <TAB> item = self. _run_span_gamut ( item ) <TAB> self. _last_li_endswith_two_eols = len ( match. group ( 5 ) ) == 2 <TAB> if ""task_list"" in self. extras : <TAB> <TAB> item = self. _task_list_item_re. sub ( self. _task_list_item_sub, item ) <TAB> return ""<li>%s</li>\n"" % item",False,item.endswith('\n'),item.endswith(b'<TAB>'),0.6490521430969238
|
||
|
666,"def update ( self, x, who = None, metadata = None ) : <TAB> self. _retain_refs ( metadata ) <TAB> y = self. _get_key ( x ) <TAB> if self. keep == ""last"" : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _buffer. pop ( y, None ) <TAB> <TAB> self. _metadata_buffer. pop ( y, None ) <TAB> <TAB> self. _buffer [ y ] = x <TAB> <TAB> self. _metadata_buffer [ y ] = metadata <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _buffer [ y ] = x <TAB> <TAB> <TAB> self. _metadata_buffer [ y ] = metadata <TAB> return self. last",False,y not in self._buffer,self.keep == 'previous',0.6640939712524414
|
||
|
667,"def _GetValue ( value_pb ) : <TAB> """"""Gets the value from the value_pb."""""" <TAB> if value_pb. type ( ) in _PROTO_FIELDS_STRING_VALUE : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return value_pb. string_value ( ) <TAB> <TAB> return None <TAB> if value_pb. type ( ) == document_pb. FieldValue. DATE : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return search_util. DeserializeDate ( value_pb. string_value ( ) ) <TAB> <TAB> return None <TAB> if value_pb. type ( ) == document_pb. FieldValue. NUMBER : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return float ( value_pb. string_value ( ) ) <TAB> <TAB> return None <TAB> if value_pb. type ( ) == document_pb. FieldValue. GEO : <TAB> <TAB> if value_pb. has_geo ( ) : <TAB> <TAB> <TAB> geo_pb = value_pb. geo ( ) <TAB> <TAB> <TAB> return GeoPoint ( latitude = geo_pb. lat ( ), longitude = geo_pb. lng ( ) ) <TAB> <TAB> return None <TAB> raise TypeError ( ""unknown FieldValue type %d"" % value_pb. type ( ) )",False,value_pb.has_string_value(),value_pb.type() == document_pb.FieldValue.FLOAT,0.6523259282112122
|
||
|
668,"def forms_list ( self, trans, payload = None, ** kwd ) : <TAB> message = kwd. get ( ""message"", """" ) <TAB> status = kwd. get ( ""status"", """" ) <TAB> if ""operation"" in kwd : <TAB> <TAB> id = kwd. get ( ""id"" ) <TAB> <TAB> if not id : <TAB> <TAB> <TAB> return self. message_exception ( <TAB> <TAB> <TAB> <TAB> trans, ""Invalid form id (%s) received."" % str ( id ) <TAB> <TAB> <TAB> ) <TAB> <TAB> ids = util. listify ( id ) <TAB> <TAB> operation = kwd [ ""operation"" ]. lower ( ) <TAB> <TAB> if operation == ""delete"" : <TAB> <TAB> <TAB> message, status = self. _delete_form ( trans, ids ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> message, status = self. _undelete_form ( trans, ids ) <TAB> if message and status : <TAB> <TAB> kwd [ ""message"" ] = util. sanitize_text ( message ) <TAB> <TAB> kwd [ ""status"" ] = status <TAB> return self. forms_grid ( trans, ** kwd )",True,operation == 'undelete',operation == 'undelete',0.6647933721542358
|
||
|
669,"def update_obj ( obj, new, fatal_errors = True ) : <TAB> elems = list ( obj. keys ( ) ) <TAB> if ""Conf"" in elems : <TAB> <TAB> elems. remove ( ""Conf"" ) <TAB> <TAB> elems. insert ( 0, ""Conf"" ) <TAB> if ""Env"" in elems : <TAB> <TAB> elems. remove ( ""Env"" ) <TAB> <TAB> obj [ ""Env"" ]. update ( new [ ""Env"" ] ) <TAB> if ""Hist"" in elems : <TAB> <TAB> elems. remove ( ""Hist"" ) <TAB> <TAB> obj [ ""Hist"" ] += new [ ""Hist"" ] <TAB> for elem in elems : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> for key, value in new [ elem ]. items ( ) : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> obj [ elem ] [ key ] = value <TAB> <TAB> <TAB> <TAB> except Exception as error : <TAB> <TAB> <TAB> <TAB> <TAB> item_repr = ""session.%s.%s"" % ( elem, key ) <TAB> <TAB> <TAB> <TAB> <TAB> msg_prefix = ""[-] Couldn't set %s"" % item_repr <TAB> <TAB> <TAB> <TAB> <TAB> if fatal_errors : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> print ( ""%s:"" % msg_prefix ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> raise <TAB> <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> print ( ""%s: %s"" % ( msg_prefix, error ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> obj [ elem ] = new [ elem ] <TAB> return obj",False,"isinstance(obj[elem], dict)","hasattr(obj, elem)",0.6576023697853088
|
||
|
670,"def _process_rtdest ( self ) : <TAB> LOG. debug ( ""Processing RT NLRI destination..."" ) <TAB> if self. _rtdest_queue. is_empty ( ) : <TAB> <TAB> return <TAB> else : <TAB> <TAB> processed_any = False <TAB> <TAB> while not self. _rtdest_queue. is_empty ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> next_dest = self. _rtdest_queue. pop_first ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> next_dest. process ( ) <TAB> <TAB> <TAB> <TAB> processed_any = True <TAB> <TAB> if processed_any : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _core_service. update_rtfilters ( )",True,next_dest,next_dest,0.6787724494934082
|
||
|
671,"def display_my_sessions_view ( ) : <TAB> placeholder_images = DataGetter. get_event_default_images ( ) <TAB> custom_placeholder = DataGetter. get_custom_placeholders ( ) <TAB> upcoming_events_sessions = DataGetter. get_sessions_of_user ( upcoming_events = True ) <TAB> im_config = DataGetter. get_image_configs ( ) <TAB> im_size = """" <TAB> for config in im_config : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> im_size = config. size <TAB> past_events_sessions = DataGetter. get_sessions_of_user ( upcoming_events = False ) <TAB> page_content = { <TAB> <TAB> ""tab_upcoming_events"" : ""Upcoming Sessions"", <TAB> <TAB> ""tab_past_events"" : ""Past Sessions"", <TAB> <TAB> ""title"" : ""My Session Proposals"", <TAB> } <TAB> if not AuthManager. is_verified_user ( ) : <TAB> <TAB> flash ( <TAB> <TAB> <TAB> Markup ( <TAB> <TAB> <TAB> <TAB> ""Your account is unverified. "" <TAB> <TAB> <TAB> <TAB> ""Please verify by clicking on the confirmation link that has been emailed to you."" <TAB> <TAB> <TAB> <TAB> '<br>Did not get the email? Please <a href=""/resend_email/"" class=""alert-link"">'<TAB> <TAB> <TAB> <TAB> ""click here to resend the confirmation.</a>"" <TAB> <TAB> <TAB> ) <TAB> <TAB> ) <TAB> return render_template ( <TAB> <TAB> ""gentelella/users/mysessions/mysessions_list.html"", <TAB> <TAB> upcoming_events_sessions = upcoming_events_sessions, <TAB> <TAB> past_events_sessions = past_events_sessions, <TAB> <TAB> page_content = page_content, <TAB> <TAB> placeholder_images = placeholder_images, <TAB> <TAB> custom_",False,config.page == 'mysession',config.size,0.6551402807235718
|
||
|
672,"def get_engine ( user, engine = ""solr"", facet = None, source = ""data"", cluster = '""""' ) : <TAB> if isinstance ( engine, dict ) : <TAB> <TAB> if source == ""data"" : <TAB> <TAB> <TAB> source = engine. get ( ""source"" ) <TAB> <TAB> engine = engine. get ( ""engine"", ""solr"" ) <TAB> if engine == ""report"" and facet : <TAB> <TAB> engine = facet [ ""properties"" ]. get ( ""engine"" ) <TAB> if engine!= ""solr"" : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> from impala. dashboard_api import ImpalaDashboardApi <TAB> <TAB> <TAB> return ImpalaDashboardApi ( user, engine, source = source, cluster = cluster ) <TAB> <TAB> elif engine == ""hive"" : <TAB> <TAB> <TAB> from beeswax. dashboard_api import HiveDashboardApi <TAB> <TAB> <TAB> return HiveDashboardApi ( user, engine, source = source, cluster = cluster ) <TAB> <TAB> else : <TAB> <TAB> <TAB> from notebook. dashboard_api import SQLDashboardApi <TAB> <TAB> <TAB> return SQLDashboardApi ( user, engine, source = source, cluster = cluster ) <TAB> else : <TAB> <TAB> from search. dashboard_api import SearchApi <TAB> <TAB> <TAB> <TAB> return SearchApi ( user, cluster )",False,engine == 'impala',engine == 'Impala',0.658246636390686
|
||
|
673,"def printHexFormat ( data, addr, nocolor = False ) : <TAB> for i in range ( ( int ( len ( data ) / 16 ) ) + 1 ) : <TAB> <TAB> part = data [ i * 16 : i * 16 + 16 ] <TAB> <TAB> bytes = cstr ( """" ) <TAB> <TAB> c = 0 <TAB> <TAB> for j in range ( 0, len ( part ), 2 ) : <TAB> <TAB> <TAB> if j == len ( part ) - 1 : <TAB> <TAB> <TAB> <TAB> bytes += cstr ( <TAB> <TAB> <TAB> <TAB> <TAB> ( ""%.2x "" % tuple ( part [ j : j + 1 ] ) ), <TAB> <TAB> <TAB> <TAB> <TAB> Color. WHITE if c % 2 else Color. LIGHT_GRAY, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> bytes += cstr ( <TAB> <TAB> <TAB> <TAB> <TAB> ( ""%.2x%.2x "" % tuple ( part [ j : j + 2 ] ) ), <TAB> <TAB> <TAB> <TAB> <TAB> Color. WHITE if c % 2 else Color. LIGHT_GRAY, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> c += 1 <TAB> <TAB> string = """" <TAB> <TAB> if nocolor : <TAB> <TAB> <TAB> if len ( bytes ) < 40 : <TAB> <TAB> <TAB> <TAB> bytes += "" "" * ( 40 - len ( bytes ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if len ( bytes ) < 227 : <TAB> <TAB> <TAB> <TAB> bytes += "" "" * ( ( 8 - int ( len ( bytes ) / 29 ) ) * 5 ) <TAB> <TAB> for b in part : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> string += ""."" <TAB> <TAB> <TAB> else : <",False,b < 32 or b > 126,b in addr,0.6571352481842041
|
||
|
674,"def __iter__ ( self ) : <TAB> for name, value in self. __class__. __dict__. items ( ) : <TAB> <TAB> if isinstance ( value, alias_flag_value ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> yield ( name, self. _has_flag ( value. flag ) )",False,"isinstance(value, flag_value)","isinstance(value, value._field_value)",0.648002564907074
|
||
|
675,"def _read_allele_freq_table ( f ) : <TAB> line = f. readline ( ) <TAB> while "" --"" not in line : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise StopIteration <TAB> <TAB> if ""No data"" in line : <TAB> <TAB> <TAB> return None, None <TAB> <TAB> line = f. readline ( ) <TAB> alleles = [ x for x in f. readline ( ). rstrip ( ). split ( "" "" ) if x!= """" ] <TAB> alleles = [ _gp_int ( x ) for x in alleles ] <TAB> line = f. readline ( ). rstrip ( ) <TAB> table = [ ] <TAB> while line!= """" : <TAB> <TAB> parts = [ x for x in line. split ( "" "" ) if x!= """" ] <TAB> <TAB> try : <TAB> <TAB> <TAB> table. append ( <TAB> <TAB> <TAB> <TAB> ( parts [ 0 ], [ _gp_float ( x ) for x in parts [ 1 : - 1 ] ], _gp_int ( parts [ - 1 ] ) ) <TAB> <TAB> <TAB> ) <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> table. append ( ( parts [ 0 ], [ None ] * len ( alleles ), 0 ) ) <TAB> <TAB> line = f. readline ( ). rstrip ( ) <TAB> return alleles, table",True,line == '',line == '',0.6783540844917297
|
||
|
676,"def check_require ( require_modules, require_lines ) : <TAB> for require_module in require_modules : <TAB> <TAB> st = try_import ( require_module ) <TAB> <TAB> if st == 0 : <TAB> <TAB> <TAB> continue <TAB> <TAB> elif st == 1 : <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> ""installed {}: {}\n"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> require_module, require_lines [ require_module ] <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> ""failed installed {}: {}\n"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> require_module, require_lines [ require_module ] <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> )",True,st == 2,st == 2,0.6821781396865845
|
||
|
677,"def prefixed ( self, prefix : _StrType ) -> typing. Iterator [ ""Env"" ] : <TAB> """"""Context manager for parsing envvars with a common prefix."""""" <TAB> try : <TAB> <TAB> old_prefix = self. _prefix <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _prefix = prefix <TAB> <TAB> else : <TAB> <TAB> <TAB> self. _prefix = f""{old_prefix}{prefix}"" <TAB> <TAB> yield self <TAB> finally : <TAB> <TAB> <TAB> <TAB> self. _prefix = None <TAB> self. _prefix = old_prefix",True,old_prefix is None,old_prefix is None,0.6638089418411255
|
||
|
678,"def compute_up ( expr, data, ** kwargs ) : <TAB> if isinstance ( expr. slice, _inttypes ) : <TAB> <TAB> idx = expr. slice + 1 <TAB> <TAB> if idx < 1 : <TAB> <TAB> <TAB> msg = ""Index {} out-of-bounds for SQL string indexing."" <TAB> <TAB> <TAB> raise IndexError ( msg. format ( expr. slice ) ) <TAB> <TAB> args = idx, 1 <TAB> elif isinstance ( expr. slice, tuple ) : <TAB> <TAB> start, stop, step = expr. slice <TAB> <TAB> if step is not None : <TAB> <TAB> <TAB> msg = ""step value {} not valid for SQL string indexing."" <TAB> <TAB> <TAB> raise ValueError ( msg. format ( step ) ) <TAB> <TAB> norm_start = start if isinstance ( start, _inttypes ) else 0 <TAB> <TAB> if norm_start < 0 : <TAB> <TAB> <TAB> msg = ""Negative indexing not valid for SQL strings; given {}."" <TAB> <TAB> <TAB> raise ValueError ( msg. format ( norm_start ) ) <TAB> <TAB> if isinstance ( stop, _inttypes ) : <TAB> <TAB> <TAB> if stop < 0 : <TAB> <TAB> <TAB> <TAB> msg = ""Negative indexing not valid for SQL strings; given {}."" <TAB> <TAB> <TAB> <TAB> raise ValueError ( msg. format ( stop ) ) <TAB> <TAB> <TAB> args = norm_start + 1, ( stop - norm_start ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> args = ( norm_start + 1, ) <TAB> return sa. sql. func. substring ( data, * args )",False,stop is None,norm_start > 0,0.6667633056640625
|
||
|
679,"def handle_read ( self, socket_ ) : <TAB> try : <TAB> <TAB> data, ( addr, port ) = socket_. recvfrom ( _MAX_MSG_ABSOLUTE ) <TAB> except Exception : <TAB> <TAB> self. log_exception_warning ( ) <TAB> <TAB> return <TAB> log. debug ( ""Received from %r:%r: %r "", addr, port, data ) <TAB> self. data = data <TAB> msg = DNSIncoming ( data ) <TAB> if not msg. valid : <TAB> <TAB> pass <TAB> elif msg. is_query ( ) : <TAB> <TAB> <TAB> <TAB> if port == _MDNS_PORT : <TAB> <TAB> <TAB> self. zc. handle_query ( msg, _MDNS_ADDR, _MDNS_PORT ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> self. zc. handle_query ( msg, addr, port ) <TAB> <TAB> <TAB> self. zc. handle_query ( msg, _MDNS_ADDR, _MDNS_PORT ) <TAB> else : <TAB> <TAB> self. zc. handle_response ( msg )",False,port == _DNS_PORT,addr == _MDNS_ADDR,0.6592108011245728
|
||
|
680,"def get_schema ( form_fields ) : <TAB> attrs = { } <TAB> for field in form_fields : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> field_type = marshmallow. fields. Str <TAB> <TAB> elif field. type == ""email"" : <TAB> <TAB> <TAB> field_type = marshmallow. fields. Email <TAB> <TAB> elif field. type == ""number"" : <TAB> <TAB> <TAB> field_type = marshmallow. fields. Float <TAB> <TAB> else : <TAB> <TAB> <TAB> raise UnprocessableEntityError ( <TAB> <TAB> <TAB> <TAB> { ""pointer"" : ""/data/complex-field-values/"" + field. identifier }, <TAB> <TAB> <TAB> <TAB> ""Invalid Field Type: "" + field. type, <TAB> <TAB> <TAB> ) <TAB> <TAB> attrs [ field. identifier ] = field_type ( required = field. is_required ) <TAB> return type ( ""DynamicSchema"", ( marshmallow. Schema, ), attrs )",False,"field.type in ['text', 'checkbox', 'select']",field.type == 'str',0.6524022817611694
|
||
|
681,"def __init__ ( self, app ) : <TAB> self. _credential = app. credential <TAB> db_url = app. options. get ( ""databaseURL"" ) <TAB> if db_url : <TAB> <TAB> self. _db_url = db_url <TAB> else : <TAB> <TAB> self. _db_url = None <TAB> auth_override = _DatabaseService. _get_auth_override ( app ) <TAB> if auth_override not in ( self. _DEFAULT_AUTH_OVERRIDE, { } ) : <TAB> <TAB> self. _auth_override = json. dumps ( auth_override, separators = ( "","", "":"" ) ) <TAB> else : <TAB> <TAB> self. _auth_override = None <TAB> self. _timeout = app. options. get ( ""httpTimeout"", _http_client. DEFAULT_TIMEOUT_SECONDS ) <TAB> self. _clients = { } <TAB> emulator_host = os. environ. get ( _EMULATOR_HOST_ENV_VAR ) <TAB> if emulator_host : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> 'Invalid {0}: ""{1}"". It must follow format ""host:port"".'. format ( <TAB> <TAB> <TAB> <TAB> <TAB> _EMULATOR_HOST_ENV_VAR, emulator_host <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> self. _emulator_host = emulator_host <TAB> else : <TAB> <TAB> self. _emulator_host = None",False,'//' in emulator_host,not _IP_PORT_ADDRESS.match(emulator_host),0.6563094258308411
|
||
|
682,"def platformGetMaps ( self ) : <TAB> maps = [ ] <TAB> address = ctypes. c_ulong ( 0 ) <TAB> mapsize = ctypes. c_ulong ( 0 ) <TAB> name = ctypes. c_uint32 ( 0 ) <TAB> count = ctypes. c_uint32 ( VM_REGION_BASIC_INFO_COUNT_64 ) <TAB> info = vm_region_basic_info_64 ( ) <TAB> while True : <TAB> <TAB> r = self. libc. mach_vm_region ( <TAB> <TAB> <TAB> self. task, <TAB> <TAB> <TAB> addrof ( address ), <TAB> <TAB> <TAB> addrof ( mapsize ), <TAB> <TAB> <TAB> VM_REGION_BASIC_INFO_64, <TAB> <TAB> <TAB> addrof ( info ), <TAB> <TAB> <TAB> addrof ( count ), <TAB> <TAB> <TAB> addrof ( name ), <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> if r == 1 : <TAB> <TAB> <TAB> break <TAB> <TAB> if r!= 0 : <TAB> <TAB> <TAB> self. libc. mach_error ( ""mach_vm_region"", r ) <TAB> <TAB> <TAB> raise Exception ( ""vm_region Failed for 0x%.8x: 0x%.8x"" % ( address. value, r ) ) <TAB> <TAB> perms = 0 <TAB> <TAB> p = info. protection <TAB> <TAB> if p & VM_PROT_READ : <TAB> <TAB> <TAB> perms |= e_mem. MM_READ <TAB> <TAB> if p & VM_PROT_WRITE : <TAB> <TAB> <TAB> perms |= e_mem. MM_WRITE <TAB> <TAB> if p & VM_PROT_EXECUTE : <TAB> <TAB> <TAB> perms |= e_mem. MM_EXEC <TAB> <TAB> if info. shared : <TAB> <TAB> <TAB> perms |= e_mem. MM_SHARED <TAB> <TAB>",False,perms,maps[0],0.6890894174575806
|
||
|
683,"def _set_qresult_hits ( qresult, hit_rows = ( ) ) : <TAB> """"""Append Hits without alignments into QueryResults (PRIVATE)."""""" <TAB> for hit_row in hit_rows : <TAB> <TAB> hit_id, remainder = hit_row. split ( "" "", 1 ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> frag = HSPFragment ( hit_id, qresult. id ) <TAB> <TAB> <TAB> hsp = HSP ( [ frag ] ) <TAB> <TAB> <TAB> hit = Hit ( [ hsp ] ) <TAB> <TAB> <TAB> qresult. append ( hit ) <TAB> return qresult",False,hit_id not in qresult,remainder,0.671747624874115
|
||
|
684,"def process_ifconfig_nodes ( app : Sphinx, doctree : nodes. document, docname : str ) -> None : <TAB> ns = { confval. name : confval. value for confval in app. config } <TAB> ns. update ( app. config. __dict__. copy ( ) ) <TAB> ns [ ""builder"" ] = app. builder. name <TAB> for node in doctree. traverse ( ifconfig ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> res = eval ( node [ ""expr"" ], ns ) <TAB> <TAB> except Exception as err : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> from traceback import format_exception_only <TAB> <TAB> <TAB> msg = """". join ( format_exception_only ( err. __class__, err ) ) <TAB> <TAB> <TAB> newnode = doctree. reporter. error ( <TAB> <TAB> <TAB> <TAB> ""Exception occurred in "" ""ifconfig expression: \n%s"" % msg, <TAB> <TAB> <TAB> <TAB> base_node = node, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> node. replace_self ( newnode ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> node. replace_self ( [ ] ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> node. replace_self ( node. children )",False,not res,node.children is None,0.6831022500991821
|
||
|
685,"def explain ( self, other, depth = 0 ) : <TAB> exp = super ( UnionType, self ). explain ( other, depth ) <TAB> for ndx, subtype in enumerate ( self. params [ ""allowed_types"" ] ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> exp += ""\n{}and"". format ( """". join ( [ ""\t"" ] * depth ) ) <TAB> <TAB> exp += ""\n"" + subtype. explain ( other, depth = depth + 1 ) <TAB> return exp",True,ndx > 0,ndx > 0,0.6678018569946289
|
||
|
686,"def convert_with_key ( self, key, value, replace = True ) : <TAB> result = self. configurator. convert ( value ) <TAB> <TAB> if value is not result : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self [ key ] = result <TAB> <TAB> if type ( result ) in ( ConvertingDict, ConvertingList, ConvertingTuple ) : <TAB> <TAB> <TAB> result. parent = self <TAB> <TAB> <TAB> result. key = key <TAB> return result",True,replace,replace,0.6944632530212402
|
||
|
687,"def OnLeftUp ( self, event ) : <TAB> btnpos = self. GetButtonsPos ( ) <TAB> btnsize = self. GetButtonsSize ( ) <TAB> if self. HasCapture ( ) : <TAB> <TAB> self. ReleaseMouse ( ) <TAB> for btn in range ( 2 ) : <TAB> <TAB> if self. HitTest ( btnpos [ btn ], event. GetPosition ( ), btnsize [ btn ] ) : <TAB> <TAB> <TAB> if btn == 0 : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> self. searchButtonPressed = False <TAB> <TAB> <TAB> <TAB> <TAB> self. Refresh ( ) <TAB> <TAB> <TAB> <TAB> <TAB> self. SetFocus ( ) <TAB> <TAB> <TAB> <TAB> <TAB> wx. PostEvent ( self, SearchButton ( ) ) <TAB> <TAB> <TAB> if btn == 1 : <TAB> <TAB> <TAB> <TAB> if self. cancelButtonPressed : <TAB> <TAB> <TAB> <TAB> <TAB> self. cancelButtonPressed = False <TAB> <TAB> <TAB> <TAB> <TAB> self. Refresh ( ) <TAB> <TAB> <TAB> <TAB> <TAB> self. SetFocus ( ) <TAB> <TAB> <TAB> <TAB> <TAB> wx. PostEvent ( self, CancelButton ( ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if btn == 0 : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> self. searchButtonPressed = False <TAB> <TAB> <TAB> <TAB> <TAB> self. Refresh ( ) <TAB> <TAB> <TAB> if btn == 1 : <TAB> <TAB> <TAB> <TAB> if self. cancelButtonPressed : <TAB> <TAB> <TAB> <TAB> <TAB> self. cancelButtonPressed = False <TAB> <TAB> <TAB> <TAB> <TAB> self. Refresh ( )",True,self.searchButtonPressed,self.searchButtonPressed,0.6666840314865112
|
||
|
688,"def get_boarding_status ( project ) : <TAB> status = ""Pending"" <TAB> if project : <TAB> <TAB> doc = frappe. get_doc ( ""Project"", project ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> status = ""In Process"" <TAB> <TAB> elif flt ( doc. percent_complete ) == 100.0 : <TAB> <TAB> <TAB> status = ""Completed"" <TAB> <TAB> return status",False,flt(doc.percent_complete) > 0.0 and flt(doc.percent_complete) < 100.0,doc.percent_complete >= 0.0,0.655147910118103
|
||
|
689,"def replace_all ( self, event = None ) : <TAB> prog = self. engine. getprog ( ) <TAB> if not prog : <TAB> <TAB> return <TAB> repl = self. replvar. get ( ) <TAB> text = self. text <TAB> res = self. engine. search_text ( text, prog ) <TAB> if not res : <TAB> <TAB> text. bell ( ) <TAB> <TAB> return <TAB> text. tag_remove ( ""sel"", ""1.0"", ""end"" ) <TAB> text. tag_remove ( ""hit"", ""1.0"", ""end"" ) <TAB> line = res [ 0 ] <TAB> col = res [ 1 ]. start ( ) <TAB> if self. engine. iswrap ( ) : <TAB> <TAB> line = 1 <TAB> <TAB> col = 0 <TAB> ok = 1 <TAB> first = last = None <TAB> <TAB> text. undo_block_start ( ) <TAB> while 1 : <TAB> <TAB> res = self. engine. search_forward ( text, prog, line, col, 0, ok ) <TAB> <TAB> if not res : <TAB> <TAB> <TAB> break <TAB> <TAB> line, m = res <TAB> <TAB> chars = text. get ( ""%d.0"" % line, ""%d.0"" % ( line + 1 ) ) <TAB> <TAB> orig = m. group ( ) <TAB> <TAB> new = self. _replace_expand ( m, repl ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> break <TAB> <TAB> i, j = m. span ( ) <TAB> <TAB> first = ""%d.%d"" % ( line, i ) <TAB> <TAB> last = ""%d.%d"" % ( line, j ) <TAB> <TAB> if new == orig : <TAB> <TAB> <TAB> text. mark_set ( ""insert"", last ) <TAB> <TAB> else : <TAB> <TAB> <TAB> text. mark_set ( ""insert"", first ) <TAB> <TAB> <TAB> if first!= last : <TAB>",False,new is None,new == chars,0.6622529029846191
|
||
|
690,"def normalize_host ( host ) : <TAB> """"""Normalize a host string."""""" <TAB> if misc. IPv6_MATCHER. match ( host ) : <TAB> <TAB> percent = host. find ( ""%"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> percent_25 = host. find ( ""%25"" ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if ( <TAB> <TAB> <TAB> <TAB> percent_25 == - 1 <TAB> <TAB> <TAB> <TAB> or percent < percent_25 <TAB> <TAB> <TAB> <TAB> or ( percent == percent_25 and percent_25 == len ( host ) - 4 ) <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> host = host. replace ( ""%"", ""%25"", 1 ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return host [ : percent ]. lower ( ) + host [ percent : ] <TAB> return host. lower ( )",False,percent != -1,percent > -1,0.6667181849479675
|
||
|
691,"def get_indexes ( self, cursor, table_name ) : <TAB> indexes = { } <TAB> for info in self. _table_info ( cursor, table_name ) : <TAB> <TAB> if info [ ""pk"" ]!= 0 : <TAB> <TAB> <TAB> indexes [ info [ ""name"" ] ] = { ""primary_key"" : True, ""unique"" : False } <TAB> cursor. execute ( ""PRAGMA index_list(%s)"" % self. connection. ops. quote_name ( table_name ) ) <TAB> <TAB> for index, unique in [ ( field [ 1 ], field [ 2 ] ) for field in cursor. fetchall ( ) ] : <TAB> <TAB> cursor. execute ( ""PRAGMA index_info(%s)"" % self. connection. ops. quote_name ( index ) ) <TAB> <TAB> info = cursor. fetchall ( ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> name = info [ 0 ] [ 2 ] <TAB> <TAB> indexes [ name ] = { ""primary_key"" : False, ""unique"" : unique } <TAB> return indexes",False,len(info) != 1,len(info) < 3,0.6550526022911072
|
||
|
692,"def __init__ ( self, parent, name, description = None ) : <TAB> FieldSet. __init__ ( self, parent, name, description ) <TAB> self. _size = ( self [ ""size"" ]. value + 3 * 4 ) * 8 <TAB> if MAX_CHUNK_SIZE < ( self. _size // 8 ) : <TAB> <TAB> raise ParserError ( ""PNG: Chunk is too big (%s)"" % humanFilesize ( self. _size // 8 ) ) <TAB> tag = self [ ""tag"" ]. value <TAB> self. desc_func = None <TAB> self. value_func = None <TAB> if tag in self. TAG_INFO : <TAB> <TAB> self. _name, self. parse_func, desc, value_func = self. TAG_INFO [ tag ] <TAB> <TAB> if value_func : <TAB> <TAB> <TAB> self. value_func = value_func <TAB> <TAB> <TAB> self. createValue = self. createValueFunc <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if isinstance ( desc, str ) : <TAB> <TAB> <TAB> <TAB> self. _description = desc <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. desc_func = desc <TAB> else : <TAB> <TAB> self. _description = """" <TAB> <TAB> self. parse_func = None",True,desc,desc,0.701418399810791
|
||
|
693,"def extract ( self, mp3 ) : <TAB> if ""/frames/frame[0]"" in mp3 : <TAB> <TAB> frame = mp3 [ ""/frames/frame[0]"" ] <TAB> <TAB> self. nb_channel = ( frame. getNbChannel ( ), frame [ ""channel_mode"" ]. display ) <TAB> <TAB> self. format_version = u""MPEG version %s layer %s"" % ( <TAB> <TAB> <TAB> frame [ ""version"" ]. display, <TAB> <TAB> <TAB> frame [ ""layer"" ]. display, <TAB> <TAB> ) <TAB> <TAB> self. sample_rate = frame. getSampleRate ( ) <TAB> <TAB> self. bits_per_sample = 16 <TAB> <TAB> if mp3 [ ""frames"" ]. looksConstantBitRate ( ) : <TAB> <TAB> <TAB> self. computeBitrate ( frame ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. computeVariableBitrate ( mp3 ) <TAB> if ""id3v1"" in mp3 : <TAB> <TAB> id3 = mp3 [ ""id3v1"" ] <TAB> <TAB> self. comment = id3 [ ""comment"" ]. value <TAB> <TAB> self. author = id3 [ ""author"" ]. value <TAB> <TAB> self. title = id3 [ ""song"" ]. value <TAB> <TAB> self. album = id3 [ ""album"" ]. value <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. creation_date = id3 [ ""year"" ]. value <TAB> <TAB> if ""track_nb"" in id3 : <TAB> <TAB> <TAB> self. track_number = id3 [ ""track_nb"" ]. value <TAB> if ""id3v2"" in mp3 : <TAB> <TAB> self. readID3v2 ( mp3 [ ""id3v2"" ] ) <TAB> if ""frames"" in mp3 : <TAB> <TAB> computeComprRate ( self, mp3 [ ""frames"" ]. size )",False,id3['year'].value != '0','year' in id3,0.6536756753921509
|
||
|
694,"def tool_lineages ( self, trans ) : <TAB> rval = [ ] <TAB> for id, tool in self. app. toolbox. tools ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> lineage_dict = tool. lineage. to_dict ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> lineage_dict = None <TAB> <TAB> entry = dict ( id = id, lineage = lineage_dict ) <TAB> <TAB> rval. append ( entry ) <TAB> return rval",True,"hasattr(tool, 'lineage')","hasattr(tool, 'lineage')",0.6558094620704651
|
||
|
695,"def _div ( self, op, isInvalid = None ) : <TAB> oper = op. opers [ 0 ] <TAB> divbase = self. getOperObj ( op, 0 ) <TAB> if isInvalid is None : <TAB> <TAB> limit = ( 2 ** ( oper. tsize * 8 ) ) - 1 <TAB> <TAB> isInvalid = lambda val : val > limit <TAB> if oper. tsize == 1 : <TAB> <TAB> ax = self. getRegObj ( e_i386. REG_AX ) <TAB> <TAB> quot = ax / divbase <TAB> <TAB> rem = ax % divbase <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise envi. DivideError ( ""i386 #DE"" ) <TAB> <TAB> self. effSetVariable ( ""eax"", ( rem << 8 ) + quot ) <TAB> elif oper. tsize == 2 : <TAB> <TAB> ax = self. getRegObj ( e_i386. REG_AX ) <TAB> <TAB> dx = self. getRegObj ( e_i386. REG_DX ) <TAB> <TAB> tot = ( edx << Const ( 16, self. _psize ) ) + eax <TAB> <TAB> quot = tot / divbase <TAB> <TAB> rem = tot % divbase <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise envi. DivideError ( ""i386 #DE"" ) <TAB> <TAB> self. effSetVariable ( ""eax"", quot ) <TAB> <TAB> self. effSetVariable ( ""edx"", rem ) <TAB> elif oper. tsize == 4 : <TAB> <TAB> eax = Var ( ""eax"", self. _psize ) <TAB> <TAB> edx = Var ( ""edx"", self. _psize ) <TAB> <TAB> tot = ( edx << Const ( 32, self. _psize ) ) + eax <TAB> <TAB> quot = tot / divbase <TAB> <TAB> rem = tot % divbase <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB>",False,quot.isDiscrete() and isInvalid(quot),not isInvalid,0.649432897567749
|
||
|
696,"def batch_slice ( data, batch_size, sort = True ) : <TAB> batch_num = int ( np. ceil ( len ( data ) / float ( batch_size ) ) ) <TAB> for i in range ( batch_num ) : <TAB> <TAB> cur_batch_size = batch_size if i < batch_num - 1 else len ( data ) - batch_size * i <TAB> <TAB> src_sents = [ data [ i * batch_size + b ] [ 0 ] for b in range ( cur_batch_size ) ] <TAB> <TAB> tgt_sents = [ data [ i * batch_size + b ] [ 1 ] for b in range ( cur_batch_size ) ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> src_ids = sorted ( <TAB> <TAB> <TAB> <TAB> range ( cur_batch_size ), <TAB> <TAB> <TAB> <TAB> key = lambda src_id : len ( src_sents [ src_id ] ), <TAB> <TAB> <TAB> <TAB> reverse = True, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> src_sents = [ src_sents [ src_id ] for src_id in src_ids ] <TAB> <TAB> <TAB> tgt_sents = [ tgt_sents [ src_id ] for src_id in src_ids ] <TAB> <TAB> yield src_sents, tgt_sents",True,sort,sort,0.680050790309906
|
||
|
697,"def serialize_to_cmessage ( self ) : <TAB> <TAB> <TAB> from... engines. light import SpOffset <TAB> cmsg = self. _get_cmsg ( ) <TAB> if self. memory_data is not None : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> cmsg. target_type = primitives_pb2. CodeReference. CodeTarget <TAB> <TAB> else : <TAB> <TAB> <TAB> cmsg. target_type = primitives_pb2. CodeReference. DataTarget <TAB> <TAB> cmsg. location = primitives_pb2. CodeReference. Internal <TAB> <TAB> cmsg. data_ea = self. memory_data. addr <TAB> elif self. dst is not None : <TAB> <TAB> if isinstance ( self. dst, SpOffset ) : <TAB> <TAB> <TAB> cmsg. target_type = primitives_pb2. CodeReference. StackTarget <TAB> <TAB> <TAB> cmsg. data_ea = self. dst. offset <TAB> <TAB> else : <TAB> <TAB> <TAB> cmsg. data_ea = self. dst <TAB> else : <TAB> <TAB> <TAB> <TAB> cmsg. data_ea = - 1 <TAB> if self. insn_op_idx is None : <TAB> <TAB> cmsg. operand_idx = - 1 <TAB> else : <TAB> <TAB> cmsg. operand_idx = self. insn_op_idx <TAB> cmsg. ea = self. ins_addr <TAB> cmsg. block_ea = self. block_addr <TAB> cmsg. stmt_idx = self. stmt_idx <TAB> cmsg. ref_type = self. type <TAB> return cmsg",False,self.memory_data.sort == MemoryDataSort.CodeReference,"isinstance(self.memory_data.addr, addr.Array)",0.6545739769935608
|
||
|
698,"def _find_key_in_yaml_file ( <TAB> yaml_file_path, search_keys, full_key_name, value_is_relative_path ) : <TAB> """"""Find a key in a yaml file."""""" <TAB> if not os. path. isfile ( yaml_file_path ) : <TAB> <TAB> return None <TAB> result = _load_yaml_file ( yaml_file_path ) <TAB> if not search_keys : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return result <TAB> for search_key in search_keys : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise errors. InvalidConfigKey ( full_key_name ) <TAB> <TAB> if search_key not in result : <TAB> <TAB> <TAB> return None <TAB> <TAB> result = result [ search_key ] <TAB> if value_is_relative_path : <TAB> <TAB> yaml_directory = os. path. dirname ( yaml_file_path ) <TAB> <TAB> if isinstance ( result, list ) : <TAB> <TAB> <TAB> result = [ os. path. join ( yaml_directory, str ( i ) ) for i in result ] <TAB> <TAB> else : <TAB> <TAB> <TAB> result = os. path. join ( yaml_directory, str ( result ) ) <TAB> return result",False,"not isinstance(result, dict)",full_key_name in result,0.6480915546417236
|
||
|
699,"def call ( self, inputs, state ) : <TAB> """""" """""" <TAB> ( c_prev, m_prev ) = state <TAB> self. _batch_size = inputs. shape [ 0 ]. value or array_ops. shape ( inputs ) [ 0 ] <TAB> scope = vs. get_variable_scope ( ) <TAB> with vs. variable_scope ( scope, initializer = self. _initializer ) : <TAB> <TAB> x = array_ops. concat ( [ inputs, m_prev ], axis = 1 ) <TAB> <TAB> with vs. variable_scope ( ""first_gemm"" ) : <TAB> <TAB> <TAB> if self. _linear1 is None : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _linear1 = _Linear ( x, self. _fact_size, False ) <TAB> <TAB> <TAB> R_fact = self. _linear1 ( x ) <TAB> <TAB> with vs. variable_scope ( ""second_gemm"" ) : <TAB> <TAB> <TAB> if self. _linear2 is None : <TAB> <TAB> <TAB> <TAB> self. _linear2 = _Linear ( R_fact, 4 * self. _num_units, True ) <TAB> <TAB> <TAB> R = self. _linear2 ( R_fact ) <TAB> <TAB> i, j, f, o = array_ops. split ( R, 4, 1 ) <TAB> <TAB> c = math_ops. sigmoid ( f + self. _forget_bias ) * c_prev + math_ops. sigmoid ( <TAB> <TAB> <TAB> i <TAB> <TAB> ) * math_ops. tanh ( j ) <TAB> <TAB> m = math_ops. sigmoid ( o ) * self. _activation ( c ) <TAB> if self. _num_proj is not None : <TAB> <TAB> with vs. variable_scope ( ""projection"" ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. _linear3 = _Linear ( m, self. _num_proj, False )",True,self._linear3 is None,self._linear3 is None,0.6679277420043945
|
||
|
700,"def log ( self, level, msg, * args, ** kw ) : <TAB> if args : <TAB> <TAB> if kw : <TAB> <TAB> <TAB> raise TypeError ( ""You may give positional or keyword arguments, not both"" ) <TAB> args = args or kw <TAB> rendered = None <TAB> for consumer_level, consumer in self. consumers : <TAB> <TAB> if self. level_matches ( level, consumer_level ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. in_progress_hanging = False <TAB> <TAB> <TAB> <TAB> print ( """" ) <TAB> <TAB> <TAB> <TAB> sys. stdout. flush ( ) <TAB> <TAB> <TAB> if rendered is None : <TAB> <TAB> <TAB> <TAB> if args : <TAB> <TAB> <TAB> <TAB> <TAB> rendered = msg % args <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> rendered = msg <TAB> <TAB> <TAB> <TAB> rendered = "" "" * self. indent + rendered <TAB> <TAB> <TAB> if hasattr ( consumer, ""write"" ) : <TAB> <TAB> <TAB> <TAB> consumer. write ( rendered + ""\n"" ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> consumer ( rendered )",False,"self.in_progress_hanging and consumer in (sys.stdout, sys.stderr)",self.in_progress_hanging,0.653225839138031
|
||
|
701,"def remove_data_directory ( self ) : <TAB> self. set_role ( ""uninitialized"" ) <TAB> logger. info ( ""Removing data directory: %s"", self. _data_dir ) <TAB> try : <TAB> <TAB> if os. path. islink ( self. _data_dir ) : <TAB> <TAB> <TAB> os. unlink ( self. _data_dir ) <TAB> <TAB> elif not os. path. exists ( self. _data_dir ) : <TAB> <TAB> <TAB> return <TAB> <TAB> elif os. path. isfile ( self. _data_dir ) : <TAB> <TAB> <TAB> os. remove ( self. _data_dir ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for pg_wal_realpath in self. pg_wal_realpath ( ). values ( ) : <TAB> <TAB> <TAB> <TAB> logger. info ( ""Removing WAL directory: %s"", pg_wal_realpath ) <TAB> <TAB> <TAB> <TAB> shutil. rmtree ( pg_wal_realpath ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for pg_tsp_rpath in self. pg_tblspc_realpaths ( ). values ( ) : <TAB> <TAB> <TAB> <TAB> logger. info ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Removing user defined tablespace directory: %s"", pg_tsp_rpath <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> shutil. rmtree ( pg_tsp_rpath, ignore_errors = True ) <TAB> <TAB> <TAB> shutil. rmtree ( self. _data_dir ) <TAB> except ( IOError, OSError ) : <TAB> <TAB> logger. exception ( ""Could not remove data directory %s"", self. _data_dir ) <TAB> <TAB> self. move_data_directory ( )",True,os.path.isdir(self._data_dir),os.path.isdir(self._data_dir),0.6478986740112305
|
||
|
702,"def _simple_interactive_update ( self ) : <TAB> while True : <TAB> <TAB> stale_packages = [ ] <TAB> <TAB> stale = partial = False <TAB> <TAB> for info in sorted ( getattr ( self. _ds, ""packages"" ) ( ), key = str ) : <TAB> <TAB> <TAB> if self. _ds. status ( info ) == self. _ds. STALE : <TAB> <TAB> <TAB> <TAB> stale_packages. append ( ( info. id, info. name ) ) <TAB> <TAB> print ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> print ( ""Will update following packages (o=ok; x=cancel)"" ) <TAB> <TAB> <TAB> for pid, pname in stale_packages : <TAB> <TAB> <TAB> <TAB> name = textwrap. fill ( <TAB> <TAB> <TAB> <TAB> <TAB> ""-"" * 27 + ( pname ), 75, subsequent_indent = 27 * "" "" <TAB> <TAB> <TAB> <TAB> ) [ 27 : ] <TAB> <TAB> <TAB> <TAB> print ( "" [ ] %s %s"" % ( pid. ljust ( 20, ""."" ), name ) ) <TAB> <TAB> <TAB> print ( ) <TAB> <TAB> <TAB> user_input = unicode ( input ( "" Identifier> "" ) ) <TAB> <TAB> <TAB> if user_input. lower ( ) == ""o"" : <TAB> <TAB> <TAB> <TAB> for pid, pname in stale_packages : <TAB> <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _ds. download ( pid, prefix = "" "" ) <TAB> <TAB> <TAB> <TAB> <TAB> except ( IOError, ValueError ) as e : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> print ( e ) <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> elif user_input. lower ( ) in ( ""x"", ""q"", """"",False,stale_packages,self.partial,0.665532112121582
|
||
|
703,"def deploy_arm_template_at_subscription_scope ( <TAB> cmd, <TAB> template_file = None, <TAB> template_uri = None, <TAB> parameters = None, <TAB> deployment_name = None, <TAB> deployment_location = None, <TAB> no_wait = False, <TAB> handle_extended_json_format = None, <TAB> no_prompt = False, <TAB> confirm_with_what_if = None, <TAB> what_if_result_format = None, <TAB> what_if_exclude_change_types = None, <TAB> template_spec = None, <TAB> query_string = None, ) : <TAB> if confirm_with_what_if : <TAB> <TAB> what_if_deploy_arm_template_at_subscription_scope ( <TAB> <TAB> <TAB> cmd, <TAB> <TAB> <TAB> template_file = template_file, <TAB> <TAB> <TAB> template_uri = template_uri, <TAB> <TAB> <TAB> parameters = parameters, <TAB> <TAB> <TAB> deployment_name = deployment_name, <TAB> <TAB> <TAB> deployment_location = deployment_location, <TAB> <TAB> <TAB> result_format = what_if_result_format, <TAB> <TAB> <TAB> exclude_change_types = what_if_exclude_change_types, <TAB> <TAB> <TAB> no_prompt = no_prompt, <TAB> <TAB> <TAB> template_spec = template_spec, <TAB> <TAB> <TAB> query_string = query_string, <TAB> <TAB> ) <TAB> <TAB> from knack. prompting import prompt_y_n <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return None <TAB> return _deploy_arm_template_at_subscription_scope ( <TAB> <TAB> cmd = cmd, <TAB> <TAB> template_file = template_file, <TAB> <TAB> template_uri = template_uri, <TAB> <TAB> parameters = parameters, <TAB> <TAB> deployment_name = deployment_name, <TAB> <TAB> deployment_location =",False,not prompt_y_n('\nAre you sure you want to execute the deployment?'),no_prompt,0.6487878561019897
|
||
|
704,"def readchunk ( self, inode, index, chunkopflags = 0 ) : <TAB> cnt = 0 <TAB> while True : <TAB> <TAB> cnt += 1 <TAB> <TAB> if self. version < ( 3, 0, 4 ) : <TAB> <TAB> <TAB> ans = self. sendAndReceive ( CLTOMA_FUSE_READ_CHUNK, inode, index ) <TAB> <TAB> else : <TAB> <TAB> <TAB> ans = self. sendAndReceive ( <TAB> <TAB> <TAB> <TAB> CLTOMA_FUSE_READ_CHUNK, inode, index, uint8 ( chunkopflags ) <TAB> <TAB> <TAB> ) <TAB> <TAB> n = len ( ans ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> from. utils import Error <TAB> <TAB> <TAB> err = ord ( ans ) <TAB> <TAB> <TAB> if err == ERROR_LOCKED : <TAB> <TAB> <TAB> <TAB> if cnt < 100 : <TAB> <TAB> <TAB> <TAB> <TAB> time. sleep ( 0.1 ) <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> logger. warning ( ""Waited too long for locked chunk %s:%s"", inode, index ) <TAB> <TAB> <TAB> raise Error ( ord ( ans ) ) <TAB> <TAB> if n < 20 : <TAB> <TAB> <TAB> raise Exception ( ""read chunk invalid length: %s(expected 20 above)"" % n ) <TAB> <TAB> if self. version >= ( 3, 0, 10 ) : <TAB> <TAB> <TAB> assert ( n - 21 ) % 14 == 0, n <TAB> <TAB> <TAB> protocolid, length, id_, version = unpack ( ""BQQI"", ans ) <TAB> <TAB> <TAB> return Chunk ( id_, length, version, ans [ 21 : ], ele_width = 14 ) <TAB> <TAB> elif self. version >= ( 1, 7, 32 ) : <TAB> <TAB> <TAB> assert ( n - 21 ) % 10",False,n == 1,n > 0,0.6724562048912048
|
||
|
705,"def tearDown ( self ) : <TAB> """"""Shutdown the UDP server."""""" <TAB> try : <TAB> <TAB> if self. server : <TAB> <TAB> <TAB> self. server. stop ( 2.0 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. root_logger. removeHandler ( self. sock_hdlr ) <TAB> <TAB> <TAB> self. sock_hdlr. close ( ) <TAB> finally : <TAB> <TAB> BaseTest. tearDown ( self )",False,self.sock_hdlr,self.root_logger,0.6611213088035583
|
||
|
706,"def labels_to_inputs ( self, labels, converter ) : <TAB> inputs = [ ] <TAB> for label_arr in labels : <TAB> <TAB> input_ = np. zeros ( <TAB> <TAB> <TAB> ( len ( label_arr ), converter. input_depth ), converter. input_dtype <TAB> <TAB> ) <TAB> <TAB> for i, l in enumerate ( label_arr ) : <TAB> <TAB> <TAB> if l == converter. end_token : <TAB> <TAB> <TAB> <TAB> input_ [ i, - 2 ] = 1 <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> input_ [ i, - 1 ] = 1 <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> j = 0 <TAB> <TAB> <TAB> <TAB> while l : <TAB> <TAB> <TAB> <TAB> <TAB> input_ [ i, j ] = l % 2 <TAB> <TAB> <TAB> <TAB> <TAB> l >>= 1 <TAB> <TAB> <TAB> <TAB> <TAB> j += 1 <TAB> <TAB> <TAB> <TAB> assert np. any ( input_ [ i ] ), label_arr. astype ( np. int ) <TAB> <TAB> inputs. append ( input_ ) <TAB> return inputs",False,l == 0,l == converter.start_token,0.6759565472602844
|
||
|
707,"def package_files ( self ) : <TAB> seen_package_directories = ( ) <TAB> directories = self. distribution. package_dir or { } <TAB> empty_directory_exists = """" in directories <TAB> packages = self. distribution. packages or [ ] <TAB> for package in packages : <TAB> <TAB> if package in directories : <TAB> <TAB> <TAB> package_directory = directories [ package ] <TAB> <TAB> elif empty_directory_exists : <TAB> <TAB> <TAB> package_directory = os. path. join ( directories [ """" ], package ) <TAB> <TAB> else : <TAB> <TAB> <TAB> package_directory = package <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> seen_package_directories += ( package_directory + ""."", ) <TAB> <TAB> <TAB> yield package_directory",False,not package_directory.startswith(seen_package_directories),package_directory not in seen_package_directories,0.6473897695541382
|
||
|
708,"def _resolve ( <TAB> self, debug : bool, silent : bool, level : Optional [ int ], spinner ) -> Optional [ bool ] : <TAB> if silent : <TAB> <TAB> logger. debug ( <TAB> <TAB> <TAB> ""next iteration"", <TAB> <TAB> <TAB> extra = dict ( <TAB> <TAB> <TAB> <TAB> layers = len ( self. graph. _layers ), <TAB> <TAB> <TAB> <TAB> mutations = self. mutator. mutations, <TAB> <TAB> <TAB> ), <TAB> <TAB> ) <TAB> else : <TAB> <TAB> spinner. text = ""layers: {layers}, mutations: {mutations}"". format ( <TAB> <TAB> <TAB> layers = len ( self. graph. _layers ), <TAB> <TAB> <TAB> mutations = self. mutator. mutations, <TAB> <TAB> ) <TAB> <TAB> deps = self. graph. get_leafs ( level = level ) <TAB> <TAB> if not deps : <TAB> <TAB> return True <TAB> <TAB> for dep in deps : <TAB> <TAB> if not dep. python_compat : <TAB> <TAB> <TAB> self. graph. conflict = dep <TAB> <TAB> <TAB> return False <TAB> no_conflicts = self. _apply_deps ( deps, debug = debug ) <TAB> if no_conflicts : <TAB> <TAB> return None <TAB> <TAB> groups = self. mutator. mutate ( self. graph ) <TAB> <TAB> if groups is None : <TAB> <TAB> return False <TAB> self. graph. conflict = None <TAB> <TAB> for group in groups : <TAB> <TAB> dep = self. graph. get ( group. name ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> logger. debug ( <TAB> <TAB> <TAB> <TAB> ""mutated"", <TAB> <TAB> <TAB> <TAB> extra = dict ( <TAB> <TAB> <TAB> <TAB> <TAB> group_from = str ( dep. group ), <TAB> <TAB> <TAB> <TAB> <",False,dep.group.number != group.number,dep,0.6473860740661621
|
||
|
709,"def apply ( self, items, evaluation ) : <TAB> ""%(name)s[items___]"" <TAB> items = items. flatten ( Symbol ( ""List"" ) ). get_sequence ( ) <TAB> results = [ ] <TAB> best = None <TAB> for item in items : <TAB> <TAB> if item. has_form ( ""List"", None ) : <TAB> <TAB> <TAB> leaves = item. leaves <TAB> <TAB> else : <TAB> <TAB> <TAB> leaves = [ item ] <TAB> <TAB> for leaf in leaves : <TAB> <TAB> <TAB> if best is None : <TAB> <TAB> <TAB> <TAB> best = leaf <TAB> <TAB> <TAB> <TAB> results. append ( best ) <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> c = do_cmp ( leaf, best ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> results. append ( leaf ) <TAB> <TAB> <TAB> elif ( self. sense == 1 and c > 0 ) or ( self. sense == - 1 and c < 0 ) : <TAB> <TAB> <TAB> <TAB> results. remove ( best ) <TAB> <TAB> <TAB> <TAB> best = leaf <TAB> <TAB> <TAB> <TAB> results. append ( leaf ) <TAB> if not results : <TAB> <TAB> return Expression ( ""DirectedInfinity"", - self. sense ) <TAB> if len ( results ) == 1 : <TAB> <TAB> return results. pop ( ) <TAB> if len ( results ) < len ( items ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return Expression ( self. get_name ( ), * results ) <TAB> <TAB> return None",False,c is None,self.sense == 0,0.6652126312255859
|
||
|
710,"def finish ( self ) : <TAB> self. done = True <TAB> if self. has_trailers and hasattr ( self. fp, ""read_trailer_lines"" ) : <TAB> <TAB> self. trailers = { } <TAB> <TAB> try : <TAB> <TAB> <TAB> for line in self. fp. read_trailer_lines ( ) : <TAB> <TAB> <TAB> <TAB> if line [ 0 ] in ntob ( "" \t"" ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> v = line. strip ( ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> k, v = line. split ( ntob ( "":"" ), 1 ) <TAB> <TAB> <TAB> <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> raise ValueError ( ""Illegal header line."" ) <TAB> <TAB> <TAB> <TAB> <TAB> k = k. strip ( ). title ( ) <TAB> <TAB> <TAB> <TAB> <TAB> v = v. strip ( ) <TAB> <TAB> <TAB> <TAB> if k in cheroot. server. comma_separated_headers : <TAB> <TAB> <TAB> <TAB> <TAB> existing = self. trailers. get ( k ) <TAB> <TAB> <TAB> <TAB> <TAB> if existing : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> v = ntob ( "", "" ). join ( ( existing, v ) ) <TAB> <TAB> <TAB> <TAB> self. trailers [ k ] = v <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> e = sys. exc_info ( ) [ 1 ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> raise cherrypy.",False,e.__class__.__name__ == 'MaxSizeExceeded',e,0.6711167097091675
|
||
|
711,"def sync_up_to_new_location ( self, worker_ip ) : <TAB> if worker_ip!= self. worker_ip : <TAB> <TAB> logger. debug ( ""Setting new worker IP to %s"", worker_ip ) <TAB> <TAB> self. set_worker_ip ( worker_ip ) <TAB> <TAB> self. reset ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> logger. warning ( ""Sync up to new location skipped. This should not occur."" ) <TAB> else : <TAB> <TAB> logger. warning ( ""Sync attempted to same IP %s."", worker_ip )",False,not self.sync_up(),worker_ip == self.worker_ip,0.653356671333313
|
||
|
712,"def __keyPress ( self, widget, event ) : <TAB> if self. getSelectedIndex ( ) is None : <TAB> <TAB> return False <TAB> if event. key in ( ""Left"", ""Right"", ""Up"", ""Down"" ) : <TAB> <TAB> if self. __positionIncrement == 0 : <TAB> <TAB> <TAB> return False <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> pixelIncrement = 1 <TAB> <TAB> else : <TAB> <TAB> <TAB> pixelIncrement = self. __positionIncrement * self. size ( ). x <TAB> <TAB> x = self. getPositions ( ) [ self. getSelectedIndex ( ) ] * self. size ( ). x <TAB> <TAB> x += pixelIncrement if event. key in ( ""Right"", ""Up"" ) else - pixelIncrement <TAB> <TAB> self. __setPositionInternal ( <TAB> <TAB> <TAB> self. getSelectedIndex ( ), <TAB> <TAB> <TAB> x, <TAB> <TAB> <TAB> self. PositionChangedReason. Increment, <TAB> <TAB> <TAB> clamp = not ( event. modifiers & event. modifiers. Shift ), <TAB> <TAB> ) <TAB> <TAB> return True <TAB> elif event. key in ( ""Backspace"", ""Delete"" ) : <TAB> <TAB> index = self. getSelectedIndex ( ) <TAB> <TAB> if ( <TAB> <TAB> <TAB> index is not None <TAB> <TAB> <TAB> and self. getSizeEditable ( ) <TAB> <TAB> <TAB> and len ( self. getPositions ( ) ) > self. getMinimumSize ( ) <TAB> <TAB> ) : <TAB> <TAB> <TAB> del self. __positions [ index ] <TAB> <TAB> <TAB> signal = getattr ( self, ""_indexRemovedSignal"", None ) <TAB> <TAB> <TAB> if signal is not None : <TAB> <TAB> <TAB> <TAB> signal ( self, index ) <TAB> <TAB> <TAB> self. __emitPositionChanged ( self. PositionChangedReason. IndexRemoved ) <TAB> <TAB> <TAB> self. _qtWidget",False,self.__positionIncrement is None,self.size() == None,0.6725320219993591
|
||
|
713,"def results_default_iter ( commit_hash ) : <TAB> for result in iter_results_for_machine_and_hash ( <TAB> <TAB> conf. results_dir, machine, commit_hash <TAB> ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> for key in result. get_all_result_keys ( ) : <TAB> <TAB> <TAB> params = result. get_result_params ( key ) <TAB> <TAB> <TAB> result_value = result. get_result_value ( key, params ) <TAB> <TAB> <TAB> result_stats = result. get_result_stats ( key, params ) <TAB> <TAB> <TAB> result_samples = result. get_result_samples ( key, params ) <TAB> <TAB> <TAB> result_version = result. benchmark_version. get ( key ) <TAB> <TAB> <TAB> yield ( <TAB> <TAB> <TAB> <TAB> key, <TAB> <TAB> <TAB> <TAB> params, <TAB> <TAB> <TAB> <TAB> result_value, <TAB> <TAB> <TAB> <TAB> result_stats, <TAB> <TAB> <TAB> <TAB> result_samples, <TAB> <TAB> <TAB> <TAB> result_version, <TAB> <TAB> <TAB> <TAB> result. params [ ""machine"" ], <TAB> <TAB> <TAB> <TAB> result. env_name, <TAB> <TAB> <TAB> )",False,env_names is not None and result.env_name not in env_names,result.is_empty(),0.6507217884063721
|
||
|
714,"def _binary ( self, other : ""Table"", func, do_func ) : <TAB> session_id = self. _session. session_id <TAB> left, right = self, other <TAB> if left. _partitions!= right. _partitions : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> left = left. save_as ( <TAB> <TAB> <TAB> <TAB> str ( uuid. uuid1 ( ) ), session_id, partition = right. _partitions <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> right = other. save_as ( <TAB> <TAB> <TAB> <TAB> str ( uuid. uuid1 ( ) ), session_id, partition = left. _partitions <TAB> <TAB> <TAB> ) <TAB> <TAB> results = self. _session. _submit_binary ( <TAB> <TAB> func, <TAB> <TAB> do_func, <TAB> <TAB> left. _partitions, <TAB> <TAB> left. _name, <TAB> <TAB> left. _namespace, <TAB> <TAB> right. _name, <TAB> <TAB> right. _namespace, <TAB> ) <TAB> result : _Operand = results [ 0 ] <TAB> <TAB> return _create_table ( <TAB> <TAB> session = self. _session, <TAB> <TAB> name = result. name, <TAB> <TAB> namespace = result. namespace, <TAB> <TAB> partitions = left. _partitions, <TAB> )",False,other.count() > self.count(),self._session.session_id == other._session_id,0.6512644290924072
|
||
|
715,"def _form_master_re ( relist, reflags, ldict, toknames ) : <TAB> if not relist : <TAB> <TAB> return [ ] <TAB> regex = ""|"". join ( relist ) <TAB> try : <TAB> <TAB> lexre = re. compile ( regex, re. VERBOSE | reflags ) <TAB> <TAB> <TAB> <TAB> lexindexfunc = [ None ] * ( max ( lexre. groupindex. values ( ) ) + 1 ) <TAB> <TAB> lexindexnames = lexindexfunc [ : ] <TAB> <TAB> for f, i in lexre. groupindex. items ( ) : <TAB> <TAB> <TAB> handle = ldict. get ( f, None ) <TAB> <TAB> <TAB> if type ( handle ) in ( types. FunctionType, types. MethodType ) : <TAB> <TAB> <TAB> <TAB> lexindexfunc [ i ] = ( handle, toknames [ f ] ) <TAB> <TAB> <TAB> <TAB> lexindexnames [ i ] = f <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> lexindexnames [ i ] = f <TAB> <TAB> <TAB> <TAB> if f. find ( ""ignore_"" ) > 0 : <TAB> <TAB> <TAB> <TAB> <TAB> lexindexfunc [ i ] = ( None, None ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> lexindexfunc [ i ] = ( None, toknames [ f ] ) <TAB> <TAB> return [ ( lexre, lexindexfunc ) ], [ regex ], [ lexindexnames ] <TAB> except Exception : <TAB> <TAB> m = int ( len ( relist ) / 2 ) <TAB> <TAB> if m == 0 : <TAB> <TAB> <TAB> m = 1 <TAB> <TAB> llist, lre, lnames = _form_master_re ( relist [ : m ], reflags, ldict, toknames ) <TAB> <TAB> rlist, rre, rnames = _form_master_re ( relist [",False,handle is not None,"type(f) in (types.StringTypes, types.StringTypes)",0.6600191593170166
|
||
|
716,"def decStep ( self, event = None ) : <TAB> if event is not None and not self. acceptKey ( ) : <TAB> <TAB> return <TAB> step, power = abcControlFrame. _stepPower ( self. step. get ( ) ) <TAB> s = step - power <TAB> if s <= 0.0 : <TAB> <TAB> s = step - power / 10.0 <TAB> if s < _LOWSTEP : <TAB> <TAB> s = _LOWSTEP <TAB> elif s > _HIGHSTEP : <TAB> <TAB> s = _HIGHSTEP <TAB> if self. astep is not self. step and self. astep. get ( )!= _NOASTEP : <TAB> <TAB> step, power = abcControlFrame. _stepPower ( self. astep. get ( ) ) <TAB> <TAB> aas = step - power <TAB> <TAB> if aas <= 0.0 : <TAB> <TAB> <TAB> aas = step - power / 10.0 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> aas = _LOWSTEP <TAB> <TAB> elif aas > _HIGHASTEP : <TAB> <TAB> <TAB> aas = _HIGHASTEP <TAB> else : <TAB> <TAB> aas = None <TAB> self. setStep ( s, aas )",False,aas < _LOWSTEP,aas > _LOWSTEP,0.6739943027496338
|
||
|
717,"def _nested_ui_dict ( <TAB> self, <TAB> ui_schema : List [ Dict [ str, Any ] ], <TAB> option_dict : Dict [ str, Any ], <TAB> key : str, <TAB> multiple : bool = False, ) -> None : <TAB> """"""UI nested dict items."""""" <TAB> ui_node = { <TAB> <TAB> ""name"" : key, <TAB> <TAB> ""type"" : ""schema"", <TAB> <TAB> ""optional"" : True, <TAB> <TAB> ""multiple"" : multiple, <TAB> } <TAB> nested_schema = [ ] <TAB> for c_key, c_value in option_dict. items ( ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _nested_ui_list ( nested_schema, c_value, c_key ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. _single_ui_option ( nested_schema, c_value, c_key ) <TAB> ui_node [ ""schema"" ] = nested_schema <TAB> ui_schema. append ( ui_node )",True,"isinstance(c_value, list)","isinstance(c_value, list)",0.6476407647132874
|
||
|
718,"def test_https ( ) : <TAB> for proto in [ ""http"", ""https"" ] : <TAB> <TAB> for convention in [ ""virtualhost"", ""path"", ""subdomain"" ] : <TAB> <TAB> <TAB> opts = calling_format. _s3connection_opts_from_uri ( <TAB> <TAB> <TAB> <TAB> ""{0}+{1}://"". format ( proto, convention ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> assert ( proto == ""https"" ) == opts [ ""is_secure"" ] <TAB> <TAB> <TAB> assert ( proto == ""http"" ) == ( not opts [ ""is_secure"" ] ) <TAB> <TAB> <TAB> cf = opts [ ""calling_format"" ] <TAB> <TAB> <TAB> if convention == ""virtualhost"" : <TAB> <TAB> <TAB> <TAB> assert isinstance ( cf, connection. VHostCallingFormat ) <TAB> <TAB> <TAB> elif convention == ""path"" : <TAB> <TAB> <TAB> <TAB> assert isinstance ( cf, connection. OrdinaryCallingFormat ) <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> assert isinstance ( cf, connection. SubdomainCallingFormat ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> assert False",False,convention == 'subdomain',conconation == 'subdomain',0.6675941944122314
|
||
|
719,"def render ( self, name, value, attrs = None, renderer = None ) : <TAB> output = [ ] <TAB> for option in self. subwidgets ( name, value, attrs ) : <TAB> <TAB> option_value = option [ ""value"" ] <TAB> <TAB> option [ ""widget"" ] = self. create_option ( <TAB> <TAB> <TAB> name = name, <TAB> <TAB> <TAB> value = option [ ""value"" ], <TAB> <TAB> <TAB> label = option [ ""label"" ], <TAB> <TAB> <TAB> selected = option_value == value, <TAB> <TAB> <TAB> index = option [ ""index"" ], <TAB> <TAB> <TAB> attrs = option [ ""attrs"" ], <TAB> <TAB> ) <TAB> <TAB> if option_value. split ( ""/"" ) [ 0 ] == ""icon"" or option_value == """" : <TAB> <TAB> <TAB> icon_name = option [ ""label"" ] <TAB> <TAB> <TAB> original_widget = self. _render ( self. option_template_name, option ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> original_widget = format_html ( <TAB> <TAB> <TAB> <TAB> <TAB> '<label for=""{label_id}"">{widget}</label>', <TAB> <TAB> <TAB> <TAB> <TAB> label_id = option [ ""widget"" ] [ ""attrs"" ] [ ""id"" ], <TAB> <TAB> <TAB> <TAB> <TAB> widget = original_widget, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> output. append ( <TAB> <TAB> <TAB> <TAB> format_html ( <TAB> <TAB> <TAB> <TAB> <TAB> self. base_html, <TAB> <TAB> <TAB> <TAB> <TAB> active = ""active"" if option_value == value else """", <TAB> <TAB> <TAB> <TAB> <TAB> static = settings. STATIC_URL, <TAB",False,not original_widget.startswith('<label for='),original_widget,0.6515800952911377
|
||
|
720,"def index_list_children ( self, pagename ) : <TAB> <TAB> file, folder = self. map_page ( pagename ) <TAB> if not folder. exists ( ) : <TAB> <TAB> return [ ] <TAB> names = set ( ) <TAB> for object in folder : <TAB> <TAB> if isinstance ( object, File ) : <TAB> <TAB> <TAB> if object. path. endswith ( self. default_extension ) : <TAB> <TAB> <TAB> <TAB> name = object. basename [ : - len ( self. default_extension ) ] <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> else : <TAB> <TAB> <TAB> name = object. basename <TAB> <TAB> pname = decode_filename ( name ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> names. add ( pname ) <TAB> return [ pagename + basename for basename in sorted ( names ) ]",False,encode_filename(pname) == name,pname,0.6546167135238647
|
||
|
721,"def log_graph ( self, model : LightningModule, input_array = None ) : <TAB> if self. _log_graph : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> input_array = model. example_input_array <TAB> <TAB> if input_array is not None : <TAB> <TAB> <TAB> input_array = model. _apply_batch_transfer_handler ( input_array ) <TAB> <TAB> <TAB> self. experiment. add_graph ( model, input_array ) <TAB> <TAB> else : <TAB> <TAB> <TAB> rank_zero_warn ( <TAB> <TAB> <TAB> <TAB> ""Could not log computational graph since the"" <TAB> <TAB> <TAB> <TAB> "" `model.example_input_array` attribute is not set"" <TAB> <TAB> <TAB> <TAB> "" or `input_array` was not given"", <TAB> <TAB> <TAB> <TAB> UserWarning, <TAB> <TAB> <TAB> )",True,input_array is None,input_array is None,0.659860372543335
|
||
|
722,"def modify_bottle_params ( self, output_stride = None ) : <TAB> if output_stride is not None and output_stride % 2!= 0 : <TAB> <TAB> raise Exception ( ""output stride must to be even number"" ) <TAB> if output_stride is None : <TAB> <TAB> return <TAB> else : <TAB> <TAB> stride = 2 <TAB> <TAB> for i, _cfg in enumerate ( self. cfg ) : <TAB> <TAB> <TAB> stride = stride * _cfg [ - 1 ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> s = 1 <TAB> <TAB> <TAB> <TAB> self. cfg [ i ] [ - 1 ] = s",False,stride > output_stride,stride == 2,0.680195689201355
|
||
|
723,"def create_dir ( path ) : <TAB> curr_path = None <TAB> for p in path : <TAB> <TAB> if curr_path is None : <TAB> <TAB> <TAB> curr_path = os. path. abspath ( p ) <TAB> <TAB> else : <TAB> <TAB> <TAB> curr_path = os. path. join ( curr_path, p ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> os. mkdir ( curr_path )",True,not os.path.exists(curr_path),not os.path.exists(curr_path),0.6460517048835754
|
||
|
724,"def _recv ( self, wait_for_req_id = None ) : <TAB> try : <TAB> <TAB> while True : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if wait_for_req_id in self. pending_response : <TAB> <TAB> <TAB> <TAB> response = self. pending_response. pop ( wait_for_req_id ) <TAB> <TAB> <TAB> <TAB> return _Response ( wait_for_req_id, response ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> response = self. receiver. recv_multipart ( ) <TAB> <TAB> <TAB> request_id = int ( response [ - 1 ] ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if not wait_for_req_id or ( wait_for_req_id == request_id ) : <TAB> <TAB> <TAB> <TAB> self. pending_request. remove ( request_id ) <TAB> <TAB> <TAB> <TAB> return _Response ( request_id, response ) <TAB> <TAB> <TAB> elif wait_for_req_id!= request_id : <TAB> <TAB> <TAB> <TAB> self. pending_response [ request_id ] = response <TAB> <TAB> <TAB> <TAB> <TAB> except Exception as e : <TAB> <TAB> raise e <TAB> finally : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. pending_request. remove ( wait_for_req_id )",False,wait_for_req_id in self.pending_request,wait_for_req_id,0.652309238910675
|
||
|
725,"def check_headers ( self, headers : Headers ) -> None : <TAB> etag = headers. get ( ""etag"" ) <TAB> if etag is not None : <TAB> <TAB> if etag. startswith ( ( ""W/"", ""w/"" ) ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> warn ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Weak etag indicator should be upper case."", <TAB> <TAB> <TAB> <TAB> <TAB> HTTPWarning, <TAB> <TAB> <TAB> <TAB> <TAB> stacklevel = 4, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> etag = etag [ 2 : ] <TAB> <TAB> if not ( etag [ : 1 ] == etag [ - 1 : ] == '""' ) : <TAB> <TAB> <TAB> warn ( ""Unquoted etag emitted."", HTTPWarning, stacklevel = 4 ) <TAB> location = headers. get ( ""location"" ) <TAB> if location is not None : <TAB> <TAB> if not urlparse ( location ). netloc : <TAB> <TAB> <TAB> warn ( <TAB> <TAB> <TAB> <TAB> ""Absolute URLs required for location header."", <TAB> <TAB> <TAB> <TAB> HTTPWarning, <TAB> <TAB> <TAB> <TAB> stacklevel = 4, <TAB> <TAB> <TAB> )",False,etag.startswith('w/'),"etag.startswith(('w/', 'w/'))",0.6573379039764404
|
||
|
726,"def __init__ ( self, format ) : <TAB> <TAB> format = "" "". join ( re. split ( r""(?:\s|%t|%n)+"", format ) ) <TAB> pattern = [ ] <TAB> try : <TAB> <TAB> for spec in re. findall ( r""%\w|%%|."", format ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> spec = SPEC [ spec ] <TAB> <TAB> <TAB> pattern. append ( spec ) <TAB> except KeyError : <TAB> <TAB> raise ValueError ( ""unknown specificer:{}"". format ( spec ) ) <TAB> self. pattern = re. compile ( r""(?i)"" + """". join ( pattern ) )",False,spec[0] == '%',spec in SPEC,0.6606450080871582
|
||
|
727,"def _update_indexes ( self, _rev, data ) : <TAB> _id, new_rev, db_data = self. _update_id_index ( _rev, data ) <TAB> with self. main_lock : <TAB> <TAB> self. id_revs [ _id ] = new_rev <TAB> for index in self. indexes [ 1 : ] : <TAB> <TAB> with self. main_lock : <TAB> <TAB> <TAB> curr_rev = self. id_revs. get ( _id ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> self. _single_update_index ( index, data, db_data, _id ) <TAB> with self. main_lock : <TAB> <TAB> if self. id_revs [ _id ] == new_rev : <TAB> <TAB> <TAB> del self. id_revs [ _id ] <TAB> return _id, new_rev",False,curr_rev != new_rev,curr_rev == new_rev,0.653876781463623
|
||
|
728,"def connect ( self ) : <TAB> self. sock = sockssocket ( ) <TAB> self. sock. setproxy ( * proxy_args ) <TAB> if type ( self. timeout ) in ( int, float ) : <TAB> <TAB> self. sock. settimeout ( self. timeout ) <TAB> self. sock. connect ( ( self. host, self. port ) ) <TAB> if isinstance ( self, compat_http_client. HTTPSConnection ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. sock = self. _context. wrap_socket ( self. sock, server_hostname = self. host ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. sock = ssl. wrap_socket ( self. sock )",False,"hasattr(self, '_context')",self._context,0.6537714004516602
|
||
|
729,"def train ( epoch ) : <TAB> model. train ( ) <TAB> train_loss = 0 <TAB> for batch_idx, ( data, _ ) in enumerate ( train_loader ) : <TAB> <TAB> data = data. to ( device ) <TAB> <TAB> optimizer. zero_grad ( ) <TAB> <TAB> recon_batch, mu, logvar = model ( data ) <TAB> <TAB> loss = loss_function ( recon_batch, data, mu, logvar ) <TAB> <TAB> loss. backward ( ) <TAB> <TAB> train_loss += loss. item ( ) <TAB> <TAB> optimizer. step ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> ""Train Epoch: {} [{}/{} ({:.0f}%)]\tLoss: {:.6f}"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> epoch, <TAB> <TAB> <TAB> <TAB> <TAB> batch_idx * len ( data ), <TAB> <TAB> <TAB> <TAB> <TAB> len ( train_loader. dataset ), <TAB> <TAB> <TAB> <TAB> <TAB> 100.0 * batch_idx / len ( train_loader ), <TAB> <TAB> <TAB> <TAB> <TAB> loss. item ( ) / len ( data ), <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> print ( <TAB> <TAB> ""====> Epoch: {} Average loss: {:.4f}"". format ( <TAB> <TAB> <TAB> epoch, train_loss / len ( train_loader. dataset ) <TAB> <TAB> ) <TAB> )",False,batch_idx % args.log_interval == 0,"hasattr(train_loader, 'dataset')",0.6529800891876221
|
||
|
730,"def create_unit ( <TAB> self, <TAB> key : str, <TAB> source : Union [ str, List [ str ] ], <TAB> target : Optional [ Union [ str, List [ str ] ] ] = None, ) : <TAB> if isinstance ( source, list ) : <TAB> <TAB> context = source [ 0 ] <TAB> <TAB> unit = self. construct_unit ( context ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> source = context <TAB> <TAB> else : <TAB> <TAB> <TAB> source = multistring ( source ) <TAB> else : <TAB> <TAB> context = source <TAB> <TAB> unit = self. construct_unit ( source ) <TAB> if isinstance ( target, list ) : <TAB> <TAB> if len ( target ) == 1 : <TAB> <TAB> <TAB> target = target [ 0 ] <TAB> <TAB> else : <TAB> <TAB> <TAB> target = multistring ( target ) <TAB> if key : <TAB> <TAB> unit. setid ( key ) <TAB> elif target is not None and self. set_context_bilingual : <TAB> <TAB> unit. setid ( context ) <TAB> <TAB> unit. context = context <TAB> if target is None : <TAB> <TAB> target = source <TAB> <TAB> source = self. create_unit_key ( key, source ) <TAB> unit. source = source <TAB> if isinstance ( unit, LISAunit ) and self. language_code : <TAB> <TAB> unit. settarget ( target, self. language_code ) <TAB> else : <TAB> <TAB> unit. target = target <TAB> return unit",True,len(source) == 1,len(source) == 1,0.6580545902252197
|
||
|
731,"def __setattr__ ( self, name, value ) : <TAB> if name == ""path"" : <TAB> <TAB> if value and value!= """" : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> <TAB> 'The page path should always start with a slash (""/"").' <TAB> <TAB> <TAB> <TAB> ) <TAB> elif name == ""load_time"" : <TAB> <TAB> if value and not isinstance ( value, int ) : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""Page load time must be specified in integer milliseconds."" <TAB> <TAB> <TAB> ) <TAB> object. __setattr__ ( self, name, value )",False,value[0] != '/',not value.startswith('/'),0.6724666953086853
|
||
|
732,"def predict ( <TAB> self, <TAB> img : Union [ str, np. ndarray ], <TAB> save_path : str = ""openpose_body"", <TAB> visualization : bool = True, ) : <TAB> self. eval ( ) <TAB> self. visualization = visualization <TAB> if isinstance ( img, str ) : <TAB> <TAB> orgImg = cv2. imread ( img ) <TAB> else : <TAB> <TAB> orgImg = img <TAB> data, imageToTest_padded, pad = self. transform ( orgImg ) <TAB> Mconv7_stage6_L1, Mconv7_stage6_L2 = self. forward ( paddle. to_tensor ( data ) ) <TAB> Mconv7_stage6_L1 = Mconv7_stage6_L1. numpy ( ) <TAB> Mconv7_stage6_L2 = Mconv7_stage6_L2. numpy ( ) <TAB> heatmap_avg = self. remove_pad ( Mconv7_stage6_L2, imageToTest_padded, orgImg, pad ) <TAB> paf_avg = self. remove_pad ( Mconv7_stage6_L1, imageToTest_padded, orgImg, pad ) <TAB> all_peaks = self. get_peak ( heatmap_avg ) <TAB> connection_all, special_k = self. get_connection ( all_peaks, paf_avg, orgImg ) <TAB> candidate, subset = self. get_candidate ( all_peaks, connection_all, special_k ) <TAB> canvas = copy. deepcopy ( orgImg ) <TAB> canvas = self. draw_pose ( canvas, candidate, subset ) <TAB> if self. visualization : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> os. mkdir ( save_path ) <TAB> <TAB> img_name = str ( time. time ( ) ) + "".png"" <TAB> <TAB> save_path = os. path. join ( save_path, img_name ) <TAB> <TAB> cv2. imwrite ( save_path, canvas ) <TAB> results = { ""candidate"" : candidate, ""subset"" : subset, ""data"" :",True,not os.path.exists(save_path),not os.path.exists(save_path),0.646492600440979
|
||
|
733,"def zip_readline_read_test ( self, f, compression ) : <TAB> self. make_test_archive ( f, compression ) <TAB> <TAB> with zipfile. ZipFile ( f, ""r"" ) as zipfp, zipfp. open ( TESTFN ) as zipopen : <TAB> <TAB> data = b"""" <TAB> <TAB> while True : <TAB> <TAB> <TAB> read = zipopen. readline ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> data += read <TAB> <TAB> <TAB> read = zipopen. read ( 100 ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> data += read <TAB> self. assertEqual ( data, self. data )",False,not read,len(read) > 100,0.6653151512145996
|
||
|
734,def update_trackers_info ( self ) : <TAB> old_trackers = self. get_old_trackers ( ) <TAB> with db_session : <TAB> <TAB> trackers = self. mds. TrackerState. select ( ). for_update ( ) [ : ] <TAB> <TAB> for tracker in trackers : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> tracker. set ( ** old_trackers [ tracker. url ] ),False,tracker.url in old_trackers,old_trackers.has_key(tracker.url),0.6619849801063538
|
||
|
735,"def convertPlaylistInfoToString ( seld, aPlaylistInfo, aTrackItems ) : <TAB> str = """" <TAB> str += ""[Title] %s\n"" % ( aPlaylistInfo [ ""title"" ] ) <TAB> str += ""[Type] %s\n"" % ( aPlaylistInfo [ ""type"" ] ) <TAB> str += ""[NumberOfTracks] %s\n"" % ( aPlaylistInfo [ ""numberOfTracks"" ] ) <TAB> str += ""[NumberOfVideos] %s\n"" % ( aPlaylistInfo [ ""numberOfVideos"" ] ) <TAB> str += ""[Duration] %s\n"" % ( aPlaylistInfo [ ""duration"" ] ) <TAB> i = 0 <TAB> str += ""===========Track=============\n"" <TAB> for item in aTrackItems : <TAB> <TAB> type = item [ ""type"" ] <TAB> <TAB> item = item [ ""item"" ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> i = i + 1 <TAB> <TAB> str += ""{:<8}"". format ( ""[%d]"" % i ) + item [ ""title"" ] + ""\n"" <TAB> i = 0 <TAB> str += ""\n===========Video=============\n"" <TAB> for item in aTrackItems : <TAB> <TAB> type = item [ ""type"" ] <TAB> <TAB> item = item [ ""item"" ] <TAB> <TAB> if type!= ""video"" : <TAB> <TAB> <TAB> continue <TAB> <TAB> i = i + 1 <TAB> <TAB> str += ""{:<8}"". format ( ""[%d]"" % i ) + item [ ""title"" ] + ""\n"" <TAB> return str",False,type != 'track',type != 'video',0.6633092164993286
|
||
|
736,"def build_inputs ( self ) : <TAB> inputs = { } <TAB> for encoder in self. model. pipeline. encoders : <TAB> <TAB> if hasattr ( encoder, ""sequence_length"" ) : <TAB> <TAB> <TAB> for i in range ( encoder. sequence_length ) : <TAB> <TAB> <TAB> <TAB> inputs [ encoder. sequence_name ( i ) ] = Input ( <TAB> <TAB> <TAB> <TAB> <TAB> shape = ( 1, ), name = encoder. sequence_name ( i ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> inputs [ encoder. sequence_name ( i, suffix = ""_twin"" ) ] = Input ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> shape = ( 1, ), name = encoder. sequence_name ( i, suffix = ""_twin"" ) <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> inputs [ encoder. name ] = Input ( shape = ( 1, ), name = encoder. name ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> inputs [ encoder. twin_name ] = Input ( shape = ( 1, ), name = encoder. twin_name ) <TAB> return inputs",False,encoder.twin,"hasattr(encoder, 'twin_name')",0.6700774431228638
|
||
|
737,"def process_url_iterable ( self, iterable, opts, functionality, enabled_functionality ) : <TAB> self. out. debug ( ""base_plugin_internal.process_url_iterable"" ) <TAB> timeout_host = opts [ ""timeout_host"" ] <TAB> i = 0 <TAB> with ThreadPoolExecutor ( max_workers = opts [ ""threads_scan"" ] ) as executor : <TAB> <TAB> results = [ ] <TAB> <TAB> for url in iterable : <TAB> <TAB> <TAB> args = [ url, opts, functionality, enabled_functionality, True ] <TAB> <TAB> <TAB> future = executor. submit ( self. url_scan, * args ) <TAB> <TAB> <TAB> url_to_log = str ( url ). rstrip ( ) <TAB> <TAB> <TAB> results. append ( <TAB> <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> <TAB> ""future"" : future, <TAB> <TAB> <TAB> <TAB> <TAB> ""url"" : url_to_log, <TAB> <TAB> <TAB> <TAB> } <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. _process_results_multisite ( results, functionality, timeout_host ) <TAB> <TAB> <TAB> <TAB> results = [ ] <TAB> <TAB> <TAB> i += 1 <TAB> <TAB> if len ( results ) > 0 : <TAB> <TAB> <TAB> self. _process_results_multisite ( results, functionality, timeout_host ) <TAB> <TAB> <TAB> results = [ ]",False,i % 1000 == 0 and i != 0,len(results) > 0,0.6647021770477295
|
||
|
738,"def __process_family ( self, family, person1, person2, append_list ) : <TAB> if family. get_handle ( ) in self. __processed_families : <TAB> <TAB> return <TAB> self. __processed_families [ family. get_handle ( ) ] = True <TAB> missingbits = [ ] <TAB> if person1 is UnknownPerson or person1 is None : <TAB> <TAB> name1 = _ ( ""(unknown person)"" ) <TAB> else : <TAB> <TAB> name1 = name_displayer. display ( person1 ) <TAB> <TAB> if not name1 : <TAB> <TAB> <TAB> name1 = _ ( ""(person with unknown name)"" ) <TAB> if person2 is UnknownPerson or person2 is None : <TAB> <TAB> name2 = _ ( ""(unknown person)"" ) <TAB> else : <TAB> <TAB> name2 = name_displayer. display ( person2 ) <TAB> <TAB> if not name2 : <TAB> <TAB> <TAB> name2 = _ ( ""(person with unknown name)"" ) <TAB> name = _ ( ""%(name1)s and %(name2)s"" ) % { ""name1"" : name1, ""name2"" : name2 } <TAB> has_marriage = False <TAB> for event_ref in family. get_event_ref_list ( ) : <TAB> <TAB> event = self. dbstate. db. get_event_from_handle ( event_ref. ref ) <TAB> <TAB> if event. get_type ( ) not in [ EventType. MARRIAGE, EventType. DIVORCE ] : <TAB> <TAB> <TAB> continue <TAB> <TAB> missingbits. extend ( self. __process_event ( event ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> has_marriage = True <TAB> if family. get_relationship ( ) == FamilyRelType. MARRIED : <TAB> <TAB> if not has_marriage : <TAB> <TAB> <TAB> missingbits. append ( _ ( ""marriage event missing"" ) ) <TAB> elif family. get_relationship ( ) == FamilyRelType. UNKNOWN : <",False,event.get_type() == EventType.MARRIAGE,append_list,0.6539820432662964
|
||
|
739,"def test_main ( self ) : <TAB> allowed = [ ] <TAB> for license in self. ALLOWED : <TAB> <TAB> allowed. append ( """". join ( license. split ( ) ) ) <TAB> found = set ( ) <TAB> missing = [ ] <TAB> for path in iter_py_paths ( ) : <TAB> <TAB> header = b"""" <TAB> <TAB> with open ( path, ""rb"" ) as h : <TAB> <TAB> <TAB> for line in h : <TAB> <TAB> <TAB> <TAB> line = line. strip ( ) <TAB> <TAB> <TAB> <TAB> if not line. startswith ( b""#"" ) : <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> header += line. lstrip ( b""# "" ) + b""\n"" <TAB> <TAB> norm = b"""". join ( header. split ( ) ) <TAB> <TAB> norm = norm. decode ( ""utf-8"" ) <TAB> <TAB> for license_ in allowed : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> found. add ( license_ ) <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> else : <TAB> <TAB> <TAB> missing. append ( path ) <TAB> self. assertFalse ( missing, msg = ""Missing license: %r"" % missing ) <TAB> assert len ( allowed ) == len ( found )",False,license_ in norm,license_ in found,0.6635072231292725
|
||
|
740,"def init ( self ) : <TAB> r = self. get_redis ( ) <TAB> if r : <TAB> <TAB> key = ""pocsuite_target"" <TAB> <TAB> info_msg = ""[PLUGIN] try fetch targets from redis..."" <TAB> <TAB> logger. info ( info_msg ) <TAB> <TAB> targets = r. get ( key ) <TAB> <TAB> count = 0 <TAB> <TAB> if targets : <TAB> <TAB> <TAB> for target in targets : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> count += 1 <TAB> <TAB> info_msg = ""[PLUGIN] get {0} target(s) from redis"". format ( count ) <TAB> <TAB> logger. info ( info_msg )",False,self.add_target(target),target,0.6513898372650146
|
||
|
741,"def ShouldAttachKey ( cls, config, vcards = None, emails = None, ttl = 90 ) : <TAB> now = datetime. now ( ) <TAB> offset = timedelta ( days = ttl ) <TAB> never = datetime. fromtimestamp ( 0 ) <TAB> dates = [ ] <TAB> <TAB> who = dict ( ( vc. email, vc ) for vc in ( vcards or [ ] ) if vc ) <TAB> for e in emails or [ ] : <TAB> <TAB> if e not in who : <TAB> <TAB> <TAB> who [ e ] = config. vcards. get ( e ) <TAB> <TAB> <TAB> needs_key = 0 <TAB> for email, vc in who. iteritems ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> ts = None <TAB> <TAB> if vc : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ts = datetime. fromtimestamp ( float ( vc. pgp_key_shared ) ) <TAB> <TAB> <TAB> except ( ValueError, TypeError, AttributeError ) : <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> if ( ts or never ) + offset < now : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> needs_key += 1 <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ratio = cls. _encryption_ratio ( <TAB> <TAB> <TAB> <TAB> config. background, config. index, email, minimum = 1 <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if ratio <= 0 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return False <TAB> <TAB> return needs_key > 0",False,vc and vc.kind == 'profile',email == '',0.655734121799469
|
||
|
742,"def test_insert ( self ) : <TAB> funcs = [ <TAB> <TAB> functions. sin, <TAB> <TAB> functions. cos, <TAB> <TAB> functions. tan, <TAB> ] <TAB> <TAB> orig = [ ] <TAB> for orig_is_link in self. orig : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> orig. append ( links. Linear ( ( 3, 3 ) ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> orig. append ( funcs. pop ( 0 ) ) <TAB> <TAB> if self. is_link : <TAB> <TAB> subj = links. Linear ( ( 3, 3 ) ) <TAB> else : <TAB> <TAB> subj = funcs. pop ( 0 ) <TAB> <TAB> seq = chainer. Sequential ( * orig ) <TAB> if self. expect_error : <TAB> <TAB> with pytest. raises ( IndexError ) : <TAB> <TAB> <TAB> seq. insert ( self. pos, subj ) <TAB> else : <TAB> <TAB> seq. insert ( self. pos, subj ) <TAB> <TAB> <TAB> <TAB> orig. insert ( self. pos, subj ) <TAB> <TAB> assert len ( seq ) == len ( self. orig ) + 1 <TAB> <TAB> for i in range ( len ( self. orig ) + 1 ) : <TAB> <TAB> <TAB> assert seq [ i ] is orig [ i ]",True,orig_is_link,orig_is_link,0.657129168510437
|
||
|
743,"def _build_nightly_dict ( <TAB> registered_ds : FullNamesDict, <TAB> stable_version_ds : FullNamesDict, ) -> NightlyDict : <TAB> """"""Computes the nightly dict from the registered and stable dict."""""" <TAB> nightly_ds = collections. defaultdict ( <TAB> <TAB> lambda : collections. defaultdict ( <TAB> <TAB> <TAB> lambda : collections. defaultdict ( bool ) <TAB> <TAB> ) <TAB> ) <TAB> for dataset in registered_ds : <TAB> <TAB> if dataset in stable_version_ds : <TAB> <TAB> <TAB> for config in registered_ds [ dataset ] : <TAB> <TAB> <TAB> <TAB> if config in stable_version_ds [ dataset ] : <TAB> <TAB> <TAB> <TAB> <TAB> for version in registered_ds [ dataset ] [ config ] : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <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> nightly_ds [ dataset ] [ config ] [ version ] = False <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> nightly_ds [ dataset ] [ config ] [ version ] = True <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> nightly_ds [ dataset ] [ config ] = True <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> nightly_ds [ dataset ] = True <TAB> return nightly_ds",False,version in stable_version_ds[dataset][config],version in nightly_ds,0.6587651968002319
|
||
|
744,"def single_line_beta_description ( schema_or_field, strict = True ) : <TAB> if ""\n"" in schema_or_field [ ""field_details"" ] [ ""beta"" ] : <TAB> <TAB> msg = ""Beta descriptions must be single line.\n"" <TAB> <TAB> msg += ( <TAB> <TAB> <TAB> f""Offending field or field set: {schema_or_field['field_details']['name']}"" <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( msg ) <TAB> <TAB> else : <TAB> <TAB> <TAB> ecs_helpers. strict_warning ( msg )",True,strict,strict,0.6842748522758484
|
||
|
745,"def get_displayname ( self, schema : s_schema. Schema ) -> str : <TAB> if self. is_view ( schema ) and not self. get_alias_is_persistent ( schema ) : <TAB> <TAB> schema, mtype = self. material_type ( schema ) <TAB> else : <TAB> <TAB> mtype = self <TAB> union_of = mtype. get_union_of ( schema ) <TAB> if union_of : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> std_obj = schema. get ( ""std::BaseObject"", type = ObjectType ) <TAB> <TAB> <TAB> return std_obj. get_displayname ( schema ) <TAB> <TAB> else : <TAB> <TAB> <TAB> comps = sorted ( union_of. objects ( schema ), key = lambda o : o. id ) <TAB> <TAB> <TAB> return "" | "". join ( c. get_displayname ( schema ) for c in comps ) <TAB> else : <TAB> <TAB> intersection_of = mtype. get_intersection_of ( schema ) <TAB> <TAB> if intersection_of : <TAB> <TAB> <TAB> comps = sorted ( intersection_of. objects ( schema ), key = lambda o : o. id ) <TAB> <TAB> <TAB> comp_dns = ( c. get_displayname ( schema ) for c in comps ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return "" & "". join ( dn for dn in comp_dns if dn!= ""std::BaseObject"" ) <TAB> <TAB> elif mtype is self : <TAB> <TAB> <TAB> return super ( ). get_displayname ( schema ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return mtype. get_displayname ( schema )",False,self.get_is_opaque_union(schema),schema is None,0.6482722759246826
|
||
|
746,"def get_prep_value ( self ) : <TAB> prep_value = [ ] <TAB> for i, item in enumerate ( self. _bound_blocks ) : <TAB> <TAB> if item : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if not item. id : <TAB> <TAB> <TAB> <TAB> item. id = str ( uuid. uuid4 ( ) ) <TAB> <TAB> <TAB> prep_value. append ( item. get_prep_value ( ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> raw_item = self. _raw_data [ i ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raw_item [ ""id"" ] = str ( uuid. uuid4 ( ) ) <TAB> <TAB> <TAB> prep_value. append ( raw_item ) <TAB> return prep_value",False,not raw_item.get('id'),not raw_item.id,0.6522339582443237
|
||
|
747,"def parse_condexpr ( self ) : <TAB> lineno = self. stream. current. lineno <TAB> expr1 = self. parse_or ( ) <TAB> while self. stream. skip_if ( ""name:if"" ) : <TAB> <TAB> expr2 = self. parse_or ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> expr3 = self. parse_condexpr ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> expr3 = None <TAB> <TAB> expr1 = nodes. CondExpr ( expr2, expr1, expr3, lineno = lineno ) <TAB> <TAB> lineno = self. stream. current. lineno <TAB> return expr1",False,self.stream.skip_if('name:else'),expr2 is None,0.6482930779457092
|
||
|
748,"def _to_string_term ( self, ostream, _idx, _sub, _name_buffer, verbose ) : <TAB> if _idx == 0 and self. _const!= 0 : <TAB> <TAB> ostream. write ( ""%s"" % ( self. _const, ) ) <TAB> else : <TAB> <TAB> coef = self. _coef [ id ( _sub ) ] <TAB> <TAB> _coeftype = coef. __class__ <TAB> <TAB> if _idx and _coeftype is _NegationExpression : <TAB> <TAB> <TAB> coef = coef. _args [ 0 ] <TAB> <TAB> <TAB> _coeftype = coef. __class__ <TAB> <TAB> if _coeftype in native_numeric_types : <TAB> <TAB> <TAB> if _idx : <TAB> <TAB> <TAB> <TAB> coef = abs ( coef ) <TAB> <TAB> <TAB> if coef == 1 : <TAB> <TAB> <TAB> <TAB> ostream. write ( _sub. cname ( True, _name_buffer ) ) <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> ostream. write ( str ( coef ) ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> coef. to_string ( <TAB> <TAB> <TAB> <TAB> ostream = ostream, <TAB> <TAB> <TAB> <TAB> verbose = verbose, <TAB> <TAB> <TAB> <TAB> precedence = _ProductExpression. PRECEDENCE, <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> ostream. write ( str ( coef ) ) <TAB> <TAB> ostream. write ( ""*%s"" % ( _sub. cname ( True, _name_buffer ) ) )",False,coef.is_expression(),coef == 2,0.6549028158187866
|
||
|
749,"def run ( self ) : <TAB> display_fileno = self. _display. fileno ( ) <TAB> while True : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> rlist, wlist, xlist = select. select ( <TAB> <TAB> <TAB> <TAB> <TAB> ( self. _pipe [ 0 ], display_fileno ), ( ), ( ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> except select. error as err : <TAB> <TAB> <TAB> <TAB> if isinstance ( err, OSError ) : <TAB> <TAB> <TAB> <TAB> <TAB> code = err. errno <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> code = err [ 0 ] <TAB> <TAB> <TAB> <TAB> if code!= errno. EINTR : <TAB> <TAB> <TAB> <TAB> <TAB> raise <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> assert not wlist <TAB> <TAB> <TAB> assert not xlist <TAB> <TAB> <TAB> if self. _pipe [ 0 ] in rlist : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> self. _on_event ( self. _display. next_event ( ) )",False,not self._display.pending_events(),self._pipe[0] >= 0,0.6534614562988281
|
||
|
750,"def options_to_cli ( self, options ) : <TAB> verbose = options. pop ( ""verbose"", 0 ) <TAB> args = { ""become"" : False, ""check"" : True } <TAB> args. update ( options ) <TAB> cli = [ ] <TAB> cli_args = [ ] <TAB> if verbose : <TAB> <TAB> cli. append ( ""-"" + ""v"" * verbose ) <TAB> for arg_name, value in args. items ( ) : <TAB> <TAB> option = self. _known_options [ arg_name ] <TAB> <TAB> opt_cli = option [ ""cli"" ] <TAB> <TAB> opt_type = option [ ""type"" ] <TAB> <TAB> if opt_type == ""boolean"" : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> cli. append ( opt_cli ) <TAB> <TAB> elif opt_type == ""string"" : <TAB> <TAB> <TAB> cli. append ( opt_cli + "" %s"" ) <TAB> <TAB> <TAB> cli_args. append ( value ) <TAB> <TAB> elif opt_type == ""json"" : <TAB> <TAB> <TAB> cli. append ( opt_cli + "" %s"" ) <TAB> <TAB> <TAB> value_json = json. dumps ( value ) <TAB> <TAB> <TAB> cli_args. append ( value_json ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise TypeError ( ""Unsupported argument type '%s'."" % opt_type ) <TAB> return "" "". join ( cli ), cli_args",False,value,opt_type == 'bool',0.6882610321044922
|
||
|
751,"def __run ( self ) : <TAB> threads = self. parameters ( ) [ ""threads"" ]. getTypedValue ( ) <TAB> with IECore. tbb_global_control ( <TAB> <TAB> IECore. tbb_global_control. parameter. max_allowed_parallelism, <TAB> <TAB> IECore. hardwareConcurrency ( ) if threads == 0 else threads, <TAB> ) : <TAB> <TAB> self. _executeStartupFiles ( self. root ( ). getName ( ) ) <TAB> <TAB> <TAB> <TAB> defaultMessageHandler = IECore. MessageHandler. getDefaultHandler ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> IECore. MessageHandler. setDefaultHandler ( <TAB> <TAB> <TAB> <TAB> Gaffer. ProcessMessageHandler ( defaultMessageHandler ) <TAB> <TAB> <TAB> ) <TAB> <TAB> return self. _run ( self. parameters ( ). getValidatedValue ( ) )",False,"not isinstance(defaultMessageHandler, Gaffer.ProcessMessageHandler)",defaultMessageHandler is not None,0.6522072553634644
|
||
|
752,def run ( self ) : <TAB> try : <TAB> <TAB> <TAB> <TAB> next ( self. coro ) <TAB> <TAB> while True : <TAB> <TAB> <TAB> with self. abort_lock : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> msg = self. in_queue. get ( ) <TAB> <TAB> <TAB> if msg is POISON : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> with self. abort_lock : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> out = self. coro. send ( msg ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for msg in _allmsgs ( out ) : <TAB> <TAB> <TAB> <TAB> with self. abort_lock : <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> <TAB> self. out_queue. put ( msg ) <TAB> except BaseException : <TAB> <TAB> self. abort_all ( sys. exc_info ( ) ) <TAB> <TAB> return <TAB> <TAB> self. out_queue. release ( ),False,self.abort_flag,msg is not None,0.6556994915008545
|
||
|
753,"def _check_is_max_context ( doc_spans, cur_span_index, position ) : <TAB> """"""chech is max context"""""" <TAB> best_score = None <TAB> best_span_index = None <TAB> for ( span_index, doc_span ) in enumerate ( doc_spans ) : <TAB> <TAB> end = doc_span. start + doc_span. length - 1 <TAB> <TAB> if position < doc_span. start : <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> num_left_context = position - doc_span. start <TAB> <TAB> num_right_context = end - position <TAB> <TAB> score = min ( num_left_context, num_right_context ) + 0.01 * doc_span. length <TAB> <TAB> if best_score is None or score > best_score : <TAB> <TAB> <TAB> best_score = score <TAB> <TAB> <TAB> best_span_index = span_index <TAB> return cur_span_index == best_span_index",False,position > end,end < doc_span.length,0.6760665774345398
|
||
|
754,"def async_to_sync_wrap ( * args, ** kwargs ) : <TAB> coroutine = function ( * args, ** kwargs ) <TAB> try : <TAB> <TAB> loop = asyncio. get_event_loop ( ) <TAB> except RuntimeError : <TAB> <TAB> loop = main_loop <TAB> if loop. is_running ( ) : <TAB> <TAB> if threading. current_thread ( ) is threading. main_thread ( ) : <TAB> <TAB> <TAB> return coroutine <TAB> <TAB> else : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return asyncio. run_coroutine_threadsafe ( coroutine, loop ). result ( ) <TAB> <TAB> <TAB> if inspect. isasyncgen ( coroutine ) : <TAB> <TAB> <TAB> <TAB> return asyncio. run_coroutine_threadsafe ( <TAB> <TAB> <TAB> <TAB> <TAB> consume_generator ( coroutine ), loop <TAB> <TAB> <TAB> <TAB> ). result ( ) <TAB> if<mask> : <TAB> <TAB> return loop. run_until_complete ( coroutine ) <TAB> if inspect. isasyncgen ( coroutine ) : <TAB> <TAB> return loop. run_until_complete ( consume_generator ( coroutine ) )",True,inspect.iscoroutine(coroutine),inspect.iscoroutine(coroutine),0.6525558233261108
|
||
|
755,"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<mask> : <TAB> <TAB> <TAB> if ftype == TType. I64 : <TAB> <TAB> <TAB> <TAB> self. timestamp = iprot. readI64 ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif fid == 2 : <TAB> <TAB> <TAB> if ftype == TType. STRING : <TAB> <TAB> <TAB> <TAB> self. value = iprot. readString ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif fid == 3 : <TAB> <TAB> <TAB> if ftype == TType. STRUCT : <TAB> <TAB> <TAB> <TAB> self. host = Endpoint ( ) <TAB> <TAB> <TAB> <TAB> self. host. 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.6738317012786865
|
||
|
756,"def open_file_action ( self ) : <TAB> wildcard = ""All files (*.*)|*.*"" <TAB> for src in registry. sources : <TAB> <TAB> if len ( src. extensions ) > 0 : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> wildcard += src. wildcard <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> wildcard += ""|"" + src. wildcard <TAB> dialog = FileDialog ( <TAB> <TAB> parent = None, title = ""Open supported data file"", action = ""open"", wildcard = wildcard <TAB> ) <TAB> if dialog. open ( ) == OK : <TAB> <TAB> if not isfile ( dialog. path ) : <TAB> <TAB> <TAB> error ( ""File '%s' does not exist!"" % dialog. path ) <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> object = self. object <TAB> <TAB> engine = get_engine ( object ) <TAB> <TAB> engine. open ( dialog. path, object )",False,wildcard.endswith('|') or src.wildcard.startswith('|'),"hasattr(src, 'wildcard')",0.652045726776123
|
||
|
757,"def format_drf_errors ( response, context, exc ) : <TAB> errors = [ ] <TAB> <TAB> if isinstance ( response. data, list ) : <TAB> <TAB> for message in response. data : <TAB> <TAB> <TAB> errors. extend ( format_error_object ( message, ""/data"", response ) ) <TAB> <TAB> else : <TAB> <TAB> for field, error in response. data. items ( ) : <TAB> <TAB> <TAB> field = format_value ( field ) <TAB> <TAB> <TAB> pointer = ""/data/attributes/{}"". format ( field ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> errors. extend ( format_error_object ( error, None, response ) ) <TAB> <TAB> <TAB> elif isinstance ( error, str ) : <TAB> <TAB> <TAB> <TAB> classes = inspect. getmembers ( exceptions, inspect. isclass ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if isinstance ( exc, tuple ( x [ 1 ] for x in classes ) ) : <TAB> <TAB> <TAB> <TAB> <TAB> pointer = ""/data"" <TAB> <TAB> <TAB> <TAB> errors. extend ( format_error_object ( error, pointer, response ) ) <TAB> <TAB> <TAB> elif isinstance ( error, list ) : <TAB> <TAB> <TAB> <TAB> errors. extend ( format_error_object ( error, pointer, response ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> errors. extend ( format_error_object ( error, pointer, response ) ) <TAB> context [ ""view"" ]. resource_name = ""errors"" <TAB> response. data = errors <TAB> return response",False,"isinstance(exc, Http404) and isinstance(error, str)","isinstance(error, dict)",0.6502106189727783
|
||
|
758,"def find_missing_file ( file_path ) : <TAB> """"""Find a missing file name or file path, and return valid path."""""" <TAB> _ = get_app ( ). _tr <TAB> modified = False <TAB> skipped = False <TAB> <TAB> if os. path. exists ( file_path ) : <TAB> <TAB> return ( file_path, modified, skipped ) <TAB> <TAB> file_name = os. path. split ( file_path ) [ - 1 ] <TAB> <TAB> for known_path in known_paths : <TAB> <TAB> possible_path = os. path. join ( known_path, file_name ) <TAB> <TAB> if os. path. exists ( possible_path ) : <TAB> <TAB> <TAB> modified = True <TAB> <TAB> <TAB> return ( possible_path, modified, skipped ) <TAB> <TAB> while not os. path. exists ( file_path ) : <TAB> <TAB> recommended_path = get_app ( ). project. current_filepath or """" <TAB> <TAB> if not recommended_path : <TAB> <TAB> <TAB> recommended_path = info. HOME_PATH <TAB> <TAB> else : <TAB> <TAB> <TAB> recommended_path = os. path. dirname ( recommended_path ) <TAB> <TAB> QMessageBox. warning ( <TAB> <TAB> <TAB> None, <TAB> <TAB> <TAB> _ ( ""Missing File (%s)"" ) % file_name, <TAB> <TAB> <TAB> _ ( ""%s cannot be found."" ) % file_name, <TAB> <TAB> ) <TAB> <TAB> modified = True <TAB> <TAB> folder_to_check = QFileDialog. getExistingDirectory ( <TAB> <TAB> <TAB> None, _ ( ""Find directory that contains: %s"" % file_name ), recommended_path <TAB> <TAB> ) <TAB> <TAB> if folder_to_check and folder_to_check not in known_paths : <TAB> <TAB> <TAB> known_paths. append ( folder_to_check ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB",False,folder_to_check == '',not file_path,0.6510452628135681
|
||
|
759,"def split_parameter_list_as_sql ( self, compiler, connection ) : <TAB> <TAB> <TAB> max_in_list_size = connection. ops. max_in_list_size ( ) <TAB> lhs, lhs_params = self. process_lhs ( compiler, connection ) <TAB> rhs, rhs_params = self. batch_process_rhs ( compiler, connection ) <TAB> in_clause_elements = [ ""("" ] <TAB> params = [ ] <TAB> for offset in range ( 0, len ( rhs_params ), max_in_list_size ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> in_clause_elements. append ( "" OR "" ) <TAB> <TAB> in_clause_elements. append ( ""%s IN ("" % lhs ) <TAB> <TAB> params. extend ( lhs_params ) <TAB> <TAB> sqls = rhs [ offset : offset + max_in_list_size ] <TAB> <TAB> sqls_params = rhs_params [ offset : offset + max_in_list_size ] <TAB> <TAB> param_group = "", "". join ( sqls ) <TAB> <TAB> in_clause_elements. append ( param_group ) <TAB> <TAB> in_clause_elements. append ( "")"" ) <TAB> <TAB> params. extend ( sqls_params ) <TAB> in_clause_elements. append ( "")"" ) <TAB> return """". join ( in_clause_elements ), params",False,offset > 0,lhs_params[offset + max_in_list_size] > 0,0.6728770732879639
|
||
|
760,"def _set_http_cookie ( ) : <TAB> if conf. cookie : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> conf. http_headers [ HTTP_HEADER. COOKIE ] = ""; "". join ( <TAB> <TAB> <TAB> <TAB> map ( lambda x : ""="". join ( x ), conf. cookie. items ( ) ) <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> conf. http_headers [ HTTP_HEADER. COOKIE ] = conf. cookie",False,"isinstance(conf.cookie, dict)","hasattr(conf.cookie, 'items')",0.6557393074035645
|
||
|
761,"def daemon_stop ( pid_file ) : <TAB> import errno <TAB> try : <TAB> <TAB> with open ( pid_file ) as f : <TAB> <TAB> <TAB> buf = f. read ( ) <TAB> <TAB> <TAB> pid = common. to_str ( buf ) <TAB> <TAB> <TAB> if not buf : <TAB> <TAB> <TAB> <TAB> logging. error ( ""not running"" ) <TAB> except IOError as e : <TAB> <TAB> shell. print_exception ( e ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> logging. error ( ""not running"" ) <TAB> <TAB> <TAB> return <TAB> <TAB> sys. exit ( 1 ) <TAB> pid = int ( pid ) <TAB> if pid > 0 : <TAB> <TAB> try : <TAB> <TAB> <TAB> os. kill ( pid, signal. SIGTERM ) <TAB> <TAB> except OSError as e : <TAB> <TAB> <TAB> if e. errno == errno. ESRCH : <TAB> <TAB> <TAB> <TAB> logging. error ( ""not running"" ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> shell. print_exception ( e ) <TAB> <TAB> <TAB> sys. exit ( 1 ) <TAB> else : <TAB> <TAB> logging. error ( ""pid is not positive: %d"", pid ) <TAB> <TAB> for i in range ( 0, 200 ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> os. kill ( pid, 0 ) <TAB> <TAB> except OSError as e : <TAB> <TAB> <TAB> if e. errno == errno. ESRCH : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> time. sleep ( 0.05 ) <TAB> else : <TAB> <TAB> logging. error ( ""timed out when stopping pid %d"", pid ) <TAB> <TAB> sys. exit (",False,e.errno == errno.ENOENT,pid < 0,0.657820463180542
|
||
|
762,"def __init__ ( self, red_op, axis, acc_dtype, dtype, return_indices ) : <TAB> DnnBase. __init__ ( self, [ ""c_code/dnn_redux.c"" ], ""APPLY_SPECIFIC(dnn_redux)"" ) <TAB> assert cudnn. cudnnReduceTensorOp_t. has_alias ( red_op ) <TAB> self. red_op = red_op <TAB> assert acc_dtype in [ ""float16"", ""float32"", ""float64"" ] <TAB> self. acc_dtype = acc_dtype <TAB> assert dtype in [ ""float16"", ""float32"", ""float64"" ] <TAB> self. dtype = dtype <TAB> <TAB> if axis is not None : <TAB> <TAB> if len ( axis ) > 8 : <TAB> <TAB> <TAB> raise ValueError ( ""Too many axes to reduce on"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( ""Axes larger than 8 not supported"" ) <TAB> <TAB> axis = tuple ( axis ) <TAB> <TAB> self. c_axis = self. _convert_axis ( axis ) <TAB> <TAB> self. axis = axis <TAB> if return_indices and ( red_op!= ""maximum"" and red_op!= ""minimum"" ) : <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> ""Can't request indices for something other than"" "" minimum or maximum"" <TAB> <TAB> ) <TAB> self. return_indices = return_indices",False,any((a >= 8 for a in axis)),len(axis) > 8,0.6600173711776733
|
||
|
763,"def testformat ( formatstr, args, output = None, limit = None, overflowok = False ) : <TAB> if verbose : <TAB> <TAB> if output : <TAB> <TAB> <TAB> print ( ""{!a} % {!a} =? {!a}..."". format ( formatstr, args, output ), end = "" "" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> print ( ""{!a} % {!a} works?..."". format ( formatstr, args ), end = "" "" ) <TAB> try : <TAB> <TAB> result = formatstr % args <TAB> except OverflowError : <TAB> <TAB> if not overflowok : <TAB> <TAB> <TAB> raise <TAB> <TAB> if verbose : <TAB> <TAB> <TAB> print ( ""overflow (this is fine)"" ) <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if verbose : <TAB> <TAB> <TAB> <TAB> print ( ""no"" ) <TAB> <TAB> <TAB> raise AssertionError ( <TAB> <TAB> <TAB> <TAB> ""%r %% %r == %r!= %r"" % ( formatstr, args, result, output ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> elif ( <TAB> <TAB> <TAB> output <TAB> <TAB> <TAB> and limit is not None <TAB> <TAB> <TAB> and ( len ( result )!= len ( output ) or result [ : limit ]!= output [ : limit ] ) <TAB> <TAB> ) : <TAB> <TAB> <TAB> if verbose : <TAB> <TAB> <TAB> <TAB> print ( ""no"" ) <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> ""%s %% %s == %s!= %s"" <TAB> <TAB> <TAB> <TAB> % ( repr ( formatstr ), repr ( args ), repr ( result ), repr ( output ) ) <TAB> <TAB> <TAB>",False,output and limit is None and (result != output),overflowok,0.6537837982177734
|
||
|
764,"def check_format_version ( filename, data ) : <TAB> format_version_ = data. pop ( ""format_version"", None ) <TAB> if format_version_ is not None : <TAB> <TAB> try : <TAB> <TAB> <TAB> format_version_ = int ( format_version_ ) <TAB> <TAB> except : <TAB> <TAB> <TAB> return <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> print_warning ( <TAB> <TAB> <TAB> <TAB> ""Loading from %s may fail: newer format version (%d) than current "" <TAB> <TAB> <TAB> <TAB> ""format version (%d)"" % ( filename, format_version_, format_version ) <TAB> <TAB> <TAB> )",False,format_version_ > format_version,format_version_ > 6,0.6510088443756104
|
||
|
765,"def describe_volumes ( self, volume_ids = None, filters = None ) : <TAB> matches = self. volumes. values ( ) <TAB> if volume_ids : <TAB> <TAB> matches = [ vol for vol in matches if vol. id in volume_ids ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> unknown_ids = set ( volume_ids ) - set ( matches ) <TAB> <TAB> <TAB> raise InvalidVolumeIdError ( unknown_ids ) <TAB> if filters : <TAB> <TAB> matches = generic_filter ( filters, matches ) <TAB> return matches",False,len(volume_ids) > len(matches),volume_ids,0.6511069536209106
|
||
|
766,"def acquire ( self, timeout = None ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> timeout = timeout if timeout is not None else self. timeout <TAB> end_time = time. time ( ) <TAB> if timeout is not None and timeout > 0 : <TAB> <TAB> end_time += timeout <TAB> while True : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> os. symlink ( self. unique_name, self. lock_file ) <TAB> <TAB> except OSError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if self. i_am_locking ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if timeout is not None and time. time ( ) > end_time : <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> raise LockTimeout ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""Timeout waiting to acquire"" "" lock for %s"" % self. path <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> raise AlreadyLocked ( ""%s is already locked"" % self. path ) <TAB> <TAB> <TAB> <TAB> time. sleep ( timeout / 10 if timeout is not None else 0.1 ) <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return",False,timeout > 0,timeout is None or timeout < 0,0.679872989654541
|
||
|
767,"def save_data ( data, _id, path, do_pickle = True, silent = False ) : <TAB> """"""Save data to a diskfile"""""" <TAB> if not silent : <TAB> <TAB> logging. debug ( ""[%s] Saving data for %s in %s"", misc. caller_name ( ), _id, path ) <TAB> path = os. path. join ( path, _id ) <TAB> <TAB> for t in range ( 3 ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> with open ( path, ""wb"" ) as data_file : <TAB> <TAB> <TAB> <TAB> if do_pickle : <TAB> <TAB> <TAB> <TAB> <TAB> pickle. dump ( data, data_file, protocol = pickle. HIGHEST_PROTOCOL ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> data_file. write ( data ) <TAB> <TAB> <TAB> break <TAB> <TAB> except : <TAB> <TAB> <TAB> if silent : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> logging. error ( T ( ""Saving %s failed"" ), path ) <TAB> <TAB> <TAB> <TAB> logging. info ( ""Traceback: "", exc_info = True ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> time. sleep ( 0.1 )",False,t == 2,not silent,0.673535943031311
|
||
|
768,"def open_file_input ( cli_parsed ) : <TAB> files = glob. glob ( os. path. join ( cli_parsed. d, ""*report.html"" ) ) <TAB> if len ( files ) > 0 : <TAB> <TAB> print ( ""\n[*] Done! Report written in the "" + cli_parsed. d + "" folder!"" ) <TAB> <TAB> print ( ""Would you like to open the report now? [Y/n]"" ) <TAB> <TAB> while True : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> response = input ( ). lower ( ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> return True <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> return strtobool ( response ) <TAB> <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> <TAB> print ( ""Please respond with y or n"" ) <TAB> else : <TAB> <TAB> print ( ""[*] No report files found to open, perhaps no hosts were successful"" ) <TAB> <TAB> return False",False,response == '',response == 'y',0.685572624206543
|
||
|
769,"def _IsDBInstanceReady ( self, instance_id, timeout = IS_READY_TIMEOUT ) : <TAB> cmd = util. GcloudCommand ( self, ""sql"", ""instances"", ""describe"", instance_id ) <TAB> start_time = datetime. datetime. now ( ) <TAB> while True : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> logging. exception ( ""Timeout waiting for sql instance to be ready"" ) <TAB> <TAB> <TAB> return False <TAB> <TAB> stdout, _, _ = cmd. Issue ( suppress_warning = True, raise_on_failure = False ) <TAB> <TAB> try : <TAB> <TAB> <TAB> json_output = json. loads ( stdout ) <TAB> <TAB> <TAB> state = json_output [ ""state"" ] <TAB> <TAB> <TAB> logging. info ( ""Instance %s state: %s"", instance_id, state ) <TAB> <TAB> <TAB> if state == ""RUNNABLE"" : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> except : <TAB> <TAB> <TAB> logging. exception ( ""Error attempting to read stdout. Creation failure."" ) <TAB> <TAB> <TAB> return False <TAB> <TAB> time. sleep ( 5 ) <TAB> return True",False,(datetime.datetime.now() - start_time).seconds > timeout,not cmd.issue,0.6474670767784119
|
||
|
770,"def __modules ( self ) : <TAB> raw_output = self. __module_avail_output ( ). decode ( ""utf-8"" ) <TAB> for line in StringIO ( raw_output ) : <TAB> <TAB> line = line and line. strip ( ) <TAB> <TAB> if not line or line. startswith ( ""-"" ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> line_modules = line. split ( ) <TAB> <TAB> for module in line_modules : <TAB> <TAB> <TAB> if module. endswith ( self. default_indicator ) : <TAB> <TAB> <TAB> <TAB> module = module [ 0 : - len ( self. default_indicator ) ]. strip ( ) <TAB> <TAB> <TAB> module_parts = module. split ( ""/"" ) <TAB> <TAB> <TAB> module_version = None <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> module_version = module_parts [ 1 ] <TAB> <TAB> <TAB> module_name = module_parts [ 0 ] <TAB> <TAB> <TAB> yield module_name, module_version",False,len(module_parts) == 2,len(module_parts) > 1,0.6514577269554138
|
||
|
771,"def _parse_literal_set ( self ) : <TAB> valid_types = ( six. string_types, Binary, Decimal ) <TAB> first_type = type ( self. _current [ ""value"" ] ) <TAB> elements = set ( ) <TAB> while True : <TAB> <TAB> element = self. _current <TAB> <TAB> if not self. _match ( ""literal"" ) : <TAB> <TAB> <TAB> raise UnexpectedTokenError ( <TAB> <TAB> <TAB> <TAB> token = self. _current, <TAB> <TAB> <TAB> <TAB> expression = self. _expression, <TAB> <TAB> <TAB> <TAB> expected_type = ""literal"", <TAB> <TAB> <TAB> ) <TAB> <TAB> if not isinstance ( element [ ""value"" ], valid_types ) : <TAB> <TAB> <TAB> message = ( <TAB> <TAB> <TAB> <TAB> ""Sets may only contain numbers, strings, or bytes, "" <TAB> <TAB> <TAB> <TAB> ""but literal of type `%s` was found"" <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> raise InvalidLiteralValueError ( <TAB> <TAB> <TAB> <TAB> token = self. _current, <TAB> <TAB> <TAB> <TAB> expression = self. _expression, <TAB> <TAB> <TAB> <TAB> message = message % type ( element [ ""type"" ] ), <TAB> <TAB> <TAB> ) <TAB> <TAB> if not isinstance ( element [ ""value"" ], first_type ) : <TAB> <TAB> <TAB> message = ( <TAB> <TAB> <TAB> <TAB> ""Set values must all be of the same type. First type was "" <TAB> <TAB> <TAB> <TAB> ""`%s`, but found value of type `%s`"" <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> raise InvalidLiteralValueError ( <TAB> <TAB> <TAB> <TAB> token = self. _current, <TAB> <TAB> <TAB> <TAB> expression = self. _expression, <TAB> <TAB> <TAB>",False,not self._match('comma'),self._type is None,0.6520204544067383
|
||
|
772,"def index_structure ( structure, path, path_separator = ""/"" ) : <TAB> """"""Follows :obj:`path` in a nested structure of objects, lists, and dicts."""""" <TAB> keys = path. split ( path_separator ) <TAB> for i, key in enumerate ( keys ) : <TAB> <TAB> current_path = ""%s%s"" % ( path_separator, path_separator. join ( keys [ : i ] ) ) <TAB> <TAB> if isinstance ( structure, list ) : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> index = int ( key ) <TAB> <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Object referenced by path '%s' is a list, but got non "" <TAB> <TAB> <TAB> <TAB> <TAB> ""integer index '%s'"" % ( current_path, key ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if index < 0 or index >= len ( structure ) : <TAB> <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""List referenced by path '%s' has length %d, but got "" <TAB> <TAB> <TAB> <TAB> <TAB> ""out of range index %d"" % ( current_path, len ( structure ), index ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> structure = structure [ index ] <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> structure = structure. get ( key ) <TAB> <TAB> <TAB> if structure is None : <TAB> <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Dictionary referenced by path '%s' does not have the "" <TAB> <TAB> <TAB> <TAB> <TAB> ""key '%s'"" % ( current_path, key ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB",True,"isinstance(structure, dict)","isinstance(structure, dict)",0.655419111251831
|
||
|
773,"def parse_results ( cwd ) : <TAB> optimal_dd = None <TAB> optimal_measure = numpy. inf <TAB> for tup in tools. find_conf_files ( cwd ) : <TAB> <TAB> dd = tup [ 1 ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if dd [ ""results.train_y_misclass"" ] < optimal_measure : <TAB> <TAB> <TAB> <TAB> optimal_measure = dd [ ""results.train_y_misclass"" ] <TAB> <TAB> <TAB> <TAB> optimal_dd = dd <TAB> print ( ""Optimal results.train_y_misclass:"", str ( optimal_measure ) ) <TAB> for key, value in optimal_dd. items ( ) : <TAB> <TAB> if ""hyper_parameters"" in key : <TAB> <TAB> <TAB> print ( key + "": "" + str ( value ) )",False,'results.train_y_misclass' in dd,dd is not None,0.6543463468551636
|
||
|
774,"def from_json ( self, value, trans, other_values = { } ) : <TAB> if self. multiple : <TAB> <TAB> tag_list = [ ] <TAB> <TAB> <TAB> <TAB> if isinstance ( value, list ) or isinstance ( value, str ) : <TAB> <TAB> <TAB> if not isinstance ( value, list ) : <TAB> <TAB> <TAB> <TAB> value = value. split ( ""\n"" ) <TAB> <TAB> <TAB> for tag_str in value : <TAB> <TAB> <TAB> <TAB> for tag in str ( tag_str ). split ( "","" ) : <TAB> <TAB> <TAB> <TAB> <TAB> tag = tag. strip ( ) <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> tag_list. append ( tag ) <TAB> <TAB> value = tag_list <TAB> else : <TAB> <TAB> if not value : <TAB> <TAB> <TAB> value = None <TAB> <TAB> <TAB> return super ( ). from_json ( value, trans, other_values, require_legal_value = False )",True,tag,tag,0.6900748014450073
|
||
|
775,"def live ( self ) : <TAB> if os. geteuid ( )!= 0 : <TAB> <TAB> self. session. logging. error ( <TAB> <TAB> <TAB> ""You are not root. It is likely that some operations "" <TAB> <TAB> <TAB> ""may not be available."" <TAB> <TAB> ) <TAB> <TAB> with self. session : <TAB> <TAB> self. session. SetParameter ( ""cache"", ""timed"" ) <TAB> <TAB> self. session. SetParameter ( ""live_mode"", self. plugin_args. mode ) <TAB> <TAB> self. session. SetParameter ( ""session_name"", ""Live (%s)"" % self. plugin_args. mode ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> load_as = self. session. plugins. load_as ( session = self. session ) <TAB> <TAB> <TAB> <TAB> base_as = standard. FileAddressSpace ( <TAB> <TAB> <TAB> <TAB> <TAB> session = self. session, filename = ""/proc/kcore"" <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> self. session. physical_address_space = load_as. GuessAddressSpace ( <TAB> <TAB> <TAB> <TAB> <TAB> base_as = base_as <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> self. session. SetParameter ( ""session_name"", ""Live(/proc/kcore)"" ) <TAB> <TAB> <TAB> except IOError as e : <TAB> <TAB> <TAB> <TAB> self. session. logging. error ( ""Unable to load physical memory: %s "", e )",False,self.plugin_args.mode == 'Memory',self.session.physical_address_space is not None,0.651208221912384
|
||
|
776,"def _generate_tags ( self, base = None ) : <TAB> """"""Return dictionary of tags, mapping tag names to values."""""" <TAB> tags = { } <TAB> for key in self. tag_fields : <TAB> <TAB> if key. startswith ( ""rg_"" ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> tags [ key ] = 1.0 <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> tags [ key ] = - 1 <TAB> <TAB> else : <TAB> <TAB> <TAB> tags [ key ] = ""value\u2010%s"" % key <TAB> for key in [ ""disc"", ""disctotal"", ""track"", ""tracktotal"", ""bpm"" ] : <TAB> <TAB> tags [ key ] = 1 <TAB> tags [ ""art"" ] = self. jpg_data <TAB> tags [ ""comp"" ] = True <TAB> date = datetime. date ( 2001, 4, 3 ) <TAB> tags [ ""date"" ] = date <TAB> tags [ ""year"" ] = date. year <TAB> tags [ ""month"" ] = date. month <TAB> tags [ ""day"" ] = date. day <TAB> original_date = datetime. date ( 1999, 5, 6 ) <TAB> tags [ ""original_date"" ] = original_date <TAB> tags [ ""original_year"" ] = original_date. year <TAB> tags [ ""original_month"" ] = original_date. month <TAB> tags [ ""original_day"" ] = original_date. day <TAB> return tags",False,key.startswith('r128_'),key == 'clcl',0.654512345790863
|
||
|
777,"def parse_simple ( d, data ) : <TAB> units = { } <TAB> for v in data [ d ] : <TAB> <TAB> key = v [ ""name"" ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> key_to_insert = make_key ( key ) <TAB> <TAB> if key_to_insert in units : <TAB> <TAB> <TAB> index = 2 <TAB> <TAB> <TAB> tmp = f""{key_to_insert}_{index}"" <TAB> <TAB> <TAB> while tmp in units : <TAB> <TAB> <TAB> <TAB> index += 1 <TAB> <TAB> <TAB> <TAB> tmp = f""{key_to_insert}_{index}"" <TAB> <TAB> <TAB> key_to_insert = tmp <TAB> <TAB> units [ key_to_insert ] = v [ ""id"" ] <TAB> return units",False,not key,key in units,0.669816255569458
|
||
|
778,"def _create_examples ( cls, data_path, set_type ) : <TAB> curr_token_list, curr_pos_list = [ ], [ ] <TAB> data_lines = read_file_lines ( data_path, ""r"", encoding = ""utf-8"" ) <TAB> examples = [ ] <TAB> idx = 0 <TAB> for data_line in data_lines : <TAB> <TAB> data_line = data_line. strip ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if set_type == ""test"" : <TAB> <TAB> <TAB> <TAB> line_tokens = data_line. split ( ""\t"" ) <TAB> <TAB> <TAB> <TAB> if len ( line_tokens ) == 2 : <TAB> <TAB> <TAB> <TAB> <TAB> token, pos = line_tokens <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> token, pos = data_line, None <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> token, pos = data_line. split ( ""\t"" ) <TAB> <TAB> <TAB> curr_token_list. append ( token ) <TAB> <TAB> <TAB> curr_pos_list. append ( pos ) <TAB> <TAB> else : <TAB> <TAB> <TAB> examples. append ( <TAB> <TAB> <TAB> <TAB> Example ( <TAB> <TAB> <TAB> <TAB> <TAB> guid = ""%s-%s"" % ( set_type, idx ), <TAB> <TAB> <TAB> <TAB> <TAB> tokens = curr_token_list, <TAB> <TAB> <TAB> <TAB> <TAB> pos_list = curr_pos_list, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> idx += 1 <TAB> <TAB> <TAB> curr_token_list, curr_pos_list = [ ], [ ] <TAB> if curr_token_list : <TAB> <TAB> examples",True,data_line,data_line,0.6569391489028931
|
||
|
779,"def post ( self, request, * args, ** kwargs ) : <TAB> contact_id = kwargs. get ( ""pk"" ) <TAB> self. object = get_object_or_404 ( Contact, id = contact_id ) <TAB> if ( <TAB> <TAB> self. request. user. role!= ""ADMIN"" <TAB> <TAB> and not self. request. user. is_superuser <TAB> <TAB> and self. request. user!= self. object. created_by <TAB> ) or self. object. company!= self. request. company : <TAB> <TAB> raise PermissionDenied <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. object. address. delete ( ) <TAB> <TAB> self. object. delete ( ) <TAB> <TAB> if self. request. is_ajax ( ) : <TAB> <TAB> <TAB> return JsonResponse ( { ""error"" : False } ) <TAB> <TAB> return redirect ( ""contacts:list"" )",False,self.object.address_id,self.object.address,0.651253879070282
|
||
|
780,"def _get_data_from_buffer ( obj ) : <TAB> try : <TAB> <TAB> view = memoryview ( obj ) <TAB> except TypeError : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> view = memoryview ( buffer ( obj ) ) <TAB> <TAB> <TAB> warnings. warn ( <TAB> <TAB> <TAB> <TAB> ""using old buffer interface to unpack %s; "" <TAB> <TAB> <TAB> <TAB> ""this leads to unpacking errors if slicing is used and "" <TAB> <TAB> <TAB> <TAB> ""will be removed in a future version"" % type ( obj ), <TAB> <TAB> <TAB> <TAB> RuntimeWarning, <TAB> <TAB> <TAB> <TAB> stacklevel = 3, <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise <TAB> if view. itemsize!= 1 : <TAB> <TAB> raise ValueError ( ""cannot unpack from multi-byte object"" ) <TAB> return view",False,PY2,view.itemsize == 0,0.7054789066314697
|
||
|
781,"def __repr__ ( self ) : <TAB> class_name = self. __class__. __name__ <TAB> configuration = { } <TAB> self. config. _populate_values ( ) <TAB> for hp_name in self. config : <TAB> <TAB> if self. config [ hp_name ] is not None : <TAB> <TAB> <TAB> configuration [ hp_name ] = self. config [ hp_name ] <TAB> configuration_string = """". join ( <TAB> <TAB> [ <TAB> <TAB> <TAB> ""configuration={\n "", <TAB> <TAB> <TAB> "",\n "". join ( <TAB> <TAB> <TAB> <TAB> [ <TAB> <TAB> <TAB> <TAB> <TAB> ""'%s': %s"" % ( hp_name, repr ( configuration [ hp_name ] ) ) <TAB> <TAB> <TAB> <TAB> <TAB> for hp_name in sorted ( configuration ) <TAB> <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> ""}"", <TAB> <TAB> ] <TAB> ) <TAB> if len ( self. dataset_properties ) > 0 : <TAB> <TAB> dataset_properties_string = [ ] <TAB> <TAB> dataset_properties_string. append ( ""dataset_properties={"" ) <TAB> <TAB> for i, item in enumerate ( self. dataset_properties. items ( ) ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> dataset_properties_string. append ( "",\n "" ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> dataset_properties_string. append ( ""\n "" ) <TAB> <TAB> <TAB> if isinstance ( item [ 1 ], str ) : <TAB> <TAB> <TAB> <TAB> dataset_properties_string. append ( ""'%s': '%s'"" % ( item [ 0 ], item [ 1 ] ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> dataset_properties_string. append ( ""'%s':",False,i != 0,i > 0,0.6818699836730957
|
||
|
782,"def unwrap ( self ) : <TAB> if not self. _sslobj : <TAB> <TAB> raise ValueError ( ""No SSL wrapper around "" + str ( self ) ) <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> shutdown = self. _sslobj. shutdown <TAB> except AttributeError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> shutdown = self. _sslobj. unwrap <TAB> s = self. _sock <TAB> while True : <TAB> <TAB> try : <TAB> <TAB> <TAB> s = shutdown ( ) <TAB> <TAB> <TAB> break <TAB> <TAB> except SSLWantReadError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise <TAB> <TAB> <TAB> self. _wait ( self. _read_event ) <TAB> <TAB> except SSLWantWriteError : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise <TAB> <TAB> <TAB> self. _wait ( self. _write_event ) <TAB> <TAB> except OSError as e : <TAB> <TAB> <TAB> if e. errno == 0 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> raise <TAB> self. _sslobj = None <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> assert s is self. _sock <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return self",False,self.timeout == 0.0,self._sock is None,0.660361647605896
|
||
|
783,"def render_text ( self, outfd, data ) : <TAB> self. table_header ( <TAB> <TAB> outfd, <TAB> <TAB> [ <TAB> <TAB> <TAB> ( ""Offset (V)"", ""[addrpad]"" ), <TAB> <TAB> <TAB> ( ""Filter Name"", ""50"" ), <TAB> <TAB> <TAB> ( ""Filter Member"", ""16"" ), <TAB> <TAB> <TAB> ( ""Socket (V)"", ""[addrpad]"" ), <TAB> <TAB> <TAB> ( ""Handler"", ""[addrpad]"" ), <TAB> <TAB> <TAB> ( ""Module"", ""30"" ), <TAB> <TAB> <TAB> ( ""Status"", """" ), <TAB> <TAB> ], <TAB> ) <TAB> for ( good, filter, filter_name, filter_socket, member, ptr, module ) in data : <TAB> <TAB> status = ""OK"" <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> status = ""UNKNOWN"" <TAB> <TAB> self. table_row ( <TAB> <TAB> <TAB> outfd, <TAB> <TAB> <TAB> filter. obj_offset, <TAB> <TAB> <TAB> filter_name, <TAB> <TAB> <TAB> member, <TAB> <TAB> <TAB> filter_socket, <TAB> <TAB> <TAB> ptr, <TAB> <TAB> <TAB> module, <TAB> <TAB> <TAB> status, <TAB> <TAB> )",False,good == 0,good,0.6830132603645325
|
||
|
784,"def _extract_prev_responses ( self, batch ) : <TAB> <TAB> warn_once ( ""WARNING: This code is specific to self-feeding formatted examples"" ) <TAB> <TAB> p1 = self. dict. txt2vec ( ""__p1__"" ) [ 0 ] <TAB> p2 = self. dict. txt2vec ( ""__p2__"" ) [ 0 ] <TAB> self. prev_responses = [ ] <TAB> <TAB> for text_vec in batch. text_vec : <TAB> <TAB> p1s = ( text_vec == p1 ). nonzero ( ) <TAB> <TAB> p2s = ( text_vec == p2 ). nonzero ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> response_vec = text_vec [ p2s [ - 1 ] + 1 : p1s [ - 1 ] ] <TAB> <TAB> else : <TAB> <TAB> <TAB> response_vec = [ self. NULL_IDX ] <TAB> <TAB> response = self. dict. vec2txt ( response_vec ) <TAB> <TAB> self. prev_responses. append ( response )",False,len(p1s) and len(p2s),p1s,0.6521165370941162
|
||
|
785,"def set_clock ( self, prompt ) : <TAB> """"""Set station clock to current time."""""" <TAB> ans = None <TAB> while ans not in [ ""y"", ""n"" ] : <TAB> <TAB> v = self. station. getTime ( ) <TAB> <TAB> vstr = weeutil. weeutil. timestamp_to_string ( v ) <TAB> <TAB> print ( ""Station clock is"", vstr ) <TAB> <TAB> if prompt : <TAB> <TAB> <TAB> ans = input ( ""Set station clock (y/n)? "" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> print ( ""Setting station clock"" ) <TAB> <TAB> <TAB> ans = ""y"" <TAB> <TAB> if ans == ""y"" : <TAB> <TAB> <TAB> self. station. setTime ( ) <TAB> <TAB> <TAB> v = self. station. getTime ( ) <TAB> <TAB> <TAB> vstr = weeutil. weeutil. timestamp_to_string ( v ) <TAB> <TAB> <TAB> print ( ""Station clock is now"", vstr ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> print ( ""Set clock cancelled."" )",False,ans == 'n',prompt,0.6654626131057739
|
||
|
786,"def draw_grayscale_heightmap ( world, target ) : <TAB> min_elev_sea = None <TAB> max_elev_sea = None <TAB> min_elev_land = None <TAB> max_elev_land = None <TAB> for y in range ( world. height ) : <TAB> <TAB> for x in range ( world. width ) : <TAB> <TAB> <TAB> e = world. elevation [ ""data"" ] [ y ] [ x ] <TAB> <TAB> <TAB> if world. is_land ( ( x, y ) ) : <TAB> <TAB> <TAB> <TAB> if min_elev_land is None or e < min_elev_land : <TAB> <TAB> <TAB> <TAB> <TAB> min_elev_land = e <TAB> <TAB> <TAB> <TAB> if max_elev_land is None or e > max_elev_land : <TAB> <TAB> <TAB> <TAB> <TAB> max_elev_land = e <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> if min_elev_sea is None or e < min_elev_sea : <TAB> <TAB> <TAB> <TAB> <TAB> min_elev_sea = e <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> max_elev_sea = e <TAB> elev_delta_land = max_elev_land - min_elev_land <TAB> elev_delta_sea = max_elev_sea - min_elev_sea <TAB> for y in range ( world. height ) : <TAB> <TAB> for x in range ( world. width ) : <TAB> <TAB> <TAB> e = world. elevation [ ""data"" ] [ y ] [ x ] <TAB> <TAB> <TAB> if world. is_land ( ( x, y ) ) : <TAB> <TAB> <TAB> <TAB> c = int ( ( ( e - min_elev_land ) * 127 ) / elev_delta",False,max_elev_sea is None or e > max_elev_sea,max_elev_sea is None or e < min_elev_sea,0.650437593460083
|
||
|
787,"def post ( self, request, format = None ) : <TAB> token_limit_per_user = self. get_token_limit_per_user ( ) <TAB> if token_limit_per_user is not None : <TAB> <TAB> now = timezone. now ( ) <TAB> <TAB> token = request. user. auth_token_set. filter ( expiry__gt = now ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return Response ( <TAB> <TAB> <TAB> <TAB> { ""error"" : ""Maximum amount of tokens allowed per user exceeded."" }, <TAB> <TAB> <TAB> <TAB> status = status. HTTP_403_FORBIDDEN, <TAB> <TAB> <TAB> ) <TAB> token_ttl = self. get_token_ttl ( ) <TAB> instance, token = AuthToken. objects. create ( request. user, token_ttl ) <TAB> user_logged_in. send ( <TAB> <TAB> sender = request. user. __class__, request = request, user = request. user <TAB> ) <TAB> data = self. get_post_response_data ( request, token, instance ) <TAB> return Response ( data )",False,token.count() >= token_limit_per_user,token_limit_per_user.valid(),0.6475284099578857
|
||
|
788,"def get_external_addresses ( self, label = None ) -> List [ str ] : <TAB> result = [ ] <TAB> for c in self. _conf [ ""pools"" ]. values ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if label == c [ ""label"" ] : <TAB> <TAB> <TAB> <TAB> result. append ( c [ ""external_address"" ] [ 0 ] ) <TAB> <TAB> else : <TAB> <TAB> <TAB> result. append ( c [ ""external_address"" ] [ 0 ] ) <TAB> return result",True,label is not None,label is not None,0.6610390543937683
|
||
|
789,"def _cast_attr ( value, default ) : <TAB> env. require ( lore. dependencies. DATEUTIL ) <TAB> import dateutil <TAB> if isinstance ( default, bool ) : <TAB> <TAB> return value. lower ( ) in [ ""1"", ""t"", ""true"" ] <TAB> elif isinstance ( default, int ) : <TAB> <TAB> return int ( value ) <TAB> elif isinstance ( default, float ) : <TAB> <TAB> return float ( value ) <TAB> elif isinstance ( default, datetime. date ) : <TAB> <TAB> return dateutil. parser. parse ( value ). date ( ) <TAB> elif isinstance ( default, datetime. datetime ) : <TAB> <TAB> return dateutil. parser. parse ( value ) <TAB> elif isinstance ( value, str ) and default is None : <TAB> <TAB> if value. lower ( ) in [ ""t"", ""true"" ] : <TAB> <TAB> <TAB> return True <TAB> <TAB> elif value. lower ( ) in [ ""f"", ""false"" ] : <TAB> <TAB> <TAB> return False <TAB> <TAB> elif value. lower ( ) in [ ""none"" ] : <TAB> <TAB> <TAB> return None <TAB> <TAB> try : <TAB> <TAB> <TAB> f = float ( value ) <TAB> <TAB> <TAB> i = int ( f ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return i <TAB> <TAB> <TAB> elif str ( f ) == value : <TAB> <TAB> <TAB> <TAB> return f <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> pass <TAB> <TAB> try : <TAB> <TAB> <TAB> return dateutil. parser. parse ( value ) <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> pass <TAB> return value",False,str(i) == value,i > default,0.6571345329284668
|
||
|
790,"def get_formatted_stats ( self ) : <TAB> """"""Get percentage or number of rar's done"""""" <TAB> if self. cur_setname and self. cur_setname in self. total_volumes : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return ""%02d/%02d"" % ( self. cur_volume, self. total_volumes [ self. cur_setname ] ) <TAB> return self. cur_volume",False,self.total_volumes[self.cur_setname] >= self.cur_volume and self.cur_volume,self.cur_volume and self.cur_setname in self.total_volumes[self.cur_setname],0.6495836973190308
|
||
|
791,"def __call__ ( self, environ, start_response ) : <TAB> """"""Dispatch the requests."""""" <TAB> <TAB> <TAB> <TAB> request = Request ( environ ) <TAB> response = self. debug_application <TAB> if request. args. get ( ""__debugger__"" ) == ""yes"" : <TAB> <TAB> cmd = request. args. get ( ""cmd"" ) <TAB> <TAB> arg = request. args. get ( ""f"" ) <TAB> <TAB> secret = request. args. get ( ""s"" ) <TAB> <TAB> traceback = self. tracebacks. get ( request. args. get ( ""tb"", type = int ) ) <TAB> <TAB> frame = self. frames. get ( request. args. get ( ""frm"", type = int ) ) <TAB> <TAB> if cmd == ""resource"" and arg : <TAB> <TAB> <TAB> response = self. get_resource ( request, arg ) <TAB> <TAB> elif cmd == ""paste"" and traceback is not None and secret == self. secret : <TAB> <TAB> <TAB> response = self. paste_traceback ( request, traceback ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> response = self. get_source ( request, frame ) <TAB> <TAB> elif ( <TAB> <TAB> <TAB> self. evalex <TAB> <TAB> <TAB> and cmd is not None <TAB> <TAB> <TAB> and frame is not None <TAB> <TAB> <TAB> and self. secret == secret <TAB> <TAB> ) : <TAB> <TAB> <TAB> response = self. execute_command ( request, cmd, frame ) <TAB> elif ( <TAB> <TAB> self. evalex <TAB> <TAB> and self. console_path is not None <TAB> <TAB> and request. path == self. console_path <TAB> ) : <TAB> <TAB> response = self. display_console ( request ) <TAB> return response ( environ, start_response )",False,cmd == 'source' and frame and (self.secret == secret),cmd == 'source',0.6521545648574829
|
||
|
792,"def get_tokens_unprocessed ( self, text ) : <TAB> bashlexer = BashLexer ( ** self. options ) <TAB> pos = 0 <TAB> curcode = """" <TAB> insertions = [ ] <TAB> for match in line_re. finditer ( text ) : <TAB> <TAB> line = match. group ( ) <TAB> <TAB> m = re. match ( r""^((?:\[?\S+@[^$#%]+\]?\s*)[$#%])(.*\n?)"", line ) <TAB> <TAB> if m : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> pos = match. start ( ) <TAB> <TAB> <TAB> insertions. append ( ( len ( curcode ), [ ( 0, Generic. Prompt, m. group ( 1 ) ) ] ) ) <TAB> <TAB> <TAB> curcode += m. group ( 2 ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if insertions : <TAB> <TAB> <TAB> <TAB> toks = bashlexer. get_tokens_unprocessed ( curcode ) <TAB> <TAB> <TAB> <TAB> for i, t, v in do_insertions ( insertions, toks ) : <TAB> <TAB> <TAB> <TAB> <TAB> yield pos + i, t, v <TAB> <TAB> <TAB> yield match. start ( ), Generic. Output, line <TAB> <TAB> <TAB> insertions = [ ] <TAB> <TAB> <TAB> curcode = """" <TAB> if insertions : <TAB> <TAB> for i, t, v in do_insertions ( <TAB> <TAB> <TAB> insertions, bashlexer. get_tokens_unprocessed ( curcode ) <TAB> <TAB> ) : <TAB> <TAB> <TAB> yield pos + i, t, v",False,not insertions,pos > 0,0.6784878969192505
|
||
|
793,"def parse_bzr_stats ( status ) : <TAB> stats = RepoStats ( ) <TAB> statustype = ""changed"" <TAB> for statusline in status : <TAB> <TAB> if statusline [ : 2 ] == "" "" : <TAB> <TAB> <TAB> setattr ( stats, statustype, getattr ( stats, statustype ) + 1 ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> statustype = ""staged"" <TAB> <TAB> elif statusline == ""unknown:"" : <TAB> <TAB> <TAB> statustype = ""new"" <TAB> <TAB> else : <TAB> <TAB> <TAB> statustype = ""changed"" <TAB> return stats",False,statusline == 'added:',statusline == 'staged:',0.6653767824172974
|
||
|
794,"def testFunctions ( self ) : <TAB> from zim. formats. wiki import match_url, is_url <TAB> for input, input_is_url, tail in self. examples : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if tail : <TAB> <TAB> <TAB> <TAB> self. assertEqual ( match_url ( input ), input [ : - len ( tail ) ] ) <TAB> <TAB> <TAB> <TAB> self. assertFalse ( is_url ( input ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. assertEqual ( match_url ( input ), input ) <TAB> <TAB> <TAB> <TAB> self. assertTrue ( is_url ( input ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. assertEqual ( match_url ( input ), None ) <TAB> <TAB> <TAB> self. assertFalse ( is_url ( input ) )",True,input_is_url,input_is_url,0.65309739112854
|
||
|
795,"def execute ( self, fullpath, fstat, test = False ) : <TAB> result = [ ] <TAB> for arg in self. fmt : <TAB> <TAB> if arg == ""path"" : <TAB> <TAB> <TAB> result. append ( fullpath ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> result. append ( os. path. basename ( fullpath ) ) <TAB> <TAB> elif arg == ""size"" : <TAB> <TAB> <TAB> result. append ( fstat [ stat. ST_SIZE ] ) <TAB> <TAB> elif arg == ""type"" : <TAB> <TAB> <TAB> result. append ( _FILE_TYPES. get ( stat. S_IFMT ( fstat [ stat. ST_MODE ] ), ""?"" ) ) <TAB> <TAB> elif arg == ""mode"" : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> result. append ( int ( oct ( fstat [ stat. ST_MODE ] ) [ - 3 : ], 8 ) ) <TAB> <TAB> elif arg == ""mtime"" : <TAB> <TAB> <TAB> result. append ( fstat [ stat. ST_MTIME ] ) <TAB> <TAB> elif arg == ""user"" : <TAB> <TAB> <TAB> uid = fstat [ stat. ST_UID ] <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> result. append ( pwd. getpwuid ( uid ). pw_name ) <TAB> <TAB> <TAB> except KeyError : <TAB> <TAB> <TAB> <TAB> result. append ( uid ) <TAB> <TAB> elif arg == ""group"" : <TAB> <TAB> <TAB> gid = fstat [ stat. ST_GID ] <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> result. append ( grp. getgrgid ( gid ). gr_name ) <TAB> <TAB> <TAB> except KeyError : <TAB> <TAB> <TAB> <TAB> result. append ( gid ) <TAB> <TAB> elif arg == ""md5"" : <TAB> <TAB> <TAB> if stat. S_",False,arg == 'name',arg == 'basename',0.6608589887619019
|
||
|
796,"def tagset ( bot, event, * args ) : <TAB> """"""set a single tag. usage: tagset <""conv""|""user""|""convuser""> <id> <tag>"""""" <TAB> if len ( args ) == 3 : <TAB> <TAB> [ type, id, tag ] = args <TAB> <TAB> type, id = _tagshortcuts ( event, type, id ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> message = _ ( <TAB> <TAB> <TAB> <TAB> ""tagged <b><pre>{}</pre></b> with <b><pre>{}</pre></b>"". format ( id, tag ) <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> message = _ ( ""<b><pre>{}</pre></b> unchanged"". format ( id ) ) <TAB> else : <TAB> <TAB> message = _ ( ""<b>supply type, id, tag</b>"" ) <TAB> yield from bot. coro_send_message ( event. conv_id, message )",False,"bot.tags.add(type, id, tag)",type == 'tag',0.6495245099067688
|
||
|
797,"def _convert_args ( <TAB> self, config : JobTemplateConfig, args : Dict [ str, Any ] ) -> JobTemplateRequest : <TAB> """"""convert arguments from argparse into a JobTemplateRequest"""""" <TAB> user_fields = { } <TAB> for field in config. user_fields : <TAB> <TAB> value = None <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> value = args [ field. name ] <TAB> <TAB> elif field. name in args [ ""parameters"" ] : <TAB> <TAB> <TAB> value = args [ ""parameters"" ] [ field. name ] <TAB> <TAB> elif field. required : <TAB> <TAB> <TAB> raise Exception ( ""missing field: %s"" % field. name ) <TAB> <TAB> if field. name == ""target_exe"" and isinstance ( value, str ) : <TAB> <TAB> <TAB> value = os. path. basename ( value ) <TAB> <TAB> if value is not None : <TAB> <TAB> <TAB> user_fields [ field. name ] = value <TAB> containers = self. _convert_container_args ( config, args ) <TAB> request = JobTemplateRequest ( <TAB> <TAB> name = config. name, user_fields = user_fields, containers = containers <TAB> ) <TAB> return request",True,field.name in args,field.name in args,0.66373610496521
|
||
|
798,"def test_updater ( self ) : <TAB> res, value = linkcheck. updater. check_update ( ) <TAB> self. assertTrue ( type ( res ) == bool ) <TAB> if res : <TAB> <TAB> self. assertTrue ( value is None or isinstance ( value, tuple ), repr ( value ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. assertEqual ( len ( value ), 2 ) <TAB> <TAB> <TAB> version, url = value <TAB> <TAB> <TAB> self. assertTrue ( isinstance ( version, basestring ), repr ( version ) ) <TAB> <TAB> <TAB> self. assertTrue ( url is None or isinstance ( url, basestring ), repr ( url ) ) <TAB> else : <TAB> <TAB> self. assertTrue ( isinstance ( value, unicode ), repr ( value ) )",True,"isinstance(value, tuple)","isinstance(value, tuple)",0.6493678092956543
|
||
|
799,"def _flush ( self ) : <TAB> if self. _data : <TAB> <TAB> if self. _last is not None : <TAB> <TAB> <TAB> text = """". join ( self. _data ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> assert self. _last. tail is None, ""internal error (tail)"" <TAB> <TAB> <TAB> <TAB> self. _last. tail = text <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> assert self. _last. text is None, ""internal error (text)"" <TAB> <TAB> <TAB> <TAB> self. _last. text = text <TAB> <TAB> self. _data = [ ]",True,self._tail,self._tail,0.6738963723182678
|
||
|
800,"def oauth_auth ( <TAB> self, token = None, oauth_verifier = None, signature_type = SIGNATURE_TYPE_AUTH_HEADER ) : <TAB> key, secret = self. get_key_and_secret ( ) <TAB> oauth_verifier = oauth_verifier or self. data. get ( ""oauth_verifier"" ) <TAB> if token : <TAB> <TAB> resource_owner_key = token. get ( ""oauth_token"" ) <TAB> <TAB> resource_owner_secret = token. get ( ""oauth_token_secret"" ) <TAB> <TAB> if not resource_owner_key : <TAB> <TAB> <TAB> raise AuthTokenError ( self, ""Missing oauth_token"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise AuthTokenError ( self, ""Missing oauth_token_secret"" ) <TAB> else : <TAB> <TAB> resource_owner_key = None <TAB> <TAB> resource_owner_secret = None <TAB> state = self. get_or_create_state ( ) <TAB> return OAuth1 ( <TAB> <TAB> key, <TAB> <TAB> secret, <TAB> <TAB> resource_owner_key = resource_owner_key, <TAB> <TAB> resource_owner_secret = resource_owner_secret, <TAB> <TAB> callback_uri = self. get_redirect_uri ( state ), <TAB> <TAB> verifier = oauth_verifier, <TAB> <TAB> signature_type = signature_type, <TAB> )",False,not resource_owner_secret,not secret,0.6539005041122437
|
||
|
801,"def get_conv_output_size ( input_size, kernel_size, stride, padding, dilation ) : <TAB> ndim = len ( input_size ) <TAB> output_size = [ ] <TAB> for i in range ( ndim ) : <TAB> <TAB> size = ( <TAB> <TAB> <TAB> input_size [ i ] + 2 * padding [ i ] - dilation [ i ] * ( kernel_size [ i ] - 1 ) - 1 <TAB> <TAB> ) // stride [ i ] + 1 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> output_size. append ( 1 ) <TAB> <TAB> else : <TAB> <TAB> <TAB> output_size. append ( size ) <TAB> return output_size",False,kernel_size[i] == -1,size == -1,0.6572177410125732
|
||
|
802,"def process_question ( qtxt ) : <TAB> question = """" <TAB> skip = False <TAB> for letter in qtxt : <TAB> <TAB> if letter == ""<"" : <TAB> <TAB> <TAB> skip = True <TAB> <TAB> if letter == "">"" : <TAB> <TAB> <TAB> skip = False <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> if letter. isalnum ( ) or letter == "" "" : <TAB> <TAB> <TAB> if letter == "" "" : <TAB> <TAB> <TAB> <TAB> letter = ""_"" <TAB> <TAB> <TAB> question += letter. lower ( ) <TAB> return question",True,skip,skip,0.6906230449676514
|
||
|
803,"def compute_out ( v, downsample, stride ) : <TAB> if ignore_border : <TAB> <TAB> if downsample == stride : <TAB> <TAB> <TAB> return v // stride <TAB> <TAB> else : <TAB> <TAB> <TAB> out = ( v - downsample ) // stride + 1 <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return tensor. maximum ( out, 0 ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> return np. maximum ( out, 0 ) <TAB> else : <TAB> <TAB> if isinstance ( v, theano. Variable ) : <TAB> <TAB> <TAB> return tensor. switch ( <TAB> <TAB> <TAB> <TAB> tensor. ge ( stride, downsample ), <TAB> <TAB> <TAB> <TAB> ( v - 1 ) // stride + 1, <TAB> <TAB> <TAB> <TAB> tensor. maximum ( 0, ( v - 1 - downsample ) // stride + 1 ) + 1, <TAB> <TAB> <TAB> ) <TAB> <TAB> elif stride >= downsample : <TAB> <TAB> <TAB> return ( v - 1 ) // stride + 1 <TAB> <TAB> else : <TAB> <TAB> <TAB> return max ( 0, ( v - 1 - downsample + stride ) // stride ) + 1",False,"isinstance(out, theano.Variable)",downsample == downsample,0.6468735933303833
|
||
|
804,"def gather_callback_args ( self, obj, callbacks ) : <TAB> session = sa. orm. object_session ( obj ) <TAB> for callback in callbacks : <TAB> <TAB> backref = callback. backref <TAB> <TAB> root_objs = getdotattr ( obj, backref ) if backref else obj <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if not isinstance ( root_objs, Iterable ) : <TAB> <TAB> <TAB> <TAB> root_objs = [ root_objs ] <TAB> <TAB> <TAB> with session. no_autoflush : <TAB> <TAB> <TAB> <TAB> for root_obj in root_objs : <TAB> <TAB> <TAB> <TAB> <TAB> if root_obj : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> args = self. get_callback_args ( root_obj, callback ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if args : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> yield args",False,root_objs,self.has_root_functions,0.6755106449127197
|
||
|
805,"def authenticate ( self, * args, ** kwargs ) : <TAB> authenticated = super ( ). authenticate ( * args, ** kwargs ) <TAB> if authenticated : <TAB> <TAB> allow_anonymous = self. auth_config. get ( <TAB> <TAB> <TAB> ""allow-anonymous"", True <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> authenticated = True <TAB> <TAB> <TAB> self. context. logger. debug ( ""Authentication success: config allows anonymous"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> session = kwargs. get ( ""session"", None ) <TAB> <TAB> <TAB> <TAB> authenticated = True if session. username else False <TAB> <TAB> <TAB> <TAB> if self. context. logger. isEnabledFor ( logging. DEBUG ) : <TAB> <TAB> <TAB> <TAB> <TAB> if authenticated : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. context. logger. debug ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""Authentication success: session has a non empty username"" <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. context. logger. debug ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""Authentication failure: session has an empty username"" <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> except KeyError : <TAB> <TAB> <TAB> <TAB> self. context. logger. warning ( ""Session informations not available"" ) <TAB> <TAB> <TAB> <TAB> authenticated = False <TAB> return authenticated",False,allow_anonymous,allow_anonymous is False,0.6651857495307922
|
||
|
806,"def _writeMockResultFile ( result ) : <TAB> """"""writes a test result as a gtest compatible test runner would do"""""" <TAB> with open ( result. filename, ""w"" ) as f : <TAB> <TAB> f. write ( '<?xml version=""1.0"" encoding=""UTF-8""?>\n' ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> f. write ( ""<testsuites>\n"" ) <TAB> <TAB> for suite in result. suites : <TAB> <TAB> <TAB> f. write ( <TAB> <TAB> <TAB> <TAB> '<testsuite tests=""' <TAB> <TAB> <TAB> <TAB> + str ( suite. tests ) <TAB> <TAB> <TAB> <TAB> + '"" failures=""' <TAB> <TAB> <TAB> <TAB> + str ( suite. fail ) <TAB> <TAB> <TAB> <TAB> + '"" time=""' <TAB> <TAB> <TAB> <TAB> + str ( suite. time ) <TAB> <TAB> <TAB> <TAB> + '"" errors=""' <TAB> <TAB> <TAB> <TAB> + str ( suite. errors ) <TAB> <TAB> <TAB> <TAB> + '"" name=""' <TAB> <TAB> <TAB> <TAB> + suite. name <TAB> <TAB> <TAB> <TAB> + '"">\n' <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> for case in suite. cases : <TAB> <TAB> <TAB> <TAB> f. write ( <TAB> <TAB> <TAB> <TAB> <TAB> '<testcase name=""' <TAB> <TAB> <TAB> <TAB> <TAB> + case. name <TAB> <TAB> <TAB> <TAB> <TAB> + '"" status=""run"" time=""' <TAB> <TAB> <TAB> <TAB> <TAB> + str ( case. time ) <TAB> <TAB> <TAB> <TAB> <TAB> + '"" classname=""' <TAB> <TAB> <TAB> <TAB> <TAB> + case. classname <TAB> <TAB> <TAB> <TAB> <TAB> + '"">\n' <TAB> <TAB>",False,len(result.suites) > 1 or result.noSuitesRoot is False,result.suites,0.6570720672607422
|
||
|
807,"def LeaseCronJobs ( self, cronjob_ids = None, lease_time = None ) : <TAB> """"""Leases all available cron jobs."""""" <TAB> leased_jobs = [ ] <TAB> now = rdfvalue. RDFDatetime. Now ( ) <TAB> expiration_time = now + lease_time <TAB> for job in self. cronjobs. values ( ) : <TAB> <TAB> if cronjob_ids and job. cron_job_id not in cronjob_ids : <TAB> <TAB> <TAB> continue <TAB> <TAB> existing_lease = self. cronjob_leases. get ( job. cron_job_id ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. cronjob_leases [ job. cron_job_id ] = ( <TAB> <TAB> <TAB> <TAB> expiration_time, <TAB> <TAB> <TAB> <TAB> utils. ProcessIdString ( ), <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> job = job. Copy ( ) <TAB> <TAB> <TAB> job. leased_until, job. leased_by = self. cronjob_leases [ job. cron_job_id ] <TAB> <TAB> <TAB> leased_jobs. append ( job ) <TAB> return leased_jobs",False,existing_lease is None or existing_lease[0] < now,existing_lease,0.6531012058258057
|
||
|
808,"def __get__ ( self, instance, instance_type = None ) : <TAB> if instance : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> rel_obj = self. get_obj ( instance ) <TAB> <TAB> <TAB> if rel_obj : <TAB> <TAB> <TAB> <TAB> instance. _obj_cache [ self. att_name ] = rel_obj <TAB> <TAB> return instance. _obj_cache. get ( self. att_name ) <TAB> return self",True,self.att_name not in instance._obj_cache,self.att_name not in instance._obj_cache,0.6591638922691345
|
||
|
809,"def _flatten_settings_from_form ( self, settings, form, form_values ) : <TAB> """"""Take a nested dict and return a flat dict of setting values."""""" <TAB> setting_values = { } <TAB> for field in form. c : <TAB> <TAB> if isinstance ( field, _ContainerMixin ) : <TAB> <TAB> <TAB> setting_values. update ( <TAB> <TAB> <TAB> <TAB> self. _flatten_settings_from_form ( <TAB> <TAB> <TAB> <TAB> <TAB> settings, field, form_values [ field. _name ] <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> setting_values [ field. _name ] = form_values [ field. _name ] <TAB> return setting_values",False,field._name in settings,"isinstance(field, field_BaseField)",0.6617257595062256
|
||
|
810,"def _file_path_changed ( self, fpath ) : <TAB> value = fpath. get ( ) <TAB> if len ( value ) == 0 : <TAB> <TAB> return <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> d_type = find_file_data_type ( fpath. get ( ) ) <TAB> <TAB> <TAB> self. reader = eval ( ""tvtk.XML%sReader()"" % d_type ) <TAB> <TAB> reader = self. reader <TAB> <TAB> reader. file_name = value <TAB> <TAB> reader. update ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> n = reader. number_of_outputs <TAB> <TAB> except AttributeError : <TAB> <TAB> <TAB> n = reader. number_of_output_ports <TAB> <TAB> outputs = [ ] <TAB> <TAB> for i in range ( n ) : <TAB> <TAB> <TAB> outputs. append ( reader. get_output ( i ) ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> aa = self. _assign_attribute <TAB> <TAB> aa. input = outputs [ 0 ] <TAB> <TAB> outputs [ 0 ] = aa. output <TAB> <TAB> self. update_data ( ) <TAB> <TAB> self. outputs = outputs <TAB> <TAB> <TAB> <TAB> self. output_info. datasets = [ get_tvtk_dataset_name ( outputs [ 0 ] ) ] <TAB> <TAB> <TAB> <TAB> self. name = self. _get_name ( )",False,self.reader is None,self.read_tab == False,0.6607459783554077
|
||
|
811,"def run_for ( self, args ) : <TAB> """"""Running commands from args namespace"""""" <TAB> logger. debug ( ""Call run_for on {}"". format ( self. name ) ) <TAB> if args. remove : <TAB> <TAB> if args. destdir : <TAB> <TAB> <TAB> message = ""You can't specify a destination dir while removing a framework"" <TAB> <TAB> <TAB> logger. error ( message ) <TAB> <TAB> <TAB> UI. return_main_screen ( status_code = 2 ) <TAB> <TAB> self. remove ( ) <TAB> else : <TAB> <TAB> install_path = None <TAB> <TAB> auto_accept_license = False <TAB> <TAB> if args. destdir : <TAB> <TAB> <TAB> install_path = os. path. abspath ( os. path. expanduser ( args. destdir ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> auto_accept_license = True <TAB> <TAB> self. setup ( install_path = install_path, auto_accept_license = auto_accept_license )",False,self.expect_license and args.accept_license,not install_path or install_path == '',0.6493919491767883
|
||
|
812,"def test_base ( expressions, sources ) : <TAB> base, x, sql, bc, mongo = sources <TAB> for expr, exclusions in expressions. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> model = into ( <TAB> <TAB> <TAB> <TAB> DataFrame, into ( np. ndarray, expr. _subs ( { t : data ( base, t. dshape ) } ) ) <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> model = compute ( expr. _subs ( { t : data ( base, t. dshape ) } ) ) <TAB> <TAB> print ( ""\nexpr: %s\n"" % expr ) <TAB> <TAB> for source in sources : <TAB> <TAB> <TAB> if source is None or id ( source ) in map ( id, exclusions ) : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> print ( ""%s <- %s"" % ( typename ( model ), typename ( source ) ) ) <TAB> <TAB> <TAB> T = data ( source ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> result = into ( type ( model ), expr. _subs ( { t : T } ) ) <TAB> <TAB> <TAB> <TAB> if isscalar ( expr. dshape. measure ) : <TAB> <TAB> <TAB> <TAB> <TAB> assert set ( into ( list, result ) ) == set ( into ( list, model ) ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> assert df_eq ( result, model ) <TAB> <TAB> <TAB> elif isrecord ( expr. dshape ) : <TAB> <TAB> <TAB> <TAB> result = compute ( expr. _subs ( { t : T } ) ) <TAB> <TAB> <TAB> <TAB> assert into ( tuple, result ) == into ( tuple, model ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> result = compute ( expr.",False,iscollection(expr.dshape),isrecord(expr.dshape),0.6528378129005432
|
||
|
813,"def load ( self, *, config_fd : TextIO = None ) -> None : <TAB> config = """" <TAB> if config_fd : <TAB> <TAB> config = config_fd. read ( ) <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> file_path = """" <TAB> <TAB> if os. path. exists ( LOCAL_CONFIG_FILENAME ) : <TAB> <TAB> <TAB> file_path = LOCAL_CONFIG_FILENAME <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> logger. warning ( <TAB> <TAB> <TAB> <TAB> ""Using local configuration ({!r}), changes will not be "" <TAB> <TAB> <TAB> <TAB> ""persisted."". format ( file_path ) <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> file_path = BaseDirectory. load_first_config ( ""snapcraft"", ""snapcraft.cfg"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> with open ( file_path, ""r"" ) as f : <TAB> <TAB> <TAB> <TAB> config = f. read ( ) <TAB> if config : <TAB> <TAB> _load_potentially_base64_config ( self. parser, config )",False,file_path and os.path.exists(file_path),file_path,0.6474583148956299
|
||
|
814,"def main ( ) : <TAB> args = parse_cmdline ( ) <TAB> if not os. path. exists ( args. input_file ) : <TAB> <TAB> print ( <TAB> <TAB> <TAB> f""Error: input file {args.input_file} inaccessible or does not exist, check path"" <TAB> <TAB> ) <TAB> <TAB> sys. exit ( 1 ) <TAB> with open_file_read ( args. input_file ) as fh : <TAB> <TAB> yaml_input = fh. read ( ) <TAB> if args. prepend_file : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> f""Error: prepend input file {args.prepend_file} inaccessible or does not exist, check path"" <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> sys. exit ( 1 ) <TAB> <TAB> with open_file_read ( args. prepend_file ) as fh : <TAB> <TAB> <TAB> prepend = fh. read ( ) <TAB> <TAB> <TAB> yaml_input = prepend + yaml_input <TAB> if not args. output_file : <TAB> <TAB> file_out = args. input_file <TAB> <TAB> pre, _ = os. path. splitext ( file_out ) <TAB> <TAB> file_out = pre <TAB> else : <TAB> <TAB> file_out = args. output_file <TAB> file_out = os. path. abspath ( file_out ) <TAB> parse ( yaml_input, file_out = file_out )",True,not os.path.exists(args.prepend_file),not os.path.exists(args.prepend_file),0.6468584537506104
|
||
|
815,"def GetPoseS_GTF ( cfg, dlc_cfg, sess, inputs, outputs, cap, nframes ) : <TAB> """"""Non batch wise pose estimation for video cap."""""" <TAB> if cfg [ ""cropping"" ] : <TAB> <TAB> ny, nx = checkcropping ( cfg, cap ) <TAB> pose_tensor = predict. extract_GPUprediction ( <TAB> <TAB> outputs, dlc_cfg <TAB> ) <TAB> PredictedData = np. zeros ( ( nframes, 3 * len ( dlc_cfg [ ""all_joints_names"" ] ) ) ) <TAB> pbar = tqdm ( total = nframes ) <TAB> counter = 0 <TAB> step = max ( 10, int ( nframes / 100 ) ) <TAB> while cap. isOpened ( ) : <TAB> <TAB> if counter % step == 0 : <TAB> <TAB> <TAB> pbar. update ( step ) <TAB> <TAB> ret, frame = cap. read ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> frame = cv2. cvtColor ( frame, cv2. COLOR_BGR2RGB ) <TAB> <TAB> <TAB> if cfg [ ""cropping"" ] : <TAB> <TAB> <TAB> <TAB> frame = img_as_ubyte ( <TAB> <TAB> <TAB> <TAB> <TAB> frame [ cfg [ ""y1"" ] : cfg [ ""y2"" ], cfg [ ""x1"" ] : cfg [ ""x2"" ] ] <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> frame = img_as_ubyte ( frame ) <TAB> <TAB> <TAB> pose = sess. run ( <TAB> <TAB> <TAB> <TAB> pose_tensor, <TAB> <TAB> <TAB> <TAB> feed_dict = { inputs : np. expand_dims ( frame, axis = 0 ). astype ( float ) }, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> pose [ :, [ 0, 1, 2 ] ] = pose [ :, [ 1",True,ret,ret,0.7049673795700073
|
||
|
816,"def _arg_with_type ( self ) : <TAB> for t in self. d [ ""Args"" ] : <TAB> <TAB> m = re. search ( ""([A-Za-z0-9_-]+)\s{0,4}(\(.+\))\s{0,4}:"", t ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. args [ m. group ( 1 ) ] = m. group ( 2 ) <TAB> return self. args",True,m,m,0.6985384821891785
|
||
|
817,"def recent_events ( self, events ) : <TAB> frame = events. get ( ""frame"" ) <TAB> if self. active and frame : <TAB> <TAB> recent_pupil_positions = events [ ""pupil_positions"" ] <TAB> <TAB> gray_img = frame. gray <TAB> <TAB> if self. clicks_to_close <= 0 : <TAB> <TAB> <TAB> self. stop ( ) <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> <TAB> self. markers = find_concetric_circles ( gray_img, min_ring_count = 4 ) <TAB> <TAB> if len ( self. markers ) > 0 : <TAB> <TAB> <TAB> self. detected = True <TAB> <TAB> <TAB> marker_pos = self. markers [ 0 ] [ 0 ] [ 0 ] <TAB> <TAB> <TAB> self. pos = normalize ( marker_pos, ( frame. width, frame. height ), flip_y = True ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. detected = False <TAB> <TAB> <TAB> self. pos = None <TAB> <TAB> <TAB> <TAB> on_position = self. lead_in < self. screen_marker_state <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> ref = { } <TAB> <TAB> <TAB> ref [ ""norm_pos"" ] = self. pos <TAB> <TAB> <TAB> ref [ ""screen_pos"" ] = marker_pos <TAB> <TAB> <TAB> ref [ ""timestamp"" ] = frame. timestamp <TAB> <TAB> <TAB> self. ref_list. append ( ref ) <TAB> <TAB> <TAB> <TAB> for p_pt in recent_pupil_positions : <TAB> <TAB> <TAB> if p_pt [ ""confidence"" ] > self. pupil_confidence_threshold : <TAB> <TAB> <TAB> <TAB> self. pupil_list. append ( p_pt ) <TAB> <TAB> <TAB> <TAB> if self. detected or not on_position : <TAB> <",False,on_position and self.detected,on_position,0.655582070350647
|
||
|
818,"def _config ( _molecule_file, request ) : <TAB> with open ( _molecule_file ) as f : <TAB> <TAB> d = util. safe_load ( f ) <TAB> if hasattr ( request, ""param"" ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> d2 = util. safe_load ( request. getfixturevalue ( request. param ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> d2 = request. getfixturevalue ( request. param ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> d = util. merge_dicts ( d, d2 ) <TAB> <TAB> <TAB> return d",False,"isinstance(request.getfixturevalue(request.param), str)",request.param_type == 'string',0.6551940441131592
|
||
|
819,"def __init__ ( <TAB> self, <TAB> name = None, <TAB> invoke_without_command = False, <TAB> no_args_is_help = None, <TAB> subcommand_metavar = None, <TAB> chain = False, <TAB> result_callback = None, <TAB> ** attrs ) : <TAB> Command. __init__ ( self, name, ** attrs ) <TAB> if no_args_is_help is None : <TAB> <TAB> no_args_is_help = not invoke_without_command <TAB> self. no_args_is_help = no_args_is_help <TAB> self. invoke_without_command = invoke_without_command <TAB> if subcommand_metavar is None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> subcommand_metavar = SUBCOMMANDS_METAVAR <TAB> <TAB> else : <TAB> <TAB> <TAB> subcommand_metavar = SUBCOMMAND_METAVAR <TAB> self. subcommand_metavar = subcommand_metavar <TAB> self. chain = chain <TAB> <TAB> <TAB> self. result_callback = result_callback <TAB> if self. chain : <TAB> <TAB> for param in self. params : <TAB> <TAB> <TAB> if isinstance ( param, Argument ) and not param. required : <TAB> <TAB> <TAB> <TAB> raise RuntimeError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Multi commands in chain mode cannot "" ""have optional arguments."" <TAB> <TAB> <TAB> <TAB> )",False,chain,subcommand_metavar is None,0.6929587125778198
|
||
|
820,"def _get_ilo_version ( self ) : <TAB> try : <TAB> <TAB> self. _get_ilo2 ( '<?xml version=""1.0""?><RIBCL VERSION=""2.0""></RIBCL>' ) <TAB> except ResponseError as e : <TAB> <TAB> if hasattr ( e, ""code"" ) : <TAB> <TAB> <TAB> if e. code == 405 : <TAB> <TAB> <TAB> <TAB> return 3 <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return 1 <TAB> <TAB> raise <TAB> return 2",False,e.code == 501,e.code == 504,0.6616497039794922
|
||
|
821,"def del_ ( self, key ) : <TAB> hash_ = self. hash ( key ) <TAB> node_ = self. _table [ hash_ ] <TAB> pre_node = None <TAB> while node_ is not None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if pre_node is None : <TAB> <TAB> <TAB> <TAB> self. _table [ hash_ ] = node_. next <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> pre_node. next = node_. next <TAB> <TAB> <TAB> self. _len -= 1 <TAB> <TAB> pre_node = node_ <TAB> <TAB> node_ = node_. next",False,node_.key == key,node_.hash() == hash_,0.6645716428756714
|
||
|
822,"def htmlentityreplace_errors ( exc ) : <TAB> if isinstance ( exc, ( UnicodeEncodeError, UnicodeTranslateError ) ) : <TAB> <TAB> res = [ ] <TAB> <TAB> codepoints = [ ] <TAB> <TAB> skip = False <TAB> <TAB> for i, c in enumerate ( exc. object [ exc. start : exc. end ] ) : <TAB> <TAB> <TAB> if skip : <TAB> <TAB> <TAB> <TAB> skip = False <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> index = i + exc. start <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> codepoint = utils. surrogatePairToCodepoint ( <TAB> <TAB> <TAB> <TAB> <TAB> exc. object [ index : index + 2 ] <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> skip = True <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> codepoint = ord ( c ) <TAB> <TAB> <TAB> codepoints. append ( codepoint ) <TAB> <TAB> for cp in codepoints : <TAB> <TAB> <TAB> e = encode_entity_map. get ( cp ) <TAB> <TAB> <TAB> if e : <TAB> <TAB> <TAB> <TAB> res. append ( ""&"" ) <TAB> <TAB> <TAB> <TAB> res. append ( e ) <TAB> <TAB> <TAB> <TAB> if not e. endswith ( "";"" ) : <TAB> <TAB> <TAB> <TAB> <TAB> res. append ( "";"" ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> res. append ( ""&#x%s;"" % ( hex ( cp ) [ 2 : ] ) ) <TAB> <TAB> return ( """". join ( res ), exc. end ) <TAB> else : <TAB> <TAB> return xmlcharrefreplace_errors ( exc )",False,"utils.isSurrogatePair(exc.object[index:min([exc.end, index + 2])])",index >= 0,0.6538420915603638
|
||
|
823,"def formatd ( x, code, precision, flags = 0 ) : <TAB> if flags & DTSF_ALT : <TAB> <TAB> alt = ""#"" <TAB> else : <TAB> <TAB> alt = """" <TAB> if code == ""r"" : <TAB> <TAB> fmt = ""%r"" <TAB> else : <TAB> <TAB> fmt = ""%%%s.%d%s"" % ( alt, precision, code ) <TAB> s = fmt % ( x, ) <TAB> if flags & DTSF_ADD_DOT_0 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> idx = len ( s ) <TAB> <TAB> for idx in range ( len ( s ), 0, - 1 ) : <TAB> <TAB> <TAB> c = s [ idx - 1 ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if c in ""eE"" : <TAB> <TAB> <TAB> <TAB> if s [ idx ] in ""+-"" : <TAB> <TAB> <TAB> <TAB> <TAB> idx += 1 <TAB> <TAB> <TAB> <TAB> s = s [ : idx ] + ""%02d"" % ( int ( s [ idx : ] ) ) <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> else : <TAB> <TAB> <TAB> if len ( s ) < precision : <TAB> <TAB> <TAB> <TAB> s += "".0"" <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> sign = ""+"" <TAB> <TAB> <TAB> <TAB> if x < 1 : <TAB> <TAB> <TAB> <TAB> <TAB> sign = ""-"" <TAB> <TAB> <TAB> <TAB> s = ""%s.%se%s%02d"" % ( s [ 0 ], s [ 1 : ], sign, len ( s ) - 1 ) <TAB> elif code == ""r"" and s. endswith ( "".0"" ) : <TAB",False,c in '.eE',c in 'eE',0.6567772030830383
|
||
|
824,"def _data_and_options ( leaves, defined_options ) : <TAB> data = [ ] <TAB> options = defined_options. copy ( ) <TAB> for leaf in leaves : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if len ( leaf. leaves )!= 2 : <TAB> <TAB> <TAB> <TAB> raise BoxConstructError <TAB> <TAB> <TAB> name, value = leaf. leaves <TAB> <TAB> <TAB> name_head = name. get_head_name ( ) <TAB> <TAB> <TAB> if name_head == ""System`Symbol"" : <TAB> <TAB> <TAB> <TAB> py_name = name. get_name ( ) <TAB> <TAB> <TAB> elif name_head == ""System`String"" : <TAB> <TAB> <TAB> <TAB> py_name = ""System`"" + name. get_string_value ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> raise BoxConstructError <TAB> <TAB> <TAB> options [ py_name ] = value <TAB> <TAB> else : <TAB> <TAB> <TAB> data. append ( leaf ) <TAB> return data, options",False,leaf.get_head_name() == 'System`Rule',"hasattr(leaf, 'leaves')",0.6552551984786987
|
||
|
825,"def verify ( self ) : <TAB> """"""Verify specific targets after build is complete."""""" <TAB> verify_history = self. _load_verify_history ( ) <TAB> header_inclusion_history = verify_history [ ""header_inclusion_dependencies"" ] <TAB> error = 0 <TAB> verify_details = { } <TAB> verify_suppress = config. get_item ( ""cc_config"", ""hdr_dep_missing_suppress"" ) <TAB> <TAB> for k in sorted ( self. __expanded_command_targets ) : <TAB> <TAB> target = self. __build_targets [ k ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> ok, details = target. verify_hdr_dep_missing ( <TAB> <TAB> <TAB> <TAB> header_inclusion_history, verify_suppress. get ( target. key, { } ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if not ok : <TAB> <TAB> <TAB> <TAB> error += 1 <TAB> <TAB> <TAB> if details : <TAB> <TAB> <TAB> <TAB> verify_details [ target. key ] = details <TAB> self. _dump_verify_details ( verify_details ) <TAB> self. _dump_verify_history ( ) <TAB> return error == 0",False,target.type.startswith('cc_') and target.srcs,target.verify_hdr_dep_missing,0.6518244743347168
|
||
|
826,"def validate_common_ids ( self ) -> None : <TAB> if ( <TAB> <TAB> not self. _extracted_metadata <TAB> <TAB> or not self. _extracted_metadata. common_id_list <TAB> <TAB> or ""apps"" not in self. _config_data <TAB> ) : <TAB> <TAB> return <TAB> common_id_list = self. _extracted_metadata. common_id_list <TAB> for app in self. _config_data [ ""apps"" ] : <TAB> <TAB> app_common_id = self. _config_data [ ""apps"" ] [ app ]. get ( ""common-id"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> logger. warning ( <TAB> <TAB> <TAB> <TAB> ""Common ID {common_id!r} specified in app {app!r} is "" <TAB> <TAB> <TAB> <TAB> ""not used in any metadata file."". format ( <TAB> <TAB> <TAB> <TAB> <TAB> common_id = app_common_id, app = app <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> )",False,app_common_id not in common_id_list,app_common_id and common_id_list and (common_id_list[common_id] not in self._config_data),0.6500170230865479
|
||
|
827,def test_erratic_draws ( ) : <TAB> n = [ 0 ] <TAB> with pytest. raises ( Flaky ) : <TAB> <TAB> @ run_to_buffer <TAB> <TAB> def x ( data ) : <TAB> <TAB> <TAB> data. draw_bytes ( n [ 0 ] ) <TAB> <TAB> <TAB> data. draw_bytes ( 255 - n [ 0 ] ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> data. mark_interesting ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> n [ 0 ] += 1,True,n[0] == 255,n[0] == 255,0.6632730960845947
|
||
|
828,"def __init__ ( <TAB> self, <TAB> element = None, <TAB> parentOffset = None, <TAB> parentEndTime = None, <TAB> parentage = None, <TAB> offset = None, <TAB> endTime = None, ) : <TAB> super ( ). __init__ ( offset = offset, endTime = endTime ) <TAB> self. element = element <TAB> if parentage is not None : <TAB> <TAB> parentage = tuple ( parentage ) <TAB> self. parentage = parentage <TAB> if parentOffset is not None : <TAB> <TAB> parentOffset = float ( parentOffset ) <TAB> self. parentOffset = parentOffset <TAB> if parentEndTime is not None : <TAB> <TAB> parentEndTime = float ( parentEndTime ) <TAB> self. parentEndTime = parentEndTime <TAB> if parentOffset is not None and parentEndTime is not None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise TimespanException ( <TAB> <TAB> <TAB> <TAB> f""offset {parentOffset!r} must be after parentEndTime {parentEndTime!r}"" <TAB> <TAB> <TAB> )",False,parentOffset > parentEndTime,parentOffset > self._max_time,0.6775654554367065
|
||
|
829,"def run ( self ) : <TAB> try : <TAB> <TAB> print ( <TAB> <TAB> <TAB> ""======== request ======== \n Url: %s \n Data: %s"" % ( self. url, self. data ) <TAB> <TAB> ) <TAB> <TAB> response = pool. urlopen ( <TAB> <TAB> <TAB> ""POST"", self. url, body = self. data, timeout = self. timeout <TAB> <TAB> ). data <TAB> <TAB> if not response : <TAB> <TAB> <TAB> print ( ""======== response ======== \n response is empty"" ) <TAB> <TAB> <TAB> self. callback ( None ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if response. startswith ( codecs. BOM_UTF8 ) : <TAB> <TAB> <TAB> <TAB> decodeddata = response. decode ( ""utf-8-sig"" ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> decodeddata = response. decode ( ""utf-8"" ) <TAB> <TAB> <TAB> print ( ""======== response ======== \n %s"" % decodeddata ) <TAB> <TAB> <TAB> self. callback ( json. loads ( decodeddata ) ) <TAB> <TAB> print ( ""======== end ========"" ) <TAB> except Exception as ex : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> print ( str ( ex ) ) <TAB> <TAB> <TAB> set_omnisharp_status ( ""Error talking to "" + self. url ) <TAB> <TAB> else : <TAB> <TAB> <TAB> set_omnisharp_status ( ""Server Not Running"" ) <TAB> <TAB> self. callback ( None )",False,'checkalivestatus' not in self.url,ex.__class__.__name__ == 'NoSuchConnection',0.6552556753158569
|
||
|
830,"def analyze ( vw ) : <TAB> <TAB> align = vw. arch. getPointerSize ( ) <TAB> rlen = vw. config. viv. analysis. pointertables. table_min_len <TAB> plist = [ ] <TAB> for va, pval in vw. findPointers ( ) : <TAB> <TAB> if len ( plist ) : <TAB> <TAB> <TAB> lastva, lastptr = plist [ - 1 ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if lastva!= va - align : <TAB> <TAB> <TAB> <TAB> nloc = vw. getLocation ( lastva + align ) <TAB> <TAB> <TAB> <TAB> while nloc is not None : <TAB> <TAB> <TAB> <TAB> <TAB> if nloc [ L_LTYPE ]!= LOC_POINTER : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> <TAB> lva = nloc [ L_VA ] <TAB> <TAB> <TAB> <TAB> <TAB> plist. append ( ( lva, vw. castPointer ( lva ) ) ) <TAB> <TAB> <TAB> <TAB> <TAB> nloc = vw. getLocation ( lva + nloc [ L_SIZE ] ) <TAB> <TAB> <TAB> if lastva!= va - align : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> handleArray ( vw, plist ) <TAB> <TAB> <TAB> <TAB> plist = [ ] <TAB> <TAB> plist. append ( ( va, pval ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> handleArray ( vw, plist )",False,len(plist) > rlen,rlen == 1,0.6712081432342529
|
||
|
831,"def root_item_selected ( self, item ) : <TAB> """"""Root item has been selected: expanding it and collapsing others"""""" <TAB> for index in range ( self. topLevelItemCount ( ) ) : <TAB> <TAB> root_item = self. topLevelItem ( index ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. expandItem ( root_item ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. collapseItem ( root_item )",False,root_item is item,"isinstance(root_item, basestring)",0.6588168144226074
|
||
|
832,"def __get_dynamic_attr ( self, attname, obj, default = None ) : <TAB> try : <TAB> <TAB> attr = getattr ( self, attname ) <TAB> except AttributeError : <TAB> <TAB> return default <TAB> if callable ( attr ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if hasattr ( attr, ""func_code"" ) : <TAB> <TAB> <TAB> argcount = attr. func_code. co_argcount <TAB> <TAB> else : <TAB> <TAB> <TAB> argcount = attr. __call__. func_code. co_argcount <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return attr ( obj ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return attr ( ) <TAB> return attr",False,argcount == 2,argcount == 0,0.6746383905410767
|
||
|
833,"def read ( self, size = - 1 ) : <TAB> buf = bytearray ( ) <TAB> while size!= 0 and self. cursor < self. maxpos : <TAB> <TAB> if not self. in_current_block ( self. cursor ) : <TAB> <TAB> <TAB> self. seek_to_block ( self. cursor ) <TAB> <TAB> part = self. current_stream. read ( size ) <TAB> <TAB> if size > 0 : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise EOFError ( ) <TAB> <TAB> <TAB> size -= len ( part ) <TAB> <TAB> self. cursor += len ( part ) <TAB> <TAB> buf += part <TAB> return bytes ( buf )",False,len(part) == 0,not part,0.6572363376617432
|
||
|
834,"def Run ( self, cmd_val ) : <TAB> <TAB> attrs, arg_r = flag_spec. ParseCmdVal ( ""mapfile"", cmd_val ) <TAB> arg = arg_types. mapfile ( attrs. attrs ) <TAB> var_name, _ = arg_r. Peek2 ( ) <TAB> if var_name is None : <TAB> <TAB> var_name = ""MAPFILE"" <TAB> else : <TAB> <TAB> if var_name. startswith ( "":"" ) : <TAB> <TAB> <TAB> var_name = var_name [ 1 : ] <TAB> lines = [ ] <TAB> while True : <TAB> <TAB> line = _ReadLine ( ) <TAB> <TAB> if len ( line ) == 0 : <TAB> <TAB> <TAB> break <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> line = line [ : - 1 ] <TAB> <TAB> lines. append ( line ) <TAB> state. SetRefArray ( self. mem, var_name, lines ) <TAB> return 0",False,arg.t and line.endswith('\n'),line.endswith('\n'),0.6455460786819458
|
||
|
835,"def create_bundle ( request ) : <TAB> bundle = Bundle ( owner = request. user, schema_version = ""uri:oozie:bundle:0.2"" ) <TAB> if request. method == ""POST"" : <TAB> <TAB> bundle_form = BundleForm ( request. POST, instance = bundle ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> bundle = bundle_form. save ( ) <TAB> <TAB> <TAB> Document. objects. link ( <TAB> <TAB> <TAB> <TAB> bundle, <TAB> <TAB> <TAB> <TAB> owner = bundle. owner, <TAB> <TAB> <TAB> <TAB> name = bundle. name, <TAB> <TAB> <TAB> <TAB> description = bundle. description, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> return redirect ( reverse ( ""oozie:edit_bundle"", kwargs = { ""bundle"" : bundle. id } ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> request. error ( _ ( ""Errors on the form: %s"" ) % bundle_form. errors ) <TAB> else : <TAB> <TAB> bundle_form = BundleForm ( instance = bundle ) <TAB> return render ( <TAB> <TAB> ""editor/create_bundle.mako"", <TAB> <TAB> request, <TAB> <TAB> { <TAB> <TAB> <TAB> ""bundle"" : bundle, <TAB> <TAB> <TAB> ""bundle_form"" : bundle_form, <TAB> <TAB> }, <TAB> )",True,bundle_form.is_valid(),bundle_form.is_valid(),0.6521379947662354
|
||
|
836,"def suite ( module_prefix = """", timing_check = None ) : <TAB> test_modules = [ <TAB> <TAB> ""test_associate"", <TAB> <TAB> ""test_basics"", <TAB> <TAB> ""test_dbenv"", <TAB> <TAB> ""test_db"", <TAB> <TAB> ""test_compare"", <TAB> <TAB> ""test_compat"", <TAB> <TAB> ""test_cursor_pget_bug"", <TAB> <TAB> ""test_dbobj"", <TAB> <TAB> ""test_dbshelve"", <TAB> <TAB> ""test_dbtables"", <TAB> <TAB> ""test_distributed_transactions"", <TAB> <TAB> ""test_early_close"", <TAB> <TAB> ""test_fileid"", <TAB> <TAB> ""test_get_none"", <TAB> <TAB> ""test_join"", <TAB> <TAB> ""test_lock"", <TAB> <TAB> ""test_misc"", <TAB> <TAB> ""test_pickle"", <TAB> <TAB> ""test_queue"", <TAB> <TAB> ""test_recno"", <TAB> <TAB> ""test_replication"", <TAB> <TAB> ""test_sequence"", <TAB> <TAB> ""test_thread"", <TAB> ] <TAB> alltests = unittest. TestSuite ( ) <TAB> for name in test_modules : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> module = __import__ ( module_prefix + name, globals ( ), locals ( ), name ) <TAB> <TAB> alltests. addTest ( module. test_suite ( ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> alltests. addTest ( unittest. makeSuite ( timing_check ) ) <TAB> return alltests",False,timing_check,timing_check is not None,0.6534469127655029
|
||
|
837,"def _execute_with_error ( command, error, message ) : <TAB> try : <TAB> <TAB> cli. invocation = cli. invocation_cls ( <TAB> <TAB> <TAB> cli_ctx = cli, <TAB> <TAB> <TAB> parser_cls = cli. parser_cls, <TAB> <TAB> <TAB> commands_loader_cls = cli. commands_loader_cls, <TAB> <TAB> <TAB> help_cls = cli. help_cls, <TAB> <TAB> ) <TAB> <TAB> cli. invocation. execute ( command. split ( ) ) <TAB> except CLIError as ex : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise AssertionError ( <TAB> <TAB> <TAB> <TAB> ""{}\nExpected: {}\nActual: {}"". format ( message, error, ex ) <TAB> <TAB> <TAB> ) <TAB> <TAB> return <TAB> except Exception as ex : <TAB> <TAB> raise ex <TAB> raise AssertionError ( ""exception not raised for '{0}'"". format ( message ) )",False,error not in str(ex),error is None or ex.args[0] or error < ex.args[1],0.6559051275253296
|
||
|
838,"def say ( self, phrase ) : <TAB> self. _logger. debug ( ""Saying '%s' with '%s'"", phrase, self. SLUG ) <TAB> with tempfile. NamedTemporaryFile ( suffix = "".wav"", delete = False ) as f : <TAB> <TAB> fname = f. name <TAB> cmd = [ ""pico2wave"", ""--wave"", fname ] <TAB> if self. language not in self. languages : <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> ""Language '%s' not supported by '%s'"", self. language, self. SLUG <TAB> <TAB> ) <TAB> cmd. extend ( [ ""-l"", self. language ] ) <TAB> cmd. append ( phrase ) <TAB> self. _logger. debug ( ""Executing %s"", "" "". join ( [ pipes. quote ( arg ) for arg in cmd ] ) ) <TAB> with tempfile. TemporaryFile ( ) as f : <TAB> <TAB> subprocess. call ( cmd, stdout = f, stderr = f ) <TAB> <TAB> f. seek ( 0 ) <TAB> <TAB> output = f. read ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _logger. debug ( ""Output was: '%s'"", output ) <TAB> self. play ( fname ) <TAB> os. remove ( fname )",False,output,output != '',0.6841362118721008
|
||
|
839,"def get_connection ( self, url, proxies = None ) : <TAB> with self. pools. lock : <TAB> <TAB> pool = self. pools. get ( url ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return pool <TAB> <TAB> pool = NpipeHTTPConnectionPool ( <TAB> <TAB> <TAB> self. npipe_path, self. timeout, maxsize = self. max_pool_size <TAB> <TAB> ) <TAB> <TAB> self. pools [ url ] = pool <TAB> return pool",False,pool,pool and proxies or pool[url],0.6944013833999634
|
||
|
840,"def get_user_from_api_key ( api_key, query_id ) : <TAB> if not api_key : <TAB> <TAB> return None <TAB> user = None <TAB> <TAB> org = current_org. _get_current_object ( ) <TAB> try : <TAB> <TAB> user = models. User. get_by_api_key_and_org ( api_key, org ) <TAB> <TAB> if user. is_disabled : <TAB> <TAB> <TAB> user = None <TAB> except models. NoResultFound : <TAB> <TAB> try : <TAB> <TAB> <TAB> api_key = models. ApiKey. get_by_api_key ( api_key ) <TAB> <TAB> <TAB> user = models. ApiUser ( api_key, api_key. org, [ ] ) <TAB> <TAB> except models. NoResultFound : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> query = models. Query. get_by_id_and_org ( query_id, org ) <TAB> <TAB> <TAB> <TAB> if query and query. api_key == api_key : <TAB> <TAB> <TAB> <TAB> <TAB> user = models. ApiUser ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> api_key, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> query. org, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> list ( query. groups. keys ( ) ), <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> name = ""ApiKey: Query {}"". format ( query. id ), <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> return user",True,query_id,query_id,0.6675068736076355
|
||
|
841,"def describe_return_bits ( self, data, names ) : <TAB> i = 0x01 << len ( names ) - 1 <TAB> bit = 0 <TAB> while i!= 0 : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. putx ( 3 if ( data & i ) else 4, 1, names [ bit ] ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. advance_ann ( 3, 1 ) <TAB> <TAB> i >>= 1 <TAB> <TAB> bit += 1",False,names[bit] != '',names[bit] & 1,0.6616164445877075
|
||
|
842,"def create ( self, path, wipe = False ) : <TAB> <TAB> _path = self. validatepath ( path ) <TAB> with ftp_errors ( self, path ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> empty_file = io. BytesIO ( ) <TAB> <TAB> <TAB> self. ftp. storbinary ( <TAB> <TAB> <TAB> <TAB> str ( ""STOR "" ) + _encode ( _path, self. ftp. encoding ), empty_file <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> return True <TAB> return False",False,wipe or not self.isfile(path),wipe,0.6491141319274902
|
||
|
843,"def computeData ( self ) : <TAB> self. nameList = [ ] <TAB> self. names = { } <TAB> self. tnodes = { } <TAB> for p in self. c. all_unique_positions ( ) : <TAB> <TAB> h = p. h. strip ( ) <TAB> <TAB> v = p. v <TAB> <TAB> nameList = self. names. get ( h, [ ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if p. parent ( ) : <TAB> <TAB> <TAB> <TAB> key = ""%s, parent: %s"" % ( h, p. parent ( ). h ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> key = ""%s, child index: %d"" % ( h, p. childIndex ( ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> key = h <TAB> <TAB> self. nameList. append ( key ) <TAB> <TAB> self. tnodes [ key ] = v <TAB> <TAB> nameList. append ( key ) <TAB> <TAB> self. names [ h ] = nameList",False,nameList,len(nameList) > 0,0.6689449548721313
|
||
|
844,"def remote_change_labels ( <TAB> crispin_client, account_id, message_ids, removed_labels, added_labels ) : <TAB> uids_for_message = { } <TAB> with session_scope ( account_id ) as db_session : <TAB> <TAB> for message_id in message_ids : <TAB> <TAB> <TAB> folder_uids_map = uids_by_folder ( message_id, db_session ) <TAB> <TAB> <TAB> for folder_name, uids in folder_uids_map. items ( ) : <TAB> <TAB> <TAB> <TAB> if folder_name not in uids_for_message : <TAB> <TAB> <TAB> <TAB> <TAB> uids_for_message [ folder_name ] = [ ] <TAB> <TAB> <TAB> <TAB> uids_for_message [ folder_name ]. extend ( uids ) <TAB> for folder_name, uids in uids_for_message. items ( ) : <TAB> <TAB> crispin_client. select_folder_if_necessary ( folder_name, uidvalidity_cb ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> crispin_client. conn. add_gmail_labels ( <TAB> <TAB> <TAB> <TAB> uids, _encode_labels ( added_labels ), silent = True <TAB> <TAB> <TAB> ) <TAB> <TAB> if len ( removed_labels ) > 0 : <TAB> <TAB> <TAB> crispin_client. conn. remove_gmail_labels ( <TAB> <TAB> <TAB> <TAB> uids, _encode_labels ( removed_labels ), silent = True <TAB> <TAB> <TAB> )",True,len(added_labels) > 0,len(added_labels) > 0,0.6525024175643921
|
||
|
845,"def _sanitize_outputs ( component_cls, outputs ) : <TAB> if outputs is None : <TAB> <TAB> outputs = component_cls. outputs <TAB> if outputs is None : <TAB> <TAB> outputs = [ ] <TAB> if isinstance ( outputs, ( list, tuple ) ) : <TAB> <TAB> streams = { } <TAB> <TAB> for output in outputs : <TAB> <TAB> <TAB> if isinstance ( output, Stream ) : <TAB> <TAB> <TAB> <TAB> streams [ output. name ] = StreamInfo ( <TAB> <TAB> <TAB> <TAB> <TAB> output_fields = output. fields, direct = output. direct <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> default = streams. setdefault ( <TAB> <TAB> <TAB> <TAB> <TAB> ""default"", StreamInfo ( output_fields = [ ], direct = False ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> default. output_fields. append ( output ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> raise TypeError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Outputs must either be a list of strings "" <TAB> <TAB> <TAB> <TAB> <TAB> ""or a list of Streams. Invalid entry: {!r}"". format ( output ) <TAB> <TAB> <TAB> <TAB> ) <TAB> else : <TAB> <TAB> raise TypeError ( <TAB> <TAB> <TAB> ""Outputs must either be a list of strings or a list"" <TAB> <TAB> <TAB> "" of Streams. Given: {!r}"". format ( outputs ) <TAB> <TAB> ) <TAB> return streams",False,"isinstance(output, str)","isinstance(output, Stream)",0.6495030522346497
|
||
|
846,"def saveFileMain ( self, dlg ) : <TAB> if ( not self. fileNames [ self. ind ] ) or dlg : <TAB> <TAB> markupClass = self. getMarkupClass ( ) <TAB> <TAB> if ( markupClass is None ) or not hasattr ( markupClass, ""default_extension"" ) : <TAB> <TAB> <TAB> defaultExt = self. tr ( ""Plain text (*.txt)"" ) <TAB> <TAB> <TAB> ext = "".txt"" <TAB> <TAB> else : <TAB> <TAB> <TAB> defaultExt = ( <TAB> <TAB> <TAB> <TAB> self. tr ( ""%s files"", ""Example of final string: Markdown files"" ) <TAB> <TAB> <TAB> <TAB> % markupClass. name <TAB> <TAB> <TAB> <TAB> + "" ("" <TAB> <TAB> <TAB> <TAB> + str. join ( <TAB> <TAB> <TAB> <TAB> <TAB> "" "", ( ""*"" + extension for extension in markupClass. file_extensions ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> + "")"" <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ext = markupClass. default_extension <TAB> <TAB> newFileName = getSaveFileName ( self, self. tr ( ""Save file"" ), """", defaultExt ) <TAB> <TAB> if newFileName : <TAB> <TAB> <TAB> if not QFileInfo ( newFileName ). suffix ( ) : <TAB> <TAB> <TAB> <TAB> newFileName += ext <TAB> <TAB> <TAB> self. fileNames [ self. ind ] = newFileName <TAB> <TAB> <TAB> self. actionSetEncoding. setDisabled ( self. autoSaveActive ( ) ) <TAB> if self. fileNames [ self. ind ] : <TAB> <TAB> result = self. saveFileCore ( self. fileNames [ self. ind ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. setCurrentFile ( ) <TAB> <TAB> <TAB> self. editBoxes [ self. ind ]. document ( ). setModified ( False ) <TAB>",True,result,result,0.6872763633728027
|
||
|
847,"def mat_mul ( job_id, idx, data_list ) : <TAB> _, all_parties = session_init ( job_id, idx ) <TAB> with SPDZ ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> x = FixedPointTensor. from_source ( ""x"", data_list [ 0 ] ) <TAB> <TAB> <TAB> y = FixedPointTensor. from_source ( ""y"", all_parties [ 1 ] ) <TAB> <TAB> else : <TAB> <TAB> <TAB> x = FixedPointTensor. from_source ( ""x"", all_parties [ 0 ] ) <TAB> <TAB> <TAB> y = FixedPointTensor. from_source ( ""y"", data_list [ 1 ] ) <TAB> <TAB> return ( x @ y ). get ( )",False,idx == 0,len(all_parties) == 2,0.6795542240142822
|
||
|
848,"def loop_accept_pipe ( f = None ) : <TAB> pipe = None <TAB> try : <TAB> <TAB> if f : <TAB> <TAB> <TAB> pipe = f. result ( ) <TAB> <TAB> <TAB> server. _free_instances. discard ( pipe ) <TAB> <TAB> <TAB> if server. closed ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> pipe. close ( ) <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> protocol = protocol_factory ( ) <TAB> <TAB> <TAB> self. _make_duplex_pipe_transport ( pipe, protocol, extra = { ""addr"" : address } ) <TAB> <TAB> pipe = server. _get_unconnected_pipe ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return <TAB> <TAB> f = self. _proactor. accept_pipe ( pipe ) <TAB> except OSError as exc : <TAB> <TAB> if pipe and pipe. fileno ( )!= - 1 : <TAB> <TAB> <TAB> self. call_exception_handler ( <TAB> <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> <TAB> ""message"" : ""Pipe accept failed"", <TAB> <TAB> <TAB> <TAB> <TAB> ""exception"" : exc, <TAB> <TAB> <TAB> <TAB> <TAB> ""pipe"" : pipe, <TAB> <TAB> <TAB> <TAB> } <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> pipe. close ( ) <TAB> <TAB> elif self. _debug : <TAB> <TAB> <TAB> logger. warning ( ""Accept pipe failed on pipe %r"", pipe, exc_info = True ) <TAB> except exceptions. CancelledError : <TAB> <TAB> if pipe : <TAB> <TAB> <TAB> pipe. close ( ) <TAB> else : <TAB> <TAB> server. _accept_pipe_future = f <TAB>",False,pipe is None,self._proactor is not None,0.6645748615264893
|
||
|
849,"def check_program ( self, program ) : <TAB> quantized_ops = { } <TAB> persistable_vars = [ <TAB> <TAB> v. name for v in filter ( lambda var : var. persistable, program. list_vars ( ) ) <TAB> ] <TAB> for block in program. blocks : <TAB> <TAB> for idx, op in enumerate ( block. ops ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if op. type in self. quantizable_op_and_inputs : <TAB> <TAB> <TAB> <TAB> for i, arg_name in enumerate ( op. input_arg_names ) : <TAB> <TAB> <TAB> <TAB> <TAB> quant_op_type = ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. weight_quant_op_type <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> else self. act_quant_op_type <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> self. assertTrue ( arg_name. endswith ( "".quantized.dequantized"" ) ) <TAB> <TAB> <TAB> <TAB> <TAB> if arg_name not in quantized_ops : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. assertEqual ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> block. ops [ idx - 2 * i - 1 ]. type, self. dequant_op_type <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. assertEqual ( block. ops [ idx - 2 * i - 2 ]. type, quant_op_type ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> quantized_ops [ arg_name ] = block. ops [ idx - 2 * i - 2 ] <TAB> <TAB> <TAB>",False,_original_var_name(arg_name) in persistable_vars,quant_op_type is None,0.6491057872772217
|
||
|
850,"def process ( self ) : <TAB> if not any ( socket. is_linked for socket in self. outputs ) : <TAB> <TAB> return <TAB> vertices_s = self. inputs [ ""Vertices"" ]. sv_get ( ) <TAB> vertices_s = ensure_nesting_level ( vertices_s, 3 ) <TAB> epsilon_s = self. inputs [ ""Epsilon"" ]. sv_get ( ) <TAB> smooth_s = self. inputs [ ""Smooth"" ]. sv_get ( ) <TAB> curves_out = [ ] <TAB> for vertices, epsilon, smooth in zip_long_repeat ( vertices_s, epsilon_s, smooth_s ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> epsilon = epsilon [ 0 ] <TAB> <TAB> if isinstance ( smooth, ( list, int ) ) : <TAB> <TAB> <TAB> smooth = smooth [ 0 ] <TAB> <TAB> vertices = np. array ( vertices ) <TAB> <TAB> ts = make_euclidian_ts ( vertices ) <TAB> <TAB> rbf = Rbf ( <TAB> <TAB> <TAB> ts, <TAB> <TAB> <TAB> vertices, <TAB> <TAB> <TAB> function = self. function, <TAB> <TAB> <TAB> smooth = smooth, <TAB> <TAB> <TAB> epsilon = epsilon, <TAB> <TAB> <TAB> mode = ""N-D"", <TAB> <TAB> ) <TAB> <TAB> curve = SvRbfCurve ( rbf, ( 0.0, 1.0 ) ) <TAB> <TAB> curves_out. append ( curve ) <TAB> self. outputs [ ""Curve"" ]. sv_set ( curves_out )",True,"isinstance(epsilon, (list, int))","isinstance(epsilon, (list, int))",0.6550108194351196
|
||
|
851,"def get_ast_subexprs ( claripy_ast ) : <TAB> queue = [ claripy_ast ] <TAB> while queue : <TAB> <TAB> ast = queue. pop ( 0 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> queue += ast. args [ 1 : ] <TAB> <TAB> <TAB> yield ast. args [ 0 ] <TAB> <TAB> elif ast. op == ""Or"" : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> common = None <TAB> <TAB> <TAB> for arg in ast. args : <TAB> <TAB> <TAB> <TAB> subexprs = get_ast_subexprs ( arg ) <TAB> <TAB> <TAB> <TAB> if common is None : <TAB> <TAB> <TAB> <TAB> <TAB> common = set ( subexprs ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> common = common. intersection ( subexprs ) <TAB> <TAB> <TAB> <TAB> if len ( common ) == 0 : <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> for expr in common : <TAB> <TAB> <TAB> <TAB> yield expr <TAB> <TAB> else : <TAB> <TAB> <TAB> yield ast",True,ast.op == 'And',ast.op == 'And',0.6530584096908569
|
||
|
852,"def net_arch ( input, drop_prob, drop_path_mask, is_train, num_classes ) : <TAB> c_in = 36 <TAB> stem_multiplier = 3 <TAB> c_curr = stem_multiplier * c_in <TAB> x = self. _conv_bn ( <TAB> <TAB> input, c_curr, kernel_size = 3, padding = 1, stride = 1, name = ""cifar10_darts_conv0"" <TAB> ) <TAB> s0 = s1 = x <TAB> logits_aux = None <TAB> reduction_prev = False <TAB> for i, layer_setting in enumerate ( self. bottleneck_params_list ) : <TAB> <TAB> filter_num, stride = layer_setting [ 0 ], layer_setting [ 1 ] <TAB> <TAB> if stride == 2 : <TAB> <TAB> <TAB> reduction = True <TAB> <TAB> else : <TAB> <TAB> <TAB> reduction = False <TAB> <TAB> if is_train : <TAB> <TAB> <TAB> drop_path_cell = drop_path_mask [ :, i, :, : ] <TAB> <TAB> else : <TAB> <TAB> <TAB> drop_path_cell = drop_path_mask <TAB> <TAB> s0, s1 = s1, self. _cell ( <TAB> <TAB> <TAB> s0, <TAB> <TAB> <TAB> s1, <TAB> <TAB> <TAB> filter_num, <TAB> <TAB> <TAB> stride, <TAB> <TAB> <TAB> reduction_prev, <TAB> <TAB> <TAB> drop_prob, <TAB> <TAB> <TAB> drop_path_cell, <TAB> <TAB> <TAB> is_train, <TAB> <TAB> <TAB> name = ""cifar10_darts_layer{}"". format ( i + 1 ), <TAB> <TAB> ) <TAB> <TAB> reduction_prev = reduction <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if is_train : <TAB> <TAB> <TAB> <TAB> logits_aux = self. _auxiliary",False,i == 2 * 20 // 3,logits_aux is None,0.6636972427368164
|
||
|
853,"def has_bad_headers ( self ) : <TAB> headers = [ self. sender, self. reply_to ] + self. recipients <TAB> for header in headers : <TAB> <TAB> if _has_newline ( header ) : <TAB> <TAB> <TAB> return True <TAB> if self. subject : <TAB> <TAB> if _has_newline ( self. subject ) : <TAB> <TAB> <TAB> for linenum, line in enumerate ( self. subject. split ( ""\r\n"" ) ) : <TAB> <TAB> <TAB> <TAB> if not line : <TAB> <TAB> <TAB> <TAB> <TAB> return True <TAB> <TAB> <TAB> <TAB> if linenum > 0 and line [ 0 ] not in ""\t "" : <TAB> <TAB> <TAB> <TAB> <TAB> return True <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> return True <TAB> <TAB> <TAB> <TAB> if len ( line. strip ( ) ) == 0 : <TAB> <TAB> <TAB> <TAB> <TAB> return True <TAB> return False",False,_has_newline(line),linenum > 0 and line[0] not in '\t ',0.6545993089675903
|
||
|
854,"def _get_external_data ( url ) : <TAB> result = { } <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> resp = urlopen ( url ) <TAB> <TAB> headers = resp. info ( ) <TAB> <TAB> ct = headers. get ( ""Content-Type"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> logger. debug ( ""Unexpected response for JSON request: %s"", ct ) <TAB> <TAB> else : <TAB> <TAB> <TAB> reader = codecs. getreader ( ""utf-8"" ) ( resp ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> result = json. load ( reader ) <TAB> except Exception as e : <TAB> <TAB> logger. exception ( ""Failed to get external data for %s: %s"", url, e ) <TAB> return result",True,not ct.startswith('application/json'),not ct.startswith('application/json'),0.6471430063247681
|
||
|
855,"def get_item_address ( self, item ) : <TAB> """"""Get an item's address as a collection of names"""""" <TAB> result = [ ] <TAB> while True : <TAB> <TAB> name = self. tree_ctrl. GetItemPyData ( item ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> break <TAB> <TAB> else : <TAB> <TAB> <TAB> result. insert ( 0, name ) <TAB> <TAB> <TAB> item = self. tree_ctrl. GetItemParent ( item ) <TAB> return result",True,name is None,name is None,0.6606528759002686
|
||
|
856,"def _calc_block_io ( self, blkio ) : <TAB> """"""Calculate block IO stats."""""" <TAB> for stats in blkio [ ""io_service_bytes_recursive"" ] : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _blk_read += stats [ ""value"" ] <TAB> <TAB> elif stats [ ""op"" ] == ""Write"" : <TAB> <TAB> <TAB> self. _blk_write += stats [ ""value"" ]",False,stats['op'] == 'Read',"stats[op""] == ""Read""",0.6567075252532959
|
||
|
857,"def append ( self, val, label = None ) : <TAB> if hasattr ( val, ""__len__"" ) : <TAB> <TAB> if val. isdigit ( ) and len ( val ) > 2 : <TAB> <TAB> <TAB> self. century_specified = True <TAB> <TAB> <TAB> if label not in [ None, ""Y"" ] : <TAB> <TAB> <TAB> <TAB> raise ValueError ( label ) <TAB> <TAB> <TAB> label = ""Y"" <TAB> elif val > 100 : <TAB> <TAB> self. century_specified = True <TAB> <TAB> if label not in [ None, ""Y"" ] : <TAB> <TAB> <TAB> raise ValueError ( label ) <TAB> <TAB> label = ""Y"" <TAB> super ( self. __class__, self ). append ( int ( val ) ) <TAB> if label == ""M"" : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( ""Month is already set"" ) <TAB> <TAB> self. mstridx = len ( self ) - 1 <TAB> elif label == ""D"" : <TAB> <TAB> if self. has_day : <TAB> <TAB> <TAB> raise ValueError ( ""Day is already set"" ) <TAB> <TAB> self. dstridx = len ( self ) - 1 <TAB> elif label == ""Y"" : <TAB> <TAB> if self. has_year : <TAB> <TAB> <TAB> raise ValueError ( ""Year is already set"" ) <TAB> <TAB> self. ystridx = len ( self ) - 1",True,self.has_month,self.has_month,0.6591854691505432
|
||
|
858,"def _setup ( self, rnn_type, ntoken, ninp, nhid, nlayers, dropout = 0.5, tie_weights = False ) : <TAB> self. drop = nn. Dropout ( dropout ) <TAB> self. encoder = nn. Embedding ( ntoken, ninp ) <TAB> if rnn_type in [ ""LSTM"", ""GRU"" ] : <TAB> <TAB> self. rnn = getattr ( nn, rnn_type ) ( ninp, nhid, nlayers, dropout = dropout ) <TAB> else : <TAB> <TAB> try : <TAB> <TAB> <TAB> nonlinearity = { ""RNN_TANH"" : ""tanh"", ""RNN_RELU"" : ""relu"" } [ rnn_type ] <TAB> <TAB> except KeyError : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""An invalid option for `--model` was supplied, "" <TAB> <TAB> <TAB> <TAB> ""options are ['LSTM', 'GRU', 'RNN_TANH' or 'RNN_RELU']"" <TAB> <TAB> <TAB> ) <TAB> <TAB> self. rnn = nn. RNN ( <TAB> <TAB> <TAB> ninp, nhid, nlayers, nonlinearity = nonlinearity, dropout = dropout <TAB> <TAB> ) <TAB> self. decoder = nn. Linear ( nhid, ntoken ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if tie_weights : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( ""When using the tied flag, nhid must be equal to emsize"" ) <TAB> <TAB> self. decoder. weight = self. encoder. weight <TAB> self. _init_weights ( ) <TAB> self. rnn_type = rnn_type <TAB> self. nhid = nhid <TAB> self. nlayers = nlayers",False,nhid != ninp,nhid > nm,0.6781313419342041
|
||
|
859,"def _create ( self ) : <TAB> pkgs_to_install = self. manifest. parse_initial_manifest ( ) <TAB> rpm_pre_process_cmds = self. d. getVar ( ""RPM_PREPROCESS_COMMANDS"" ) <TAB> rpm_post_process_cmds = self. d. getVar ( ""RPM_POSTPROCESS_COMMANDS"" ) <TAB> <TAB> self. pm. write_index ( ) <TAB> execute_pre_post_process ( self. d, rpm_pre_process_cmds ) <TAB> if self. progress_reporter : <TAB> <TAB> self. progress_reporter. next_stage ( ) <TAB> if self. inc_rpm_image_gen == ""1"" : <TAB> <TAB> self. _create_incremental ( pkgs_to_install ) <TAB> if self. progress_reporter : <TAB> <TAB> self. progress_reporter. next_stage ( ) <TAB> self. pm. update ( ) <TAB> pkgs = [ ] <TAB> pkgs_attempt = [ ] <TAB> for pkg_type in pkgs_to_install : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> pkgs_attempt += pkgs_to_install [ pkg_type ] <TAB> <TAB> else : <TAB> <TAB> <TAB> pkgs += pkgs_to_install [ pkg_type ] <TAB> if self. progress_reporter : <TAB> <TAB> self. progress_reporter. next_stage ( ) <TAB> self. pm. install ( pkgs ) <TAB> if self. progress_reporter : <TAB> <TAB> self. progress_reporter. next_stage ( ) <TAB> self. pm. install ( pkgs_attempt, True ) <TAB> if self. progress_reporter : <TAB> <TAB> self. progress_reporter. next_stage ( ) <TAB> self. pm. install_complementary ( ) <TAB> if self. progress_reporter : <TAB> <TAB> self. progress_reporter. next_stage ( ) <TAB> self. _setup_dbg_rootfs ( [ ""/etc"", ""/var/lib/rpm"", ""/var/cache/",False,pkg_type == Manifest.PKG_TYPE_ATTEMPT_ONLY,pkg_type in pkgs,0.649940013885498
|
||
|
860,"def load_syntax ( syntax ) : <TAB> context = _create_scheme ( ) or { } <TAB> partition_scanner = PartitionScanner ( syntax. get ( ""partitions"", [ ] ) ) <TAB> scanners = { } <TAB> for part_name, part_scanner in list ( syntax. get ( ""scanner"", { } ). items ( ) ) : <TAB> <TAB> scanners [ part_name ] = Scanner ( part_scanner ) <TAB> formats = [ ] <TAB> for fname, fstyle in list ( syntax. get ( ""formats"", { } ). items ( ) ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if fstyle. startswith ( ""%("" ) and fstyle. endswith ( "")s"" ) : <TAB> <TAB> <TAB> <TAB> key = fstyle [ 2 : - 2 ] <TAB> <TAB> <TAB> <TAB> fstyle = context [ key ] <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> fstyle = fstyle % context <TAB> <TAB> formats. append ( ( fname, fstyle ) ) <TAB> return partition_scanner, scanners, formats",False,"isinstance(fstyle, basestring)",fname in context,0.6503206491470337
|
||
|
861,"def _open_files ( self ) : <TAB> self. _opened_files = [ ] <TAB> self. _log_destination = [ ] <TAB> self. _log_destination_is_tty = [ ] <TAB> for dest in utils. to_list ( self. log_destination ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> file = open ( dest, ""a"" ) <TAB> <TAB> <TAB> self. _opened_files. append ( file ) <TAB> <TAB> <TAB> self. _log_destination_is_tty. append ( False ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if not hasattr ( dest, ""write"" ) : <TAB> <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> <TAB> f""Log destination {dest} is not a "" f""file-like object"" <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> isatty = dest. isatty ( ) <TAB> <TAB> <TAB> except AttributeError : <TAB> <TAB> <TAB> <TAB> isatty = False <TAB> <TAB> <TAB> file = dest <TAB> <TAB> <TAB> self. _log_destination_is_tty. append ( isatty ) <TAB> <TAB> self. _log_destination. append ( file )",False,"isinstance(dest, (str, Path))","isinstance(dest, basestring)",0.6609674096107483
|
||
|
862,"def formTypesHistogram ( self, prepared ) : <TAB> histo = { } <TAB> <TAB> keys = [ <TAB> <TAB> ""isTriad"", <TAB> <TAB> ""isSeventh"", <TAB> <TAB> ""isMajorTriad"", <TAB> <TAB> ""isMinorTriad"", <TAB> <TAB> ""isIncompleteMajorTriad"", <TAB> <TAB> ""isIncompleteMinorTriad"", <TAB> <TAB> ""isDiminishedTriad"", <TAB> <TAB> ""isAugmentedTriad"", <TAB> <TAB> ""isDominantSeventh"", <TAB> <TAB> ""isDiminishedSeventh"", <TAB> <TAB> ""isHalfDiminishedSeventh"", <TAB> ] <TAB> for c in prepared : <TAB> <TAB> for thisKey in keys : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> histo [ thisKey ] = 0 <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if getattr ( c, thisKey ) ( ) : <TAB> <TAB> <TAB> <TAB> histo [ thisKey ] += 1 <TAB> return histo",False,thisKey not in histo,"getattr(c, thisKey) is None",0.6639055609703064
|
||
|
863,"def generate_scraper ( class_name, host_name ) : <TAB> with open ( ""templates/scraper.py"" ) as source : <TAB> <TAB> code = source. read ( ) <TAB> <TAB> program = ast. parse ( code ) <TAB> <TAB> state = GenerateScraperState ( class_name, host_name, code ) <TAB> <TAB> for node in ast. walk ( program ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> output = f""recipe_scrapers/{class_name.lower()}.py"" <TAB> <TAB> with open ( output, ""w"" ) as target : <TAB> <TAB> <TAB> target. write ( state. result ( ) )",False,not state.step(node),node.error(),0.6513723134994507
|
||
|
864,"def f_freeze ( _ ) : <TAB> repos = utils. get_repos ( ) <TAB> for name, path in repos. items ( ) : <TAB> <TAB> url = """" <TAB> <TAB> cp = subprocess. run ( [ ""git"", ""remote"", ""-v"" ], cwd = path, capture_output = True ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> url = cp. stdout. decode ( ""utf-8"" ). split ( ""\n"" ) [ 0 ]. split ( ) [ 1 ] <TAB> <TAB> print ( f""{url},{name},{path}"" )",True,cp.returncode == 0,cp.returncode == 0,0.6603929400444031
|
||
|
865,"def load ( cls, storefile, template_store ) : <TAB> <TAB> if not hasattr ( storefile, ""read"" ) : <TAB> <TAB> storefile = open ( storefile, ""rb"" ) <TAB> <TAB> store = cls. convertfile ( storefile, template_store ) <TAB> for unit in store. units : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> if cls. needs_target_sync : <TAB> <TAB> <TAB> unit. target = unit. source <TAB> <TAB> <TAB> unit. rich_target = unit. rich_source <TAB> return store",False,unit.isheader(),unit.is_multigraph,0.65279221534729
|
||
|
866,"def fixup_pth_and_egg_link ( home_dir, sys_path = None ) : <TAB> """"""Makes.pth and.egg-link files use relative paths"""""" <TAB> home_dir = os. path. normcase ( os. path. abspath ( home_dir ) ) <TAB> if sys_path is None : <TAB> <TAB> sys_path = sys. path <TAB> for a_path in sys_path : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> a_path = ""."" <TAB> <TAB> if not os. path. isdir ( a_path ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> a_path = os. path. normcase ( os. path. abspath ( a_path ) ) <TAB> <TAB> if not a_path. startswith ( home_dir ) : <TAB> <TAB> <TAB> logger. debug ( ""Skipping system (non-environment) directory %s"", a_path ) <TAB> <TAB> <TAB> continue <TAB> <TAB> for filename in os. listdir ( a_path ) : <TAB> <TAB> <TAB> filename = os. path. join ( a_path, filename ) <TAB> <TAB> <TAB> if filename. endswith ( "".pth"" ) : <TAB> <TAB> <TAB> <TAB> if not os. access ( filename, os. W_OK ) : <TAB> <TAB> <TAB> <TAB> <TAB> logger. warn ( ""Cannot write.pth file %s, skipping"", filename ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> fixup_pth_file ( filename ) <TAB> <TAB> <TAB> if filename. endswith ( "".egg-link"" ) : <TAB> <TAB> <TAB> <TAB> if not os. access ( filename, os. W_OK ) : <TAB> <TAB> <TAB> <TAB> <TAB> logger. warn ( ""Cannot write.egg-link file %s, skipping"", filename ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> fix",False,not a_path,a_path == None,0.6560148000717163
|
||
|
867,"def validate_pull_secret ( namespace ) : <TAB> if namespace. pull_secret is None : <TAB> <TAB> <TAB> <TAB> warning = ( <TAB> <TAB> <TAB> ""No --pull-secret provided: cluster will not include samples or operators from "" <TAB> <TAB> <TAB> + ""Red Hat or from certified partners."" <TAB> <TAB> ) <TAB> <TAB> logger. warning ( warning ) <TAB> else : <TAB> <TAB> try : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise Exception ( ) <TAB> <TAB> except : <TAB> <TAB> <TAB> raise InvalidArgumentValueError ( ""Invalid --pull-secret."" )",False,"not isinstance(json.loads(namespace.pull_secret), dict)","namespace.pull_secret.lower() not in ['AVG', 'AVG', 'AVG', 'AVG', 'AVG', 'AVG']",0.6529994010925293
|
||
|
868,"def setdefault ( self, key, default = None ) : <TAB> try : <TAB> <TAB> o = self. data [ key ] ( ) <TAB> except KeyError : <TAB> <TAB> o = None <TAB> if o is None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _commit_removals ( ) <TAB> <TAB> self. data [ key ] = KeyedRef ( default, self. _remove, key ) <TAB> <TAB> return default <TAB> else : <TAB> <TAB> return o",True,self._pending_removals,self._pending_removals,0.659338653087616
|
||
|
869,"def run_cmd ( self, util, value ) : <TAB> state = util. state <TAB> if not state. argument_supplied : <TAB> <TAB> state. argument_supplied = True <TAB> <TAB> if value == ""by_four"" : <TAB> <TAB> <TAB> state. argument_value = 4 <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> state. argument_negative = True <TAB> <TAB> else : <TAB> <TAB> <TAB> state. argument_value = value <TAB> elif value == ""by_four"" : <TAB> <TAB> state. argument_value *= 4 <TAB> elif isinstance ( value, int ) : <TAB> <TAB> state. argument_value *= 10 <TAB> <TAB> state. argument_value += value <TAB> elif<mask> : <TAB> <TAB> state. argument_value = - state. argument_value",True,value == 'negative',value == 'negative',0.664093017578125
|
||
|
870,"def close ( self ) : <TAB> with self. _lock : <TAB> <TAB> """"""Close this _MultiFileWatcher object forever."""""" <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _folder_handlers = { } <TAB> <TAB> <TAB> LOGGER. debug ( <TAB> <TAB> <TAB> <TAB> ""Stopping observer thread even though there is a non-zero "" <TAB> <TAB> <TAB> <TAB> ""number of event observers!"" <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> LOGGER. debug ( ""Stopping observer thread"" ) <TAB> <TAB> self. _observer. stop ( ) <TAB> <TAB> self. _observer. join ( timeout = 5 )",False,len(self._folder_handlers) != 0,self._observer is not None,0.6578959226608276
|
||
|
871,"def update_completion ( self ) : <TAB> <TAB> if not self. notebook : <TAB> <TAB> return <TAB> text = self. get_text ( ) <TAB> completion = self. get_completion ( ) <TAB> if completion is None : <TAB> <TAB> return <TAB> model = completion. get_model ( ) <TAB> model. clear ( ) <TAB> if not text or not self. get_input_valid ( ) : <TAB> <TAB> return <TAB> if "":"" in text : <TAB> <TAB> i = text. rfind ( "":"" ) <TAB> <TAB> prefix = text [ : i + 1 ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> path = Path ( "":"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> reference = self. notebookpath or Path ( "":"" ) <TAB> <TAB> <TAB> link = prefix <TAB> <TAB> <TAB> if self. subpaths_only and not link. startswith ( ""+"" ) : <TAB> <TAB> <TAB> <TAB> link = ""+"" + link. lstrip ( "":"" ) <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> path = self. notebook. pages. lookup_from_user_input ( link, reference ) <TAB> <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> try : <TAB> <TAB> <TAB> self. _fill_completion_for_anchor ( path, prefix, text ) <TAB> <TAB> except IndexNotFoundError : <TAB> <TAB> <TAB> pass <TAB> elif text. startswith ( ""+"" ) and self. notebookpath : <TAB> <TAB> prefix = ""+"" <TAB> <TAB> path = self. notebookpath <TAB> <TAB> try : <TAB> <TAB> <TAB> self. _fill_completion_for_anchor ( path, prefix, text ) <TAB> <TAB> except IndexNotFoundError : <TAB> <TAB> <TAB> pass <TAB> else : <TAB> <TAB> path = self. notebookpath or Path ( "":"" ) <TAB> <TAB> try : <TAB> <TAB> <TAB",False,prefix == ':',prefix.startswith(':'),0.6793688535690308
|
||
|
872,"def _get_git_branch ( q ) : <TAB> denv = builtins. __xonsh__. env. detype ( ) <TAB> try : <TAB> <TAB> branches = xt. decode_bytes ( <TAB> <TAB> <TAB> subprocess. check_output ( <TAB> <TAB> <TAB> <TAB> [ ""git"", ""branch"" ], env = denv, stderr = subprocess. DEVNULL <TAB> <TAB> <TAB> ) <TAB> <TAB> ). splitlines ( ) <TAB> except ( subprocess. CalledProcessError, OSError, FileNotFoundError ) : <TAB> <TAB> q. put ( None ) <TAB> else : <TAB> <TAB> for branch in branches : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> elif branch. endswith ( "")"" ) : <TAB> <TAB> <TAB> <TAB> branch = branch. split ( ) [ - 1 ] [ : - 1 ] <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> branch = branch. split ( ) [ - 1 ] <TAB> <TAB> <TAB> q. put ( branch ) <TAB> <TAB> <TAB> break <TAB> <TAB> else : <TAB> <TAB> <TAB> q. put ( None )",False,not branch.startswith('* '),"not branch.endswith('."")",0.6480258703231812
|
||
|
873,"def _normalize_dict_keys ( transformer, keys ) : <TAB> res = [ ] <TAB> for key in keys : <TAB> <TAB> if isinstance ( key, str ) : <TAB> <TAB> <TAB> key = ast. Str ( key ) <TAB> <TAB> elif isinstance ( key, JSStr ) : <TAB> <TAB> <TAB> key = ast. Str ( key. args [ 0 ] ) <TAB> <TAB> if not isinstance ( key, ast. Str ) : <TAB> <TAB> <TAB> if transformer. enable_es6 : <TAB> <TAB> <TAB> <TAB> key = JSKeySubscript ( key ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> if isinstance ( key, ast. AST ) : <TAB> <TAB> <TAB> <TAB> <TAB> py_node = key <TAB> <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> py_node = key. py_node <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""Value of type %r cannot "" ""be use as key"" % type ( key ) <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> transformer. unsupported ( <TAB> <TAB> <TAB> <TAB> <TAB> py_node, <TAB> <TAB> <TAB> <TAB> <TAB> True, <TAB> <TAB> <TAB> <TAB> <TAB> ""Value of type %r cannot "" ""be use as key"" % type ( key ), <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> res. append ( key ) <TAB> return res",False,"isinstance(key, TargetNode) and key.py_node is not None","isinstance(key, ast.Subscript)",0.6515085101127625
|
||
|
874,"def recv_some ( p, t = 0.1, e = 1, tr = 5, stderr = 0 ) : <TAB> if tr < 1 : <TAB> <TAB> tr = 1 <TAB> x = time. time ( ) + t <TAB> y = [ ] <TAB> r = """" <TAB> if stderr : <TAB> <TAB> pr = p. recv_err <TAB> else : <TAB> <TAB> pr = p. recv <TAB> while time. time ( ) < x or r : <TAB> <TAB> r = pr ( ) <TAB> <TAB> if r is None : <TAB> <TAB> <TAB> break <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> y. append ( r ) <TAB> <TAB> else : <TAB> <TAB> <TAB> time. sleep ( max ( ( x - time. time ( ) ) / tr, 0 ) ) <TAB> return """". join ( y )",False,r,e,0.6913201808929443
|
||
|
875,"def _extract_lemma ( self, parse : Parse ) -> str : <TAB> special_feats = [ x for x in self. SPECIAL_FEATURES if x in parse. tag ] <TAB> if len ( special_feats ) == 0 : <TAB> <TAB> return parse. normal_form <TAB> <TAB> for other in parse. lexeme : <TAB> <TAB> tag = other. tag <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> if ( <TAB> <TAB> <TAB> tag. case == ""nomn"" <TAB> <TAB> <TAB> and tag. gender == parse. tag. gender <TAB> <TAB> <TAB> and tag. number == ""sing"" <TAB> <TAB> ) : <TAB> <TAB> <TAB> return other. word <TAB> return parse. normal_form",False,any((x not in tag for x in special_feats)),tag == parse.tag,0.6533888578414917
|
||
|
876,"def run_async ( self ) : <TAB> for entry in self. interface. entries : <TAB> <TAB> if self. commit_is_merge ( entry. long_hash ) : <TAB> <TAB> <TAB> sublime. message_dialog ( ""Unable to squash a merge."" ) <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> <TAB> last_commit_idx = len ( self. interface. entries ) - 1 <TAB> commit_chain = self. perpare_rewrites ( self. interface. entries ) <TAB> <TAB> <TAB> for idx, commit in enumerate ( commit_chain ) : <TAB> <TAB> commit. modified = True <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> commit. do_commit = False <TAB> <TAB> <TAB> commit_chain [ idx + 1 ]. msg = commit. msg + ""\n\n"" + commit_chain [ idx + 1 ]. msg <TAB> <TAB> <TAB> commit. msg = None <TAB> <TAB> else : <TAB> <TAB> <TAB> commit. squashed = True <TAB> self. make_changes ( commit_chain, ""squashed all commits"" )",False,idx < last_commit_idx,commit.do_commit and idx + 1 < len(commit_chain),0.6533656120300293
|
||
|
877,"def verify_installed_apps ( <TAB> captured_outerr, package_name : str, test_error_fh : io. StringIO, deps : bool = False ) -> bool : <TAB> package_apps = PKG [ package_name ] [ ""apps"" ]. copy ( ) <TAB> if deps : <TAB> <TAB> package_apps += PKG [ package_name ] [ ""apps_of_dependencies"" ] <TAB> reported_apps_re = re. search ( <TAB> <TAB> r""These apps are now globally available(.+)"", captured_outerr. out, re. DOTALL <TAB> ) <TAB> if reported_apps_re : <TAB> <TAB> reported_apps = [ <TAB> <TAB> <TAB> x. strip ( ) [ 2 : ] for x in reported_apps_re. group ( 1 ). strip ( ). split ( ""\n"" ) <TAB> <TAB> ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> app_success = False <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> ""verify_install: REPORTED APPS DO NOT MATCH PACKAGE"", file = test_error_fh <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> print ( f""pipx reported apps: {reported_apps}"", file = test_error_fh ) <TAB> <TAB> <TAB> print ( f"" true package apps: {package_apps}"", file = test_error_fh ) <TAB> <TAB> else : <TAB> <TAB> <TAB> app_success = True <TAB> else : <TAB> <TAB> app_success = False <TAB> <TAB> print ( ""verify_install: APPS TESTING ERROR"", file = test_error_fh ) <TAB> return app_success",False,set(reported_apps) != set(package_apps),package_apps,0.6491948962211609
|
||
|
878,"def _get ( self, heappop = heapq. heappop ) : <TAB> while self. queue : <TAB> <TAB> item = heappop ( self. queue ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> self. queue_dict. pop ( item. taskid, None ) <TAB> <TAB> return item <TAB> return None",True,item.taskid is None,item.taskid is None,0.6567336320877075
|
||
|
879,"def logic ( ) : <TAB> while 1 : <TAB> <TAB> yield PI, PT <TAB> <TAB> PT. next [ n : ] = PI <TAB> <TAB> for l in range ( 1, m + 1 ) : <TAB> <TAB> <TAB> for k in range ( 2 ** ( m - l ) ) : <TAB> <TAB> <TAB> <TAB> for i in range ( 2 ** ( l - 1 ) ) : <TAB> <TAB> <TAB> <TAB> <TAB> if ( k * 2 ** l + i ) < n : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> PT. next [ l * n + k * 2 ** l + i ] = PT [ <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ( l - 1 ) * n + k * 2 ** l + i <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> PT. next [ l * n + k * 2 ** l + 2 ** ( l - 1 ) + i ] = ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> PT [ ( l - 1 ) * n + k * 2 ** l + 2 ** ( l - 1 ) + i ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> & PT [ ( l - 1 ) * n + k * 2 ** l + 2 ** ( l - 1 ) - 1 ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> PO. next = PT [ ( m + 1 ) * n : m * n ]",False,k * 2 ** l + 2 ** (l - 1) + i < n,l > 0,0.6610714197158813
|
||
|
880,"def onMessage ( self, payload, isBinary ) : <TAB> if not isBinary : <TAB> <TAB> self. result = ""Expected binary message with payload, but got binary."" <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. result = ( <TAB> <TAB> <TAB> <TAB> ""Expected binary message with payload of length %d, but got %d."" <TAB> <TAB> <TAB> <TAB> % ( self. DATALEN, len ( payload ) ) <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. behavior = Case. OK <TAB> <TAB> <TAB> self. result = ""Received binary message of length %d."" % len ( payload ) <TAB> self. p. createWirelog = True <TAB> self. p. sendClose ( self. p. CLOSE_STATUS_CODE_NORMAL )",False,len(payload) != self.DATALEN,len(payload) > self.DATALEN,0.6611055135726929
|
||
|
881,"def __init__ ( self, ** kwargs ) : <TAB> self. theme = kwargs. pop ( ""theme"" ) <TAB> super ( GenericThemeForm, self ). __init__ ( ** kwargs ) <TAB> if self. theme. stylesheets : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> choices = [ <TAB> <TAB> <TAB> <TAB> ( style [ ""stylesheet"" ], style [ ""name"" ] ) for style in self. theme. stylesheets <TAB> <TAB> <TAB> ] <TAB> <TAB> else : <TAB> <TAB> <TAB> warnings. warn ( <TAB> <TAB> <TAB> <TAB> ""Using list of tuples in theme.stylesheets will deprecate "" <TAB> <TAB> <TAB> <TAB> ""in Shuup 0.5.7. Use list of dictionaries instead."", <TAB> <TAB> <TAB> <TAB> RemovedInFutureShuupWarning, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> choices = self. theme. stylesheets <TAB> <TAB> self. fields [ ""stylesheet"" ] = forms. ChoiceField ( <TAB> <TAB> <TAB> label = _ ( ""Stylesheets"" ), choices = choices, initial = choices [ 0 ], required = True <TAB> <TAB> ) <TAB> fields = self. theme. fields <TAB> if hasattr ( fields, ""items"" ) : <TAB> <TAB> fields = fields. items ( ) <TAB> for name, field in fields : <TAB> <TAB> self. fields [ name ] = deepcopy ( field ) <TAB> self. initial. update ( self. instance. get_settings ( ) )",False,"isinstance(self.theme.stylesheets[0], dict)","hasattr(self.theme.stylesheets, '__iter__')",0.6531034111976624
|
||
|
882,"def samples_to_records ( samples, default_keys = None ) : <TAB> """"""Convert samples into output CWL records."""""" <TAB> from bcbio. pipeline import run_info <TAB> RECORD_CONVERT_TO_LIST = set ( <TAB> <TAB> [ <TAB> <TAB> <TAB> ""config__algorithm__tools_on"", <TAB> <TAB> <TAB> ""config__algorithm__tools_off"", <TAB> <TAB> <TAB> ""reference__genome_context"", <TAB> <TAB> ] <TAB> ) <TAB> all_keys = _get_all_cwlkeys ( samples, default_keys ) <TAB> out = [ ] <TAB> for data in samples : <TAB> <TAB> for raw_key in sorted ( list ( all_keys ) ) : <TAB> <TAB> <TAB> key = raw_key. split ( ""__"" ) <TAB> <TAB> <TAB> if tz. get_in ( key, data ) is None : <TAB> <TAB> <TAB> <TAB> data = tz. update_in ( data, key, lambda x : None ) <TAB> <TAB> <TAB> if raw_key not in data [ ""cwl_keys"" ] : <TAB> <TAB> <TAB> <TAB> data [ ""cwl_keys"" ]. append ( raw_key ) <TAB> <TAB> <TAB> if raw_key in RECORD_CONVERT_TO_LIST : <TAB> <TAB> <TAB> <TAB> val = tz. get_in ( key, data ) <TAB> <TAB> <TAB> <TAB> if not val : <TAB> <TAB> <TAB> <TAB> <TAB> val = [ ] <TAB> <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> val = [ val ] <TAB> <TAB> <TAB> <TAB> data = tz. update_in ( data, key, lambda x : val ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if isinstance ( tz. get_in ( key, data ), bool ) : <TAB> <TAB> <TAB> <TAB> data = tz. update_",False,"not isinstance(val, (list, tuple))",val,0.6498900055885315
|
||
|
883,"def check_related_active_jobs ( self, obj ) : <TAB> active_jobs = obj. get_active_jobs ( ) <TAB> if len ( active_jobs ) > 0 : <TAB> <TAB> raise ActiveJobConflict ( active_jobs ) <TAB> time_cutoff = now ( ) - dateutil. relativedelta. relativedelta ( minutes = 1 ) <TAB> recent_jobs = obj. _get_related_jobs ( ). filter ( finished__gte = time_cutoff ) <TAB> for unified_job in recent_jobs. get_real_instances ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise PermissionDenied ( <TAB> <TAB> <TAB> <TAB> _ ( ""Related job {} is still processing events."" ). format ( <TAB> <TAB> <TAB> <TAB> <TAB> unified_job. log_format <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> )",False,not unified_job.event_processing_finished,unified_job.has_events(),0.6505641341209412
|
||
|
884,"def _parse_param_value ( name, datatype, default ) : <TAB> if datatype == ""bool"" : <TAB> <TAB> if default. lower ( ) == ""true"" : <TAB> <TAB> <TAB> return True <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> return False <TAB> <TAB> else : <TAB> <TAB> <TAB> _s = ""{}: Invalid default value '{}' for bool parameter {}"" <TAB> <TAB> <TAB> raise SyntaxError ( _s. format ( self. name, default, p ) ) <TAB> elif datatype == ""int"" : <TAB> <TAB> if type ( default ) == int : <TAB> <TAB> <TAB> return default <TAB> <TAB> else : <TAB> <TAB> <TAB> return int ( default, 0 ) <TAB> elif datatype == ""real"" : <TAB> <TAB> if type ( default ) == float : <TAB> <TAB> <TAB> return default <TAB> <TAB> else : <TAB> <TAB> <TAB> return float ( default ) <TAB> else : <TAB> <TAB> return str ( default )",True,default.lower() == 'false',default.lower() == 'false',0.6580437421798706
|
||
|
885,"def create_new_file ( obj, source, destination, destination_node ) : <TAB> <TAB> if not source [ ""materialized"" ]. startswith ( ""/"" ) : <TAB> <TAB> source [ ""materialized"" ] = ""/"" + source [ ""materialized"" ] <TAB> if not destination [ ""materialized"" ]. startswith ( ""/"" ) : <TAB> <TAB> destination [ ""materialized"" ] = ""/"" + destination [ ""materialized"" ] <TAB> if not source [ ""path"" ]. endswith ( ""/"" ) : <TAB> <TAB> data = dict ( destination ) <TAB> <TAB> new_file = BaseFileNode. resolve_class ( <TAB> <TAB> <TAB> destination [ ""provider"" ], BaseFileNode. FILE <TAB> <TAB> ). get_or_create ( destination_node, destination [ ""path"" ] ) <TAB> <TAB> if destination [ ""provider"" ]!= ""osfstorage"" : <TAB> <TAB> <TAB> new_file. update ( revision = None, data = data ) <TAB> else : <TAB> <TAB> new_file = find_and_create_file_from_metadata ( <TAB> <TAB> <TAB> destination. get ( ""children"", [ ] ), source, destination, destination_node, obj <TAB> <TAB> ) <TAB> <TAB> if not new_file : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> new_path = obj. referent. path <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> new_path = obj. referent. materialized_path. replace ( <TAB> <TAB> <TAB> <TAB> <TAB> source [ ""materialized"" ], destination [ ""materialized"" ] <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> new_file = BaseFileNode. resolve_class ( <TAB> <TAB> <TAB> <TAB> destination [ ""provider"" ], BaseFileNode. FILE <TAB> <TAB> <TAB> ). get_or_create ( destination_node, new_path ) <TAB> <TAB> <TAB>",False,source['provider'] == 'box',obj.referent.path,0.6547295451164246
|
||
|
886,"def __init__ ( self, tree ) : <TAB> for k, v in sorted ( tree. items ( ) ) : <TAB> <TAB> if v is None : <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> setattr ( self, k, globals ( ) [ self. members [ k ] ] ( v ) ) <TAB> <TAB> elif k in self. lists : <TAB> <TAB> <TAB> if k. endswith ( ""_append"" ) : <TAB> <TAB> <TAB> <TAB> _k = k [ : - 7 ] <TAB> <TAB> <TAB> <TAB> _l = getattr ( self, _k, [ ] ) [ : ] <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> _k = k <TAB> <TAB> <TAB> <TAB> _l = [ ] <TAB> <TAB> <TAB> for _item in v : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> _l. append ( globals ( ) [ self. lists [ _k ] ] ( _item ) ) <TAB> <TAB> <TAB> <TAB> except TypeError as e : <TAB> <TAB> <TAB> <TAB> <TAB> raise SyntaxError ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""Bad option '{}' in section '{}'"". format ( _item, k ) <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> setattr ( self, _k, _l ) <TAB> <TAB> elif k in self. dicts : <TAB> <TAB> <TAB> if not isinstance ( v, dict ) : <TAB> <TAB> <TAB> <TAB> raise SyntaxError ( ""Object in '{}' section must be a dict"". format ( k ) ) <TAB> <TAB> <TAB> _d = { } <TAB> <TAB> <TAB> for _name, _items in v. items ( ) : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> _d",True,k in self.members,k in self.members,0.6650645732879639
|
||
|
887,"def tile ( cls, op : ""LGBMAlign"" ) : <TAB> inputs = [ <TAB> <TAB> d for d in [ op. data, op. label, op. sample_weight, op. init_score ] if d is not None <TAB> ] <TAB> data = op. data <TAB> <TAB> check_chunks_unknown_shape ( inputs, TilesError ) <TAB> ctx = get_context ( ) <TAB> if ctx. running_mode!= RunningMode. distributed : <TAB> <TAB> outputs = [ <TAB> <TAB> <TAB> inp. rechunk ( tuple ( ( s, ) for s in inp. shape ) ). _inplace_tile ( ) <TAB> <TAB> <TAB> for inp in inputs <TAB> <TAB> ] <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> data = data. rechunk ( { 1 : data. shape [ 1 ] } ). _inplace_tile ( ) <TAB> <TAB> outputs = [ data ] <TAB> <TAB> for inp in inputs [ 1 : ] : <TAB> <TAB> <TAB> if inp is not None : <TAB> <TAB> <TAB> <TAB> outputs. append ( inp. rechunk ( ( data. nsplits [ 0 ], ) ). _inplace_tile ( ) ) <TAB> kws = [ ] <TAB> for o in outputs : <TAB> <TAB> kw = o. params. copy ( ) <TAB> <TAB> kw. update ( dict ( chunks = o. chunks, nsplits = o. nsplits ) ) <TAB> <TAB> kws. append ( kw ) <TAB> new_op = op. copy ( ). reset_key ( ) <TAB> tileables = new_op. new_tileables ( inputs, kws = kws ) <TAB> return tileables",False,len(data.nsplits[1]) != 1,data is not None,0.6540103554725647
|
||
|
888,"def get_code ( self, fullname = None ) : <TAB> fullname = self. _fix_name ( fullname ) <TAB> if self. code is None : <TAB> <TAB> mod_type = self. etc [ 2 ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> source = self. get_source ( fullname ) <TAB> <TAB> <TAB> self. code = compile ( source, self. filename, ""exec"" ) <TAB> <TAB> elif mod_type == imp. PY_COMPILED : <TAB> <TAB> <TAB> self. _reopen ( ) <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> self. code = read_code ( self. file ) <TAB> <TAB> <TAB> finally : <TAB> <TAB> <TAB> <TAB> self. file. close ( ) <TAB> <TAB> elif mod_type == imp. PKG_DIRECTORY : <TAB> <TAB> <TAB> self. code = self. _get_delegate ( ). get_code ( ) <TAB> return self. code",False,mod_type == imp.PY_SOURCE,mod_type == imp.NONE,0.6575285196304321
|
||
|
889,"def reprocess_lines ( processed_lines ) : <TAB> reprocessed_lines = [ ] <TAB> for line in processed_lines : <TAB> <TAB> text = """". join ( line ) <TAB> <TAB> chunks = sent_tokenize ( text ) <TAB> <TAB> if sum ( len ( x ) for x in chunks )!= len ( text ) : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""Got unexpected text length: \n{}\nvs\n{}"". format ( text, chunks ) <TAB> <TAB> <TAB> ) <TAB> <TAB> chunk_lengths = [ len ( x ) for x in chunks ] <TAB> <TAB> current_length = 0 <TAB> <TAB> new_line = [ ] <TAB> <TAB> for word in line : <TAB> <TAB> <TAB> if len ( word ) + current_length < chunk_lengths [ 0 ] : <TAB> <TAB> <TAB> <TAB> new_line. append ( word ) <TAB> <TAB> <TAB> <TAB> current_length = current_length + len ( word ) <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> new_line. append ( word ) <TAB> <TAB> <TAB> <TAB> reprocessed_lines. append ( new_line ) <TAB> <TAB> <TAB> <TAB> new_line = [ ] <TAB> <TAB> <TAB> <TAB> chunk_lengths = chunk_lengths [ 1 : ] <TAB> <TAB> <TAB> <TAB> current_length = 0 <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> remaining_len = chunk_lengths [ 0 ] - current_length <TAB> <TAB> <TAB> <TAB> new_line. append ( word [ : remaining_len ] ) <TAB> <TAB> <TAB> <TAB> reprocessed_lines. append ( new_line ) <TAB> <TAB> <TAB> <TAB> word = word [ remaining_len : ] <TAB> <TAB> <TAB> <TAB> chunk_lengths = chunk_lengths [ 1 : ] <TAB> <",False,len(word) + current_length == chunk_lengths[0],len(word) + current_length < chunk_lengths[0],0.6559857130050659
|
||
|
890,"def clean_permissions ( <TAB> cls, <TAB> requestor : ""User"", <TAB> group : auth_models. Group, <TAB> errors : Dict [ Optional [ str ], List [ ValidationError ] ], <TAB> cleaned_input : dict, ) : <TAB> field = ""add_permissions"" <TAB> permission_items = cleaned_input. get ( field ) <TAB> if permission_items : <TAB> <TAB> cleaned_input [ field ] = get_permissions ( permission_items ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> cls. ensure_can_manage_permissions ( <TAB> <TAB> <TAB> <TAB> requestor, errors, field, permission_items <TAB> <TAB> <TAB> )",False,not requestor.is_superuser,errors,0.6512376070022583
|
||
|
891,"def choose_detectors ( args ) : <TAB> all_detector_classes = get_detectors_classes ( ) <TAB> detectors = { d. ARGUMENT : d for d in all_detector_classes } <TAB> arguments = list ( detectors. keys ( ) ) <TAB> detectors_to_run = [ ] <TAB> if not args. exclude_all : <TAB> <TAB> exclude = [ ] <TAB> <TAB> if args. detectors_to_exclude : <TAB> <TAB> <TAB> exclude = args. detectors_to_exclude. split ( "","" ) <TAB> <TAB> <TAB> for e in exclude : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> raise Exception ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> f""{e} is not a detector name, must be one of {arguments}. See also `--list-detectors`."" <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> for arg, detector_cls in detectors. items ( ) : <TAB> <TAB> <TAB> if arg not in exclude : <TAB> <TAB> <TAB> <TAB> detectors_to_run. append ( detector_cls ) <TAB> return detectors_to_run",False,e not in arguments,e not in detectors,0.6711958646774292
|
||
|
892,"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. req = TGetTableTypesReq ( ) <TAB> <TAB> <TAB> <TAB> self. req. 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 ( )",False,ftype == TType.STRUCT,ftype == TType.TABLE_TYPE,0.6619229912757874
|
||
|
893,"def read_plugin_info ( plugin, zip_data ) : <TAB> file = StringIO. StringIO ( zip_data ) <TAB> archive = zipfile. ZipFile ( file ) <TAB> has_info = False <TAB> for name in archive. namelist ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> data = json. load ( archive. open ( name ) ) <TAB> <TAB> <TAB> plugin. name = data [ ""name"" ] <TAB> <TAB> <TAB> plugin. info_json = json. dumps ( data ) <TAB> <TAB> <TAB> plugin. categories = data. get ( ""categories"", [ ""Other"" ] ) <TAB> <TAB> <TAB> has_info = True <TAB> <TAB> elif name. endswith ( ""/Icon.png"" ) or name. endswith ( ""/icon.png"" ) : <TAB> <TAB> <TAB> data = archive. open ( name ). read ( ) <TAB> <TAB> <TAB> plugin. icon_url = resize_and_store ( data, 128 ) <TAB> <TAB> elif name. endswith ( ""/Screenshot.png"" ) : <TAB> <TAB> <TAB> screenshot = archive. open ( name ). read ( ) <TAB> <TAB> <TAB> plugin. screenshot_url = resize_and_store ( screenshot, 800 ) <TAB> <TAB> elif name. endswith ( "".version"" ) : <TAB> <TAB> <TAB> plugin. version = int ( name. split ( ""/"" ) [ - 1 ]. split ( ""."" ) [ 0 ] ) <TAB> return has_info",False,name.endswith('/info.json'),name.endswith('.json'),0.643671452999115
|
||
|
894,"def _actions_read ( self, c ) : <TAB> self. action_input. handle_read ( c ) <TAB> if c in [ curses. KEY_ENTER, util. KEY_ENTER2 ] : <TAB> <TAB> <TAB> <TAB> if self. action_input. selected_index == 0 : <TAB> <TAB> <TAB> self. back_to_parent ( ) <TAB> <TAB> elif self. action_input. selected_index == 1 : <TAB> <TAB> <TAB> self. _apply_prefs ( ) <TAB> <TAB> <TAB> client. core. get_config ( ). addCallback ( self. _update_preferences ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> self. _apply_prefs ( ) <TAB> <TAB> <TAB> self. back_to_parent ( )",True,self.action_input.selected_index == 2,self.action_input.selected_index == 2,0.6521742343902588
|
||
|
895,"def untokenize ( self, iterable ) : <TAB> it = iter ( iterable ) <TAB> indents = [ ] <TAB> startline = False <TAB> for t in it : <TAB> <TAB> if len ( t ) == 2 : <TAB> <TAB> <TAB> self. compat ( t, it ) <TAB> <TAB> <TAB> break <TAB> <TAB> tok_type, token, start, end, line = t <TAB> <TAB> if tok_type == ENDMARKER : <TAB> <TAB> <TAB> break <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> indents. append ( token ) <TAB> <TAB> <TAB> continue <TAB> <TAB> elif tok_type == DEDENT : <TAB> <TAB> <TAB> indents. pop ( ) <TAB> <TAB> <TAB> self. prev_row, self. prev_col = end <TAB> <TAB> <TAB> continue <TAB> <TAB> elif tok_type in ( NEWLINE, NL ) : <TAB> <TAB> <TAB> startline = True <TAB> <TAB> elif startline and indents : <TAB> <TAB> <TAB> indent = indents [ - 1 ] <TAB> <TAB> <TAB> if start [ 1 ] >= len ( indent ) : <TAB> <TAB> <TAB> <TAB> self. tokens. append ( indent ) <TAB> <TAB> <TAB> <TAB> self. prev_col = len ( indent ) <TAB> <TAB> <TAB> startline = False <TAB> <TAB> self. add_whitespace ( start ) <TAB> <TAB> self. tokens. append ( token ) <TAB> <TAB> self. prev_row, self. prev_col = end <TAB> <TAB> if tok_type in ( NEWLINE, NL ) : <TAB> <TAB> <TAB> self. prev_row += 1 <TAB> <TAB> <TAB> self. prev_col = 0 <TAB> return """". join ( self. tokens )",False,tok_type == INDENT,startline,0.6676044464111328
|
||
|
896,"def force_ipv4 ( self, * args ) : <TAB> """"""only ipv4 localhost in /etc/hosts"""""" <TAB> logg. debug ( ""checking /etc/hosts for '::1 localhost'"" ) <TAB> lines = [ ] <TAB> for line in open ( self. etc_hosts ( ) ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> newline = re. sub ( ""\\slocalhost\\s"", "" "", line ) <TAB> <TAB> <TAB> if line!= newline : <TAB> <TAB> <TAB> <TAB> logg. info ( ""/etc/hosts: '%s' => '%s'"", line. rstrip ( ), newline. rstrip ( ) ) <TAB> <TAB> <TAB> <TAB> line = newline <TAB> <TAB> lines. append ( line ) <TAB> f = open ( self. etc_hosts ( ), ""w"" ) <TAB> for line in lines : <TAB> <TAB> f. write ( line ) <TAB> f. close ( )",False,'::1' in line,self.ipv4_ipv4 and line,0.654106855392456
|
||
|
897,"def build_share ( config, share ) : <TAB> if share [ ""paths"" ] : <TAB> <TAB> result = [ p. rstrip ( ""/"" ) for p in share [ ""paths"" ] ] <TAB> <TAB> if share [ ""alldirs"" ] : <TAB> <TAB> <TAB> result. append ( ""-alldirs"" ) <TAB> <TAB> if share [ ""ro"" ] : <TAB> <TAB> <TAB> result. append ( ""-ro"" ) <TAB> <TAB> if share [ ""quiet"" ] : <TAB> <TAB> <TAB> result. append ( ""-quiet"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> s = '-mapall=""' + share [ ""mapall_user"" ]. replace ( ""\\"", ""\\\\"" ) + '""' <TAB> <TAB> <TAB> if share [ ""mapall_group"" ] : <TAB> <TAB> <TAB> <TAB> s += ':""' + share [ ""mapall_group"" ]. replace ( ""\\"", ""\\\\"" ) + '""' <TAB> <TAB> <TAB> result. append ( s ) <TAB> <TAB> elif share [ ""maproot_user"" ] : <TAB> <TAB> <TAB> s = '-maproot=""' + share [ ""maproot_user"" ]. replace ( ""\\"", ""\\\\"" ) + '""' <TAB> <TAB> <TAB> if share [ ""maproot_group"" ] : <TAB> <TAB> <TAB> <TAB> s += ':""' + share [ ""maproot_group"" ]. replace ( ""\\"", ""\\\\"" ) + '""' <TAB> <TAB> <TAB> result. append ( s ) <TAB> <TAB> if config [ ""v4"" ] and share [ ""security"" ] : <TAB> <TAB> <TAB> result. append ( ""-sec="" + "":"". join ( [ s. lower ( ) for s in share [ ""security"" ] ] ) ) <TAB> <TAB> targets = build_share_targets ( share ) <TAB> <TAB> if targets : <TAB> <TAB> <TAB> return [ "" "". join ( result + [ target ] ) for target in targets ] <TAB> <TAB> else : <TAB> <TAB> <TAB",True,share['mapall_user'],share['mapall_user'],0.6569101810455322
|
||
|
898,"def get_descendants ( self, el, tags = True, no_iframe = False ) : <TAB> """"""Get descendants."""""" <TAB> if not no_iframe or not self. is_iframe ( el ) : <TAB> <TAB> next_good = None <TAB> <TAB> for child in el. descendants : <TAB> <TAB> <TAB> if next_good is not None : <TAB> <TAB> <TAB> <TAB> if child is not next_good : <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> next_good = None <TAB> <TAB> <TAB> is_tag = self. is_tag ( child ) <TAB> <TAB> <TAB> if no_iframe and is_tag and self. is_iframe ( child ) : <TAB> <TAB> <TAB> <TAB> if child. next_sibling is not None : <TAB> <TAB> <TAB> <TAB> <TAB> next_good = child. next_sibling <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> last_child = child <TAB> <TAB> <TAB> <TAB> <TAB> while self. is_tag ( last_child ) and last_child. contents : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> last_child = last_child. contents [ - 1 ] <TAB> <TAB> <TAB> <TAB> <TAB> next_good = last_child. next_element <TAB> <TAB> <TAB> <TAB> yield child <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if not tags or is_tag : <TAB> <TAB> <TAB> <TAB> yield child",False,next_good is None,next_good and tags,0.6640669107437134
|
||
|
899,"def resolve_name ( self, modname, parents, path, base ) : <TAB> if modname is None : <TAB> <TAB> if path : <TAB> <TAB> <TAB> mod_cls = path. rstrip ( ""."" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> mod_cls = None <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> mod_cls = self. env. temp_data. get ( ""autodoc:class"" ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if mod_cls is None : <TAB> <TAB> <TAB> <TAB> mod_cls = self. env. temp_data. get ( ""py:class"" ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if mod_cls is None : <TAB> <TAB> <TAB> <TAB> return None, [ ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> modname, accessor = rpartition ( mod_cls, ""."" ) <TAB> <TAB> modname, cls = rpartition ( modname, ""."" ) <TAB> <TAB> parents = [ cls, accessor ] <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> modname = self. env. temp_data. get ( ""autodoc:module"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if sphinx. __version__ > ""1.3"" : <TAB> <TAB> <TAB> <TAB> modname = self. env. ref_context. get ( ""py:module"" ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> modname = self. env. temp_data. get ( ""py:module"" ) <TAB> <TAB> <TAB> return modname, parents + [ base ]",False,not modname,sphinx.__version__ > '1.3',0.6826549768447876
|
||
|
900,"def create_fb_format ( data, dpath ) : <TAB> fw1 = open ( os. path. join ( dpath, ""train.txt"" ), ""w"" ) <TAB> fw2 = open ( os. path. join ( dpath, ""valid.txt"" ), ""w"" ) <TAB> fw3 = open ( os. path. join ( dpath, ""test.txt"" ), ""w"" ) <TAB> for i in range ( 0, len ( data ) - 1, 2 ) : <TAB> <TAB> fout = fw1 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> fout = fw2 <TAB> <TAB> elif ( i % 500 ) == 2 : <TAB> <TAB> <TAB> fout = fw3 <TAB> <TAB> use = True <TAB> <TAB> x = data [ i ]. rstrip ( "" "" ). lstrip ( "" "" ). replace ( ""\t"", "" "" ) <TAB> <TAB> y = data [ i + 1 ]. rstrip ( "" "" ). lstrip ( "" "" ). replace ( ""\t"", "" "" ) <TAB> <TAB> x = x. replace ( ""|"", "" __PIPE__ "" ) <TAB> <TAB> y = y. replace ( ""|"", "" __PIPE__ "" ) <TAB> <TAB> x = """". join ( list ( map ( replace_emoji, x ) ) ) <TAB> <TAB> y = """". join ( list ( map ( replace_emoji, y ) ) ) <TAB> <TAB> x = split_punctuation ( unidecode. unidecode ( x ) ) <TAB> <TAB> y = split_punctuation ( unidecode. unidecode ( y ) ) <TAB> <TAB> x = "" "". join ( x. split ( ) ) <TAB> <TAB> y = "" "". join ( y. split ( ) ) <TAB> <TAB> if len ( x ) < 1 or len ( y ) < 1 : <TAB> <TAB> <TAB> use = False <TAB> <TAB> if use : <TAB> <TAB> <TAB> s = ""text:"" + x + ""\tlabels:"" + y + ""\tepisode_done:True"" <TAB> <TAB",False,i % 500 == 0,i % 500,0.6705561876296997
|
||
|
901,"def get_commandline ( self ) : <TAB> if self. mm : <TAB> <TAB> <TAB> <TAB> proc_as = self. get_process_address_space ( ) <TAB> <TAB> if proc_as == None : <TAB> <TAB> <TAB> return """" <TAB> <TAB> <TAB> <TAB> start = self. mm. arg_start. v ( ) <TAB> <TAB> size_to_read = self. mm. arg_end - self. mm. arg_start <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> name = """" <TAB> <TAB> else : <TAB> <TAB> <TAB> argv = proc_as. read ( start, size_to_read ) <TAB> <TAB> <TAB> if argv : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> name = "" "". join ( argv. split ( ""\x00"" ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> name = """" <TAB> else : <TAB> <TAB> <TAB> <TAB> name = ""["" + self. comm + ""]"" <TAB> if len ( name ) > 1 and name [ - 1 ] == "" "" : <TAB> <TAB> name = name [ : - 1 ] <TAB> return name",False,size_to_read < 1 or size_to_read > 4096,size_to_read > 0,0.6515439748764038
|
||
|
902,"def _convert_dense_data ( <TAB> instances, <TAB> bin_inner_param : BinInnerParam, <TAB> bin_results : BinResults, <TAB> abnormal_list : list, <TAB> convert_type : str = ""bin_num"", ) : <TAB> instances = copy. deepcopy ( instances ) <TAB> features = instances. features <TAB> transform_cols_idx = bin_inner_param. transform_bin_indexes <TAB> split_points_dict = bin_results. all_split_points <TAB> for col_idx, col_value in enumerate ( features ) : <TAB> <TAB> if col_idx in transform_cols_idx : <TAB> <TAB> <TAB> if col_value in abnormal_list : <TAB> <TAB> <TAB> <TAB> features [ col_idx ] = col_value <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> col_name = bin_inner_param. header [ col_idx ] <TAB> <TAB> <TAB> split_points = split_points_dict [ col_name ] <TAB> <TAB> <TAB> bin_num = BaseBinning. get_bin_num ( col_value, split_points ) <TAB> <TAB> <TAB> if convert_type == ""bin_num"" : <TAB> <TAB> <TAB> <TAB> features [ col_idx ] = bin_num <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> col_results = bin_results. all_cols_results. get ( col_name ) <TAB> <TAB> <TAB> <TAB> woe_value = col_results. woe_array [ bin_num ] <TAB> <TAB> <TAB> <TAB> features [ col_idx ] = woe_value <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> features [ col_idx ] = col_value <TAB> instances. features = features <TAB> return instances",False,convert_type == 'woe',convert_type == 'bin_results',0.6594418287277222
|
||
|
903,"def refresh ( self, inicontents = None ) : <TAB> comment_count = 1 <TAB> unknown_count = 1 <TAB> curr_indent = """" <TAB> inicontents = inicontents or self. inicontents <TAB> inicontents = inicontents. strip ( os. linesep ) <TAB> if not inicontents : <TAB> <TAB> return <TAB> for opt in self : <TAB> <TAB> self. pop ( opt ) <TAB> for opt_str in inicontents. split ( os. linesep ) : <TAB> <TAB> <TAB> <TAB> com_match = COM_REGX. match ( opt_str ) <TAB> <TAB> if com_match : <TAB> <TAB> <TAB> name = ""#comment{0}"". format ( comment_count ) <TAB> <TAB> <TAB> self. com = com_match. group ( 1 ) <TAB> <TAB> <TAB> comment_count += 1 <TAB> <TAB> <TAB> self. update ( { name : opt_str } ) <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> indented_match = INDENTED_REGX. match ( opt_str ) <TAB> <TAB> if indented_match : <TAB> <TAB> <TAB> indent = indented_match. group ( 1 ). replace ( ""\t"", "" "" ) <TAB> <TAB> <TAB> if indent > curr_indent : <TAB> <TAB> <TAB> <TAB> options = list ( self ) <TAB> <TAB> <TAB> <TAB> if options : <TAB> <TAB> <TAB> <TAB> <TAB> prev_opt = options [ - 1 ] <TAB> <TAB> <TAB> <TAB> <TAB> value = self. get ( prev_opt ) <TAB> <TAB> <TAB> <TAB> <TAB> self. update ( { prev_opt : os. linesep. join ( ( value, opt_str ) ) } ) <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> opt_match = self. opt_regx. match ( opt_str ) <",False,opt_match,self.unknown_count == 1,0.6569211483001709
|
||
|
904,"def _GetCSVRow ( self, value ) : <TAB> row = [ ] <TAB> for type_info in value. __class__. type_infos : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> row. extend ( self. _GetCSVRow ( value. Get ( type_info. name ) ) ) <TAB> <TAB> elif isinstance ( type_info, rdf_structs. ProtoBinary ) : <TAB> <TAB> <TAB> row. append ( text. Asciify ( value. Get ( type_info. name ) ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> row. append ( str ( value. Get ( type_info. name ) ) ) <TAB> return row",False,"isinstance(type_info, rdf_structs.ProtoEmbedded)","isinstance(type_info, rdf_structs.ProtoTable)",0.6501303315162659
|
||
|
905,"def _parse_job ( output ) : <TAB> BSE_exitons_patt = re. compile ( <TAB> <TAB> r""^exiton \s+ (\d+) : \s+ ([\d.]+) \( \s+ ([-\d.]+) \) \s+ \|.* "", <TAB> <TAB> re. VERBOSE, <TAB> ) <TAB> end_patt = re. compile ( r""\s*program returned normally\s*"" ) <TAB> total_time_patt = re. compile ( r""\s*total \s+ time: \s+ ([\d.]+).*"", re. VERBOSE ) <TAB> BSE_results = { } <TAB> parse_BSE_results = False <TAB> parse_total_time = False <TAB> for l in output. split ( ""\n"" ) : <TAB> <TAB> if parse_total_time : <TAB> <TAB> <TAB> m = end_patt. search ( l ) <TAB> <TAB> <TAB> if m : <TAB> <TAB> <TAB> <TAB> BSE_results. update ( end_normally = True ) <TAB> <TAB> <TAB> m = total_time_patt. search ( l ) <TAB> <TAB> <TAB> if m : <TAB> <TAB> <TAB> <TAB> BSE_results. update ( total_time = m. group ( 1 ) ) <TAB> <TAB> if parse_BSE_results : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> parse_total_time = True <TAB> <TAB> <TAB> <TAB> parse_BSE_results = False <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> m = BSE_exitons_patt. search ( l ) <TAB> <TAB> <TAB> if m : <TAB> <TAB> <TAB> <TAB> d = { } <TAB> <TAB> <TAB> <TAB> d. update ( bse_eig = m. group ( 2 ), osc_strength = m. group ( 3 ) ) <TAB> <TAB> <TAB",False,l.find('FULL BSE main valence -> conduction transitions weight:') != -1,total_time,0.6527070999145508
|
||
|
906,"def _setSitemapTargets ( ) : <TAB> if not conf. sitemapUrl : <TAB> <TAB> return <TAB> infoMsg = ""parsing sitemap '%s'"" % conf. sitemapUrl <TAB> logger. info ( infoMsg ) <TAB> found = False <TAB> for item in parseSitemap ( conf. sitemapUrl ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> found = True <TAB> <TAB> <TAB> kb. targets. add ( ( item. strip ( ), None, None, None, None ) ) <TAB> if not found and not conf. forms and not conf. crawlDepth : <TAB> <TAB> warnMsg = ""no usable links found (with GET parameters)"" <TAB> <TAB> logger. warn ( warnMsg )",False,"re.match('[^ ]+\\?(.+)', item, re.I)",item.strip(),0.6478191614151001
|
||
|
907,def on_update ( self ) : <TAB> <TAB> <TAB> <TAB> self. max_per_well = 0 <TAB> for pd in list ( self. plate_well_site. values ( ) ) : <TAB> <TAB> for wd in list ( pd. values ( ) ) : <TAB> <TAB> <TAB> nplanes = sum ( [ len ( x ) for x in list ( wd. values ( ) ) ] ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. max_per_well = nplanes <TAB> for registrant in self. registrants : <TAB> <TAB> registrant ( ),True,nplanes > self.max_per_well,nplanes > self.max_per_well,0.6519075632095337
|
||
|
908,"def get_all_ns ( ) : <TAB> ns_set = [ ] <TAB> gridfs_ns_set = [ ] <TAB> db_list = self. namespace_config. get_included_databases ( ) <TAB> if not db_list : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> db_list = retry_until_ok ( self. primary_client. database_names ) <TAB> for database in db_list : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> coll_list = retry_until_ok ( self. primary_client [ database ]. collection_names ) <TAB> <TAB> for coll in coll_list : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if coll. startswith ( ""system."" ) : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if coll. endswith ( "".chunks"" ) : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if coll. endswith ( "".files"" ) : <TAB> <TAB> <TAB> <TAB> namespace = ""%s.%s"" % ( database, coll ) <TAB> <TAB> <TAB> <TAB> namespace = namespace [ : - len ( "".files"" ) ] <TAB> <TAB> <TAB> <TAB> if self. namespace_config. gridfs_namespace ( namespace ) : <TAB> <TAB> <TAB> <TAB> <TAB> gridfs_ns_set. append ( namespace ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> namespace = ""%s.%s"" % ( database, coll ) <TAB> <TAB> <TAB> <TAB> if self. namespace_config. map_namespace ( namespace ) : <TAB> <TAB> <TAB> <TAB> <TAB> ns_set. append ( namespace ) <TAB> return ns_set, gridfs_ns_set",False,database == 'config' or database == 'local',database not in self.primary_client,0.6518546342849731
|
||
|
909,"def parse_ec2_keys ( ) : <TAB> path = os. path. expanduser ( ""~/.ec2-keys"" ) <TAB> if os. path. isfile ( path ) : <TAB> <TAB> with open ( path, ""r"" ) as f : <TAB> <TAB> <TAB> contents = f. read ( ) <TAB> <TAB> <TAB> for l in contents. splitlines ( ) : <TAB> <TAB> <TAB> <TAB> l = l. split ( ""#"" ) [ 0 ] <TAB> <TAB> <TAB> <TAB> w = l. split ( ) <TAB> <TAB> <TAB> <TAB> if len ( w ) < 2 or len ( w ) > 3 : <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> if len ( w ) == 3 and w [ 2 ] == access_key_id : <TAB> <TAB> <TAB> <TAB> <TAB> return ( w [ 0 ], w [ 1 ] ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> return ( access_key_id, w [ 1 ] ) <TAB> return None",False,w[0] == access_key_id,len(w) == 2,0.6499176025390625
|
||
|
910,"def EnsureTempDirIsSane ( directory ) : <TAB> """"""Checks that the directory exists and has the correct permissions set."""""" <TAB> if not os. path. isabs ( directory ) : <TAB> <TAB> raise ErrorBadPath ( ""Directory %s is not absolute"" % directory ) <TAB> if os. path. isdir ( directory ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if not client_utils. VerifyFileOwner ( directory ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> shutil. rmtree ( directory ) <TAB> if not os. path. isdir ( directory ) : <TAB> <TAB> os. makedirs ( directory ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> from grr_response_client import ( <TAB> <TAB> <TAB> <TAB> client_utils_windows, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> client_utils_windows. WinChmod ( <TAB> <TAB> <TAB> <TAB> directory, [ ""FILE_GENERIC_READ"", ""FILE_GENERIC_WRITE"" ] <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> os. chmod ( directory, stat. S_IXUSR | stat. S_IRUSR | stat. S_IWUSR )",False,sys.platform == 'win32',os.path.isfile(directory),0.660055935382843
|
||
|
911,"def __getitem__ ( self, index ) : <TAB> if isinstance ( index, slice ) : <TAB> <TAB> if index. step is not None and index. step!= 1 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return pdeque ( tuple ( self ) [ index ], maxlen = self. _maxlen ) <TAB> <TAB> result = self <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> result = result. popleft ( index. start % self. _length ) <TAB> <TAB> if index. stop is not None : <TAB> <TAB> <TAB> result = result. pop ( self. _length - ( index. stop % self. _length ) ) <TAB> <TAB> return result <TAB> if not isinstance ( index, Integral ) : <TAB> <TAB> raise TypeError ( <TAB> <TAB> <TAB> ""'%s' object cannot be interpreted as an index"" % type ( index ). __name__ <TAB> <TAB> ) <TAB> if index >= 0 : <TAB> <TAB> return self. popleft ( index ). left <TAB> shifted = len ( self ) + index <TAB> if shifted < 0 : <TAB> <TAB> raise IndexError ( <TAB> <TAB> <TAB> ""pdeque index {0} out of range {1}"". format ( index, len ( self ) ), <TAB> <TAB> ) <TAB> return self. popleft ( shifted ). left",True,index.start is not None,index.start is not None,0.6576463580131531
|
||
|
912,"def send_response ( <TAB> client : BaseSocketModeClient, <TAB> req : SocketModeRequest, <TAB> bolt_resp : BoltResponse, <TAB> start_time : float, ) : <TAB> if bolt_resp. status == 200 : <TAB> <TAB> content_type = bolt_resp. headers. get ( ""content-type"", [ """" ] ) [ 0 ] <TAB> <TAB> if bolt_resp. body is None or len ( bolt_resp. body ) == 0 : <TAB> <TAB> <TAB> client. send_socket_mode_response ( <TAB> <TAB> <TAB> <TAB> SocketModeResponse ( envelope_id = req. envelope_id ) <TAB> <TAB> <TAB> ) <TAB> <TAB> elif content_type. startswith ( ""application/json"" ) : <TAB> <TAB> <TAB> dict_body = json. loads ( bolt_resp. body ) <TAB> <TAB> <TAB> client. send_socket_mode_response ( <TAB> <TAB> <TAB> <TAB> SocketModeResponse ( envelope_id = req. envelope_id, payload = dict_body ) <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> client. send_socket_mode_response ( <TAB> <TAB> <TAB> <TAB> SocketModeResponse ( <TAB> <TAB> <TAB> <TAB> <TAB> envelope_id = req. envelope_id, payload = { ""text"" : bolt_resp. body } <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> spent_time = int ( ( time ( ) - start_time ) * 1000 ) <TAB> <TAB> <TAB> client. logger. debug ( f""Response time: {spent_time} milliseconds"" ) <TAB> else : <TAB> <TAB> client. logger. info ( <TAB> <TAB> <TAB> f""Unsuccessful Bolt execution result (status: {bolt_resp.status}, body: {bolt_resp.body})"" <TAB> <TAB> )",False,client.logger.level <= logging.DEBUG,start_time is not None,0.6523712873458862
|
||
|
913,"def sdl_audio_load ( snd, fn = None, reload = False ) : <TAB> global _sdl_audio_sounds, _libsdl, _libsdl_mixer <TAB> if snd not in _sdl_audio_sounds or reload : <TAB> <TAB> sdl_audio_init ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> _libsdl_mixer. Mix_FreeChunk ( _sdl_audio_sounds [ snd ] ) <TAB> <TAB> rw = _libsdl. SDL_RWFromFile ( fn, ""rb"" ) <TAB> <TAB> _sdl_audio_sounds [ snd ] = _libsdl_mixer. Mix_LoadWAV_RW ( rw, 1 )",False,snd in _sdl_audio_sounds,fn is not None,0.6603587865829468
|
||
|
914,"def _get_qnames_to_try ( self, qname, search ) : <TAB> <TAB> <TAB> if search is None : <TAB> <TAB> search = self. use_search_by_default <TAB> qnames_to_try = [ ] <TAB> if qname. is_absolute ( ) : <TAB> <TAB> qnames_to_try. append ( qname ) <TAB> else : <TAB> <TAB> abs_qname = qname. concatenate ( dns. name. root ) <TAB> <TAB> if search : <TAB> <TAB> <TAB> if len ( self. search ) > 0 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> search_list = self. search [ : ] <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> search_list = [ self. domain ] <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> search_list = [ ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if self. ndots is None : <TAB> <TAB> <TAB> <TAB> ndots = 1 <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> ndots = self. ndots <TAB> <TAB> <TAB> for suffix in search_list : <TAB> <TAB> <TAB> <TAB> qnames_to_try. append ( qname + suffix ) <TAB> <TAB> <TAB> if len ( qname ) > ndots : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> qnames_to_try. insert ( 0, abs_qname ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> qnames_to_try. append ( abs_qname ) <TAB",False,self.domain != dns.name.root and self.domain is not None,self.domain is not None,0.652694821357727
|
||
|
915,"def __init__ ( self, path, localtrack_folder, ** kwargs ) : <TAB> self. _localtrack_folder = localtrack_folder <TAB> self. _path = path <TAB> if isinstance ( path, ( Path, WindowsPath, PosixPath, LocalPath ) ) : <TAB> <TAB> path = str ( path. absolute ( ) ) <TAB> elif path is not None : <TAB> <TAB> path = str ( path ) <TAB> self. cwd = Path. cwd ( ) <TAB> _lt_folder = Path ( self. _localtrack_folder ) if self. _localtrack_folder else self. cwd <TAB> _path = Path ( path ) if path else self. cwd <TAB> if _lt_folder. parts [ - 1 ]. lower ( ) == ""localtracks"" and not kwargs. get ( ""forced"" ) : <TAB> <TAB> self. localtrack_folder = _lt_folder <TAB> elif kwargs. get ( ""forced"" ) : <TAB> <TAB> if _path. parts [ - 1 ]. lower ( ) == ""localtracks"" : <TAB> <TAB> <TAB> self. localtrack_folder = _path <TAB> <TAB> else : <TAB> <TAB> <TAB> self. localtrack_folder = _path / ""localtracks"" <TAB> else : <TAB> <TAB> self. localtrack_folder = _lt_folder / ""localtracks"" <TAB> try : <TAB> <TAB> _path = Path ( path ) <TAB> <TAB> _path. relative_to ( self. localtrack_folder ) <TAB> <TAB> self. path = _path <TAB> except ( ValueError, TypeError ) : <TAB> <TAB> for sep in _PATH_SEPS : <TAB> <TAB> <TAB> if path and path. startswith ( f""localtracks{sep}{sep}"" ) : <TAB> <TAB> <TAB> <TAB> path = path. replace ( f""localtracks{sep}{sep}"", """", 1 ) <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> path = path. replace ( f""localtracks{sep}"", """", 1 ) <TAB> <TAB> self. path",True,path and path.startswith(f'localtracks{sep}'),path and path.startswith(f'localtracks{sep}'),0.6505128145217896
|
||
|
916,"def setup ( self ) : <TAB> self. _pre_setup ( ) <TAB> logs. log ( ""Retrieving symbolized build r%d."" % self. revision ) <TAB> build_update = not self. exists ( ) <TAB> if build_update : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return False <TAB> <TAB> logs. log ( ""Retrieved symbolized build r%d."" % self. revision ) <TAB> else : <TAB> <TAB> logs. log ( ""Build already exists."" ) <TAB> if self. release_build_url : <TAB> <TAB> self. _setup_application_path ( self. release_build_dir, build_update = build_update ) <TAB> <TAB> environment. set_value ( ""BUILD_URL"", self. release_build_url ) <TAB> if self. debug_build_url : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _setup_application_path ( <TAB> <TAB> <TAB> self. debug_build_dir, ""APP_PATH_DEBUG"", build_update = build_update <TAB> <TAB> ) <TAB> self. _post_setup_success ( update_revision = build_update ) <TAB> return True",False,not self._unpack_builds(),self.exists(),0.6584277153015137
|
||
|
917,"def check_seed_limits ( self, torrent, session ) : <TAB> seed_limit_ok = True <TAB> idle_limit_ok = True <TAB> if torrent. seedRatioMode == 1 : <TAB> <TAB> seed_limit_ok = torrent. uploadRatio >= torrent. seedRatioLimit <TAB> elif torrent. seedRatioMode == 0 : <TAB> <TAB> if session. seedRatioLimited : <TAB> <TAB> <TAB> seed_limit_ok = torrent. uploadRatio >= session. seedRatioLimit <TAB> if torrent. seedIdleMode == 1 : <TAB> <TAB> idle_limit_ok = ( <TAB> <TAB> <TAB> torrent. date_active + timedelta ( minutes = torrent. seedIdleLimit ) <TAB> <TAB> <TAB> < datetime. now ( ) <TAB> <TAB> ) <TAB> elif torrent. seedIdleMode == 0 : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> idle_limit_ok = ( <TAB> <TAB> <TAB> <TAB> torrent. date_active + timedelta ( minutes = session. idle_seeding_limit ) <TAB> <TAB> <TAB> <TAB> < datetime. now ( ) <TAB> <TAB> <TAB> ) <TAB> return seed_limit_ok, idle_limit_ok",False,session.idle_seeding_limit_enabled,session.idle_seeding_limit,0.6527003049850464
|
||
|
918,"def content ( self, val ) : <TAB> """"""Set content"""""" <TAB> soup = BeautifulSoup ( val ) <TAB> for todo in soup. findAll ( ""en-todo"" ) : <TAB> <TAB> todo. name = ""input"" <TAB> <TAB> todo [ ""type"" ] = ""checkbox"" <TAB> <TAB> if todo. get ( ""checked"" ) == ""false"" : <TAB> <TAB> <TAB> del todo [ ""checked"" ] <TAB> <TAB> self. changed_by_default = True <TAB> for media in soup. findAll ( ""en-media"" ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> media. name = ""img"" <TAB> <TAB> <TAB> res = self. parent. resource_edit. get_by_hash ( media [ ""hash"" ] ) <TAB> <TAB> <TAB> if res : <TAB> <TAB> <TAB> <TAB> if media [ ""type"" ]. find ( ""image"" ) == 0 : <TAB> <TAB> <TAB> <TAB> <TAB> media [ ""src"" ] = ""file://%s"" % res. file_path <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> media [ ""src"" ] = file_icon_path <TAB> <TAB> <TAB> <TAB> media [ ""title"" ] = res. file_name <TAB> <TAB> <TAB> <TAB> res. in_content = True <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> tag = Tag ( soup, ""a"", [ ( ""href"", ""file://%s"" % res. file_path ) ] ) <TAB> <TAB> <TAB> <TAB> media. replaceWith ( tag ) <TAB> <TAB> <TAB> <TAB> tag. insert ( 0, media ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> media [ ""src"" ] = """" <TAB> <TAB> <TAB> <TAB> media [ ""title"" ] = """" <TAB> <TAB> else : <TAB> <TAB>",False,media.get('hash'),media[0],0.6525328159332275
|
||
|
919,"def apply ( self, db, person ) : <TAB> families = person. get_parent_family_handle_list ( ) <TAB> if families == [ ] : <TAB> <TAB> return True <TAB> for family_handle in person. get_parent_family_handle_list ( ) : <TAB> <TAB> family = db. get_family_from_handle ( family_handle ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> father_handle = family. get_father_handle ( ) <TAB> <TAB> <TAB> mother_handle = family. get_mother_handle ( ) <TAB> <TAB> <TAB> if not father_handle : <TAB> <TAB> <TAB> <TAB> return True <TAB> <TAB> <TAB> if not mother_handle : <TAB> <TAB> <TAB> <TAB> return True <TAB> return False",True,family,family,0.6950480937957764
|
||
|
920,"def _flatten_keywords ( self, context, flattened ) : <TAB> match = FlattenKeywordMatcher ( flattened ). match <TAB> started = - 1 <TAB> for event, elem in context : <TAB> <TAB> tag = elem. tag <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if started >= 0 : <TAB> <TAB> <TAB> <TAB> started += 1 <TAB> <TAB> <TAB> elif match ( elem. get ( ""name"" ), elem. get ( ""type"" ) ) : <TAB> <TAB> <TAB> <TAB> started = 0 <TAB> <TAB> if started == 0 and event == ""end"" and tag == ""doc"" : <TAB> <TAB> <TAB> elem. text = ( <TAB> <TAB> <TAB> <TAB> ""%s\n\n_*Keyword content flattened.*_"" % ( elem. text or """" ) <TAB> <TAB> <TAB> ). strip ( ) <TAB> <TAB> if started <= 0 or tag == ""msg"" : <TAB> <TAB> <TAB> yield event, elem <TAB> <TAB> else : <TAB> <TAB> <TAB> elem. clear ( ) <TAB> <TAB> if started >= 0 and event == ""end"" and tag == ""kw"" : <TAB> <TAB> <TAB> started -= 1",False,event == 'start' and tag == 'kw',tag == 'kw',0.6539344787597656
|
||
|
921,"def _skip_start ( self ) : <TAB> start, stop = self. start, self. stop <TAB> for chunk in self. app_iter : <TAB> <TAB> self. _pos += len ( chunk ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> elif self. _pos == start : <TAB> <TAB> <TAB> return b"""" <TAB> <TAB> else : <TAB> <TAB> <TAB> chunk = chunk [ start - self. _pos : ] <TAB> <TAB> <TAB> if stop is not None and self. _pos > stop : <TAB> <TAB> <TAB> <TAB> chunk = chunk [ : stop - self. _pos ] <TAB> <TAB> <TAB> <TAB> assert len ( chunk ) == stop - start <TAB> <TAB> <TAB> return chunk <TAB> else : <TAB> <TAB> raise StopIteration ( )",False,self._pos < start,self._pos == stop,0.6676946878433228
|
||
|
922,"def _train_by_any_executor ( self, event_handler, exe, num_epochs, reader ) : <TAB> if self. checkpoint_cfg : <TAB> <TAB> epochs = [ <TAB> <TAB> <TAB> epoch_id <TAB> <TAB> <TAB> for epoch_id in range ( num_epochs ) <TAB> <TAB> <TAB> if epoch_id >= self. checkpoint_cfg. epoch_id <TAB> <TAB> ] <TAB> else : <TAB> <TAB> epochs = [ epoch_id for epoch_id in range ( num_epochs ) ] <TAB> for epoch_id in epochs : <TAB> <TAB> event_handler ( BeginEpochEvent ( epoch_id ) ) <TAB> <TAB> for step_id, data in enumerate ( reader ( ) ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> if self. checkpoint_cfg : <TAB> <TAB> <TAB> <TAB> <TAB> self. _clean_checkpoint ( ) <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> if ( <TAB> <TAB> <TAB> <TAB> self. checkpoint_cfg <TAB> <TAB> <TAB> <TAB> and self. checkpoint_cfg. load_serial <TAB> <TAB> <TAB> <TAB> and self. checkpoint_cfg. step_id >= step_id <TAB> <TAB> <TAB> <TAB> and self. checkpoint_cfg. epoch_id == epoch_id <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> begin_event = BeginStepEvent ( epoch_id, step_id ) <TAB> <TAB> <TAB> event_handler ( begin_event ) <TAB> <TAB> <TAB> if begin_event. fetch_metrics : <TAB> <TAB> <TAB> <TAB> metrics = exe. run ( <TAB> <TAB> <TAB> <TAB> <TAB> feed = data, fetch_list = [ var. name for var in self. train_func_outputs ] <TAB> <TAB> <TAB> <TAB> ) <TAB> <",False,self.__stop,step_id >= 0,0.6690965294837952
|
||
|
923,"def process_logs_and_crash ( self, artifact_prefix ) : <TAB> """"""Fetch symbolized logs and crashes."""""" <TAB> if not artifact_prefix : <TAB> <TAB> return <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> crash_location_regex = r""(.*)(Test unit written to )(data/.*)"" <TAB> _, processed_log_path = tempfile. mkstemp ( ) <TAB> with open ( processed_log_path, mode = ""w"", encoding = ""utf-8"" ) as new_file : <TAB> <TAB> with open ( self. fuzzer. logfile, encoding = ""utf-8"", errors = ""ignore"" ) as old_file : <TAB> <TAB> <TAB> for line in old_file : <TAB> <TAB> <TAB> <TAB> line_match = re. match ( crash_location_regex, line ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> crash_name = line_match. group ( 3 ). replace ( ""data/"", """" ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. device. fetch ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. fuzzer. data_path ( crash_name ), artifact_prefix <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> crash_testcase_file_path = os. path. join ( artifact_prefix, crash_name ) <TAB> <TAB> <TAB> <TAB> <TAB> line = re. sub ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> crash_location_regex, r""\1\2"" + crash_testcase_file_path, line <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> new_file",True,line_match,line_match,0.6560198068618774
|
||
|
924,"def test_is_power_of_k ( self ) : <TAB> f = mathutil. is_power_of_k <TAB> for i in range ( 1, 100 ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. failUnless ( f ( i, 2 ), ""but %d *is* a power of 2"" % i ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. failIf ( f ( i, 2 ), ""but %d is *not* a power of 2"" % i ) <TAB> for i in range ( 1, 100 ) : <TAB> <TAB> if i in ( 1, 3, 9, 27, 81 ) : <TAB> <TAB> <TAB> self. failUnless ( f ( i, 3 ), ""but %d *is* a power of 3"" % i ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. failIf ( f ( i, 3 ), ""but %d is *not* a power of 3"" % i )",False,"i in (1, 2, 4, 8, 16, 32, 64)","i in (1, 2, 9, 27, 81)",0.6488779783248901
|
||
|
925,"def extract_certs ( srvs ) : <TAB> res = [ ] <TAB> for srv in srvs : <TAB> <TAB> if ""key_descriptor"" in srv : <TAB> <TAB> <TAB> for key in srv [ ""key_descriptor"" ] : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> for dat in key [ ""key_info"" ] [ ""x509_data"" ] : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> cert = repack_cert ( dat [ ""x509_certificate"" ] [ ""text"" ] ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if cert not in res : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> res. append ( cert ) <TAB> <TAB> <TAB> <TAB> elif not ""use"" in key : <TAB> <TAB> <TAB> <TAB> <TAB> for dat in key [ ""key_info"" ] [ ""x509_data"" ] : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> cert = repack_cert ( dat [ ""x509_certificate"" ] [ ""text"" ] ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if cert not in res : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> res. append ( cert ) <TAB> return res",False,'use' in key and key['use'] == use,key in key,0.65516197681427
|
||
|
926,"def narrow_declared_type ( declared : Type, narrowed : Type ) -> Type : <TAB> """"""Return the declared type narrowed down to another type."""""" <TAB> <TAB> declared = get_proper_type ( declared ) <TAB> narrowed = get_proper_type ( narrowed ) <TAB> if declared == narrowed : <TAB> <TAB> return declared <TAB> if isinstance ( declared, UnionType ) : <TAB> <TAB> return make_simplified_union ( <TAB> <TAB> <TAB> [ narrow_declared_type ( x, narrowed ) for x in declared. relevant_items ( ) ] <TAB> <TAB> ) <TAB> elif not is_overlapping_types ( <TAB> <TAB> declared, narrowed, prohibit_none_typevar_overlap = True <TAB> ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return UninhabitedType ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return NoneType ( ) <TAB> elif isinstance ( narrowed, UnionType ) : <TAB> <TAB> return make_simplified_union ( <TAB> <TAB> <TAB> [ narrow_declared_type ( declared, x ) for x in narrowed. relevant_items ( ) ] <TAB> <TAB> ) <TAB> elif isinstance ( narrowed, AnyType ) : <TAB> <TAB> return narrowed <TAB> elif isinstance ( declared, TypeType ) and isinstance ( narrowed, TypeType ) : <TAB> <TAB> return TypeType. make_normalized ( <TAB> <TAB> <TAB> narrow_declared_type ( declared. item, narrowed. item ) <TAB> <TAB> ) <TAB> elif isinstance ( declared, ( Instance, TupleType, TypeType, LiteralType ) ) : <TAB> <TAB> return meet_types ( declared, narrowed ) <TAB> elif isinstance ( declared, TypedDictType ) and isinstance ( narrowed, Instance ) : <TAB> <TAB> <TAB> <TAB> if narrowed. type. fullname == ""builtins.dict"" and all ( <TAB> <TAB> <TAB> isinstance ( t, AnyType ) for t in get_proper_types ( narrowed. args ) <",False,state.strict_optional,"isinstance(declared, UninhabitedType)",0.6519722938537598
|
||
|
927,"def handle ( self ) : <TAB> from poetry. utils. env import EnvManager <TAB> manager = EnvManager ( self. poetry ) <TAB> current_env = manager. get ( ) <TAB> for venv in manager. list ( ) : <TAB> <TAB> name = venv. path. name <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> name = str ( venv. path ) <TAB> <TAB> if venv == current_env : <TAB> <TAB> <TAB> self. line ( ""<info>{} (Activated)</info>"". format ( name ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> self. line ( name )",False,self.option('full-path'),name == '',0.6458825469017029
|
||
|
928,"def _iter_fields ( self ) : <TAB> _fields = self. fields <TAB> if hasattr ( self. fields, ""items"" ) : <TAB> <TAB> _fields = list ( self. fields. items ( ) ) <TAB> for k, v in _fields : <TAB> <TAB> file_name = None <TAB> <TAB> file_type = None <TAB> <TAB> file_headers = None <TAB> <TAB> if isinstance ( v, ( list, tuple ) ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> file_name, file_pointer = v <TAB> <TAB> <TAB> elif len ( v ) == 3 : <TAB> <TAB> <TAB> <TAB> file_name, file_pointer, file_type = v <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> file_name, file_pointer, file_type, file_headers = v <TAB> <TAB> else : <TAB> <TAB> <TAB> file_pointer = v <TAB> <TAB> field = fields. RequestField ( <TAB> <TAB> <TAB> name = k, data = file_pointer, filename = file_name, headers = file_headers <TAB> <TAB> ) <TAB> <TAB> field. make_multipart ( content_type = file_type ) <TAB> <TAB> yield field",False,len(v) == 2,len(v) == 4,0.6548320651054382
|
||
|
929,"def run ( self ) : <TAB> <TAB> if not self. __credentials : <TAB> <TAB> raise AnalyzerRunException ( ""no credentials retrieved"" ) <TAB> split_credentials = self. __credentials. split ( ""|"" ) <TAB> if len ( split_credentials )!= 2 : <TAB> <TAB> raise AnalyzerRunException ( <TAB> <TAB> <TAB> ""CIRCL credentials not properly configured."" <TAB> <TAB> <TAB> ""Template to use: '<user>|<pwd>'"" <TAB> <TAB> ) <TAB> user = split_credentials [ 0 ] <TAB> pwd = split_credentials [ 1 ] <TAB> pssl = pypssl. PyPSSL ( basic_auth = ( user, pwd ) ) <TAB> result = pssl. query ( self. observable_name ) <TAB> certificates = [ ] <TAB> if result. get ( self. observable_name, { } ) : <TAB> <TAB> certificates = list ( result. get ( self. observable_name ). get ( ""certificates"", [ ] ) ) <TAB> parsed_result = { ""ip"" : self. observable_name, ""certificates"" : [ ] } <TAB> for cert in certificates : <TAB> <TAB> subject = ( <TAB> <TAB> <TAB> result. get ( self. observable_name ) <TAB> <TAB> <TAB>. get ( ""subjects"", { } ) <TAB> <TAB> <TAB>. get ( cert, { } ) <TAB> <TAB> <TAB>. get ( ""values"", [ ] ) <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> parsed_result [ ""certificates"" ]. append ( <TAB> <TAB> <TAB> <TAB> { ""fingerprint"" : cert, ""subject"" : subject [ 0 ] } <TAB> <TAB> <TAB> ) <TAB> return parsed_result",False,subject,len(parsed_result) > 0,0.7046061754226685
|
||
|
930,"def _populate_cache_dir ( self ) -> None : <TAB> if self. stage_cache is None : <TAB> <TAB> return <TAB> <TAB> cache_etc_apt_path = Path ( self. stage_cache, ""etc"", ""apt"" ) <TAB> if not cache_etc_apt_path. exists ( ) : <TAB> <TAB> cache_etc_apt_path. parent. mkdir ( parents = True, exist_ok = True ) <TAB> <TAB> os. symlink ( Path ( ""/etc/apt"" ), cache_etc_apt_path ) <TAB> <TAB> <TAB> dpkg_path = shutil. which ( ""dpkg"" ) <TAB> if dpkg_path : <TAB> <TAB> <TAB> <TAB> destination = Path ( self. stage_cache, dpkg_path [ 1 : ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> destination. parent. mkdir ( parents = True, exist_ok = True ) <TAB> <TAB> <TAB> os. symlink ( dpkg_path, destination ) <TAB> else : <TAB> <TAB> logger. warning ( ""Cannot find 'dpkg' command needed to support multiarch"" )",False,not destination.exists(),destination.exists(),0.655684232711792
|
||
|
931,"def number_operators ( self, a, b, skip = [ ] ) : <TAB> dict = { ""a"" : a, ""b"" : b } <TAB> for name, expr in self. binops. items ( ) : <TAB> <TAB> if name not in skip : <TAB> <TAB> <TAB> name = ""__%s__"" % name <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> res = eval ( expr, dict ) <TAB> <TAB> <TAB> <TAB> self. binop_test ( a, b, res, expr, name ) <TAB> for name, expr in self. unops. items ( ) : <TAB> <TAB> if name not in skip : <TAB> <TAB> <TAB> name = ""__%s__"" % name <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> res = eval ( expr, dict ) <TAB> <TAB> <TAB> <TAB> self. unop_test ( a, res, expr, name )",False,"hasattr(a, name)",a and b,0.6512517929077148
|
||
|
932,"def compose ( self, keys = None ) : <TAB> composes = [ ] <TAB> explored = set ( ) <TAB> keys = set ( keys or [ ] ) <TAB> graph = self. _graph <TAB> for v in graph. topological_iter ( ) : <TAB> <TAB> if v. op. gpu or v. op. sparse : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return [ ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> if v in explored or type ( v. op ) in REDUCTION_OP : <TAB> <TAB> <TAB> continue <TAB> <TAB> if graph. count_successors ( v )!= 1 : <TAB> <TAB> <TAB> continue <TAB> <TAB> selected = [ v ] <TAB> <TAB> <TAB> <TAB> cur_node = graph. successors ( v ) [ 0 ] <TAB> <TAB> while ( <TAB> <TAB> <TAB> graph. count_predecessors ( cur_node ) == 1 <TAB> <TAB> <TAB> and _support ( cur_node ) <TAB> <TAB> <TAB> and cur_node. key not in keys <TAB> <TAB> ) : <TAB> <TAB> <TAB> selected. append ( cur_node ) <TAB> <TAB> <TAB> if ( <TAB> <TAB> <TAB> <TAB> graph. count_successors ( cur_node )!= 1 <TAB> <TAB> <TAB> <TAB> or type ( cur_node. op ) in REDUCTION_OP <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> cur_node = graph. successors ( cur_node ) [ 0 ] <TAB> <TAB> if len ( selected ) > 1 : <TAB> <TAB> <TAB> explored. update ( selected ) <TAB> <TAB> <TAB> composes. append ( list ( selected ) ) <TAB> return self. _compose_graph ( composes )",False,type(v.op) not in SUPPORT_OP or v.key in keys,v.op.gpu and v.op.sparse,0.6524445414543152
|
||
|
933,"def unpack_namespace_single ( self, var_obj, in_vector, in_scalar ) : <TAB> code = [ ] <TAB> if isinstance ( var_obj, ArrayVariable ) : <TAB> <TAB> array_name = self. generator. get_array_name ( var_obj ) <TAB> <TAB> dtype = self. c_data_type ( var_obj. dtype ) <TAB> <TAB> if in_vector : <TAB> <TAB> <TAB> code += [ <TAB> <TAB> <TAB> <TAB> ( <TAB> <TAB> <TAB> <TAB> <TAB> ""_GSL_dataholder.{array} = <{dtype} *> "" <TAB> <TAB> <TAB> <TAB> <TAB> ""_buf_{array}.data"". format ( array = array_name, dtype = dtype ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> code += [ <TAB> <TAB> <TAB> <TAB> ( <TAB> <TAB> <TAB> <TAB> <TAB> ""{array} = <{dtype} *> "" <TAB> <TAB> <TAB> <TAB> <TAB> ""_buf_{array}.data"". format ( array = array_name, dtype = dtype ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ] <TAB> else : <TAB> <TAB> if in_vector : <TAB> <TAB> <TAB> code += [ <TAB> <TAB> <TAB> <TAB> '_GSL_dataholder.{var} = _namespace[""{var}""]'. format ( var = var_obj. name ) <TAB> <TAB> <TAB> ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> code += [ '{var} = _namespace[""{var}""]'. format ( var = var_obj. name ) ] <TAB> return ""\n"". join ( code )",True,in_scalar,in_scalar,0.6746989488601685
|
||
|
934,"def get_ami_list_from_ec2 ( main_region, regions, owner, credentials, filters ) : <TAB> """"""Get the AMI mappings structure given the constraints represented by the args."""""" <TAB> amis_json = get_initialized_mappings_dicts ( ) <TAB> for region_name in regions : <TAB> <TAB> images_for_region = get_images_ec2 ( filters, owner, region_name ) <TAB> <TAB> for architecture, mapping_name in ARCHITECTURES_TO_MAPPING_NAME. items ( ) : <TAB> <TAB> <TAB> amis_json [ mapping_name ] [ region_name ] = get_amis_for_architecture ( <TAB> <TAB> <TAB> <TAB> images_for_region, architecture <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> for credential in credentials : <TAB> <TAB> <TAB> <TAB> <TAB> credential_region = credential [ 0 ] <TAB> <TAB> <TAB> <TAB> <TAB> images_for_credential_region = get_images_ec2_credential ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> filters, main_region, credential <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> amis_json [ mapping_name ] [ <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> credential_region <TAB> <TAB> <TAB> <TAB> <TAB> ] = get_amis_for_architecture ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> images_for_credential_region, architecture <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> return amis_json",False,main_region == region_name,credentials,0.6523140668869019
|
||
|
935,"def serialize ( self ) : <TAB> data = { } <TAB> if self. size : <TAB> <TAB> data [ ""size"" ] = self. size <TAB> if self. order : <TAB> <TAB> if self. order not in self. ORDER_VALUES : <TAB> <TAB> <TAB> raise RuntimeError ( ""Invalid order value:%s"" % self. order ) <TAB> <TAB> data [ ""order"" ] = self. order <TAB> if self. key_field : <TAB> <TAB> data [ ""key_field"" ] = self. key_field <TAB> <TAB> if self. value_field : <TAB> <TAB> <TAB> data [ ""value_field"" ] = self. value_field <TAB> <TAB> else : <TAB> <TAB> <TAB> raise RuntimeError ( ""Invalid key_field: value_field required"" ) <TAB> elif self. key_script : <TAB> <TAB> data [ ""key_script"" ] = self. key_script <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> data [ ""value_script"" ] = self. value_script <TAB> <TAB> else : <TAB> <TAB> <TAB> raise RuntimeError ( ""Invalid key_script: value_script required"" ) <TAB> <TAB> if self. params : <TAB> <TAB> <TAB> data [ ""params"" ] = self. params <TAB> params = self. _base_parameters ( ) <TAB> params [ self. _internal_name ] = data <TAB> return { self. name : params }",True,self.value_script,self.value_script,0.6631819009780884
|
||
|
936,"def _update_tileable_and_chunk_shape ( self, tileable_graph, chunk_result, failed_ops ) : <TAB> for n in tileable_graph : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> tiled_n = get_tiled ( n ) <TAB> <TAB> if has_unknown_shape ( tiled_n ) : <TAB> <TAB> <TAB> if any ( c. key not in chunk_result for c in tiled_n. chunks ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> new_nsplits = self. get_tileable_nsplits ( n, chunk_result = chunk_result ) <TAB> <TAB> <TAB> for node in ( n, tiled_n ) : <TAB> <TAB> <TAB> <TAB> node. _update_shape ( tuple ( sum ( nsplit ) for nsplit in new_nsplits ) ) <TAB> <TAB> <TAB> tiled_n. _nsplits = new_nsplits",False,n.op in failed_ops,n in failed_ops,0.6544344425201416
|
||
|
937,"def i2repr ( self, pkt, x ) : <TAB> s = [ ] <TAB> for v in x : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if v [ 0 ] in DHCPRevOptions and isinstance ( DHCPRevOptions [ v [ 0 ] ] [ 1 ], Field ) : <TAB> <TAB> <TAB> <TAB> f = DHCPRevOptions [ v [ 0 ] ] [ 1 ] <TAB> <TAB> <TAB> <TAB> vv = "","". join ( f. i2repr ( pkt, val ) for val in v [ 1 : ] ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> vv = "","". join ( repr ( val ) for val in v [ 1 : ] ) <TAB> <TAB> <TAB> r = ""%s=%s"" % ( v [ 0 ], vv ) <TAB> <TAB> <TAB> s. append ( r ) <TAB> <TAB> else : <TAB> <TAB> <TAB> s. append ( sane ( v ) ) <TAB> return ""[%s]"" % ( "" "". join ( s ) )",False,type(v) is tuple and len(v) >= 2,v,0.6507476568222046
|
||
|
938,"def h2i ( self, pkt, s ) : <TAB> t = ( ) <TAB> if type ( s ) is str : <TAB> <TAB> t = time. strptime ( s ) <TAB> <TAB> t = t [ : 2 ] + t [ 2 : - 3 ] <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> y, m, d, h, min, sec, rest, rest, rest = time. gmtime ( time. time ( ) ) <TAB> <TAB> <TAB> t = ( y, m, d, h, min, sec ) <TAB> <TAB> else : <TAB> <TAB> <TAB> t = s <TAB> return t",False,not s,pkt is not None,0.6916464567184448
|
||
|
939,"def handle ( self, input ) : <TAB> raw_query = OrderedDict ( { } ) <TAB> if ( input is not None ) and ( input. has_key ( ""op"" ) ) : <TAB> <TAB> if input [ ""op"" ] == ""insert"" : <TAB> <TAB> <TAB> return None <TAB> <TAB> elif input [ ""op"" ] == ""query"" : <TAB> <TAB> <TAB> if input [ ""query"" ]. has_key ( ""$query"" ) : <TAB> <TAB> <TAB> <TAB> raw_query [ ""query"" ] = input [ ""query"" ] [ ""$query"" ] <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> orderby = input [ ""query"" ] [ ""$orderby"" ] <TAB> <TAB> <TAB> <TAB> <TAB> raw_query [ ""orderby"" ] = orderby <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> raw_query [ ""query"" ] = input [ ""query"" ] <TAB> <TAB> <TAB> raw_query [ ""millis"" ] = input [ ""millis"" ] <TAB> <TAB> <TAB> raw_query [ ""ns"" ] = input [ ""ns"" ] <TAB> <TAB> <TAB> return raw_query <TAB> <TAB> elif input [ ""op"" ] == ""update"" : <TAB> <TAB> <TAB> raw_query [ ""query"" ] = input [ ""query"" ] <TAB> <TAB> <TAB> if input. has_key ( ""updateobj"" ) : <TAB> <TAB> <TAB> <TAB> if input [ ""updateobj"" ]. has_key ( ""orderby"" ) : <TAB> <TAB> <TAB> <TAB> <TAB> orderby = input [ ""updateobj"" ] [ ""orderby"" ] <TAB> <TAB> <TAB> <TAB> <TAB> raw_query [ ""orderby"" ] = orderby <TAB> <TAB> <TAB> raw_query [ ""millis"" ] = input [ ""millis"" ] <TAB> <TAB> <TAB> raw_query [ ""ns"" ] =",False,input['query'].has_key('$orderby'),input.has_key('$query'),0.6595568656921387
|
||
|
940,"def split_magnets ( self, filename ) : <TAB> log. debug ( ""Attempting to open %s for splitting magnets."", filename ) <TAB> magnets = [ ] <TAB> try : <TAB> <TAB> with open ( filename, ""r"" ) as _file : <TAB> <TAB> <TAB> magnets = list ( filter ( len, _file. read ( ). splitlines ( ) ) ) <TAB> except IOError as ex : <TAB> <TAB> log. warning ( ""Unable to open %s: %s"", filename, ex ) <TAB> if len ( magnets ) < 2 : <TAB> <TAB> return [ ] <TAB> path = filename. rsplit ( os. sep, 1 ) [ 0 ] <TAB> for magnet in magnets : <TAB> <TAB> if not is_magnet ( magnet ) : <TAB> <TAB> <TAB> log. warning ( ""Found line which is not a magnet: %s"", magnet ) <TAB> <TAB> <TAB> continue <TAB> <TAB> for part in magnet. split ( ""&"" ) : <TAB> <TAB> <TAB> if part. startswith ( ""dn="" ) : <TAB> <TAB> <TAB> <TAB> name = part [ 3 : ]. strip ( ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> mname = os. sep. join ( [ path, name + "".magnet"" ] ) <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> else : <TAB> <TAB> <TAB> short_hash = magnet. split ( ""btih:"" ) [ 1 ] [ : 8 ] <TAB> <TAB> <TAB> mname = ""."". join ( [ os. path. splitext ( filename ) [ 0 ], short_hash, ""magnet"" ] ) <TAB> <TAB> try : <TAB> <TAB> <TAB> with open ( mname, ""w"" ) as _mfile : <TAB> <TAB> <TAB> <TAB> _mfile. write ( magnet ) <TAB> <TAB> except IOError as ex : <TAB> <TAB> <TAB> log.",False,name,path,0.6815444231033325
|
||
|
941,"def fix_reference_name ( name, blacklist = None ) : <TAB> """"""Return a syntax-valid Python reference name from an arbitrary name"""""" <TAB> import re <TAB> name = """". join ( re. split ( r""[^0-9a-zA-Z_]"", name ) ) <TAB> while name and not re. match ( r""([a-zA-Z]+[0-9a-zA-Z_]*)$"", name ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> name = name [ 1 : ] <TAB> <TAB> <TAB> continue <TAB> name = str ( name ) <TAB> if not name : <TAB> <TAB> name = ""data"" <TAB> if blacklist is not None and name in blacklist : <TAB> <TAB> get_new_name = lambda index : name + ( ""%03d"" % index ) <TAB> <TAB> index = 0 <TAB> <TAB> while get_new_name ( index ) in blacklist : <TAB> <TAB> <TAB> index += 1 <TAB> <TAB> name = get_new_name ( index ) <TAB> return name",False,"not re.match('[a-zA-Z]', name[0])",name and name.startswith('.'),0.6477032899856567
|
||
|
942,"def test_slice_indexing ( self ) : <TAB> self. set_up_indexing ( ) <TAB> for np_fix, prime_fix in zip ( self. np_fixtures, self. prime_fixtures ) : <TAB> <TAB> ndim = len ( np_fix. shape ) <TAB> <TAB> if ndim == 1 : <TAB> <TAB> <TAB> np. testing. assert_equal ( np_fix [ 2 : 5 ], prime_fix [ 2 : 5 ]. value ) <TAB> <TAB> <TAB> continue <TAB> <TAB> np. testing. assert_equal ( np_fix [ :, 0 ], prime_fix [ :, 0 ]. value ) <TAB> <TAB> np. testing. assert_equal ( np_fix [ :, 1 ], prime_fix [ :, 1 ]. value ) <TAB> <TAB> np. testing. assert_equal ( np_fix [ :, - 1 ], prime_fix [ :, - 1 ]. value ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> np. testing. assert_equal ( np_fix [ :, : - 1,... ], prime_fix [ :, : - 1,... ]. value ) <TAB> <TAB> <TAB> np. testing. assert_equal ( np_fix [ :, : 1,... ], prime_fix [ :, : 1,... ]. value ) <TAB> <TAB> <TAB> np. testing. assert_equal ( np_fix [ :, 1 :,... ], prime_fix [ :, 1 :,... ]. value ) <TAB> <TAB> elif ndim == 2 : <TAB> <TAB> <TAB> np. testing. assert_equal ( np_fix [ :, : 2 ], prime_fix [ :, : - 1 ]. value ) <TAB> <TAB> <TAB> np. testing. assert_equal ( np_fix [ :, 1 : ], prime_fix [ :, 1 : ]. value )",False,ndim > 2,ndim == 3,0.6682177782058716
|
||
|
943,"def op_fuse ( self ) : <TAB> """"""fuse bn and scale"""""" <TAB> new_layers = [ ] <TAB> temp_layers = { } <TAB> changed_layers = { } <TAB> for index, pl in enumerate ( self. predict_layer ) : <TAB> <TAB> op_type = pl. type <TAB> <TAB> if op_type == ""Input"" : <TAB> <TAB> <TAB> new_layers. append ( pl ) <TAB> <TAB> <TAB> continue <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> if ( index!= len ( self. predict_layer ) - 1 ) and ( <TAB> <TAB> <TAB> <TAB> self. predict_layer [ index + 1 ]. type == ""Scale"" <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> temp_layers [ ""bn"" ] = pl <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> new_layers. append ( pl ) <TAB> <TAB> <TAB> <TAB> temp_layers. clear ( ) <TAB> <TAB> elif op_type == ""Scale"" : <TAB> <TAB> <TAB> if self. predict_layer [ index - 1 ]. type == ""BatchNorm"" : <TAB> <TAB> <TAB> <TAB> temp_layers [ ""scale"" ] = pl <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> new_layers. append ( pl ) <TAB> <TAB> <TAB> <TAB> temp_layers. clear ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> temp_layers. clear ( ) <TAB> <TAB> if len ( temp_layers ) == 2 : <TAB> <TAB> <TAB> layer = self. fuse_op ( temp_layers ) <TAB> <TAB> <TAB> new_layers. append ( layer ) <TAB> <TAB> <TAB> changed_layers [ temp_layers [ ""scale"" ]. name ] = temp_layers [ ""bn"" ]. name <TAB> <TAB",True,op_type == 'BatchNorm',op_type == 'BatchNorm',0.6535085439682007
|
||
|
944,"def TryMerge ( self, d ) : <TAB> while d. avail ( ) > 0 : <TAB> <TAB> tt = d. getVarInt32 ( ) <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_cost ( ). TryMerge ( tmp ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if tt == 24 : <TAB> <TAB> <TAB> self. add_version ( d. getVarInt64 ( ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if tt == 0 : <TAB> <TAB> <TAB> raise ProtocolBuffer. ProtocolBufferDecodeError <TAB> <TAB> d. skipData ( tt )",False,tt == 10,tt == 24,0.6944561004638672
|
||
|
945,"def _get_port ( self, state, c_id, tpl_var ) : <TAB> """"""Extract a port from a container_inspect or the k8s API given a template variable."""""" <TAB> container_inspect = state. inspect_container ( c_id ) <TAB> ports = [ ] <TAB> try : <TAB> <TAB> ports = [ <TAB> <TAB> <TAB> x. split ( ""/"" ) [ 0 ] <TAB> <TAB> <TAB> for x in container_inspect [ ""NetworkSettings"" ] [ ""Ports"" ]. keys ( ) <TAB> <TAB> ] <TAB> <TAB> if len ( ports ) == 0 : <TAB> <TAB> <TAB> raise IndexError <TAB> except ( IndexError, KeyError, AttributeError ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> spec = state. get_kube_container_spec ( c_id ) <TAB> <TAB> <TAB> if spec : <TAB> <TAB> <TAB> <TAB> ports = [ str ( x. get ( ""containerPort"" ) ) for x in spec. get ( ""ports"", [ ] ) ] <TAB> <TAB> else : <TAB> <TAB> <TAB> ports = [ <TAB> <TAB> <TAB> <TAB> p. split ( ""/"" ) [ 0 ] <TAB> <TAB> <TAB> <TAB> for p in container_inspect [ ""Config"" ]. get ( ""ExposedPorts"", { } ). keys ( ) <TAB> <TAB> <TAB> ] <TAB> ports = sorted ( ports, key = int ) <TAB> return self. _extract_port_from_list ( ports, tpl_var )",False,Platform.is_k8s(),state.has_kube_container(c_id),0.6565148830413818
|
||
|
946,"def upgrade ( ) : <TAB> bind = op. get_bind ( ) <TAB> session = db. Session ( bind = bind ) <TAB> tables = [ <TAB> <TAB> Annotation, <TAB> <TAB> Dashboard, <TAB> <TAB> Database, <TAB> <TAB> DruidCluster, <TAB> <TAB> DruidColumn, <TAB> <TAB> DruidDatasource, <TAB> <TAB> DruidMetric, <TAB> <TAB> Slice, <TAB> <TAB> SqlaTable, <TAB> <TAB> SqlMetric, <TAB> <TAB> TableColumn, <TAB> ] <TAB> for table in tables : <TAB> <TAB> for record in session. query ( table ). all ( ) : <TAB> <TAB> <TAB> for col in record. __table__. columns. values ( ) : <TAB> <TAB> <TAB> <TAB> if not col. primary_key : <TAB> <TAB> <TAB> <TAB> <TAB> value = getattr ( record, col. name ) <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> setattr ( record, col. name, None ) <TAB> <TAB> session. commit ( ) <TAB> session. close ( )",False,value is not None and value.strip() == '',value,0.655017614364624
|
||
|
947,"def __init__ ( self, * args ) : <TAB> if len ( args ) == 3 : <TAB> <TAB> assert ( <TAB> <TAB> <TAB> isinstance ( args [ 0 ], Point3 ) <TAB> <TAB> <TAB> and isinstance ( args [ 1 ], Vector3 ) <TAB> <TAB> <TAB> and type ( args [ 2 ] ) == float <TAB> <TAB> ) <TAB> <TAB> self. p = args [ 0 ]. copy ( ) <TAB> <TAB> self. v = args [ 1 ] * args [ 2 ] / abs ( args [ 1 ] ) <TAB> elif len ( args ) == 2 : <TAB> <TAB> if isinstance ( args [ 0 ], Point3 ) and isinstance ( args [ 1 ], Point3 ) : <TAB> <TAB> <TAB> self. p = args [ 0 ]. copy ( ) <TAB> <TAB> <TAB> self. v = args [ 1 ] - args [ 0 ] <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> self. p = args [ 0 ]. copy ( ) <TAB> <TAB> <TAB> self. v = args [ 1 ]. copy ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise AttributeError ( ""%r"" % ( args, ) ) <TAB> elif len ( args ) == 1 : <TAB> <TAB> if isinstance ( args [ 0 ], Line3 ) : <TAB> <TAB> <TAB> self. p = args [ 0 ]. p. copy ( ) <TAB> <TAB> <TAB> self. v = args [ 0 ]. v. copy ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise AttributeError ( ""%r"" % ( args, ) ) <TAB> else : <TAB> <TAB> raise AttributeError ( ""%r"" % ( args, ) )",False,"isinstance(args[0], Point3) and isinstance(args[1], Vector3)",len(args) == 1,0.6530184745788574
|
||
|
948,"def _getOpcodeSuffix ( self, trace, va, op ) : <TAB> pc = trace. getProgramCounter ( ) <TAB> if va!= pc : <TAB> <TAB> return """" <TAB> ovals = [ ] <TAB> for o in op. opers : <TAB> <TAB> if o. isDeref ( ) : <TAB> <TAB> <TAB> ova = o. getOperAddr ( op, trace ) <TAB> <TAB> else : <TAB> <TAB> <TAB> ova = o. getOperValue ( op, trace ) <TAB> <TAB> sym = None <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> rova = trace. readMemoryFormat ( ova, ""<P"" ) [ 0 ] <TAB> <TAB> <TAB> sym = trace. getSymByAddr ( rova ) <TAB> <TAB> if sym is None : <TAB> <TAB> <TAB> sym = trace. getSymByAddr ( ova ) <TAB> <TAB> if sym : <TAB> <TAB> <TAB> ovals. append ( repr ( sym ) ) <TAB> <TAB> elif o. isDeref ( ) : <TAB> <TAB> <TAB> ovals. append ( ""[0x%.8x]"" % ova ) <TAB> <TAB> else : <TAB> <TAB> <TAB> ovals. append ( ""0x%.8x"" % ova ) <TAB> if [ branch for branch, flag in op. getBranches ( ) if flag & envi. BR_COND ] : <TAB> <TAB> emu = self. emu_cache. get ( self. arch, vtrace. getEmu ( trace ) ) <TAB> <TAB> emu. setRegisters ( trace. getRegisters ( ) ) <TAB> <TAB> emu. setProgramCounter ( va ) <TAB> <TAB> emu. executeOpcode ( op ) <TAB> <TAB> nextpc = emu. getProgramCounter ( ) <TAB> <TAB> if va + len ( op )!= nextpc : <TAB> <TAB> <TAB> ovals. append ( ""Branch taken: 0x%08x"" % nextpc ) <TAB> <TAB>",False,trace.isValidPointer(ova),o.isMemory(),0.6635071039199829
|
||
|
949,"def _connect_line2_line2 ( A, B ) : <TAB> d = B. v. y * A. v. x - B. v. x * A. v. y <TAB> if d == 0 : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> p1, p2 = _connect_point2_line2 ( B. p, A ) <TAB> <TAB> <TAB> return p2, p1 <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return _connect_point2_line2 ( A. p, B ) <TAB> dy = A. p. y - B. p. y <TAB> dx = A. p. x - B. p. x <TAB> ua = ( B. v. x * dy - B. v. y * dx ) / d <TAB> if not A. _u_in ( ua ) : <TAB> <TAB> ua = max ( min ( ua, 1.0 ), 0.0 ) <TAB> ub = ( A. v. x * dy - A. v. y * dx ) / d <TAB> if not B. _u_in ( ub ) : <TAB> <TAB> ub = max ( min ( ub, 1.0 ), 0.0 ) <TAB> return LineSegment2 ( <TAB> <TAB> Point2 ( A. p. x + ua * A. v. x, A. p. y + ua * A. v. y ), <TAB> <TAB> Point2 ( B. p. x + ub * B. v. x, B. p. y + ub * B. v. y ), <TAB> )",False,"isinstance(B, Ray2) or isinstance(B, LineSegment2)",A == B,0.652072012424469
|
||
|
950,"def process_output ( <TAB> self, data, output_prompt, input_lines, output, is_doctest, image_file ) : <TAB> """"""Process data block for OUTPUT token."""""" <TAB> if is_doctest : <TAB> <TAB> submitted = data. strip ( ) <TAB> <TAB> found = output <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> found = found. strip ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ind = found. find ( output_prompt ) <TAB> <TAB> <TAB> if ind < 0 : <TAB> <TAB> <TAB> <TAB> e = 'output prompt=""%s"" does not match out line=%s' % ( <TAB> <TAB> <TAB> <TAB> <TAB> output_prompt, <TAB> <TAB> <TAB> <TAB> <TAB> found, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> raise RuntimeError ( e ) <TAB> <TAB> <TAB> found = found [ len ( output_prompt ) : ]. strip ( ) <TAB> <TAB> <TAB> if found!= submitted : <TAB> <TAB> <TAB> <TAB> e = ( <TAB> <TAB> <TAB> <TAB> <TAB> 'doctest failure for input_lines=""%s"" with'<TAB> <TAB> <TAB> <TAB> <TAB> 'found_output=""%s"" and submitted output=""%s""' <TAB> <TAB> <TAB> <TAB> <TAB> % ( input_lines, found, submitted ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> raise RuntimeError ( e )",False,found is not None,found,0.6617709994316101
|
||
|
951,"def cleanup_ad_hoc_commands ( self ) : <TAB> skipped, deleted = 0, 0 <TAB> ad_hoc_commands = AdHocCommand. objects. filter ( created__lt = self. cutoff ) <TAB> for ad_hoc_command in ad_hoc_commands. iterator ( ) : <TAB> <TAB> ad_hoc_command_display = '""%s"" (%d events)' % ( <TAB> <TAB> <TAB> str ( ad_hoc_command ), <TAB> <TAB> <TAB> ad_hoc_command. ad_hoc_command_events. count ( ), <TAB> <TAB> ) <TAB> <TAB> if ad_hoc_command. status in ( ""pending"", ""waiting"", ""running"" ) : <TAB> <TAB> <TAB> action_text = ""would skip"" if self. dry_run else ""skipping"" <TAB> <TAB> <TAB> self. logger. debug ( <TAB> <TAB> <TAB> <TAB> ""%s %s ad hoc command %s"", <TAB> <TAB> <TAB> <TAB> action_text, <TAB> <TAB> <TAB> <TAB> ad_hoc_command. status, <TAB> <TAB> <TAB> <TAB> ad_hoc_command_display, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> skipped += 1 <TAB> <TAB> else : <TAB> <TAB> <TAB> action_text = ""would delete"" if self. dry_run else ""deleting"" <TAB> <TAB> <TAB> self. logger. info ( ""%s %s"", action_text, ad_hoc_command_display ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> ad_hoc_command. delete ( ) <TAB> <TAB> <TAB> deleted += 1 <TAB> skipped += AdHocCommand. objects. filter ( created__gte = self. cutoff ). count ( ) <TAB> return skipped, deleted",False,not self.dry_run,ad_hoc_command.exists(),0.6582926511764526
|
||
|
952,"def default_loader ( href, parse, encoding = None ) : <TAB> with open ( href ) as file : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> data = ElementTree. parse ( file ). getroot ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> data = file. read ( ) <TAB> <TAB> <TAB> if encoding : <TAB> <TAB> <TAB> <TAB> data = data. decode ( encoding ) <TAB> return data",False,parse == 'xml',parse,0.66475510597229
|
||
|
953,"def handle_ctcp ( self, conn, evt ) : <TAB> args = evt. arguments ( ) <TAB> source = evt. source ( ). split ( ""!"" ) [ 0 ] <TAB> if args : <TAB> <TAB> if args [ 0 ] == ""VERSION"" : <TAB> <TAB> <TAB> conn. ctcp_reply ( source, ""VERSION "" + BOT_VERSION ) <TAB> <TAB> elif args [ 0 ] == ""PING"" : <TAB> <TAB> <TAB> conn. ctcp_reply ( source, ""PING"" ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> conn. ctcp_reply ( source, ""CLIENTINFO PING VERSION CLIENTINFO"" )",True,args[0] == 'CLIENTINFO',args[0] == 'CLIENTINFO',0.6536786556243896
|
||
|
954,"def get_bill_no_and_update_amounts ( <TAB> reference_doctype, <TAB> ref_doc, <TAB> total_amount, <TAB> exchange_rate, <TAB> party_account_currency, <TAB> company_currency, ) : <TAB> outstanding_amount, bill_no = None <TAB> if reference_doctype in ( ""Sales Invoice"", ""Purchase Invoice"" ) : <TAB> <TAB> outstanding_amount = ref_doc. get ( ""outstanding_amount"" ) <TAB> <TAB> bill_no = ref_doc. get ( ""bill_no"" ) <TAB> elif reference_doctype == ""Expense Claim"" : <TAB> <TAB> outstanding_amount = ( <TAB> <TAB> <TAB> flt ( ref_doc. get ( ""total_sanctioned_amount"" ) ) <TAB> <TAB> <TAB> + flt ( ref_doc. get ( ""total_taxes_and_charges"" ) ) <TAB> <TAB> <TAB> - flt ( ref_doc. get ( ""total_amount_reimbursed"" ) ) <TAB> <TAB> <TAB> - flt ( ref_doc. get ( ""total_advance_amount"" ) ) <TAB> <TAB> ) <TAB> elif reference_doctype == ""Employee Advance"" : <TAB> <TAB> outstanding_amount = flt ( ref_doc. advance_amount ) - flt ( ref_doc. paid_amount ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> outstanding_amount = flt ( outstanding_amount ) * flt ( exchange_rate ) <TAB> <TAB> <TAB> if party_account_currency == company_currency : <TAB> <TAB> <TAB> <TAB> exchange_rate = 1 <TAB> else : <TAB> <TAB> outstanding_amount = flt ( total_amount ) - flt ( ref_doc. advance_paid ) <TAB> return outstanding_amount, exchange_rate, bill_no",False,party_account_currency != ref_doc.currency,party_account_currency == company_currency,0.6521563529968262
|
||
|
955,"def update_ui ( self ) : <TAB> if self. _state == ""closed"" : <TAB> <TAB> return <TAB> while not self. _work_events_queue. empty ( ) : <TAB> <TAB> self. handle_work_event ( * self. _work_events_queue. get ( ) ) <TAB> <TAB> if self. _state == ""closed"" : <TAB> <TAB> <TAB> return <TAB> if self. _state == ""idle"" : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _ok_button. configure ( state = ""normal"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. _ok_button. configure ( state = ""disabled"" ) <TAB> else : <TAB> <TAB> self. _ok_button. configure ( state = ""disabled"" ) <TAB> if self. _state == ""done"" : <TAB> <TAB> set_text_if_different ( self. _cancel_button, tr ( ""Close"" ) ) <TAB> else : <TAB> <TAB> set_text_if_different ( self. _cancel_button, tr ( ""Cancel"" ) )",False,self.is_ready_for_work(),self.is_different_ui_idle(),0.6476125121116638
|
||
|
956,"def _recursive_saxify ( self, element, prefixes ) : <TAB> content_handler = self. _content_handler <TAB> tag = element. tag <TAB> if tag is Comment or tag is ProcessingInstruction : <TAB> <TAB> if tag is ProcessingInstruction : <TAB> <TAB> <TAB> content_handler. processingInstruction ( element. target, element. text ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> content_handler. characters ( element. tail ) <TAB> <TAB> return <TAB> new_prefixes = [ ] <TAB> build_qname = self. _build_qname <TAB> attribs = element. items ( ) <TAB> if attribs : <TAB> <TAB> attr_values = { } <TAB> <TAB> attr_qnames = { } <TAB> <TAB> for attr_ns_name, value in attribs : <TAB> <TAB> <TAB> attr_ns_tuple = _getNsTag ( attr_ns_name ) <TAB> <TAB> <TAB> attr_values [ attr_ns_tuple ] = value <TAB> <TAB> <TAB> attr_qnames [ attr_ns_tuple ] = build_qname ( <TAB> <TAB> <TAB> <TAB> attr_ns_tuple [ 0 ], attr_ns_tuple [ 1 ], prefixes, new_prefixes <TAB> <TAB> <TAB> ) <TAB> <TAB> sax_attributes = self. _attr_class ( attr_values, attr_qnames ) <TAB> else : <TAB> <TAB> sax_attributes = self. _empty_attributes <TAB> ns_uri, local_name = _getNsTag ( tag ) <TAB> qname = build_qname ( ns_uri, local_name, prefixes, new_prefixes ) <TAB> for prefix, uri in new_prefixes : <TAB> <TAB> content_handler. startPrefixMapping ( prefix, uri ) <TAB> content_handler. startElementNS ( ( ns_uri, local_name ), qname, sax_attributes ) <TAB> if element. text : <TAB> <TAB> content_handler. characters ( element. text ) <TAB> for child in element : <TAB> <TAB> self. _recursive_sax",True,element.tail,element.tail,0.6731557846069336
|
||
|
957,"def _mapdict_values ( items ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> opt_val = [ ] <TAB> for item in items : <TAB> <TAB> state = item [ : - 1 ] <TAB> <TAB> val = item [ - 1 ] <TAB> <TAB> <TAB> <TAB> state [ 0 ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> state = state [ 0 ] or """" <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> state = "" "". join ( state ) <TAB> <TAB> opt_val. append ( state ) <TAB> <TAB> if val is not None : <TAB> <TAB> <TAB> opt_val. append ( val ) <TAB> return opt_val",False,len(state) == 1,state is not None,0.6603293418884277
|
||
|
958,"def _persist_metadata ( self, dirname, filename ) : <TAB> metadata_path = ""{0}/{1}.json"". format ( dirname, filename ) <TAB> if self. media_metadata or self. comments or self. include_location : <TAB> <TAB> if self. posts : <TAB> <TAB> <TAB> if self. latest : <TAB> <TAB> <TAB> <TAB> self. merge_json ( { ""GraphImages"" : self. posts }, metadata_path ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. save_json ( { ""GraphImages"" : self. posts }, metadata_path ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if self. latest : <TAB> <TAB> <TAB> <TAB> self. merge_json ( { ""GraphStories"" : self. stories }, metadata_path ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. save_json ( { ""GraphStories"" : self. stories }, metadata_path )",True,self.stories,self.stories,0.6608641147613525
|
||
|
959,"def _dump_str ( v ) : <TAB> if sys. version_info < ( 3, ) and hasattr ( v, ""decode"" ) and isinstance ( v, str ) : <TAB> <TAB> v = v. decode ( ""utf-8"" ) <TAB> v = ""%r"" % v <TAB> if v [ 0 ] == ""u"" : <TAB> <TAB> v = v [ 1 : ] <TAB> singlequote = v. startswith ( ""'"" ) <TAB> if singlequote or v. startswith ( '""' ) : <TAB> <TAB> v = v [ 1 : - 1 ] <TAB> if singlequote : <TAB> <TAB> v = v. replace ( ""\\'"", ""'"" ) <TAB> <TAB> v = v. replace ( '""', '\\""' ) <TAB> v = v. split ( ""\\x"" ) <TAB> while len ( v ) > 1 : <TAB> <TAB> i = - 1 <TAB> <TAB> if not v [ 0 ] : <TAB> <TAB> <TAB> v = v [ 1 : ] <TAB> <TAB> v [ 0 ] = v [ 0 ]. replace ( ""\\\\"", ""\\"" ) <TAB> <TAB> <TAB> <TAB> joinx = v [ 0 ] [ i ]!= ""\\"" <TAB> <TAB> while v [ 0 ] [ : i ] and v [ 0 ] [ i ] == ""\\"" : <TAB> <TAB> <TAB> joinx = not joinx <TAB> <TAB> <TAB> i -= 1 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> joiner = ""x"" <TAB> <TAB> else : <TAB> <TAB> <TAB> joiner = ""u00"" <TAB> <TAB> v = [ v [ 0 ] + joiner + v [ 1 ] ] + v [ 2 : ] <TAB> return unicode ( '""' + v [ 0 ] + '""' )",True,joinx,joinx,0.6794019937515259
|
||
|
960,"def _handle_socket ( self, event, fd, multi, data, _pycurl = pycurl ) : <TAB> if event == _pycurl. POLL_REMOVE : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. hub. remove ( fd ) <TAB> <TAB> <TAB> self. _fds. pop ( fd, None ) <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. hub. remove ( fd ) <TAB> <TAB> if event == _pycurl. POLL_IN : <TAB> <TAB> <TAB> self. hub. add_reader ( fd, self. on_readable, fd ) <TAB> <TAB> <TAB> self. _fds [ fd ] = READ <TAB> <TAB> elif event == _pycurl. POLL_OUT : <TAB> <TAB> <TAB> self. hub. add_writer ( fd, self. on_writable, fd ) <TAB> <TAB> <TAB> self. _fds [ fd ] = WRITE <TAB> <TAB> elif event == _pycurl. POLL_INOUT : <TAB> <TAB> <TAB> self. hub. add_reader ( fd, self. on_readable, fd ) <TAB> <TAB> <TAB> self. hub. add_writer ( fd, self. on_writable, fd ) <TAB> <TAB> <TAB> self. _fds [ fd ] = READ | WRITE",False,fd in self._fds,multi,0.6659975051879883
|
||
|
961,"def load_vocab ( vocab_file ) : <TAB> """"""Loads a vocabulary file into a dictionary."""""" <TAB> <TAB> extra_map = { } <TAB> extra_map [ ""[unused1]"" ] = ""[X_SEP]"" <TAB> for i in range ( 10 ) : <TAB> <TAB> extra_map [ ""[unused{}]"". format ( i + 2 ) ] = ""[SEP_{}]"". format ( i ) <TAB> extra_map [ ""[unused12]"" ] = ""[S2S_SEP]"" <TAB> extra_map [ ""[unused13]"" ] = ""[S2S_CLS]"" <TAB> extra_map [ ""[unused14]"" ] = ""[L2R_SEP]"" <TAB> extra_map [ ""[unused15]"" ] = ""[L2R_CLS]"" <TAB> extra_map [ ""[unused16]"" ] = ""[R2L_SEP]"" <TAB> extra_map [ ""[unused17]"" ] = ""[R2L_CLS]"" <TAB> extra_map [ ""[unused18]"" ] = ""[S2S_SOS]"" <TAB> vocab = collections. OrderedDict ( ) <TAB> index = 0 <TAB> with open ( vocab_file, ""r"", encoding = ""utf-8"" ) as reader : <TAB> <TAB> while True : <TAB> <TAB> <TAB> token = reader. readline ( ) <TAB> <TAB> <TAB> if not token : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> token = token. strip ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> token = extra_map [ token ] <TAB> <TAB> <TAB> vocab [ token ] = index <TAB> <TAB> <TAB> index += 1 <TAB> return vocab",True,token in extra_map,token in extra_map,0.6640057563781738
|
||
|
962,"def loadFromTVDB ( self, cache = True, tvapi = None, cachedSeason = None ) : <TAB> logger. log ( str ( self. tvdbid ) + u"": Loading show info from theTVDB"" ) <TAB> <TAB> <TAB> if tvapi is None : <TAB> <TAB> ltvdb_api_parms = sickbeard. TVDB_API_PARMS. copy ( ) <TAB> <TAB> if not cache : <TAB> <TAB> <TAB> ltvdb_api_parms [ ""cache"" ] = False <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> ltvdb_api_parms [ ""language"" ] = self. lang <TAB> <TAB> t = tvdb_api. Tvdb ( ** ltvdb_api_parms ) <TAB> else : <TAB> <TAB> t = tvapi <TAB> myEp = t [ self. tvdbid ] <TAB> try : <TAB> <TAB> self. name = myEp [ ""seriesname"" ]. strip ( ) <TAB> except AttributeError : <TAB> <TAB> raise tvdb_exceptions. tvdb_attributenotfound ( <TAB> <TAB> <TAB> ""Found %s, but attribute'seriesname' was empty."" % ( self. tvdbid ) <TAB> <TAB> ) <TAB> self. genre = myEp [ ""genre"" ] <TAB> self. network = myEp [ ""network"" ] <TAB> if myEp [ ""airs_dayofweek"" ] is not None and myEp [ ""airs_time"" ] is not None : <TAB> <TAB> self. airs = myEp [ ""airs_dayofweek"" ] + "" "" + myEp [ ""airs_time"" ] <TAB> if myEp [ ""firstaired"" ] is not None and myEp [ ""firstaired"" ] : <TAB> <TAB> self. startyear = int ( myEp [ ""firstaired"" ]. split ( ""-"" ) [ 0 ] ) <TAB> if self. airs is None : <TAB> <TAB> self. airs = """" <TAB> if myEp [ ""status"" ] is not None : <TAB",False,self.lang,self.lang is not None,0.6700106859207153
|
||
|
963,"def _move_node ( <TAB> self, node, target, position = ""last-child"", save = True, refresh_target = True ) : <TAB> if self. tree_model. _mptt_is_tracking : <TAB> <TAB> <TAB> <TAB> return self. insert_node ( <TAB> <TAB> <TAB> node, <TAB> <TAB> <TAB> target, <TAB> <TAB> <TAB> position = position, <TAB> <TAB> <TAB> save = save, <TAB> <TAB> <TAB> allow_existing_pk = True, <TAB> <TAB> <TAB> refresh_target = refresh_target, <TAB> <TAB> ) <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if node. is_child_node ( ) : <TAB> <TAB> <TAB> <TAB> self. _make_child_root_node ( node ) <TAB> <TAB> elif target. is_root_node ( ) and position in ( ""left"", ""right"" ) : <TAB> <TAB> <TAB> self. _make_sibling_of_root_node ( node, target, position ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if node. is_root_node ( ) : <TAB> <TAB> <TAB> <TAB> self. _move_root_node ( node, target, position ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. _move_child_node ( node, target, position )",False,target is None,save or refresh_target,0.6632372140884399
|
||
|
964,"def scan ( self, offset = 0, ** kwargs ) : <TAB> for pool_header in super ( PoolScanShutdownCallback, self ). scan ( <TAB> <TAB> offset = offset, ** kwargs <TAB> ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> callback = self. profile. _SHUTDOWN_PACKET ( <TAB> <TAB> <TAB> offset = pool_header. end ( ), vm = self. address_space <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> driver_obj = callback. DeviceObject. dereference ( <TAB> <TAB> <TAB> vm = self. kernel_address_space <TAB> <TAB> ). DriverObject <TAB> <TAB> function_pointer = driver_obj. MajorFunction [ ""IRP_MJ_SHUTDOWN"" ] <TAB> <TAB> details = driver_obj. DriverName <TAB> <TAB> yield ""IoRegisterShutdownNotification"", function_pointer, details",False,not callback.sanity_check(self.kernel_address_space),self.is_tab_valid(),0.6504683494567871
|
||
|
965,"def process ( self ) : <TAB> L, S, R, A = self. inputs <TAB> Ma = self. outputs [ 0 ] <TAB> if not Ma. is_linked : <TAB> <TAB> return <TAB> loc = Vector_generate ( L. sv_get ( ) ) <TAB> scale = Vector_generate ( S. sv_get ( ) ) <TAB> rot = Vector_generate ( R. sv_get ( ) ) <TAB> rotA, angle = [ [ ] ], [ [ 0.0 ] ] <TAB> <TAB> if A. is_linked : <TAB> <TAB> if A. links [ 0 ]. from_socket. bl_idname == ""SvVerticesSocket"" : <TAB> <TAB> <TAB> rotA = Vector_generate ( A. sv_get ( ) ) <TAB> <TAB> <TAB> angle = [ [ ] ] <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> angle = A. sv_get ( ) <TAB> <TAB> <TAB> rotA = [ [ ] ] <TAB> else : <TAB> <TAB> angle = A. sv_get ( ) <TAB> <TAB> rotA = [ [ ] ] <TAB> result = [ ] <TAB> m_add = result. extend if self. flat_output else result. append <TAB> params = match_long_repeat ( [ loc, scale, rot, angle, rotA ] ) <TAB> for par in zip ( * params ) : <TAB> <TAB> matrixes = matrix_in ( par ) <TAB> <TAB> m_add ( matrixes ) <TAB> Ma. sv_set ( result )",False,A.links[0].from_socket.bl_idname == 'SvStringsSocket',A.is_linked,0.6534470319747925
|
||
|
966,"def compare ( self, d1, d2, p1, p2, root ) : <TAB> """"""Compare dicts d1 and d2."""""" <TAB> for h in sorted ( d1. keys ( ) ) : <TAB> <TAB> p1, p2 = d1. get ( h ), d2. get ( h ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> lines1, lines2 = g. splitLines ( p1. b ), g. splitLines ( p2. b ) <TAB> <TAB> <TAB> aList = list ( difflib. unified_diff ( lines1, lines2, ""vr1"", ""vr2"" ) ) <TAB> <TAB> <TAB> if aList : <TAB> <TAB> <TAB> <TAB> p = root. insertAsLastChild ( ) <TAB> <TAB> <TAB> <TAB> p. h = h <TAB> <TAB> <TAB> <TAB> p. b = """". join ( aList ) <TAB> <TAB> <TAB> <TAB> p1. clone ( ). moveToLastChildOf ( p ) <TAB> <TAB> <TAB> <TAB> p2. clone ( ). moveToLastChildOf ( p ) <TAB> <TAB> elif p1. b. strip ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> p = root. insertAsLastChild ( ) <TAB> <TAB> <TAB> p. h = h + ""(%s only)"" % p1. h <TAB> <TAB> <TAB> p1. clone ( ). moveToLastChildOf ( p ) <TAB> for h in sorted ( d2. keys ( ) ) : <TAB> <TAB> p2 = d2. get ( h ) <TAB> <TAB> if h not in d1 and p2. b. strip ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> p = root. insertAsLastChild ( ) <TAB> <TAB> <TAB> p. h = h + ""(%s only)"" % p2. h <TAB> <TAB> <TAB> p2. clone ( ). moveToLastChildOf ( p ) <TAB>",False,h in d2,p1.h and p2.h,0.6693493127822876
|
||
|
967,"def get_data ( self, df : pd. DataFrame ) -> VizData : <TAB> if df. empty : <TAB> <TAB> return None <TAB> <TAB> for key in self. spatial_control_keys : <TAB> <TAB> df = self. process_spatial_data_obj ( key, df ) <TAB> features = [ ] <TAB> for d in df. to_dict ( orient = ""records"" ) : <TAB> <TAB> feature = self. get_properties ( d ) <TAB> <TAB> extra_props = self. get_js_columns ( d ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> feature [ ""extraProps"" ] = extra_props <TAB> <TAB> features. append ( feature ) <TAB> return { <TAB> <TAB> ""features"" : features, <TAB> <TAB> ""mapboxApiKey"" : config [ ""MAPBOX_API_KEY"" ], <TAB> <TAB> ""metricLabels"" : self. metric_labels, <TAB> }",True,extra_props,extra_props,0.6635777354240417
|
||
|
968,"def collation_cb ( * args, ** kwargs ) : <TAB> layout = self [ args ] <TAB> layout_type = type ( layout ). __name__ <TAB> if len ( container. keys ( ) )!= len ( layout. keys ( ) ) : <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> ""Collated DynamicMaps must return "" <TAB> <TAB> <TAB> ""%s with consistent number of items."" % layout_type <TAB> <TAB> ) <TAB> key = kwargs [ ""selection_key"" ] <TAB> index = kwargs [ ""selection_index"" ] <TAB> obj_type = kwargs [ ""selection_type"" ] <TAB> dyn_type_map = defaultdict ( list ) <TAB> for k, v in layout. data. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return layout [ k ] <TAB> <TAB> dyn_type_map [ type ( v ) ]. append ( v ) <TAB> dyn_type_counter = { t : len ( vals ) for t, vals in dyn_type_map. items ( ) } <TAB> if dyn_type_counter!= type_counter : <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> ""The objects in a %s returned by a "" <TAB> <TAB> <TAB> ""DynamicMap must consistently return "" <TAB> <TAB> <TAB> ""the same number of items of the "" <TAB> <TAB> <TAB> ""same type."" % layout_type <TAB> <TAB> ) <TAB> return dyn_type_map [ obj_type ] [ index ]",True,k == key,k == key,0.6799268126487732
|
||
|
969,"def handle ( self, * args, ** options ) : <TAB> """"""Command entry point."""""" <TAB> exts_pool. load_all ( ) <TAB> for filename in options [ ""files"" ] : <TAB> <TAB> try : <TAB> <TAB> <TAB> with transaction. atomic ( ) : <TAB> <TAB> <TAB> <TAB> self. _import ( filename, options ) <TAB> <TAB> except CommandError as exc : <TAB> <TAB> <TAB> raise exc <TAB> <TAB> except UnicodeDecodeError : <TAB> <TAB> <TAB> self. stdout. write ( <TAB> <TAB> <TAB> <TAB> self. style. NOTICE ( <TAB> <TAB> <TAB> <TAB> <TAB> _ ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""CSV file is not encoded in UTF-8, attempting to guess "" <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""encoding"" <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> detector = UniversalDetector ( ) <TAB> <TAB> <TAB> with io. open ( filename, ""rb"" ) as fp : <TAB> <TAB> <TAB> <TAB> for line in fp : <TAB> <TAB> <TAB> <TAB> <TAB> detector. feed ( line ) <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> detector. close ( ) <TAB> <TAB> <TAB> self. stdout. write ( <TAB> <TAB> <TAB> <TAB> self. style. NOTICE ( <TAB> <TAB> <TAB> <TAB> <TAB> _ ( ""Reading CSV file using %(encoding)s encoding"" ) % detector. result <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> with transaction.",False,detector.done,options['force'],0.6640725135803223
|
||
|
970,"def extractValues ( self, constraints, analysis, arch ) : <TAB> if not constraints : <TAB> <TAB> return [ ] <TAB> to_return = [ ] <TAB> for constraintString in constraints : <TAB> <TAB> m = re. match ( Searcher. CONSTRAINT_REGEX, constraintString ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise RopperError ( ""Not a valid constraint"" ) <TAB> <TAB> reg1 = m. group ( 1 ) <TAB> <TAB> reg2 = m. group ( 3 ) <TAB> <TAB> reg1 = reg1. replace ( ""["", """" ) <TAB> <TAB> reg1 = reg1. replace ( ""]"", """" ) <TAB> <TAB> reg1 = arch. getRegisterName ( reg1 ) <TAB> <TAB> reg2 = reg2. replace ( ""["", """" ) <TAB> <TAB> reg2 = reg2. replace ( ""]"", """" ) <TAB> <TAB> if reg2. isdigit ( ) or isHex ( reg2 ) : <TAB> <TAB> <TAB> reg2 = None <TAB> <TAB> reg2 = arch. getRegisterName ( reg2 ) <TAB> <TAB> to_return. append ( ( reg1, reg2 ) ) <TAB> return to_return",False,not m,m is None,0.6749292612075806
|
||
|
971,"def filtercomments ( source ) : <TAB> """"""NOT USED: strips trailing comments and put them at the top."""""" <TAB> trailing_comments = [ ] <TAB> comment = True <TAB> while comment : <TAB> <TAB> if re. search ( r""^\s*\/\*"", source ) : <TAB> <TAB> <TAB> comment = source [ 0, source. index ( ""*/"" ) + 2 ] <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> comment = re. search ( r""^\s*\/\/"", source ). group ( 0 ) <TAB> <TAB> else : <TAB> <TAB> <TAB> comment = None <TAB> <TAB> if comment : <TAB> <TAB> <TAB> source = re. sub ( r""^\s+"", """", source [ len ( comment ) : ] ) <TAB> <TAB> <TAB> trailing_comments. append ( comment ) <TAB> return ""\n"". join ( trailing_comments ) + source",False,"re.search('^\\s*\\/\\/', source)","source.search('^\\s*\\/\\/', source)",0.6493881940841675
|
||
|
972,"def deleteMenu ( self, menuName ) : <TAB> try : <TAB> <TAB> menu = self. getMenu ( menuName ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. destroy ( menu ) <TAB> <TAB> <TAB> self. destroyMenu ( menuName ) <TAB> <TAB> else : <TAB> <TAB> <TAB> g. es ( ""can't delete menu:"", menuName ) <TAB> except Exception : <TAB> <TAB> g. es ( ""exception deleting"", menuName, ""menu"" ) <TAB> <TAB> g. es_exception ( )",True,menu,menu,0.6883183717727661
|
||
|
973,"def __init__ ( self, opt, data_loader = None, cands = None, shared = None, ** kwargs ) : <TAB> <TAB> super ( ). __init__ ( opt, data_loader, cands, shared, ** kwargs ) <TAB> self. cycle = kwargs [ ""cycle"" ] if ""cycle"" in kwargs else True <TAB> if shared : <TAB> <TAB> <TAB> <TAB> self. reset_data = shared [ ""reset"" ] <TAB> <TAB> <TAB> <TAB> self. datafile = shared [ ""datafile"" ] <TAB> <TAB> self. data_loader = shared [ ""data_loader"" ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. lock = shared [ ""lock"" ] <TAB> else : <TAB> <TAB> <TAB> <TAB> self. data_loader = data_loader <TAB> <TAB> if ""datafile"" not in opt : <TAB> <TAB> <TAB> raise KeyError ( <TAB> <TAB> <TAB> <TAB> ERROR_MESSAGE_NO_DATAFILE. format ( class_name = self. __class__. __name__ ) <TAB> <TAB> <TAB> ) <TAB> <TAB> self. datafile = opt [ ""datafile"" ] <TAB> <TAB> self. reset_data = None <TAB> <TAB> self. is_reset = True <TAB> self. entry_idx = 0 <TAB> self. cur_episode = self. _FIRST_PASS <TAB> self. num_eps = None <TAB> self. num_exs = None <TAB> self. rank = get_rank ( ) <TAB> self. num_workers = num_workers ( ) <TAB> self. is_distributed_and_is_eval = ( <TAB> <TAB> self. num_workers > 1 and not DatatypeHelper. is_training ( opt [ ""datatype"" ] ) <TAB> )",False,'lock' in shared,shared,0.6630645394325256
|
||
|
974,"def to_mongo ( self, document ) : <TAB> if isinstance ( document, DBRef ) : <TAB> <TAB> if not self. dbref : <TAB> <TAB> <TAB> return document. id <TAB> <TAB> return document <TAB> if isinstance ( document, Document ) : <TAB> <TAB> <TAB> <TAB> id_ = document. pk <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. error ( <TAB> <TAB> <TAB> <TAB> ""You can only reference documents once they have"" <TAB> <TAB> <TAB> <TAB> "" been saved to the database"" <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> cls = document <TAB> else : <TAB> <TAB> id_ = document <TAB> <TAB> cls = self. document_type <TAB> id_field_name = cls. _meta [ ""id_field"" ] <TAB> id_field = cls. _fields [ id_field_name ] <TAB> id_ = id_field. to_mongo ( id_ ) <TAB> if self. document_type. _meta. get ( ""abstract"" ) : <TAB> <TAB> collection = cls. _get_collection_name ( ) <TAB> <TAB> return DBRef ( collection, id_, cls = cls. _class_name ) <TAB> elif self. dbref : <TAB> <TAB> collection = cls. _get_collection_name ( ) <TAB> <TAB> return DBRef ( collection, id_ ) <TAB> return id_",False,id_ is None,id_ == None,0.6651803255081177
|
||
|
975,"def get_subkeys ( self, key ) : <TAB> <TAB> <TAB> parent_path = key. get_path ( ) <TAB> subkeys = [ ] <TAB> for k in self. keys : <TAB> <TAB> test_path = k. get_path ( ) <TAB> <TAB> if test_path. lower ( ). startswith ( parent_path. lower ( ) ) : <TAB> <TAB> <TAB> sub = test_path [ len ( parent_path ) : ] <TAB> <TAB> <TAB> if sub. startswith ( ""\\"" ) : <TAB> <TAB> <TAB> <TAB> sub = sub [ 1 : ] <TAB> <TAB> <TAB> end_slash = sub. find ( ""\\"" ) <TAB> <TAB> <TAB> if end_slash >= 0 : <TAB> <TAB> <TAB> <TAB> sub = sub [ : end_slash ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> subkeys. append ( sub ) <TAB> return subkeys",False,not sub,end_slash == -1,0.6703736186027527
|
||
|
976,"def generator ( self, data ) : <TAB> if self. _config. SILENT : <TAB> <TAB> silent_vars = self. _get_silent_vars ( ) <TAB> for task in data : <TAB> <TAB> for var, val in task. environment_variables ( ) : <TAB> <TAB> <TAB> if self. _config. SILENT : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> yield ( <TAB> <TAB> <TAB> <TAB> 0, <TAB> <TAB> <TAB> <TAB> [ <TAB> <TAB> <TAB> <TAB> <TAB> int ( task. UniqueProcessId ), <TAB> <TAB> <TAB> <TAB> <TAB> str ( task. ImageFileName ), <TAB> <TAB> <TAB> <TAB> <TAB> Address ( task. Peb. ProcessParameters. Environment ), <TAB> <TAB> <TAB> <TAB> <TAB> str ( var ), <TAB> <TAB> <TAB> <TAB> <TAB> str ( val ), <TAB> <TAB> <TAB> <TAB> ], <TAB> <TAB> <TAB> )",False,var in silent_vars,silent_vars,0.6612224578857422
|
||
|
977,"def get_documents_data ( self ) : <TAB> """"""Return Editors: path, project, cursor position"""""" <TAB> files = [ ] <TAB> for i in range ( self. count ( ) ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> files. append ( [ self. widget ( i ). ID, self. widget ( i ). get_cursor_position ( ) ] ) <TAB> <TAB> <TAB> self. widget ( i ). _sidebarWidget. _save_breakpoints_bookmarks ( ) <TAB> return files",False,type(self.widget(i)) is editor.Editor and self.widget(i).ID != '',self.widget(i).exists(),0.6579665541648865
|
||
|
978,"def get ( self, block = True, timeout = None ) : <TAB> self. not_empty. acquire ( ) <TAB> try : <TAB> <TAB> if not block : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return None <TAB> <TAB> elif timeout is None : <TAB> <TAB> <TAB> while self. qsize ( ) == 0 : <TAB> <TAB> <TAB> <TAB> self. not_empty. wait ( ) <TAB> <TAB> elif timeout < 0 : <TAB> <TAB> <TAB> raise ValueError ( ""'timeout' must be a positive number"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> end_time = time. time ( ) + timeout <TAB> <TAB> <TAB> while not self. qsize ( ) : <TAB> <TAB> <TAB> <TAB> remaining = end_time - time. time ( ) <TAB> <TAB> <TAB> <TAB> if remaining <= 0.0 : <TAB> <TAB> <TAB> <TAB> <TAB> return None <TAB> <TAB> <TAB> <TAB> self. not_empty. wait ( remaining ) <TAB> <TAB> item = self. _get ( ) <TAB> <TAB> return item <TAB> finally : <TAB> <TAB> self. not_empty. release ( )",True,self.qsize() == 0,self.qsize() == 0,0.6634102463722229
|
||
|
979,"def _optimize ( <TAB> self, S : np. ndarray, u : Optional [ np. ndarray ] = None, w0 : Optional [ np. ndarray ] = None ) -> np. ndarray : <TAB> <TAB> if self. method == self. OPT_INV : <TAB> <TAB> if u is not None : <TAB> <TAB> <TAB> warnings. warn ( ""`u` is set but will not be used for `inv` portfolio"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> warnings. warn ( ""`w0` is set but will not be used for `inv` portfolio"" ) <TAB> <TAB> return self. _optimize_inv ( S ) <TAB> <TAB> if self. method == self. OPT_GMV : <TAB> <TAB> if u is not None : <TAB> <TAB> <TAB> warnings. warn ( ""`u` is set but will not be used for `gmv` portfolio"" ) <TAB> <TAB> return self. _optimize_gmv ( S, w0 ) <TAB> <TAB> if self. method == self. OPT_MVO : <TAB> <TAB> return self. _optimize_mvo ( S, u, w0 ) <TAB> <TAB> if self. method == self. OPT_RP : <TAB> <TAB> if u is not None : <TAB> <TAB> <TAB> warnings. warn ( ""`u` is set but will not be used for `rp` portfolio"" ) <TAB> <TAB> return self. _optimize_rp ( S, w0 )",True,w0 is not None,w0 is not None,0.6668111085891724
|
||
|
980,"def getTempMarkdownPreviewPath ( view ) : <TAB> """"""return a permanent full path of the temp markdown preview file"""""" <TAB> settings = sublime. load_settings ( ""MarkdownPreview.sublime-settings"" ) <TAB> tmp_filename = ""%s.html"" % view. id ( ) <TAB> tmp_dir = tempfile. gettempdir ( ) <TAB> if settings. get ( ""path_tempfile"" ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> tmp_dir = settings. get ( ""path_tempfile"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> tmp_dir = os. path. join ( <TAB> <TAB> <TAB> <TAB> os. path. dirname ( view. file_name ( ) ), settings. get ( ""path_tempfile"" ) <TAB> <TAB> <TAB> ) <TAB> if not os. path. isdir ( tmp_dir ) : <TAB> <TAB> os. makedirs ( tmp_dir ) <TAB> tmp_fullpath = os. path. join ( tmp_dir, tmp_filename ) <TAB> return tmp_fullpath",False,os.path.isabs(settings.get('path_tempfile')),view.file_name() == None,0.6477821469306946
|
||
|
981,"def compute_value ( self ) : <TAB> now = int ( time. time ( ) ) <TAB> current_interval = now - ( now % self. aggregation_frequency ) <TAB> age_threshold = current_interval - ( <TAB> <TAB> settings [ ""MAX_AGGREGATION_INTERVALS"" ] * self. aggregation_frequency <TAB> ) <TAB> for buffer in list ( self. interval_buffers. values ( ) ) : <TAB> <TAB> if buffer. active : <TAB> <TAB> <TAB> value = self. aggregation_func ( buffer. values ) <TAB> <TAB> <TAB> datapoint = ( buffer. interval, value ) <TAB> <TAB> <TAB> state. events. metricGenerated ( self. metric_path, datapoint ) <TAB> <TAB> <TAB> state. instrumentation. increment ( ""aggregateDatapointsSent"" ) <TAB> <TAB> <TAB> buffer. mark_inactive ( ) <TAB> <TAB> if buffer. interval < age_threshold : <TAB> <TAB> <TAB> del self. interval_buffers [ buffer. interval ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. close ( ) <TAB> <TAB> <TAB> <TAB> self. configured = False <TAB> <TAB> <TAB> <TAB> del BufferManager. buffers [ self. metric_path ]",False,not self.interval_buffers,self.configured,0.6556923389434814
|
||
|
982,"def selectRow ( self, rowNumber, highlight = None ) : <TAB> if rowNumber == ""h"" : <TAB> <TAB> rowNumber = 0 <TAB> else : <TAB> <TAB> rowNumber = int ( rowNumber ) + 1 <TAB> if 1 > rowNumber >= len ( self. cells ) + 1 : <TAB> <TAB> raise Exception ( ""Invalid row number."" ) <TAB> else : <TAB> <TAB> selected = self. cells [ rowNumber ] [ 0 ]. selected <TAB> <TAB> for cell in self. cells [ rowNumber ] : <TAB> <TAB> <TAB> if highlight is None : <TAB> <TAB> <TAB> <TAB> if selected : <TAB> <TAB> <TAB> <TAB> <TAB> cell. deselect ( ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> cell. select ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> cell. mouseEnter ( ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> cell. mouseLeave ( )",True,highlight,highlight,0.7138727307319641
|
||
|
983,"def kendall_tau ( a, b ) : <TAB> n_samples = a. shape [ 0 ] <TAB> assert a. shape == b. shape <TAB> n_concordant = 0 <TAB> n_disconcordant = 0 <TAB> for i in range ( n_samples ) : <TAB> <TAB> for j in range ( i + 1, n_samples ) : <TAB> <TAB> <TAB> if a [ i ] > a [ j ] and b [ i ] > b [ j ] : <TAB> <TAB> <TAB> <TAB> n_concordant = n_concordant + 1 <TAB> <TAB> <TAB> if a [ i ] < a [ j ] and b [ i ] < b [ j ] : <TAB> <TAB> <TAB> <TAB> n_concordant = n_concordant + 1 <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> n_disconcordant = n_disconcordant + 1 <TAB> <TAB> <TAB> if a [ i ] < a [ j ] and b [ i ] > b [ j ] : <TAB> <TAB> <TAB> <TAB> n_disconcordant = n_disconcordant + 1 <TAB> return ( n_concordant - n_disconcordant ) / ( 0.5 * n_samples * ( n_samples - 1 ) )",False,a[i] > a[j] and b[i] < b[j],n_concordant > 0,0.6508519649505615
|
||
|
984,"def reader ( ) : <TAB> with open ( file_list ) as flist : <TAB> <TAB> full_lines = [ line. strip ( ) for line in flist ] <TAB> <TAB> if shuffle : <TAB> <TAB> <TAB> random. shuffle ( full_lines ) <TAB> <TAB> if mode == ""train"" : <TAB> <TAB> <TAB> trainer_id = int ( os. getenv ( ""PADDLE_TRAINER_ID"" ) ) <TAB> <TAB> <TAB> trainer_count = int ( os. getenv ( ""PADDLE_TRAINERS"" ) ) <TAB> <TAB> <TAB> per_node_lines = len ( full_lines ) / trainer_count <TAB> <TAB> <TAB> lines = full_lines [ <TAB> <TAB> <TAB> <TAB> trainer_id * per_node_lines : ( trainer_id + 1 ) * per_node_lines <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> ""read images from %d, length: %d, lines length: %d, total: %d"" <TAB> <TAB> <TAB> <TAB> % ( <TAB> <TAB> <TAB> <TAB> <TAB> trainer_id * per_node_lines, <TAB> <TAB> <TAB> <TAB> <TAB> per_node_lines, <TAB> <TAB> <TAB> <TAB> <TAB> len ( lines ), <TAB> <TAB> <TAB> <TAB> <TAB> len ( full_lines ), <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> lines = full_lines <TAB> <TAB> for line in lines : <TAB> <TAB> <TAB> if mode == ""train"" : <TAB> <TAB> <TAB> <TAB> img_path, label = line. split ( ) <TAB> <TAB> <TAB> <TAB> img_path = img_path. replace ( ""JPEG"", ""jpeg"" ) <TAB> <TAB> <TAB> <",False,mode == 'val',len(line) > 0,0.6595242023468018
|
||
|
985,"def on_task_start ( self, task, config ) : <TAB> """"""Task starting, install cookiejar"""""" <TAB> import os <TAB> config = self. prepare_config ( config ) <TAB> cookie_type = config. get ( ""type"" ) <TAB> cookie_file = os. path. expanduser ( config. get ( ""file"" ) ) <TAB> cj = self. cookiejars. get ( cookie_file, None ) <TAB> if cj is not None : <TAB> <TAB> log. debug ( ""Loading cookiejar from cache."" ) <TAB> elif cookie_type == ""firefox3"" : <TAB> <TAB> log. debug ( ""Loading %s cookies"" % cookie_type ) <TAB> <TAB> cj = self. sqlite2cookie ( cookie_file ) <TAB> <TAB> self. cookiejars [ cookie_file ] = cj <TAB> else : <TAB> <TAB> if cookie_type == ""mozilla"" : <TAB> <TAB> <TAB> log. debug ( ""Loading %s cookies"" % cookie_type ) <TAB> <TAB> <TAB> cj = http. cookiejar. MozillaCookieJar ( ) <TAB> <TAB> <TAB> self. cookiejars [ cookie_file ] = cj <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> log. debug ( ""Loading %s cookies"" % cookie_type ) <TAB> <TAB> <TAB> cj = http. cookiejar. LWPCookieJar ( ) <TAB> <TAB> <TAB> self. cookiejars [ cookie_file ] = cj <TAB> <TAB> else : <TAB> <TAB> <TAB> raise plugin. PluginError ( ""Unknown cookie type %s"" % cookie_type, log ) <TAB> <TAB> try : <TAB> <TAB> <TAB> cj. load ( filename = cookie_file, ignore_expires = True ) <TAB> <TAB> <TAB> log. debug ( ""%s cookies loaded"" % cookie_type ) <TAB> <TAB> except ( http. cookiejar. LoadError, IOError ) : <TAB> <TAB> <TAB> import sys <TAB> <TAB> <TAB> raise plugin. PluginError ( <TAB> <TAB> <TAB> <",False,cookie_type == 'lwp',cookie_type == 'lWPCcookie',0.6705670952796936
|
||
|
986,"def dont_let_stderr_buffer ( ) : <TAB> while True : <TAB> <TAB> line = context. daemon. stderr. readline ( ) <TAB> <TAB> if not line : <TAB> <TAB> <TAB> return <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> context. num_workers_crashed += 1 <TAB> <TAB> print ( f""deployd stderr: {line}"" )",False,DEAD_DEPLOYD_WORKER_MESSAGE.encode('utf-8') in line,context.num_workers_crashed >= len(line),0.6471341252326965
|
||
|
987,"def expand ( self, pvalue ) : <TAB> result = { } <TAB> for dataset_key_idx, dataset_key in enumerate ( self. _sorted_dataset_keys ) : <TAB> <TAB> dataset_cache_path = _get_dataset_cache_path ( self. _cache_base_dir, dataset_key ) <TAB> <TAB> manifest_file = _ManifestFile ( dataset_cache_path ) <TAB> <TAB> manifest = manifest_file. read ( ) <TAB> <TAB> if not manifest : <TAB> <TAB> <TAB> continue <TAB> <TAB> result [ dataset_key ] = { } <TAB> <TAB> for key, cache_key_idx in manifest. items ( ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> result [ dataset_key ] [ <TAB> <TAB> <TAB> <TAB> <TAB> key <TAB> <TAB> <TAB> <TAB> ] = pvalue. pipeline | ""Read[AnalysisIndex{}][CacheKeyIndex{}]"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> dataset_key_idx, cache_key_idx <TAB> <TAB> <TAB> <TAB> ) >> self. _source ( <TAB> <TAB> <TAB> <TAB> <TAB> ""{}{}"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> os. path. join ( dataset_cache_path, str ( cache_key_idx ) ), ""-*-of-*"" <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> ) <TAB> return result",False,self._should_read_cache_entry_key(key),key in result,0.6488548517227173
|
||
|
988,"def compute ( self, split ) : <TAB> import msgpack <TAB> with closing ( self. open_file ( ) ) as f : <TAB> <TAB> magic = f. read ( 8 ) <TAB> <TAB> start = split. index * self. splitSize <TAB> <TAB> end = ( split. index + 1 ) * self. splitSize <TAB> <TAB> start = self. find_magic ( f, start, magic ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return <TAB> <TAB> f. seek ( start ) <TAB> <TAB> hdr_size = 12 <TAB> <TAB> while start < end : <TAB> <TAB> <TAB> m = f. read ( len ( magic ) ) <TAB> <TAB> <TAB> if m!= magic : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> compressed, count, size = struct. unpack ( ""III"", f. read ( hdr_size ) ) <TAB> <TAB> <TAB> d = f. read ( size ) <TAB> <TAB> <TAB> assert len ( d ) == size, ""unexpected end"" <TAB> <TAB> <TAB> if compressed : <TAB> <TAB> <TAB> <TAB> d = zlib. decompress ( d ) <TAB> <TAB> <TAB> for r in msgpack. Unpacker ( BytesIO ( d ) ) : <TAB> <TAB> <TAB> <TAB> yield r <TAB> <TAB> <TAB> start += len ( magic ) + hdr_size + size",False,start < 0,start == end,0.6737005710601807
|
||
|
989,"def _checkHttpProxy ( selfip, proxies, isHttp = True ) : <TAB> types = - 1 <TAB> speed = - 1 <TAB> if isHttp : <TAB> <TAB> test_url = config. TEST_HTTP_HEADER <TAB> else : <TAB> <TAB> test_url = config. TEST_HTTPS_HEADER <TAB> try : <TAB> <TAB> start = time. time ( ) <TAB> <TAB> r = requests. get ( <TAB> <TAB> <TAB> url = test_url, <TAB> <TAB> <TAB> headers = config. get_header ( ), <TAB> <TAB> <TAB> timeout = config. TIMEOUT, <TAB> <TAB> <TAB> proxies = proxies, <TAB> <TAB> ) <TAB> <TAB> if r. ok : <TAB> <TAB> <TAB> speed = round ( time. time ( ) - start, 2 ) <TAB> <TAB> <TAB> content = json. loads ( r. text ) <TAB> <TAB> <TAB> headers = content [ ""headers"" ] <TAB> <TAB> <TAB> ip = content [ ""origin"" ] <TAB> <TAB> <TAB> proxy_connection = headers. get ( ""Proxy-Connection"", None ) <TAB> <TAB> <TAB> if "","" in ip : <TAB> <TAB> <TAB> <TAB> types = 2 <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> types = 1 <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> types = 0 <TAB> <TAB> <TAB> return True, types, speed <TAB> <TAB> else : <TAB> <TAB> <TAB> return False, types, speed <TAB> except Exception as e : <TAB> <TAB> return False, types, speed",False,proxy_connection,'.' in proxy_connection,0.6645303964614868
|
||
|
990,"def cube_report ( cube_name ) : <TAB> report_request = json. loads ( request. data ) <TAB> try : <TAB> <TAB> queries = report_request [ ""queries"" ] <TAB> except KeyError : <TAB> <TAB> raise RequestError ( ""Report request does not contain 'queries' key"" ) <TAB> cell_cuts = report_request. get ( ""cell"" ) <TAB> if cell_cuts : <TAB> <TAB> <TAB> <TAB> cuts = [ cut_from_dict ( cut ) for cut in cell_cuts ] <TAB> <TAB> cell = Cell ( g. cube, cuts ) <TAB> <TAB> logger. info ( <TAB> <TAB> <TAB> ""using cell from report specification (URL parameters "" ""are ignored)"" <TAB> <TAB> ) <TAB> <TAB> if workspace. authorizer : <TAB> <TAB> <TAB> cell = workspace. authorizer. restricted_cell ( <TAB> <TAB> <TAB> <TAB> g. auth_identity, cube = g. cube, cell = cell <TAB> <TAB> <TAB> ) <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> cell = Cell ( g. cube ) <TAB> <TAB> else : <TAB> <TAB> <TAB> cell = g. cell <TAB> result = g. browser. report ( cell, queries ) <TAB> return jsonify ( result )",False,not g.cell,cube_name,0.662129282951355
|
||
|
991,"def read_lccn ( line, is_marc8 = False ) : <TAB> found = [ ] <TAB> for k, v in get_raw_subfields ( line, [ ""a"" ] ) : <TAB> <TAB> lccn = v. strip ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> m = re_lccn. search ( lccn ) <TAB> <TAB> if not m : <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> lccn = re_letters_and_bad. sub ( """", m. group ( 1 ) ). strip ( ) <TAB> <TAB> if lccn : <TAB> <TAB> <TAB> found. append ( lccn ) <TAB> return found",False,re_question.match(lccn),is_marc8 and lccn,0.6495903730392456
|
||
|
992,"def set_shape ( self, shape ) : <TAB> """"""Sets a shape."""""" <TAB> if self. _shape is not None : <TAB> <TAB> logger. warning ( 'Modifying the shape of Placeholder ""%s"".', self. name ) <TAB> if not isinstance ( shape, ( list, tuple ) ) : <TAB> <TAB> shape = ( shape, ) <TAB> shape = tuple ( x if x!= ""None"" else None for x in shape ) <TAB> for x in shape : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ParsingError ( <TAB> <TAB> <TAB> <TAB> 'All entries in ""shape"" must be integers, or in special'<TAB> <TAB> <TAB> <TAB> ""cases None. Shape is: {}"". format ( shape ) <TAB> <TAB> <TAB> ) <TAB> self. _shape = shape",False,"not isinstance(x, (int, type(None)))",not (x == 'None' or x == 'cases'),0.6489138603210449
|
||
|
993,"def evaluateWord ( self, argument ) : <TAB> wildcard_count = argument [ 0 ]. count ( ""*"" ) <TAB> if wildcard_count > 0 : <TAB> <TAB> if wildcard_count == 1 and argument [ 0 ]. startswith ( ""*"" ) : <TAB> <TAB> <TAB> return self. GetWordWildcard ( argument [ 0 ] [ 1 : ], method = ""endswith"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return self. GetWordWildcard ( argument [ 0 ] [ : - 1 ], method = ""startswith"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> _regex = argument [ 0 ]. replace ( ""*"", "".+"" ) <TAB> <TAB> <TAB> matched = False <TAB> <TAB> <TAB> for w in self. words : <TAB> <TAB> <TAB> <TAB> matched = bool ( re. search ( _regex, w ) ) <TAB> <TAB> <TAB> <TAB> if matched : <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> return matched <TAB> return self. GetWord ( argument [ 0 ] )",False,wildcard_count == 1 and argument[0].endswith('*'),wildcard_count == 1,0.6540383100509644
|
||
|
994,"def __init__ ( self, changes, useweeks ) : <TAB> authordateinfo_list = sorted ( changes. get_authordateinfo_list ( ). items ( ) ) <TAB> self. changes = changes <TAB> self. entries = { } <TAB> self. total_changes_by_period = { } <TAB> self. useweeks = useweeks <TAB> for i in authordateinfo_list : <TAB> <TAB> key = None <TAB> <TAB> if useweeks : <TAB> <TAB> <TAB> yearweek = datetime. date ( <TAB> <TAB> <TAB> <TAB> int ( i [ 0 ] [ 0 ] [ 0 : 4 ] ), int ( i [ 0 ] [ 0 ] [ 5 : 7 ] ), int ( i [ 0 ] [ 0 ] [ 8 : 10 ] ) <TAB> <TAB> <TAB> ). isocalendar ( ) <TAB> <TAB> <TAB> key = ( i [ 0 ] [ 1 ], str ( yearweek [ 0 ] ) + ""W"" + ""{0:02d}"". format ( yearweek [ 1 ] ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> key = ( i [ 0 ] [ 1 ], i [ 0 ] [ 0 ] [ 0 : 7 ] ) <TAB> <TAB> if self. entries. get ( key, None ) == None : <TAB> <TAB> <TAB> self. entries [ key ] = i [ 1 ] <TAB> <TAB> else : <TAB> <TAB> <TAB> self. entries [ key ]. insertions += i [ 1 ]. insertions <TAB> <TAB> <TAB> self. entries [ key ]. deletions += i [ 1 ]. deletions <TAB> for period in self. get_periods ( ) : <TAB> <TAB> total_insertions = 0 <TAB> <TAB> total_deletions = 0 <TAB> <TAB> for author in self. get_authors ( ) : <TAB> <TAB> <TAB> entry = self. entries. get ( ( author [ 0 ], period ), None ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> total_insertions",False,entry != None,entry,0.6711770296096802
|
||
|
995,"def update_ui ( self ) : <TAB> self. _action_group. set_sensitive ( self. _window. get_active_document ( )!= None ) <TAB> self. doc = self. _window. get_active_document ( ) <TAB> if self. doc : <TAB> <TAB> self. view = self. _window. get_active_view ( ) <TAB> <TAB> self. view. connect ( ""key-press-event"", self. fold_off ) <TAB> <TAB> table = self. doc. get_tag_table ( ) <TAB> <TAB> self. fld = table. lookup ( ""fld"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. fld = self. doc. create_tag ( <TAB> <TAB> <TAB> <TAB> ""fld"", foreground = ""#333333"", paragraph_background = ""#aadc5c"" <TAB> <TAB> <TAB> ) <TAB> <TAB> self. inv = table. lookup ( ""inv"" ) <TAB> <TAB> if self. inv == None : <TAB> <TAB> <TAB> self. inv = self. doc. create_tag ( ""inv"", invisible = True )",True,self.fld == None,self.fld == None,0.6581529974937439
|
||
|
996,"def schedule_logger ( job_id = None, delete = False ) : <TAB> if not job_id : <TAB> <TAB> return getLogger ( ""fate_flow_schedule"" ) <TAB> else : <TAB> <TAB> if delete : <TAB> <TAB> <TAB> with LoggerFactory. lock : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> for key in LoggerFactory. schedule_logger_dict. keys ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> del LoggerFactory. schedule_logger_dict [ key ] <TAB> <TAB> <TAB> <TAB> except : <TAB> <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> return True <TAB> <TAB> key = job_id + ""schedule"" <TAB> <TAB> if key in LoggerFactory. schedule_logger_dict : <TAB> <TAB> <TAB> return LoggerFactory. schedule_logger_dict [ key ] <TAB> <TAB> return LoggerFactory. get_schedule_logger ( job_id )",False,job_id in key,key in LoggerFactory.schedule_logger_dict,0.6663422584533691
|
||
|
997,"def layout_draw_solid_categories ( layout, node_details, sub_category ) : <TAB> for node_info in node_details : <TAB> <TAB> if node_info [ 0 ] == ""separator"" : <TAB> <TAB> <TAB> layout. separator ( ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if not node_info : <TAB> <TAB> <TAB> print ( repr ( node_info ), ""is incomplete, or unparsable"" ) <TAB> <TAB> <TAB> continue <TAB> <TAB> bl_idname = node_info [ 0 ] <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> node_ref = get_node_class_reference ( bl_idname ) <TAB> <TAB> if hasattr ( node_ref, ""bl_label"" ) : <TAB> <TAB> <TAB> layout_params = dict ( text = node_ref. bl_label, ** node_icon ( node_ref ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> continue <TAB> <TAB> if ( <TAB> <TAB> <TAB> hasattr ( node_ref, ""solid_catergory"" ) <TAB> <TAB> <TAB> and node_ref. solid_catergory == sub_category <TAB> <TAB> ) : <TAB> <TAB> <TAB> node_op = draw_add_node_operator ( layout, bl_idname, params = layout_params )",False,bl_idname == 'ScalarMathNode',not bl_idname,0.6586661338806152
|
||
|
998,"def get_boxes ( self, generation, what ) : <TAB> retval = """" <TAB> if self. box_mode == ""UTF"" : <TAB> <TAB> space = "" "" <TAB> elif self. box_mode == ""ASCII"" : <TAB> <TAB> space = "" "" <TAB> space_len = len ( space ) + 2 <TAB> for i in range ( generation + 1 ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> retval += space + ""|"" <TAB> <TAB> else : <TAB> <TAB> <TAB> retval += space + "" "" <TAB> if retval [ - 1 ] == "" "" : <TAB> <TAB> if what == ""sf"" : <TAB> <TAB> <TAB> retval = retval [ : - space_len ] + ""/"" <TAB> <TAB> elif what == ""sm"" : <TAB> <TAB> <TAB> retval = retval [ : - space_len ] + ""\\"" <TAB> elif retval. endswith ( ""|"" + space + ""|"" ) : <TAB> <TAB> retval = retval [ : - space_len ] + ""+"" <TAB> if self. box_mode == ""UTF"" : <TAB> <TAB> retval += ""-"" <TAB> <TAB> retval = retval. replace ( ""\\"", ""\u2514"" ) <TAB> <TAB> retval = retval. replace ( ""-"", ""\u2500"" ) <TAB> <TAB> retval = retval. replace ( ""|"", ""\u2502"" ) <TAB> <TAB> retval = retval. replace ( ""/"", ""\u250c"" ) <TAB> elif self. box_mode == ""ASCII"" : <TAB> <TAB> retval += ""--"" <TAB> return retval",False,self._boxes[i],i == 0,0.6571937203407288
|
||
|
999,"def do_query ( data, q ) : <TAB> ret = [ ] <TAB> if not q : <TAB> <TAB> return ret <TAB> qkey = q [ 0 ] <TAB> for key, value in iterate ( data ) : <TAB> <TAB> if len ( q ) == 1 : <TAB> <TAB> <TAB> if key == qkey : <TAB> <TAB> <TAB> <TAB> ret. append ( value ) <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> ret. extend ( do_query ( value, q ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if not is_iterable ( value ) : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if key == qkey : <TAB> <TAB> <TAB> <TAB> ret. extend ( do_query ( value, q [ 1 : ] ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> ret. extend ( do_query ( value, q ) ) <TAB> return ret",False,is_iterable(value),len(q) == 2,0.6517411470413208
|
||
|
1000,"def token_producer ( source ) : <TAB> token = source. read_uint8 ( ) <TAB> while token is not None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> yield DataToken ( read_data ( token, source ) ) <TAB> <TAB> elif is_small_integer ( token ) : <TAB> <TAB> <TAB> yield SmallIntegerToken ( read_small_integer ( token ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> yield Token ( token ) <TAB> <TAB> token = source. read_uint8 ( )",False,is_push_data_token(token),is_data(token),0.6522794961929321
|
||
|
1001,"def _generate_toc ( self ) : <TAB> """"""Generate key-to-(start, stop) table of contents."""""" <TAB> starts, stops = [ ], [ ] <TAB> last_was_empty = False <TAB> self. _file. seek ( 0 ) <TAB> while True : <TAB> <TAB> line_pos = self. _file. tell ( ) <TAB> <TAB> line = self. _file. readline ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if len ( stops ) < len ( starts ) : <TAB> <TAB> <TAB> <TAB> if last_was_empty : <TAB> <TAB> <TAB> <TAB> <TAB> stops. append ( line_pos - len ( os. linesep ) ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> stops. append ( line_pos ) <TAB> <TAB> <TAB> starts. append ( line_pos ) <TAB> <TAB> <TAB> last_was_empty = False <TAB> <TAB> elif not line : <TAB> <TAB> <TAB> if last_was_empty : <TAB> <TAB> <TAB> <TAB> stops. append ( line_pos - len ( os. linesep ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> stops. append ( line_pos ) <TAB> <TAB> <TAB> break <TAB> <TAB> elif line == os. linesep : <TAB> <TAB> <TAB> last_was_empty = True <TAB> <TAB> else : <TAB> <TAB> <TAB> last_was_empty = False <TAB> self. _toc = dict ( enumerate ( zip ( starts, stops ) ) ) <TAB> self. _next_key = len ( self. _toc ) <TAB> self. _file_length = self. _file. tell ( )",False,line.startswith('From '),line,0.6488137245178223
|
||
|
1002,"def __set__ ( self, obj, value ) : <TAB> if ( <TAB> <TAB> value is not None <TAB> <TAB> and self. field. _currency_field. null <TAB> <TAB> and not isinstance ( value, MONEY_CLASSES + ( Decimal, ) ) <TAB> ) : <TAB> <TAB> <TAB> <TAB> raise ValueError ( ""Missing currency value"" ) <TAB> if isinstance ( value, BaseExpression ) : <TAB> <TAB> if isinstance ( value, Value ) : <TAB> <TAB> <TAB> value = self. prepare_value ( obj, value. value ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> validate_money_expression ( obj, value ) <TAB> <TAB> <TAB> prepare_expression ( value ) <TAB> else : <TAB> <TAB> value = self. prepare_value ( obj, value ) <TAB> obj. __dict__ [ self. field. name ] = value",False,"not isinstance(value, Func)","isinstance(value, MONEY_CLASSES)",0.6532878279685974
|
||
|
1003,"def _collect_peers_of_interest ( self, new_best_path ) : <TAB> """"""Collect all peers that qualify for sharing a path with given RTs."""""" <TAB> path_rts = new_best_path. get_rts ( ) <TAB> qualified_peers = set ( self. _peers. values ( ) ) <TAB> <TAB> qualified_peers = self. _rt_manager. filter_by_origin_as ( <TAB> <TAB> new_best_path, qualified_peers <TAB> ) <TAB> <TAB> <TAB> <TAB> if path_rts : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> path_rts. append ( RouteTargetMembershipNLRI. DEFAULT_RT ) <TAB> <TAB> <TAB> <TAB> qualified_peers = set ( self. _get_non_rtc_peers ( ) ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> peer_to_rtfilter_map = self. _peer_to_rtfilter_map <TAB> <TAB> for peer, rt_filter in peer_to_rtfilter_map. items ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if rt_filter is None : <TAB> <TAB> <TAB> <TAB> qualified_peers. add ( peer ) <TAB> <TAB> <TAB> elif rt_filter. intersection ( path_rts ) : <TAB> <TAB> <TAB> <TAB> qualified_peers. add ( peer ) <TAB> return qualified_peers",True,peer is None,peer is None,0.6669421195983887
|
||
|
1004,"def get_integration ( integration, * args, ** kwargs ) : <TAB> """"""Return a integration instance specified by `integration` name"""""" <TAB> klass = integration_cache. get ( integration, None ) <TAB> if not klass : <TAB> <TAB> integration_filename = ""%s_integration"" % integration <TAB> <TAB> integration_module = None <TAB> <TAB> for app in settings. INSTALLED_APPS : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> integration_module = import_module ( <TAB> <TAB> <TAB> <TAB> <TAB> "".integrations.%s"" % integration_filename, package = app <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> except ImportError : <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise IntegrationModuleNotFound ( ""Missing integration: %s"" % ( integration ) ) <TAB> <TAB> integration_class_name = """". join ( integration_filename. title ( ). split ( ""_"" ) ) <TAB> <TAB> try : <TAB> <TAB> <TAB> klass = getattr ( integration_module, integration_class_name ) <TAB> <TAB> except AttributeError : <TAB> <TAB> <TAB> raise IntegrationNotConfigured ( <TAB> <TAB> <TAB> <TAB> ""Missing %s class in the integration module."" % integration_class_name <TAB> <TAB> <TAB> ) <TAB> <TAB> integration_cache [ integration ] = klass <TAB> return klass ( * args, ** kwargs )",False,not integration_module,integration_module is None,0.6701433658599854
|
||
|
1005,"def parse_rules ( self, content ) : <TAB> end_fix = [ ] <TAB> hosts = [ ] <TAB> content = utils. to_bytes ( content ) <TAB> content = content. replace ( b"","", b""\n"" ). replace ( b"";"", b""\n"" ) <TAB> lines = content. split ( b""\n"" ) <TAB> for line in lines : <TAB> <TAB> line = line. strip ( ) <TAB> <TAB> if not line : <TAB> <TAB> <TAB> continue <TAB> <TAB> if b""="" in line : <TAB> <TAB> <TAB> lp = line. split ( b""="" ) <TAB> <TAB> <TAB> left = lp [ 0 ]. strip ( ) <TAB> <TAB> <TAB> right = lp [ 1 ]. strip ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> left = line <TAB> <TAB> <TAB> right = None <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> left = left [ 7 : ] <TAB> <TAB> if left. startswith ( b""https://"" ) : <TAB> <TAB> <TAB> left = left [ 8 : ] <TAB> <TAB> if left. startswith ( b""*"" ) : <TAB> <TAB> <TAB> left = left [ 1 : ] <TAB> <TAB> if b""/"" in left : <TAB> <TAB> <TAB> p = left. find ( b""/"" ) <TAB> <TAB> <TAB> host = left [ : p ] <TAB> <TAB> else : <TAB> <TAB> <TAB> host = left <TAB> <TAB> if host. startswith ( b""."" ) : <TAB> <TAB> <TAB> end_fix. append ( host ) <TAB> <TAB> elif host. startswith ( b""*."" ) : <TAB> <TAB> <TAB> end_fix. append ( host [ 1 : ] ) <TAB> <TAB> else : <TAB> <TAB> <TAB> hosts. append ( host ) <TAB> return hosts, end_fix",False,left.startswith(b'http://'),right,0.645950436592102
|
||
|
1006,"def execute_and_fetch ( self, q ) : <TAB> try : <TAB> <TAB> if self. show_sql : <TAB> <TAB> <TAB> print ( repr ( q ) ) <TAB> <TAB> self. cursor. execute ( q ) <TAB> <TAB> if self. cursor. description is not None : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> query_column_names = [ <TAB> <TAB> <TAB> <TAB> <TAB> unicode ( c [ 0 ], ""utf-8"" ) for c in self. cursor. description <TAB> <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> query_column_names = [ c [ 0 ] for c in self. cursor. description ] <TAB> <TAB> else : <TAB> <TAB> <TAB> query_column_names = None <TAB> <TAB> result = self. cursor. fetchall ( ) <TAB> finally : <TAB> <TAB> pass <TAB> return Sqlite3DBResults ( query_column_names, result )",False,six.PY2,"isinstance(self.cursor.description, list)",0.6689985990524292
|
||
|
1007,"def set_xml_text_value ( self, target, xmltarget ) : <TAB> if ""<"" in target : <TAB> <TAB> <TAB> <TAB> target = target. replace ( ""&"", ""&"" ) <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> newstring = etree. fromstring ( ""<string>%s</string>"" % target ) <TAB> <TAB> except : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> target = target. replace ( ""<"", ""<"" ) <TAB> <TAB> <TAB> newstring = etree. fromstring ( ""<string>%s</string>"" % target ) <TAB> <TAB> <TAB> <TAB> if newstring. text is None : <TAB> <TAB> <TAB> xmltarget. text = """" <TAB> <TAB> else : <TAB> <TAB> <TAB> xmltarget. text = newstring. text <TAB> <TAB> <TAB> <TAB> for x in xmltarget. iterchildren ( ) : <TAB> <TAB> <TAB> xmltarget. remove ( x ) <TAB> <TAB> <TAB> <TAB> for x in newstring. iter ( ) : <TAB> <TAB> <TAB> x. text = self. escape ( x. text, False ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> x. prefix = self. escape ( x. prefix, False ) <TAB> <TAB> <TAB> if x. tail is not None : <TAB> <TAB> <TAB> <TAB> x. tail = self. escape ( x. tail, False ) <TAB> <TAB> <TAB> <TAB> for x in newstring. iterchildren ( ) : <TAB> <TAB> <TAB> xmltarget. append ( x ) <TAB> else : <TAB> <TAB> <TAB> <TAB> xmltarget. text = self. escape ( target )",True,x.prefix is not None,x.prefix is not None,0.6522507071495056
|
||
|
1008,"def next_frame ( self ) : <TAB> frame_index = None <TAB> rate = self. rate <TAB> time_base = self. time_base <TAB> self. pts_seen = False <TAB> for packet in self. file. demux ( self. stream ) : <TAB> <TAB> <TAB> <TAB> if packet. pts : <TAB> <TAB> <TAB> self. pts_seen = True <TAB> <TAB> for frame in packet. decode ( ) : <TAB> <TAB> <TAB> if frame_index is None : <TAB> <TAB> <TAB> <TAB> if self. pts_seen : <TAB> <TAB> <TAB> <TAB> <TAB> pts = frame. pts <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> pts = frame. dts <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> frame_index = pts_to_frame ( pts, time_base, rate, self. start_time ) <TAB> <TAB> <TAB> elif not frame_index is None : <TAB> <TAB> <TAB> <TAB> frame_index += 1 <TAB> <TAB> <TAB> if not frame. dts in self. pts_map : <TAB> <TAB> <TAB> <TAB> secs = None <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> secs = pts * time_base <TAB> <TAB> <TAB> <TAB> self. pts_map [ frame. dts ] = secs <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> yield frame_index, frame",False,not pts is None,self.sec_frame is None,0.6681995391845703
|
||
|
1009,"def get_converter ( in_ext, out_ext = None, templ_ext = None ) : <TAB> convert_candidates = None <TAB> if templ_ext : <TAB> <TAB> if ( in_ext, templ_ext ) in converters : <TAB> <TAB> <TAB> convert_candidates = converters [ ( in_ext, templ_ext ) ] <TAB> <TAB> else : <TAB> <TAB> <TAB> raise UnsupportedConversionError ( in_ext, out_ext, templ_ext ) <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> convert_candidates = converters [ in_ext ] <TAB> <TAB> elif ( in_ext, ) in converters : <TAB> <TAB> <TAB> convert_candidates = converters [ ( in_ext, ) ] <TAB> <TAB> else : <TAB> <TAB> <TAB> raise UnsupportedConversionError ( in_ext, out_ext ) <TAB> convert_fn = None <TAB> if not out_ext : <TAB> <TAB> out_ext, convert_fn = convert_candidates [ 0 ] <TAB> else : <TAB> <TAB> for ext, func in convert_candidates : <TAB> <TAB> <TAB> if ext == out_ext : <TAB> <TAB> <TAB> <TAB> convert_fn = func <TAB> <TAB> <TAB> <TAB> break <TAB> if not convert_fn : <TAB> <TAB> raise UnsupportedConversionError ( in_ext, out_ext, templ_ext ) <TAB> return convert_fn",False,in_ext in converters,in_ext,0.6615919470787048
|
||
|
1010,"def _apply_transformation ( self, image, interp_order = 3 ) : <TAB> if interp_order < 0 : <TAB> <TAB> return image <TAB> assert self. _rand_zoom is not None <TAB> full_zoom = np. array ( self. _rand_zoom ) <TAB> while len ( full_zoom ) < image. ndim : <TAB> <TAB> full_zoom = np. hstack ( ( full_zoom, [ 1.0 ] ) ) <TAB> is_undersampling = all ( full_zoom [ : 3 ] < 1 ) <TAB> run_antialiasing_filter = self. antialiasing and is_undersampling <TAB> if<mask> : : <TAB> <TAB> sigma = self. _get_sigma ( full_zoom [ : 3 ] ) <TAB> if image. ndim == 4 : <TAB> <TAB> output = [ ] <TAB> <TAB> for mod in range ( image. shape [ - 1 ] ) : <TAB> <TAB> <TAB> to_scale = ( <TAB> <TAB> <TAB> <TAB> ndi. gaussian_filter ( image [..., mod ], sigma ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> else image [..., mod ] <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> scaled = ndi. zoom ( to_scale, full_zoom [ : 3 ], order = interp_order ) <TAB> <TAB> <TAB> output. append ( scaled [..., np. newaxis ] ) <TAB> <TAB> return np. concatenate ( output, axis = - 1 ) <TAB> elif image. ndim == 3 : <TAB> <TAB> to_scale = ( <TAB> <TAB> <TAB> ndi. gaussian_filter ( image, sigma ) if<mask> : else image <TAB> <TAB> ) <TAB> <TAB> scaled = ndi. zoom ( to_scale, full_zoom [ : 3 ], order = interp_order ) <TAB> <TAB> return scaled [..., np. newaxis ] <TAB> else : <TAB> <TAB> raise NotImplementedError ( ""not implemented random scaling"" )",True,run_antialiasing_filter,run_antialiasing_filter,0.6510010957717896
|
||
|
1011,"def _get_split_on_quotes ( self, line ) : <TAB> doublequotesplits = line. split ( '""' ) <TAB> quoted = False <TAB> quotesplits = [ ] <TAB> if len ( doublequotesplits ) > 1 and ""'"" in doublequotesplits [ 0 ] : <TAB> <TAB> singlequotesplits = doublequotesplits [ 0 ]. split ( ""'"" ) <TAB> <TAB> doublequotesplits = doublequotesplits [ 1 : ] <TAB> <TAB> while len ( singlequotesplits ) % 2 == 0 and len ( doublequotesplits ) : <TAB> <TAB> <TAB> singlequotesplits [ - 1 ] += '""' + doublequotesplits [ 0 ] <TAB> <TAB> <TAB> doublequotesplits = doublequotesplits [ 1 : ] <TAB> <TAB> <TAB> if ""'"" in singlequotesplits [ - 1 ] : <TAB> <TAB> <TAB> <TAB> singlequotesplits = singlequotesplits [ : - 1 ] + singlequotesplits [ <TAB> <TAB> <TAB> <TAB> <TAB> - 1 <TAB> <TAB> <TAB> <TAB> ]. split ( ""'"" ) <TAB> <TAB> quotesplits += singlequotesplits <TAB> for doublequotesplit in doublequotesplits : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> quotesplits. append ( doublequotesplit ) <TAB> <TAB> else : <TAB> <TAB> <TAB> quotesplits += doublequotesplit. split ( ""'"" ) <TAB> <TAB> <TAB> quoted = not quoted <TAB> return quotesplits",False,quoted,"doublequotesplit == ""'""",0.6908809542655945
|
||
|
1012,"def extended_noun_chunks ( sentence ) : <TAB> noun_chunks = { ( np. start, np. end ) for np in sentence. noun_chunks } <TAB> np_start, cur_np = 0, ""NONE"" <TAB> for i, token in enumerate ( sentence ) : <TAB> <TAB> np_type = token. pos_ if token. pos_ in { ""NOUN"", ""PROPN"" } else ""NONE"" <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if cur_np!= ""NONE"" : <TAB> <TAB> <TAB> <TAB> noun_chunks. add ( ( np_start, i ) ) <TAB> <TAB> <TAB> if np_type!= ""NONE"" : <TAB> <TAB> <TAB> <TAB> np_start = i <TAB> <TAB> <TAB> cur_np = np_type <TAB> if cur_np!= ""NONE"" : <TAB> <TAB> noun_chunks. add ( ( np_start, len ( sentence ) ) ) <TAB> return [ sentence [ s : e ] for ( s, e ) in sorted ( noun_chunks ) ]",False,np_type != cur_np,np_type == 'NONE',0.6510747671127319
|
||
|
1013,"def _loop_writing ( self, f = None, data = None ) : <TAB> try : <TAB> <TAB> assert f is self. _write_fut <TAB> <TAB> self. _write_fut = None <TAB> <TAB> self. _pending_write = 0 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> f. result ( ) <TAB> <TAB> if data is None : <TAB> <TAB> <TAB> data = self. _buffer <TAB> <TAB> <TAB> self. _buffer = None <TAB> <TAB> if not data : <TAB> <TAB> <TAB> if self. _closing : <TAB> <TAB> <TAB> <TAB> self. _loop. call_soon ( self. _call_connection_lost, None ) <TAB> <TAB> <TAB> if self. _eof_written : <TAB> <TAB> <TAB> <TAB> self. _sock. shutdown ( socket. SHUT_WR ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _maybe_resume_protocol ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. _write_fut = self. _loop. _proactor. send ( self. _sock, data ) <TAB> <TAB> <TAB> if not self. _write_fut. done ( ) : <TAB> <TAB> <TAB> <TAB> assert self. _pending_write == 0 <TAB> <TAB> <TAB> <TAB> self. _pending_write = len ( data ) <TAB> <TAB> <TAB> <TAB> self. _write_fut. add_done_callback ( self. _loop_writing ) <TAB> <TAB> <TAB> <TAB> self. _maybe_pause_protocol ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. _write_fut. add_done_callback ( self. _loop_writing ) <TAB> except",False,f,f is not None,0.6815915107727051
|
||
|
1014,"def find_pingback_urls ( self, urls ) : <TAB> """"""Find the pingback urls of each urls"""""" <TAB> pingback_urls = { } <TAB> for url in urls : <TAB> <TAB> try : <TAB> <TAB> <TAB> page = urlopen ( url ) <TAB> <TAB> <TAB> headers = page. info ( ) <TAB> <TAB> <TAB> if ""text/"" not in headers. get ( ""Content-Type"", """" ). lower ( ) : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> server_url = headers. get ( ""X-Pingback"" ) <TAB> <TAB> <TAB> if not server_url : <TAB> <TAB> <TAB> <TAB> server_url = self. find_pingback_href ( page. read ( ) ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> server_url_splitted = urlsplit ( server_url ) <TAB> <TAB> <TAB> <TAB> if not server_url_splitted. netloc : <TAB> <TAB> <TAB> <TAB> <TAB> url_splitted = urlsplit ( url ) <TAB> <TAB> <TAB> <TAB> <TAB> server_url = ""%s://%s%s"" % ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> url_splitted. scheme, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> url_splitted. netloc, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> server_url, <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> pingback_urls [ url ] = server_url <TAB> <TAB> except IOError : <TAB> <TAB> <TAB> pass <TAB> return pingback_urls",True,server_url,server_url,0.667713463306427
|
||
|
1015,"def _check_step ( self, step, step_num ) : <TAB> """"""Don't try to run steps that include commands or use manifests."""""" <TAB> super ( SparkMRJobRunner, self ). _check_step ( step, step_num ) <TAB> if step. get ( ""input_manifest"" ) : <TAB> <TAB> raise NotImplementedError ( ""spark runner does not support input manifests"" ) <TAB> <TAB> if step [ ""type"" ] == ""streaming"" : <TAB> <TAB> if not self. _mrjob_cls : <TAB> <TAB> <TAB> raise ValueError ( ""You must set mrjob_cls to run streaming steps"" ) <TAB> <TAB> for mrc in ( ""mapper"", ""combiner"", ""reducer"" ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> if ""command"" in step [ mrc ] or ""pre_filter"" in step [ mrc ] : <TAB> <TAB> <TAB> <TAB> <TAB> raise NotImplementedError ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""step %d's %s runs a command, but spark"" <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> "" runner does not support commands"" % ( step_num, mrc ) <TAB> <TAB> <TAB> <TAB> <TAB> )",False,step.get(mrc),mrc in step,0.6509639024734497
|
||
|
1016,"def read_http ( sock ) : <TAB> fd = sock. makefile ( ""rb"" ) <TAB> try : <TAB> <TAB> response_line = bytes_to_str ( fd. readline ( ). rstrip ( b""\r\n"" ) ) <TAB> except socket. error as exc : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if support. get_errno ( exc ) in ( 10053, 54 ) : <TAB> <TAB> <TAB> raise ConnectionClosed <TAB> <TAB> raise <TAB> if not response_line : <TAB> <TAB> raise ConnectionClosed ( response_line ) <TAB> header_lines = [ ] <TAB> while True : <TAB> <TAB> line = fd. readline ( ) <TAB> <TAB> if line == b""\r\n"" : <TAB> <TAB> <TAB> break <TAB> <TAB> else : <TAB> <TAB> <TAB> header_lines. append ( line ) <TAB> headers_original = { } <TAB> headers_lower = { } <TAB> for x in header_lines : <TAB> <TAB> x = x. strip ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> key, value = bytes_to_str ( x ). split ( "":"", 1 ) <TAB> <TAB> key = key. rstrip ( ) <TAB> <TAB> value = value. lstrip ( ) <TAB> <TAB> key_lower = key. lower ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> assert key_lower not in headers_lower, ""header duplicated: {0}"". format ( key ) <TAB> <TAB> headers_original [ key ] = value <TAB> <TAB> headers_lower [ key_lower ] = value <TAB> content_length_str = headers_lower. get ( CONTENT_LENGTH. lower ( ), """" ) <TAB> if content_length_str : <TAB> <TAB> num = int ( content_length_str ) <TAB> <TAB> body = fd. read ( num ) <TAB> else : <TAB> <TAB> <TAB> <TAB> body",True,not x,not x,0.6765691637992859
|
||
|
1017,"def migration_10 ( env ) : <TAB> <TAB> <TAB> <TAB> import datetime <TAB> system_certificate = os. path. join ( env [ ""STORAGE_ROOT"" ], ""ssl/ssl_certificate.pem"" ) <TAB> if not os. path. islink ( system_certificate ) : <TAB> <TAB> new_path = os. path. join ( <TAB> <TAB> <TAB> env [ ""STORAGE_ROOT"" ], <TAB> <TAB> <TAB> ""ssl"", <TAB> <TAB> <TAB> env [ ""PRIMARY_HOSTNAME"" ] <TAB> <TAB> <TAB> + ""-"" <TAB> <TAB> <TAB> + datetime. datetime. now ( ). date ( ). isoformat ( ). replace ( ""-"", """" ) <TAB> <TAB> <TAB> + "".pem"", <TAB> <TAB> ) <TAB> <TAB> print ( <TAB> <TAB> <TAB> ""Renamed"", <TAB> <TAB> <TAB> system_certificate, <TAB> <TAB> <TAB> ""to"", <TAB> <TAB> <TAB> new_path, <TAB> <TAB> <TAB> ""and created a symlink for the original location."", <TAB> <TAB> ) <TAB> <TAB> shutil. move ( system_certificate, new_path ) <TAB> <TAB> os. symlink ( new_path, system_certificate ) <TAB> <TAB> <TAB> <TAB> <TAB> for sslcert in glob. glob ( <TAB> <TAB> os. path. join ( env [ ""STORAGE_ROOT"" ], ""ssl/*/ssl_certificate.pem"" ) <TAB> ) : <TAB> <TAB> d = os. path. dirname ( sslcert ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> newname = os. path. join ( <TAB> <TAB> <TAB> <TAB> env [ ""STORAGE_ROOT"" ], ""ssl"", os. path. basename ( d ) + "".pem"" <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if not os. path. exists ( newname ) : <TAB> <TAB> <",False,len(os.listdir(d)) == 1,d,0.6512948274612427
|
||
|
1018,def _cleanup ( ) : <TAB> for inst in _active [ : ] : <TAB> <TAB> res = inst. _internal_poll ( _deadstate = sys. maxint ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> _active. remove ( inst ) <TAB> <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> pass,False,res is not None and res >= 0,res,0.6581555604934692
|
||
|
1019,"def _augment_maps_by_samples ( self, augmentables, arr_attr_name, ks ) : <TAB> <TAB> arrs = [ getattr ( map_i, arr_attr_name ) for map_i in augmentables ] <TAB> arrs_aug = self. _augment_arrays_by_samples ( arrs, ks, self. keep_size, None ) <TAB> maps_aug = [ ] <TAB> gen = zip ( augmentables, arrs, arrs_aug, ks ) <TAB> for augmentable_i, arr, arr_aug, k_i in gen : <TAB> <TAB> shape_orig = arr. shape <TAB> <TAB> setattr ( augmentable_i, arr_attr_name, arr_aug ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> augmentable_i = augmentable_i. resize ( shape_orig [ 0 : 2 ] ) <TAB> <TAB> elif k_i % 2 == 1 : <TAB> <TAB> <TAB> h, w = augmentable_i. shape [ 0 : 2 ] <TAB> <TAB> <TAB> augmentable_i. shape = tuple ( [ w, h ] + list ( augmentable_i. shape [ 2 : ] ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> maps_aug. append ( augmentable_i ) <TAB> return maps_aug",False,self.keep_size,k_i % 2 == 1,0.6544825434684753
|
||
|
1020,"def _write_opf_spine ( self, root, ncx_id ) : <TAB> spine_attributes = { ""toc"" : ncx_id or ""ncx"" } <TAB> if self. book. direction and self. options [ ""spine_direction"" ] : <TAB> <TAB> spine_attributes [ ""page-progression-direction"" ] = self. book. direction <TAB> spine = etree. SubElement ( root, ""spine"", spine_attributes ) <TAB> for _item in self. book. spine : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> is_linear = True <TAB> <TAB> if isinstance ( _item, tuple ) : <TAB> <TAB> <TAB> item = _item [ 0 ] <TAB> <TAB> <TAB> if len ( _item ) > 1 : <TAB> <TAB> <TAB> <TAB> if _item [ 1 ] == ""no"" : <TAB> <TAB> <TAB> <TAB> <TAB> is_linear = False <TAB> <TAB> else : <TAB> <TAB> <TAB> item = _item <TAB> <TAB> if isinstance ( item, EpubHtml ) : <TAB> <TAB> <TAB> opts = { ""idref"" : item. get_id ( ) } <TAB> <TAB> <TAB> if not item. is_linear or not is_linear : <TAB> <TAB> <TAB> <TAB> opts [ ""linear"" ] = ""no"" <TAB> <TAB> elif isinstance ( item, EpubItem ) : <TAB> <TAB> <TAB> opts = { ""idref"" : item. get_id ( ) } <TAB> <TAB> <TAB> if not item. is_linear or not is_linear : <TAB> <TAB> <TAB> <TAB> opts [ ""linear"" ] = ""no"" <TAB> <TAB> else : <TAB> <TAB> <TAB> opts = { ""idref"" : item } <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> itm = self. book. get_item_with_id ( item ) <TAB> <TAB> <TAB> <TAB",False,not itm.is_linear or not is_linear,self.options['spine_id'],0.6558881402015686
|
||
|
1021,"def _get_state_handlers_dict ( ) : <TAB> state_handlers = { } <TAB> for module in import_submodules ( galaxy. jobs. runners. state_handlers, ordered = True ) : <TAB> <TAB> for func in getattr ( module, ""__all__"", [ ] ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> state_handlers [ func ] = [ ] <TAB> <TAB> <TAB> state_handlers [ func ]. append ( getattr ( module, func ) ) <TAB> <TAB> <TAB> log. debug ( ""Loaded '%s' state handler from module %s"", func, module. __name__ ) <TAB> return state_handlers",True,func not in state_handlers,func not in state_handlers,0.6623349189758301
|
||
|
1022,"def __init__ ( self, * args, ** kwargs ) : <TAB> if kwargs. get ( ""bindAddress"", None ) is None : <TAB> <TAB> import socket <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""Dynamic FCGI server not available on this platform. "" <TAB> <TAB> <TAB> <TAB> ""You must use a static or external one by providing a "" <TAB> <TAB> <TAB> <TAB> ""legal bindAddress."" <TAB> <TAB> <TAB> ) <TAB> self. args = args <TAB> self. kwargs = kwargs <TAB> self. ready = False",False,"not hasattr(socket, 'fromfd')",socket.get_terminal() is None,0.652373731136322
|
||
|
1023,"def ftp_login ( host, port, username = None, password = None, anonymous = False ) : <TAB> ret = False <TAB> try : <TAB> <TAB> ftp = ftplib. FTP ( ) <TAB> <TAB> ftp. connect ( host, port, timeout = 6 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> ftp. login ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> ftp. login ( username, password ) <TAB> <TAB> ret = True <TAB> <TAB> ftp. quit ( ) <TAB> except Exception : <TAB> <TAB> pass <TAB> return ret",True,anonymous,anonymous,0.6977392435073853
|
||
|
1024,"def _parse_value ( value ) : <TAB> """"""Internal helper for parsing configuration values into python values"""""" <TAB> if isinstance ( value, bool ) : <TAB> <TAB> return ""true"" if value else ""false"" <TAB> elif isinstance ( value, six. string_types ) : <TAB> <TAB> <TAB> <TAB> listparser = re. compile ( r""""""((?:[^,""']|""[^""]*""|'[^']*')+)"""""" ) <TAB> <TAB> value = value. strip ( ) <TAB> <TAB> if value. startswith ( ""["" ) and value. endswith ( ""]"" ) : <TAB> <TAB> <TAB> return listparser. split ( value [ 1 : - 1 ] ) [ 1 : : 2 ] <TAB> <TAB> elif value. startswith ( ""("" ) and value. endswith ( "")"" ) : <TAB> <TAB> <TAB> rval = { } <TAB> <TAB> <TAB> for pair in listparser. split ( value [ 1 : - 1 ] ) [ 1 : : 2 ] : <TAB> <TAB> <TAB> <TAB> pair = pair. split ( ""="" ) <TAB> <TAB> <TAB> <TAB> if '""' in pair [ 1 ] : <TAB> <TAB> <TAB> <TAB> <TAB> pair [ 1 ] = pair [ 1 ]. replace ( '""', """" ) <TAB> <TAB> <TAB> <TAB> if pair [ 1 ]. isdigit ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> rval [ pair [ 0 ] ] = int ( pair [ 1 ] ) <TAB> <TAB> <TAB> <TAB> elif pair [ 1 ] == ""true"" : <TAB> <TAB> <TAB> <TAB> <TAB> rval [ pair [ 0 ] ] = True <TAB> <TAB> <TAB> <TAB> elif pair [ 1 ] == ""false"" : <TAB> <TAB> <TAB> <TAB> <TAB> rval [ pair [ 0 ] ] = False <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> rval [ pair [ 0 ] ] = pair [ 1 ] <TAB> <TAB> <TAB> return rval <TAB> <TAB> else : <TAB>",False,value.isdigit(),value is None,0.6561739444732666
|
||
|
1025,"def _handle_whq ( self ) : <TAB> self. assertToken ( self. token ( ), ""("" ) <TAB> self. assertToken ( self. token ( ), ""["" ) <TAB> ans_types = [ ] <TAB> while self. token ( 0 )!= ""]"" : <TAB> <TAB> cat = self. token ( ) <TAB> <TAB> self. assertToken ( self. token ( ), "":"" ) <TAB> <TAB> if cat == ""des"" : <TAB> <TAB> <TAB> ans_types. append ( self. token ( ) ) <TAB> <TAB> elif cat == ""num"" : <TAB> <TAB> <TAB> ans_types. append ( ""number"" ) <TAB> <TAB> <TAB> typ = self. token ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> ans_types. append ( ""count"" ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> ans_types. append ( typ ) <TAB> <TAB> else : <TAB> <TAB> <TAB> ans_types. append ( self. token ( ) ) <TAB> self. token ( ) <TAB> self. assertToken ( self. token ( ), "","" ) <TAB> d1 = self. parse_Expression ( None ) <TAB> self. assertToken ( self. token ( ), "","" ) <TAB> ref = self. parse_variable ( ) <TAB> self. assertToken ( self. token ( ), "","" ) <TAB> d2 = self. parse_Expression ( None ) <TAB> self. assertToken ( self. token ( ), "")"" ) <TAB> return lambda sent_index, word_indices : BoxerWhq ( <TAB> <TAB> self. discourse_id, sent_index, word_indices, ans_types, d1, ref, d2 <TAB> )",False,typ == 'cou',typ == 'count',0.659706175327301
|
||
|
1026,"def dgl_mp_batchify_fn ( data ) : <TAB> if isinstance ( data [ 0 ], tuple ) : <TAB> <TAB> data = zip ( * data ) <TAB> <TAB> return [ dgl_mp_batchify_fn ( i ) for i in data ] <TAB> for dt in data : <TAB> <TAB> if dt is not None : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return [ d for d in data if isinstance ( d, dgl. DGLGraph ) ] <TAB> <TAB> <TAB> elif isinstance ( dt, nd. NDArray ) : <TAB> <TAB> <TAB> <TAB> pad = Pad ( axis = ( 1, 2 ), num_shards = 1, ret_length = False ) <TAB> <TAB> <TAB> <TAB> data_list = [ dt for dt in data if dt is not None ] <TAB> <TAB> <TAB> <TAB> return pad ( data_list )",True,"isinstance(dt, dgl.DGLGraph)","isinstance(dt, dgl.DGLGraph)",0.6500488519668579
|
||
|
1027,"def test_main ( self, c1 ) : <TAB> for line in self : <TAB> <TAB> try : <TAB> <TAB> <TAB> c1 = 6 <TAB> <TAB> except : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> c1 = 5 <TAB> <TAB> <TAB> <TAB> except : <TAB> <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> c1 = 1 <TAB> <TAB> <TAB> continue <TAB> <TAB> pass",False,c1,c1 == 6,0.6797674894332886
|
||
|
1028,"def _parse ( self, engine ) : <TAB> """"""Parse the layer."""""" <TAB> if isinstance ( self. args, dict ) : <TAB> <TAB> if ""axis"" in self. args : <TAB> <TAB> <TAB> self. axis = engine. evaluate ( self. args [ ""axis"" ], recursive = True ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise ParsingError ( '""axis"" must be an integer.' ) <TAB> <TAB> if ""momentum"" in self. args : <TAB> <TAB> <TAB> self. momentum = engine. evaluate ( self. args [ ""momentum"" ], recursive = True ) <TAB> <TAB> <TAB> if not isinstance ( self. momentum, ( int, float ) ) : <TAB> <TAB> <TAB> <TAB> raise ParsingError ( '""momentum"" must be numeric.' )",False,"not isinstance(self.axis, int)","not isinstance(self.axis, (int, float))",0.6546884775161743
|
||
|
1029,"def build ( self, settlement_manager, resource_id ) : <TAB> village_builder = settlement_manager. village_builder <TAB> building_purpose = self. get_purpose ( resource_id ) <TAB> building_id = BUILDING_PURPOSE. get_building ( building_purpose ) <TAB> building_class = Entities. buildings [ building_id ] <TAB> for coords, ( purpose, ( section, _ ) ) in village_builder. plan. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> object = village_builder. land_manager. island. ground_map [ coords ]. object <TAB> <TAB> if object is not None and object. id == self. id : <TAB> <TAB> <TAB> continue <TAB> <TAB> if building_purpose!= BUILDING_PURPOSE. MAIN_SQUARE : <TAB> <TAB> <TAB> if not self. _need_producer ( settlement_manager, coords, resource_id ) : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> if not village_builder. have_resources ( building_id ) : <TAB> <TAB> <TAB> return ( BUILD_RESULT. NEED_RESOURCES, None ) <TAB> <TAB> if ( <TAB> <TAB> <TAB> coords <TAB> <TAB> <TAB> not in village_builder. settlement. buildability_cache. cache [ <TAB> <TAB> <TAB> <TAB> building_class. size <TAB> <TAB> <TAB> ] <TAB> <TAB> ) : <TAB> <TAB> <TAB> position = Rect. init_from_topleft_and_size_tuples ( <TAB> <TAB> <TAB> <TAB> coords, building_class. size <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> return ( BUILD_RESULT. OUT_OF_SETTLEMENT, position ) <TAB> <TAB> building = BasicBuilder ( building_id, coords, 0 ). execute ( <TAB> <TAB> <TAB> settlement_manager. land_manager <TAB> <",False,section > village_builder.current_section or purpose != building_purpose,self.id is None,0.6574970483779907
|
||
|
1030,"def valid_fieldnames ( fieldnames ) : <TAB> """"""check if fieldnames are valid"""""" <TAB> for fieldname in fieldnames : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return True <TAB> <TAB> elif fieldname in fieldname_map and fieldname_map [ fieldname ] == ""source"" : <TAB> <TAB> <TAB> return True <TAB> return False",False,fieldname in canonical_field_names and fieldname == 'source',fieldname == 'password',0.6545164585113525
|
||
|
1031,"def _parse_top_intents ( self, text, top_n, intents = None ) : <TAB> if isinstance ( intents, str ) : <TAB> <TAB> intents = { intents } <TAB> elif isinstance ( intents, list ) : <TAB> <TAB> intents = set ( intents ) <TAB> if top_n < 1 : <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> ""top_n argument must be greater or equal to 1, but got: %s"" % top_n <TAB> <TAB> ) <TAB> results_per_intent = defaultdict ( list ) <TAB> for text_candidate, entities in self. _get_candidates ( text, intents ) : <TAB> <TAB> val = self. _map. get ( hash_str ( text_candidate ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> result = self. _parse_map_output ( text, val, entities, intents ) <TAB> <TAB> <TAB> if result : <TAB> <TAB> <TAB> <TAB> intent_name = result [ RES_INTENT ] [ RES_INTENT_NAME ] <TAB> <TAB> <TAB> <TAB> results_per_intent [ intent_name ]. append ( result ) <TAB> results = [ ] <TAB> for intent_results in itervalues ( results_per_intent ) : <TAB> <TAB> sorted_results = sorted ( intent_results, key = lambda res : len ( res [ RES_SLOTS ] ) ) <TAB> <TAB> results. append ( sorted_results [ 0 ] ) <TAB> <TAB> <TAB> weights = [ 1.0 / ( 1.0 + len ( res [ RES_SLOTS ] ) ) for res in results ] <TAB> total_weight = sum ( weights ) <TAB> for res, weight in zip ( results, weights ) : <TAB> <TAB> res [ RES_INTENT ] [ RES_PROBA ] = weight / total_weight <TAB> results = sorted ( results, key = lambda r : - r [ RES_INTENT ] [ RES_PROBA ] ) <TAB> return results [ : top_n ]",False,val is not None,val,0.6625601053237915
|
||
|
1032,"def middleware ( self, request, handler ) : <TAB> try : <TAB> <TAB> overrides = { } <TAB> <TAB> headers = request. headers <TAB> <TAB> forwarded_for = self. get_forwarded_for ( headers ) <TAB> <TAB> if forwarded_for : <TAB> <TAB> <TAB> overrides [ ""remote"" ] = str ( forwarded_for [ - self. _num ] ) <TAB> <TAB> proto = self. get_forwarded_proto ( headers ) <TAB> <TAB> if proto : <TAB> <TAB> <TAB> overrides [ ""scheme"" ] = proto [ - self. _num ] <TAB> <TAB> host = self. get_forwarded_host ( headers ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> overrides [ ""host"" ] = host <TAB> <TAB> prefix = self. get_forwarded_path ( headers ) <TAB> <TAB> if prefix is not None : <TAB> <TAB> <TAB> prefix = ""/"" + prefix. strip ( ""/"" ) + ""/"" <TAB> <TAB> <TAB> request_path = URL ( request. path. lstrip ( ""/"" ) ) <TAB> <TAB> <TAB> overrides [ ""rel_url"" ] = URL ( prefix ). join ( request_path ) <TAB> <TAB> request = request. clone ( ** overrides ) <TAB> <TAB> return await handler ( request ) <TAB> except RemoteError as exc : <TAB> <TAB> exc. log ( request ) <TAB> await self. raise_error ( request )",False,host is not None,host,0.6642715930938721
|
||
|
1033,"def _as_key_indices ( keys, key_names ) : <TAB> key_names = _as_tuple ( key_names ) <TAB> keys = _bool_to_indices ( _as_tuple ( keys ), len ( key_names ) ) <TAB> for key in keys : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> key_index = key <TAB> <TAB> <TAB> if key_index < 0 : <TAB> <TAB> <TAB> <TAB> key_index += len ( key_names ) <TAB> <TAB> <TAB> if key_index not in range ( 0, len ( key_names ) ) : <TAB> <TAB> <TAB> <TAB> raise IndexError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""index {} is out of bounds for keys with size {}"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> key, len ( key_names ) <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> key_index = key_names. index ( key ) <TAB> <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> <TAB> raise KeyError ( ""{} does not exists"". format ( key ) ) <TAB> <TAB> yield key_index",False,"isinstance(key, numbers.Integral)",_is_tab_char(key),0.6479559540748596
|
||
|
1034,"def showUserList ( self, currentUser, rooms ) : <TAB> for room in rooms : <TAB> <TAB> message = ""In room '{}':"". format ( room ) <TAB> <TAB> self. showMessage ( message, True ) <TAB> <TAB> for user in rooms [ room ] : <TAB> <TAB> <TAB> userflags = """" <TAB> <TAB> <TAB> if user. isController ( ) : <TAB> <TAB> <TAB> <TAB> userflags += ""({}) "". format ( getMessage ( ""controller-userlist-userflag"" ) ) <TAB> <TAB> <TAB> if user. isReady ( ) : <TAB> <TAB> <TAB> <TAB> userflags += ""({}) "". format ( getMessage ( ""ready-userlist-userflag"" ) ) <TAB> <TAB> <TAB> username = ( <TAB> <TAB> <TAB> <TAB> userflags + ""*<{}>*"". format ( user. username ) <TAB> <TAB> <TAB> <TAB> if user == currentUser <TAB> <TAB> <TAB> <TAB> else userflags + ""<{}>"". format ( user. username ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> message = getMessage ( ""userlist-playing-notification"" ). format ( username ) <TAB> <TAB> <TAB> <TAB> self. showMessage ( message, True ) <TAB> <TAB> <TAB> <TAB> message = "" {}: '{}' ({})"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> getMessage ( ""userlist-file-notification"" ), <TAB> <TAB> <TAB> <TAB> <TAB> user. file [ ""name"" ], <TAB> <TAB> <TAB> <TAB> <TAB> formatTime ( user. file [ ""duration"" ] ), <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> if currentUser. file : <TAB> <TAB> <TAB> <TAB> <TAB> if ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> user. file [",False,user.file,user.isPLAYING(),0.6592985391616821
|
||
|
1035,"def callback ( lexer, match, context ) : <TAB> text = match. group ( ) <TAB> extra = """" <TAB> if start : <TAB> <TAB> context. next_indent = len ( text ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> while context. next_indent < context. indent : <TAB> <TAB> <TAB> <TAB> context. indent = context. indent_stack. pop ( ) <TAB> <TAB> <TAB> if context. next_indent > context. indent : <TAB> <TAB> <TAB> <TAB> extra = text [ context. indent : ] <TAB> <TAB> <TAB> <TAB> text = text [ : context. indent ] <TAB> else : <TAB> <TAB> context. next_indent += len ( text ) <TAB> if text : <TAB> <TAB> yield match. start ( ), TokenClass, text <TAB> if extra : <TAB> <TAB> yield match. start ( ) + len ( text ), TokenClass. Error, extra <TAB> context. pos = match. end ( )",False,context.next_indent < context.indent,len(text) > context.next_indent,0.6498527526855469
|
||
|
1036,"def TryMerge ( self, d ) : <TAB> while d. avail ( ) > 0 : <TAB> <TAB> tt = d. getVarInt32 ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. set_name_space ( d. getPrefixedString ( ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if tt == 18 : <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. add_item ( ). TryMerge ( tmp ) <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_override ( ). TryMerge ( tmp ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if tt == 0 : <TAB> <TAB> <TAB> raise ProtocolBuffer. ProtocolBufferDecodeError <TAB> <TAB> d. skipData ( tt )",False,tt == 10,tt == 33554432,0.6911654472351074
|
||
|
1037,"def save_labels ( dataset_list, output_dir ) : <TAB> if is_main_process ( ) : <TAB> <TAB> logger = logging. getLogger ( __name__ ) <TAB> <TAB> ids_to_labels = { } <TAB> <TAB> for dataset in dataset_list : <TAB> <TAB> <TAB> if hasattr ( dataset, ""categories"" ) : <TAB> <TAB> <TAB> <TAB> ids_to_labels. update ( dataset. categories ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> logger. warning ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Dataset [{}] has no categories attribute, labels.json file won't be created"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> dataset. __class__. __name__ <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> labels_file = os. path. join ( output_dir, ""labels.json"" ) <TAB> <TAB> <TAB> logger. info ( ""Saving labels mapping into {}"". format ( labels_file ) ) <TAB> <TAB> <TAB> with open ( labels_file, ""w"" ) as f : <TAB> <TAB> <TAB> <TAB> json. dump ( ids_to_labels, f, indent = 2 )",False,ids_to_labels,output_dir is not None,0.6549862623214722
|
||
|
1038,"def _feed ( self, end ) : <TAB> if self. _current_size < end : <TAB> <TAB> if self. checked : <TAB> <TAB> <TAB> raise ReadStreamError ( end - self. _size, self. _size ) <TAB> <TAB> a, fa, fs = self. fragments [ - 1 ] <TAB> <TAB> while self. stream. sizeGe ( fa + min ( fs, end - a ) ) : <TAB> <TAB> <TAB> a += fs <TAB> <TAB> <TAB> f = self. next <TAB> <TAB> <TAB> if a >= end : <TAB> <TAB> <TAB> <TAB> self. _current_size = end <TAB> <TAB> <TAB> <TAB> if a == end and not f : <TAB> <TAB> <TAB> <TAB> <TAB> self. _setSize ( ) <TAB> <TAB> <TAB> <TAB> return False <TAB> <TAB> <TAB> if f : <TAB> <TAB> <TAB> <TAB> self. next = f. next <TAB> <TAB> <TAB> <TAB> f = f. getData ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. _current_size = a <TAB> <TAB> <TAB> <TAB> self. _setSize ( ) <TAB> <TAB> <TAB> <TAB> return True <TAB> <TAB> <TAB> fa = f. absolute_address <TAB> <TAB> <TAB> fs = f. size <TAB> <TAB> <TAB> self. fragments += [ ( a, fa, fs ) ] <TAB> <TAB> self. _current_size = a + max ( 0, self. stream. size - fa ) <TAB> <TAB> self. _setSize ( ) <TAB> <TAB> return True <TAB> return False",False,not f,a > end,0.6777458786964417
|
||
|
1039,"def check_duplicates ( self, message ) : <TAB> guild = message. guild <TAB> author = message. author <TAB> guild_cache = self. cache. get ( guild. id, None ) <TAB> if guild_cache is None : <TAB> <TAB> repeats = await self. config. guild ( guild ). delete_repeats ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return False <TAB> <TAB> guild_cache = self. cache [ guild. id ] = defaultdict ( lambda : deque ( maxlen = repeats ) ) <TAB> if not message. content : <TAB> <TAB> return False <TAB> guild_cache [ author ]. append ( message. content ) <TAB> msgs = guild_cache [ author ] <TAB> if len ( msgs ) == msgs. maxlen and len ( set ( msgs ) ) == 1 : <TAB> <TAB> try : <TAB> <TAB> <TAB> await message. delete ( ) <TAB> <TAB> <TAB> return True <TAB> <TAB> except discord. HTTPException : <TAB> <TAB> <TAB> pass <TAB> return False",False,repeats == -1,guild.id not in self.cache,0.6627511382102966
|
||
|
1040,"def extract ( self ) : <TAB> self. set2 [ ""total"" ] = [ 0, 0 ] <TAB> for line in self. fd [ 0 ]. readlines ( ) : <TAB> <TAB> l = line. replace ( "" /"", ""/"" ). split ( ) <TAB> <TAB> if len ( l )!= 12 : <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> if ( <TAB> <TAB> <TAB> "","". join ( l ) <TAB> <TAB> <TAB> == ""Name,Mtu/TSO,Network,Address,Ipkts,Ierrs,Ibytes,Opkts,Oerrs,Obytes,Coll,Time"" <TAB> <TAB> ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> if l [ 0 ] == ""Usage:"" : <TAB> <TAB> <TAB> continue <TAB> <TAB> name = l [ 0 ] <TAB> <TAB> if name in self. vars : <TAB> <TAB> <TAB> self. set2 [ name ] = ( int ( l [ 6 ] ), int ( l [ 9 ] ) ) <TAB> <TAB> if name!= ""lo0"" : <TAB> <TAB> <TAB> self. set2 [ ""total"" ] = ( <TAB> <TAB> <TAB> <TAB> self. set2 [ ""total"" ] [ 0 ] + int ( l [ 6 ] ), <TAB> <TAB> <TAB> <TAB> self. set2 [ ""total"" ] [ 1 ] + int ( l [ 9 ] ), <TAB> <TAB> <TAB> ) <TAB> if update : <TAB> <TAB> for name in self. set2 : <TAB> <TAB> <TAB> self. val [ name ] = list ( <TAB> <TAB> <TAB> <TAB> map ( <TAB> <TAB> <TAB> <TAB> <TAB> lambda x, y : ( y - x ) * 1.0 / elapsed, <TAB> <TAB> <TAB> <TAB> <TAB> self. set1 [ name ], <TAB> <TAB> <TAB> <TAB",False,l[2][:5] == '<Link',l[6] == 'lo0',0.6538936495780945
|
||
|
1041,"def Do ( self ) : <TAB> pyfalog. debug ( <TAB> <TAB> ""Doing change of module charges according to map {} on fit {}"". format ( <TAB> <TAB> <TAB> self. chargeMap, self. fitID <TAB> <TAB> ) <TAB> ) <TAB> sFit = Fit. getInstance ( ) <TAB> fit = sFit. getFit ( self. fitID ) <TAB> container = fit. modules if not self. projected else fit. projectedModules <TAB> changes = False <TAB> self. savedChargeMap = { } <TAB> sMkt = Market. getInstance ( ) <TAB> for position, chargeItemID in self. chargeMap. items ( ) : <TAB> <TAB> mod = container [ position ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> if mod. chargeID is None and chargeItemID is None : <TAB> <TAB> <TAB> continue <TAB> <TAB> if mod. chargeID == chargeItemID : <TAB> <TAB> <TAB> continue <TAB> <TAB> chargeItem = sMkt. getItem ( chargeItemID ) if chargeItemID is not None else None <TAB> <TAB> if chargeItem is not None and not chargeItem. isCharge : <TAB> <TAB> <TAB> continue <TAB> <TAB> if not self. ignoreRestriction and not mod. isValidCharge ( chargeItem ) : <TAB> <TAB> <TAB> pyfalog. warning ( ""Invalid charge {} for {}"". format ( chargeItem, mod ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> pyfalog. debug ( <TAB> <TAB> <TAB> ""Setting charge {} for {} on fit {}"". format ( chargeItem, mod, self. fitID ) <TAB> <TAB> ) <TAB> <TAB> self. savedChargeMap [ position ] = mod. chargeID <TAB> <TAB> changes = True <TAB> <TAB> mod. charge = chargeItem <TAB> if not changes : <TAB> <TAB> return False <TAB> if self. recalc : <TAB> <TAB> sFit. recalc ( fit ) <TAB> <TAB> self. savedStateCheckChanges",False,mod.isEmpty,not mod,0.6595723628997803
|
||
|
1042,"def _prepare_fc_map ( self, fc_map_id, timeout, restore ) : <TAB> self. ssh. prestartfcmap ( fc_map_id, restore ) <TAB> mapping_ready = False <TAB> max_retries = ( timeout // self. WAIT_TIME ) + 1 <TAB> for try_number in range ( 1, max_retries ) : <TAB> <TAB> mapping_attrs = self. _get_flashcopy_mapping_attributes ( fc_map_id ) <TAB> <TAB> if mapping_attrs is None or ""status"" not in mapping_attrs : <TAB> <TAB> <TAB> break <TAB> <TAB> if mapping_attrs [ ""status"" ] == ""prepared"" : <TAB> <TAB> <TAB> mapping_ready = True <TAB> <TAB> <TAB> break <TAB> <TAB> elif mapping_attrs [ ""status"" ] == ""stopped"" : <TAB> <TAB> <TAB> self. ssh. prestartfcmap ( fc_map_id, restore ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> msg = _ ( <TAB> <TAB> <TAB> <TAB> ""Unexecpted mapping status %(status)s for mapping "" <TAB> <TAB> <TAB> <TAB> ""%(id)s. Attributes: %(attr)s."" <TAB> <TAB> <TAB> ) % { <TAB> <TAB> <TAB> <TAB> ""status"" : mapping_attrs [ ""status"" ], <TAB> <TAB> <TAB> <TAB> ""id"" : fc_map_id, <TAB> <TAB> <TAB> <TAB> ""attr"" : mapping_attrs, <TAB> <TAB> <TAB> } <TAB> <TAB> <TAB> LOG. error ( msg ) <TAB> <TAB> <TAB> raise exception. VolumeBackendAPIException ( data = msg ) <TAB> <TAB> greenthread. sleep ( self. WAIT_TIME ) <TAB> if not mapping_ready : <TAB> <TAB> msg = _ ( <TAB> <TAB> <TAB> ""Mapping %(id)s prepare failed to complete within the "" <TAB> <TAB> <TAB> ""allotted %(to)d seconds",False,mapping_attrs['status'] != 'preparing',restore and fc_map_id and (fc_map_id[0] == 'id' or restore),0.6515494585037231
|
||
|
1043,"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. message = 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,message is not None,0.658729076385498
|
||
|
1044,"def __call__ ( self, input_tensor, index, name ) : <TAB> inputs = [ input_tensor ] <TAB> if index is not None : <TAB> <TAB> if not isinstance ( index, pd. Index ) : <TAB> <TAB> <TAB> if isinstance ( index, INDEX_TYPE ) : <TAB> <TAB> <TAB> <TAB> self. _index = index <TAB> <TAB> <TAB> <TAB> index_value = index. index_value <TAB> <TAB> <TAB> <TAB> inputs. append ( index ) <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> self. _index = index <TAB> <TAB> <TAB> <TAB> index = astensor ( index ) <TAB> <TAB> <TAB> <TAB> if index. ndim!= 1 : <TAB> <TAB> <TAB> <TAB> <TAB> raise ValueError ( f""index should be 1-d, got {index.ndim}-d"" ) <TAB> <TAB> <TAB> <TAB> index_value = parse_index ( <TAB> <TAB> <TAB> <TAB> <TAB> pd. Index ( [ ], dtype = index. dtype ), index, type ( self ). __name__ <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> inputs. append ( index ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> index = pd. Index ( index ) <TAB> <TAB> <TAB> <TAB> index_value = parse_index ( index, store_data = True ) <TAB> <TAB> else : <TAB> <TAB> <TAB> index_value = parse_index ( index, store_data = True ) <TAB> else : <TAB> <TAB> index_value = parse_index ( pd. RangeIndex ( start = 0, stop = input_tensor. shape [ 0 ] ) ) <TAB> return self. new_series ( <TAB> <TAB> inputs, <TAB> <TAB> shape = input_tensor. shape, <TAB> <TAB> dtype = self. dtype, <TAB> <TAB> index_value = index",False,"isinstance(index, (Base, Entity))","isinstance(index, pd.Series)",0.6572250723838806
|
||
|
1045,"def redirect ( self ) : <TAB> c = self. c <TAB> if c. config. getBool ( ""eval-redirect"" ) : <TAB> <TAB> self. old_stderr = g. stdErrIsRedirected ( ) <TAB> <TAB> self. old_stdout = g. stdOutIsRedirected ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> g. redirectStderr ( ) <TAB> <TAB> if not self. old_stdout : <TAB> <TAB> <TAB> g. redirectStdout ( )",True,not self.old_stderr,not self.old_stderr,0.6628884077072144
|
||
|
1046,"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. filesAdded = [ ] <TAB> <TAB> <TAB> <TAB> ( _etype451, _size448 ) = iprot. readListBegin ( ) <TAB> <TAB> <TAB> <TAB> for _i452 in xrange ( _size448 ) : <TAB> <TAB> <TAB> <TAB> <TAB> _elem453 = iprot. readString ( ) <TAB> <TAB> <TAB> <TAB> <TAB> self. filesAdded. append ( _elem453 ) <TAB> <TAB> <TAB> <TAB> iprot. readListEnd ( ) <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.LIST,fid == 2,0.660045862197876
|
||
|
1047,"def persist ( self, * _ ) : <TAB> for key, obj in self. _objects. items ( ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> state = obj. get_state ( ) <TAB> <TAB> <TAB> if not state : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> md5 = hashlib. md5 ( state ). hexdigest ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> self. _persist_provider. store ( key, state ) <TAB> <TAB> except Exception as e : <TAB> <TAB> <TAB> system_log. exception ( ""PersistHelper.persist fail"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. _last_state [ key ] = md5",False,self._last_state.get(key) == md5,self._persist_provider is None or md5 < TAB > self.get_state(key),0.6504796743392944
|
||
|
1048,"def _joinrealpath ( path, rest, seen ) : <TAB> if isabs ( rest ) : <TAB> <TAB> rest = rest [ 1 : ] <TAB> <TAB> path = sep <TAB> while rest : <TAB> <TAB> name, _, rest = rest. partition ( sep ) <TAB> <TAB> if not name or name == curdir : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> if name == pardir : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if path : <TAB> <TAB> <TAB> <TAB> path, name = split ( path ) <TAB> <TAB> <TAB> <TAB> if name == pardir : <TAB> <TAB> <TAB> <TAB> <TAB> path = join ( path, pardir, pardir ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> path = pardir <TAB> <TAB> <TAB> continue <TAB> <TAB> newpath = join ( path, name ) <TAB> <TAB> if not islink ( newpath ) : <TAB> <TAB> <TAB> path = newpath <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> if newpath in seen : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> path = seen [ newpath ] <TAB> <TAB> <TAB> if path is not None : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return join ( newpath, rest ), False <TAB> <TAB> seen [ newpath ] = None <TAB> <TAB> path, ok = _joinrealpath ( path, os. readlink ( newpath ), seen ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return join ( path, rest ), False <TAB> <TAB> seen [ newpath ] = path <TAB> return path, True",False,not ok,ok,0.6789413094520569
|
||
|
1049,"def _find_children ( node, test_func ) : <TAB> result = [ ] <TAB> if node in visited : <TAB> <TAB> return result <TAB> else : <TAB> <TAB> visited. add ( node ) <TAB> for field, value in base. iter_fields ( node, include_meta = False ) : <TAB> <TAB> field_spec = node. _fields [ field ] <TAB> <TAB> if isinstance ( value, ( list, set, frozenset ) ) : <TAB> <TAB> <TAB> for n in value : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> if not field_spec. hidden and test_func ( n, * args, ** kwargs ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> result. append ( n ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if terminate_early : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return result <TAB> <TAB> <TAB> <TAB> except SkipNode : <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> if field_spec. child_traverse or force_traversal : <TAB> <TAB> <TAB> <TAB> <TAB> _n = _find_children ( n, test_func ) <TAB> <TAB> <TAB> <TAB> <TAB> if _n is not None : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> result. extend ( _n ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if terminate_early : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return result <TAB> <TAB> elif base. is_ast_node ( value ) : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> if not field_spec. hidden and",False,not base.is_ast_node(n),n is None,0.6484529972076416
|
||
|
1050,"def get_meta_data ( self, doc ) : <TAB> data = defaultdict ( dict ) <TAB> properties = self. parser. css_select ( doc, ""meta"" ) <TAB> for prop in properties : <TAB> <TAB> key = prop. attrib. get ( ""property"" ) or prop. attrib. get ( ""name"" ) <TAB> <TAB> value = prop. attrib. get ( ""content"" ) or prop. attrib. get ( ""value"" ) <TAB> <TAB> if not key or not value : <TAB> <TAB> <TAB> continue <TAB> <TAB> key, value = key. strip ( ), value. strip ( ) <TAB> <TAB> if value. isdigit ( ) : <TAB> <TAB> <TAB> value = int ( value ) <TAB> <TAB> if "":"" not in key : <TAB> <TAB> <TAB> data [ key ] = value <TAB> <TAB> <TAB> continue <TAB> <TAB> key = key. split ( "":"" ) <TAB> <TAB> key_head = key. pop ( 0 ) <TAB> <TAB> ref = data [ key_head ] <TAB> <TAB> if isinstance ( ref, str ) : <TAB> <TAB> <TAB> data [ key_head ] = { key_head : ref } <TAB> <TAB> <TAB> ref = data [ key_head ] <TAB> <TAB> for idx, part in enumerate ( key ) : <TAB> <TAB> <TAB> if idx == len ( key ) - 1 : <TAB> <TAB> <TAB> <TAB> ref [ part ] = value <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> ref [ part ] = dict ( ) <TAB> <TAB> <TAB> elif isinstance ( ref. get ( part ), str ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ref [ part ] = { ""identifier"" : ref [ part ] } <TAB> <TAB> <TAB> ref = ref [ part ] <TAB> return data",False,not ref.get(part),part is None,0.6537399291992188
|
||
|
1051,"def check_no_overlapping_paths ( paths : Sequence [ str ] ) -> None : <TAB> """"""Given a list of paths, ensure that all are unique and do not have the same prefix."""""" <TAB> for path in paths : <TAB> <TAB> list_copy_without_path = list ( paths ) <TAB> <TAB> list_copy_without_path. remove ( path ) <TAB> <TAB> if path in list_copy_without_path : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""{} appeared more than once. All paths must be unique."". format ( path ) <TAB> <TAB> <TAB> ) <TAB> <TAB> for p in list_copy_without_path : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""{} and {} have the same prefix. All paths must be unique and cannot overlap."". format ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> path, p <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> )",False,path in p,p in list_copy_with_path and (not p in list_copy_without_path),0.6779139041900635
|
||
|
1052,"def ensure_slice ( x ) : <TAB> """"""Try to convert an object into a slice, complain on failure"""""" <TAB> if not x and x!= 0 : <TAB> <TAB> return slice ( None ) <TAB> elif is_slice ( x ) : <TAB> <TAB> return x <TAB> try : <TAB> <TAB> x = int ( x ) <TAB> <TAB> if x!= - 1 : <TAB> <TAB> <TAB> s = slice ( x, x + 1 ) <TAB> <TAB> else : <TAB> <TAB> <TAB> s = slice ( - 1, None, None ) <TAB> except ValueError : <TAB> <TAB> x = x. strip ( ""[]()"" ) <TAB> <TAB> m = SLICE_REG. fullmatch ( x ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> groups = ( int ( i ) if i else None for i in m. groups ( ) ) <TAB> <TAB> <TAB> s = slice ( * groups ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise ValueError ( ""cannot convert {!r} to slice"". format ( x ) ) <TAB> except TypeError : <TAB> <TAB> try : <TAB> <TAB> <TAB> s = slice ( * ( int ( i ) for i in x ) ) <TAB> <TAB> except ( TypeError, ValueError ) : <TAB> <TAB> <TAB> raise ValueError ( ""cannot convert {!r} to slice"". format ( x ) ) <TAB> return s",True,m,m,0.6932783126831055
|
||
|
1053,"def flickr_download_main ( url, output_dir = ""."", info_only = False, ** kwargs ) : <TAB> urls = None <TAB> size = ""o"" <TAB> title = None <TAB> if ""stream_id"" in kwargs : <TAB> <TAB> size = kwargs [ ""stream_id"" ] <TAB> if match1 ( url, pattern_url_single_photo ) : <TAB> <TAB> url, title = get_single_photo_url ( url ) <TAB> <TAB> urls = [ url ] <TAB> else : <TAB> <TAB> urls, title = fetch_photo_url_list ( url, size ) <TAB> index = 1 <TAB> for url in urls : <TAB> <TAB> mime, ext, size = url_info ( url ) <TAB> <TAB> print_info ( site_info, title, mime, size ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> title = ""{} {}"". format ( title, index ) <TAB> <TAB> <TAB> download_urls ( [ url ], title, ext, size, output_dir, ** kwargs ) <TAB> <TAB> <TAB> index += 1",False,not info_only,info_only,0.6536680459976196
|
||
|
1054,"def generate_breadcrumb ( self ) : <TAB> if getattr ( self, ""ci"" ) : <TAB> <TAB> parent_id = self. ci. id <TAB> else : <TAB> <TAB> return [ ] <TAB> breadcrumbs = [ ] <TAB> counter = 0 <TAB> while parent_id and counter < 100 : <TAB> <TAB> try : <TAB> <TAB> <TAB> ci = db. CI. objects. filter ( id = parent_id ). all ( ) [ 0 ] <TAB> <TAB> except IndexError : <TAB> <TAB> <TAB> break <TAB> <TAB> breadcrumbs. insert ( 0, ci ) <TAB> <TAB> try : <TAB> <TAB> <TAB> parent_id = db. CI. objects. filter ( parent__child = parent_id ). all ( ) [ 0 ]. id <TAB> <TAB> except IndexError : <TAB> <TAB> <TAB> parent_id = None <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> parent_id = None <TAB> <TAB> counter += 1 <TAB> return breadcrumbs",False,parent_id == ci.id,parent_id and counter >= 100,0.6662282943725586
|
||
|
1055,"def test_mode ( self ) -> None : <TAB> <TAB> if not has_stat : <TAB> <TAB> return <TAB> dir = self. do_create ( ) <TAB> try : <TAB> <TAB> mode = stat. S_IMODE ( os. stat ( dir ). st_mode ) <TAB> <TAB> mode &= 0o777 <TAB> <TAB> expected = 0o700 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> user = expected >> 6 <TAB> <TAB> <TAB> expected = user * ( 1 + 8 + 64 ) <TAB> <TAB> self. assertEqual ( mode, expected ) <TAB> finally : <TAB> <TAB> os. rmdir ( dir )",False,"sys.platform in ('win32', 'os2emx')",mode & 128,0.6534214019775391
|
||
|
1056,"def compose ( self, keys = None ) : <TAB> composes = [ ] <TAB> explored = set ( ) <TAB> keys = set ( keys or [ ] ) <TAB> graph = self. _graph <TAB> for v in graph. topological_iter ( ) : <TAB> <TAB> if type ( v. op ) not in CP_OP : <TAB> <TAB> <TAB> continue <TAB> <TAB> if v in explored : <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> if v. key in keys : <TAB> <TAB> <TAB> continue <TAB> <TAB> selected = [ v ] <TAB> <TAB> <TAB> <TAB> cur_node = graph. successors ( v ) [ 0 ] <TAB> <TAB> while ( <TAB> <TAB> <TAB> graph. count_predecessors ( cur_node ) == 1 <TAB> <TAB> <TAB> and type ( cur_node. op ) in CP_OP <TAB> <TAB> <TAB> and cur_node. key not in keys <TAB> <TAB> ) : <TAB> <TAB> <TAB> selected. append ( cur_node ) <TAB> <TAB> <TAB> if graph. count_successors ( cur_node )!= 1 : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> cur_node = graph. successors ( cur_node ) [ 0 ] <TAB> <TAB> if len ( selected ) > 1 : <TAB> <TAB> <TAB> explored. update ( selected ) <TAB> <TAB> <TAB> composes. append ( list ( selected ) ) <TAB> return self. _compose_graph ( composes )",False,graph.count_successors(v) != 1,v.op == CP_OP,0.6556057333946228
|
||
|
1057,"def optimize ( self, graph : Graph ) -> Tuple [ Graph, bool ] : <TAB> flag_changed = False <TAB> matches = search_sub_structure ( graph, [ self. pattern [ 0 ], Variable, self. pattern [ 1 ] ] ) <TAB> while len ( matches ) > 0 : <TAB> <TAB> op1, v1, op2 = matches. pop ( ) <TAB> <TAB> if len ( v1. input_to ) > 1 : <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> flag_changed = True <TAB> <TAB> <TAB> matches = search_sub_structure ( <TAB> <TAB> <TAB> <TAB> graph, [ self. pattern [ 0 ], Variable, self. pattern [ 1 ] ] <TAB> <TAB> <TAB> ) <TAB> return graph, flag_changed",False,"self.optimize_pair(graph, op1, op2)",op1.input_to == op2 and op1.input_to == op2,0.6514405012130737
|
||
|
1058,"def close ( self ) : <TAB> """"""Close the window and uninitialize the resources"""""" <TAB> <TAB> if self. winHandle. context is None : <TAB> <TAB> return <TAB> <TAB> if self. _origGammaRamp is not None : <TAB> <TAB> self. gammaRamp = self. _origGammaRamp <TAB> _hw_handle = None <TAB> try : <TAB> <TAB> _hw_handle = self. win. _hw_handle <TAB> <TAB> self. winHandle. close ( ) <TAB> except Exception : <TAB> <TAB> pass <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> from psychopy. iohub. client import ioHubConnection <TAB> <TAB> <TAB> conn = ioHubConnection. ACTIVE_CONNECTION <TAB> <TAB> <TAB> conn. unregisterWindowHandles ( _hw_handle ) <TAB> except Exception : <TAB> <TAB> pass",False,window.IOHUB_ACTIVE and _hw_handle,"hasattr(self.win, 'ACTIVE_CONNECTION')",0.6594565510749817
|
||
|
1059,"def f ( view, s ) : <TAB> if mode == modes. INTERNAL_NORMAL : <TAB> <TAB> if count == 1 : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> eol = view. line ( s. b ). b <TAB> <TAB> <TAB> <TAB> return R ( s. b, eol ) <TAB> <TAB> <TAB> return s <TAB> return s",False,view.line(s.b).size() > 0,view.line is not None and s.b is not None,0.6558170318603516
|
||
|
1060,"def __init__ ( self, weight = None, pos_weight = None, ignore_index = 255, edge_label = False ) : <TAB> super ( ). __init__ ( ) <TAB> self. weight = weight <TAB> self. pos_weight = pos_weight <TAB> self. ignore_index = ignore_index <TAB> self. edge_label = edge_label <TAB> self. EPS = 1e-10 <TAB> if self. weight is not None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if self. weight!= ""dynamic"" : <TAB> <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""if type of `weight` is str, it should equal to 'dynamic', but it is {}"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. weight <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> elif isinstance ( self. weight, paddle. VarBase ) : <TAB> <TAB> <TAB> raise TypeError ( <TAB> <TAB> <TAB> <TAB> ""The type of `weight` is wrong, it should be Tensor or str, but it is {}"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> type ( self. weight ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> if self. pos_weight is not None : <TAB> <TAB> if isinstance ( self. pos_weight, str ) : <TAB> <TAB> <TAB> if self. pos_weight!= ""dynamic"" : <TAB> <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""if type of `pos_weight` is str, it should equal to 'dynamic', but it is {}"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. pos_weight <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB",True,"isinstance(self.weight, str)","isinstance(self.weight, str)",0.6535137891769409
|
||
|
1061,"def trash ( self ) : <TAB> """"""Trash expired sessions."""""" <TAB> now = datetime. datetime. now ( ) <TAB> for item in self. get ( ) : <TAB> <TAB> last_visit = item. last_visit_default ( ) <TAB> <TAB> try : <TAB> <TAB> <TAB> session = item. get ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> if session. auth. expiration and not self. force : <TAB> <TAB> <TAB> <TAB> <TAB> self. expiration = session. auth. expiration <TAB> <TAB> <TAB> <TAB> if session. auth. last_visit : <TAB> <TAB> <TAB> <TAB> <TAB> last_visit = session. auth. last_visit <TAB> <TAB> except : <TAB> <TAB> <TAB> pass <TAB> <TAB> age = 0 <TAB> <TAB> if last_visit : <TAB> <TAB> <TAB> age = total_seconds ( now - last_visit ) <TAB> <TAB> if age > self. expiration or not self. expiration : <TAB> <TAB> <TAB> item. delete ( ) <TAB> <TAB> <TAB> status = ""trashed"" <TAB> <TAB> else : <TAB> <TAB> <TAB> status = ""OK"" <TAB> <TAB> if self. verbose > 1 : <TAB> <TAB> <TAB> print ( ""key: %s"" % item ) <TAB> <TAB> <TAB> print ( ""expiration: %s seconds"" % self. expiration ) <TAB> <TAB> <TAB> print ( ""last visit: %s"" % last_visit ) <TAB> <TAB> <TAB> print ( ""age: %s seconds"" % age ) <TAB> <TAB> <TAB> print ( ""status: %s"" % status ) <TAB> <TAB> <TAB> print ( """" ) <TAB> <TAB> elif self. verbose > 0 : <TAB> <TAB> <TAB> print ( ""%s %s"" % ( item, status ) )",False,session.auth,self.force,0.665627658367157
|
||
|
1062,"def setup ( self, stage ) : <TAB> if self. queue_length > 0 : <TAB> <TAB> queue_folder = os. path. join ( self. logger. log_dir, self. queue_path ) <TAB> <TAB> if not os. path. exists ( queue_folder ) : <TAB> <TAB> <TAB> os. makedirs ( queue_folder ) <TAB> <TAB> self. queue_path = os. path. join ( <TAB> <TAB> <TAB> queue_folder, ""queue"" + str ( self. trainer. global_rank ) + "".pth"" <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. queue = torch. load ( self. queue_path ) [ ""queue"" ]",False,os.path.isfile(self.queue_path),stage == 'load',0.6441220045089722
|
||
|
1063,"def convert_to_bytes ( self, BitRateString ) : <TAB> bit_rate_bytes = 0 <TAB> <TAB> s = BitRateString. lower ( ). split ( "" "" ) <TAB> measurement = ""kb"" <TAB> try : <TAB> <TAB> <TAB> <TAB> if len ( s ) >= 2 : <TAB> <TAB> <TAB> raw_number_string = s [ 0 ] <TAB> <TAB> <TAB> raw_measurement = s [ 1 ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> raw_number = locale. atof ( raw_number_string ) <TAB> <TAB> <TAB> if ""kb"" in raw_measurement : <TAB> <TAB> <TAB> <TAB> measurement = ""kb"" <TAB> <TAB> <TAB> <TAB> bit_rate_bytes = raw_number * 1000.0 <TAB> <TAB> <TAB> elif ""mb"" in raw_measurement : <TAB> <TAB> <TAB> <TAB> measurement = ""mb"" <TAB> <TAB> <TAB> <TAB> bit_rate_bytes = raw_number * 1000.0 * 1000.0 <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> measurement = ""crf"" <TAB> <TAB> <TAB> <TAB> if raw_number > 63 : <TAB> <TAB> <TAB> <TAB> <TAB> raw_number = 63 <TAB> <TAB> <TAB> <TAB> if raw_number < 0 : <TAB> <TAB> <TAB> <TAB> <TAB> raw_number = 0 <TAB> <TAB> <TAB> <TAB> bit_rate_bytes = raw_number <TAB> except : <TAB> <TAB> pass <TAB> <TAB> return str ( int ( bit_rate_bytes ) )",True,'crf' in raw_measurement,'crf' in raw_measurement,0.6572733521461487
|
||
|
1064,"def edit ( self ) : <TAB> trace = False and not g. unitTesting <TAB> if<mask> : <TAB> <TAB> g. trace ( ""===== (MultiLine:%s)"" % self. __class__. __name__ ) <TAB> <TAB> <TAB> self. editing = True <TAB> self. how_exited = None <TAB> <TAB> self. display ( ) <TAB> while self. editing : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> g. trace ( ""(MultiLine:%s) LOOP"" % self. __class__. __name__ ) <TAB> <TAB> self. get_and_use_key_press ( ) <TAB> <TAB> self. update ( clear = None ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. parent. refresh ( ) <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> g. trace ( ""(MultiLine:%s) DONE"" % self. __class__. __name__ )",False,trace,self.how_exited,0.6919523477554321
|
||
|
1065,"def subscribe ( self, channel, timeout = None ) : <TAB> event = threading. Event ( ) <TAB> self. _channels [ channel ] [ ""subs"" ]. add ( event ) <TAB> try : <TAB> <TAB> try : <TAB> <TAB> <TAB> cursor = self. _channels [ channel ] [ ""msgs"" ] [ - 1 ] [ 0 ] <TAB> <TAB> except IndexError : <TAB> <TAB> <TAB> cursor = None <TAB> <TAB> while True : <TAB> <TAB> <TAB> if not cursor : <TAB> <TAB> <TAB> <TAB> cursor_found = True <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> cursor_found = False <TAB> <TAB> <TAB> if not event. wait ( timeout ) : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> event. clear ( ) <TAB> <TAB> <TAB> messages = copy. copy ( self. _channels [ channel ] [ ""msgs"" ] ) <TAB> <TAB> <TAB> for message in messages : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> yield message [ 1 ] <TAB> <TAB> <TAB> <TAB> elif message [ 0 ] == cursor : <TAB> <TAB> <TAB> <TAB> <TAB> cursor_found = True <TAB> <TAB> <TAB> if not cursor_found : <TAB> <TAB> <TAB> <TAB> for message in messages : <TAB> <TAB> <TAB> <TAB> <TAB> yield message [ 1 ] <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> cursor = messages [ - 1 ] [ 0 ] <TAB> <TAB> <TAB> except IndexError : <TAB> <TAB> <TAB> <TAB> cursor = None <TAB> finally : <TAB> <TAB> try : <TAB> <TAB> <TAB> self. _channels [ channel ] [ ""subs"" ]. remove ( event ) <TAB> <TAB> except KeyError : <TAB> <TAB> <TAB> pass",False,cursor_found,cursor and cursor_found,0.6654545068740845
|
||
|
1066,"def test_didl_object_inheritance ( ) : <TAB> """"""Test that DIDL object inheritance is as indicated by the didl class"""""" <TAB> class_dict = data_structures. _DIDL_CLASS_TO_CLASS. copy ( ) <TAB> class_dict [ ""object"" ] = data_structures. DidlObject <TAB> for didl_class, soco_class in data_structures. _DIDL_CLASS_TO_CLASS. items ( ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> if didl_class == ""object"" : <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> assert didl_class == soco_class. item_class <TAB> <TAB> base_didl_class = ""."". join ( didl_class. split ( ""."" ) [ : - 1 ] ) <TAB> <TAB> base_class = data_structures. _DIDL_CLASS_TO_CLASS [ base_didl_class ] <TAB> <TAB> assert base_class == soco_class. __bases__ [ 0 ]",False,didl_class == 'object.itemobject.item.sonos-favorite',didl_class == 'class',0.6502702236175537
|
||
|
1067,"def process_lib ( vars_, coreval ) : <TAB> for d in vars_ : <TAB> <TAB> var = d. upper ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> value = env [ ""LIBPATH_"" + var ] <TAB> <TAB> if value : <TAB> <TAB> <TAB> core = env [ coreval ] <TAB> <TAB> <TAB> accu = [ ] <TAB> <TAB> <TAB> for lib in value : <TAB> <TAB> <TAB> <TAB> if lib in core : <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> accu. append ( lib ) <TAB> <TAB> <TAB> env [ ""LIBPATH_"" + var ] = accu",False,var == 'QTCORE',var not in env,0.6675856113433838
|
||
|
1068,"def generateData ( evaluator, hof1, hof2, symmetric = True ) : <TAB> assert len ( hof1 ) == len ( hof2 ) <TAB> gens = len ( hof1 ) <TAB> res = zeros ( ( gens, gens ) ) <TAB> for g1, ind1 in enumerate ( hof1 ) : <TAB> <TAB> for g2, ind2 in enumerate ( hof2 [ : g1 + 1 ] ) : <TAB> <TAB> <TAB> res [ g1, g2 ] = evaluator ( ind1, ind2 ) <TAB> <TAB> <TAB> if symmetric : <TAB> <TAB> <TAB> <TAB> res [ g2, g1 ] = res [ g1, g2 ] <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> res [ g1, g2 ] += evaluator ( ind2, ind1 ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> res [ g2, g1 ] = evaluator ( ind2, ind1 ) <TAB> return res",False,g1 == g2,ind1 > 0,0.6651709079742432
|
||
|
1069,"def main ( ) : <TAB> parser = argparse. ArgumentParser ( description = ""Output k-mer abundance distribution."" ) <TAB> parser. add_argument ( ""hashname"" ) <TAB> parser. add_argument ( ""seqfile"" ) <TAB> parser. add_argument ( ""histout"" ) <TAB> args = parser. parse_args ( ) <TAB> hashfile = args. hashname <TAB> seqfile = args. seqfile <TAB> histout = args. histout <TAB> outfp = open ( histout, ""w"" ) <TAB> print ( ""hashtable from"", hashfile ) <TAB> ht = khmer. load_countgraph ( hashfile ) <TAB> hist = { } <TAB> for i in range ( 65536 ) : <TAB> <TAB> hist [ i ] = 0 <TAB> for n, record in enumerate ( screed. open ( seqfile ) ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> print ( ""..."", n ) <TAB> <TAB> seq = record. sequence. replace ( ""N"", ""A"" ) <TAB> <TAB> try : <TAB> <TAB> <TAB> med, _, _ = ht. get_median_count ( seq ) <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> continue <TAB> <TAB> hist [ med ] = hist [ med ] + 1 <TAB> histlist = list ( hist. items ( ) ) <TAB> histlist. sort ( ) <TAB> maxk = max ( hist. keys ( ) ) <TAB> sumk = sum ( hist. values ( ) ) <TAB> sofar = 0 <TAB> for n, m in histlist : <TAB> <TAB> sofar += m <TAB> <TAB> percent = float ( sofar ) / sumk <TAB> <TAB> outfp. write ( ""%d %d %d %.3f\n"" % ( n, m, sofar, percent ) ) <TAB> outfp. close ( )",False,n > 0 and n % 100000 == 0,n % 2 != 0,0.6720070838928223
|
||
|
1070,"def _create_examples ( self, lines, set_type ) : <TAB> """"""Creates examples for the training and dev sets."""""" <TAB> examples = [ ] <TAB> for ( i, line ) in enumerate ( lines ) : <TAB> <TAB> <TAB> <TAB> if set_type == ""test"" and i == 0 : <TAB> <TAB> <TAB> continue <TAB> <TAB> guid = ""%s-%s"" % ( set_type, i ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> text_a = tokenization. convert_to_unicode ( line [ 1 ] ) <TAB> <TAB> <TAB> label = ""0"" <TAB> <TAB> else : <TAB> <TAB> <TAB> text_a = tokenization. convert_to_unicode ( line [ 3 ] ) <TAB> <TAB> <TAB> label = tokenization. convert_to_unicode ( line [ 1 ] ) <TAB> <TAB> examples. append ( <TAB> <TAB> <TAB> InputExample ( guid = guid, text_a = text_a, text_b = None, label = label ) <TAB> <TAB> ) <TAB> return examples",False,set_type == 'test',line[0] == 0,0.6525334119796753
|
||
|
1071,"def assertFormFieldValueTransformCorrect ( self, form_field, expected, read_results = None ) : <TAB> if expected is None : <TAB> <TAB> return <TAB> field_type = expected. type <TAB> if field_type == ""string"" : <TAB> <TAB> self. assertEqual ( form_field. value, expected. value_string ) <TAB> if field_type == ""number"" : <TAB> <TAB> self. assertEqual ( form_field. value, expected. value_number ) <TAB> if field_type == ""integer"" : <TAB> <TAB> self. assertEqual ( form_field. value, expected. value_integer ) <TAB> if field_type == ""date"" : <TAB> <TAB> self. assertEqual ( form_field. value, expected. value_date ) <TAB> if field_type == ""phoneNumber"" : <TAB> <TAB> self. assertEqual ( form_field. value, expected. value_phone_number ) <TAB> if field_type == ""time"" : <TAB> <TAB> self. assertEqual ( form_field. value, expected. value_time ) <TAB> if field_type == ""array"" : <TAB> <TAB> for i in range ( len ( expected. value_array ) ) : <TAB> <TAB> <TAB> self. assertFormFieldValueTransformCorrect ( <TAB> <TAB> <TAB> <TAB> form_field. value [ i ], expected. value_array [ i ], read_results <TAB> <TAB> <TAB> ) <TAB> if field_type == ""object"" : <TAB> <TAB> self. assertFormFieldsTransformCorrect ( <TAB> <TAB> <TAB> form_field. value, expected. value_object, read_results <TAB> <TAB> ) <TAB> if field_type not in [ ""array"", ""object"" ] and form_field. value_data : <TAB> <TAB> self. assertBoundingBoxTransformCorrect ( <TAB> <TAB> <TAB> form_field. value_data. bounding_box, expected. bounding_box <TAB> <TAB> ) <TAB> <TAB> self. assertEqual ( expected. text, form_field. value_data. text ) <TAB",False,read_results,read_results is not None,0.6613643169403076
|
||
|
1072,"def small_count ( v ) : <TAB> if not v : <TAB> <TAB> return 0 <TAB> z = [ <TAB> <TAB> ( 1000000000, _ ( ""b"" ) ), <TAB> <TAB> ( 1000000, _ ( ""m"" ) ), <TAB> <TAB> ( 1000, _ ( ""k"" ) ), <TAB> ] <TAB> v = int ( v ) <TAB> for x, y in z : <TAB> <TAB> o, p = divmod ( v, x ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if len ( str ( o ) ) > 2 or not p : <TAB> <TAB> <TAB> <TAB> return ""%d%s"" % ( o, y ) <TAB> <TAB> <TAB> return ""%.1f%s"" % ( v / float ( x ), y ) <TAB> return v",False,o,o > 0,0.7001277804374695
|
||
|
1073,"def run ( self, params = None ) : <TAB> databus = conpot_core. get_databus ( ) <TAB> cmd_ok = """" <TAB> if params : <TAB> <TAB> params_split = params. split ( "" "" ) <TAB> <TAB> cmd_ok = ""OK"" <TAB> <TAB> kap_port = parse_port ( params_split [ 0 ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> databus. set_value ( ""kap_a_server_port"", kap_port ) <TAB> <TAB> if len ( params_split ) > 1 : <TAB> <TAB> <TAB> cha_port = parse_port ( params_split [ 1 ] ) <TAB> <TAB> <TAB> if cha_port!= 0 : <TAB> <TAB> <TAB> <TAB> databus. set_value ( ""channel_a_port"", cha_port ) <TAB> <TAB> if len ( params_split ) > 2 : <TAB> <TAB> <TAB> chb_port = parse_port ( params_split [ 2 ] ) <TAB> <TAB> <TAB> if chb_port!= 0 : <TAB> <TAB> <TAB> <TAB> databus. set_value ( ""channel_b_port"", chb_port ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return self. CMD_OUTPUT. format ( <TAB> <TAB> cmd_ok, <TAB> <TAB> databus. get_value ( ""kap_a_server_port"" ), <TAB> <TAB> databus. get_value ( ""channel_a_port"" ), <TAB> <TAB> databus. get_value ( ""channel_b_port"" ), <TAB> <TAB> 50100, <TAB> )",True,kap_port != 0,kap_port != 0,0.6604142189025879
|
||
|
1074,"def help ( self, request ) : <TAB> if type ( request ) is type ( """" ) : <TAB> <TAB> if request == ""help"" : <TAB> <TAB> <TAB> self. intro ( ) <TAB> <TAB> elif request == ""keywords"" : <TAB> <TAB> <TAB> self. listkeywords ( ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> self. listtopics ( ) <TAB> <TAB> elif request == ""modules"" : <TAB> <TAB> <TAB> self. listmodules ( ) <TAB> <TAB> elif request [ : 8 ] == ""modules "" : <TAB> <TAB> <TAB> self. listmodules ( split ( request ) [ 1 ] ) <TAB> <TAB> elif request in self. keywords : <TAB> <TAB> <TAB> self. showtopic ( request ) <TAB> <TAB> elif request in self. topics : <TAB> <TAB> <TAB> self. showtopic ( request ) <TAB> <TAB> elif request : <TAB> <TAB> <TAB> doc ( request, ""Help on %s:"" ) <TAB> elif isinstance ( request, Helper ) : <TAB> <TAB> self ( ) <TAB> else : <TAB> <TAB> doc ( request, ""Help on %s:"" ) <TAB> self. output. write ( ""\n"" )",True,request == 'topics',request == 'topics',0.6826637387275696
|
||
|
1075,"def _grouped_backends ( cls, options, backend ) : <TAB> ""Group options by backend and filter out output group appropriately"" <TAB> if options is None : <TAB> <TAB> return [ ( backend or Store. current_backend, options ) ] <TAB> dfltdict = defaultdict ( dict ) <TAB> for spec, groups in options. items ( ) : <TAB> <TAB> if ""output"" not in groups. keys ( ) or len ( groups [ ""output"" ] ) == 0 : <TAB> <TAB> <TAB> dfltdict [ backend or Store. current_backend ] [ spec. strip ( ) ] = groups <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> dfltdict [ groups [ ""output"" ] [ ""backend"" ] ] [ spec. strip ( ) ] = groups <TAB> <TAB> elif [ ""backend"" ] == list ( groups [ ""output"" ]. keys ( ) ) : <TAB> <TAB> <TAB> filtered = { k : v for k, v in groups. items ( ) if k!= ""output"" } <TAB> <TAB> <TAB> dfltdict [ groups [ ""output"" ] [ ""backend"" ] ] [ spec. strip ( ) ] = filtered <TAB> <TAB> else : <TAB> <TAB> <TAB> raise Exception ( ""The output options group must have the backend keyword"" ) <TAB> return [ ( bk, bk_opts ) for ( bk, bk_opts ) in dfltdict. items ( ) ]",False,set(groups['output'].keys()) - set(['backend']),"[backend""] == list(groups[""output""])",0.6504580974578857
|
||
|
1076,"def index ( request, response_format = ""html"" ) : <TAB> ""All available tickets"" <TAB> if request. GET : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> query = _get_filter_query ( request. GET ) <TAB> <TAB> else : <TAB> <TAB> <TAB> query = Q ( status__hidden = False ) & _get_filter_query ( request. GET ) <TAB> <TAB> tickets = Object. filter_by_request ( request, Ticket. objects. filter ( query ) ) <TAB> else : <TAB> <TAB> tickets = Object. filter_by_request ( <TAB> <TAB> <TAB> request, Ticket. objects. filter ( status__hidden = False ) <TAB> <TAB> ) <TAB> filters = FilterForm ( request. user. profile, """", request. GET ) <TAB> context = _get_default_context ( request ) <TAB> context. update ( <TAB> <TAB> { <TAB> <TAB> <TAB> ""tickets"" : tickets, <TAB> <TAB> <TAB> ""filters"" : filters, <TAB> <TAB> } <TAB> ) <TAB> return render_to_response ( <TAB> <TAB> ""services/index"", <TAB> <TAB> context, <TAB> <TAB> context_instance = RequestContext ( request ), <TAB> <TAB> response_format = response_format, <TAB> )",False,'status' in request.GET and request.GET['status'],status__hidden,0.6580737829208374
|
||
|
1077,"def fwd_normalize ( fwd : OptionsIterable ) -> Options : <TAB> """"""Normalize and convert values extracted from forwarded headers."""""" <TAB> ret : Dict [ str, Union [ int, str ] ] = { } <TAB> for key, val in fwd : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> if key in ( ""by"", ""for"" ) : <TAB> <TAB> <TAB> <TAB> <TAB> ret [ key ] = fwd_normalize_address ( val ) <TAB> <TAB> <TAB> <TAB> elif key in ( ""host"", ""proto"" ) : <TAB> <TAB> <TAB> <TAB> <TAB> ret [ key ] = val. lower ( ) <TAB> <TAB> <TAB> <TAB> elif key == ""port"" : <TAB> <TAB> <TAB> <TAB> <TAB> ret [ key ] = int ( val ) <TAB> <TAB> <TAB> <TAB> elif key == ""path"" : <TAB> <TAB> <TAB> <TAB> <TAB> ret [ key ] = unquote ( val ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> ret [ key ] = val <TAB> <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> <TAB> pass <TAB> return ret",False,val is not None,key == 'address',0.6647884249687195
|
||
|
1078,"def _well_known_rules ( conf ) : <TAB> <TAB> yield iptables. Rule ( <TAB> <TAB> protocol = ""ip"", <TAB> <TAB> src = ""0.0.0.0/0.0.0.0"", <TAB> <TAB> dst = ""0.0.0.0/0.0.0.0"", <TAB> <TAB> target = ""PAASTA-COMMON"", <TAB> <TAB> matches = ( ), <TAB> <TAB> target_parameters = ( ), <TAB> ) <TAB> for dep in conf. get_dependencies ( ) or ( ) : <TAB> <TAB> resource = dep. get ( ""well-known"" ) <TAB> <TAB> if resource == ""internet"" : <TAB> <TAB> <TAB> yield iptables. Rule ( <TAB> <TAB> <TAB> <TAB> protocol = ""ip"", <TAB> <TAB> <TAB> <TAB> src = ""0.0.0.0/0.0.0.0"", <TAB> <TAB> <TAB> <TAB> dst = ""0.0.0.0/0.0.0.0"", <TAB> <TAB> <TAB> <TAB> target = ""PAASTA-INTERNET"", <TAB> <TAB> <TAB> <TAB> matches = ( ), <TAB> <TAB> <TAB> <TAB> target_parameters = ( ), <TAB> <TAB> <TAB> ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> raise AssertionError ( resource )",False,resource is not None,resource != 'error',0.6598106622695923
|
||
|
1079,"def binaryPrecedence ( token = None, allowIn = None ) : <TAB> prec = 0 <TAB> if ( token. type!= Token. Punctuator ) and ( token. type!= Token. Keyword ) : <TAB> <TAB> return 0 <TAB> while 1 : <TAB> <TAB> if token. value == ""||"" : <TAB> <TAB> <TAB> prec = 1 <TAB> <TAB> <TAB> break <TAB> <TAB> elif token. value == ""&&"" : <TAB> <TAB> <TAB> prec = 2 <TAB> <TAB> <TAB> break <TAB> <TAB> elif token. value == ""|"" : <TAB> <TAB> <TAB> prec = 3 <TAB> <TAB> <TAB> break <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> prec = 4 <TAB> <TAB> <TAB> break <TAB> <TAB> elif token. value == ""&"" : <TAB> <TAB> <TAB> prec = 5 <TAB> <TAB> <TAB> break <TAB> <TAB> elif ( token. value == ""!=="" ) or ( <TAB> <TAB> <TAB> ( token. value == ""==="" ) or ( ( token. value == ""!="" ) or ( token. value == ""=="" ) ) <TAB> <TAB> ) : <TAB> <TAB> <TAB> prec = 6 <TAB> <TAB> <TAB> break <TAB> <TAB> elif ( token. value == ""instanceof"" ) or ( <TAB> <TAB> <TAB> ( token. value == "">="" ) <TAB> <TAB> <TAB> or ( ( token. value == ""<="" ) or ( ( token. value == "">"" ) or ( token. value == ""<"" ) ) ) <TAB> <TAB> ) : <TAB> <TAB> <TAB> prec = 7 <TAB> <TAB> <TAB> break <TAB> <TAB> elif token. value == ""in"" : <TAB> <TAB> <TAB> prec = 7 if allowIn else 0 <TAB> <TAB> <TAB> break <TAB> <TAB> elif ( token. value == "">>>"" ) or ( ( token. value == "">>"" ) or ( token. value == ""<<"" ) ) : <TAB> <TAB>",False,token.value == '^',token.value == 'in',0.6612650752067566
|
||
|
1080,"def __init__ ( <TAB> self, <TAB> family = None, <TAB> style = None, <TAB> weight = None, <TAB> color = None, <TAB> size = None, <TAB> ha = None, <TAB> va = None, <TAB> rotation = None, <TAB> linespacing = None, <TAB> backgroundcolor = None, <TAB> margin = None, <TAB> ** kwargs ) : <TAB> d = { ""visible"" : True } <TAB> <TAB> with suppress ( KeyError ) : <TAB> <TAB> linespacing = kwargs. pop ( ""lineheight"" ) <TAB> with suppress ( KeyError ) : <TAB> <TAB> color = color or kwargs. pop ( ""colour"" ) <TAB> with suppress ( KeyError ) : <TAB> <TAB> _face = kwargs. pop ( ""face"" ) <TAB> <TAB> if _face == ""plain"" : <TAB> <TAB> <TAB> style = ""normal"" <TAB> <TAB> elif _face == ""italic"" : <TAB> <TAB> <TAB> style = ""italic"" <TAB> <TAB> elif _face == ""bold"" : <TAB> <TAB> <TAB> weight = ""bold"" <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> style = ""italic"" <TAB> <TAB> <TAB> weight = ""bold"" <TAB> with suppress ( KeyError ) : <TAB> <TAB> ha = self. _translate_hjust ( kwargs. pop ( ""hjust"" ) ) <TAB> with suppress ( KeyError ) : <TAB> <TAB> va = self. _translate_vjust ( kwargs. pop ( ""vjust"" ) ) <TAB> with suppress ( KeyError ) : <TAB> <TAB> rotation = kwargs. pop ( ""angle"" ) <TAB> if margin is not None : <TAB> <TAB> margin = Margin ( self, ** margin ) <TAB> <TAB> <TAB> names = ( <TAB> <TAB> ""backgroundcolor"", <TAB> <TAB> ""color"", <TAB> <TAB> ""family"", <TAB> <TAB> ""ha"", <TAB> <TAB> ""linespacing"", <TAB> <TAB> ""rotation",False,_face == 'bold.italic',_face == 'italic',0.6530894041061401
|
||
|
1081,"def wrapper_function ( * args, ** kwargs ) : <TAB> if fn. __class__ in _simple_constraint_rule_types : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> value = fn <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> value = fn ( * args, ** kwargs ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if value. __class__ in _simple_constraint_rule_types : <TAB> <TAB> if value is None : <TAB> <TAB> <TAB> return ConstraintList. End <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> return Constraint. Feasible <TAB> <TAB> elif value is False : <TAB> <TAB> <TAB> return Constraint. Infeasible <TAB> return value",True,value is True,value is True,0.6682366132736206
|
||
|
1082,"def sayText ( text, voice = None, verbose = False ) : <TAB> if ViewClient. isLinux : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> print ( ""\x1b[{}{}m>> saying: {}\x1b[0m"". format ( 35, """", text ) ) <TAB> <TAB> time. sleep ( 2 ) <TAB> <TAB> if DEBUG : <TAB> <TAB> <TAB> print ( 'Saying ""%s"" using festival' % text, file = sys. stderr ) <TAB> <TAB> pipe = subprocess. Popen ( [ ""/usr/bin/festival"" ] ) <TAB> <TAB> pipe. communicate ( '(SayText ""%s"")' % text ) <TAB> <TAB> pipe. terminate ( ) <TAB> <TAB> time. sleep ( 5 ) <TAB> elif ViewClient. isDarwin : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> print ( ""\x1b[{}{}m>> saying: {}\x1b[0m"". format ( 35, """", text ) ) <TAB> <TAB> time. sleep ( 1 ) <TAB> <TAB> if not voice : <TAB> <TAB> <TAB> voice = ""Samantha"" <TAB> <TAB> if DEBUG : <TAB> <TAB> <TAB> print ( 'Saying ""%s"" as %s' % ( text, voice ), file = sys. stderr ) <TAB> <TAB> subprocess. check_call ( [ ""/usr/bin/say"", ""-v"", voice, text ] ) <TAB> <TAB> time. sleep ( 5 ) <TAB> else : <TAB> <TAB> print ( ""sayText: Unsupported OS: {}"". format ( ViewClient. osName ), file = sys. stderr )",True,verbose,verbose,0.690322995185852
|
||
|
1083,"def calc ( self, arg ) : <TAB> op = arg [ ""op"" ] <TAB> if op == ""C"" : <TAB> <TAB> self. clear ( ) <TAB> <TAB> return str ( self. current ) <TAB> num = decimal. Decimal ( arg [ ""num"" ] ) <TAB> if self. op : <TAB> <TAB> if self. op == ""+"" : <TAB> <TAB> <TAB> self. current += num <TAB> <TAB> elif self. op == ""-"" : <TAB> <TAB> <TAB> self. current -= num <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> self. current *= num <TAB> <TAB> elif self. op == ""/"" : <TAB> <TAB> <TAB> self. current /= num <TAB> <TAB> self. op = op <TAB> else : <TAB> <TAB> self. op = op <TAB> <TAB> self. current = num <TAB> res = str ( self. current ) <TAB> if op == ""="" : <TAB> <TAB> self. clear ( ) <TAB> return res",False,self.op == '*',self.op == '+',0.664408802986145
|
||
|
1084,"def set_text_from_of ( self, direction ) : <TAB> """"""Sets the text of the numbers of displayed pages in table."""""" <TAB> if self. pagination : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if len ( self. _row_data_parts [ self. _rows_number ] ) < self. _to_value : <TAB> <TAB> <TAB> <TAB> self. _current_value = self. _current_value + self. rows_num <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. _current_value = self. _current_value + len ( <TAB> <TAB> <TAB> <TAB> <TAB> self. _row_data_parts [ self. _rows_number ] <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> self. _to_value = self. _to_value + len ( <TAB> <TAB> <TAB> <TAB> self. _row_data_parts [ self. _rows_number ] <TAB> <TAB> <TAB> ) <TAB> <TAB> if direction == ""back"" : <TAB> <TAB> <TAB> self. _current_value = self. _current_value - len ( <TAB> <TAB> <TAB> <TAB> self. _row_data_parts [ self. _rows_number ] <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> self. _to_value = self. _to_value - len ( <TAB> <TAB> <TAB> <TAB> self. _row_data_parts [ self. _rows_number ] <TAB> <TAB> <TAB> ) <TAB> <TAB> if direction == ""increment"" : <TAB> <TAB> <TAB> self. _current_value = 1 <TAB> <TAB> <TAB> self. _to_value = self. rows_num + self. _current_value - 1 <TAB> <TAB> self. pagination. ids. label_rows_per_page. text = ( <TAB> <TAB> <TAB> f""{self._current_value}-{self._to_value} of {len(",False,direction == 'forward',self._rows_number >= 0,0.6607716679573059
|
||
|
1085,"def PyJs_anonymous_3997_ ( min, max, this, arguments, var = var ) : <TAB> var = Scope ( { u""this"" : this, u""max"" : max, u""arguments"" : arguments, u""min"" : min }, var ) <TAB> var. registers ( [ u""max"", u""folded"", u""$this"", u""min"" ] ) <TAB> var. put ( u""$this"", var. get ( u""this"" ) ) <TAB> while 1 : <TAB> <TAB> var. put ( u""folded"", var. get ( u""caseFold"" ) ( var. get ( u""min"" ) ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> var. get ( u""$this"" ). callprop ( u""add"", var. get ( u""folded"" ) ) <TAB> <TAB> if not ( <TAB> <TAB> <TAB> var. put ( u""min"", Js ( var. get ( u""min"" ). to_number ( ) ) + Js ( 1 ) ) <= var. get ( u""max"" ) <TAB> <TAB> ) : <TAB> <TAB> <TAB> break <TAB> return var. get ( u""$this"" )",False,var.get(u'folded'),"hasattr(var, 'get')",0.6533318758010864
|
||
|
1086,"def check_value_shape ( self, value, slice_ ) : <TAB> """"""Checks if value can be set to the slice"""""" <TAB> if None not in self. shape and self. dtype!= ""O"" : <TAB> <TAB> if not all ( [ isinstance ( sh, int ) for sh in slice_ ] ) : <TAB> <TAB> <TAB> expected_value_shape = tuple ( <TAB> <TAB> <TAB> <TAB> [ <TAB> <TAB> <TAB> <TAB> <TAB> len ( range ( * slice_shape. indices ( self. shape [ i ] ) ) ) <TAB> <TAB> <TAB> <TAB> <TAB> for i, slice_shape in enumerate ( slice_ ) <TAB> <TAB> <TAB> <TAB> <TAB> if not isinstance ( slice_shape, int ) <TAB> <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if isinstance ( value, list ) : <TAB> <TAB> <TAB> <TAB> value = np. array ( value ) <TAB> <TAB> <TAB> if isinstance ( value, np. ndarray ) : <TAB> <TAB> <TAB> <TAB> value_shape = [ dim for dim in value. shape if dim!= 1 ] <TAB> <TAB> <TAB> <TAB> expected_shape = [ dim for dim in expected_value_shape if dim!= 1 ] <TAB> <TAB> <TAB> <TAB> if value_shape!= expected_shape : <TAB> <TAB> <TAB> <TAB> <TAB> raise ValueShapeError ( expected_value_shape, value. shape ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> value = value. reshape ( expected_value_shape ) <TAB> <TAB> else : <TAB> <TAB> <TAB> expected_value_shape = ( 1, ) <TAB> <TAB> <TAB> if isinstance ( value, list ) : <TAB> <TAB> <TAB> <TAB> value = np. array ( value ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise",False,"isinstance(value, np.ndarray) and value.shape != expected_value_shape",value != expected_value_shape,0.6493576765060425
|
||
|
1087,"def _can_serialize_limited_fsim ( theta : float, phi : float ) : <TAB> <TAB> <TAB> if _near_mod_2pi ( phi, 0 ) or isinstance ( phi, sympy. Symbol ) : <TAB> <TAB> if isinstance ( theta, sympy. Symbol ) : <TAB> <TAB> <TAB> return True <TAB> <TAB> <TAB> <TAB> if _near_mod_2pi ( theta, 0 ) : <TAB> <TAB> <TAB> return True <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return True <TAB> <TAB> <TAB> <TAB> if _near_mod_2pi ( theta, np. pi / 4 ) : <TAB> <TAB> <TAB> return True <TAB> <TAB> if ( <TAB> <TAB> ( _near_mod_2pi ( theta, np. pi / 2 ) or isinstance ( theta, sympy. Symbol ) ) <TAB> <TAB> and ( _near_mod_2pi ( phi, np. pi / 6 ) ) <TAB> <TAB> or isinstance ( phi, sympy. Symbol ) <TAB> ) : <TAB> <TAB> return True <TAB> <TAB> if ( <TAB> <TAB> ( _near_mod_2pi ( theta, 0 ) or isinstance ( theta, sympy. Symbol ) ) <TAB> <TAB> and ( _near_mod_2pi ( phi, np. pi ) ) <TAB> <TAB> or isinstance ( phi, sympy. Symbol ) <TAB> ) : <TAB> <TAB> return True <TAB> return False",False,"_near_mod_2pi(theta, -np.pi / 4)",phi is None,0.6483414173126221
|
||
|
1088,"def tokens_to_spans ( ) -> Iterable [ Tuple [ str, Optional [ Style ] ] ] : <TAB> """"""Convert tokens to spans."""""" <TAB> tokens = iter ( line_tokenize ( ) ) <TAB> line_no = 0 <TAB> _line_start = line_start - 1 <TAB> <TAB> while line_no < _line_start : <TAB> <TAB> _token_type, token = next ( tokens ) <TAB> <TAB> yield ( token, None ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> line_no += 1 <TAB> <TAB> for token_type, token in tokens : <TAB> <TAB> yield ( token, _get_theme_style ( token_type ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> line_no += 1 <TAB> <TAB> <TAB> if line_no >= line_end : <TAB> <TAB> <TAB> <TAB> break",False,token.endswith('\n'),token_type in THRESHOLD_STANDALONE_CLASSES,0.651739239692688
|
||
|
1089,"def getCustomProperties ( self ) : <TAB> self. fields = { } <TAB> self. relations = { } <TAB> self. columns = [ ] <TAB> self. meta = self. klass. _meta <TAB> for name in self. meta. get_all_field_names ( ) : <TAB> <TAB> x = self. meta. get_field_by_name ( name ) [ 0 ] <TAB> <TAB> if isinstance ( x, files. FileField ) : <TAB> <TAB> <TAB> self. readonly_attrs. update ( [ name ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> if isinstance ( x, related. ManyToManyField ) : <TAB> <TAB> <TAB> self. relations [ name ] = x <TAB> <TAB> elif not isinstance ( x, related. ForeignKey ) : <TAB> <TAB> <TAB> self. fields [ name ] = x <TAB> <TAB> else : <TAB> <TAB> <TAB> self. relations [ name ] = x <TAB> parent_fields = [ ] <TAB> for field in self. meta. parents. values ( ) : <TAB> <TAB> parent_fields. append ( field. attname ) <TAB> <TAB> del self. relations [ field. name ] <TAB> self. exclude_attrs. update ( parent_fields ) <TAB> props = self. fields. keys ( ) <TAB> self. encodable_properties. update ( props ) <TAB> self. decodable_properties. update ( props ) <TAB> self. exclude_attrs. update ( [ ""_state"" ] )",False,"isinstance(x, related.RelatedObject)",not x,0.6547265648841858
|
||
|
1090,"def kwargs ( self ) : <TAB> kwargs = { } <TAB> kwargs_started = False <TAB> for param_name, param in self. _signature. parameters. items ( ) : <TAB> <TAB> if not kwargs_started : <TAB> <TAB> <TAB> if param. kind in ( _VAR_KEYWORD, _KEYWORD_ONLY ) : <TAB> <TAB> <TAB> <TAB> kwargs_started = True <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> if param_name not in self. arguments : <TAB> <TAB> <TAB> <TAB> <TAB> kwargs_started = True <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> if not kwargs_started : <TAB> <TAB> <TAB> continue <TAB> <TAB> try : <TAB> <TAB> <TAB> arg = self. arguments [ param_name ] <TAB> <TAB> except KeyError : <TAB> <TAB> <TAB> pass <TAB> <TAB> else : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> kwargs. update ( arg ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> kwargs [ param_name ] = arg <TAB> return kwargs",False,param.kind == _VAR_KEYWORD,arg,0.6594990491867065
|
||
|
1091,"def ki_protection_enabled ( frame ) : <TAB> while frame is not None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return frame. f_locals [ LOCALS_KEY_KI_PROTECTION_ENABLED ] <TAB> <TAB> if frame. f_code. co_name == ""__del__"" : <TAB> <TAB> <TAB> return True <TAB> <TAB> frame = frame. f_back <TAB> return True",True,LOCALS_KEY_KI_PROTECTION_ENABLED in frame.f_locals,LOCALS_KEY_KI_PROTECTION_ENABLED in frame.f_locals,0.6562126278877258
|
||
|
1092,"def wrapper ( self, * args, ** kwargs ) : <TAB> initial_switch_count = getattr ( _get_hub ( ), ""switch_count"", None ) <TAB> self. switch_expected = getattr ( self, ""switch_expected"", True ) <TAB> if initial_switch_count is not None : <TAB> <TAB> fullname = getattr ( self, ""fullname"", None ) <TAB> <TAB> if self. switch_expected == ""default"" and fullname : <TAB> <TAB> <TAB> self. switch_expected = get_switch_expected ( fullname ) <TAB> result = method ( self, * args, ** kwargs ) <TAB> if initial_switch_count is not None and self. switch_expected is not None : <TAB> <TAB> switch_count = _get_hub ( ). switch_count - initial_switch_count <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> assert switch_count >= 0 <TAB> <TAB> <TAB> if not switch_count : <TAB> <TAB> <TAB> <TAB> raise AssertionError ( ""%s did not switch"" % fullname ) <TAB> <TAB> elif self. switch_expected is False : <TAB> <TAB> <TAB> if switch_count : <TAB> <TAB> <TAB> <TAB> raise AssertionError ( ""%s switched but not expected to"" % fullname ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise AssertionError ( <TAB> <TAB> <TAB> <TAB> ""Invalid value for switch_expected: %r"" % ( self. switch_expected, ) <TAB> <TAB> <TAB> ) <TAB> return result",False,self.switch_expected is True,fullname,0.6529824733734131
|
||
|
1093,"def ResolveTarget ( build_file, target, toolset ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> [ parsed_build_file, target, parsed_toolset ] = ParseQualifiedTarget ( target ) <TAB> if parsed_build_file : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> build_file = os. path. normpath ( <TAB> <TAB> <TAB> <TAB> os. path. join ( os. path. dirname ( build_file ), parsed_build_file ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if not os. path. isabs ( build_file ) : <TAB> <TAB> <TAB> <TAB> build_file = RelativePath ( build_file, ""."" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> build_file = parsed_build_file <TAB> if parsed_toolset : <TAB> <TAB> toolset = parsed_toolset <TAB> return [ build_file, target, toolset ]",True,build_file,build_file,0.6688035726547241
|
||
|
1094,"def unpack_response ( response ) : <TAB> try : <TAB> <TAB> data = response. task. read ( size = 2 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise GAE_Exception ( 600, ""get protocol head fail"" ) <TAB> <TAB> if len ( data )!= 2 : <TAB> <TAB> <TAB> raise GAE_Exception ( <TAB> <TAB> <TAB> <TAB> 600, ""get protocol head fail, data:%s, len:%d"" % ( data, len ( data ) ) <TAB> <TAB> <TAB> ) <TAB> <TAB> ( headers_length, ) = struct. unpack ( ""!h"", data ) <TAB> <TAB> data = response. task. read ( size = headers_length ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise GAE_Exception ( 600, ""get protocol head fail, len:%d"" % headers_length ) <TAB> <TAB> raw_response_line, headers_data = inflate ( data ). split ( b""\r\n"", 1 ) <TAB> <TAB> rl = raw_response_line. split ( ) <TAB> <TAB> response. app_status = int ( rl [ 1 ] ) <TAB> <TAB> if len ( rl ) >= 3 : <TAB> <TAB> <TAB> response. app_reason = rl [ 2 ]. strip ( ) <TAB> <TAB> headers_block, app_msg = headers_data. split ( b""\r\n\r\n"" ) <TAB> <TAB> headers_pairs = headers_block. split ( b""\r\n"" ) <TAB> <TAB> response. headers = { } <TAB> <TAB> for pair in headers_pairs : <TAB> <TAB> <TAB> if not pair : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> k, v = pair. split ( b"": "", 1 ) <TAB> <TAB> <TAB> response. headers [ k ] = v <TAB> <TAB> response. app_msg = app_msg <TAB> <TAB> return response <TAB> except Exception as e : <TAB> <TAB",False,not data,len(data) != 0,0.675366997718811
|
||
|
1095,"def _do_http_request ( <TAB> self, retry, machines_cache, request_executor, method, path, fields = None, ** kwargs ) : <TAB> if fields is not None : <TAB> <TAB> kwargs [ ""fields"" ] = fields <TAB> some_request_failed = False <TAB> for i, base_uri in enumerate ( machines_cache ) : <TAB> <TAB> if i > 0 : <TAB> <TAB> <TAB> logger. info ( ""Retrying on %s"", base_uri ) <TAB> <TAB> try : <TAB> <TAB> <TAB> response = request_executor ( method, base_uri + path, ** kwargs ) <TAB> <TAB> <TAB> response. data. decode ( ""utf-8"" ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. set_base_uri ( base_uri ) <TAB> <TAB> <TAB> <TAB> self. _refresh_machines_cache ( ) <TAB> <TAB> <TAB> return response <TAB> <TAB> except ( HTTPError, HTTPException, socket. error, socket. timeout ) as e : <TAB> <TAB> <TAB> self. http. clear ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if not retry and i + 1 < len ( machines_cache ) : <TAB> <TAB> <TAB> <TAB> self. set_base_uri ( machines_cache [ i + 1 ] ) <TAB> <TAB> <TAB> if ( <TAB> <TAB> <TAB> <TAB> isinstance ( fields, dict ) <TAB> <TAB> <TAB> <TAB> and fields. get ( ""wait"" ) == ""true"" <TAB> <TAB> <TAB> <TAB> and isinstance ( e, ( ReadTimeoutError, ProtocolError ) ) <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> logger. debug ( ""Watch timed out."" ) <TAB> <TAB> <TAB> <TAB> raise etcd. EtcdWatchTimedOut ( ""Watch timed out: {0}"". format ( e ), cause = e ) <TAB>",True,some_request_failed,some_request_failed,0.6598477959632874
|
||
|
1096,"def check ( self, result_info ) : <TAB> if ""Scored"" not in result_info [ ""status"" ] : <TAB> <TAB> raise TestFailure ( <TAB> <TAB> <TAB> ""Expected a successful evaluation, got: %s"" % result_info [ ""status"" ] <TAB> <TAB> ) <TAB> if not result_info [ ""evaluations"" ] : <TAB> <TAB> raise TestFailure ( ""No evaluations found."" ) <TAB> for evaluation in result_info [ ""evaluations"" ] : <TAB> <TAB> score = float ( evaluation [ ""outcome"" ] ) <TAB> <TAB> text = evaluation [ ""text"" ] <TAB> <TAB> if score!= 0.0 : <TAB> <TAB> <TAB> raise TestFailure ( <TAB> <TAB> <TAB> <TAB> ""Should have %s. Scored %g."" % ( self. short_adjective, score ) <TAB> <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise TestFailure ( ""Should have %s, got %s"" % ( self. short_adjective, text ) )",False,self.failure_string not in text,text != 0.0,0.6532106399536133
|
||
|
1097,"def _try_passwordless_openssh ( server, keyfile ) : <TAB> """"""Try passwordless login with shell ssh command."""""" <TAB> if pexpect is None : <TAB> <TAB> raise ImportError ( ""pexpect unavailable, use paramiko"" ) <TAB> cmd = ""ssh -f "" + server <TAB> if keyfile : <TAB> <TAB> cmd += "" -i "" + keyfile <TAB> cmd += "" exit"" <TAB> <TAB> env = os. environ. copy ( ) <TAB> env. pop ( ""SSH_ASKPASS"", None ) <TAB> ssh_newkey = ""Are you sure you want to continue connecting"" <TAB> p = pexpect. spawn ( cmd, env = env ) <TAB> while True : <TAB> <TAB> try : <TAB> <TAB> <TAB> i = p. expect ( [ ssh_newkey, _password_pat ], timeout = 0.1 ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise SSHException ( ""The authenticity of the host can't be established."" ) <TAB> <TAB> except pexpect. TIMEOUT : <TAB> <TAB> <TAB> continue <TAB> <TAB> except pexpect. EOF : <TAB> <TAB> <TAB> return True <TAB> <TAB> else : <TAB> <TAB> <TAB> return False",False,i == 0,i is None,0.676398515701294
|
||
|
1098,"def process_batch_data ( input_data, settings, mode, color_jitter, rotate ) : <TAB> batch_data = [ ] <TAB> for sample in input_data : <TAB> <TAB> if os. path. isfile ( sample [ 0 ] ) : <TAB> <TAB> <TAB> tmp_data = process_image ( sample, settings, mode, color_jitter, rotate ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> batch_data. append ( tmp_data ) <TAB> <TAB> else : <TAB> <TAB> <TAB> logger. info ( ""File not exist : {0}"". format ( sample [ 0 ] ) ) <TAB> return batch_data",False,tmp_data is None,len(tmp_data) == 0,0.6562032699584961
|
||
|
1099,"def _GetMSBuildConfigurationDetails ( spec, build_file ) : <TAB> properties = { } <TAB> for name, settings in spec [ ""configurations"" ]. iteritems ( ) : <TAB> <TAB> msbuild_attributes = _GetMSBuildAttributes ( spec, settings, build_file ) <TAB> <TAB> condition = _GetConfigurationCondition ( name, settings ) <TAB> <TAB> character_set = msbuild_attributes. get ( ""CharacterSet"" ) <TAB> <TAB> _AddConditionalProperty ( <TAB> <TAB> <TAB> properties, <TAB> <TAB> <TAB> condition, <TAB> <TAB> <TAB> ""ConfigurationType"", <TAB> <TAB> <TAB> msbuild_attributes [ ""ConfigurationType"" ], <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> _AddConditionalProperty ( <TAB> <TAB> <TAB> <TAB> properties, condition, ""CharacterSet"", character_set <TAB> <TAB> <TAB> ) <TAB> return _GetMSBuildPropertyGroup ( spec, ""Configuration"", properties )",False,character_set,"not property_exists(spec, property_names)",0.663638174533844
|
||
|
1100,"def _get_attr ( sdk_path, mod_attr_path, checked = True ) : <TAB> try : <TAB> <TAB> attr_mod, attr_path = ( <TAB> <TAB> <TAB> mod_attr_path. split ( ""#"" ) if ""#"" in mod_attr_path else ( mod_attr_path, """" ) <TAB> <TAB> ) <TAB> <TAB> full_mod_path = ""{}.{}"". format ( sdk_path, attr_mod ) if attr_mod else sdk_path <TAB> <TAB> op = import_module ( full_mod_path ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for part in attr_path. split ( ""."" ) : <TAB> <TAB> <TAB> <TAB> op = getattr ( op, part ) <TAB> <TAB> return op <TAB> except ( ImportError, AttributeError ) as ex : <TAB> <TAB> if checked : <TAB> <TAB> <TAB> return None <TAB> <TAB> raise ex",True,attr_path,attr_path,0.6652535200119019
|
||
|
1101,"def _process_sample_weight ( self, interactions, sample_weight ) : <TAB> if sample_weight is not None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise NotImplementedError ( <TAB> <TAB> <TAB> <TAB> ""k-OS loss with sample weights "" ""not implemented."" <TAB> <TAB> <TAB> ) <TAB> <TAB> if not isinstance ( sample_weight, sp. coo_matrix ) : <TAB> <TAB> <TAB> raise ValueError ( ""Sample_weight must be a COO matrix."" ) <TAB> <TAB> if sample_weight. shape!= interactions. shape : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""Sample weight and interactions "" ""matrices must be the same shape"" <TAB> <TAB> <TAB> ) <TAB> <TAB> if not ( <TAB> <TAB> <TAB> np. array_equal ( interactions. row, sample_weight. row ) <TAB> <TAB> <TAB> and np. array_equal ( interactions. col, sample_weight. col ) <TAB> <TAB> ) : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""Sample weight and interaction matrix "" <TAB> <TAB> <TAB> <TAB> ""entries must be in the same order"" <TAB> <TAB> <TAB> ) <TAB> <TAB> if sample_weight. data. dtype!= CYTHON_DTYPE : <TAB> <TAB> <TAB> sample_weight_data = sample_weight. data. astype ( CYTHON_DTYPE ) <TAB> <TAB> else : <TAB> <TAB> <TAB> sample_weight_data = sample_weight. data <TAB> else : <TAB> <TAB> if np. array_equiv ( interactions. data, 1.0 ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> sample_weight_data = interactions. data <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> sample_weight_data = np. ones_like ( interactions. data,",False,self.loss == 'warp-kos',self.k_OS_Loss,0.6573790311813354
|
||
|
1102,"def correct_awareness ( value ) : <TAB> if isinstance ( value, datetime ) : <TAB> <TAB> if settings. USE_TZ : <TAB> <TAB> <TAB> return make_aware ( value ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> default_tz = timezone. get_default_timezone ( ) <TAB> <TAB> <TAB> return timezone. make_naive ( value, default_tz ) <TAB> return value",False,timezone.is_aware(value),"isinstance(value, timezone.timezone)",0.6515957117080688
|
||
|
1103,"def _init_weights ( self, module ) : <TAB> if isinstance ( module, nn. Linear ) : <TAB> <TAB> module. weight. data. normal_ ( mean = 0.0, std = self. config. init_std ) <TAB> <TAB> if module. bias is not None : <TAB> <TAB> <TAB> module. bias. data. zero_ ( ) <TAB> elif isinstance ( module, nn. Embedding ) : <TAB> <TAB> module. weight. data. normal_ ( mean = 0.0, std = self. config. init_std ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> module. weight. data [ module. padding_idx ]. zero_ ( )",True,module.padding_idx is not None,module.padding_idx is not None,0.6553285121917725
|
||
|
1104,"def _create_examples ( self, lines, set_type ) : <TAB> """"""Creates examples for the training/dev/test sets."""""" <TAB> examples = [ ] <TAB> for i, line in enumerate ( lines ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> guid = ""%s-%s"" % ( set_type, i ) <TAB> <TAB> if set_type == ""test"" : <TAB> <TAB> <TAB> text_a = self. process_text_fn ( line [ 1 ] ) <TAB> <TAB> <TAB> label = ""0"" <TAB> <TAB> else : <TAB> <TAB> <TAB> text_a = self. process_text_fn ( line [ 3 ] ) <TAB> <TAB> <TAB> label = self. process_text_fn ( line [ 1 ] ) <TAB> <TAB> examples. append ( <TAB> <TAB> <TAB> InputExample ( guid = guid, text_a = text_a, text_b = None, label = label ) <TAB> <TAB> ) <TAB> return examples",False,set_type == 'test' and i == 0,i == 0,0.6546224355697632
|
||
|
1105,"def there_are_num_which_tasks ( context, num, which, state, exact ) : <TAB> context. max_tasks = num <TAB> app_id = which_id ( context, which ) <TAB> <TAB> for _ in range ( 180 ) : <TAB> <TAB> app = context. current_client. get_app ( app_id, embed_tasks = True ) <TAB> <TAB> happy_tasks = get_happy_tasks ( <TAB> <TAB> <TAB> app, context. service, ""fake_nerve_ns"", context. system_paasta_config <TAB> <TAB> ) <TAB> <TAB> happy_count = len ( happy_tasks ) <TAB> <TAB> if state == ""healthy"" : <TAB> <TAB> <TAB> if exact : <TAB> <TAB> <TAB> <TAB> if happy_count == context. max_tasks : <TAB> <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> elif state == ""unhealthy"" : <TAB> <TAB> <TAB> if exact : <TAB> <TAB> <TAB> <TAB> if len ( app. tasks ) - happy_count == context. max_tasks : <TAB> <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> if len ( app. tasks ) - happy_count >= context. max_tasks : <TAB> <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> time. sleep ( 0.5 ) <TAB> raise Exception ( <TAB> <TAB> ""timed out waiting for %d %s tasks on %s; there are %d"" <TAB> <TAB> % ( context. max_tasks, state, app_id, len ( app. tasks ) ) <TAB> )",False,happy_count >= context.max_tasks,len(app.tasks) == context.max_tasks,0.653680682182312
|
||
|
1106,"def _dump_arg_defaults ( kwargs ) : <TAB> """"""Inject default arguments for dump functions."""""" <TAB> if current_app : <TAB> <TAB> kwargs. setdefault ( ""cls"", current_app. json_encoder ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> kwargs. setdefault ( ""ensure_ascii"", False ) <TAB> <TAB> kwargs. setdefault ( ""sort_keys"", current_app. config [ ""JSON_SORT_KEYS"" ] ) <TAB> else : <TAB> <TAB> kwargs. setdefault ( ""sort_keys"", True ) <TAB> <TAB> kwargs. setdefault ( ""cls"", JSONEncoder )",False,not current_app.config['JSON_AS_ASCII'],'JSON_SORT_KEYS' in current_app.config,0.6479122638702393
|
||
|
1107,"def clear_except ( self, retained_segments ) : <TAB> sn = set ( s. name for s in retained_segments ) <TAB> try : <TAB> <TAB> for n in os. listdir ( self. running ) : <TAB> <TAB> <TAB> if n not in sn and re. match ( storage. SEGMENT_REGEXP, n ) : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> shutil. rmtree ( path. join ( self. running, n ) ) <TAB> <TAB> <TAB> <TAB> except EnvironmentError as e : <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> raise <TAB> except EnvironmentError as e : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise <TAB> try : <TAB> <TAB> for n in os. listdir ( self. prefetched_dir ) : <TAB> <TAB> <TAB> if n not in sn and re. match ( storage. SEGMENT_REGEXP, n ) : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> os. remove ( path. join ( self. prefetched_dir, n ) ) <TAB> <TAB> <TAB> <TAB> except EnvironmentError as e : <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> raise <TAB> except EnvironmentError as e : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise",False,e.errno != errno.ENOENT,e.exit_code,0.6543263792991638
|
||
|
1108,"def _check_extra_fetches ( self, extra_fetches ) : <TAB> fetch_values = None <TAB> if extra_fetches is not None : <TAB> <TAB> fetch_values = list ( extra_fetches. values ( ) ) <TAB> if fetch_values is not None : <TAB> <TAB> if self. _samples in fetch_values : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""`samples` must not be included in `extra_fetches`. "" <TAB> <TAB> <TAB> <TAB> ""It is added automatically."" <TAB> <TAB> <TAB> ) <TAB> <TAB> if self. _sequence_length in fetch_values : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""`sequence_length` must not be included in `extra_fetches`."" <TAB> <TAB> <TAB> <TAB> "" It is added automatically."" <TAB> <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""Key'samples' is preserved and must not be used "" ""in `extra_fetches`."" <TAB> <TAB> <TAB> ) <TAB> <TAB> if ""sequence_length"" in extra_fetches : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""Key'sequence_length' is preserved and must not be used "" <TAB> <TAB> <TAB> <TAB> ""in `extra_fetches`."" <TAB> <TAB> <TAB> )",True,'samples' in extra_fetches,'samples' in extra_fetches,0.6581804156303406
|
||
|
1109,"def generate_and_check_random ( ) : <TAB> random_size = 256 <TAB> while True : <TAB> <TAB> random = os. urandom ( random_size ) <TAB> <TAB> a = int. from_bytes ( random, ""big"" ) <TAB> <TAB> A = pow ( g, a, p ) <TAB> <TAB> if is_good_mod_exp_first ( A, p ) : <TAB> <TAB> <TAB> a_for_hash = big_num_for_hash ( A ) <TAB> <TAB> <TAB> u = int. from_bytes ( sha256 ( a_for_hash, b_for_hash ), ""big"" ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return ( a, a_for_hash, u )",False,u > 0,"is_good_mod_exp_first(u, p)",0.6681889295578003
|
||
|
1110,"def get_children ( node ) : <TAB> result = [ ] <TAB> if node. _fields is not None : <TAB> <TAB> for name in node. _fields : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> child = getattr ( node, name ) <TAB> <TAB> <TAB> result. append ( child ) <TAB> return result",False,"name in ['lineno', 'col_offset']","hasattr(node, name) is False",0.6571792364120483
|
||
|
1111,"def from_unparsed_string ( self, chunk ) : <TAB> """"""Parse an unknown string into body and prefix."""""" <TAB> chunk = chunk. strip ( ) <TAB> if not Flag. indicates_flag ( chunk ) : <TAB> <TAB> <TAB> <TAB> return Flag. Builder ( ) <TAB> for prefix in Flag. SEPARABLE_PREFIXES : <TAB> <TAB> if chunk. startswith ( prefix ) : <TAB> <TAB> <TAB> self. __prefix = prefix <TAB> <TAB> <TAB> rest = chunk [ len ( prefix ) : ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. __separator = rest [ 0 ] <TAB> <TAB> <TAB> <TAB> rest = rest [ 1 : ] <TAB> <TAB> <TAB> self. __body = rest. strip ( ) <TAB> <TAB> <TAB> return self <TAB> <TAB> if not self. __body : <TAB> <TAB> self. __body = chunk <TAB> return self",False,rest and rest[0] in Flag.POSSIBLE_SEPARATORS,rest,0.6559641361236572
|
||
|
1112,"def _format_input_map_as_tensors ( self, input_map ) : <TAB> """"""Returns a map from string to `tf.Tensor` or `CompositeTensor`."""""" <TAB> result = { } <TAB> for key, value in input_map. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> result [ key ] = value <TAB> <TAB> else : <TAB> <TAB> <TAB> result [ key ] = tf. convert_to_tensor ( value ) <TAB> return result",False,"isinstance(value, (tf.Tensor, composite_tensor.CompositeTensor))","isinstance(value, (tf.Tensor, tf.CompositeTensor))",0.6526621580123901
|
||
|
1113,"def _create_win ( self ) : <TAB> try : <TAB> <TAB> key = _winreg. OpenKey ( <TAB> <TAB> <TAB> _winreg. HKEY_LOCAL_MACHINE, <TAB> <TAB> <TAB> r""Software\Microsoft\Windows NT\CurrentVersion\Fonts"", <TAB> <TAB> ) <TAB> except EnvironmentError : <TAB> <TAB> try : <TAB> <TAB> <TAB> key = _winreg. OpenKey ( <TAB> <TAB> <TAB> <TAB> _winreg. HKEY_LOCAL_MACHINE, <TAB> <TAB> <TAB> <TAB> r""Software\Microsoft\Windows\CurrentVersion\Fonts"", <TAB> <TAB> <TAB> ) <TAB> <TAB> except EnvironmentError : <TAB> <TAB> <TAB> raise FontNotFound ( ""Can't open Windows font registry key"" ) <TAB> try : <TAB> <TAB> path = self. _lookup_win ( key, self. font_name, STYLES [ ""NORMAL"" ], True ) <TAB> <TAB> self. fonts [ ""NORMAL"" ] = ImageFont. truetype ( path, self. font_size ) <TAB> <TAB> for style in ( ""ITALIC"", ""BOLD"", ""BOLDITALIC"" ) : <TAB> <TAB> <TAB> path = self. _lookup_win ( key, self. font_name, STYLES [ style ] ) <TAB> <TAB> <TAB> if path : <TAB> <TAB> <TAB> <TAB> self. fonts [ style ] = ImageFont. truetype ( path, self. font_size ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> self. fonts [ style ] = self. fonts [ ""BOLD"" ] <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> self. fonts [ style ] = self. fonts [ ""NORMAL"" ] <TAB> finally : <TAB> <TAB> _winreg. CloseKey ( key )",False,style == 'BOLDITALIC',self.has_font,0.6627036333084106
|
||
|
1114,"def data ( self, index, role ) : <TAB> <TAB> row_offset = self. get_row_offset ( ) <TAB> if not index. isValid ( ) : <TAB> <TAB> return None <TAB> elif role!= QtCore. Qt. DisplayRole : <TAB> <TAB> return None <TAB> if index. column ( ) == 0 : <TAB> <TAB> return ""{:,}"". format ( index. row ( ) + self. row_count_start + row_offset ) <TAB> else : <TAB> <TAB> <TAB> <TAB> row = row_offset + index. row ( ) <TAB> <TAB> column_name = self. get_column_names ( ) [ index. column ( ) - 1 ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> value = self. dataset. evaluate ( column_name, row, row + 1 ) <TAB> <TAB> except Exception as e : <TAB> <TAB> <TAB> logger. exception ( ""Error evaluating: %s %s"", column_name, row ) <TAB> <TAB> <TAB> return ""Error: %r"" % e <TAB> <TAB> try : <TAB> <TAB> <TAB> value = value [ 0 ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return str ( value ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> return ""%s %s"" % ( value. dtype. name, value. shape ) <TAB> <TAB> except : <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> return str ( value )",False,len(value.shape) == 0,role == QtCore.Qt.DisplayRole,0.655818521976471
|
||
|
1115,"def run ( self ) : <TAB> self. alive = True <TAB> if _log. isEnabledFor ( _DEBUG ) : <TAB> <TAB> _log. debug ( ""started"" ) <TAB> while self. alive : <TAB> <TAB> task = self. queue. get ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> function, args, kwargs = task <TAB> <TAB> <TAB> assert function <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> function ( * args, ** kwargs ) <TAB> <TAB> <TAB> except : <TAB> <TAB> <TAB> <TAB> _log. exception ( ""calling %s"", function ) <TAB> if _log. isEnabledFor ( _DEBUG ) : <TAB> <TAB> _log. debug ( ""stopped"" )",True,task,task,0.7189342975616455
|
||
|
1116,"def record_error ( e ) : <TAB> if isinstance ( e, failure. Failure ) : <TAB> <TAB> e = e. value <TAB> <TAB> with self. lock : <TAB> <TAB> <TAB> <TAB> if self. _already_closed ( factory. i ) : <TAB> <TAB> <TAB> extra_logger. info ( <TAB> <TAB> <TAB> <TAB> ""[%s] Ignoring error for already closed connection: %s"", label, e <TAB> <TAB> <TAB> ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> extra_logger. info ( <TAB> <TAB> <TAB> <TAB> ""[%s] Received error for connection which has not been fully initialized: %s"", <TAB> <TAB> <TAB> <TAB> label, <TAB> <TAB> <TAB> <TAB> e, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. errors [ factory. i ] = e <TAB> <TAB> else : <TAB> <TAB> <TAB> extra_logger. info ( ""[%s] Recording fatal error for connection: %s"", label, e ) <TAB> <TAB> <TAB> self. errors [ factory. i ] = e",False,factory.i not in self.clients,self._has_error(factory.i),0.6604547500610352
|
||
|
1117,"def _as_key_indices ( keys, key_names ) : <TAB> if keys is None : <TAB> <TAB> return keys <TAB> key_indices = [ ] <TAB> for key in keys : <TAB> <TAB> if isinstance ( key, numbers. Integral ) : <TAB> <TAB> <TAB> key_index = key <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> key_index += len ( key_names ) <TAB> <TAB> <TAB> if key_index < 0 or len ( key_names ) <= key_index : <TAB> <TAB> <TAB> <TAB> raise IndexError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""index {} is out of bounds for keys with size {}"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> key, len ( key_names ) <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> key_index = key_names. index ( key ) <TAB> <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> <TAB> raise KeyError ( ""{} does not exists"". format ( key ) ) <TAB> <TAB> key_indices. append ( key_index ) <TAB> return tuple ( key_indices )",True,key_index < 0,key_index < 0,0.6618554592132568
|
||
|
1118,"def merge_weekdays ( base_wd, icu_wd ) : <TAB> result = [ ] <TAB> for left, right in zip ( base_wd, icu_wd ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> result. append ( left ) <TAB> <TAB> <TAB> continue <TAB> <TAB> left = set ( left. split ( ""|"" ) ) <TAB> <TAB> right = set ( right. split ( ""|"" ) ) <TAB> <TAB> result. append ( ""|"". join ( left | right ) ) <TAB> return result",False,left == right,not right,0.6880174875259399
|
||
|
1119,"def _clean_regions ( items, region ) : <TAB> """"""Intersect region with target file if it exists"""""" <TAB> variant_regions = bedutils. population_variant_regions ( items, merged = True ) <TAB> with utils. tmpfile ( ) as tx_out_file : <TAB> <TAB> target = subset_variant_regions ( variant_regions, region, tx_out_file, items ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if isinstance ( target, six. string_types ) and os. path. isfile ( target ) : <TAB> <TAB> <TAB> <TAB> target = _load_regions ( target ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> target = [ target ] <TAB> <TAB> <TAB> return target",True,target,target,0.6975597739219666
|
||
|
1120,"def data_dir ( self ) -> Path : <TAB> try : <TAB> <TAB> from appdirs import user_data_dir <TAB> except ImportError : <TAB> <TAB> <TAB> <TAB> path = Path. home ( ) / "".local"" / ""share"" <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return path / ""dephell"" <TAB> <TAB> <TAB> <TAB> path = Path. home ( ) / ""Library"" / ""Application Support"" <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return path / ""dephell"" <TAB> <TAB> self. pip_main ( [ ""install"", ""appdirs"" ] ) <TAB> <TAB> from appdirs import user_data_dir <TAB> return Path ( user_data_dir ( ""dephell"" ) )",False,path.exists(),self.in_app_support(),0.6595215797424316
|
||
|
1121,"def _get_booster_best_score ( self, booster : ""lgb.Booster"" ) -> float : <TAB> metric = self. _get_metric_for_objective ( ) <TAB> valid_sets : Optional [ VALID_SET_TYPE ] = self. lgbm_kwargs. get ( ""valid_sets"" ) <TAB> if self. lgbm_kwargs. get ( ""valid_names"" ) is not None : <TAB> <TAB> if type ( self. lgbm_kwargs [ ""valid_names"" ] ) is str : <TAB> <TAB> <TAB> valid_name = self. lgbm_kwargs [ ""valid_names"" ] <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> valid_name = self. lgbm_kwargs [ ""valid_names"" ] [ - 1 ] <TAB> <TAB> else : <TAB> <TAB> <TAB> raise NotImplementedError <TAB> elif type ( valid_sets ) is lgb. Dataset : <TAB> <TAB> valid_name = ""valid_0"" <TAB> elif isinstance ( valid_sets, ( list, tuple ) ) and len ( valid_sets ) > 0 : <TAB> <TAB> valid_set_idx = len ( valid_sets ) - 1 <TAB> <TAB> valid_name = ""valid_{}"". format ( valid_set_idx ) <TAB> else : <TAB> <TAB> raise NotImplementedError <TAB> val_score = booster. best_score [ valid_name ] [ metric ] <TAB> return val_score",False,"type(self.lgbm_kwargs['valid_names']) in [list, tuple]",type(self.lgbm_kwargs['valid_names']) is str,0.6504154801368713
|
||
|
1122,"def get_changed_module ( self ) : <TAB> source = self. resource. read ( ) <TAB> change_collector = codeanalyze. ChangeCollector ( source ) <TAB> if self. replacement is not None : <TAB> <TAB> change_collector. add_change ( self. skip_start, self. skip_end, self. replacement ) <TAB> for occurrence in self. occurrence_finder. find_occurrences ( self. resource ) : <TAB> <TAB> start, end = occurrence. get_primary_range ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. handle. occurred_inside_skip ( change_collector, occurrence ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. handle. occurred_outside_skip ( change_collector, occurrence ) <TAB> result = change_collector. get_changed ( ) <TAB> if result is not None and result!= source : <TAB> <TAB> return result",False,self.skip_start <= start < self.skip_end,start == end,0.6526960134506226
|
||
|
1123,"def check_send_webhook_message ( <TAB> request : HttpRequest, <TAB> user_profile : UserProfile, <TAB> topic : str, <TAB> body : str, <TAB> stream : Optional [ str ] = REQ ( default = None ), <TAB> user_specified_topic : Optional [ str ] = REQ ( ""topic"", default = None ), <TAB> unquote_url_parameters : bool = False, ) -> None : <TAB> if stream is None : <TAB> <TAB> assert user_profile. bot_owner is not None <TAB> <TAB> check_send_private_message ( <TAB> <TAB> <TAB> user_profile, request. client, user_profile. bot_owner, body <TAB> <TAB> ) <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> stream = unquote ( stream ) <TAB> <TAB> if user_specified_topic is not None : <TAB> <TAB> <TAB> topic = user_specified_topic <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> topic = unquote ( topic ) <TAB> <TAB> try : <TAB> <TAB> <TAB> check_send_stream_message ( user_profile, request. client, stream, topic, body ) <TAB> <TAB> except StreamDoesNotExistError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> pass",False,unquote_url_parameters,topic is not None,0.6574562788009644
|
||
|
1124,"def log_metrics ( self, metrics : Dict [ str, float ], step : Optional [ int ] = None ) -> None : <TAB> assert rank_zero_only. rank == 0, ""experiment tried to log from global_rank!= 0"" <TAB> metrics = self. _add_prefix ( metrics ) <TAB> timestamp_ms = int ( time ( ) * 1000 ) <TAB> for k, v in metrics. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> log. warning ( f""Discarding metric with string value {k}={v}."" ) <TAB> <TAB> <TAB> continue <TAB> <TAB> new_k = re. sub ( ""[^a-zA-Z0-9_/. -]+"", """", k ) <TAB> <TAB> if k!= new_k : <TAB> <TAB> <TAB> rank_zero_warn ( <TAB> <TAB> <TAB> <TAB> ""MLFlow only allows '_', '/', '.' and'' special characters in metric name."" <TAB> <TAB> <TAB> <TAB> f"" Replacing {k} with {new_k}."", <TAB> <TAB> <TAB> <TAB> RuntimeWarning, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> k = new_k <TAB> <TAB> self. experiment. log_metric ( self. run_id, k, v, timestamp_ms, step )",False,"isinstance(v, str)",k == '',0.6483108401298523
|
||
|
1125,"def call_init ( self, node, instance ) : <TAB> <TAB> for b in instance. bindings : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> self. _initialized_instances. add ( b. data ) <TAB> <TAB> node = self. _call_init_on_binding ( node, b ) <TAB> return node",False,b.data in self._initialized_instances,not b.data,0.6558672189712524
|
||
|
1126,"def removeUser ( self, username ) : <TAB> hideFromOSD = not constants. SHOW_DIFFERENT_ROOM_OSD <TAB> if username in self. _users : <TAB> <TAB> user = self. _users [ username ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if self. isRoomSame ( user. room ) : <TAB> <TAB> <TAB> <TAB> hideFromOSD = not constants. SHOW_SAME_ROOM_OSD <TAB> if username in self. _users : <TAB> <TAB> self. _users. pop ( username ) <TAB> <TAB> message = getMessage ( ""left-notification"" ). format ( username ) <TAB> <TAB> self. ui. showMessage ( message, hideFromOSD ) <TAB> <TAB> self. _client. lastLeftTime = time. time ( ) <TAB> <TAB> self. _client. lastLeftUser = username <TAB> self. userListChange ( )",False,user.room,user.isOpen(),0.6622039079666138
|
||
|
1127,"def content ( self ) : <TAB> """"""Content of the response, in bytes."""""" <TAB> if self. _content is False : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise RuntimeError ( ""The content for this response was already consumed"" ) <TAB> <TAB> if self. status_code == 0 or self. raw is None : <TAB> <TAB> <TAB> self. _content = None <TAB> <TAB> else : <TAB> <TAB> <TAB> self. _content = ( <TAB> <TAB> <TAB> <TAB> bytes ( ). join ( self. iter_content ( CONTENT_CHUNK_SIZE ) ) or bytes ( ) <TAB> <TAB> <TAB> ) <TAB> self. _content_consumed = True <TAB> <TAB> <TAB> return self. _content",True,self._content_consumed,self._content_consumed,0.6681613922119141
|
||
|
1128,"def has_google_credentials ( ) : <TAB> global _HAS_GOOGLE_CREDENTIALS <TAB> if _HAS_GOOGLE_CREDENTIALS is None : <TAB> <TAB> provider = Provider ( ""google"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> _HAS_GOOGLE_CREDENTIALS = False <TAB> <TAB> else : <TAB> <TAB> <TAB> _HAS_GOOGLE_CREDENTIALS = True <TAB> return _HAS_GOOGLE_CREDENTIALS",False,provider.get_access_key() is None or provider.get_secret_key() is None,provider is None,0.6513177156448364
|
||
|
1129,"def get_order ( self, aBuf ) : <TAB> if not aBuf : <TAB> <TAB> return - 1, 1 <TAB> <TAB> first_char = wrap_ord ( aBuf [ 0 ] ) <TAB> if ( 0x81 <= first_char <= 0x9F ) or ( 0xE0 <= first_char <= 0xFC ) : <TAB> <TAB> charLen = 2 <TAB> else : <TAB> <TAB> charLen = 1 <TAB> <TAB> if len ( aBuf ) > 1 : <TAB> <TAB> second_char = wrap_ord ( aBuf [ 1 ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return second_char - 0x9F, charLen <TAB> return - 1, charLen",False,first_char == 202 and 159 <= second_char <= 241,129 <= second_char <= 159,0.6537764072418213
|
||
|
1130,"def _serialize ( self, value, attr, obj, ** kwargs ) : <TAB> if self. allow_none and value is None : <TAB> <TAB> return None <TAB> for type_, schema_ in self. desc. items ( ) : <TAB> <TAB> if _issubclass_safe ( type ( value ), type_ ) : <TAB> <TAB> <TAB> if is_dataclass ( value ) : <TAB> <TAB> <TAB> <TAB> res = schema_. _serialize ( value, attr, obj, ** kwargs ) <TAB> <TAB> <TAB> <TAB> res [ ""__type"" ] = str ( type_. __name__ ) <TAB> <TAB> <TAB> <TAB> return res <TAB> <TAB> <TAB> break <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> return schema_. _serialize ( value, attr, obj, ** kwargs ) <TAB> else : <TAB> <TAB> warnings. warn ( <TAB> <TAB> <TAB> f'The type ""{type(value).__name__}"" (value: ""{value}"")'<TAB> <TAB> <TAB> f""is not in the list of possible types of typing.Union "" <TAB> <TAB> <TAB> f""(dataclass: {self.cls.__name__}, field: {self.field.name}). "" <TAB> <TAB> <TAB> f""Value cannot be serialized properly."" <TAB> <TAB> ) <TAB> return super ( ). _serialize ( value, attr, obj, ** kwargs )",False,"isinstance(value, _get_type_origin(type_))","isinstance(value, list)",0.6508442163467407
|
||
|
1131,"def decode ( self, value, force = False ) : <TAB> ""Return a unicode string from the bytes-like representation"" <TAB> if self. decode_responses or force : <TAB> <TAB> if isinstance ( value, memoryview ) : <TAB> <TAB> <TAB> value = value. tobytes ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> value = value. decode ( self. encoding, self. encoding_errors ) <TAB> return value",False,"isinstance(value, bytes)",self.encoding and force,0.6479377746582031
|
||
|
1132,"def repack_pyz ( pyz, obfpath, cipher = None, clean = False ) : <TAB> code_dict = { } <TAB> obflist = [ ] <TAB> n = len ( obfpath ) + 1 <TAB> for dirpath, dirnames, filenames in os. walk ( obfpath ) : <TAB> <TAB> for pyfile in [ x for x in filenames if x. endswith ( "".py"" ) ] : <TAB> <TAB> <TAB> pyfile = os. path. join ( dirpath, pyfile ) <TAB> <TAB> <TAB> logger. info ( ""Compile %s"", pyfile ) <TAB> <TAB> <TAB> name = pyfile [ n : ]. replace ( ""\\"", ""."" ). replace ( ""/"", ""."" ) [ : - 3 ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> name = name [ : - len ( ""__init__.py"" ) ]. strip ( ""."" ) <TAB> <TAB> <TAB> with open ( pyfile, ""r"" ) as f : <TAB> <TAB> <TAB> <TAB> source = f. read ( ) <TAB> <TAB> <TAB> logger. debug ( ""Got obfuscated item: %s"", name ) <TAB> <TAB> <TAB> code_dict [ name ] = compile ( source, ""<%s>"" % name, ""exec"" ) <TAB> <TAB> <TAB> obflist. append ( name ) <TAB> logger. info ( ""Got %d obfuscated items"", len ( obflist ) ) <TAB> logger. info ( 'Patching PYZ file ""%s""', pyz ) <TAB> arch = ZlibArchive ( pyz ) <TAB> logic_toc = [ ] <TAB> for name in arch. toc : <TAB> <TAB> logger. debug ( ""Extract %s"", name ) <TAB> <TAB> typ, obj = arch. extract ( name ) <TAB> <TAB> if name in obflist : <TAB> <TAB> <TAB> logger. info ( 'Replace item ""%s"" with obfsucated one', name ) <TAB> <TAB> <TAB> obflist. remove ( name ) <TAB> <TAB>",False,name.endswith('__init__.py'),name.startswith(__init__),0.6528229713439941
|
||
|
1133,"def __new__ ( mcl, classname, bases, dictionary ) : <TAB> slots = list ( dictionary. get ( ""__slots__"", [ ] ) ) <TAB> for getter_name in [ key for key in dictionary if key. startswith ( ""get_"" ) ] : <TAB> <TAB> name = getter_name <TAB> <TAB> slots. append ( ""__"" + name ) <TAB> <TAB> getter = dictionary. pop ( getter_name ) <TAB> <TAB> setter = dictionary. get ( setter_name, None ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> del dictionary [ setter_name ] <TAB> <TAB> dictionary [ name ] = property ( getter. setter ) <TAB> <TAB> dictionary [ ""__slots__"" ] = tuple ( slots ) <TAB> <TAB> return super ( ). __new__ ( mcl, classname, bases, dictionary )",False,"setter is not None and isinstance(setter, collections.Callable)",setter is not None,0.6497122049331665
|
||
|
1134,"def transform ( a, cmds ) : <TAB> buf = a. split ( ""\n"" ) <TAB> for cmd in cmds : <TAB> <TAB> ctype, line, col, char = cmd <TAB> <TAB> if ctype == ""D"" : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> buf [ line ] = buf [ line ] [ : col ] + buf [ line ] [ col + len ( char ) : ] <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> buf [ line ] = buf [ line ] + buf [ line + 1 ] <TAB> <TAB> <TAB> <TAB> del buf [ line + 1 ] <TAB> <TAB> elif ctype == ""I"" : <TAB> <TAB> <TAB> buf [ line ] = buf [ line ] [ : col ] + char + buf [ line ] [ col : ] <TAB> <TAB> buf = ""\n"". join ( buf ). split ( ""\n"" ) <TAB> return ""\n"". join ( buf )",False,char != '\n',char,0.667432427406311
|
||
|
1135,"def value ( self ) : <TAB> quote = False <TAB> if self. defects : <TAB> <TAB> quote = True <TAB> else : <TAB> <TAB> for x in self : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> quote = True <TAB> if quote : <TAB> <TAB> pre = post = """" <TAB> <TAB> if self [ 0 ]. token_type == ""cfws"" or self [ 0 ] [ 0 ]. token_type == ""cfws"" : <TAB> <TAB> <TAB> pre = "" "" <TAB> <TAB> if self [ - 1 ]. token_type == ""cfws"" or self [ - 1 ] [ - 1 ]. token_type == ""cfws"" : <TAB> <TAB> <TAB> post = "" "" <TAB> <TAB> return pre + quote_string ( self. display_name ) + post <TAB> else : <TAB> <TAB> return super ( DisplayName, self ). value",False,x.token_type == 'quoted-string',x.defect_code == 0,0.6491146087646484
|
||
|
1136,"def dnp3 ( data, control_code = b""\x44"", src = b""\x00\x00"", dst = b""\x00\x00"" ) : <TAB> num_packets = int ( math. ceil ( float ( len ( data ) ) / 250.0 ) ) <TAB> packets = [ ] <TAB> for i in xrange ( num_packets ) : <TAB> <TAB> packet_slice = data [ i * 250 : ( i + 1 ) * 250 ] <TAB> <TAB> p = b""\x05\x64"" <TAB> <TAB> p += six. int2byte ( len ( packet_slice ) ) <TAB> <TAB> p += control_code <TAB> <TAB> p += dst <TAB> <TAB> p += src <TAB> <TAB> chksum = struct. pack ( ""<H"", crc16 ( p ) ) <TAB> <TAB> p += chksum <TAB> <TAB> num_chunks = int ( math. ceil ( float ( len ( packet_slice ) / 16.0 ) ) ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> frag_number = i <TAB> <TAB> if i == 0 : <TAB> <TAB> <TAB> frag_number |= 0x40 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> frag_number |= 0x80 <TAB> <TAB> p += six. int2byte ( frag_number ) <TAB> <TAB> for x in xrange ( num_chunks ) : <TAB> <TAB> <TAB> chunk = packet_slice [ i * 16 : ( i + 1 ) * 16 ] <TAB> <TAB> <TAB> chksum = struct. pack ( ""<H"", crc16 ( chunk ) ) <TAB> <TAB> <TAB> p += chksum + chunk <TAB> <TAB> packets. append ( p ) <TAB> return packets",False,i == num_packets - 1,i == 1,0.662838339805603
|
||
|
1137,"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 fid == 1 : <TAB> <TAB> <TAB> if ftype == TType. LIST : <TAB> <TAB> <TAB> <TAB> self. values = [ ] <TAB> <TAB> <TAB> <TAB> ( _etype100, _size97 ) = iprot. readListBegin ( ) <TAB> <TAB> <TAB> <TAB> for _i101 in range ( _size97 ) : <TAB> <TAB> <TAB> <TAB> <TAB> _elem102 = iprot. readBinary ( ) <TAB> <TAB> <TAB> <TAB> <TAB> self. values. append ( _elem102 ) <TAB> <TAB> <TAB> <TAB> iprot. readListEnd ( ) <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. nulls = iprot. readBinary ( ) <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,nulls is not None,0.6609013080596924
|
||
|
1138,"def _get_diff ( self ) : <TAB> """"""Get a diff between running config and a proposed file."""""" <TAB> diff = [ ] <TAB> self. _create_sot_file ( ) <TAB> diff_out = self. _send_command ( <TAB> <TAB> ""show diff rollback-patch file {} file {}"". format ( <TAB> <TAB> <TAB> ""sot_file"", self. candidate_cfg <TAB> <TAB> ), <TAB> <TAB> raw_text = True, <TAB> ) <TAB> try : <TAB> <TAB> diff_out = ( <TAB> <TAB> <TAB> diff_out. split ( ""Generating Rollback Patch"" ) [ 1 ] <TAB> <TAB> <TAB>. replace ( ""Rollback Patch is Empty"", """" ) <TAB> <TAB> <TAB>. strip ( ) <TAB> <TAB> ) <TAB> <TAB> for line in diff_out. splitlines ( ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> if line [ 0 ]. strip ( )!= ""!"" and line [ 0 ]. strip ( )!= ""."" : <TAB> <TAB> <TAB> <TAB> <TAB> diff. append ( line. rstrip ( "" "" ) ) <TAB> except ( AttributeError, KeyError ) : <TAB> <TAB> raise ReplaceConfigException ( <TAB> <TAB> <TAB> ""Could not calculate diff. It's possible the given file doesn't exist."" <TAB> <TAB> ) <TAB> return ""\n"". join ( diff )",True,line,line,0.6805548071861267
|
||
|
1139,"def _get_turns ( data, with_indices = False ) : <TAB> utterances, responses, dialog_indices = [ ], [ ], [ ] <TAB> for dialog, scenario in data : <TAB> <TAB> for i, turn in enumerate ( dialog ) : <TAB> <TAB> <TAB> replica = turn [ ""data"" ] <TAB> <TAB> <TAB> if i == 0 : <TAB> <TAB> <TAB> <TAB> replica [ ""episode_done"" ] = True <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> replica [ ""task"" ] = scenario [ ""task"" ] <TAB> <TAB> <TAB> <TAB> replica [ ""dialog_id"" ] = scenario [ ""uuid"" ] <TAB> <TAB> <TAB> <TAB> replica [ ""kb_columns"" ] = scenario [ ""kb"" ] [ ""column_names"" ] <TAB> <TAB> <TAB> <TAB> replica [ ""kb_items"" ] = scenario [ ""kb"" ] [ ""items"" ] <TAB> <TAB> <TAB> <TAB> utterances. append ( replica ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> responses. append ( replica ) <TAB> <TAB> <TAB> <TAB> if len ( responses )!= len ( utterances ) : <TAB> <TAB> <TAB> utterances [ - 1 ] [ ""end_dialogue"" ] = False <TAB> <TAB> <TAB> responses. append ( { ""utterance"" : """", ""end_dialogue"" : True } ) <TAB> <TAB> last_utter = responses [ - 1 ] [ ""utterance"" ] <TAB> <TAB> if last_utter and not last_utter [ - 1 ]. isspace ( ) : <TAB> <TAB> <TAB> last_utter += "" "" <TAB> <TAB> responses [ - 1 ] [ ""utterance"" ] = last_utter + ""END_OF_DIALOGUE"" <TAB> <TAB> dialog_indices. append ( <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> ""start"" : len ( utterances ), <",False,turn['turn'] == 'driver',with_indices,0.654859185218811
|
||
|
1140,"def retry ( cls, func, retry = 0, retryTime = 30 ) : <TAB> if retry == 0 : <TAB> <TAB> retry = 9999 <TAB> if retryTime == 0 : <TAB> <TAB> retryTime = 9999 <TAB> startTime = time. time ( ) <TAB> retryCount = 0 <TAB> sleepSeconds = 2 <TAB> while retryCount >= retry : <TAB> <TAB> result = func ( ) <TAB> <TAB> if result : <TAB> <TAB> <TAB> return True <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return False <TAB> <TAB> eventlet. sleep ( sleepSeconds ) <TAB> <TAB> sleepSeconds = sleepSeconds + 2 <TAB> <TAB> retryCount = retryCount + 1 <TAB> return False",False,time.time() - startTime <= retryTime,eventlet.isOpen(),0.6601369976997375
|
||
|
1141,"def LoadBuildFileIncludesIntoDict ( <TAB> subdict, subdict_path, data, aux_data, variables, includes, check ) : <TAB> includes_list = [ ] <TAB> if includes!= None : <TAB> <TAB> includes_list. extend ( includes ) <TAB> if ""includes"" in subdict : <TAB> <TAB> for include in subdict [ ""includes"" ] : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> relative_include = os. path. normpath ( <TAB> <TAB> <TAB> <TAB> os. path. join ( os. path. dirname ( subdict_path ), include ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> includes_list. append ( relative_include ) <TAB> <TAB> <TAB> <TAB> del subdict [ ""includes"" ] <TAB> <TAB> for include in includes_list : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> aux_data [ subdict_path ] [ ""included"" ] = [ ] <TAB> <TAB> aux_data [ subdict_path ] [ ""included"" ]. append ( include ) <TAB> <TAB> gyp. DebugOutput ( gyp. DEBUG_INCLUDES, ""Loading Included File: '%s'"", include ) <TAB> <TAB> MergeDicts ( <TAB> <TAB> <TAB> subdict, <TAB> <TAB> <TAB> LoadOneBuildFile ( include, data, aux_data, variables, None, False, check ), <TAB> <TAB> <TAB> subdict_path, <TAB> <TAB> <TAB> include, <TAB> <TAB> ) <TAB> <TAB> for k, v in subdict. iteritems ( ) : <TAB> <TAB> if v. __class__ == dict : <TAB> <TAB> <TAB> LoadBuildFileIncludesIntoDict ( <TAB> <TAB> <TAB> <TAB> v, subdict_path, data, aux_data, variables, None, check <TAB> <TAB> <TAB> ) <TAB> <TAB> elif v. __class__ ==",False,not 'included' in aux_data[subdict_path],subdict_path in subdict,0.6511030197143555
|
||
|
1142,"def build ( self, predictions, targets, inputs = None ) : <TAB> """"""Prints the number of each kind of prediction"""""" <TAB> self. built = True <TAB> pshape = predictions. get_shape ( ) <TAB> self. inner_metric. build ( predictions, targets, inputs ) <TAB> with tf. name_scope ( self. name ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. name = self. name or ""binary_prediction_counts"" <TAB> <TAB> <TAB> y, idx, count = tf. unique_with_counts ( tf. argmax ( predictions ) ) <TAB> <TAB> <TAB> self. tensor = tf. Print ( <TAB> <TAB> <TAB> <TAB> self. inner_metric, [ y, count ], name = self. inner_metric. name <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. name = self. name or ""categorical_prediction_counts"" <TAB> <TAB> <TAB> y, idx, count = tf. unique_with_counts ( tf. argmax ( predictions, dimension = 1 ) ) <TAB> <TAB> <TAB> self. tensor = tf. Print ( <TAB> <TAB> <TAB> <TAB> self. inner_metric. tensor, [ y, count ], name = self. inner_metric. name <TAB> <TAB> <TAB> )",False,len(pshape) == 1 or (len(pshape) == 2 and int(pshape[1]) == 1),self.built,0.6511821746826172
|
||
|
1143,"def get_input ( prompt : str, answers : Iterable [ str ] = ( ), require_confirm = False ) -> str : <TAB> with PrintLock ( ) : <TAB> <TAB> if not ( require_confirm or PikaurConfig ( ). ui. RequireEnterConfirm. get_bool ( ) ) : <TAB> <TAB> <TAB> answer = read_answer_from_tty ( prompt, answers = answers ) <TAB> <TAB> else : <TAB> <TAB> <TAB> sub_tty = TTYRestore ( ) <TAB> <TAB> <TAB> TTYRestore. restore ( ) <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> answer = input ( split_last_line ( prompt ) ). lower ( ) <TAB> <TAB> <TAB> except EOFError : <TAB> <TAB> <TAB> <TAB> raise SysExit ( 125 ) <TAB> <TAB> <TAB> finally : <TAB> <TAB> <TAB> <TAB> sub_tty. restore_new ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> for choice in answers : <TAB> <TAB> <TAB> <TAB> <TAB> if choice. isupper ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return choice. lower ( ) <TAB> <TAB> return answer",False,not answer,len(answers) > 0,0.6813108921051025
|
||
|
1144,"def test_timestamp_extract ( backend, alltypes, df, attr ) : <TAB> if attr == ""millisecond"" : <TAB> <TAB> if backend. name == ""sqlite"" : <TAB> <TAB> <TAB> pytest. xfail ( reason = ( ""Issue #2156"" ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> pytest. xfail ( reason = ""Issue #2159"" ) <TAB> <TAB> expected = ( df. timestamp_col. dt. microsecond // 1000 ). astype ( ""int32"" ) <TAB> elif attr == ""epoch_seconds"" : <TAB> <TAB> expected = df. timestamp_col. astype ( ""int64"" ) // int ( 1e9 ) <TAB> else : <TAB> <TAB> expected = getattr ( df. timestamp_col. dt, attr. replace ( ""_"", """" ) ). astype ( ""int32"" ) <TAB> expr = getattr ( alltypes. timestamp_col, attr ) ( ) <TAB> result = expr. execute ( ) <TAB> if attr == ""epoch_seconds"" and backend. name in [ <TAB> <TAB> ""bigquery"", <TAB> <TAB> ""postgres"", <TAB> <TAB> ""spark"", <TAB> ] : <TAB> <TAB> <TAB> <TAB> result = result. astype ( ""int64"" ) <TAB> expected = backend. default_series_rename ( expected ) <TAB> backend. assert_series_equal ( result, expected )",False,backend.name == 'spark',backend.name == 'int32',0.6578556299209595
|
||
|
1145,"def fill ( self ) : <TAB> try : <TAB> <TAB> while ( <TAB> <TAB> <TAB> not self. stopping. wait ( self. sample_wait ) <TAB> <TAB> <TAB> and len ( self. queue ) < self. queue. maxlen <TAB> <TAB> ) : <TAB> <TAB> <TAB> self. queue. append ( self. parent. _read ( ) ) <TAB> <TAB> <TAB> if self. partial and isinstance ( self. parent, EventsMixin ) : <TAB> <TAB> <TAB> <TAB> self. parent. _fire_events ( ) <TAB> <TAB> self. full. set ( ) <TAB> <TAB> while not self. stopping. wait ( self. sample_wait ) : <TAB> <TAB> <TAB> self. queue. append ( self. parent. _read ( ) ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. parent. _fire_events ( ) <TAB> except ReferenceError : <TAB> <TAB> <TAB> <TAB> pass",False,"isinstance(self.parent, EventsMixin)","self.parent and isinstance(self.parent, EventsMixin)",0.6638846397399902
|
||
|
1146,"def get_queryset ( self ) : <TAB> request = self. request <TAB> user = request. user <TAB> flag = request. GET. get ( ""flag"", """" ) <TAB> image_id = request. GET. get ( ""image_id"", """" ) <TAB> if flag == ""list"" and user. is_superuser : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> container_vul_list = ContainerVul. objects. filter ( <TAB> <TAB> <TAB> <TAB> image_id = image_id <TAB> <TAB> <TAB> ). order_by ( ""-create_date"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> container_vul_list = ContainerVul. objects. all ( ). order_by ( ""-create_date"" ) <TAB> else : <TAB> <TAB> container_vul_list = ContainerVul. objects. filter ( <TAB> <TAB> <TAB> user_id = self. request. user. id, time_model_id = """" <TAB> <TAB> ) <TAB> return container_vul_list",True,image_id,image_id,0.6683754920959473
|
||
|
1147,"def match_in_kwargs ( self, match_args, kwargs ) : <TAB> """"""Matches against kwargs."""""" <TAB> for match, default in match_args : <TAB> <TAB> names = get_match_names ( match ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> tempvar = self. get_temp_var ( ) <TAB> <TAB> <TAB> self. add_def ( <TAB> <TAB> <TAB> <TAB> tempvar <TAB> <TAB> <TAB> <TAB> + "" = "" <TAB> <TAB> <TAB> <TAB> + """". join ( <TAB> <TAB> <TAB> <TAB> <TAB> kwargs <TAB> <TAB> <TAB> <TAB> <TAB> + '.pop(""' <TAB> <TAB> <TAB> <TAB> <TAB> + name <TAB> <TAB> <TAB> <TAB> <TAB> + '"") if ""' <TAB> <TAB> <TAB> <TAB> <TAB> + name <TAB> <TAB> <TAB> <TAB> <TAB> + '"" in'<TAB> <TAB> <TAB> <TAB> <TAB> + kwargs <TAB> <TAB> <TAB> <TAB> <TAB> + "" else "" <TAB> <TAB> <TAB> <TAB> <TAB> for name in names <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> + default, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> with self. down_a_level ( ) : <TAB> <TAB> <TAB> <TAB> self. match ( match, tempvar ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise CoconutDeferredSyntaxError ( <TAB> <TAB> <TAB> <TAB> ""keyword-only pattern-matching function arguments must have names"", <TAB> <TAB> <TAB> <TAB> self. loc, <TAB> <TAB> <TAB> )",True,names,names,0.6848276853561401
|
||
|
1148,"def _init_sock ( self ) : <TAB> if self. unix_socket : <TAB> <TAB> <TAB> <TAB> _sock = socket. socket ( socket. AF_UNIX, socket. SOCK_STREAM ) <TAB> <TAB> try : <TAB> <TAB> <TAB> _sock. connect ( self. unix_socket ) <TAB> <TAB> except ( socket. error, OSError ) as err : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> os. unlink ( self. unix_socket ) <TAB> else : <TAB> <TAB> _sock = socket. socket ( self. socket_family, socket. SOCK_STREAM ) <TAB> _sock. setsockopt ( socket. SOL_SOCKET, socket. SO_REUSEADDR, 1 ) <TAB> if hasattr ( socket, ""SO_REUSEPORT"" ) : <TAB> <TAB> _sock. setsockopt ( socket. SOL_SOCKET, socket. SO_REUSEPORT, 1 ) <TAB> _sock. settimeout ( None ) <TAB> self. sock = _sock",False,err.args[0] == errno.ECONNREFUSED,"err.args[0] in [ECONN, ECONN, ECONN, ESHUTDOWN]",0.6516908407211304
|
||
|
1149,"def combine_cd ( combine ) : <TAB> new_files = [ ] <TAB> for item in { re. match ( ""(.+)[cC][dD][0-9]."", item ). groups ( ) [ 0 ] for item in combine } : <TAB> <TAB> concat = """" <TAB> <TAB> for n in range ( 99 ) : <TAB> <TAB> <TAB> files = [ <TAB> <TAB> <TAB> <TAB> file <TAB> <TAB> <TAB> <TAB> for file in combine <TAB> <TAB> <TAB> <TAB> if n + 1 == int ( re. match ( "".+[cC][dD]([0-9]+)."", file ). groups ( ) [ 0 ] ) <TAB> <TAB> <TAB> <TAB> and item in file <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> if files : <TAB> <TAB> <TAB> <TAB> concat += ""{file}|"". format ( file = files [ 0 ] ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> new_files. append ( ""concat:{0}"". format ( concat [ : - 1 ] ) ) <TAB> return new_files",True,concat,concat,0.7049475908279419
|
||
|
1150,"def transform_kwarg ( self, name, value, split_single_char_options ) : <TAB> if len ( name ) == 1 : <TAB> <TAB> if value is True : <TAB> <TAB> <TAB> return [ ""-%s"" % name ] <TAB> <TAB> elif value not in ( False, None ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return [ ""-%s"" % name, ""%s"" % value ] <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> return [ ""-%s%s"" % ( name, value ) ] <TAB> else : <TAB> <TAB> if value is True : <TAB> <TAB> <TAB> return [ ""--%s"" % dashify ( name ) ] <TAB> <TAB> elif value is not False and value is not None : <TAB> <TAB> <TAB> return [ ""--%s=%s"" % ( dashify ( name ), value ) ] <TAB> return [ ]",True,split_single_char_options,split_single_char_options,0.6503164172172546
|
||
|
1151,"def _codegen_impl ( self, state : CodegenState, default_semicolon : bool = False ) -> None : <TAB> with state. record_syntactic_position ( self ) : <TAB> <TAB> state. add_token ( ""return"" ) <TAB> <TAB> whitespace_after_return = self. whitespace_after_return <TAB> <TAB> value = self. value <TAB> <TAB> if isinstance ( whitespace_after_return, MaybeSentinel ) : <TAB> <TAB> <TAB> if value is not None : <TAB> <TAB> <TAB> <TAB> state. add_token ( "" "" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> whitespace_after_return. _codegen ( state ) <TAB> <TAB> if value is not None : <TAB> <TAB> <TAB> value. _codegen ( state ) <TAB> semicolon = self. semicolon <TAB> if isinstance ( semicolon, MaybeSentinel ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> state. add_token ( ""; "" ) <TAB> elif isinstance ( semicolon, Semicolon ) : <TAB> <TAB> semicolon. _codegen ( state )",True,default_semicolon,default_semicolon,0.6673389673233032
|
||
|
1152,"def is_valid ( sample ) : <TAB> if sample is None : <TAB> <TAB> return False <TAB> if isinstance ( sample, tuple ) : <TAB> <TAB> for s in sample : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return False <TAB> <TAB> <TAB> elif isinstance ( s, np. ndarray ) and s. size == 0 : <TAB> <TAB> <TAB> <TAB> return False <TAB> <TAB> <TAB> elif isinstance ( s, collections. abc. Sequence ) and len ( s ) == 0 : <TAB> <TAB> <TAB> <TAB> return False <TAB> return True",True,s is None,s is None,0.6731966137886047
|
||
|
1153,"def _get_image ( self, msg ) : <TAB> """"""get image content and type from a message"""""" <TAB> if msg. type == TYPE_IMG : <TAB> <TAB> <TAB> <TAB> imgpath = msg. imgPath. split ( ""_"" ) [ - 1 ] <TAB> <TAB> if not imgpath : <TAB> <TAB> <TAB> logger. warn ( <TAB> <TAB> <TAB> <TAB> ""No imgpath in an image message. Perhaps a bug in wechat: {}"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> msg <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> return """", """" <TAB> <TAB> bigimgpath = self. parser. imginfo. get ( msg. msgSvrId ) <TAB> <TAB> img = self. res. get_img ( [ imgpath, bigimgpath ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> logger. warn ( ""No image found for {}"". format ( imgpath ) ) <TAB> <TAB> return img, ""jpeg"" <TAB> elif msg. type == TYPE_EMOJI : <TAB> <TAB> md5 = msg. imgPath <TAB> <TAB> emoji_img, format = self. res. get_emoji_by_md5 ( md5 ) <TAB> <TAB> return emoji_img, format <TAB> elif msg. type == TYPE_CUSTOM_EMOJI : <TAB> <TAB> pq = PyQuery ( msg. content ) <TAB> <TAB> md5 = pq ( ""emoticonmd5"" ). text ( ) <TAB> <TAB> img, format = self. res. get_emoji ( md5, None ) <TAB> <TAB> return img, format <TAB> else : <TAB> <TAB> return """", """"",True,not img,not img,0.6827529072761536
|
||
|
1154,"def get_default_shell_info ( shell_name = None, settings = None ) : <TAB> if not shell_name : <TAB> <TAB> settings = settings or load_settings ( lazy = True ) <TAB> <TAB> shell_name = settings. get ( ""shell"" ) <TAB> <TAB> if shell_name : <TAB> <TAB> <TAB> return shell_name, None <TAB> <TAB> shell_path = os. environ. get ( ""SHELL"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> shell_name = basepath ( shell_path ) <TAB> <TAB> else : <TAB> <TAB> <TAB> shell_name = DEFAULT_SHELL <TAB> <TAB> return shell_name, shell_path <TAB> return shell_name, None",True,shell_path,shell_path,0.66959547996521
|
||
|
1155,"def send_input ( capture, key_events ) : <TAB> for evt in key_events. strip ( ). split ( ) : <TAB> <TAB> if evt. startswith ( ""+"" ) : <TAB> <TAB> <TAB> capture. key_down ( evt [ 1 : ] ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> capture. key_up ( evt [ 1 : ] ) <TAB> <TAB> else : <TAB> <TAB> <TAB> capture. key_down ( evt ) <TAB> <TAB> <TAB> capture. key_up ( evt )",True,evt.startswith('-'),evt.startswith('-'),0.6526145935058594
|
||
|
1156,"def check ( self, hyperlinks : Dict [ str, Hyperlink ] ) -> Generator [ CheckResult, None, None ] : <TAB> self. invoke_threads ( ) <TAB> total_links = 0 <TAB> for hyperlink in hyperlinks. values ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> yield CheckResult ( <TAB> <TAB> <TAB> <TAB> hyperlink. uri, hyperlink. docname, hyperlink. lineno, ""ignored"", """", 0 <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. wqueue. put ( CheckRequest ( CHECK_IMMEDIATELY, hyperlink ), False ) <TAB> <TAB> <TAB> total_links += 1 <TAB> done = 0 <TAB> while done < total_links : <TAB> <TAB> yield self. rqueue. get ( ) <TAB> <TAB> done += 1 <TAB> self. shutdown_threads ( )",False,self.is_ignored_uri(hyperlink.uri),self.wqueue.get() is False,0.6547796726226807
|
||
|
1157,"def from_dict ( name, raw_value ) : <TAB> selectors = { } <TAB> labels = { } <TAB> text = { } <TAB> sub_components = { } <TAB> for key, value in raw_value. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> base_selector = None <TAB> <TAB> <TAB> if ""_"" in value : <TAB> <TAB> <TAB> <TAB> base_selector = value [ ""_"" ] <TAB> <TAB> <TAB> <TAB> del value [ ""_"" ] <TAB> <TAB> <TAB> for selector_key, selector_value in value. items ( ) : <TAB> <TAB> <TAB> <TAB> selectors [ selector_key ] = SelectorTemplate. from_dict ( selector_value ) <TAB> <TAB> <TAB> if base_selector : <TAB> <TAB> <TAB> <TAB> selectors [ ""_"" ] = SelectorTemplate. from_dict ( <TAB> <TAB> <TAB> <TAB> <TAB> base_selector, children = selectors <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> elif key == ""labels"" : <TAB> <TAB> <TAB> for label_key, label_value in value. items ( ) : <TAB> <TAB> <TAB> <TAB> labels [ label_key ] = Label ( label_value ) <TAB> <TAB> elif key == ""text"" : <TAB> <TAB> <TAB> for text_key, text_value in value. items ( ) : <TAB> <TAB> <TAB> <TAB> text [ text_key ] = Text ( text_value ) <TAB> <TAB> else : <TAB> <TAB> <TAB> component = Component. from_dict ( key, value ) <TAB> <TAB> <TAB> sub_components [ key ] = component <TAB> return Component ( name, sub_components, selectors, labels, text )",False,key == 'selectors',key == 'selector',0.6741434335708618
|
||
|
1158,"def write ( self, * data ) : <TAB> if ( len ( data ) == 1 ) and data [ 0 ] == self. indent : <TAB> <TAB> diff = max ( <TAB> <TAB> <TAB> self. pending_newlines, self. desired_line_number - self. current_line_number <TAB> <TAB> ) <TAB> <TAB> self. f. write ( ""\n"" * diff ) <TAB> <TAB> self. current_line_number += diff <TAB> <TAB> self. pending_newlines = 0 <TAB> if ( len ( data ) == 0 ) or ( len ( data ) == 1 and data [ 0 ] == """" ) : <TAB> <TAB> return <TAB> out = """". join ( ( str ( j ) for j in data ) ) <TAB> n = 0 <TAB> for i in out : <TAB> <TAB> if i == ""\n"" : <TAB> <TAB> <TAB> n += 1 <TAB> <TAB> <TAB> if n == len ( out ) : <TAB> <TAB> <TAB> <TAB> self. pending_newlines = max ( self. pending_newlines, n ) <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> self. pending_newlines = max ( self. pending_newlines, n ) <TAB> <TAB> <TAB> out = out [ n : ] <TAB> <TAB> <TAB> break <TAB> <TAB> else : <TAB> <TAB> <TAB> break <TAB> if self. pending_newlines > 0 : <TAB> <TAB> diff = max ( <TAB> <TAB> <TAB> self. pending_newlines, self. desired_line_number - self. current_line_number <TAB> <TAB> ) <TAB> <TAB> self. f. write ( ""\n"" * diff ) <TAB> <TAB> self. current_line_number += diff <TAB> <TAB> self. pending_newlines = 0 <TAB> for i in out [ : : - 1 ] : <TAB> <TAB> if i == ""\n"" : <TAB> <TAB> <TAB> self. pending_newlines += 1 <TAB> <TAB> else",False,n,n == len(out),0.6866810321807861
|
||
|
1159,"def encode ( self, input, errors = ""strict"" ) : <TAB> if errors!= ""strict"" : <TAB> <TAB> <TAB> <TAB> raise UnicodeError ( ""unsupported error handling "" + errors ) <TAB> if not input : <TAB> <TAB> return b"""", 0 <TAB> try : <TAB> <TAB> result = input. encode ( ""ascii"" ) <TAB> except UnicodeEncodeError : <TAB> <TAB> pass <TAB> else : <TAB> <TAB> <TAB> <TAB> labels = result. split ( b""."" ) <TAB> <TAB> for label in labels [ : - 1 ] : <TAB> <TAB> <TAB> if not ( 0 < len ( label ) < 64 ) : <TAB> <TAB> <TAB> <TAB> raise UnicodeError ( ""label empty or too long"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise UnicodeError ( ""label too long"" ) <TAB> <TAB> return result, len ( input ) <TAB> result = bytearray ( ) <TAB> labels = dots. split ( input ) <TAB> if labels and not labels [ - 1 ] : <TAB> <TAB> trailing_dot = b""."" <TAB> <TAB> del labels [ - 1 ] <TAB> else : <TAB> <TAB> trailing_dot = b"""" <TAB> for label in labels : <TAB> <TAB> if result : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> result. extend ( b""."" ) <TAB> <TAB> result. extend ( ToASCII ( label ) ) <TAB> return bytes ( result + trailing_dot ), len ( input )",False,len(labels[-1]) >= 64,len(label) > 32,0.65909343957901
|
||
|
1160,"def _select_from ( self, parent_path, is_dir, exists, scandir ) : <TAB> try : <TAB> <TAB> with scandir ( parent_path ) as scandir_it : <TAB> <TAB> <TAB> entries = list ( scandir_it ) <TAB> <TAB> for entry in entries : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if not entry. is_dir ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> except OSError as e : <TAB> <TAB> <TAB> <TAB> <TAB> if not _ignore_error ( e ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> raise <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> name = entry. name <TAB> <TAB> <TAB> if self. match ( name ) : <TAB> <TAB> <TAB> <TAB> path = parent_path. _make_child_relpath ( name ) <TAB> <TAB> <TAB> <TAB> for p in self. successor. _select_from ( path, is_dir, exists, scandir ) : <TAB> <TAB> <TAB> <TAB> <TAB> yield p <TAB> except PermissionError : <TAB> <TAB> return",False,self.dironly,"hasattr(entry, 'name')",0.658218502998352
|
||
|
1161,"def sentencebreaks_to_newlines ( text ) : <TAB> offsets = [ o for o in en_sentence_boundary_gen ( text ) ] <TAB> <TAB> sentences = [ s for s in _text_by_offsets_gen ( text, offsets ) ] <TAB> <TAB> orig_parts = [ ] <TAB> new_parts = [ ] <TAB> sentnum = len ( sentences ) <TAB> for i in range ( sentnum ) : <TAB> <TAB> sent = sentences [ i ] <TAB> <TAB> orig_parts. append ( sent ) <TAB> <TAB> new_parts. append ( sent ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> orig_parts. append ( text [ offsets [ i ] [ 1 ] : offsets [ i + 1 ] [ 0 ] ] ) <TAB> <TAB> <TAB> if offsets [ i ] [ 1 ] < offsets [ i + 1 ] [ 0 ] and text [ offsets [ i ] [ 1 ] ]. isspace ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> new_parts. append ( ""\n"" + text [ offsets [ i ] [ 1 ] + 1 : offsets [ i + 1 ] [ 0 ] ] ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> new_parts. append ( text [ offsets [ i ] [ 1 ] : offsets [ i + 1 ] [ 0 ] ] ) <TAB> if len ( offsets ) and offsets [ - 1 ] [ 1 ] < len ( text ) : <TAB> <TAB> orig_parts. append ( text [ offsets [ - 1 ] [ 1 ] : ] ) <TAB> <TAB> new_parts. append ( text [ offsets [ - 1 ] [ 1 ] : ] ) <TAB> <TAB> assert text == """". join ( orig_parts ), ""INTERNAL ERROR:\n '%s'\nvs\n '%s'"" % ( <TAB> <TAB> text, <TAB> <TAB> """". join ( orig_parts ), <TAB> ) <TAB> splittext = """". join ( new_parts ) <TAB> <TAB> assert len ( text ) == len ( splittext ), ""INTERNAL ERROR",False,i < sentnum - 1,len(offsets) > 0,0.666646420955658
|
||
|
1162,"def __init__ ( self, data, weights = None, ddof = 0 ) : <TAB> self. data = np. asarray ( data ) <TAB> if weights is None : <TAB> <TAB> self. weights = np. ones ( self. data. shape [ 0 ] ) <TAB> else : <TAB> <TAB> self. weights = np. asarray ( weights ). astype ( float ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. weights = self. weights. squeeze ( ) <TAB> self. ddof = ddof",False,len(self.weights.shape) > 1 and len(self.weights) > 1,self.weights is not None,0.6528981328010559
|
||
|
1163,"def __init__ ( self, ** params ) : <TAB> if self. _css and self. _css not in config. css_files : <TAB> <TAB> config. css_files. append ( self. _css ) <TAB> template = self. _template. read_text ( ) <TAB> if ""header"" not in params : <TAB> <TAB> params [ ""header"" ] = ListLike ( ) <TAB> if ""main"" not in params : <TAB> <TAB> params [ ""main"" ] = ListLike ( ) <TAB> if ""sidebar"" not in params : <TAB> <TAB> params [ ""sidebar"" ] = ListLike ( ) <TAB> super ( BasicTemplate, self ). __init__ ( template = template, ** params ) <TAB> if self. theme : <TAB> <TAB> theme = self. theme. find_theme ( type ( self ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> config. css_files. append ( theme. css ) <TAB> self. _update_vars ( ) <TAB> self. main. param. watch ( self. _update_render_items, [ ""objects"" ] ) <TAB> self. sidebar. param. watch ( self. _update_render_items, [ ""objects"" ] ) <TAB> self. header. param. watch ( self. _update_render_items, [ ""objects"" ] ) <TAB> self. param. watch ( self. _update_vars, [ ""title"", ""header_background"", ""header_color"" ] )",False,theme and theme.css and (theme.css not in config.css_files),theme and theme.css,0.651672899723053
|
||
|
1164,"def getPrivileges ( body, privs, action ) : <TAB> all_privileges = gapi_directory_privileges. print_ ( return_only = True ) <TAB> if privs == ""ALL"" : <TAB> <TAB> body [ ""rolePrivileges"" ] = [ <TAB> <TAB> <TAB> { ""privilegeName"" : p [ ""privilegeName"" ], ""serviceId"" : p [ ""serviceId"" ] } <TAB> <TAB> <TAB> for p in all_privileges <TAB> <TAB> ] <TAB> elif privs == ""ALL_OU"" : <TAB> <TAB> body [ ""rolePrivileges"" ] = [ <TAB> <TAB> <TAB> { ""privilegeName"" : p [ ""privilegeName"" ], ""serviceId"" : p [ ""serviceId"" ] } <TAB> <TAB> <TAB> for p in all_privileges <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> ] <TAB> else : <TAB> <TAB> body. setdefault ( ""rolePrivileges"", [ ] ) <TAB> <TAB> for priv in privs. split ( "","" ) : <TAB> <TAB> <TAB> for p in all_privileges : <TAB> <TAB> <TAB> <TAB> if priv == p [ ""privilegeName"" ] : <TAB> <TAB> <TAB> <TAB> <TAB> body [ ""rolePrivileges"" ]. append ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""privilegeName"" : p [ ""privilegeName"" ], <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""serviceId"" : p [ ""serviceId"" ], <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> } <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> controlflow. invalid_argument_exit ( <TAB> <TAB>",False,p.get('isOuScopable'),len(p) == 0,0.6547329425811768
|
||
|
1165,"def apply ( self, ui ) : <TAB> if self. query : <TAB> <TAB> open_searches = ui. get_buffers_of_type ( buffers. SearchBuffer ) <TAB> <TAB> to_be_focused = None <TAB> <TAB> for sb in open_searches : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> to_be_focused = sb <TAB> <TAB> if to_be_focused : <TAB> <TAB> <TAB> if ui. current_buffer!= to_be_focused : <TAB> <TAB> <TAB> <TAB> ui. buffer_focus ( to_be_focused ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ui. current_buffer. rebuild ( ) <TAB> <TAB> <TAB> <TAB> ui. update ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> ui. buffer_open ( buffers. SearchBuffer ( ui, self. query, sort_order = self. order ) ) <TAB> else : <TAB> <TAB> ui. notify ( ""empty query string"" )",False,sb.querystring == self.query,sb.query_string,0.6540195345878601
|
||
|
1166,"def dump_list ( heading, aList ) : <TAB> if heading : <TAB> <TAB> print ( ""\n%s...\n"" % heading ) <TAB> for aTuple in aList : <TAB> <TAB> key, val = aTuple <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if key. endswith ( ( ""leo_expanded"", ""leo_marked"" ) ) : <TAB> <TAB> <TAB> <TAB> if val : <TAB> <TAB> <TAB> <TAB> <TAB> print ( ""%30s:"" % key ) <TAB> <TAB> <TAB> <TAB> <TAB> g. printObj ( val. split ( "","" ) ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> print ( ""%30s: []"" % key ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> print ( ""%30s: %s"" % ( key, val ) ) <TAB> <TAB> elif isinstance ( val, ( int, float ) ) : <TAB> <TAB> <TAB> print ( ""%30s: %s"" % ( key, val ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> print ( ""%30s:"" % key ) <TAB> <TAB> <TAB> g. printObj ( val )",False,g.isString(val),key,0.6495877504348755
|
||
|
1167,"def _load_windows_store_certs ( self, storename, purpose ) : <TAB> certs = bytearray ( ) <TAB> try : <TAB> <TAB> for cert, encoding, trust in enum_certificates ( storename ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> if trust is True or purpose. oid in trust : <TAB> <TAB> <TAB> <TAB> <TAB> certs. extend ( cert ) <TAB> except PermissionError : <TAB> <TAB> warnings. warn ( ""unable to enumerate Windows certificate store"" ) <TAB> if certs : <TAB> <TAB> self. load_verify_locations ( cadata = certs ) <TAB> return certs",False,encoding == 'x509_asn',encoding.oid == 'windows',0.6536643505096436
|
||
|
1168,"def run_scheduler ( self, timeout = - 1, ** kwargs ) : <TAB> """"""Run the CronTab as an internal scheduler (generator)"""""" <TAB> count = 0 <TAB> while count!= timeout : <TAB> <TAB> now = datetime. now ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> now += timedelta ( seconds = count * 60 ) <TAB> <TAB> for value in self. run_pending ( now = now ) : <TAB> <TAB> <TAB> yield value <TAB> <TAB> sleep ( kwargs. get ( ""cadence"", 60 ) ) <TAB> <TAB> count += 1",False,'warp' in kwargs,self.is_pending(now),0.6583479046821594
|
||
|
1169,"def Tokenize ( s ) : <TAB> <TAB> for item in TOKEN_RE. findall ( s ) : <TAB> <TAB> <TAB> <TAB> item = cast ( TupleStr4, item ) <TAB> <TAB> if item [ 0 ] : <TAB> <TAB> <TAB> typ = ""number"" <TAB> <TAB> <TAB> val = item [ 0 ] <TAB> <TAB> elif item [ 1 ] : <TAB> <TAB> <TAB> typ = ""name"" <TAB> <TAB> <TAB> val = item [ 1 ] <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> typ = item [ 2 ] <TAB> <TAB> <TAB> val = item [ 2 ] <TAB> <TAB> elif item [ 3 ] : <TAB> <TAB> <TAB> typ = item [ 3 ] <TAB> <TAB> <TAB> val = item [ 3 ] <TAB> <TAB> yield Token ( typ, val )",True,item[2],item[2],0.6707429885864258
|
||
|
1170,"def write ( self, x ) : <TAB> <TAB> self. _errors = ""backslashescape"" if self. encoding!= ""mbcs"" else ""surrogateescape"" <TAB> try : <TAB> <TAB> return io. TextIOWrapper. write ( self, to_text ( x, errors = self. _errors ) ) <TAB> except UnicodeDecodeError : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _errors = ""surrogateescape"" <TAB> <TAB> else : <TAB> <TAB> <TAB> self. _errors = ""replace"" <TAB> <TAB> return io. TextIOWrapper. write ( self, to_text ( x, errors = self. _errors ) )",False,self._errors != 'surrogateescape',self.encoding != 'mbcs',0.6582704782485962
|
||
|
1171,"def _ones_matrix_band_part ( rows, cols, num_lower, num_upper, out_shape = None ) : <TAB> """"""Matrix band part of ones."""""" <TAB> if all ( [ isinstance ( el, int ) for el in [ rows, cols, num_lower, num_upper ] ] ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> num_lower = rows - 1 <TAB> <TAB> if num_upper < 0 : <TAB> <TAB> <TAB> num_upper = cols - 1 <TAB> <TAB> lower_mask = np. tri ( cols, rows, num_lower ). T <TAB> <TAB> upper_mask = np. tri ( rows, cols, num_upper ) <TAB> <TAB> band = np. ones ( ( rows, cols ) ) * lower_mask * upper_mask <TAB> <TAB> if out_shape : <TAB> <TAB> <TAB> band = band. reshape ( out_shape ) <TAB> <TAB> band = tf. constant ( band, tf. float32 ) <TAB> else : <TAB> <TAB> band = tf. matrix_band_part ( <TAB> <TAB> <TAB> tf. ones ( [ rows, cols ] ), <TAB> <TAB> <TAB> tf. cast ( num_lower, tf. int64 ), <TAB> <TAB> <TAB> tf. cast ( num_upper, tf. int64 ), <TAB> <TAB> ) <TAB> <TAB> if out_shape : <TAB> <TAB> <TAB> band = tf. reshape ( band, out_shape ) <TAB> return band",True,num_lower < 0,num_lower < 0,0.6620115637779236
|
||
|
1172,"def check_registration_allowed ( self, email, username, password ) : <TAB> """"""Checks if the provided email/username is allowed to register."""""" <TAB> message = """" <TAB> status = ""done"" <TAB> for provider, options in self. active_authenticators ( email, username, password ) : <TAB> <TAB> allow_reg = _get_allow_register ( options ) <TAB> <TAB> if allow_reg == ""challenge"" : <TAB> <TAB> <TAB> auth_results = provider. authenticate ( email, username, password, options ) <TAB> <TAB> <TAB> if auth_results [ 0 ] is True : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> if auth_results [ 0 ] is None : <TAB> <TAB> <TAB> <TAB> message = ""Invalid email address/username or password."" <TAB> <TAB> <TAB> <TAB> status = ""error"" <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> break <TAB> <TAB> elif allow_reg is False : <TAB> <TAB> <TAB> message = ""Account registration not required for your account. Please simply login."" <TAB> <TAB> <TAB> status = ""error"" <TAB> <TAB> <TAB> break <TAB> return message, status",True,allow_reg is True,allow_reg is True,0.6555767059326172
|
||
|
1173,"def set_filter ( self, dataset_opt ) : <TAB> """"""This function create and set the pre_filter to the obj as attributes"""""" <TAB> self. pre_filter = None <TAB> for key_name in dataset_opt. keys ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> new_name = key_name. replace ( ""filters"", ""filter"" ) <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> filt = instantiate_filters ( getattr ( dataset_opt, key_name ) ) <TAB> <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> <TAB> log. exception ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Error trying to create {}, {}"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> new_name, getattr ( dataset_opt, key_name ) <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> setattr ( self, new_name, filt )",False,'filter' in key_name,"hasattr(dataset_opt, key_name)",0.6575393080711365
|
||
|
1174,"def read_headers ( cls, fp ) : <TAB> headers = httputil. HeaderMap ( ) <TAB> while True : <TAB> <TAB> line = fp. readline ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> raise EOFError ( ""Illegal end of headers."" ) <TAB> <TAB> if line == ntob ( ""\r\n"" ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> if not line. endswith ( ntob ( ""\r\n"" ) ) : <TAB> <TAB> <TAB> raise ValueError ( ""MIME requires CRLF terminators: %r"" % line ) <TAB> <TAB> if line [ 0 ] in ntob ( "" \t"" ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> v = line. strip ( ). decode ( ""ISO-8859-1"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> k, v = line. split ( ntob ( "":"" ), 1 ) <TAB> <TAB> <TAB> k = k. strip ( ). decode ( ""ISO-8859-1"" ) <TAB> <TAB> <TAB> v = v. strip ( ). decode ( ""ISO-8859-1"" ) <TAB> <TAB> existing = headers. get ( k ) <TAB> <TAB> if existing : <TAB> <TAB> <TAB> v = "", "". join ( ( existing, v ) ) <TAB> <TAB> headers [ k ] = v <TAB> return headers",True,not line,not line,0.671269953250885
|
||
|
1175,"def walk_to_corner ( from_vert, to_edges ) : <TAB> to_verts = { v for e in to_edges for v in e. verts } <TAB> edges = [ <TAB> <TAB> ( e, from_vert, None ) <TAB> <TAB> for e in from_vert. link_edges <TAB> <TAB> if not e. is_manifold and e. is_valid <TAB> ] <TAB> touched = { } <TAB> found = None <TAB> while edges : <TAB> <TAB> ec, v0, ep = edges. pop ( 0 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> touched [ ec ] = ( v0, ep ) <TAB> <TAB> v1 = ec. other_vert ( v0 ) <TAB> <TAB> if v1 in to_verts : <TAB> <TAB> <TAB> found = ec <TAB> <TAB> <TAB> break <TAB> <TAB> nedges = [ <TAB> <TAB> <TAB> ( en, v1, ec ) <TAB> <TAB> <TAB> for en in v1. link_edges <TAB> <TAB> <TAB> if en!= ec and not en. is_manifold and en. is_valid <TAB> <TAB> ] <TAB> <TAB> edges += nedges <TAB> if not found : <TAB> <TAB> return None <TAB> <TAB> walk = [ found ] <TAB> while True : <TAB> <TAB> ec = walk [ - 1 ] <TAB> <TAB> v0, ep = touched [ ec ] <TAB> <TAB> if v0 == from_vert : <TAB> <TAB> <TAB> break <TAB> <TAB> walk. append ( ep ) <TAB> return walk",False,ec in touched,ec == ec,0.6749950051307678
|
||
|
1176,"def execute ( self, client, smp_name, lun_size, * args, ** kwargs ) : <TAB> LOG. debug ( ""%s.execute"", self. __class__. __name__ ) <TAB> smp = client. get_lun ( name = smp_name ) <TAB> if lun_size > smp. total_capacity_gb : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> client. expand_lun ( smp_name, lun_size ) <TAB> <TAB> else : <TAB> <TAB> <TAB> LOG. warning ( <TAB> <TAB> <TAB> <TAB> ""Not extending the SMP: %s, because its base lun "" ""is not thin."", <TAB> <TAB> <TAB> <TAB> smp_name, <TAB> <TAB> <TAB> ) <TAB> else : <TAB> <TAB> LOG. info ( <TAB> <TAB> <TAB> ""Not extending the SMP: %(smp)s, size: %(size)s, because "" <TAB> <TAB> <TAB> ""the new size: %(new_size)s is smaller."", <TAB> <TAB> <TAB> { ""smp"" : smp_name, ""size"" : smp. total_capacity_gb, ""new_size"" : lun_size }, <TAB> <TAB> )",False,smp.primary_lun.is_thin_lun,lun_size > smp.total_capacity_gb,0.6476624608039856
|
||
|
1177,"def _write_references ( self, record ) : <TAB> <TAB> number = 0 <TAB> for ref in record. annotations [ ""references"" ] : <TAB> <TAB> if not isinstance ( ref, SeqFeature. Reference ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> number += 1 <TAB> <TAB> self. _write_single_line ( ""RN"", ""[%i]"" % number ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if ref. location and len ( ref. location ) == 1 : <TAB> <TAB> <TAB> self. _write_single_line ( <TAB> <TAB> <TAB> <TAB> ""RP"", <TAB> <TAB> <TAB> <TAB> ""%i-%i"" <TAB> <TAB> <TAB> <TAB> % ( ref. location [ 0 ]. nofuzzy_start + 1, ref. location [ 0 ]. nofuzzy_end ), <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> if ref. pubmed_id : <TAB> <TAB> <TAB> self. _write_single_line ( ""RX"", ""PUBMED; %s."" % ref. pubmed_id ) <TAB> <TAB> if ref. consrtm : <TAB> <TAB> <TAB> self. _write_single_line ( ""RG"", ""%s"" % ref. consrtm ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _write_multi_line ( ""RA"", ref. authors + "";"" ) <TAB> <TAB> if ref. title : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _write_multi_line ( ""RT"", '""%s"";' % ref. title ) <TAB> <TAB> if ref. journal : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _write_multi_line ( ""RL"", ref. journal ) <TAB> <TAB> self. handle. write ( ""XX\n"" )",True,ref.authors,ref.authors,0.6737276315689087
|
||
|
1178,"def test_valid_config ( ) : <TAB> config = DockerSchema2Config ( Bytes. for_string_or_unicode ( CONFIG_BYTES ) ) <TAB> history = list ( config. history ) <TAB> assert len ( history ) == 4 <TAB> assert not history [ 0 ]. is_empty <TAB> assert history [ 1 ]. is_empty <TAB> assert history [ 0 ]. created_datetime. year == 2018 <TAB> assert history [ 1 ]. command == '/bin/sh -c #(nop) CMD [""sh""]' <TAB> assert history [ 2 ]. command == ""sh"" <TAB> for index, history_entry in enumerate ( history ) : <TAB> <TAB> v1_compat = config. build_v1_compatibility ( <TAB> <TAB> <TAB> history_entry, ""somev1id"", ""someparentid"", index == 3 <TAB> <TAB> ) <TAB> <TAB> assert v1_compat [ ""id"" ] == ""somev1id"" <TAB> <TAB> assert v1_compat [ ""parent"" ] == ""someparentid"" <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> assert v1_compat [ ""container_config"" ] == config. _parsed [ ""container_config"" ] <TAB> <TAB> else : <TAB> <TAB> <TAB> assert ""Hostname"" not in v1_compat [ ""container_config"" ] <TAB> <TAB> <TAB> assert v1_compat [ ""container_config"" ] [ ""Cmd"" ] == [ history_entry. command ] <TAB> assert config. labels == { }",False,index == 3,"isinstance(v1_compat, dict)",0.6688709259033203
|
||
|
1179,"def on_edit_button_clicked ( self, event = None, a = None, col = None ) : <TAB> tree, tree_id = self. treeView. get_selection ( ). get_selected ( ) <TAB> watchdir_id = str ( self. store. get_value ( tree_id, 0 ) ) <TAB> if watchdir_id : <TAB> <TAB> if col and col. get_title ( ) == _ ( ""Active"" ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> client. autoadd. disable_watchdir ( watchdir_id ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> client. autoadd. enable_watchdir ( watchdir_id ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. opts_dialog. show ( self. watchdirs [ watchdir_id ], watchdir_id )",False,self.watchdirs[watchdir_id]['enabled'],self.opts_dialog.get_selected(),0.6544655561447144
|
||
|
1180,"def writexml ( <TAB> self, <TAB> stream, <TAB> indent = """", <TAB> addindent = """", <TAB> newl = """", <TAB> strip = 0, <TAB> nsprefixes = { }, <TAB> namespace = """", ) : <TAB> w = _streamWriteWrapper ( stream ) <TAB> if self. raw : <TAB> <TAB> val = self. nodeValue <TAB> <TAB> if not isinstance ( val, str ) : <TAB> <TAB> <TAB> val = str ( self. nodeValue ) <TAB> else : <TAB> <TAB> v = self. nodeValue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> v = str ( v ) <TAB> <TAB> if strip : <TAB> <TAB> <TAB> v = "" "". join ( v. split ( ) ) <TAB> <TAB> val = escape ( v ) <TAB> w ( val )",True,"not isinstance(v, str)","not isinstance(v, str)",0.6503371596336365
|
||
|
1181,"def ensure_not_cyclic ( self, start, get_children ) : <TAB> <TAB> <TAB> todo = set ( self. nodes ) <TAB> while todo : <TAB> <TAB> node = todo. pop ( ) <TAB> <TAB> stack = [ node ] <TAB> <TAB> while stack : <TAB> <TAB> <TAB> top = stack [ - 1 ] <TAB> <TAB> <TAB> for node in get_children ( top ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> cycle = stack [ stack. index ( node ) : ] <TAB> <TAB> <TAB> <TAB> <TAB> raise CircularDependencyError ( "", "". join ( ""%s.%s"" % n for n in cycle ) ) <TAB> <TAB> <TAB> <TAB> if node in todo : <TAB> <TAB> <TAB> <TAB> <TAB> stack. append ( node ) <TAB> <TAB> <TAB> <TAB> <TAB> todo. remove ( node ) <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> node = stack. pop ( )",False,node in stack,node in start,0.6821103692054749
|
||
|
1182,"def check_localhost ( self ) : <TAB> """"""Warn if any socket_host is 'localhost'. See #711."""""" <TAB> for k, v in cherrypy. config. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> warnings. warn ( <TAB> <TAB> <TAB> <TAB> ""The use of 'localhost' as a socket host can "" <TAB> <TAB> <TAB> <TAB> ""cause problems on newer systems, since "" <TAB> <TAB> <TAB> <TAB> ""'localhost' can map to either an IPv4 or an "" <TAB> <TAB> <TAB> <TAB> ""IPv6 address. You should use '127.0.0.1' "" <TAB> <TAB> <TAB> <TAB> ""or '[::1]' instead."" <TAB> <TAB> <TAB> )",False,k == 'server.socket_host' and v == 'localhost',k != 'socket_host',0.6515125036239624
|
||
|
1183,"def reindex ( cls, dataset, kdims = None, vdims = None ) : <TAB> data = dataset. data <TAB> dropped_kdims = [ kd for kd in dataset. kdims if kd not in kdims ] <TAB> constant = { } <TAB> for kd in dropped_kdims : <TAB> <TAB> vals = cls. values ( dataset, kd. name, expanded = False ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> constant [ kd. name ] = vals [ 0 ] <TAB> if dropped_kdims or constant : <TAB> <TAB> return tuple ( dataset. columns ( kdims + vdims ). values ( ) ) <TAB> if vdims is not None and vdims!= dataset. vdims and len ( dataset. vdims ) > 1 : <TAB> <TAB> inds = [ dataset. get_dimension_index ( vd ) - dataset. ndims for vd in vdims ] <TAB> <TAB> return data [..., inds ] if len ( inds ) > 1 else data [..., inds [ 0 ] ] <TAB> return data",False,len(vals) == 1,len(vals) > 0,0.6615097522735596
|
||
|
1184,"def message_to_dict ( post_dict : Dict [ str, Any ] ) -> Dict [ str, Any ] : <TAB> sender_username = post_dict [ ""user"" ] <TAB> sender_id = user_id_mapper. get ( sender_username ) <TAB> content = post_dict [ ""message"" ] <TAB> if masking_content : <TAB> <TAB> content = re. sub ( ""[a-z]"", ""x"", content ) <TAB> <TAB> content = re. sub ( ""[A-Z]"", ""X"", content ) <TAB> if ""reactions"" in post_dict : <TAB> <TAB> reactions = post_dict [ ""reactions"" ] or [ ] <TAB> else : <TAB> <TAB> reactions = [ ] <TAB> message_dict = dict ( <TAB> <TAB> sender_id = sender_id, <TAB> <TAB> content = content, <TAB> <TAB> date_sent = int ( post_dict [ ""create_at"" ] / 1000 ), <TAB> <TAB> reactions = reactions, <TAB> ) <TAB> if ""channel"" in post_dict : <TAB> <TAB> message_dict [ ""channel_name"" ] = post_dict [ ""channel"" ] <TAB> elif ""channel_members"" in post_dict : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> channel_members = post_dict [ ""channel_members"" ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> message_dict [ ""huddle_name"" ] = generate_huddle_name ( channel_members ) <TAB> <TAB> elif len ( channel_members ) == 2 : <TAB> <TAB> <TAB> message_dict [ ""pm_members"" ] = channel_members <TAB> else : <TAB> <TAB> raise AssertionError ( ""Post without channel or channel_members key."" ) <TAB> return message_dict",False,len(channel_members) > 2,len(channel_members) == 1,0.6495811939239502
|
||
|
1185,"def child ( kind ) : <TAB> term = TestTerminal ( kind = kind, force_styling = True ) <TAB> keymap = get_keyboard_sequences ( term ) <TAB> if term. _cuf1 : <TAB> <TAB> assert term. _cuf1!= u"" "" <TAB> <TAB> assert term. _cuf1 in keymap <TAB> <TAB> assert keymap [ term. _cuf1 ] == term. KEY_RIGHT <TAB> if term. _cub1 : <TAB> <TAB> assert term. _cub1 in keymap <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> assert keymap [ term. _cub1 ] == term. KEY_BACKSPACE <TAB> <TAB> else : <TAB> <TAB> <TAB> assert keymap [ term. _cub1 ] == term. KEY_LEFT",False,term._cub1 == '\x08',term._cub1 != u' ',0.6584067344665527
|
||
|
1186,"def __assert_eq ( self, * args, ** kwargs ) : <TAB> """"""Minified assert_equal() using only the list diff."""""" <TAB> minified_exception = None <TAB> try : <TAB> <TAB> self. assertEqual ( * args, ** kwargs ) <TAB> except Exception as e : <TAB> <TAB> str_e = str ( e ) <TAB> <TAB> minified_exception = ""\nAssertionError:\n"" <TAB> <TAB> lines = str_e. split ( ""\n"" ) <TAB> <TAB> countdown = 3 <TAB> <TAB> countdown_on = False <TAB> <TAB> for line in lines : <TAB> <TAB> <TAB> if countdown_on : <TAB> <TAB> <TAB> <TAB> minified_exception += line + ""\n"" <TAB> <TAB> <TAB> <TAB> countdown = countdown - 1 <TAB> <TAB> <TAB> <TAB> if countdown == 0 : <TAB> <TAB> <TAB> <TAB> <TAB> countdown_on = False <TAB> <TAB> <TAB> elif line. startswith ( ""F"" ) : <TAB> <TAB> <TAB> <TAB> countdown_on = True <TAB> <TAB> <TAB> <TAB> countdown = 3 <TAB> <TAB> <TAB> <TAB> minified_exception += line + ""\n"" <TAB> <TAB> <TAB> elif line. startswith ( ""+"" ) or line. startswith ( ""-"" ) : <TAB> <TAB> <TAB> <TAB> minified_exception += line + ""\n"" <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> minified_exception += line + ""\n"" <TAB> <TAB> <TAB> elif line. strip ( ). startswith ( ""*"" ) : <TAB> <TAB> <TAB> <TAB> minified_exception += line + ""\n"" <TAB> if minified_exception : <TAB> <TAB> raise Exception ( minified_exception )",False,line.startswith('?'),line.strip() == '',0.6507472991943359
|
||
|
1187,"def to_dict ( self ) : <TAB> contexts_ = { } <TAB> for k, data in self. contexts. items ( ) : <TAB> <TAB> data_ = data. copy ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> del data_ [ ""context"" ] <TAB> <TAB> if ""loaded"" in data_ : <TAB> <TAB> <TAB> del data_ [ ""loaded"" ] <TAB> <TAB> contexts_ [ k ] = data_ <TAB> return dict ( contexts = contexts_ )",True,'context' in data_,'context' in data_,0.6572332978248596
|
||
|
1188,"def _handle_eio_message ( self, sid, data ) : <TAB> """"""Dispatch Engine.IO messages."""""" <TAB> if sid in self. _binary_packet : <TAB> <TAB> pkt = self. _binary_packet [ sid ] <TAB> <TAB> if pkt. add_attachment ( data ) : <TAB> <TAB> <TAB> del self. _binary_packet [ sid ] <TAB> <TAB> <TAB> if pkt. packet_type == packet. BINARY_EVENT : <TAB> <TAB> <TAB> <TAB> await self. _handle_event ( sid, pkt. namespace, pkt. id, pkt. data ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> await self. _handle_ack ( sid, pkt. namespace, pkt. id, pkt. data ) <TAB> else : <TAB> <TAB> pkt = packet. Packet ( encoded_packet = data ) <TAB> <TAB> if pkt. packet_type == packet. CONNECT : <TAB> <TAB> <TAB> await self. _handle_connect ( sid, pkt. namespace ) <TAB> <TAB> elif pkt. packet_type == packet. DISCONNECT : <TAB> <TAB> <TAB> await self. _handle_disconnect ( sid, pkt. namespace ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> await self. _handle_event ( sid, pkt. namespace, pkt. id, pkt. data ) <TAB> <TAB> elif pkt. packet_type == packet. ACK : <TAB> <TAB> <TAB> await self. _handle_ack ( sid, pkt. namespace, pkt. id, pkt. data ) <TAB> <TAB> elif ( <TAB> <TAB> <TAB> pkt. packet_type == packet. BINARY_EVENT <TAB> <TAB> <TAB> or pkt. packet_type == packet. BINARY_ACK <TAB> <TAB> ) : <TAB> <TAB> <TAB> self. _binary_packet [ sid ] = pkt <TAB> <TAB> elif pkt. packet_type == packet. ERROR : <TAB> <TAB> <TAB> raise ValueError ( ""Unexpected ERROR packet."" ) <TAB> <TAB> else : <TAB> <TAB>",True,pkt.packet_type == packet.EVENT,pkt.packet_type == packet.EVENT,0.6598875522613525
|
||
|
1189,"def _WriteFonts ( self ) : <TAB> self. _write ( r""{\fonttbl"" ) <TAB> self. _font_map = { } <TAB> offset = 0 <TAB> for font in self. _doc. StyleSheet. Fonts : <TAB> <TAB> pitch = """" <TAB> <TAB> panose = """" <TAB> <TAB> alternate = """" <TAB> <TAB> if font. Pitch : <TAB> <TAB> <TAB> pitch = r""\fprq%s"" % font. Pitch <TAB> <TAB> if font. Panose : <TAB> <TAB> <TAB> panose = r""{\*\panose %s}"" % font. Panose <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> alternate = r""{\*\falt %s}"" % font. Alternate. Name <TAB> <TAB> self. _write ( <TAB> <TAB> <TAB> r""{\f%s\f%s%s\fcharset%s%s %s%s;}"", <TAB> <TAB> <TAB> offset, <TAB> <TAB> <TAB> font. Family, <TAB> <TAB> <TAB> pitch, <TAB> <TAB> <TAB> font. CharacterSet, <TAB> <TAB> <TAB> panose, <TAB> <TAB> <TAB> font. Name, <TAB> <TAB> <TAB> alternate, <TAB> <TAB> ) <TAB> <TAB> self. _font_map [ font ] = offset <TAB> <TAB> offset += 1 <TAB> self. _write ( ""}\n"" )",True,font.Alternate,font.Alternate,0.6764723062515259
|
||
|
1190,"def distros_for_location ( location, basename, metadata = None ) : <TAB> """"""Yield egg or source distribution objects based on basename"""""" <TAB> if basename. endswith ( "".egg.zip"" ) : <TAB> <TAB> basename = basename [ : - 4 ] <TAB> if basename. endswith ( "".egg"" ) and ""-"" in basename : <TAB> <TAB> <TAB> <TAB> return [ Distribution. from_location ( location, basename, metadata ) ] <TAB> if basename. endswith ( "".whl"" ) and ""-"" in basename : <TAB> <TAB> wheel = Wheel ( basename ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return [ ] <TAB> <TAB> return [ <TAB> <TAB> <TAB> Distribution ( <TAB> <TAB> <TAB> <TAB> location = location, <TAB> <TAB> <TAB> <TAB> project_name = wheel. project_name, <TAB> <TAB> <TAB> <TAB> version = wheel. version, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> precedence = EGG_DIST + 1, <TAB> <TAB> <TAB> ) <TAB> <TAB> ] <TAB> if basename. endswith ( "".exe"" ) : <TAB> <TAB> win_base, py_ver, platform = parse_bdist_wininst ( basename ) <TAB> <TAB> if win_base is not None : <TAB> <TAB> <TAB> return interpret_distro_name ( <TAB> <TAB> <TAB> <TAB> location, win_base, metadata, py_ver, BINARY_DIST, platform <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> for ext in EXTENSIONS : <TAB> <TAB> if basename. endswith ( ext ) : <TAB> <TAB> <TAB> basename = basename [ : - len ( ext ) ] <TAB> <TAB> <TAB> return interpret_distro_name ( location, basename, metadata ) <TAB> return [ ]",False,not wheel.is_compatible(),not wheel,0.6536357402801514
|
||
|
1191,"def _write_ready ( self ) : <TAB> assert self. _buffer, ""Data should not be empty"" <TAB> if self. _conn_lost : <TAB> <TAB> return <TAB> try : <TAB> <TAB> n = self. _sock. send ( self. _buffer ) <TAB> except ( BlockingIOError, InterruptedError ) : <TAB> <TAB> pass <TAB> except ( SystemExit, KeyboardInterrupt ) : <TAB> <TAB> raise <TAB> except BaseException 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> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _empty_waiter. set_exception ( exc ) <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<mask> : <TAB> <TAB> <TAB> <TAB> self. _empty_waiter. set_result ( None ) <TAB> <TAB> <TAB> if self. _closing : <TAB> <TAB> <TAB> <TAB> self. _call_connection_lost ( None ) <TAB> <TAB> <TAB> elif self. _eof : <TAB> <TAB> <TAB> <TAB> self. _sock. shutdown ( socket. SHUT_WR )",False,self._empty_waiter is not None,self._sleep,0.6543573141098022
|
||
|
1192,"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<mask> : <TAB> <TAB> <TAB> break <TAB> <TAB> if fid == 1 : <TAB> <TAB> <TAB> if ftype == TType. STRING : <TAB> <TAB> <TAB> <TAB> self. ip = iprot. readString ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif fid == 2 : <TAB> <TAB> <TAB> if ftype == TType. I32 : <TAB> <TAB> <TAB> <TAB> self. duration = iprot. readI32 ( ) <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.STOP,fid == 0,0.6599719524383545
|
||
|
1193,"def get_proposer_index_maybe ( spec, state, slot, proposer_index = None ) : <TAB> if proposer_index is None : <TAB> <TAB> assert state. slot <= slot <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> proposer_index = spec. get_beacon_proposer_index ( state ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if spec. compute_epoch_at_slot ( state. slot ) + 1 > spec. compute_epoch_at_slot ( <TAB> <TAB> <TAB> <TAB> slot <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> <TAB> ""warning: block slot far away, and no proposer index manually given."" <TAB> <TAB> <TAB> <TAB> <TAB> "" Signing block is slow due to transition for proposer index calculation."" <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> stub_state = state. copy ( ) <TAB> <TAB> <TAB> if stub_state. slot < slot : <TAB> <TAB> <TAB> <TAB> spec. process_slots ( stub_state, slot ) <TAB> <TAB> <TAB> proposer_index = spec. get_beacon_proposer_index ( stub_state ) <TAB> return proposer_index",False,slot == state.slot,state.has_beacon_index,0.6684434413909912
|
||
|
1194,"def set_mode ( self, ii, mode_space ) : <TAB> for bit_info in ii. ipattern. bits : <TAB> <TAB> if bit_info. token == _mode_token : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. mode = [ bit_info. requirement ] <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> mod_space = copy. deepcopy ( mode_space ) <TAB> <TAB> <TAB> <TAB> mod_space. remove ( bit_info. requirement ) <TAB> <TAB> <TAB> <TAB> self. mode = mod_space <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> <TAB> self. mode = ildutil. mode_space",False,bit_info.test == 'eq',bit_info.requirement in mode_space,0.6536660194396973
|
||
|
1195,"def imgs_transform ( <TAB> imgs, mode, seg_num, seglen, short_size, target_size, img_mean, img_std, name = """" ) : <TAB> imgs = group_scale ( imgs, short_size ) <TAB> if mode == ""train"" : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> imgs = group_multi_scale_crop ( imgs, short_size ) <TAB> <TAB> imgs = group_random_crop ( imgs, target_size ) <TAB> <TAB> imgs = group_random_flip ( imgs ) <TAB> else : <TAB> <TAB> imgs = group_center_crop ( imgs, target_size ) <TAB> np_imgs = ( np. array ( imgs [ 0 ] ). astype ( ""float32"" ). transpose ( ( 2, 0, 1 ) ) ). reshape ( <TAB> <TAB> 1, 3, target_size, target_size <TAB> ) / 255 <TAB> for i in range ( len ( imgs ) - 1 ) : <TAB> <TAB> img = ( np. array ( imgs [ i + 1 ] ). astype ( ""float32"" ). transpose ( ( 2, 0, 1 ) ) ). reshape ( <TAB> <TAB> <TAB> 1, 3, target_size, target_size <TAB> <TAB> ) / 255 <TAB> <TAB> np_imgs = np. concatenate ( ( np_imgs, img ) ) <TAB> imgs = np_imgs <TAB> imgs -= img_mean <TAB> imgs /= img_std <TAB> imgs = np. reshape ( imgs, ( seg_num, seglen * 3, target_size, target_size ) ) <TAB> return imgs",False,name == 'TSM',"name == ""random_crop_gig and (not name)",0.6595683693885803
|
||
|
1196,"def process ( self ) : <TAB> level_socket, size_socket = self. inputs <TAB> verts_socket, edges_socket = self. outputs <TAB> if verts_socket. is_linked : <TAB> <TAB> Integer = int ( level_socket. sv_get ( ) [ 0 ] [ 0 ] ) <TAB> <TAB> Step = size_socket. sv_get ( ) [ 0 ] [ 0 ] <TAB> <TAB> verts = self. hilbert ( 0.0, 0.0, Step * 1.0, 0.0, 0.0, Step * 1.0, Integer ) <TAB> <TAB> verts_socket. sv_set ( [ verts ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> listEdg = [ ] <TAB> <TAB> <TAB> r = len ( verts ) - 1 <TAB> <TAB> <TAB> for i in range ( r ) : <TAB> <TAB> <TAB> <TAB> listEdg. append ( ( i, i + 1 ) ) <TAB> <TAB> <TAB> edg = list ( listEdg ) <TAB> <TAB> <TAB> edges_socket. sv_set ( [ edg ] )",False,edges_socket.is_linked,self.depth > 0,0.6553827524185181
|
||
|
1197,"def calculate_score ( search_string, word ) : <TAB> """"""Calculate how well the search string matches the word."""""" <TAB> <TAB> <TAB> <TAB> <TAB> if len ( search_string ) > len ( word ) : <TAB> <TAB> return 0 <TAB> original_word = word <TAB> score = 1 <TAB> search_index = 0 <TAB> last_match_index = 0 <TAB> while True : <TAB> <TAB> scale = 1 <TAB> <TAB> search_char = search_string [ search_index ] <TAB> <TAB> i = word. find ( search_char ) <TAB> <TAB> if i < 0 : <TAB> <TAB> <TAB> return 0 <TAB> <TAB> if i > 0 and word [ i - 1 ] == ""-"" : <TAB> <TAB> <TAB> scale = 0.95 <TAB> <TAB> else : <TAB> <TAB> <TAB> scale = 1 - ( i / float ( len ( word ) ) ) <TAB> <TAB> score *= scale <TAB> <TAB> word = word [ i + 1 : ] <TAB> <TAB> last_match_index = i <TAB> <TAB> search_index += 1 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> completion_scale = 1 - ( len ( word ) / float ( len ( original_word ) ) ) <TAB> score *= completion_scale <TAB> return score",False,search_index >= len(search_string),last_match_index == word,0.6491938233375549
|
||
|
1198,"def close ( self ) : <TAB> self. selector. close ( ) <TAB> if self. sock : <TAB> <TAB> sockname = None <TAB> <TAB> try : <TAB> <TAB> <TAB> sockname = self. sock. getsockname ( ) <TAB> <TAB> except ( socket. error, OSError ) : <TAB> <TAB> <TAB> pass <TAB> <TAB> self. sock. close ( ) <TAB> <TAB> if type ( sockname ) is str : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> os. remove ( sockname ) <TAB> self. sock = None",False,os.path.exists(sockname),sockname is not None,0.6488858461380005
|
||
|
1199,"def filter ( this, args ) : <TAB> array = to_object ( this, args. space ) <TAB> callbackfn = get_arg ( args, 0 ) <TAB> arr_len = js_arr_length ( array ) <TAB> if not is_callable ( callbackfn ) : <TAB> <TAB> raise MakeError ( ""TypeError"", ""callbackfn must be a function"" ) <TAB> _this = get_arg ( args, 1 ) <TAB> k = 0 <TAB> res = [ ] <TAB> while k < arr_len : <TAB> <TAB> if array. has_property ( unicode ( k ) ) : <TAB> <TAB> <TAB> kValue = array. get ( unicode ( k ) ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> res. append ( kValue ) <TAB> <TAB> k += 1 <TAB> return args. space. ConstructArray ( res )",False,"to_boolean(callbackfn.call(_this, (kValue, float(k), array)))",kValue and kValue != '',0.6516323685646057
|
||
|
1200,"def get_data_from_http_header ( self, buf ) : <TAB> ret_buf = b"""" <TAB> lines = buf. split ( b""\r\n"" ) <TAB> if lines and len ( lines ) > 1 : <TAB> <TAB> hex_items = lines [ 0 ]. split ( b""%"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> for index in range ( 1, len ( hex_items ) ) : <TAB> <TAB> <TAB> <TAB> if len ( hex_items [ index ] ) < 2 : <TAB> <TAB> <TAB> <TAB> <TAB> ret_buf += binascii. unhexlify ( ""0"" + hex_items [ index ] ) <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> elif len ( hex_items [ index ] ) > 2 : <TAB> <TAB> <TAB> <TAB> <TAB> ret_buf += binascii. unhexlify ( hex_items [ index ] [ : 2 ] ) <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> ret_buf += binascii. unhexlify ( hex_items [ index ] ) <TAB> <TAB> <TAB> return ret_buf <TAB> return b""""",False,hex_items and len(hex_items) > 1,len(hex_items) > 0,0.6537681818008423
|
||
|
1201,"def assistive ( self ) : <TAB> """"""Detects if item can be used as assistance"""""" <TAB> <TAB> if self. __assistive is None : <TAB> <TAB> assistive = False <TAB> <TAB> <TAB> <TAB> for effect in self. effects. values ( ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> assistive = True <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> self. __assistive = assistive <TAB> return self. __assistive",False,effect.isAssistance is True,not assistive,0.6646853685379028
|
||
|
1202,"def __init__ ( self, listeners ) : <TAB> self. __command_listeners = _LISTENERS. command_listeners [ : ] <TAB> self. __server_listeners = _LISTENERS. server_listeners [ : ] <TAB> lst = _LISTENERS. server_heartbeat_listeners <TAB> self. __server_heartbeat_listeners = lst [ : ] <TAB> self. __topology_listeners = _LISTENERS. topology_listeners [ : ] <TAB> if listeners is not None : <TAB> <TAB> for lst in listeners : <TAB> <TAB> <TAB> if isinstance ( lst, CommandListener ) : <TAB> <TAB> <TAB> <TAB> self. __command_listeners. append ( lst ) <TAB> <TAB> <TAB> if isinstance ( lst, ServerListener ) : <TAB> <TAB> <TAB> <TAB> self. __server_listeners. append ( lst ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. __server_heartbeat_listeners. append ( lst ) <TAB> <TAB> <TAB> if isinstance ( lst, TopologyListener ) : <TAB> <TAB> <TAB> <TAB> self. __topology_listeners. append ( lst ) <TAB> self. __enabled_for_commands = bool ( self. __command_listeners ) <TAB> self. __enabled_for_server = bool ( self. __server_listeners ) <TAB> self. __enabled_for_server_heartbeat = bool ( self. __server_heartbeat_listeners ) <TAB> self. __enabled_for_topology = bool ( self. __topology_listeners )",False,"isinstance(lst, ServerHeartbeatListener)","isinstance(lst, ServerheartbeatListener)",0.6616869568824768
|
||
|
1203,"def findtype ( self, variable ) : <TAB> """""":see Expression.findtype()"""""" <TAB> assert isinstance ( variable, Variable ), ""%s is not a Variable"" % variable <TAB> if self. is_atom ( ) : <TAB> <TAB> function, args = self. uncurry ( ) <TAB> else : <TAB> <TAB> <TAB> <TAB> function = self. function <TAB> <TAB> args = [ self. argument ] <TAB> found = [ arg. findtype ( variable ) for arg in [ function ] + args ] <TAB> unique = [ ] <TAB> for f in found : <TAB> <TAB> if f!= ANY_TYPE : <TAB> <TAB> <TAB> if unique : <TAB> <TAB> <TAB> <TAB> for u in unique : <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> unique. append ( f ) <TAB> if len ( unique ) == 1 : <TAB> <TAB> return list ( unique ) [ 0 ] <TAB> else : <TAB> <TAB> return ANY_TYPE",False,f.matches(u),u != ANY_TYPE,0.660801351070404
|
||
|
1204,"def add_network_rule ( <TAB> cmd, <TAB> client, <TAB> resource_group_name, <TAB> account_name, <TAB> action = ""Allow"", <TAB> subnet = None, <TAB> vnet_name = None, <TAB> ip_address = None, ) : <TAB> sa = client. get_properties ( resource_group_name, account_name ) <TAB> rules = sa. network_rule_set <TAB> if subnet : <TAB> <TAB> from msrestazure. tools import is_valid_resource_id <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise CLIError ( <TAB> <TAB> <TAB> <TAB> ""Expected fully qualified resource ID: got '{}'"". format ( subnet ) <TAB> <TAB> <TAB> ) <TAB> <TAB> VirtualNetworkRule = cmd. get_models ( ""VirtualNetworkRule"" ) <TAB> <TAB> if not rules. virtual_network_rules : <TAB> <TAB> <TAB> rules. virtual_network_rules = [ ] <TAB> <TAB> rules. virtual_network_rules = [ <TAB> <TAB> <TAB> r <TAB> <TAB> <TAB> for r in rules. virtual_network_rules <TAB> <TAB> <TAB> if r. virtual_network_resource_id. lower ( )!= subnet. lower ( ) <TAB> <TAB> ] <TAB> <TAB> rules. virtual_network_rules. append ( <TAB> <TAB> <TAB> VirtualNetworkRule ( virtual_network_resource_id = subnet, action = action ) <TAB> <TAB> ) <TAB> if ip_address : <TAB> <TAB> IpRule = cmd. get_models ( ""IPRule"" ) <TAB> <TAB> if not rules. ip_rules : <TAB> <TAB> <TAB> rules. ip_rules = [ ] <TAB> <TAB> rules. ip_rules = [ <TAB> <TAB> <TAB> r for r in rules. ip_rules if r. ip_address_or_range!= ip_address <TAB> <TAB> ] <TAB> <TAB> rules. ip_rules. append ( IpRule ( ip_address_or_range = ip_",False,not is_valid_resource_id(subnet),is_valid_resource_id(subnet),0.6568795442581177
|
||
|
1205,"def to_pandas ( self ) : <TAB> """"""Returns a pandas DataFrame with the response of the query."""""" <TAB> if not self. _raw_response : <TAB> <TAB> self. _execute_query ( ) <TAB> return_list = [ ] <TAB> timelines = { t. index_name : t. name for t in self. _sketch. list_timelines ( ) } <TAB> return_field_list = [ ] <TAB> return_fields = self. _return_fields <TAB> if return_fields : <TAB> <TAB> if return_fields. startswith ( ""'"" ) : <TAB> <TAB> <TAB> return_fields = return_fields [ 1 : ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return_fields = return_fields [ : - 1 ] <TAB> <TAB> return_field_list = return_fields. split ( "","" ) <TAB> for result in self. _raw_response. get ( ""objects"", [ ] ) : <TAB> <TAB> source = result. get ( ""_source"", { } ) <TAB> <TAB> if not return_fields or ""_id"" in return_field_list : <TAB> <TAB> <TAB> source [ ""_id"" ] = result. get ( ""_id"" ) <TAB> <TAB> if not return_fields or ""_type"" in return_field_list : <TAB> <TAB> <TAB> source [ ""_type"" ] = result. get ( ""_type"" ) <TAB> <TAB> if not return_fields or ""_index"" in return_field_list : <TAB> <TAB> <TAB> source [ ""_index"" ] = result. get ( ""_index"" ) <TAB> <TAB> if not return_fields or ""_source"" in return_field_list : <TAB> <TAB> <TAB> source [ ""_source"" ] = timelines. get ( result. get ( ""_index"" ) ) <TAB> <TAB> return_list. append ( source ) <TAB> data_frame = pandas. DataFrame ( return_list ) <TAB> if ""datetime"" in data_frame : <TAB> <TAB> try : <TAB> <TAB> <TAB> data_frame [ ""datetime"" ] = pandas. to",False,"return_fields.endswith(""'"")","return_fields.endswith(',')",0.6494438648223877
|
||
|
1206,"def process_extra_fields ( self ) : <TAB> if self. instance. pk is not None : <TAB> <TAB> if self. cleaned_data. get ( ""initialize"", None ) : <TAB> <TAB> <TAB> self. instance. initialize ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. instance. update_from_templates ( )",False,"self.cleaned_data.get('update', None) or not self.instance.stores.count()","self.cleaned_data.get('update_from_templates', None)",0.6510922312736511
|
||
|
1207,"def load_www ( self, filename, config_dict ) : <TAB> if ""www"" not in config_dict : <TAB> <TAB> return <TAB> www_cfg = config_dict [ ""www"" ] <TAB> allowed = set ( <TAB> <TAB> [ <TAB> <TAB> <TAB> ""port"", <TAB> <TAB> <TAB> ""debug"", <TAB> <TAB> <TAB> ""json_cache_seconds"", <TAB> <TAB> <TAB> ""rest_minimum_version"", <TAB> <TAB> <TAB> ""allowed_origins"", <TAB> <TAB> <TAB> ""jsonp"", <TAB> <TAB> <TAB> ""plugins"", <TAB> <TAB> <TAB> ""auth"", <TAB> <TAB> <TAB> ""authz"", <TAB> <TAB> <TAB> ""avatar_methods"", <TAB> <TAB> <TAB> ""logfileName"", <TAB> <TAB> <TAB> ""logRotateLength"", <TAB> <TAB> <TAB> ""maxRotatedFiles"", <TAB> <TAB> <TAB> ""versions"", <TAB> <TAB> <TAB> ""change_hook_dialects"", <TAB> <TAB> <TAB> ""change_hook_auth"", <TAB> <TAB> <TAB> ""custom_templates_dir"", <TAB> <TAB> <TAB> ""cookie_expiration_time"", <TAB> <TAB> ] <TAB> ) <TAB> unknown = set ( list ( www_cfg ) ) - allowed <TAB> if unknown : <TAB> <TAB> error ( ""unknown www configuration parameter(s) %s"" % ( "", "". join ( unknown ), ) ) <TAB> versions = www_cfg. get ( ""versions"" ) <TAB> if versions is not None : <TAB> <TAB> cleaned_versions = [ ] <TAB> <TAB> if not isinstance ( versions, list ) : <TAB> <TAB> <TAB> error ( ""Invalid www configuration value of versions"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> for i, v in enumerate ( versions ) : <TAB> <TAB> <TAB> <TAB>",False,"not isinstance(cookie_expiration_time, datetime.timedelta)",self.load_versions and filename not in allowed,0.6454242467880249
|
||
|
1208,"def canonical_custom_headers ( self, headers ) : <TAB> hoi = [ ] <TAB> custom_headers = { } <TAB> for key in headers : <TAB> <TAB> lk = key. lower ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if lk. startswith ( ""x-amz-"" ) : <TAB> <TAB> <TAB> <TAB> custom_headers [ lk ] = "","". join ( v. strip ( ) for v in headers. get_all ( key ) ) <TAB> sorted_header_keys = sorted ( custom_headers. keys ( ) ) <TAB> for key in sorted_header_keys : <TAB> <TAB> hoi. append ( ""%s:%s"" % ( key, custom_headers [ key ] ) ) <TAB> return ""\n"". join ( hoi )",False,headers[key] is not None,lk.startswith('x-amz-'),0.6531437039375305
|
||
|
1209,"def check ( self, value ) : <TAB> val = self. rule. match ( value ) <TAB> try : <TAB> <TAB> ( h, m, s ) = ( int ( val. group ( ""h"" ) ), 0, 0 ) <TAB> <TAB> if not val. group ( ""m"" ) is None : <TAB> <TAB> <TAB> m = int ( val. group ( ""m"" ) ) <TAB> <TAB> if not val. group ( ""s"" ) is None : <TAB> <TAB> <TAB> s = int ( val. group ( ""s"" ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> h = h + 12 <TAB> <TAB> if val. group ( ""d"" ) == ""am"" and h == 12 : <TAB> <TAB> <TAB> h = 0 <TAB> <TAB> if not ( h in range ( 24 ) and m in range ( 60 ) and s in range ( 60 ) ) : <TAB> <TAB> <TAB> raise ValueError ( ""Hours or minutes or seconds are outside of allowed range"" ) <TAB> <TAB> val = time ( h, m, s ) <TAB> <TAB> return val, None <TAB> except AttributeError : <TAB> <TAB> pass <TAB> except ValueError : <TAB> <TAB> pass <TAB> return value, translate ( self. message )",False,val.group('d') == 'pm' and 0 < h < 12,val.group('h') and m == 11,0.6507682800292969
|
||
|
1210,"def _fix_up_module ( ns, name, pathname, cpathname = None ) : <TAB> <TAB> loader = ns. get ( ""__loader__"" ) <TAB> spec = ns. get ( ""__spec__"" ) <TAB> if not loader : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> loader = spec. loader <TAB> <TAB> elif pathname == cpathname : <TAB> <TAB> <TAB> loader = SourcelessFileLoader ( name, pathname ) <TAB> <TAB> else : <TAB> <TAB> <TAB> loader = SourceFileLoader ( name, pathname ) <TAB> if not spec : <TAB> <TAB> spec = spec_from_file_location ( name, pathname, loader = loader ) <TAB> try : <TAB> <TAB> ns [ ""__spec__"" ] = spec <TAB> <TAB> ns [ ""__loader__"" ] = loader <TAB> <TAB> ns [ ""__file__"" ] = pathname <TAB> <TAB> ns [ ""__cached__"" ] = cpathname <TAB> except Exception : <TAB> <TAB> <TAB> <TAB> pass",False,spec,"hasattr(spec, 'loader')",0.6974095106124878
|
||
|
1211,"def parse_ep_str ( anime, grammar ) : <TAB> episodes = [ ] <TAB> if not grammar : <TAB> <TAB> return split_anime ( anime, parse_episode_range ( anime, grammar ) ) <TAB> for episode_grammar in grammar. split ( "","" ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> start, end = parse_episode_range ( anime, episode_grammar ). split ( "":"" ) <TAB> <TAB> <TAB> episode_grammar = ""%d:%d"" % ( int ( start ), int ( end ) + 1 ) <TAB> <TAB> <TAB> for episode in split_anime ( anime, episode_grammar ) : <TAB> <TAB> <TAB> <TAB> episodes. append ( episode ) <TAB> <TAB> else : <TAB> <TAB> <TAB> from anime_downloader. sites. anime import AnimeEpisode <TAB> <TAB> <TAB> ep = [ x for x in anime. _episode_urls if x [ 0 ] == int ( grammar ) ] [ 0 ] <TAB> <TAB> <TAB> ep_cls = AnimeEpisode. subclasses [ anime. sitename ] <TAB> <TAB> <TAB> episodes. append ( ep_cls ( ep [ 1 ], parent = anime, ep_no = ep [ 0 ] ) ) <TAB> return episodes",False,':' in episode_grammar,grammar,0.6632068157196045
|
||
|
1212,"def parse_messages ( self, analyzer_result ) : <TAB> """"""Parse the given analyzer result."""""" <TAB> if not os. path. exists ( analyzer_result ) : <TAB> <TAB> LOG. error ( ""Report file does not exist: %s"", analyzer_result ) <TAB> <TAB> return <TAB> try : <TAB> <TAB> with open ( analyzer_result, ""r"", encoding = ""utf-8"", errors = ""ignore"" ) as report_f : <TAB> <TAB> <TAB> reports = json. load ( report_f ) <TAB> except ( IOError, json. decoder. JSONDecodeError ) : <TAB> <TAB> LOG. error ( <TAB> <TAB> <TAB> ""Failed to parse the given analyzer result '%s'. Please "" <TAB> <TAB> <TAB> ""give a valid json file generated by Pylint."", <TAB> <TAB> <TAB> analyzer_result, <TAB> <TAB> ) <TAB> <TAB> return <TAB> for report in reports : <TAB> <TAB> file_path = os. path. join ( os. path. dirname ( analyzer_result ), report. get ( ""path"" ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> LOG. warning ( ""Source file does not exists: %s"", file_path ) <TAB> <TAB> <TAB> continue <TAB> <TAB> message = self. __parse_report ( report, file_path ) <TAB> <TAB> if message : <TAB> <TAB> <TAB> self. messages. append ( message ) <TAB> return self. messages",True,not os.path.exists(file_path),not os.path.exists(file_path),0.6452673673629761
|
||
|
1213,"def computeResultAndTermination ( obj, result, previousResult ) : <TAB> possible_overall_result = result <TAB> terminate = False <TAB> if result == FAILURE : <TAB> <TAB> if not obj. flunkOnFailure : <TAB> <TAB> <TAB> possible_overall_result = SUCCESS <TAB> <TAB> if obj. warnOnFailure : <TAB> <TAB> <TAB> possible_overall_result = WARNINGS <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> possible_overall_result = FAILURE <TAB> <TAB> if obj. haltOnFailure : <TAB> <TAB> <TAB> terminate = True <TAB> elif result == WARNINGS : <TAB> <TAB> if not obj. warnOnWarnings : <TAB> <TAB> <TAB> possible_overall_result = SUCCESS <TAB> <TAB> else : <TAB> <TAB> <TAB> possible_overall_result = WARNINGS <TAB> <TAB> if obj. flunkOnWarnings : <TAB> <TAB> <TAB> possible_overall_result = FAILURE <TAB> elif result in ( EXCEPTION, RETRY, CANCELLED ) : <TAB> <TAB> terminate = True <TAB> result = worst_status ( previousResult, possible_overall_result ) <TAB> return result, terminate",False,obj.flunkOnFailure,result == SUCCESS,0.6667091250419617
|
||
|
1214,"def parse ( self ) : <TAB> rargs = list ( self. args ) <TAB> pos = 0 <TAB> while pos < len ( rargs ) : <TAB> <TAB> arg = rargs [ pos ] <TAB> <TAB> if arg == ""--"" : <TAB> <TAB> <TAB> self. passthrough = "" "". join ( rargs [ pos : ] ) <TAB> <TAB> <TAB> break <TAB> <TAB> elif arg [ 0 ] == ""-"" : <TAB> <TAB> <TAB> if arg [ 1 ] == ""-"" : <TAB> <TAB> <TAB> <TAB> self. process_long_opt ( arg [ 2 : ] ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> value = None <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> value = rargs [ pos + 1 ] <TAB> <TAB> <TAB> <TAB> <TAB> pos += 1 <TAB> <TAB> <TAB> <TAB> self. process_short_opt ( arg [ 1 : ], value ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. values. append ( arg ) <TAB> <TAB> pos += 1",False,len(rargs) > pos + 1 and rargs[pos + 1][0] != '-',rargs[pos] > 0,0.657852292060852
|
||
|
1215,"def _get_argument ( self, name ) : <TAB> <TAB> i = 0 <TAB> end = len ( name ) <TAB> while i < end : <TAB> <TAB> c = name [ i ] <TAB> <TAB> if c == ""["" or c == ""."" : <TAB> <TAB> <TAB> break <TAB> <TAB> i += 1 <TAB> empty = not i <TAB> if empty : <TAB> <TAB> index = - 1 <TAB> else : <TAB> <TAB> index, stop = _parse_int ( name, 0, i ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> index = - 1 <TAB> use_numeric = empty or index!= - 1 <TAB> if self. auto_numbering_state == self. ANS_INIT and use_numeric : <TAB> <TAB> if empty : <TAB> <TAB> <TAB> self. auto_numbering_state = self. ANS_AUTO <TAB> <TAB> else : <TAB> <TAB> <TAB> self. auto_numbering_state = self. ANS_MANUAL <TAB> if use_numeric : <TAB> <TAB> if self. auto_numbering_state == self. ANS_MANUAL : <TAB> <TAB> <TAB> if empty : <TAB> <TAB> <TAB> <TAB> msg = ""switching from manual to automatic numbering"" <TAB> <TAB> <TAB> <TAB> raise ValueError ( msg ) <TAB> <TAB> elif not empty : <TAB> <TAB> <TAB> msg = ""switching from automatic to manual numbering"" <TAB> <TAB> <TAB> raise ValueError ( msg ) <TAB> if empty : <TAB> <TAB> index = self. auto_numbering <TAB> <TAB> self. auto_numbering += 1 <TAB> if index == - 1 : <TAB> <TAB> kwarg = name [ : i ] <TAB> <TAB> arg_key = kwarg <TAB> <TAB> try : <TAB> <TAB> <TAB> w_arg = self. kwargs [ arg_key ] <TAB> <TAB> except KeyError : <TAB> <TAB> <TAB> raise KeyError ( arg_key ) <TAB",False,stop != i,stop == False,0.689253568649292
|
||
|
1216,"def get_search_results ( soup ) : <TAB> """"""Returns a list of dictionaries containing each search result."""""" <TAB> search_results = [ ] <TAB> for result in soup. find_all ( ""div"", class_ = ""question-summary search-result"" ) : <TAB> <TAB> title_container = result. find_all ( ""div"", class_ = ""result-link"" ) [ 0 ]. find_all ( ""a"" ) [ <TAB> <TAB> <TAB> 0 <TAB> <TAB> ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> answer_count = int ( <TAB> <TAB> <TAB> <TAB> result. find_all ( ""div"", class_ = ""status answered"" ) [ 0 ] <TAB> <TAB> <TAB> <TAB>. find_all ( ""strong"" ) [ 0 ] <TAB> <TAB> <TAB> <TAB>. text <TAB> <TAB> <TAB> ) <TAB> <TAB> elif ( <TAB> <TAB> <TAB> result. find_all ( ""div"", class_ = ""status answered-accepted"" )!= [ ] <TAB> <TAB> ) : <TAB> <TAB> <TAB> answer_count = int ( <TAB> <TAB> <TAB> <TAB> result. find_all ( ""div"", class_ = ""status answered-accepted"" ) [ 0 ] <TAB> <TAB> <TAB> <TAB>. find_all ( ""strong"" ) [ 0 ] <TAB> <TAB> <TAB> <TAB>. text <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> answer_count = 0 <TAB> <TAB> search_results. append ( <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> ""Title"" : title_container [ ""title"" ], <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""Answers"" : answer_count, <TAB> <TAB> <TAB> <TAB> ""URL"" : SO_URL + title_",False,"result.find_all('div', class_='status answered') != []","result.find_all('h', class_)",0.6556181311607361
|
||
|
1217,"def _start_modules ( self ) : <TAB> if self. available_slots : <TAB> <TAB> non_started_executors = [ <TAB> <TAB> <TAB> e for e in self. executors if e not in self. started_modules <TAB> <TAB> ] <TAB> <TAB> for executor in non_started_executors : <TAB> <TAB> <TAB> self. engine. logging_level_up ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> executor. startup ( ) <TAB> <TAB> <TAB> <TAB> self. started_modules. append ( executor ) <TAB> <TAB> <TAB> <TAB> self. available_slots -= 1 <TAB> <TAB> <TAB> <TAB> msg = ""Starting execution: %s, rest of available slots: %s"" <TAB> <TAB> <TAB> <TAB> self. log. debug ( msg, executor, self. available_slots ) <TAB> <TAB> <TAB> <TAB> if not self. available_slots : <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> self. engine. logging_level_down ( )",False,time.time() >= self.start_time + executor.delay,self.available_slots > 0,0.6526844501495361
|
||
|
1218,"def update ( self, space_id ) : <TAB> form = SpaceForm ( request. form, csrf = False ) <TAB> form. set_id ( space_id ) <TAB> if form. validate_on_submit ( ) : <TAB> <TAB> space = SpaceModel ( ). get_by_id ( space_id ) <TAB> <TAB> data = form. form2dict ( ) <TAB> <TAB> current_app. logger. info ( data ) <TAB> <TAB> member_model = MemberModel ( group_id = space_id ) <TAB> <TAB> old_owner = space. user_id <TAB> <TAB> new_owner = data [ ""user_id"" ] <TAB> <TAB> <TAB> <TAB> space. update ( data ) <TAB> <TAB> if str ( old_owner )!= str ( new_owner ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> member_model. change_owner ( old_owner, new_owner ) <TAB> <TAB> <TAB> <TAB> current_owner = { ""user_id"" : new_owner, ""role"" : OWNER } <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> members = json. loads ( request. form [ ""members"" ] ) <TAB> <TAB> <TAB> members. append ( current_owner ) <TAB> <TAB> <TAB> member_model. update_group ( members = members ) <TAB> <TAB> return self. render_json ( data = space. item ( ) ) <TAB> else : <TAB> <TAB> return self. render_error ( code = Code. form_error, message = form. errors )",True,'members' in request.form,'members' in request.form,0.6528851985931396
|
||
|
1219,"def sort_and_validate ( self ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> assert len ( self. data ) > 0 <TAB> except AssertionError : <TAB> <TAB> logger. critical ( ""No data series found in plot"" ) <TAB> <TAB> raise <TAB> <TAB> l = - 1 <TAB> reference_x = None <TAB> <TAB> for series_name, data_points in self. data. iteritems ( ) : <TAB> <TAB> if l > 0 : <TAB> <TAB> <TAB> assert l == len ( data_points ) <TAB> <TAB> else : <TAB> <TAB> <TAB> l = len ( data_points ) <TAB> <TAB> <TAB> <TAB> data_points. sort ( key = itemgetter ( 0 ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> assert reference_x == [ seq [ 0 ] for seq in data_points ] <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> reference_x = [ seq [ 0 ] for seq in data_points ]",False,reference_x,reference_x is not None,0.6662988662719727
|
||
|
1220,"def getBranches ( self ) : <TAB> returned = [ ] <TAB> for git_branch_line in self. _executeGitCommandAssertSuccess ( ""branch"" ). stdout : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> git_branch_line = git_branch_line [ 1 : ] <TAB> <TAB> git_branch_line = git_branch_line. strip ( ) <TAB> <TAB> if BRANCH_ALIAS_MARKER in git_branch_line : <TAB> <TAB> <TAB> alias_name, aliased = git_branch_line. split ( BRANCH_ALIAS_MARKER ) <TAB> <TAB> <TAB> returned. append ( branch. LocalBranchAlias ( self, alias_name, aliased ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> returned. append ( branch. LocalBranch ( self, git_branch_line ) ) <TAB> return returned",False,git_branch_line.startswith('*'),git_branch_line.startswith('/'),0.6466782689094543
|
||
|
1221,"def formContourList ( self, prepared ) : <TAB> <TAB> cList = [ ] <TAB> <TAB> if prepared. hasPartLikeStreams ( ) : <TAB> <TAB> parts = prepared. parts <TAB> else : <TAB> <TAB> parts = [ prepared ] <TAB> for p in parts : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> post = p. findConsecutiveNotes ( <TAB> <TAB> <TAB> skipRests = True, skipChords = False, skipGaps = True, noNone = True <TAB> <TAB> ) <TAB> <TAB> for i, n in enumerate ( post ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> iNext = i + 1 <TAB> <TAB> <TAB> <TAB> nNext = post [ iNext ] <TAB> <TAB> <TAB> <TAB> if n. isChord : <TAB> <TAB> <TAB> <TAB> <TAB> ps = n. sortDiatonicAscending ( ). pitches [ - 1 ]. midi <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> ps = n. pitch. midi <TAB> <TAB> <TAB> <TAB> if nNext. isChord : <TAB> <TAB> <TAB> <TAB> <TAB> psNext = nNext. sortDiatonicAscending ( ). pitches [ - 1 ]. midi <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> psNext = nNext. pitch. midi <TAB> <TAB> <TAB> <TAB> cList. append ( psNext - ps ) <TAB> <TAB> return cList",False,i < len(post) - 1,n.hasThasing,0.6607534885406494
|
||
|
1222,"def _pkg_status ( self, info, filepath ) : <TAB> if not os. path. exists ( filepath ) : <TAB> <TAB> return self. NOT_INSTALLED <TAB> <TAB> try : <TAB> <TAB> filestat = os. stat ( filepath ) <TAB> except OSError : <TAB> <TAB> return self. NOT_INSTALLED <TAB> if filestat. st_size!= int ( info. size ) : <TAB> <TAB> return self. STALE <TAB> <TAB> <TAB> if filepath. endswith ( "".zip"" ) : <TAB> <TAB> unzipdir = filepath [ : - 4 ] <TAB> <TAB> if not os. path. exists ( unzipdir ) : <TAB> <TAB> <TAB> return self. INSTALLED <TAB> <TAB> if not os. path. isdir ( unzipdir ) : <TAB> <TAB> <TAB> return self. STALE <TAB> <TAB> unzipped_size = sum ( <TAB> <TAB> <TAB> os. stat ( os. path. join ( d, f ) ). st_size <TAB> <TAB> <TAB> for d, _, files in os. walk ( unzipdir ) <TAB> <TAB> <TAB> for f in files <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return self. STALE <TAB> <TAB> return self. INSTALLED",False,unzipped_size != info.unzipped_size,info.size > 0 and info.size > 0,0.6507558822631836
|
||
|
1223,"def test_events ( self ) : <TAB> """"""Tests that events are correctly yielded"""""" <TAB> from pynput. mouse import Button, Events <TAB> with Events ( ) as events : <TAB> <TAB> self. notify ( ""Move the mouse"" ) <TAB> <TAB> for event in events : <TAB> <TAB> <TAB> if isinstance ( event, Events. Move ) : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> self. notify ( ""Press the left mouse button"" ) <TAB> <TAB> for event in events : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> self. notify ( ""Press the right mouse button"" ) <TAB> <TAB> for event in events : <TAB> <TAB> <TAB> if isinstance ( event, Events. Click ) and event. button == Button. right : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> self. notify ( ""Scroll the mouse"" ) <TAB> <TAB> for event in events : <TAB> <TAB> <TAB> if isinstance ( event, Events. Scroll ) : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> self. notify ( ""Do not touch the mouse"", delay = 2.0 ) <TAB> <TAB> self. assertIsNone ( events. get ( 1.0 ) )",False,"isinstance(event, Events.Click) and event.button == Button.left",event.button == Button.left,0.6537449359893799
|
||
|
1224,"def _add_resource_group ( obj ) : <TAB> if isinstance ( obj, list ) : <TAB> <TAB> for array_item in obj : <TAB> <TAB> <TAB> _add_resource_group ( array_item ) <TAB> elif isinstance ( obj, dict ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> if obj [ ""id"" ] : <TAB> <TAB> <TAB> <TAB> <TAB> obj [ ""resourceGroup"" ] = _parse_id ( obj [ ""id"" ] ) [ ""resource-group"" ] <TAB> <TAB> except ( KeyError, IndexError, TypeError ) : <TAB> <TAB> <TAB> pass <TAB> <TAB> for item_key in obj : <TAB> <TAB> <TAB> if item_key!= ""sourceVault"" : <TAB> <TAB> <TAB> <TAB> _add_resource_group ( obj [ item_key ] )",False,'resourcegroup' not in [x.lower() for x in obj.keys()],obj[0] != 'sourceVault',0.6506759524345398
|
||
|
1225,"def _pivot_res_data ( self, res_data ) : <TAB> <TAB> <TAB> res_data_pivot = { } <TAB> for blobname, toplevelnames_from_ilk in res_data. iteritems ( ) : <TAB> <TAB> for ilk, toplevelnames in toplevelnames_from_ilk. iteritems ( ) : <TAB> <TAB> <TAB> pivot_bft = res_data_pivot. setdefault ( ilk, { } ) <TAB> <TAB> <TAB> for toplevelname in toplevelnames : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> pivot_bft [ toplevelname ] = set ( [ blobname ] ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> pivot_bft [ toplevelname ]. add ( blobname ) <TAB> return res_data_pivot",True,toplevelname not in pivot_bft,toplevelname not in pivot_bft,0.661950945854187
|
||
|
1226,"def _compare_dirs ( self, dir1 : str, dir2 : str ) -> List [ str ] : <TAB> <TAB> <TAB> diff = [ ] <TAB> for root, dirs, files in os. walk ( dir1 ) : <TAB> <TAB> for file_ in files : <TAB> <TAB> <TAB> path = os. path. join ( root, file_ ) <TAB> <TAB> <TAB> target_path = os. path. join ( dir2, os. path. split ( path ) [ - 1 ] ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> diff. append ( file_ ) <TAB> return diff",False,not os.path.exists(target_path),os.path.exists(target_path),0.6456561088562012
|
||
|
1227,"def test_object_role_JT_attach ( <TAB> rando, <TAB> job_template, <TAB> workflow_job_template, <TAB> inventory_source, <TAB> notification_template, <TAB> res_role, <TAB> expect, ) : <TAB> nt_organization = Organization. objects. create ( <TAB> <TAB> name = ""organization just for the notification template"" <TAB> ) <TAB> nt_organization. notification_admin_role. members. add ( rando ) <TAB> notification_template. organization = nt_organization <TAB> notification_template. save ( ) <TAB> kwargs = dict ( <TAB> <TAB> sub_obj = notification_template, <TAB> <TAB> relationship = ""notification_templates_success"", <TAB> <TAB> data = { ""id"" : notification_template. id }, <TAB> ) <TAB> permissions = { } <TAB> expected_permissions = { } <TAB> for resource in ( job_template, workflow_job_template, inventory_source ) : <TAB> <TAB> permission_resource = resource <TAB> <TAB> if resource == inventory_source : <TAB> <TAB> <TAB> permission_resource = inventory_source. inventory <TAB> <TAB> model_name = resource. __class__. __name__ <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if res_role is not None : <TAB> <TAB> <TAB> <TAB> getattr ( permission_resource, res_role ). members. add ( rando ) <TAB> <TAB> <TAB> permissions [ model_name ] = rando. can_access ( <TAB> <TAB> <TAB> <TAB> resource. __class__, ""attach"", resource, ** kwargs <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> expected_permissions [ model_name ] = expect <TAB> <TAB> else : <TAB> <TAB> <TAB> permissions [ model_name ] = None <TAB> <TAB> <TAB> expected_permissions [ model_name ] = None <TAB> assert permissions == expected_permissions",False,"res_role is None or hasattr(permission_resource, res_role)",model_name in permissions,0.6503365635871887
|
||
|
1228,"def get_dict ( self ) : <TAB> result = online. bits_to_dict ( self. register ) <TAB> if self. mintime == 65535 : <TAB> <TAB> result. update ( { ""mintime"" : ""MAX"" } ) <TAB> else : <TAB> <TAB> result. update ( { ""mintime"" : ""{:.3f}s"". format ( float ( self. mintime ) / 1000 ) } ) <TAB> if result [ ""ntp"" ] : <TAB> <TAB> if self. offset in ( 32767, - 32768 ) : <TAB> <TAB> <TAB> word = ""MAX"" <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> word = ""MIN"" <TAB> <TAB> <TAB> result. update ( { ""ntp-offset"" : word } ) <TAB> <TAB> else : <TAB> <TAB> <TAB> result. update ( <TAB> <TAB> <TAB> <TAB> { ""ntp-offset"" : ""{:.3f}s"". format ( float ( self. offset ) / 1000000 ) } <TAB> <TAB> <TAB> ) <TAB> else : <TAB> <TAB> result. update ( { ""ntp-offset"" : ""N/A"" } ) <TAB> return result",False,self.offset < 0,self.offset == -1,0.6579854488372803
|
||
|
1229,"def _blend ( x, y ) : <TAB> """"""Implements the ""blend"" strategy for `deep_merge`."""""" <TAB> if isinstance ( x, ( dict, OrderedDict ) ) : <TAB> <TAB> if not isinstance ( y, ( dict, OrderedDict ) ) : <TAB> <TAB> <TAB> return y <TAB> <TAB> return _merge ( x, y, recursion_func = _blend ) <TAB> if isinstance ( x, ( list, tuple ) ) : <TAB> <TAB> if not isinstance ( y, ( list, tuple ) ) : <TAB> <TAB> <TAB> return y <TAB> <TAB> result = [ _blend ( * i ) for i in zip ( x, y ) ] <TAB> <TAB> if len ( x ) > len ( y ) : <TAB> <TAB> <TAB> result += x [ len ( y ) : ] <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> result += y [ len ( x ) : ] <TAB> <TAB> return result <TAB> return y",False,len(x) < len(y),len(y) > len(x),0.6478318572044373
|
||
|
1230,"def do_shorts ( <TAB> opts : List [ Tuple [ str, str ] ], optstring : str, shortopts : str, args : List [ str ] ) -> Tuple [ List [ Tuple [ str, str ] ], List [ str ] ] : <TAB> while optstring!= """" : <TAB> <TAB> opt, optstring = optstring [ 0 ], optstring [ 1 : ] <TAB> <TAB> if short_has_arg ( opt, shortopts ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> if not args : <TAB> <TAB> <TAB> <TAB> <TAB> raise GetoptError ( ""option -%s requires argument"" % opt, opt ) <TAB> <TAB> <TAB> <TAB> optstring, args = args [ 0 ], args [ 1 : ] <TAB> <TAB> <TAB> optarg, optstring = optstring, """" <TAB> <TAB> else : <TAB> <TAB> <TAB> optarg = """" <TAB> <TAB> opts. append ( ( ""-"" + opt, optarg ) ) <TAB> return opts, args",False,optstring == '',optstring != optstring,0.6816678047180176
|
||
|
1231,"def update_user ( self ) : <TAB> <TAB> user = frappe. get_doc ( ""User"", self. user_id ) <TAB> user. flags. ignore_permissions = True <TAB> if ""Employee"" not in user. get ( ""roles"" ) : <TAB> <TAB> user. append_roles ( ""Employee"" ) <TAB> <TAB> if self. employee_name and not ( user. first_name and user. last_name ) : <TAB> <TAB> employee_name = self. employee_name. split ( "" "" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> user. last_name = "" "". join ( employee_name [ 2 : ] ) <TAB> <TAB> <TAB> user. middle_name = employee_name [ 1 ] <TAB> <TAB> elif len ( employee_name ) == 2 : <TAB> <TAB> <TAB> user. last_name = employee_name [ 1 ] <TAB> <TAB> user. first_name = employee_name [ 0 ] <TAB> if self. date_of_birth : <TAB> <TAB> user. birth_date = self. date_of_birth <TAB> if self. gender : <TAB> <TAB> user. gender = self. gender <TAB> if self. image : <TAB> <TAB> if not user. user_image : <TAB> <TAB> <TAB> user. user_image = self. image <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> frappe. get_doc ( <TAB> <TAB> <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""doctype"" : ""File"", <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""file_name"" : self. image, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""attached_to_doctype"" : ""User"", <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""attached_to_name"" : self. user_id, <",False,len(employee_name) >= 3,len(employee_name) > 2,0.6578024625778198
|
||
|
1232,"def _update_scale ( self, skip ) : <TAB> if self. dynamic_loss_scale : <TAB> <TAB> prev_scale = self. cur_scale <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. cur_scale = max ( <TAB> <TAB> <TAB> <TAB> self. cur_scale / self. scale_factor, self. min_loss_scale <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> self. last_overflow_iter = self. cur_iter <TAB> <TAB> <TAB> if self. verbose : <TAB> <TAB> <TAB> <TAB> logger. info ( ""Grad overflow on iteration: %s"", self. cur_iter ) <TAB> <TAB> <TAB> <TAB> logger. info ( <TAB> <TAB> <TAB> <TAB> <TAB> f""Reducing dynamic loss scale from {prev_scale} to {self.cur_scale}"" <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> stable_interval = ( self. cur_iter - self. last_overflow_iter ) - 1 <TAB> <TAB> <TAB> if ( stable_interval > 0 ) and ( stable_interval % self. scale_window == 0 ) : <TAB> <TAB> <TAB> <TAB> self. cur_scale *= self. scale_factor <TAB> <TAB> <TAB> <TAB> if self. verbose : <TAB> <TAB> <TAB> <TAB> <TAB> logger. info ( f""No Grad overflow for {self.scale_window} iterations"" ) <TAB> <TAB> <TAB> <TAB> <TAB> logger. info ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> f""Increasing dynamic loss scale from {prev_scale} to {self.cur_scale}"" <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> logger. info ( ""Grad overflow on iteration %s"", self. cur_iter ) <",True,skip,skip,0.6807229518890381
|
||
|
1233,"def __annotations_bytes ( self ) : <TAB> if self. annotations : <TAB> <TAB> a = [ ] <TAB> <TAB> for k, v in self. annotations. items ( ) : <TAB> <TAB> <TAB> if len ( k )!= 4 : <TAB> <TAB> <TAB> <TAB> raise errors. ProtocolError ( ""annotation key must be of length 4"" ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> k = k. encode ( ""ASCII"" ) <TAB> <TAB> <TAB> a. append ( struct. pack ( ""!4sH"", k, len ( v ) ) ) <TAB> <TAB> <TAB> a. append ( v ) <TAB> <TAB> return b"""". join ( a ) <TAB> return b""""",False,"sys.version_info >= (3, 0)",k in self.data,0.6506531238555908
|
||
|
1234,"def check_output_command ( file_path, head = None, tail = None ) : <TAB> """"""call check_output command to read content from a file"""""" <TAB> if os. path. exists ( file_path ) : <TAB> <TAB> if sys. platform == ""win32"" : <TAB> <TAB> <TAB> cmds = [ ""powershell.exe"", ""type"", file_path ] <TAB> <TAB> <TAB> if head : <TAB> <TAB> <TAB> <TAB> cmds += [ ""|"", ""select"", ""-first"", str ( head ) ] <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> cmds += [ ""|"", ""select"", ""-last"", str ( tail ) ] <TAB> <TAB> <TAB> return check_output ( cmds, shell = True ). decode ( ""utf-8"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> cmds = [ ""cat"", file_path ] <TAB> <TAB> <TAB> if head : <TAB> <TAB> <TAB> <TAB> cmds = [ ""head"", ""-"" + str ( head ), file_path ] <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> cmds = [ ""tail"", ""-"" + str ( tail ), file_path ] <TAB> <TAB> <TAB> return check_output ( cmds, shell = False ). decode ( ""utf-8"" ) <TAB> else : <TAB> <TAB> print_error ( ""{0} does not exist!"". format ( file_path ) ) <TAB> <TAB> exit ( 1 )",True,tail,tail,0.725208044052124
|
||
|
1235,"def show_help ( error = None, topic = None, parser = None ) : <TAB> """"""Display an error message, or the named topic."""""" <TAB> assert error or topic or parser <TAB> program_path = sys. argv [ 0 ] <TAB> if program_path. endswith ( os. path. sep + ""__main__.py"" ) : <TAB> <TAB> <TAB> <TAB> program_path = os. path. dirname ( program_path ) <TAB> program_name = os. path. basename ( program_path ) <TAB> if env. WINDOWS : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> auto_suffix = ""-script.py"" <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> program_name = program_name [ : - len ( auto_suffix ) ] <TAB> help_params = dict ( coverage. __dict__ ) <TAB> help_params [ ""program_name"" ] = program_name <TAB> if CTracer is not None : <TAB> <TAB> help_params [ ""extension_modifier"" ] = ""with C extension"" <TAB> else : <TAB> <TAB> help_params [ ""extension_modifier"" ] = ""without C extension"" <TAB> if error : <TAB> <TAB> print ( error, file = sys. stderr ) <TAB> <TAB> print ( ""Use '%s help' for help."" % ( program_name, ), file = sys. stderr ) <TAB> elif parser : <TAB> <TAB> print ( parser. format_help ( ). strip ( ) ) <TAB> <TAB> print ( ) <TAB> else : <TAB> <TAB> help_msg = textwrap. dedent ( HELP_TOPICS. get ( topic, """" ) ). strip ( ) <TAB> <TAB> if help_msg : <TAB> <TAB> <TAB> print ( help_msg. format ( ** help_params ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> print ( ""Don't know topic %r"" % topic ) <TAB> print ( ""Full documentation is at {__url__}"". format ( ** help_",False,program_name.endswith(auto_suffix),program_name.startswith(auto_suffix),0.6458815336227417
|
||
|
1236,"def generate_app_composes ( ) : <TAB> <TAB> composes = [ ] <TAB> for app in pathlib. Path ( config. APPS_PATH ). iterdir ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> zip_ref = zipfile. ZipFile ( app, ""r"" ) <TAB> <TAB> <TAB> <TAB> zip_ref. extractall ( config. APPS_PATH ) <TAB> <TAB> <TAB> <TAB> zip_ref. close ( ) <TAB> <TAB> <TAB> <TAB> os. remove ( app ) <TAB> <TAB> <TAB> except Exception as e : <TAB> <TAB> <TAB> <TAB> logger. error ( f""Zip error: {e}"" ) <TAB> <TAB> <TAB> <TAB> continue <TAB> for app in pathlib. Path ( config. APPS_PATH ). iterdir ( ) : <TAB> <TAB> <TAB> <TAB> if app. is_dir ( ) and not re. fullmatch ( r""(__.*)"", app. name ) : <TAB> <TAB> <TAB> for version in app. iterdir ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if re. fullmatch ( r""((\d\.?)+)"", version. name ) : <TAB> <TAB> <TAB> <TAB> <TAB> composes. append ( compose_from_app ( version, f""app_{app.name}"" ) ) <TAB> <TAB> <TAB> <TAB> logger. info ( f""Generated compose for {app.name} version: {version.name}"" ) <TAB> return composes",False,not app.is_dir(),app.is_dir(),0.6518459320068359
|
||
|
1237,"def async_trace ( * fn_args, ** fn_kwargs ) : <TAB> <TAB> span_gen = _span_generator ( <TAB> <TAB> scope, sub_scope, trace_kwargs, fn_args = fn_args, fn_kwargs = fn_kwargs <TAB> ) <TAB> <TAB> next ( span_gen ) <TAB> completed = False <TAB> <TAB> <TAB> try : <TAB> <TAB> result = await fn ( * fn_args, ** fn_kwargs ) <TAB> <TAB> completed = True <TAB> <TAB> try : <TAB> <TAB> <TAB> span_gen. send ( TracedFunctionReturned ( result ) ) <TAB> <TAB> except StopIteration : <TAB> <TAB> <TAB> pass <TAB> <TAB> return result <TAB> except : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> error_type, error_value, traceback = sys. exc_info ( ) <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> span_gen. send ( TracedFunctionThrew ( error_type, error_value, traceback ) ) <TAB> <TAB> <TAB> except StopIteration : <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> raise",True,not completed,not completed,0.7020494937896729
|
||
|
1238,"def check_bounds ( geometry ) : <TAB> if isinstance ( geometry [ 0 ], ( list, tuple ) ) : <TAB> <TAB> return list ( map ( check_bounds, geometry ) ) <TAB> else : <TAB> <TAB> if geometry [ 0 ] > 180 or geometry [ 0 ] < - 180 : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""Longitude is out of bounds, check your JSON format or data"" <TAB> <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""Latitude is out of bounds, check your JSON format or data"" <TAB> <TAB> <TAB> )",False,geometry[1] > 90 or geometry[1] < -90,geometry[0] > 90 or geometry[0] < -90,0.6568539142608643
|
||
|
1239,"def openPage ( self, name, ** args ) : <TAB> if name. strip ( ) in self. plugins. keys ( ) : <TAB> <TAB> if self. plugins [ name ]. isWebPlugin ( ) : <TAB> <TAB> <TAB> pageInfo = self. plugins [ name ]. getPage ( ** args ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> page, content = pageInfo <TAB> <TAB> <TAB> <TAB> if page : <TAB> <TAB> <TAB> <TAB> <TAB> return ( ""plugins/%s"" % page, content ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> return None <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> return ( ""error.html"", { ""status"" : { ""except"" : ""plugin-page-missing"" } } ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return ( ""error.html"", { ""status"" : { ""except"" : ""plugin-not-webplugin"" } } ) <TAB> return ( ""error.html"", { ""status"" : { ""except"" : ""plugin-not-loaded"" } } )",False,type(pageInfo) == tuple,pageInfo,0.6535598039627075
|
||
|
1240,"def visit_UnaryOp ( self, node ) : <TAB> if isinstance ( node. op, ast. USub ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return ""-{}"". format ( self. visit ( node. operand ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return ""-({})"". format ( self. visit ( node. operand ) ) <TAB> if isinstance ( node. op, ast. Invert ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return ""~{}"". format ( self. visit ( node. operand ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return ""~({})"". format ( self. visit ( node. operand ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> raise ValueError ( ""Unary op not supported: {}"". format ( node. op ) )",False,"isinstance(node.operand, (ast.Name, ast.Num))","isinstance(node.op, ast.Call) and node.op in ['+', '-', '*']",0.6477424502372742
|
||
|
1241,"def read_input ( self ) : <TAB> c = self. stdscr. getch ( ) <TAB> if is_printable_chr ( c ) : <TAB> <TAB> if chr ( c ) == ""Q"" : <TAB> <TAB> <TAB> component. get ( ""ConsoleUI"" ). quit ( ) <TAB> <TAB> elif self. inlist : <TAB> <TAB> <TAB> if chr ( c ) == ""q"" : <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> elif chr ( c ) == ""D"" : <TAB> <TAB> <TAB> <TAB> host_id = self. popup. current_selection ( ) [ 1 ] <TAB> <TAB> <TAB> <TAB> self. delete_host ( host_id ) <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> self. add_popup ( ) <TAB> <TAB> <TAB> <TAB> return <TAB> if self. popup : <TAB> <TAB> if self. popup. handle_read ( c ) and self. popup. closed ( ) : <TAB> <TAB> <TAB> self. pop_popup ( ) <TAB> <TAB> self. refresh ( )",False,chr(c) == 'a',chr(c) == 'C',0.6524997353553772
|
||
|
1242,"def _get_xarrays ( self, element, coords, xtype, ytype ) : <TAB> x, y = element. kdims <TAB> dims = [ y. name, x. name ] <TAB> irregular = any ( element. interface. irregular ( element, d ) for d in dims ) <TAB> if irregular : <TAB> <TAB> coord_dict = { x. name : ( ( ""y"", ""x"" ), coords [ 0 ] ), y. name : ( ( ""y"", ""x"" ), coords [ 1 ] ) } <TAB> else : <TAB> <TAB> coord_dict = { x. name : coords [ 0 ], y. name : coords [ 1 ] } <TAB> arrays = { } <TAB> for vd in element. vdims : <TAB> <TAB> if element. interface is XArrayInterface : <TAB> <TAB> <TAB> xarr = element. data [ vd. name ] <TAB> <TAB> <TAB> if ""datetime"" in ( xtype, ytype ) : <TAB> <TAB> <TAB> <TAB> xarr = xarr. copy ( ) <TAB> <TAB> <TAB> if dims!= xarr. dims and not irregular : <TAB> <TAB> <TAB> <TAB> xarr = xarr. transpose ( * dims ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> arr = element. dimension_values ( vd, flat = False ) <TAB> <TAB> <TAB> xarr = xr. DataArray ( arr, coords = coord_dict, dims = [ ""y"", ""x"" ] ) <TAB> <TAB> else : <TAB> <TAB> <TAB> arr = element. dimension_values ( vd, flat = False ) <TAB> <TAB> <TAB> xarr = xr. DataArray ( arr, coords = coord_dict, dims = dims ) <TAB> <TAB> if xtype == ""datetime"" : <TAB> <TAB> <TAB> xarr [ x. name ] = [ dt_to_int ( v, ""ns"" ) for v in xarr [ x. name ]. values ] <TAB> <TAB> if ytype == ""datetime"" : <TAB> <TAB> <",False,irregular,element.dimension_values is not None,0.6738534569740295
|
||
|
1243,"def __backgroundUpdate ( self ) : <TAB> selectedPaths = GafferSceneUI. ContextAlgo. getSelectedPaths ( Gaffer. Context. current ( ) ) <TAB> parameterInspectors = { } <TAB> for path in selectedPaths. paths ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> history = GafferScene. SceneAlgo. history ( <TAB> <TAB> <TAB> self. __sceneView [ ""in"" ] [ ""attributes"" ], path <TAB> <TAB> ) <TAB> <TAB> for attribute, group in self. __groups. items ( ) : <TAB> <TAB> <TAB> attributeHistory = GafferScene. SceneAlgo. attributeHistory ( <TAB> <TAB> <TAB> <TAB> history, attribute <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if attributeHistory is not None : <TAB> <TAB> <TAB> <TAB> for parameter in group. parameters ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> parameterInspectors. setdefault ( attribute, { } ). setdefault ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> parameter, [ ] <TAB> <TAB> <TAB> <TAB> <TAB> ). append ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> _ParameterInspector ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> attributeHistory, parameter, self. __sceneView. editScope ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> return parameterInspectors",False,not self.__sceneView['in'].exists(path),"path == '__sceneView[ ""in""] or path == '__sceneView[ ""in""]",0.65535968542099
|
||
|
1244,"def _wait_for_finish ( self ) -> PollExitResponse : <TAB> while True : <TAB> <TAB> if self. _backend : <TAB> <TAB> <TAB> poll_exit_resp = self. _backend. interface. communicate_poll_exit ( ) <TAB> <TAB> logger. info ( ""got exit ret: %s"", poll_exit_resp ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> done = poll_exit_resp. done <TAB> <TAB> <TAB> pusher_stats = poll_exit_resp. pusher_stats <TAB> <TAB> <TAB> if pusher_stats : <TAB> <TAB> <TAB> <TAB> self. _on_finish_progress ( pusher_stats, done ) <TAB> <TAB> <TAB> if done : <TAB> <TAB> <TAB> <TAB> return poll_exit_resp <TAB> <TAB> time. sleep ( 2 )",True,poll_exit_resp,poll_exit_resp,0.658441424369812
|
||
|
1245,"def convert ( installers, dest_dir, verbose ) : <TAB> require_pkgresources ( ""wheel convert"" ) <TAB> <TAB> from.. wininst2wheel import bdist_wininst2wheel <TAB> from.. egg2wheel import egg2wheel <TAB> for pat in installers : <TAB> <TAB> for installer in iglob ( pat ) : <TAB> <TAB> <TAB> if os. path. splitext ( installer ) [ 1 ] == "".egg"" : <TAB> <TAB> <TAB> <TAB> conv = egg2wheel <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> conv = bdist_wininst2wheel <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> sys. stdout. write ( ""{0}... "". format ( installer ) ) <TAB> <TAB> <TAB> <TAB> sys. stdout. flush ( ) <TAB> <TAB> <TAB> conv ( installer, dest_dir ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> sys. stdout. write ( ""OK\n"" )",True,verbose,verbose,0.6907249093055725
|
||
|
1246,"def __init__ ( <TAB> self, image_base_dir, anno_path, with_mask = True, dataset_filter = None, eval = False ) : <TAB> self. metas = [ ] <TAB> <TAB> <TAB> self. eval = eval <TAB> self. image_base_dir = image_base_dir <TAB> self. anno_path = anno_path <TAB> self. with_mask = with_mask <TAB> self. coco = COCO ( self. anno_path ) <TAB> self. get_image_annos ( ) <TAB> self. image_list = os. listdir ( self. image_base_dir ) <TAB> if dataset_filter!= None : <TAB> <TAB> filter_metas = [ ] <TAB> <TAB> for meta in self. metas : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> filter_metas. append ( meta ) <TAB> <TAB> self. metas = filter_metas",False,dataset_filter(meta) == True,dataset_filter.get(meta) != None,0.6530323028564453
|
||
|
1247,"def recarray2dict ( arr ) : <TAB> res = { } <TAB> tcds_types = [ time_cds_short, time_cds, time_cds_expanded ] <TAB> for dtuple in arr. dtype. descr : <TAB> <TAB> key = dtuple [ 0 ] <TAB> <TAB> ntype = dtuple [ 1 ] <TAB> <TAB> data = arr [ key ] <TAB> <TAB> if ntype in tcds_types : <TAB> <TAB> <TAB> if data. size > 1 : <TAB> <TAB> <TAB> <TAB> res [ key ] = np. array ( <TAB> <TAB> <TAB> <TAB> <TAB> [ timecds2datetime ( item ) for item in data. ravel ( ) ] <TAB> <TAB> <TAB> <TAB> ). reshape ( data. shape ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> res [ key ] = timecds2datetime ( data ) <TAB> <TAB> elif isinstance ( ntype, list ) : <TAB> <TAB> <TAB> res [ key ] = recarray2dict ( data ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if data. size == 1 : <TAB> <TAB> <TAB> <TAB> data = data [ 0 ] <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> data = data. decode ( ) <TAB> <TAB> <TAB> <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> <TAB> <TAB> data = data. split ( "":"" ) [ 0 ]. strip ( ) <TAB> <TAB> <TAB> <TAB> res [ key ] = data <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> res [ key ] = data. squeeze ( ) <TAB> return res",False,ntype[:2] == '|S',"isinstance(data, np.ndarray)",0.6625974178314209
|
||
|
1248,"def __patch_houdini_env ( self, local_path, mode = ""change"" ) : <TAB> filepath = HOUDINI_ENV <TAB> if platform. system ( ) == ""Windows"" : <TAB> <TAB> sep = "";"" <TAB> <TAB> quote_char = """" <TAB> else : <TAB> <TAB> sep = "":"" <TAB> <TAB> quote_char = '""' <TAB> to_write = [ ] <TAB> has_houdini_path_defined = False <TAB> with open ( filepath, ""r"" ) as fp : <TAB> <TAB> skip_next_line = False <TAB> <TAB> skipped_lines = 0 <TAB> <TAB> for line in fp. readlines ( ) : <TAB> <TAB> <TAB> if skip_next_line : <TAB> <TAB> <TAB> <TAB> skipped_lines += 1 <TAB> <TAB> <TAB> <TAB> if skipped_lines == 3 : <TAB> <TAB> <TAB> <TAB> <TAB> skip_next_line = False <TAB> <TAB> <TAB> <TAB> <TAB> skipped_lines = 0 <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if ""# "" + self. repo_name. upper ( ) in line : <TAB> <TAB> <TAB> <TAB> skip_next_line = True <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> has_houdini_path_defined = True <TAB> <TAB> <TAB> to_write. append ( line ) <TAB> if to_write [ - 1 ] [ - 1 ]!= ""\n"" : <TAB> <TAB> to_write [ - 1 ] += ""\n"" <TAB> <TAB> to_write. append ( ""\n"" ) <TAB> if to_write [ - 1 ]!= ""\n"" : <TAB> <TAB> to_write. append ( ""\n"" ) <TAB> if mode == ""change"" : <TAB> <TAB> to_write. append ( ""# "" + self. repo_name. upper ( ) + ""\n"" ) <",False,'HOUDINI_PATH' in line,skip_next_line,0.6586650609970093
|
||
|
1249,"def _index_from_records ( self, recarr ) : <TAB> index = recarr. dtype. metadata [ ""index"" ] <TAB> if len ( index ) == 1 : <TAB> <TAB> rtn = Index ( np. copy ( recarr [ str ( index [ 0 ] ) ] ), name = index [ 0 ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> rtn = rtn. tz_localize ( ""UTC"" ). tz_convert ( recarr. dtype. metadata [ ""index_tz"" ] ) <TAB> else : <TAB> <TAB> level_arrays = [ ] <TAB> <TAB> index_tz = recarr. dtype. metadata. get ( ""index_tz"", [ ] ) <TAB> <TAB> for level_no, index_name in enumerate ( index ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> level = Index ( np. copy ( recarr [ str ( index_name ) ] ) ) <TAB> <TAB> <TAB> if level_no < len ( index_tz ) : <TAB> <TAB> <TAB> <TAB> tz = index_tz [ level_no ] <TAB> <TAB> <TAB> <TAB> if tz is not None : <TAB> <TAB> <TAB> <TAB> <TAB> if not isinstance ( level, DatetimeIndex ) and len ( level ) == 0 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> level = DatetimeIndex ( [ ], tz = tz ) <TAB> <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> level = level. tz_localize ( ""UTC"" ). tz_convert ( tz ) <TAB> <TAB> <TAB> level_arrays. append ( level ) <TAB> <TAB> rtn = MultiIndex. from_arrays ( level_arrays, names = index ) <TAB> return rtn",False,"isinstance(rtn, DatetimeIndex) and 'index_tz' in recarr.dtype.metadata",tz is not None,0.6531420946121216
|
||
|
1250,"def refresh ( self ) : <TAB> super ( ). refresh ( ) <TAB> name = self. settlement. get_component ( NamedComponent ). name <TAB> text = T ( ""Production overview of {settlement}"" ). format ( settlement = name ) <TAB> self. _gui. findChild ( name = ""headline"" ). text = text <TAB> forward_button = self. _gui. findChild ( name = ""forwardButton"" ) <TAB> backward_button = self. _gui. findChild ( name = ""backwardButton"" ) <TAB> if self. current_page == 0 : <TAB> <TAB> backward_button. set_inactive ( ) <TAB> else : <TAB> <TAB> backward_button. set_active ( ) <TAB> max_left_page_idx = self. max_pages - 1 <TAB> max_left_page_idx -= max_left_page_idx % 2 <TAB> if self. current_page == max_left_page_idx : <TAB> <TAB> forward_button. set_inactive ( ) <TAB> else : <TAB> <TAB> forward_button. set_active ( ) <TAB> data = self. displayed_resources <TAB> data = data [ <TAB> <TAB> self. current_page <TAB> <TAB> * self. LINES_PER_PAGE : ( self. current_page + 2 ) <TAB> <TAB> * self. LINES_PER_PAGE <TAB> ] <TAB> for idx, ( resource_id, amount ) in enumerate ( data, start = 1 ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> container = self. _page_right <TAB> <TAB> else : <TAB> <TAB> <TAB> container = self. _page_left <TAB> <TAB> self. _add_line_to_gui ( container, resource_id, amount ) <TAB> self. _page_left. adaptLayout ( ) <TAB> self. _page_right. adaptLayout ( )",False,idx > self.LINES_PER_PAGE,idx == 0,0.6549789309501648
|
||
|
1251,"def run ( self ) : <TAB> okay = [ AssertionError ] <TAB> if self. writing is False : <TAB> <TAB> <TAB> <TAB> okay. append ( ValueError ) <TAB> try : <TAB> <TAB> self. info = ""Starting: %s"" % self. writing <TAB> <TAB> self. _copy_loop ( ) <TAB> except tuple ( okay ) : <TAB> <TAB> pass <TAB> except : <TAB> <TAB> self. exc_info = sys. exc_info ( ) <TAB> <TAB> traceback. print_exc ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> self. error_callback ( ) <TAB> <TAB> <TAB> except : <TAB> <TAB> <TAB> <TAB> pass <TAB> finally : <TAB> <TAB> fd, self. my_pipe_fd = self. my_pipe_fd, None <TAB> <TAB> if fd is not None : <TAB> <TAB> <TAB> fd. close ( ) <TAB> <TAB> self. info = ""Dead""",False,self.error_callback,self.error_callback is not None,0.6547931432723999
|
||
|
1252,"def find_word_bounds ( self, text, index, allowed_chars ) : <TAB> right = left = index <TAB> done = False <TAB> while not done : <TAB> <TAB> if left == 0 : <TAB> <TAB> <TAB> done = True <TAB> <TAB> elif not self. word_boundary_char ( text [ left - 1 ] ) : <TAB> <TAB> <TAB> left -= 1 <TAB> <TAB> else : <TAB> <TAB> <TAB> done = True <TAB> done = False <TAB> while not done : <TAB> <TAB> if right == len ( text ) : <TAB> <TAB> <TAB> done = True <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> right += 1 <TAB> <TAB> else : <TAB> <TAB> <TAB> done = True <TAB> return left, right",False,not self.word_boundary_char(text[right]),left > right - 1 and allowed_chars[left] in text,0.6508366465568542
|
||
|
1253,"def close ( self ) : <TAB> if ( <TAB> <TAB> self. _entity_stack <TAB> <TAB> or self. _parser is None <TAB> <TAB> or isinstance ( self. _parser, _ClosedParser ) <TAB> ) : <TAB> <TAB> <TAB> <TAB> return <TAB> try : <TAB> <TAB> self. feed ( """", isFinal = 1 ) <TAB> <TAB> self. _cont_handler. endDocument ( ) <TAB> <TAB> self. _parsing = 0 <TAB> <TAB> <TAB> <TAB> self. _parser = None <TAB> finally : <TAB> <TAB> self. _parsing = 0 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> parser = _ClosedParser ( ) <TAB> <TAB> <TAB> parser. ErrorColumnNumber = self. _parser. ErrorColumnNumber <TAB> <TAB> <TAB> parser. ErrorLineNumber = self. _parser. ErrorLineNumber <TAB> <TAB> <TAB> self. _parser = parser",True,self._parser is not None,self._parser is not None,0.6698061227798462
|
||
|
1254,"def block2assignblks ( self, block ) : <TAB> irblocks_list = super ( mipsCGen, self ). block2assignblks ( block ) <TAB> for irblocks in irblocks_list : <TAB> <TAB> for blk_idx, irblock in enumerate ( irblocks ) : <TAB> <TAB> <TAB> has_breakflow = any ( <TAB> <TAB> <TAB> <TAB> assignblock. instr. breakflow ( ) for assignblock in irblock <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if not has_breakflow : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> irs = [ ] <TAB> <TAB> <TAB> for assignblock in irblock : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> irs. append ( AssignBlock ( assignments, assignblock. instr ) ) <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> assignments = dict ( assignblock ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> assignments [ self. delay_slot_dst ] = assignblock [ self. ir_arch. pc ] <TAB> <TAB> <TAB> <TAB> assignments [ self. delay_slot_set ] = m2_expr. ExprInt ( 1, 32 ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> dst_loc_key = self. ir_arch. get_next_instr ( assignblock. instr ) <TAB> <TAB> <TAB> <TAB> assignments [ self. ir_arch. IRDst ] = m2_expr. ExprLoc ( dst_loc_key, 32 ) <TAB> <TAB> <TAB> <TAB> irs. append ( AssignBlock ( assignments, assignblock. instr ) ) <TAB> <TAB> <TAB> irblocks [ blk_idx ] = IRBlock ( irblock. loc_key, irs ) <TAB> return irblocks_list",False,self.ir_arch.pc not in assignblock,len(assignblock) == 0,0.6533259749412537
|
||
|
1255,"def get_attribute ( <TAB> self, selector, attribute, by = By. CSS_SELECTOR, timeout = None, hard_fail = True ) : <TAB> """"""This method uses JavaScript to get the value of an attribute."""""" <TAB> self. __check_scope ( ) <TAB> if not timeout : <TAB> <TAB> timeout = settings. SMALL_TIMEOUT <TAB> if self. timeout_multiplier and timeout == settings. SMALL_TIMEOUT : <TAB> <TAB> timeout = self. __get_new_timeout ( timeout ) <TAB> selector, by = self. __recalculate_selector ( selector, by ) <TAB> self. wait_for_ready_state_complete ( ) <TAB> time. sleep ( 0.01 ) <TAB> element = page_actions. wait_for_element_present ( self. driver, selector, by, timeout ) <TAB> try : <TAB> <TAB> attribute_value = element. get_attribute ( attribute ) <TAB> except ( StaleElementReferenceException, ENI_Exception ) : <TAB> <TAB> self. wait_for_ready_state_complete ( ) <TAB> <TAB> time. sleep ( 0.14 ) <TAB> <TAB> element = page_actions. wait_for_element_present ( <TAB> <TAB> <TAB> self. driver, selector, by, timeout <TAB> <TAB> ) <TAB> <TAB> attribute_value = element. get_attribute ( attribute ) <TAB> if attribute_value is not None : <TAB> <TAB> return attribute_value <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise Exception ( <TAB> <TAB> <TAB> <TAB> ""Element {%s} has no attribute {%s}!"" % ( selector, attribute ) <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return None",True,hard_fail,hard_fail,0.6700891852378845
|
||
|
1256,"def __init__ ( self, view, syntax = None ) : <TAB> self. platform = sublime. platform ( ) <TAB> self. classmap = { } <TAB> self. st_version = 2 <TAB> if sublime. version ( ) == """" or int ( sublime. version ( ) ) > 3000 : <TAB> <TAB> self. st_version = 3 <TAB> self. file_name = view. file_name ( ) <TAB> self. settings = sublime. load_settings ( ""CodeFormatter.sublime-settings"" ) <TAB> self. packages_path = sublime. packages_path ( ) <TAB> self. syntax_file = view. settings ( ). get ( ""syntax"" ) <TAB> self. syntax = syntax or self. get_syntax ( ) <TAB> <TAB> map_settings_formatter = [ <TAB> <TAB> ( ""codeformatter_php_options"", PhpFormatter ), <TAB> <TAB> ( ""codeformatter_js_options"", JsFormatter ), <TAB> <TAB> ( ""codeformatter_css_options"", CssFormatter ), <TAB> <TAB> ( ""codeformatter_html_options"", HtmlFormatter ), <TAB> <TAB> ( ""codeformatter_python_options"", PyFormatter ), <TAB> <TAB> ( ""codeformatter_vbscript_options"", VbscriptFormatter ), <TAB> <TAB> ( ""codeformatter_scss_options"", ScssFormatter ), <TAB> <TAB> ( ""codeformatter_coldfusion_options"", ColdfusionFormatter ), <TAB> <TAB> ( ""codeformatter_go_options"", GoFormatter ), <TAB> ] <TAB> for name, _class in map_settings_formatter : <TAB> <TAB> syntaxes = self. settings. get ( name, { } ). get ( ""syntaxes"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> for _formatter in syntaxes. split ( "","" ) : <TAB> <TAB> <TAB> self. classmap [ _formatter. strip ( ) ] = _class",False,"not syntaxes or not isinstance(syntaxes, str)",syntaxes is None,0.6483757495880127
|
||
|
1257,"def register_type_handlers ( connection, ** kwargs ) : <TAB> if connection. vendor!= ""postgresql"" : <TAB> <TAB> return <TAB> try : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> register_hstore ( connection. connection, globally = True, unicode = True ) <TAB> <TAB> else : <TAB> <TAB> <TAB> register_hstore ( connection. connection, globally = True ) <TAB> except ProgrammingError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> pass <TAB> try : <TAB> <TAB> with connection. cursor ( ) as cursor : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> cursor. execute ( ""SELECT typarray FROM pg_type WHERE typname = 'citext'"" ) <TAB> <TAB> <TAB> oids = tuple ( row [ 0 ] for row in cursor ) <TAB> <TAB> array_type = psycopg2. extensions. new_array_type ( <TAB> <TAB> <TAB> oids, ""citext[]"", psycopg2. STRING <TAB> <TAB> ) <TAB> <TAB> psycopg2. extensions. register_type ( array_type, None ) <TAB> except ProgrammingError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> pass",False,six.PY2,connection.vendor == 'sqlite',0.6716198921203613
|
||
|
1258,"def readexactly ( self, n ) : <TAB> buf = b"""" <TAB> while n : <TAB> <TAB> yield IORead ( self. s ) <TAB> <TAB> res = self. s. read ( n ) <TAB> <TAB> assert res is not None <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> yield IOReadDone ( self. s ) <TAB> <TAB> <TAB> break <TAB> <TAB> buf += res <TAB> <TAB> n -= len ( res ) <TAB> return buf",False,not res,len(res) == 0,0.6899232864379883
|
||
|
1259,"def __ludcmp ( self, index ) : <TAB> size = self. rows <TAB> vv = [ 0.0 ] * size <TAB> for i in range ( size ) : <TAB> <TAB> big = 0.0 <TAB> <TAB> for j in range ( size ) : <TAB> <TAB> <TAB> big = max ( abs ( self [ i ] [ j ] ), big ) <TAB> <TAB> if big == 0 : <TAB> <TAB> <TAB> raise Exception ( ""Singular matrix found"" ) <TAB> <TAB> vv [ i ] = 1.0 / big <TAB> for j in range ( size ) : <TAB> <TAB> for i in range ( j ) : <TAB> <TAB> <TAB> s = self [ i ] [ j ] <TAB> <TAB> <TAB> for k in range ( i ) : <TAB> <TAB> <TAB> <TAB> s -= self [ i ] [ k ] * self [ k ] [ j ] <TAB> <TAB> <TAB> self [ i ] [ j ] = s <TAB> <TAB> big = 0.0 <TAB> <TAB> for i in range ( j, size ) : <TAB> <TAB> <TAB> s = self [ i ] [ j ] <TAB> <TAB> <TAB> for k in range ( j ) : <TAB> <TAB> <TAB> <TAB> s -= self [ i ] [ k ] * self [ k ] [ j ] <TAB> <TAB> <TAB> self [ i ] [ j ] = s <TAB> <TAB> <TAB> dum = vv [ i ] * abs ( s ) <TAB> <TAB> <TAB> if dum >= big : <TAB> <TAB> <TAB> <TAB> big = dum <TAB> <TAB> <TAB> <TAB> imax = i <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> for k in range ( size ) : <TAB> <TAB> <TAB> <TAB> dum = self [ imax ] [ k ] <TAB> <TAB> <TAB> <TAB> self [ imax ] [ k ] = self [ j ] [ k ] <TAB> <TAB> <TAB> <TAB> self [ j ] [ k",False,j != imax,i % size > 0,0.7049155235290527
|
||
|
1260,"def check_response ( self, response ) : <TAB> """"""Specialized version of check_response()."""""" <TAB> for line in response : <TAB> <TAB> <TAB> <TAB> if not line. strip ( ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return <TAB> <TAB> elif line. startswith ( b""Benutzer/Passwort Fehler"" ) : <TAB> <TAB> <TAB> raise BadLogin ( line ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise FailedPost ( ""Server returned '%s'"" % six. ensure_text ( line ) )",False,line.startswith(b'OK'),line.startswith(b'<'),0.6486492156982422
|
||
|
1261,"def attach_to_cluster ( self, cluster ) : <TAB> client_info = self. client. info ( ) <TAB> revision = client_info [ ""version"" ] [ ""build_hash"" ] <TAB> distribution_version = client_info [ ""version"" ] [ ""number"" ] <TAB> <TAB> distribution_flavor = client_info [ ""version"" ]. get ( ""build_flavor"", ""oss"" ) <TAB> cluster. distribution_version = distribution_version <TAB> cluster. distribution_flavor = distribution_flavor <TAB> cluster. source_revision = revision <TAB> for node_stats in self. client. nodes. stats ( metric = ""_all"" ) [ ""nodes"" ]. values ( ) : <TAB> <TAB> node_name = node_stats [ ""name"" ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> cluster_node = cluster. node ( node_name ) <TAB> <TAB> else : <TAB> <TAB> <TAB> host = node_stats. get ( ""host"", ""unknown"" ) <TAB> <TAB> <TAB> cluster_node = cluster. add_node ( host, node_name ) <TAB> <TAB> self. add_node_stats ( cluster, cluster_node, node_stats ) <TAB> for node_info in self. client. nodes. info ( node_id = ""_all"" ) [ ""nodes"" ]. values ( ) : <TAB> <TAB> self. add_node_info ( cluster, node_info )",False,cluster.has_node(node_name),node_name.startswith('node:'),0.6499686241149902
|
||
|
1262,"def _is_match_rule ( self, flow, rules ) : <TAB> if not rules : <TAB> <TAB> return False <TAB> for rule_key, pattern in rules. items ( ) : <TAB> <TAB> targets = self. _get_rule_targets ( rule_key, flow ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return False <TAB> <TAB> if not self. _is_target_pattern_matched ( pattern, targets ) : <TAB> <TAB> <TAB> return False <TAB> return True",True,not targets,not targets,0.6781860589981079
|
||
|
1263,"def sort_key ( self, dupe, crit_value ) : <TAB> value = self. extract_value ( dupe ) <TAB> if crit_value in { self. ENDS_WITH_NUMBER, self. DOESNT_END_WITH_NUMBER } : <TAB> <TAB> ends_with_digit = value. strip ( ) [ - 1 : ]. isdigit ( ) <TAB> <TAB> if crit_value == self. ENDS_WITH_NUMBER : <TAB> <TAB> <TAB> return 0 if ends_with_digit else 1 <TAB> <TAB> else : <TAB> <TAB> <TAB> return 1 if ends_with_digit else 0 <TAB> else : <TAB> <TAB> value = len ( value ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> value *= - 1 <TAB> <TAB> return value",False,crit_value == self.LONGEST,value < 0,0.6688231229782104
|
||
|
1264,"def load_annotations ( self ) : <TAB> """"""Load annotation file to get video information."""""" <TAB> if self. ann_file. endswith ( "".json"" ) : <TAB> <TAB> return self. load_json_annotations ( ) <TAB> video_infos = [ ] <TAB> with open ( self. ann_file, ""r"" ) as fin : <TAB> <TAB> for line in fin : <TAB> <TAB> <TAB> line_split = line. strip ( ). split ( ) <TAB> <TAB> <TAB> video_dir = line_split [ 0 ] <TAB> <TAB> <TAB> label = int ( line_split [ 1 ] ) <TAB> <TAB> <TAB> num_clips = int ( line_split [ 2 ] ) <TAB> <TAB> <TAB> positive_clip_inds = [ int ( ind ) for ind in line_split [ 3 : ] ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> video_dir = osp. join ( self. data_prefix, video_dir ) <TAB> <TAB> <TAB> video_infos. append ( <TAB> <TAB> <TAB> <TAB> dict ( <TAB> <TAB> <TAB> <TAB> <TAB> video_dir = video_dir, <TAB> <TAB> <TAB> <TAB> <TAB> label = label, <TAB> <TAB> <TAB> <TAB> <TAB> num_clips = num_clips, <TAB> <TAB> <TAB> <TAB> <TAB> positive_clip_inds = positive_clip_inds, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> return video_infos",False,self.data_prefix is not None,self.has_data_prefix and self.data_prefix,0.651530385017395
|
||
|
1265,"def claim_ownership ( self, ownership_list ) : <TAB> <TAB> result = [ ] <TAB> for ownership in ownership_list : <TAB> <TAB> fully_qualified_namespace = ownership [ ""fully_qualified_namespace"" ] <TAB> <TAB> eventhub_name = ownership [ ""eventhub_name"" ] <TAB> <TAB> consumer_group = ownership [ ""consumer_group"" ] <TAB> <TAB> partition_id = ownership [ ""partition_id"" ] <TAB> <TAB> etag = ownership. get ( ""etag"" ) <TAB> <TAB> old_ownership_node = self. _ownerships_trie. lookup ( <TAB> <TAB> <TAB> ( fully_qualified_namespace, eventhub_name, consumer_group, partition_id ) <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> old_ownership = old_ownership_node. value <TAB> <TAB> <TAB> if etag == old_ownership [ ""etag"" ] : <TAB> <TAB> <TAB> <TAB> ownership [ ""etag"" ] = str ( uuid. uuid4 ( ) ) <TAB> <TAB> <TAB> <TAB> ownership [ ""last_modified_time"" ] = time. time ( ) <TAB> <TAB> <TAB> <TAB> old_ownership [ ""etag"" ] = ownership [ ""etag"" ] <TAB> <TAB> <TAB> <TAB> old_ownership [ ""last_modified_time"" ] = ownership [ ""last_modified_time"" ] <TAB> <TAB> <TAB> <TAB> old_ownership [ ""owner_id"" ] = ownership [ ""owner_id"" ] <TAB> <TAB> <TAB> <TAB> result. append ( old_ownership ) <TAB> <TAB> else : <TAB> <TAB> <TAB> ownership [ ""etag"" ] = str ( uuid. uuid4 ( ) ) <TAB> <TAB> <TAB> ownership [ ""last_modified_time"" ] = time. time ( ) <TAB> <TAB> <TAB> self. _ownerships_trie. set_ele ( ownership ) <TAB> <TAB> <TAB> result. append ( ownership )",True,old_ownership_node,old_ownership_node,0.6676054000854492
|
||
|
1266,"def run ( self ) : <TAB> while True : <TAB> <TAB> with self. lock : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> print ( ""\n============= THREAD FRAMES: ================"" ) <TAB> <TAB> for id, frame in sys. _current_frames ( ). items ( ) : <TAB> <TAB> <TAB> if id == threading. current_thread ( ). ident : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> name = threading. _active. get ( id, None ) <TAB> <TAB> <TAB> except : <TAB> <TAB> <TAB> <TAB> name = None <TAB> <TAB> <TAB> if name is None : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> name = QtCore. QThread. _names. get ( id ) <TAB> <TAB> <TAB> <TAB> except : <TAB> <TAB> <TAB> <TAB> <TAB> name = None <TAB> <TAB> <TAB> if name is None : <TAB> <TAB> <TAB> <TAB> name = ""???"" <TAB> <TAB> <TAB> print ( '<< thread %d ""%s"" >>' % ( id, name ) ) <TAB> <TAB> <TAB> traceback. print_stack ( frame ) <TAB> <TAB> print ( ""===============================================\n"" ) <TAB> <TAB> time. sleep ( self. interval )",False,self._stop is True,self.thread_mode,0.6634032726287842
|
||
|
1267,"def is_test_finished ( self ) : <TAB> try : <TAB> <TAB> if hasattr ( self. volta_core, ""phone"" ) : <TAB> <TAB> <TAB> if hasattr ( self. volta_core. phone, ""test_performer"" ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> logger. warning ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""There is no test performer process on the phone, interrupting test"" <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> return 1 <TAB> <TAB> <TAB> <TAB> if not self. volta_core. phone. test_performer. is_finished ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> logger. debug ( ""Waiting for phone test to finish..."" ) <TAB> <TAB> <TAB> <TAB> <TAB> return - 1 <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> return self. volta_core. phone. test_performer. retcode <TAB> <TAB> except : <TAB> <TAB> logger. error ( <TAB> <TAB> <TAB> ""Unknown exception of Android plugin. Interrupting test"", exc_info = True <TAB> <TAB> ) <TAB> <TAB> return 1",False,not self.volta_core.phone.test_performer,self.volta_core.phone.test_performer.retcode is None,0.6532264947891235
|
||
|
1268,"def dump ( self ) : <TAB> data = b"""" <TAB> dict_data = self. dfl_dict <TAB> <TAB> for key in list ( dict_data. keys ( ) ) : <TAB> <TAB> if dict_data [ key ] is None : <TAB> <TAB> <TAB> dict_data. pop ( key ) <TAB> for chunk in self. chunks : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. chunks. remove ( chunk ) <TAB> <TAB> <TAB> break <TAB> last_app_chunk = 0 <TAB> for i, chunk in enumerate ( self. chunks ) : <TAB> <TAB> if chunk [ ""m_h"" ] & 0xF0 == 0xE0 : <TAB> <TAB> <TAB> last_app_chunk = i <TAB> dflchunk = { <TAB> <TAB> ""name"" : ""APP15"", <TAB> <TAB> ""m_h"" : 0xEF, <TAB> <TAB> ""data"" : pickle. dumps ( dict_data ), <TAB> <TAB> ""ex_data"" : None, <TAB> } <TAB> self. chunks. insert ( last_app_chunk + 1, dflchunk ) <TAB> for chunk in self. chunks : <TAB> <TAB> data += struct. pack ( ""BB"", 0xFF, chunk [ ""m_h"" ] ) <TAB> <TAB> chunk_data = chunk [ ""data"" ] <TAB> <TAB> if chunk_data is not None : <TAB> <TAB> <TAB> data += struct. pack ( "">H"", len ( chunk_data ) + 2 ) <TAB> <TAB> <TAB> data += chunk_data <TAB> <TAB> chunk_ex_data = chunk [ ""ex_data"" ] <TAB> <TAB> if chunk_ex_data is not None : <TAB> <TAB> <TAB> data += chunk_ex_data <TAB> return data",False,chunk['name'] == 'APP15',chunk[0] & 240 and chunk[1] & 240,0.6562092304229736
|
||
|
1269,"def _parse_hh_mm_ss_ff ( tstr ) : <TAB> <TAB> len_str = len ( tstr ) <TAB> time_comps = [ 0, 0, 0, 0 ] <TAB> pos = 0 <TAB> for comp in range ( 0, 3 ) : <TAB> <TAB> if ( len_str - pos ) < 2 : <TAB> <TAB> <TAB> raise ValueError ( ""Incomplete time component"" ) <TAB> <TAB> time_comps [ comp ] = int ( tstr [ pos : pos + 2 ] ) <TAB> <TAB> pos += 2 <TAB> <TAB> next_char = tstr [ pos : pos + 1 ] <TAB> <TAB> if not next_char or comp >= 2 : <TAB> <TAB> <TAB> break <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( ""Invalid time separator: %c"" % next_char ) <TAB> <TAB> pos += 1 <TAB> if pos < len_str : <TAB> <TAB> if tstr [ pos ]!= ""."" : <TAB> <TAB> <TAB> raise ValueError ( ""Invalid microsecond component"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> pos += 1 <TAB> <TAB> <TAB> len_remainder = len_str - pos <TAB> <TAB> <TAB> if len_remainder not in ( 3, 6 ) : <TAB> <TAB> <TAB> <TAB> raise ValueError ( ""Invalid microsecond component"" ) <TAB> <TAB> <TAB> time_comps [ 3 ] = int ( tstr [ pos : ] ) <TAB> <TAB> <TAB> if len_remainder == 3 : <TAB> <TAB> <TAB> <TAB> time_comps [ 3 ] *= 1000 <TAB> return time_comps",False,next_char != ':',next_char and comp > 0,0.6659705638885498
|
||
|
1270,"def as_proto ( self, ** kwargs ) : <TAB> from nnabla. utils import nnabla_pb2 <TAB> from nnabla. utils. save_function import _create_function_nntxt <TAB> if kwargs : <TAB> <TAB> self. arguments. update ( kwargs ) <TAB> n = nnabla_pb2. Network ( ) <TAB> n. name = self. name <TAB> n. batch_size = self. arguments. get ( ""batch_size"", 1 ) <TAB> variables = OrderedDict ( self. variables ) <TAB> variables. update ( self. parameters ) <TAB> functions = self. functions <TAB> for name, variable in variables. items ( ) : <TAB> <TAB> v = n. variable. add ( ) <TAB> <TAB> v. name = name <TAB> <TAB> v. type = variable. type <TAB> <TAB> shape = list ( variable. shape ) <TAB> <TAB> v. shape. dim. extend ( shape ) <TAB> <TAB> if variable. info : <TAB> <TAB> <TAB> i = v. initializer <TAB> <TAB> <TAB> i. type = variable. info. initializer. __class__. __name__. replace ( <TAB> <TAB> <TAB> <TAB> ""Initializer"", """" <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> i. multiplier = 0.0 <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> i. multiplier = variable. info. initializer. value <TAB> <TAB> <TAB> elif i. type == ""Uniform"" : <TAB> <TAB> <TAB> <TAB> i. multiplier = - variable. info. initializer. lim [ 0 ] <TAB> <TAB> <TAB> elif i. type == ""Normal"" : <TAB> <TAB> <TAB> <TAB> i. multiplier = variable. info. initializer. sigma <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> pass <TAB> for name, function in functions. items ( ) : <TAB> <TAB> f = n. function. add ( ) <TAB> <TAB> _create_",False,i.type == 'Constant',variable.type == 'Constant',0.6556774973869324
|
||
|
1271,"def _competing ( self, ctx : commands. Context, *, competing : str = None ) : <TAB> """"""Sets [botname]'s competing status."""""" <TAB> status = ( <TAB> <TAB> ctx. bot. guilds [ 0 ]. me. status <TAB> <TAB> if len ( ctx. bot. guilds ) > 0 <TAB> <TAB> else discord. Status. online <TAB> ) <TAB> if competing : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> await ctx. send ( <TAB> <TAB> <TAB> <TAB> _ ( ""The maximum length of competing descriptions is 128 characters."" ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> return <TAB> <TAB> activity = discord. Activity ( name = competing, type = discord. ActivityType. competing ) <TAB> else : <TAB> <TAB> activity = None <TAB> await ctx. bot. change_presence ( status = status, activity = activity ) <TAB> if activity : <TAB> <TAB> await ctx. send ( <TAB> <TAB> <TAB> _ ( ""Status set to ``Competing in {competing}``."" ). format ( competing = competing ) <TAB> <TAB> ) <TAB> else : <TAB> <TAB> await ctx. send ( _ ( ""Competing cleared."" ) )",False,len(competing) > 128,len(ctx.guilds) > 128,0.6695790886878967
|
||
|
1272,"def process ( self, resources ) : <TAB> results = [ ] <TAB> client = local_session ( self. manager. session_factory ). client ( ""sns"" ) <TAB> for r in resources : <TAB> <TAB> policy = json. loads ( r. get ( ""Policy"" ) or ""{}"" ) <TAB> <TAB> policy_statements = policy. setdefault ( ""Statement"", [ ] ) <TAB> <TAB> new_policy, removed = self. remove_statements ( <TAB> <TAB> <TAB> policy_statements, r, CrossAccountAccessFilter. annotation_key <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> new_policy = policy_statements <TAB> <TAB> new_policy, added = self. add_statements ( new_policy ) <TAB> <TAB> if not removed and not added : <TAB> <TAB> <TAB> continue <TAB> <TAB> results += { <TAB> <TAB> <TAB> ""Name"" : r [ ""TopicArn"" ], <TAB> <TAB> <TAB> ""State"" : ""PolicyModified"", <TAB> <TAB> <TAB> ""Statements"" : new_policy, <TAB> <TAB> } <TAB> <TAB> policy [ ""Statement"" ] = new_policy <TAB> <TAB> client. set_topic_attributes ( <TAB> <TAB> <TAB> TopicArn = r [ ""TopicArn"" ], <TAB> <TAB> <TAB> AttributeName = ""Policy"", <TAB> <TAB> <TAB> AttributeValue = json. dumps ( policy ), <TAB> <TAB> ) <TAB> return results",False,new_policy is None,new_policy,0.6592462062835693
|
||
|
1273,"def then ( self, matches, when_response, context ) : <TAB> if is_iterable ( when_response ) : <TAB> <TAB> ret = [ ] <TAB> <TAB> when_response = list ( when_response ) <TAB> <TAB> for match in when_response : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> if self. match_name : <TAB> <TAB> <TAB> <TAB> <TAB> match. name = self. match_name <TAB> <TAB> <TAB> <TAB> matches. append ( match ) <TAB> <TAB> <TAB> <TAB> ret. append ( match ) <TAB> <TAB> return ret <TAB> if self. match_name : <TAB> <TAB> when_response. name = self. match_name <TAB> if when_response not in matches : <TAB> <TAB> matches. append ( when_response ) <TAB> <TAB> return when_response",False,match not in matches,match,0.6602612733840942
|
||
|
1274,"def process_response ( self, request, response ) : <TAB> now = datetime. datetime. utcnow ( ) <TAB> response [ ""Date"" ] = now. strftime ( ""%a, %d %b %Y %H:%M:%S GMT"" ) <TAB> if not response. has_header ( ""Content-Length"" ) : <TAB> <TAB> response [ ""Content-Length"" ] = str ( len ( response. content ) ) <TAB> if response. has_header ( ""ETag"" ) : <TAB> <TAB><mask> : <TAB> <TAB> if if_none_match == response [ ""ETag"" ] : <TAB> <TAB> <TAB> response. status_code = 304 <TAB> <TAB> <TAB> response. content = """" <TAB> <TAB> <TAB> response [ ""Content-Length"" ] = ""0"" <TAB> if response. has_header ( ""Last-Modified"" ) : <TAB> <TAB> last_mod = response [ ""Last-Modified"" ] <TAB> <TAB> if_modified_since = request. META. get ( ""HTTP_IF_MODIFIED_SINCE"", None ) <TAB> <TAB> if if_modified_since == response [ ""Last-Modified"" ] : <TAB> <TAB> <TAB> response. status_code = 304 <TAB> <TAB> <TAB> response. content = """" <TAB> <TAB> <TAB> response [ ""Content-Length"" ] = ""0"" <TAB> if request. method == ""HEAD"" : <TAB> <TAB> response. content = """" <TAB> return response",False,"if_none_match = request.META.get('HTTP_IF_NONE_MATCH', None)","self._is_last_modified(request, response)",0.6515220403671265
|
||
|
1275,"def _on_frame_start ( self, data ) : <TAB> self. _wire_bytes_in += len ( data ) <TAB> header, payloadlen = struct. unpack ( ""BB"", data ) <TAB> self. _final_frame = header & self. FIN <TAB> reserved_bits = header & self. RSV_MASK <TAB> self. _frame_opcode = header & self. OPCODE_MASK <TAB> self. _frame_opcode_is_control = self. _frame_opcode & 0x8 <TAB> if self. _decompressor is not None and self. _frame_opcode!= 0 : <TAB> <TAB> self. _frame_compressed = bool ( reserved_bits & self. RSV1 ) <TAB> <TAB> reserved_bits &= ~ self. RSV1 <TAB> if reserved_bits : <TAB> <TAB> <TAB> <TAB> self. _abort ( ) <TAB> <TAB> return <TAB> self. _masked_frame = bool ( payloadlen & 0x80 ) <TAB> payloadlen = payloadlen & 0x7F <TAB> if self. _frame_opcode_is_control and payloadlen >= 126 : <TAB> <TAB> <TAB> <TAB> self. _abort ( ) <TAB> <TAB> return <TAB> try : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _frame_length = payloadlen <TAB> <TAB> <TAB> if self. _masked_frame : <TAB> <TAB> <TAB> <TAB> self. stream. read_bytes ( 4, self. _on_masking_key ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. _read_frame_data ( False ) <TAB> <TAB> elif payloadlen == 126 : <TAB> <TAB> <TAB> self. stream. read_bytes ( 2, self. _on_frame_length_16 ) <TAB> <TAB> elif payloadlen == 127 : <TAB> <TAB> <TAB> self. stream. read_bytes ( 8, self. _on_frame_length_64 ) <TAB> except StreamClosedError : <TAB> <",False,payloadlen < 126,self._frame_compressed,0.6725018620491028
|
||
|
1276,"def _initialize ( bot ) : <TAB> bot. spawn_lock = asyncio. Lock ( ) <TAB> config = bot. get_config_option ( ""spawn"" ) <TAB> if not config : <TAB> <TAB> return <TAB> cmds = config. get ( ""commands"" ) <TAB> <TAB> get_location = False <TAB> for cmd, cnf in cmds. items ( ) : <TAB> <TAB> command. register ( _spawn, admin = True, final = True, name = cmd ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> get_location = True <TAB> logger. info ( ""spawn - %s"", "", "". join ( [ ""*"" + cmd for cmd in cmds ] ) ) <TAB> plugins. register_admin_command ( list ( cmds ) ) <TAB> if get_location : <TAB> <TAB> global _MAP_MATCH <TAB> <TAB> _MAP_MATCH = re. compile ( <TAB> <TAB> <TAB> config. get ( ""map_regex"", _MAP_REGEX ), re. IGNORECASE | re. MULTILINE <TAB> <TAB> ) <TAB> <TAB> plugins. register_handler ( _location_handler, type = ""message"" )",False,cnf.get('allow_location'),admin,0.6533006429672241
|
||
|
1277,"def stale_possible_simple_keys ( self ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for level in list ( self. possible_simple_keys ) : <TAB> <TAB> key = self. possible_simple_keys [ level ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if key. required : <TAB> <TAB> <TAB> <TAB> raise ScannerError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""while scanning a simple key"", <TAB> <TAB> <TAB> <TAB> <TAB> key. mark, <TAB> <TAB> <TAB> <TAB> <TAB> ""could not found expected ':'"", <TAB> <TAB> <TAB> <TAB> <TAB> self. get_mark ( ), <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> del self. possible_simple_keys [ level ]",False,key.line != self.line or self.index - key.index > 1024,key.mark is not None,0.6518813371658325
|
||
|
1278,"def add_css ( self, data ) : <TAB> if data : <TAB> <TAB> for medium, paths in data. items ( ) : <TAB> <TAB> <TAB> for path in paths : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> self. _css. setdefault ( medium, [ ] ). append ( path )",False,not self._css.get(medium) or path not in self._css[medium],path,0.6537683606147766
|
||
|
1279,"def parse_dataset ( data_dir : Path ) -> InternalBioNerDataset : <TAB> entities_per_document = defaultdict ( list ) <TAB> texts_per_document = { } <TAB> with ( data_dir / ""S800.tsv"" ). open ( encoding = ""utf8"" ) as f : <TAB> <TAB> for line in f : <TAB> <TAB> <TAB> fields = line. strip ( ). split ( ""\t"" ) <TAB> <TAB> <TAB> if not fields : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> fname, pmid = fields [ 1 ]. split ( "":"" ) <TAB> <TAB> <TAB> start, end = int ( fields [ 2 ] ), int ( fields [ 3 ] ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> entities_per_document [ fname ]. append ( Entity ( ( start, end ), ""Species"" ) ) <TAB> for fname in entities_per_document : <TAB> <TAB> with ( data_dir / ""abstracts"" / fname ). with_suffix ( "".txt"" ). open ( <TAB> <TAB> <TAB> encoding = ""utf8"" <TAB> <TAB> ) as f : <TAB> <TAB> <TAB> texts_per_document [ fname ] = f. read ( ) <TAB> return InternalBioNerDataset ( <TAB> <TAB> documents = texts_per_document, entities_per_document = entities_per_document <TAB> )",False,start == end,pmid == 'species',0.6690071225166321
|
||
|
1280,"def remove_participant ( request, thread, user ) : <TAB> """"""remove thread participant, set ""recound private threads"" flag on user"""""" <TAB> removed_owner = False <TAB> remaining_participants = [ ] <TAB> for participant in thread. participants_list : <TAB> <TAB> if participant. user == user : <TAB> <TAB> <TAB> removed_owner = participant. is_owner <TAB> <TAB> else : <TAB> <TAB> <TAB> remaining_participants. append ( participant. user ) <TAB> set_users_unread_private_threads_sync ( participants = thread. participants_list ) <TAB> if not remaining_participants : <TAB> <TAB> thread. delete ( ) <TAB> else : <TAB> <TAB> thread. threadparticipant_set. filter ( user = user ). delete ( ) <TAB> <TAB> thread. subscription_set. filter ( user = user ). delete ( ) <TAB> <TAB> if removed_owner : <TAB> <TAB> <TAB> thread. is_closed = True <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> event_type = ""owner_left"" <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> event_type = ""removed_owner"" <TAB> <TAB> else : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> event_type = ""participant_left"" <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> event_type = ""removed_participant"" <TAB> <TAB> record_event ( <TAB> <TAB> <TAB> request, <TAB> <TAB> <TAB> thread, <TAB> <TAB> <TAB> event_type, <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> ""user"" : { <TAB> <TAB> <TAB> <TAB> <TAB> ""id"" : user. id, <TAB> <TAB> <TAB> <TAB> <TAB> ""username"" : user. username, <TAB> <TAB> <TAB",False,request.user == user,"hasattr(thread, 'participant_left')",0.6623156666755676
|
||
|
1281,"def i_eor ( self, op ) : <TAB> dsize = op. opers [ 0 ]. tsize <TAB> if len ( op. opers ) == 3 : <TAB> <TAB> src1 = self. getOperValue ( op, 1 ) <TAB> <TAB> src2 = self. getOperValue ( op, 2 ) <TAB> else : <TAB> <TAB> src1 = self. getOperValue ( op, 0 ) <TAB> <TAB> src2 = self. getOperValue ( op, 1 ) <TAB> <TAB> if src1 is None or src2 is None : <TAB> <TAB> self. undefFlags ( ) <TAB> <TAB> self. setOperValue ( op, 0, None ) <TAB> <TAB> return <TAB> usrc1 = e_bits. unsigned ( src1, dsize ) <TAB> usrc2 = e_bits. unsigned ( src2, dsize ) <TAB> ures = usrc1 ^ usrc2 <TAB> self. setOperValue ( op, 0, ures ) <TAB> curmode = self. getProcMode ( ) <TAB> if op. iflags & IF_PSR_S : <TAB> <TAB> if op. opers [ 0 ]. reg == 15 : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. setCPSR ( self. getSPSR ( curmode ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> raise Exception ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Messed up opcode... adding to r15 from PM_usr or PM_sys"" <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> self. setFlag ( PSR_N_bit, e_bits. is_signed ( ures, dsize ) ) <TAB> <TAB> self. setFlag ( PSR_Z_bit, not ures ) <TAB> <TAB> self. setFlag ( PSR_C_bit, e_bits. is_unsigned_carry ( ures, dsize ) ) <TAB> <TAB> self. setFlag ( PSR_V_",False,curmode != PM_sys and curmode != PM_usr,curmode,0.6520432233810425
|
||
|
1282,"def handle_facts_hpacu ( facts ) : <TAB> disks = { } <TAB> for k, value in facts. iteritems ( ) : <TAB> <TAB> m = HPACU_GENERAL_REGEX. match ( k ) <TAB> <TAB> if not m : <TAB> <TAB> <TAB> continue <TAB> <TAB> n = HPACU_LOGICAL_PHYSICAL_REGEX. match ( m. group ( 2 ) ) <TAB> <TAB> physical_disk = n. group ( 1 ) if n else None <TAB> <TAB> property = n. group ( 2 ) if n else m. group ( 2 ) <TAB> <TAB> if not physical_disk : <TAB> <TAB> <TAB> continue <TAB> <TAB> disks. setdefault ( physical_disk, { } ) [ property ] = value. strip ( ) <TAB> detected_disks = [ ] <TAB> for disk_handle, disk in disks. iteritems ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> size_value, size_unit = disk [ ""size"" ]. split ( ) <TAB> <TAB> detected_disks. append ( <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> ""serial_number"" : disk [ ""serial_number"" ], <TAB> <TAB> <TAB> <TAB> ""label"" : ""{} {}"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> "" "". join ( disk [ ""model"" ]. split ( ) ), <TAB> <TAB> <TAB> <TAB> <TAB> disk [ ""interface_type"" ], <TAB> <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> <TAB> ""size"" : int ( float ( size_value ) / units. size_divisor [ size_unit ] ), <TAB> <TAB> <TAB> <TAB> ""family"" : "" "". join ( disk [ ""model"" ]. split ( ) ), <TAB> <TAB> <TAB> } <TAB> <TAB> ) <TAB> return detected_disks",False,not disk.get('serial_number'),disk_handle != 'hPACU',0.6511922478675842
|
||
|
1283,"def is_eligible ( self, t, status, notif_number, in_notif_time, interval ) : <TAB> small_states = { <TAB> <TAB> ""WARNING"" : ""w"", <TAB> <TAB> ""UNKNOWN"" : ""u"", <TAB> <TAB> ""CRITICAL"" : ""c"", <TAB> <TAB> ""RECOVERY"" : ""r"", <TAB> <TAB> ""FLAPPING"" : ""f"", <TAB> <TAB> ""DOWNTIME"" : ""s"", <TAB> <TAB> ""DOWN"" : ""d"", <TAB> <TAB> ""UNREACHABLE"" : ""u"", <TAB> <TAB> ""OK"" : ""o"", <TAB> <TAB> ""UP"" : ""o"", <TAB> } <TAB> <TAB> if not self. time_based : <TAB> <TAB> <TAB> <TAB> if notif_number < self. first_notification : <TAB> <TAB> <TAB> return False <TAB> <TAB> <TAB> <TAB> if self. last_notification!= 0 and notif_number > self. last_notification : <TAB> <TAB> <TAB> return False <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return False <TAB> <TAB> <TAB> <TAB> if ( <TAB> <TAB> <TAB> self. last_notification_time!= 0 <TAB> <TAB> <TAB> and in_notif_time > self. last_notification_time * interval <TAB> <TAB> ) : <TAB> <TAB> <TAB> return False <TAB> <TAB> if status in small_states and small_states [ status ] not in self. escalation_options : <TAB> <TAB> return False <TAB> <TAB> if self. escalation_period is not None and not self. escalation_period. is_time_valid ( <TAB> <TAB> t <TAB> ) : <TAB> <TAB> return False <TAB> <TAB> return True",False,in_notif_time < self.first_notification_time * interval,self.last_notification_time and in_notif_time,0.6497511863708496
|
||
|
1284,"def offsets ( self ) : <TAB> offsets = { } <TAB> offset_so_far = 0 <TAB> for name, ty in self. fields. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> l. warning ( <TAB> <TAB> <TAB> <TAB> ""Found a bottom field in struct %s. Ignore and increment the offset using the default "" <TAB> <TAB> <TAB> <TAB> ""element size."", <TAB> <TAB> <TAB> <TAB> self. name, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if not self. _pack : <TAB> <TAB> <TAB> align = ty. alignment <TAB> <TAB> <TAB> if offset_so_far % align!= 0 : <TAB> <TAB> <TAB> <TAB> offset_so_far += align - offset_so_far % align <TAB> <TAB> offsets [ name ] = offset_so_far <TAB> <TAB> offset_so_far += ty. size // self. _arch. byte_width <TAB> return offsets",False,"isinstance(ty, SimTypeBottom)",name in self.fields,0.654800534248352
|
||
|
1285,"def _internal_attach ( self, engine : Engine, usage : MetricUsage ) -> None : <TAB> self. engine = engine <TAB> for index, metric in enumerate ( itertools. chain ( self. args, self. kwargs. values ( ) ) ) : <TAB> <TAB> if isinstance ( metric, MetricsLambda ) : <TAB> <TAB> <TAB> metric. _internal_attach ( engine, usage ) <TAB> <TAB> elif isinstance ( metric, Metric ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> engine. add_event_handler ( usage. STARTED, metric. started ) <TAB> <TAB> <TAB> if not engine. has_event_handler ( <TAB> <TAB> <TAB> <TAB> metric. iteration_completed, usage. ITERATION_COMPLETED <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> engine. add_event_handler ( <TAB> <TAB> <TAB> <TAB> <TAB> usage. ITERATION_COMPLETED, metric. iteration_completed <TAB> <TAB> <TAB> <TAB> )",False,"not engine.has_event_handler(metric.started, usage.STARTED)",not engine.has_event_handler,0.6532597541809082
|
||
|
1286,"def can_read ( self ) : <TAB> if hasattr ( self. file, ""__iter__"" ) : <TAB> <TAB> iterator = iter ( self. file ) <TAB> <TAB> head = next ( iterator, None ) <TAB> <TAB> if head is None : <TAB> <TAB> <TAB> self. repaired = [ ] <TAB> <TAB> <TAB> return True <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. repaired = itertools. chain ( [ head ], iterator ) <TAB> <TAB> <TAB> return True <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> raise IOSourceError ( <TAB> <TAB> <TAB> <TAB> ""Could not open source: %r (mode: %r)"" <TAB> <TAB> <TAB> <TAB> % ( self. file, self. options [ ""mode"" ] ) <TAB> <TAB> <TAB> ) <TAB> return False",False,"isinstance(head, str)",len(head) > 0,0.6563901901245117
|
||
|
1287,"def show_container_cd_url ( cmd, resource_group_name, name, slot = None ) : <TAB> settings = get_app_settings ( cmd, resource_group_name, name, slot ) <TAB> docker_enabled = False <TAB> for setting in settings : <TAB> <TAB> if setting [ ""name"" ] == ""DOCKER_ENABLE_CI"" and setting [ ""value"" ] == ""true"" : <TAB> <TAB> <TAB> docker_enabled = True <TAB> <TAB> <TAB> break <TAB> cd_settings = { } <TAB> cd_settings [ ""DOCKER_ENABLE_CI"" ] = docker_enabled <TAB> if docker_enabled : <TAB> <TAB> credentials = list_publishing_credentials ( cmd, resource_group_name, name, slot ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> cd_url = credentials. scm_uri + ""/docker/hook"" <TAB> <TAB> <TAB> cd_settings [ ""CI_CD_URL"" ] = cd_url <TAB> else : <TAB> <TAB> cd_settings [ ""CI_CD_URL"" ] = """" <TAB> return cd_settings",True,credentials,credentials,0.7043042182922363
|
||
|
1288,"def __lookingForWrite4Where ( self, gadgetsAlreadyTested ) : <TAB> for gadget in self. __gadgets : <TAB> <TAB> if gadget in gadgetsAlreadyTested : <TAB> <TAB> <TAB> continue <TAB> <TAB> f = gadget [ ""gadget"" ]. split ( "" ; "" ) [ 0 ] <TAB> <TAB> <TAB> <TAB> regex = re. search ( <TAB> <TAB> <TAB> ""mov dword ptr \[(?P<dst>([(eax)|(ebx)|(ecx)|(edx)|(esi)|(edi)]{3}))\], (?P<src>([(eax)|(ebx)|(ecx)|(edx)|(esi)|(edi)]{3}))$"", <TAB> <TAB> <TAB> f, <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> lg = gadget [ ""gadget"" ]. split ( "" ; "" ) [ 1 : ] <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> for g in lg : <TAB> <TAB> <TAB> <TAB> <TAB> if g. split ( ) [ 0 ]!= ""pop"" and g. split ( ) [ 0 ]!= ""ret"" : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> raise <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if g!= ""ret"" : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if g. split ( ) [ 0 ] == ""ret"" and g. split ( ) [ 1 ]!= """" : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> raise <TAB> <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> <TAB> ""\t[+] Gadget found: 0x%x %s"" % ( gadget [ ""vaddr"" ], gadget [ ""gad",False,regex,gadget in gadgetsAlreadyTested,0.6866661906242371
|
||
|
1289,"def open_ ( self, path, flags, follow_link = True ) : <TAB> path = self. resolve_path ( path, follow_link = follow_link ) <TAB> if not os. path. exists ( path ) : <TAB> <TAB> <TAB> <TAB> return - 1 <TAB> fd = self. linux_env. next_fd ( ) <TAB> acc_mode = flags & self. linux_env. O_ACCMODE <TAB> if os. path. isdir ( path ) : <TAB> <TAB> assert flags & self. linux_env. O_DIRECTORY == self. linux_env. O_DIRECTORY <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> fdesc = FileDescriptorDirectory ( fd, flags, self, path ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise RuntimeError ( ""Not implemented"" ) <TAB> elif os. path. isfile ( path ) : <TAB> <TAB> if acc_mode == os. O_RDONLY : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> real_fd = os. open ( path, os. O_RDONLY ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise RuntimeError ( ""Not implemented"" ) <TAB> <TAB> fdesc = FileDescriptorRegularFile ( fd, flags, self, real_fd ) <TAB> elif os. path. islink ( path ) : <TAB> <TAB> raise RuntimeError ( ""Not implemented"" ) <TAB> else : <TAB> <TAB> raise RuntimeError ( ""Unknown file type for %r"" % path ) <TAB> self. linux_env. file_descriptors [ fd ] = fdesc <TAB> <TAB> fdesc. cont_device_id = self. device_id <TAB> fdesc. inode = self. get_path_inode ( path ) <TAB> fdesc. uid = self. linux_env. user_uid <TAB> fdesc. gid = self. linux_env. user_gid <TAB> size = os. path. getsize ( path ) <TAB> fdesc. size = size <TAB> fdesc. blksize = self. blocksize <TAB> fdesc. blocks = ( size + ( ( 512 -",False,acc_mode == self.linux_env.O_RDONLY,os.path.isdir(path),0.6542212963104248
|
||
|
1290,"def numerify_args ( items, evaluation ) : <TAB> items_sequence = items. get_sequence ( ) <TAB> all_numeric = all ( <TAB> <TAB> item. is_numeric ( ) and item. get_precision ( ) is None for item in items_sequence <TAB> ) <TAB> <TAB> if all_numeric and any ( not isinstance ( item, Number ) for item in items_sequence ) : <TAB> <TAB> <TAB> <TAB> items = items_sequence <TAB> <TAB> n_items = [ ] <TAB> <TAB> for item in items : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> n_expr = Expression ( ""N"", item, Integer ( 50 ) ) <TAB> <TAB> <TAB> <TAB> item = n_expr. evaluate ( evaluation ) <TAB> <TAB> <TAB> n_items. append ( item ) <TAB> <TAB> items = n_items <TAB> else : <TAB> <TAB> items = items. numerify ( evaluation ). get_sequence ( ) <TAB> return items",False,"not isinstance(item, Number)",all_numeric,0.6530721783638
|
||
|
1291,"def move_to_next_word ( self, forward = True ) : <TAB> if forward : <TAB> <TAB> match_iterator = re. finditer ( r""(\b\W+|$)"", self. edit_text, flags = re. UNICODE ) <TAB> <TAB> match_positions = [ m. start ( ) for m in match_iterator ] <TAB> <TAB> op = operator. gt <TAB> else : <TAB> <TAB> match_iterator = re. finditer ( r""(\w+\b|^)"", self. edit_text, flags = re. UNICODE ) <TAB> <TAB> match_positions = reversed ( [ m. start ( ) for m in match_iterator ] ) <TAB> <TAB> op = operator. lt <TAB> for pos in match_positions : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. set_edit_pos ( pos ) <TAB> <TAB> <TAB> return pos",False,"op(pos, self.edit_pos)",op & pos > 0,0.6509331464767456
|
||
|
1292,"def status ( self ) : <TAB> app = self. _app <TAB> info = app. player. info <TAB> if info : <TAB> <TAB> if app. player. paused : <TAB> <TAB> <TAB> state = ""pause"" <TAB> <TAB> else : <TAB> <TAB> <TAB> state = ""play"" <TAB> else : <TAB> <TAB> state = ""stop"" <TAB> status = [ <TAB> <TAB> ( ""volume"", int ( app. player. volume * 100 ) ), <TAB> <TAB> ( ""repeat"", int ( self. _options. repeat ) ), <TAB> <TAB> ( ""random"", int ( self. _options. shuffle ) ), <TAB> <TAB> ( ""single"", int ( self. _options. single ) ), <TAB> <TAB> ( ""consume"", 0 ), <TAB> <TAB> ( ""playlist"", self. _pl_ver ), <TAB> <TAB> ( ""playlistlength"", int ( bool ( app. player. info ) ) ), <TAB> <TAB> ( ""mixrampdb"", 0.0 ), <TAB> <TAB> ( ""state"", state ), <TAB> ] <TAB> if info : <TAB> <TAB> status. append ( <TAB> <TAB> <TAB> ( <TAB> <TAB> <TAB> <TAB> ""audio"", <TAB> <TAB> <TAB> <TAB> ""%d:%d:%d"" <TAB> <TAB> <TAB> <TAB> % ( <TAB> <TAB> <TAB> <TAB> <TAB> info ( ""~#samplerate"" ) or 0, <TAB> <TAB> <TAB> <TAB> <TAB> info ( ""~#bitdepth"" ) or 0, <TAB> <TAB> <TAB> <TAB> <TAB> info ( ""~#channels"" ) or 0, <TAB> <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> ) <TAB> <TAB> ) <TAB> <TAB> total_time = int ( info ( ""~#length"" ) ) <TAB> <TAB> elapsed_time = int ( app. player. get_",False,state != 'stop',self._options.status,0.6563791036605835
|
||
|
1293,"def main ( argv = None ) : <TAB> """"""Entry point for script."""""" <TAB> arg_parser = ArgumentParser ( description = DESCRIPTION ) <TAB> arg_parser. add_argument ( ""--file"", default = ""galaxy.log"" ) <TAB> arg_parser. add_argument ( ""--print_lines"", default = False, action = ""store_true"" ) <TAB> arg_parser. add_argument ( ""--pattern"", default = None ) <TAB> args = arg_parser. parse_args ( argv ) <TAB> print_lines = args. print_lines <TAB> pattern_str = args. pattern <TAB> filter_pattern = re. compile ( pattern_str ) if pattern_str is not None else None <TAB> times = [ ] <TAB> for line in open ( args. file, ""r"" ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> match = TIMING_LINE_PATTERN. search ( line ) <TAB> <TAB> if not match : <TAB> <TAB> <TAB> continue <TAB> <TAB> times. append ( float ( match. group ( 1 ) ) ) <TAB> <TAB> if print_lines : <TAB> <TAB> <TAB> print ( line. strip ( ) ) <TAB> template = ""Summary (ms) - Mean: %f, Median: %f, Max: %f, Min: %f, StdDev: %f"" <TAB> message = template % ( <TAB> <TAB> numpy. mean ( times ), <TAB> <TAB> numpy. median ( times ), <TAB> <TAB> numpy. max ( times ), <TAB> <TAB> numpy. min ( times ), <TAB> <TAB> numpy. std ( times ), <TAB> ) <TAB> print ( message )",False,filter_pattern and (not filter_pattern.search(line)),filter_pattern.search(line) is None,0.6445654630661011
|
||
|
1294,"def get_data_service_client ( <TAB> cli_ctx, <TAB> service_type, <TAB> account_name, <TAB> account_key, <TAB> connection_string = None, <TAB> sas_token = None, <TAB> socket_timeout = None, <TAB> token_credential = None, <TAB> endpoint_suffix = None, <TAB> location_mode = None, ) : <TAB> logger. debug ( ""Getting data service client service_type=%s"", service_type. __name__ ) <TAB> try : <TAB> <TAB> client_kwargs = { <TAB> <TAB> <TAB> ""account_name"" : account_name, <TAB> <TAB> <TAB> ""account_key"" : account_key, <TAB> <TAB> <TAB> ""connection_string"" : connection_string, <TAB> <TAB> <TAB> ""sas_token"" : sas_token, <TAB> <TAB> } <TAB> <TAB> if socket_timeout : <TAB> <TAB> <TAB> client_kwargs [ ""socket_timeout"" ] = socket_timeout <TAB> <TAB> if token_credential : <TAB> <TAB> <TAB> client_kwargs [ ""token_credential"" ] = token_credential <TAB> <TAB> if endpoint_suffix : <TAB> <TAB> <TAB> client_kwargs [ ""endpoint_suffix"" ] = endpoint_suffix <TAB> <TAB> client = service_type ( ** client_kwargs ) <TAB> <TAB> if location_mode : <TAB> <TAB> <TAB> client. location_mode = location_mode <TAB> except ValueError as exc : <TAB> <TAB> _ERROR_STORAGE_MISSING_INFO = get_sdk ( <TAB> <TAB> <TAB> cli_ctx, <TAB> <TAB> <TAB> ResourceType. DATA_STORAGE, <TAB> <TAB> <TAB> ""common._error#_ERROR_STORAGE_MISSING_INFO"", <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( exc ) <TAB> <TAB> raise CLIError ( <TAB> <TAB> <TAB> ""Unable to obtain data client. Check your connection parameters."" <TAB>",False,_ERROR_STORAGE_MISSING_INFO in str(exc),exc,0.6544076204299927
|
||
|
1295,"def _do_cmp ( f1, f2 ) : <TAB> bufsize = BUFSIZE <TAB> with open ( f1, ""rb"" ) as fp1, open ( f2, ""rb"" ) as fp2 : <TAB> <TAB> while True : <TAB> <TAB> <TAB> b1 = fp1. read ( bufsize ) <TAB> <TAB> <TAB> b2 = fp2. read ( bufsize ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return False <TAB> <TAB> <TAB> if not b1 : <TAB> <TAB> <TAB> <TAB> return True",False,b1 != b2,not b2,0.6706905364990234
|
||
|
1296,"def resolve ( self, context, ignore_failures = False ) : <TAB> try : <TAB> <TAB> obj = resolve_variable ( self. var, context ) <TAB> except VariableDoesNotExist : <TAB> <TAB> if ignore_failures : <TAB> <TAB> <TAB> obj = None <TAB> <TAB> else : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return settings. TEMPLATE_STRING_IF_INVALID <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> obj = settings. TEMPLATE_STRING_IF_INVALID <TAB> for func, args in self. filters : <TAB> <TAB> arg_vals = [ ] <TAB> <TAB> for lookup, arg in args : <TAB> <TAB> <TAB> if not lookup : <TAB> <TAB> <TAB> <TAB> arg_vals. append ( arg ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> arg_vals. append ( resolve_variable ( arg, context ) ) <TAB> <TAB> obj = func ( obj, * arg_vals ) <TAB> return obj",False,settings.TEMPLATE_STRING_IF_INVALID,self.filters is None,0.652380108833313
|
||
|
1297,def _setup_ec2 ( self ) : <TAB> if self. ec2 and self. _instance and self. _reservation : <TAB> <TAB> return <TAB> if self. id : <TAB> <TAB> if self. region_name : <TAB> <TAB> <TAB> for region in boto. ec2. regions ( ) : <TAB> <TAB> <TAB> <TAB> if region. name == self. region_name : <TAB> <TAB> <TAB> <TAB> <TAB> self. ec2 = region. connect ( ) <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> rs = self. ec2. get_all_reservations ( [ self. instance_id ] ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if len ( rs ) >= 1 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for instance in rs [ 0 ]. instances : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if instance. id == self. instance_id : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _reservation = rs [ 0 ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _instance = instance <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> except EC2ResponseError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> pass,False,self.instance_id and (not self._instance),self.instance_id,0.6545414924621582
|
||
|
1298,"def scatter_add ( x0, indices, x1, axis ) : <TAB> output = np. copy ( x0 ) <TAB> if x0. ndim == 2 : <TAB> <TAB> for i in range ( indices. shape [ 0 ] ) : <TAB> <TAB> <TAB> for j in range ( indices. shape [ 1 ] ) : <TAB> <TAB> <TAB> <TAB> if axis == 0 or axis == - 2 : <TAB> <TAB> <TAB> <TAB> <TAB> output [ indices [ i ] [ j ] ] [ j ] += x1 [ i ] [ j ] <TAB> <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> output [ i ] [ indices [ i ] [ j ] ] += x1 [ i ] [ j ] <TAB> elif x0. ndim == 3 : <TAB> <TAB> for i in range ( indices. shape [ 0 ] ) : <TAB> <TAB> <TAB> for j in range ( indices. shape [ 1 ] ) : <TAB> <TAB> <TAB> <TAB> for k in range ( indices. shape [ 2 ] ) : <TAB> <TAB> <TAB> <TAB> <TAB> if axis == 0 or axis == - 3 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> output [ indices [ i ] [ j ] [ k ] ] [ j ] [ k ] += x1 [ i ] [ j ] [ k ] <TAB> <TAB> <TAB> <TAB> <TAB> elif axis == 1 or axis == - 2 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> output [ i ] [ indices [ i ] [ j ] [ k ] ] [ k ] += x1 [ i ] [ j ] [ k ] <TAB> <TAB> <TAB> <TAB> <TAB> elif axis == 2 or axis == - 1 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> output [ i ] [ j ] [ indices [ i ] [ j ] [ k ] ] += x1 [ i ] [ j ] [ k ] <TAB> return output",False,axis == 1 or axis == -1,x0.ndim == 1,0.664332389831543
|
||
|
1299,"def cmd_ShowNode ( event ) : <TAB> c = event. get ( ""c"" ) <TAB> nd = geotag_Controller. getAttr ( c. p ) <TAB> try : <TAB> <TAB> txt = nd. h. split ( None, 5 ) <TAB> <TAB> what = ""dummy"", ""lat"", ""lng"", ""zoom"", ""maptype"", ""description"" <TAB> <TAB> data = dict ( zip ( what, txt ) ) <TAB> <TAB> data [ ""lat"" ] = float ( data [ ""lat"" ] ) <TAB> <TAB> data [ ""lng"" ] = float ( data [ ""lng"" ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> data [ ""zoom"" ] = int ( data [ ""zoom"" ] ) <TAB> <TAB> if ""description"" not in data or not data [ ""description"" ]. strip ( ) : <TAB> <TAB> <TAB> data [ ""description"" ] = c. p. h <TAB> except ( ValueError, TypeError ) : <TAB> <TAB> data = { ""description"" : c. p. h } <TAB> g. pygeotag. show_position ( data )",True,'zoom' in data,'zoom' in data,0.6696645021438599
|
||
|
1300,"def open ( self ) : <TAB> cmd = self. _check_cmd ( ) <TAB> params = self. params. copy ( ) <TAB> params [ ""_bg"" ] = True <TAB> if<mask> : <TAB> <TAB> tmpfile = tempfile. NamedTemporaryFile ( <TAB> <TAB> <TAB> prefix = ""livestreamer"", suffix = "".err"", delete = False <TAB> <TAB> ) <TAB> <TAB> params [ ""_err"" ] = tmpfile <TAB> else : <TAB> <TAB> params [ ""_err"" ] = open ( os. devnull, ""wb"" ) <TAB> with params [ ""_err"" ] : <TAB> <TAB> stream = cmd ( ** params ) <TAB> <TAB> time. sleep ( 0.5 ) <TAB> process_alive = stream. process. returncode is None <TAB> if not process_alive : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise StreamError ( <TAB> <TAB> <TAB> <TAB> ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Error while executing subprocess, "" ""error output logged to: {0}"" <TAB> <TAB> <TAB> <TAB> ). format ( tmpfile. name ) <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise StreamError ( ""Error while executing subprocess"" ) <TAB> return StreamProcessIO ( self. session, stream. process, timeout = self. timeout )",False,self.errorlog,self.delete_stderr,0.6551488041877747
|
||
|
1301,"def user_can_administer_repository ( self, user, repository ) : <TAB> """"""Return True if the received user can administer the received repository."""""" <TAB> if user : <TAB> <TAB> if repository : <TAB> <TAB> <TAB> repository_admin_role = repository. admin_role <TAB> <TAB> <TAB> for rra in repository. roles : <TAB> <TAB> <TAB> <TAB> role = rra. role <TAB> <TAB> <TAB> <TAB> if role. id == repository_admin_role. id : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for ura in role. users : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> role_member = ura. user <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return True <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for gra in role. groups : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> group = gra. group <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for uga in group. members : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> member = uga. user <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if member. id == user. id : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return True <TAB> return False",False,role_member.id == user.id,role_member.id == role_member.id,0.6542470455169678
|
||
|
1302,"def get_all_possible_filenames ( version_str ) : <TAB> """"""Get a list of all filename on this system."""""" <TAB> current_system = platform. system ( ) <TAB> POSSIBLE_FILENAMES = [ ] <TAB> for suffix in ClangUtils. SUFFIXES [ current_system ] : <TAB> <TAB> for name in ClangUtils. POSSIBLE_FILENAMES [ current_system ] : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> name = name. replace ( ""$version"", version_str ) <TAB> <TAB> <TAB> POSSIBLE_FILENAMES. append ( ""{name}{suffix}"". format ( name = name, suffix = suffix ) ) <TAB> return POSSIBLE_FILENAMES",False,platform.system() == 'Linux',version_str,0.6528959274291992
|
||
|
1303,"def getChartList ( self ) : <TAB> cache_key = ""bluray.charts"" <TAB> movie_list = { <TAB> <TAB> ""name"" : ""Blu-ray.com - New Releases"", <TAB> <TAB> ""url"" : self. display_url, <TAB> <TAB> ""order"" : self. chart_order, <TAB> <TAB> ""list"" : self. getCache ( cache_key ) or [ ], <TAB> } <TAB> if not movie_list [ ""list"" ] : <TAB> <TAB> movie_ids = [ ] <TAB> <TAB> max_items = 10 <TAB> <TAB> rss_movies = self. getRSSData ( self. rss_url ) <TAB> <TAB> for movie in rss_movies : <TAB> <TAB> <TAB> name = ( <TAB> <TAB> <TAB> <TAB> self. getTextElement ( movie, ""title"" ) <TAB> <TAB> <TAB> <TAB>. lower ( ) <TAB> <TAB> <TAB> <TAB>. split ( ""blu-ray"" ) [ 0 ] <TAB> <TAB> <TAB> <TAB>. strip ( ""("" ) <TAB> <TAB> <TAB> <TAB>. rstrip ( ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> year = ( <TAB> <TAB> <TAB> <TAB> self. getTextElement ( movie, ""description"" ) <TAB> <TAB> <TAB> <TAB>. split ( ""|"" ) [ 1 ] <TAB> <TAB> <TAB> <TAB>. strip ( ""("" ) <TAB> <TAB> <TAB> <TAB>. strip ( ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if not name. find ( ""/"" ) == - 1 : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> movie = self. search ( name, year ) <TAB> <TAB> <TAB> if movie : <TAB> <TAB> <TAB> <TAB> if movie. get ( ""imdb"" ) in movie_ids : <TAB> <TAB> <TAB> <TAB> <TAB>",False,len(movie_list['list']) >= max_items,self.getConfig('imdb'),0.6596227288246155
|
||
|
1304,"def get_norm ( norm, out_channels ) : <TAB> if isinstance ( norm, str ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return None <TAB> <TAB> norm = { <TAB> <TAB> <TAB> ""BN"" : BatchNorm2d, <TAB> <TAB> <TAB> ""GN"" : lambda channels : nn. GroupNorm ( 32, channels ), <TAB> <TAB> <TAB> ""nnSyncBN"" : nn. SyncBatchNorm, <TAB> <TAB> <TAB> """" : lambda x : x, <TAB> <TAB> } [ norm ] <TAB> return norm ( out_channels )",False,len(norm) == 0,norm == 'nnSyncBN',0.6588277816772461
|
||
|
1305,"def delete_s3_bucket ( bucket_name, dry_run = True, quiet = False ) : <TAB> s3client = boto3. client ( ""s3"" ) <TAB> versions = s3client. list_object_versions ( Bucket = bucket_name ). get ( ""Versions"", [ ] ) <TAB> objects = [ { ""Key"" : o [ ""Key"" ], ""VersionId"" : o [ ""VersionId"" ] } for o in versions ] <TAB> if objects : <TAB> <TAB> for obj in objects : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> puts ( colored. red ( ""AWS::S3::Key {}/{}"". format ( bucket_name, obj [ ""Key"" ] ) ) ) <TAB> <TAB> if not dry_run : <TAB> <TAB> <TAB> s3client. delete_objects ( <TAB> <TAB> <TAB> <TAB> Bucket = bucket_name, Delete = { ""Objects"" : objects, ""Quiet"" : False } <TAB> <TAB> <TAB> ) <TAB> if<mask> : <TAB> <TAB> puts ( colored. red ( ""S3 Bucket: {}"". format ( bucket_name ) ) ) <TAB> if not dry_run : <TAB> <TAB> s3client. delete_bucket ( Bucket = bucket_name )",False,not quiet,quiet,0.6698378324508667
|
||
|
1306,"def remove ( self, url ) : <TAB> try : <TAB> <TAB> i = self. items. index ( url ) <TAB> except ( ValueError, IndexError ) : <TAB> <TAB> pass <TAB> else : <TAB> <TAB> was_selected = i in self. selectedindices ( ) <TAB> <TAB> self. list. delete ( i ) <TAB> <TAB> del self. items [ i ] <TAB> <TAB> if not self. items : <TAB> <TAB> <TAB> self. mp. hidepanel ( self. name ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> if i >= len ( self. items ) : <TAB> <TAB> <TAB> <TAB> i = len ( self. items ) - 1 <TAB> <TAB> <TAB> self. list. select_set ( i )",True,was_selected,was_selected,0.6687973141670227
|
||
|
1307,"def get_ndarray_bounds ( self ) -> List [ Tuple [ float, float ] ] : <TAB> bounds = [ ] <TAB> final_bound = None <TAB> for hp in self. config_space. get_hyperparameters ( ) : <TAB> <TAB> if isinstance ( hp, CS. CategoricalHyperparameter ) : <TAB> <TAB> <TAB> if not self. _fix_attribute_value ( hp. name ) : <TAB> <TAB> <TAB> <TAB> bound = [ ( 0.0, 1.0 ) ] * len ( hp. choices ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> bound = [ ( 0.0, 0.0 ) ] * len ( hp. choices ) <TAB> <TAB> <TAB> <TAB> bound [ int ( self. value_for_last_pos ) ] = ( 1.0, 1.0 ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if not self. _fix_attribute_value ( hp. name ) : <TAB> <TAB> <TAB> <TAB> bound = [ ( 0.0, 1.0 ) ] <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> val_int = float ( <TAB> <TAB> <TAB> <TAB> <TAB> hp. _inverse_transform ( np. array ( [ self. value_for_last_pos ] ) ). item ( ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> bound = [ ( val_int, val_int ) ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> final_bound = bound <TAB> <TAB> else : <TAB> <TAB> <TAB> bounds. extend ( bound ) <TAB> if final_bound is not None : <TAB> <TAB> bounds. extend ( final_bound ) <TAB> return bounds",False,hp.name == self.name_last_pos,bound is not None and final_bound is not None,0.6517331600189209
|
||
|
1308,"def _find_mountains_mask ( world, factor ) : <TAB> _mask = [ <TAB> <TAB> [ False for x in range ( factor * world. width ) ] <TAB> <TAB> for y in range ( factor * world. height ) <TAB> ] <TAB> for y in range ( factor * world. height ) : <TAB> <TAB> for x in range ( factor * world. width ) : <TAB> <TAB> <TAB> if world. is_mountain ( ( int ( x / factor ), int ( y / factor ) ) ) : <TAB> <TAB> <TAB> <TAB> v = len ( <TAB> <TAB> <TAB> <TAB> <TAB> world. tiles_around ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ( int ( x / factor ), int ( y / factor ) ), <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> radius = 3, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> predicate = world. is_mountain, <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> _mask [ y ] [ x ] = v / 4 <TAB> return _mask",False,v > 32,_mask is not None,0.6718873977661133
|
||
|
1309,"def _validate ( self ) : <TAB> if not self. allow_non_single and ( self. _value [ 0 ] is None or self. _value [ 0 ] is None ) : <TAB> <TAB> raise InvalidArgumentValue ( <TAB> <TAB> <TAB> ""Address cannot be unbounded if allow_non_single is not set."" <TAB> <TAB> ) <TAB> if self. _value [ 0 ] : <TAB> <TAB> row = int ( self. _value [ 0 ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise InvalidArgumentValue ( <TAB> <TAB> <TAB> <TAB> ""Address coordinates may not be below zero: "" + repr ( self. _value ) <TAB> <TAB> <TAB> ) <TAB> if self. _value [ 1 ] : <TAB> <TAB> col = int ( self. _value [ 1 ] ) <TAB> <TAB> if col < 1 : <TAB> <TAB> <TAB> raise InvalidArgumentValue ( <TAB> <TAB> <TAB> <TAB> ""Address coordinates may not be below zero: "" + repr ( self. _value ) <TAB> <TAB> <TAB> )",True,row < 1,row < 1,0.6835970282554626
|
||
|
1310,"def _filter_imgs ( self, min_size = 32 ) : <TAB> """"""Filter images too small or without ground truths."""""" <TAB> valid_inds = [ ] <TAB> <TAB> ids_with_ann = set ( _ [ ""image_id"" ] for _ in self. coco. anns. values ( ) ) <TAB> <TAB> ids_in_cat = set ( ) <TAB> for i, class_id in enumerate ( self. cat_ids ) : <TAB> <TAB> ids_in_cat |= set ( self. coco. cat_img_map [ class_id ] ) <TAB> <TAB> <TAB> ids_in_cat &= ids_with_ann <TAB> valid_img_ids = [ ] <TAB> for i, img_info in enumerate ( self. data_infos ) : <TAB> <TAB> img_id = self. img_ids [ i ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> if min ( img_info [ ""width"" ], img_info [ ""height"" ] ) >= min_size : <TAB> <TAB> <TAB> valid_inds. append ( i ) <TAB> <TAB> <TAB> valid_img_ids. append ( img_id ) <TAB> self. img_ids = valid_img_ids <TAB> return valid_inds",False,self.filter_empty_gt and img_id not in ids_in_cat,img_id in valid_inds and img_id in ids_in_cat,0.6515251398086548
|
||
|
1311,"def comparisons ( self, predicates, simple_cover ) : <TAB> compounder = self. Compounder ( simple_cover ) <TAB> comparison_count = { } <TAB> for pred in predicates : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> estimate = self. estimate ( compounder ( pred ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> estimate = self. estimate ( simple_cover [ pred ] ) <TAB> <TAB> comparison_count [ pred ] = estimate <TAB> return comparison_count",False,len(pred) > 1,pred == pred,0.6681349277496338
|
||
|
1312,"def find_cookie ( line ) : <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> line_string = line. decode ( ""utf-8"" ) <TAB> except UnicodeDecodeError : <TAB> <TAB> msg = ""invalid or missing encoding declaration"" <TAB> <TAB> if filename is not None : <TAB> <TAB> <TAB> msg = ""{} for {!r}"". format ( msg, filename ) <TAB> <TAB> raise SyntaxError ( msg ) <TAB> match = cookie_re. match ( line_string ) <TAB> if not match : <TAB> <TAB> return None <TAB> encoding = _get_normal_name ( match. group ( 1 ) ) <TAB> try : <TAB> <TAB> codecs. lookup ( encoding ) <TAB> except LookupError : <TAB> <TAB> <TAB> <TAB> if filename is None : <TAB> <TAB> <TAB> msg = ""unknown encoding: "" + encoding <TAB> <TAB> else : <TAB> <TAB> <TAB> msg = ""unknown encoding for {!r}: {}"". format ( filename, encoding ) <TAB> <TAB> raise SyntaxError ( msg ) <TAB> if bom_found : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if filename is None : <TAB> <TAB> <TAB> <TAB> msg = ""encoding problem: utf-8"" <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> msg = ""encoding problem for {!r}: utf-8"". format ( filename ) <TAB> <TAB> <TAB> raise SyntaxError ( msg ) <TAB> <TAB> encoding += ""-sig"" <TAB> return encoding",False,encoding != 'utf-8',encoding is not None,0.6532049775123596
|
||
|
1313,"def getBranches ( self, emu = None ) : <TAB> ret = [ ] <TAB> <TAB> flags = self. iflags & envi. ARCH_MASK <TAB> addb = False <TAB> <TAB> <TAB> if self. iflags & IF_BRANCH : <TAB> <TAB> addb = True <TAB> <TAB> if not ( self. iflags & IF_NOFALL ) : <TAB> <TAB> <TAB> flags |= envi. BR_COND <TAB> <TAB> if not self. iflags & envi. IF_NOFALL : <TAB> <TAB> ret. append ( ( self. va + self. size, flags | envi. BR_FALL ) ) <TAB> <TAB> if len ( self. opers ) == 0 : <TAB> <TAB> return ret <TAB> <TAB> if self. iflags & IF_CALL : <TAB> <TAB> flags |= envi. BR_PROC <TAB> <TAB> addb = True <TAB> if addb : <TAB> <TAB> oper0 = self. opers [ 0 ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> flags |= envi. BR_DEREF <TAB> <TAB> <TAB> tova = oper0. getOperAddr ( self, emu = emu ) <TAB> <TAB> else : <TAB> <TAB> <TAB> tova = oper0. getOperValue ( self, emu = emu ) <TAB> <TAB> ret. append ( ( tova, flags ) ) <TAB> return ret",False,oper0.isDeref(),addb,0.6546223163604736
|
||
|
1314,"def actor_from_stream ( <TAB> self, <TAB> stream : Optional [ StreamT ], <TAB> *, <TAB> index : int = None, <TAB> active_partitions : Set [ TP ] = None, <TAB> channel : ChannelT = None ) -> ActorRefT : <TAB> """"""Create new actor from stream."""""" <TAB> we_created_stream = False <TAB> actual_stream : StreamT <TAB> if stream is None : <TAB> <TAB> actual_stream = self. stream ( <TAB> <TAB> <TAB> channel = channel, <TAB> <TAB> <TAB> concurrency_index = index, <TAB> <TAB> <TAB> active_partitions = active_partitions, <TAB> <TAB> ) <TAB> <TAB> we_created_stream = True <TAB> else : <TAB> <TAB> <TAB> <TAB> assert stream. concurrency_index == index <TAB> <TAB> assert stream. active_partitions == active_partitions <TAB> <TAB> actual_stream = stream <TAB> res = self. fun ( actual_stream ) <TAB> if isinstance ( res, AsyncIterable ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> actual_stream. add_processor ( self. _maybe_unwrap_reply_request ) <TAB> <TAB> return cast ( <TAB> <TAB> <TAB> ActorRefT, <TAB> <TAB> <TAB> AsyncIterableActor ( <TAB> <TAB> <TAB> <TAB> self, <TAB> <TAB> <TAB> <TAB> actual_stream, <TAB> <TAB> <TAB> <TAB> res, <TAB> <TAB> <TAB> <TAB> index = actual_stream. concurrency_index, <TAB> <TAB> <TAB> <TAB> active_partitions = actual_stream. active_partitions, <TAB> <TAB> <TAB> <TAB> loop = self. loop, <TAB> <TAB> <TAB> <TAB> beacon = self. beacon, <TAB> <TAB> <TAB> ), <TAB> <TAB> ) <TAB> else : <TAB> <TAB> return cast ( <TAB> <TAB> <TAB> ActorRefT, <TAB> <TAB> <",False,we_created_stream,self._create_reply_request,0.6563795804977417
|
||
|
1315,def compiled_query ( self ) : <TAB> if<mask> : <TAB> <TAB> self. lazy_init_lock_. acquire ( ) <TAB> <TAB> try : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. compiled_query_ = CompiledQuery ( ) <TAB> <TAB> finally : <TAB> <TAB> <TAB> self. lazy_init_lock_. release ( ) <TAB> return self. compiled_query_,True,self.compiled_query_ is None,self.compiled_query_ is None,0.6553391218185425
|
||
|
1316,"def _omit_keywords ( self, context ) : <TAB> omitted_kws = 0 <TAB> for event, elem in context : <TAB> <TAB> <TAB> <TAB> omit = elem. tag == ""kw"" and elem. get ( ""type"" )!= ""teardown"" <TAB> <TAB> start = event == ""start"" <TAB> <TAB> if omit and start : <TAB> <TAB> <TAB> omitted_kws += 1 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> yield event, elem <TAB> <TAB> elif not start : <TAB> <TAB> <TAB> elem. clear ( ) <TAB> <TAB> if omit and not start : <TAB> <TAB> <TAB> omitted_kws -= 1",False,not omitted_kws,omit_kws == 0,0.6594420671463013
|
||
|
1317,"def __exit__ ( self, exc_type, exc_val, exc_tb ) : <TAB> if self. _should_meta_profile : <TAB> <TAB> end_time = timezone. now ( ) <TAB> <TAB> exception_raised = exc_type is not None <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> Logger. error ( <TAB> <TAB> <TAB> <TAB> ""Exception when performing meta profiling, dumping trace below"" <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> traceback. print_exception ( exc_type, exc_val, exc_tb ) <TAB> <TAB> request = getattr ( DataCollector ( ). local, ""request"", None ) <TAB> <TAB> if request : <TAB> <TAB> <TAB> curr = request. meta_time or 0 <TAB> <TAB> <TAB> request. meta_time = curr + _time_taken ( self. start_time, end_time )",True,exception_raised,exception_raised,0.6654812097549438
|
||
|
1318,"def correct_for_autogen_constraints ( <TAB> self, <TAB> conn_unique_constraints, <TAB> conn_indexes, <TAB> metadata_unique_constraints, <TAB> metadata_indexes, ) : <TAB> conn_indexes_by_name = dict ( ( c. name, c ) for c in conn_indexes ) <TAB> doubled_constraints = set ( <TAB> <TAB> index for index in conn_indexes if index. info. get ( ""duplicates_constraint"" ) <TAB> ) <TAB> for ix in doubled_constraints : <TAB> <TAB> conn_indexes. remove ( ix ) <TAB> for idx in list ( metadata_indexes ) : <TAB> <TAB> if idx. name in conn_indexes_by_name : <TAB> <TAB> <TAB> continue <TAB> <TAB> exprs = idx. expressions <TAB> <TAB> for expr in exprs : <TAB> <TAB> <TAB> while isinstance ( expr, UnaryExpression ) : <TAB> <TAB> <TAB> <TAB> expr = expr. element <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> util. warn ( <TAB> <TAB> <TAB> <TAB> <TAB> ""autogenerate skipping functional index %s; "" <TAB> <TAB> <TAB> <TAB> <TAB> ""not supported by SQLAlchemy reflection"" % idx. name <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> metadata_indexes. discard ( idx )",False,"not isinstance(expr, Column)",not expr.has_function,0.6546345949172974
|
||
|
1319,"def add_model ( self, model, initial = None ) : <TAB> """"""Register a model with the state machine, initializing triggers and callbacks."""""" <TAB> models = listify ( model ) <TAB> if initial is None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""No initial state configured for machine, must specify when adding model."" <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> initial = self. initial <TAB> for mod in models : <TAB> <TAB> mod = self if mod == ""self"" else mod <TAB> <TAB> if mod not in self. models : <TAB> <TAB> <TAB> self. _checked_assignment ( mod, ""trigger"", partial ( self. _get_trigger, mod ) ) <TAB> <TAB> <TAB> for trigger in self. events : <TAB> <TAB> <TAB> <TAB> self. _add_trigger_to_model ( trigger, mod ) <TAB> <TAB> <TAB> for state in self. states. values ( ) : <TAB> <TAB> <TAB> <TAB> self. _add_model_to_state ( state, mod ) <TAB> <TAB> <TAB> self. set_state ( initial, model = mod ) <TAB> <TAB> <TAB> self. models. append ( mod )",True,self.initial is None,self.initial is None,0.6569606065750122
|
||
|
1320,"def environ_add_POST ( env, data, content_type = None ) : <TAB> if data is None : <TAB> <TAB> return <TAB> if env [ ""REQUEST_METHOD"" ] not in ( ""POST"", ""PUT"" ) : <TAB> <TAB> env [ ""REQUEST_METHOD"" ] = ""POST"" <TAB> has_files = False <TAB> if hasattr ( data, ""items"" ) : <TAB> <TAB> data = data. items ( ) <TAB> <TAB> data. sort ( ) <TAB> <TAB> has_files = filter ( lambda _ : isinstance ( _ [ 1 ], ( tuple, list ) ), data ) <TAB> if content_type is None : <TAB> <TAB> content_type = ( <TAB> <TAB> <TAB> ""multipart/form-data"" if has_files else ""application/x-www-form-urlencoded"" <TAB> <TAB> ) <TAB> if content_type. startswith ( ""multipart/form-data"" ) : <TAB> <TAB> if not isinstance ( data, str ) : <TAB> <TAB> <TAB> content_type, data = _encode_multipart ( data, content_type ) <TAB> elif content_type. startswith ( ""application/x-www-form-urlencoded"" ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""Submiting files is not allowed for"" "" content type `%s`"" % content_type <TAB> <TAB> <TAB> ) <TAB> <TAB> if not isinstance ( data, str ) : <TAB> <TAB> <TAB> data = urllib. urlencode ( data ) <TAB> else : <TAB> <TAB> if not isinstance ( data, str ) : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""Please provide `POST` data as string"" <TAB> <TAB> <TAB> <TAB> "" for content type `%s`"" % content_type <TAB> <TAB> <TAB> ) <TAB> env [ ""wsgi.input"" ] = StringIO ( data ) <TAB> env [ ""webob.is_body_seekable"" ] = True",True,has_files,has_files,0.6598866581916809
|
||
|
1321,"def _transform_init_kwargs ( cls, kwargs ) : <TAB> transformed = [ ] <TAB> for field in list ( kwargs. keys ( ) ) : <TAB> <TAB> prop = getattr ( cls, field, None ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> value = kwargs. pop ( field ) <TAB> <TAB> <TAB> _transform_single_init_kwarg ( prop, field, value, kwargs ) <TAB> <TAB> <TAB> transformed. append ( ( field, value ) ) <TAB> return transformed",False,"isinstance(prop, MoneyProperty)",prop is not None,0.6531053781509399
|
||
|
1322,"def map ( callbackfn ) : <TAB> array = this. to_object ( ) <TAB> arr_len = array. get ( ""length"" ). to_uint32 ( ) <TAB> if not callbackfn. is_callable ( ) : <TAB> <TAB> raise this. MakeError ( ""TypeError"", ""callbackfn must be a function"" ) <TAB> T = arguments [ 1 ] <TAB> A = this. Js ( [ ] ) <TAB> k = 0 <TAB> while k < arr_len : <TAB> <TAB> Pk = str ( k ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> kValue = array. get ( Pk ) <TAB> <TAB> <TAB> mappedValue = callbackfn. call ( T, ( kValue, this. Js ( k ), array ) ) <TAB> <TAB> <TAB> A. define_own_property ( <TAB> <TAB> <TAB> <TAB> Pk, <TAB> <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> <TAB> ""value"" : mappedValue, <TAB> <TAB> <TAB> <TAB> <TAB> ""writable"" : True, <TAB> <TAB> <TAB> <TAB> <TAB> ""enumerable"" : True, <TAB> <TAB> <TAB> <TAB> <TAB> ""configurable"" : True, <TAB> <TAB> <TAB> <TAB> }, <TAB> <TAB> <TAB> ) <TAB> <TAB> k += 1 <TAB> return A",False,array.has_property(Pk),array.has_key(Pk),0.6559935808181763
|
||
|
1323,"def join ( self, * args ) : <TAB> rv = self <TAB> if self. _model_ is not None : <TAB> <TAB> joins = [ ] <TAB> <TAB> jdata = [ ] <TAB> <TAB> auto_select_tables = [ self. _model_. table ] <TAB> <TAB> for arg in args : <TAB> <TAB> <TAB> condition, table, rel_type = self. _parse_rjoin ( arg ) <TAB> <TAB> <TAB> joins. append ( condition ) <TAB> <TAB> <TAB> jdata. append ( ( arg, table. _tablename, rel_type ) ) <TAB> <TAB> <TAB> auto_select_tables. append ( table ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> q = joins [ 0 ] <TAB> <TAB> <TAB> for join in joins [ 1 : ] : <TAB> <TAB> <TAB> <TAB> q = q & join <TAB> <TAB> <TAB> rv = rv. where ( q, model = self. _model_ ) <TAB> <TAB> <TAB> return self. _join_set_builder ( rv, jdata, auto_select_tables ) <TAB> return rv",True,joins,joins,0.7149646282196045
|
||
|
1324,"def best_image ( width, height ) : <TAB> <TAB> image = images [ 0 ] <TAB> for img in images : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return img <TAB> <TAB> elif img. width >= width and img. width * img. height > image. width * image. height : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> image = img <TAB> return image",False,img.width == width and img.height == height,img.width < width and img.height < height,0.6538563966751099
|
||
|
1325,"def get_full_path ( path ) : <TAB> if ""://"" not in path : <TAB> <TAB> path = os. path. join ( self. AUTO_COLL_TEMPL, path, """" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> path = os. path. join ( abs_path, path ) <TAB> return path",False,abs_path,os.path.exists(abs_path),0.6650346517562866
|
||
|
1326,"def _read_data_from_all_categories ( self, directory, config, categories ) : <TAB> lines = [ ] <TAB> for category in categories : <TAB> <TAB> data_file = os. path. join ( directory, _DATASET_VERSION, category, config ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> with open ( data_file ) as f : <TAB> <TAB> <TAB> <TAB> ls = f. read ( ). split ( ""\n"" ) <TAB> <TAB> <TAB> <TAB> for l in ls [ : : - 1 ] : <TAB> <TAB> <TAB> <TAB> <TAB> if not l : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ls. remove ( l ) <TAB> <TAB> <TAB> <TAB> lines. extend ( ls ) <TAB> return lines",True,os.path.exists(data_file),os.path.exists(data_file),0.6471824645996094
|
||
|
1327,"def get_bit_length_from_plateau_lengths ( merged_plateau_lengths ) -> int : <TAB> if len ( merged_plateau_lengths ) == 0 : <TAB> <TAB> return 0 <TAB> if len ( merged_plateau_lengths ) == 1 : <TAB> <TAB> return int ( merged_plateau_lengths [ 0 ] ) <TAB> round_plateau_lengths ( merged_plateau_lengths ) <TAB> histogram = c_auto_interpretation. get_threshold_divisor_histogram ( <TAB> <TAB> merged_plateau_lengths <TAB> ) <TAB> if len ( histogram ) == 0 : <TAB> <TAB> return 0 <TAB> else : <TAB> <TAB> <TAB> <TAB> sorted_indices = np. argsort ( histogram ) [ : : - 1 ] <TAB> <TAB> max_count = histogram [ sorted_indices [ 0 ] ] <TAB> <TAB> result = sorted_indices [ 0 ] <TAB> <TAB> for i in range ( 1, len ( sorted_indices ) ) : <TAB> <TAB> <TAB> if histogram [ sorted_indices [ i ] ] < 0.25 * max_count : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> result = sorted_indices [ i ] <TAB> <TAB> return int ( result )",False,sorted_indices[i] <= 0.5 * result,result == 0.25 * max_count,0.6554892063140869
|
||
|
1328,"def empty_trash ( ) : <TAB> from app import current_app as app <TAB> with app. app_context ( ) : <TAB> <TAB> events = Event. query. filter ( Event. deleted_at. isnot ( None ) ). all ( ) <TAB> <TAB> users = User. query. filter ( User. deleted_at. isnot ( None ) ). all ( ) <TAB> <TAB> sessions = Session. query. filter ( Session. deleted_at. isnot ( None ) ). all ( ) <TAB> <TAB> pending_orders = Order. query. filter_by ( status = ""pending"" ) <TAB> <TAB> for event in events : <TAB> <TAB> <TAB> if datetime. now ( ) - event. deleted_at >= timedelta ( days = 30 ) : <TAB> <TAB> <TAB> <TAB> DataManager. delete_event ( event. id ) <TAB> <TAB> for user in users : <TAB> <TAB> <TAB> if datetime. now ( ) - user. deleted_at >= timedelta ( days = 30 ) : <TAB> <TAB> <TAB> <TAB> transaction = transaction_class ( Event ) <TAB> <TAB> <TAB> <TAB> transaction. query. filter_by ( user_id = user. id ). delete ( ) <TAB> <TAB> <TAB> <TAB> delete_from_db ( user, ""User deleted permanently"" ) <TAB> <TAB> for session_ in sessions : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> delete_from_db ( session_, ""Session deleted permanently"" ) <TAB> <TAB> for pending_order in pending_orders : <TAB> <TAB> <TAB> if datetime. now ( ) - pending_order. created_at >= timedelta ( days = 3 ) : <TAB> <TAB> <TAB> <TAB> pending_order. status = ""expired"" <TAB> <TAB> <TAB> <TAB> save_to_db ( pending_order, ""Pending order expired."" )",False,datetime.now() - session_.deleted_at >= timedelta(days=30),session_.status == 'deleted',0.6461283564567566
|
||
|
1329,"def __new__ ( cls, * nodes ) : <TAB> if not nodes : <TAB> <TAB> raise TypeError ( ""DisjunctionNode() requires at least one node"" ) <TAB> elif len ( nodes ) == 1 : <TAB> <TAB> return nodes [ 0 ] <TAB> self = super ( DisjunctionNode, cls ). __new__ ( cls ) <TAB> self. __nodes = [ ] <TAB> <TAB> for node in nodes : <TAB> <TAB> if not isinstance ( node, Node ) : <TAB> <TAB> <TAB> raise TypeError ( <TAB> <TAB> <TAB> <TAB> ""DisjunctionNode() expects Node instances as arguments;"" <TAB> <TAB> <TAB> <TAB> "" received a non-Node instance %r"" % node <TAB> <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. __nodes. extend ( node. __nodes ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. __nodes. append ( node ) <TAB> return self",False,"isinstance(node, DisjunctionNode)","hasattr(node, '__nodes')",0.6517279148101807
|
||
|
1330,"def main ( argv ) : <TAB> opts = setup ( ). parse_args ( argv ) <TAB> vw = vivisect. VivWorkspace ( ) <TAB> vw. loadWorkspace ( opts. vw ) <TAB> print ( ""# %s"" % opts. vw ) <TAB> fnames = { } <TAB> for fva, etype, ename, fname in vw. getExports ( ) : <TAB> <TAB> enamekey = ename. lower ( ) <TAB> <TAB> fnamekey = fname. lower ( ) <TAB> <TAB> fnames [ fname ] = True <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> rtype, rname, ccname, funcname, args = vw. getFunctionApi ( fva ) <TAB> <TAB> args = tuple ( [ ( type_lookup. get ( t, t ), name_lookup. get ( t ) ) for t, name in args ] ) <TAB> <TAB> print ( <TAB> <TAB> <TAB> "" '%s.%s':( %r, None, %r, '%s.%s', %r ),"" <TAB> <TAB> <TAB> % ( fnamekey, enamekey, rtype, ccname, fname, ename, args ) <TAB> <TAB> ) <TAB> for fwdfname in fnames. keys ( ) : <TAB> <TAB> for rva, name, fwdname in vw. getFileMeta ( fwdfname, ""forwarders"", ( ) ) : <TAB> <TAB> <TAB> fwdapi = vw. getImpApi ( fwdname ) <TAB> <TAB> <TAB> if not fwdapi : <TAB> <TAB> <TAB> <TAB> print ( "" # FIXME unresolved %s -> %s"" % ( name, fwdname ) ) <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> print ( "" '%s.%s':%r,"" % ( fwdfname. lower ( ), name. lower ( ), fwdapi ) )",False,not vw.isFunction(fva),not rtype,0.6537138223648071
|
||
|
1331,"def email ( request ) : <TAB> if request. method == ""POST"" : <TAB> <TAB> form = EmailForm ( request. POST, request. FILES ) <TAB> <TAB> if form. is_valid ( ) : <TAB> <TAB> <TAB> subject = request. POST. get ( ""subject"", """" ) <TAB> <TAB> <TAB> message = request. POST. get ( ""message"", """" ) <TAB> <TAB> <TAB> from_email = request. POST. get ( ""from_email"", """" ) <TAB> <TAB> <TAB> to_email = request. POST. get ( ""to_email"", """" ) <TAB> <TAB> <TAB> file = request. FILES. get ( ""files"", None ) <TAB> <TAB> <TAB> status = request. POST. get ( ""email_draft"", """" ) <TAB> <TAB> <TAB> email = EmailMessage ( subject, message, from_email, [ to_email ] ) <TAB> <TAB> <TAB> email. content_subtype = ""html"" <TAB> <TAB> <TAB> f = form. save ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> email. attach ( file. name, file. read ( ), file. content_type ) <TAB> <TAB> <TAB> <TAB> f. file = file <TAB> <TAB> <TAB> if status : <TAB> <TAB> <TAB> <TAB> f. status = ""draft"" <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> email. send ( fail_silently = False ) <TAB> <TAB> <TAB> f. save ( ) <TAB> <TAB> <TAB> return HttpResponseRedirect ( reverse ( ""emails:list"" ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return render ( request, ""create_mail.html"", { ""form"" : form } ) <TAB> else : <TAB> <TAB> form = EmailForm ( ) <TAB> <TAB> return render ( request, ""create_mail.html"", { ""form"" : form } )",False,file is not None,file.has_file(),0.655273973941803
|
||
|
1332,"def stop ( self ) : <TAB> with self. lock : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return <TAB> <TAB> self. task_queue. put ( None ) <TAB> <TAB> self. result_queue. put ( None ) <TAB> <TAB> process = self. process <TAB> <TAB> self. process = None <TAB> <TAB> self. task_queue = None <TAB> <TAB> self. result_queue = None <TAB> process. join ( timeout = 0.1 ) <TAB> if process. exitcode is None : <TAB> <TAB> os. kill ( process. pid, signal. SIGKILL ) <TAB> <TAB> process. join ( )",False,not self.process,self.process is None,0.6593582034111023
|
||
|
1333,"def __init__ ( <TAB> self, <TAB> certificate = None, <TAB> ssl_version = None, <TAB> certreqs = None, <TAB> cacerts = None, <TAB> chatty = True, <TAB> connectionchatty = False, <TAB> starttls_server = False, <TAB> npn_protocols = None, <TAB> alpn_protocols = None, <TAB> ciphers = None, <TAB> context = None, ) : <TAB> if context : <TAB> <TAB> self. context = context <TAB> else : <TAB> <TAB> self. context = ssl. SSLContext ( <TAB> <TAB> <TAB> ssl_version if ssl_version is not None else ssl. PROTOCOL_TLS <TAB> <TAB> ) <TAB> <TAB> self. context. verify_mode = certreqs if certreqs is not None else ssl. CERT_NONE <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. context. load_verify_locations ( cacerts ) <TAB> <TAB> if certificate : <TAB> <TAB> <TAB> self. context. load_cert_chain ( certificate ) <TAB> <TAB> if npn_protocols : <TAB> <TAB> <TAB> self. context. set_npn_protocols ( npn_protocols ) <TAB> <TAB> if alpn_protocols : <TAB> <TAB> <TAB> self. context. set_alpn_protocols ( alpn_protocols ) <TAB> <TAB> if ciphers : <TAB> <TAB> <TAB> self. context. set_ciphers ( ciphers ) <TAB> self. chatty = chatty <TAB> self. connectionchatty = connectionchatty <TAB> self. starttls_server = starttls_server <TAB> self. sock = socket. socket ( ) <TAB> self. port = support. bind_port ( self. sock ) <TAB> self. flag = None <TAB> self. active = False <TAB> self. selected_npn_protocols = [ ] <TAB> self. selected_alpn_protocols = [ ] <TAB> self. shared_ciphers = [ ] <TAB> self. conn_errors = [ ] <TAB> threading. Thread.",True,cacerts,cacerts,0.6620203256607056
|
||
|
1334,"def to_key ( literal_or_identifier ) : <TAB> """"""returns string representation of this object"""""" <TAB> if literal_or_identifier [ ""type"" ] == ""Identifier"" : <TAB> <TAB> return literal_or_identifier [ ""name"" ] <TAB> elif literal_or_identifier [ ""type"" ] == ""Literal"" : <TAB> <TAB> k = literal_or_identifier [ ""value"" ] <TAB> <TAB> if isinstance ( k, float ) : <TAB> <TAB> <TAB> return unicode ( float_repr ( k ) ) <TAB> <TAB> elif ""regex"" in literal_or_identifier : <TAB> <TAB> <TAB> return compose_regex ( k ) <TAB> <TAB> elif isinstance ( k, bool ) : <TAB> <TAB> <TAB> return ""true"" if k else ""false"" <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> return ""null"" <TAB> <TAB> else : <TAB> <TAB> <TAB> return unicode ( k )",True,k is None,k is None,0.6674331426620483
|
||
|
1335,"def load_package_list ( self, options_file ) : <TAB> json_wrapper_option_list = JsonWrapper ( options_file ) <TAB> option_list_json = json_wrapper_option_list. read ( ) <TAB> options_sorted = option_list_json. items ( ) <TAB> self. package_menu_items = [ ] <TAB> base_path = os. path. dirname ( options_file ) <TAB> package_list = [ ] <TAB> if len ( options_sorted ) == 1 : <TAB> <TAB> self. inactive_screen = True <TAB> <TAB> list ( options_sorted ) [ 0 ] [ 1 ] [ ""visible"" ] = True <TAB> if platform. machine ( ) == ""aarch64"" and ""realtime"" in dict ( options_sorted ) : <TAB> <TAB> dict ( options_sorted ) [ ""realtime"" ] [ ""visible"" ] = False <TAB> default_selected = 0 <TAB> visible_options_cnt = 0 <TAB> for install_option in options_sorted : <TAB> <TAB> if install_option [ 1 ] [ ""visible"" ] == True : <TAB> <TAB> <TAB> package_list = PackageSelector. get_packages_to_install ( <TAB> <TAB> <TAB> <TAB> install_option [ 1 ], base_path <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> self. package_menu_items. append ( <TAB> <TAB> <TAB> <TAB> ( <TAB> <TAB> <TAB> <TAB> <TAB> install_option [ 1 ] [ ""title"" ], <TAB> <TAB> <TAB> <TAB> <TAB> self. exit_function, <TAB> <TAB> <TAB> <TAB> <TAB> [ install_option [ 0 ], package_list ], <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> default_selected = visible_options_cnt <TAB> <TAB> <TAB> visible_options_cnt = visible_options_cnt + 1 <TAB> if self.",False,install_option[0] == 'minimal',visible_options_cnt >= 0,0.6488913297653198
|
||
|
1336,"def pack_identifier ( self ) : <TAB> """"""Return a combined identifier for the whole pack if this has more than one episode."""""" <TAB> <TAB> if self. id_type == ""ep"" : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return ""S%02dE%02d-E%02d"" % ( <TAB> <TAB> <TAB> <TAB> self. season, <TAB> <TAB> <TAB> <TAB> self. episode, <TAB> <TAB> <TAB> <TAB> self. episode + self. episodes - 1, <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return self. identifier <TAB> else : <TAB> <TAB> return self. identifier",False,self.episodes > 1,self.identifier is None,0.6666706800460815
|
||
|
1337,"def create_files ( self, problem_id, source_code, * args, ** kwargs ) : <TAB> super ( ). create_files ( problem_id, source_code, * args, ** kwargs ) <TAB> <TAB> try : <TAB> <TAB> source_code = utf8text ( source_code ) <TAB> except UnicodeDecodeError : <TAB> <TAB> raise CompileError ( ""Your UTF-8 is bad, and you should feel bad"" ) <TAB> class_name = find_class ( source_code ) <TAB> self. _code = self. _file ( ""%s.java"" % class_name. group ( 1 ) ) <TAB> try : <TAB> <TAB> with open ( self. _code, ""wb"" ) as fo : <TAB> <TAB> <TAB> fo. write ( utf8bytes ( source_code ) ) <TAB> except IOError as e : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise CompileError ( <TAB> <TAB> <TAB> <TAB> ""Why do you need a class name so long? As a judge, I sentence your code to death.\n"" <TAB> <TAB> <TAB> ) <TAB> <TAB> raise <TAB> self. _class_name = class_name. group ( 1 )",False,"e.errno in (errno.ENAMETOOLONG, errno.ENOENT, errno.EINVAL)",e.args[0] not in [TAB > 2,0.6500363349914551
|
||
|
1338,"def get_multi ( self, hrefs ) : <TAB> hrefs = set ( hrefs ) <TAB> href_xml = [ ] <TAB> for href in hrefs : <TAB> <TAB> if href!= self. _normalize_href ( href ) : <TAB> <TAB> <TAB> raise exceptions. NotFoundError ( href ) <TAB> <TAB> href_xml. append ( ""<D:href>{}</D:href>"". format ( href ) ) <TAB> if not href_xml : <TAB> <TAB> return ( ) <TAB> data = self. get_multi_template. format ( hrefs = ""\n"". join ( href_xml ) ). encode ( ""utf-8"" ) <TAB> response = self. session. request ( <TAB> <TAB> ""REPORT"", """", data = data, headers = self. session. get_default_headers ( ) <TAB> ) <TAB> root = _parse_xml ( response. content ) <TAB> rv = [ ] <TAB> hrefs_left = set ( hrefs ) <TAB> for href, etag, prop in self. _parse_prop_responses ( root ) : <TAB> <TAB> raw = prop. find ( self. get_multi_data_query ) <TAB> <TAB> if raw is None : <TAB> <TAB> <TAB> dav_logger. warning ( ""Skipping {}, the item content is missing."". format ( href ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> raw = raw. text or u"""" <TAB> <TAB> if isinstance ( raw, bytes ) : <TAB> <TAB> <TAB> raw = raw. decode ( response. encoding ) <TAB> <TAB> if isinstance ( etag, bytes ) : <TAB> <TAB> <TAB> etag = etag. decode ( response. encoding ) <TAB> <TAB> try : <TAB> <TAB> <TAB> hrefs_left. remove ( href ) <TAB> <TAB> except KeyError : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> dav_logger. warning ( ""Server sent item twice: {}"". format ( href ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB>",False,href in hrefs,href in hrefs_left,0.6747580766677856
|
||
|
1339,"def keyvault_id ( cmd, namespace ) : <TAB> """"""Validate storage account name"""""" <TAB> from azure. cli. core. profiles import ResourceType <TAB> from azure. cli. core. commands. client_factory import get_mgmt_service_client <TAB> if not namespace. keyvault : <TAB> <TAB> return <TAB> if ""/providers/Microsoft.KeyVault/vaults/"" in namespace. keyvault : <TAB> <TAB> resource = namespace. keyvault. split ( ""/"" ) <TAB> <TAB> kv_name = resource [ resource. index ( ""Microsoft.KeyVault"" ) + 2 ] <TAB> <TAB> kv_rg = resource [ resource. index ( ""resourceGroups"" ) + 1 ] <TAB> else : <TAB> <TAB> kv_name = namespace. keyvault <TAB> <TAB> kv_rg = namespace. resource_group_name <TAB> try : <TAB> <TAB> keyvault_client = get_mgmt_service_client ( <TAB> <TAB> <TAB> cmd. cli_ctx, ResourceType. MGMT_KEYVAULT <TAB> <TAB> ) <TAB> <TAB> vault = keyvault_client. vaults. get ( kv_rg, kv_name ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""KeyVault named '{}' not found in the resource group '{}'."". format ( <TAB> <TAB> <TAB> <TAB> <TAB> kv_name, kv_rg <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> namespace. keyvault = vault. id <TAB> <TAB> namespace. keyvault_url = vault. properties. vault_uri <TAB> except Exception as exp : <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> ""Invalid KeyVault reference: {}\n{}"". format ( namespace. keyvault, exp ) <TAB> <TAB> )",True,not vault,not vault,0.7056794166564941
|
||
|
1340,"def _get_dendrogram_key ( adata, dendrogram_key, groupby ) : <TAB> <TAB> <TAB> if not isinstance ( dendrogram_key, str ) : <TAB> <TAB> if isinstance ( groupby, str ) : <TAB> <TAB> <TAB> dendrogram_key = f""dendrogram_{groupby}"" <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> dendrogram_key = f'dendrogram_{""_"".join(groupby)}' <TAB> if dendrogram_key not in adata. uns : <TAB> <TAB> from.. tools. _dendrogram import dendrogram <TAB> <TAB> logg. warning ( <TAB> <TAB> <TAB> f""dendrogram data not found (using key={dendrogram_key}). "" <TAB> <TAB> <TAB> ""Running `sc.tl.dendrogram` with default parameters. For fine "" <TAB> <TAB> <TAB> ""tuning it is recommended to run `sc.tl.dendrogram` independently."" <TAB> <TAB> ) <TAB> <TAB> dendrogram ( adata, groupby, key_added = dendrogram_key ) <TAB> if ""dendrogram_info"" not in adata. uns [ dendrogram_key ] : <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> f""The given dendrogram key ({dendrogram_key!r}) does not contain "" <TAB> <TAB> <TAB> ""valid dendrogram information."" <TAB> <TAB> ) <TAB> return dendrogram_key",False,"isinstance(groupby, list)","isinstance(groupby, str)",0.6581349968910217
|
||
|
1341,"def iterate ( self, handle ) : <TAB> """"""Iterate over the records in the IntelliGenetics file."""""" <TAB> <TAB> for line in handle : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> break <TAB> else : <TAB> <TAB> <TAB> <TAB> return <TAB> if line [ 0 ]!= "";"" : <TAB> <TAB> raise ValueError ( ""Records should start with ';' and not:\n%r"" % line ) <TAB> while line : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> comment_lines = [ ] <TAB> <TAB> while line. startswith ( "";"" ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> comment_lines. append ( line [ 1 : ]. strip ( ) ) <TAB> <TAB> <TAB> line = next ( handle ) <TAB> <TAB> title = line. rstrip ( ) <TAB> <TAB> seq_lines = [ ] <TAB> <TAB> for line in handle : <TAB> <TAB> <TAB> if line [ 0 ] == "";"" : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> seq_lines. append ( line. rstrip ( ). replace ( "" "", """" ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> line = None <TAB> <TAB> seq_str = """". join ( seq_lines ) <TAB> <TAB> if seq_str. endswith ( ""1"" ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> seq_str = seq_str [ : - 1 ] <TAB> <TAB> if ""1"" in seq_str : <TAB> <TAB> <TAB> raise ValueError ( ""Potential terminator digit one found within sequence."" ) <TAB> <TAB> <TAB> <TAB> yield SeqRecord ( <TAB> <TAB> <TAB> Seq ( seq_str ), <TAB> <TAB> <TAB> id = title, <TAB> <TAB> <TAB> name = title, <TAB> <",False,not line.startswith(';;'),line == None,0.6516513228416443
|
||
|
1342,"def generateConstPy ( self ) : <TAB> log. debug ( ""========== generate_const.py()"" ) <TAB> fin = open ( os. path. join ( self. build_src, ""const.py.in"" ), ""r"" ) <TAB> in_lines = fin. readlines ( ) <TAB> fin. close ( ) <TAB> fout = open ( os. path. join ( self. build_src, ""const.py"" ), ""w"" ) <TAB> for line in in_lines : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> corrline = line. replace ( <TAB> <TAB> <TAB> <TAB> ""@VERSIONSTRING@"", self. gramps_version. replace ( FULL_COLON_SUBST, "":"" ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> fout. write ( corrline ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> fout. write ( line ) <TAB> fout. close ( )",False,'@VERSIONSTRING@' in line,self.gramps_version and line[0] in self.cw,0.6654828786849976
|
||
|
1343,"def prompt ( default = None ) : <TAB> editor = ""nano"" <TAB> with tempfile. NamedTemporaryFile ( mode = ""r+"" ) as tmpfile : <TAB> <TAB> if default : <TAB> <TAB> <TAB> tmpfile. write ( default ) <TAB> <TAB> <TAB> tmpfile. flush ( ) <TAB> <TAB> child_pid = os. fork ( ) <TAB> <TAB> is_child = child_pid == 0 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> os. execvp ( editor, [ editor, tmpfile. name ] ) <TAB> <TAB> else : <TAB> <TAB> <TAB> os. waitpid ( child_pid, 0 ) <TAB> <TAB> <TAB> tmpfile. seek ( 0 ) <TAB> <TAB> <TAB> return tmpfile. read ( ). strip ( )",True,is_child,is_child,0.6657383441925049
|
||
|
1344,"def replaceClassMethods ( ast, module_name, tree, class_name, class_node ) : <TAB> <TAB> old_class_node = None <TAB> for child in tree. node : <TAB> <TAB> if isinstance ( child, ast. Class ) and child. name == class_name : <TAB> <TAB> <TAB> old_class_node = child <TAB> <TAB> <TAB> break <TAB> if not old_class_node : <TAB> <TAB> raise TranslationError ( <TAB> <TAB> <TAB> ""class not found: "" + class_name, class_node, module_name <TAB> <TAB> ) <TAB> <TAB> for node in class_node. code : <TAB> <TAB> if isinstance ( node, ast. Function ) : <TAB> <TAB> <TAB> found = False <TAB> <TAB> <TAB> for child in old_class_node. code : <TAB> <TAB> <TAB> <TAB> if isinstance ( child, ast. Function ) and child. name == node. name : <TAB> <TAB> <TAB> <TAB> <TAB> found = True <TAB> <TAB> <TAB> <TAB> <TAB> copyFunction ( child, node ) <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> if not found : <TAB> <TAB> <TAB> <TAB> raise TranslationError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""class method not found: "" + class_name + ""."" + node. name, <TAB> <TAB> <TAB> <TAB> <TAB> node, <TAB> <TAB> <TAB> <TAB> <TAB> module_name, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> elif isinstance ( node, ast. Assign ) and isinstance ( node. nodes [ 0 ], ast. AssName ) : <TAB> <TAB> <TAB> found = False <TAB> <TAB> <TAB> for child in old_class_node. code : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> found = True <TAB> <",False,"isinstance(child, ast.Assign) and eqNodes(child.nodes, node.nodes)",found,0.6480258703231812
|
||
|
1345,"def prepare_request ( next_link = None ) : <TAB> <TAB> header_parameters = { } <TAB> header_parameters [ ""Accept"" ] = self. _serialize. header ( ""accept"", accept, ""str"" ) <TAB> if not next_link : <TAB> <TAB> <TAB> <TAB> url = self. list_for_scope. metadata [ ""url"" ] <TAB> <TAB> path_format_arguments = { <TAB> <TAB> <TAB> ""scope"" : self. _serialize. url ( ""scope"", scope, ""str"", skip_quote = True ), <TAB> <TAB> } <TAB> <TAB> url = self. _client. format_url ( url, ** path_format_arguments ) <TAB> <TAB> <TAB> <TAB> query_parameters = { } <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> query_parameters [ ""$filter"" ] = self. _serialize. query ( ""filter"", filter, ""str"" ) <TAB> <TAB> query_parameters [ ""api-version"" ] = self. _serialize. query ( <TAB> <TAB> <TAB> ""api_version"", api_version, ""str"" <TAB> <TAB> ) <TAB> <TAB> request = self. _client. get ( url, query_parameters, header_parameters ) <TAB> else : <TAB> <TAB> url = next_link <TAB> <TAB> query_parameters = { } <TAB> <TAB> request = self. _client. get ( url, query_parameters, header_parameters ) <TAB> return request",False,filter is not None,filter,0.6641092300415039
|
||
|
1346,"def postprocess ( <TAB> self, <TAB> upload_remote = True, <TAB> handle_log = True, <TAB> handle_touch = True, <TAB> handle_temp = True, <TAB> error = False, <TAB> ignore_missing_output = False, <TAB> assume_shared_fs = True, <TAB> latency_wait = None, <TAB> keep_metadata = True, ) : <TAB> if assume_shared_fs : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. dag. handle_touch ( self ) <TAB> <TAB> if handle_log : <TAB> <TAB> <TAB> self. dag. handle_log ( self ) <TAB> <TAB> if not error : <TAB> <TAB> <TAB> self. dag. check_and_touch_output ( <TAB> <TAB> <TAB> <TAB> self, wait = latency_wait, ignore_missing_output = ignore_missing_output <TAB> <TAB> <TAB> ) <TAB> <TAB> self. dag. unshadow_output ( self, only_log = error ) <TAB> <TAB> if not error : <TAB> <TAB> <TAB> self. dag. handle_remote ( self, upload = upload_remote ) <TAB> <TAB> <TAB> self. dag. handle_protected ( self ) <TAB> <TAB> self. close_remote ( ) <TAB> else : <TAB> <TAB> if not error : <TAB> <TAB> <TAB> self. dag. check_and_touch_output ( <TAB> <TAB> <TAB> <TAB> self, wait = latency_wait, no_touch = True, force_stay_on_remote = True <TAB> <TAB> <TAB> ) <TAB> if not error : <TAB> <TAB> try : <TAB> <TAB> <TAB> self. dag. workflow. persistence. finished ( self, keep_metadata = keep_metadata ) <TAB> <TAB> except IOError as e : <TAB> <TAB> <TAB> logger. warning ( <TAB> <TAB> <TAB> <TAB> ""Error recording metadata for finished job "" <TAB> <TAB> <TAB> <TAB> ""({}). Please",False,not error and handle_touch,handle_temp,0.6568975448608398
|
||
|
1347,"def IncrementErrorCount ( self, category ) : <TAB> """"""Bumps the module's error statistic."""""" <TAB> self. error_count += 1 <TAB> if self. counting in ( ""toplevel"", ""detailed"" ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> category = category. split ( ""/"" ) [ 0 ] <TAB> <TAB> if category not in self. errors_by_category : <TAB> <TAB> <TAB> self. errors_by_category [ category ] = 0 <TAB> <TAB> self. errors_by_category [ category ] += 1",False,self.counting != 'detailed',category.startswith('/'),0.6580263376235962
|
||
|
1348,"def _get_sub_path_ranges_and_colors ( self, start : float, end : float ) : <TAB> sub_path_ranges = [ ] <TAB> colors = [ ] <TAB> start = max ( 0, int ( start ) ) <TAB> end = int ( math. ceil ( end ) ) <TAB> if not self. protocol. messages : <TAB> <TAB> return None, None <TAB> for message in self. protocol. messages : <TAB> <TAB> if message. bit_sample_pos [ - 2 ] < start : <TAB> <TAB> <TAB> continue <TAB> <TAB> color = ( <TAB> <TAB> <TAB> None <TAB> <TAB> <TAB> if message. participant is None <TAB> <TAB> <TAB> else settings. PARTICIPANT_COLORS [ message. participant. color_index ] <TAB> <TAB> ) <TAB> <TAB> if color is None : <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> sub_path_ranges. append ( ( start, message. bit_sample_pos [ 0 ] ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> colors. append ( None ) <TAB> <TAB> else : <TAB> <TAB> <TAB> colors. append ( color ) <TAB> <TAB> if message. bit_sample_pos [ - 2 ] > end : <TAB> <TAB> <TAB> sub_path_ranges. append ( ( message. bit_sample_pos [ 0 ], end ) ) <TAB> <TAB> <TAB> colors. append ( color ) <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> sub_path_ranges. append ( <TAB> <TAB> <TAB> ( message. bit_sample_pos [ 0 ], message. bit_sample_pos [ - 2 ] + 1 ) <TAB> <TAB> ) <TAB> <TAB> colors. append ( color ) <TAB> <TAB> start = message. bit_sample_pos [ - 2 ] + 1 <TAB> if sub_path_ranges and sub_path_ranges [ - 1 ] [ 1 ]!= end : <TAB> <TAB",False,start < message.bit_sample_pos[0],color is None,0.6493573188781738
|
||
|
1349,"def _hash ( self, bytes, aggresive = False ) : <TAB> idx = 0 <TAB> ret = [ ] <TAB> output_size = self. output_size <TAB> ignore_range = self. ignore_range <TAB> bsize = self. bsize <TAB> total_size = len ( bytes ) <TAB> rappend = ret. append <TAB> reduce_errors = self. reduce_errors <TAB> <TAB> while 1 : <TAB> <TAB> chunk_size = idx * bsize <TAB> <TAB> buf = bytes [ chunk_size : chunk_size + bsize ] <TAB> <TAB> char = modsum ( buf ) <TAB> <TAB> if reduce_errors : <TAB> <TAB> <TAB> if char!= 255 and char!= 0 : <TAB> <TAB> <TAB> <TAB> rappend ( chr ( char ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> rappend ( chr ( char ) ) <TAB> <TAB> idx += 1 <TAB> <TAB> if chunk_size + bsize > total_size : <TAB> <TAB> <TAB> break <TAB> ret = """". join ( ret ) <TAB> size = len ( ret ) / output_size <TAB> size = min ( int ( size ), 1 ) <TAB> buf = [ ] <TAB> <TAB> for c in range ( 0, output_size ) : <TAB> <TAB> if aggresive : <TAB> <TAB> <TAB> buf. append ( ret [ c : c + size + 1 ] [ ignore_range : ignore_range + 1 ] ) <TAB> <TAB> else : <TAB> <TAB> <TAB> buf. append ( ret [ c : c + size + 1 ] [ 1 : 2 ] ) <TAB> <TAB> i = 0 <TAB> <TAB> for x in ret [ c : c + size + 1 ] : <TAB> <TAB> <TAB> i += 1 <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> i = 0 <TAB> <TAB> <TAB> buf += x <TAB> <TAB> <TAB>",False,i != ignore_range,i == 0,0.6598858833312988
|
||
|
1350,"def _update_scale ( self, skip ) : <TAB> if self. dynamic_loss_scale : <TAB> <TAB> prev_scale = self. cur_scale <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. cur_scale = max ( <TAB> <TAB> <TAB> <TAB> self. cur_scale / self. scale_factor, self. min_loss_scale <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> self. last_overflow_iter = self. cur_iter <TAB> <TAB> <TAB> if self. verbose : <TAB> <TAB> <TAB> <TAB> logger. info ( f""\nGrad overflow on iteration {self.cur_iter}"" ) <TAB> <TAB> <TAB> <TAB> logger. info ( <TAB> <TAB> <TAB> <TAB> <TAB> f""Reducing dynamic loss scale from {prev_scale} to {self.cur_scale}"" <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> stable_interval = ( self. cur_iter - self. last_overflow_iter ) - 1 <TAB> <TAB> <TAB> if ( stable_interval > 0 ) and ( stable_interval % self. scale_window == 0 ) : <TAB> <TAB> <TAB> <TAB> self. cur_scale *= self. scale_factor <TAB> <TAB> <TAB> <TAB> if self. verbose : <TAB> <TAB> <TAB> <TAB> <TAB> logger. info ( f""No Grad overflow for {self.scale_window} iterations"" ) <TAB> <TAB> <TAB> <TAB> <TAB> logger. info ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> f""Increasing dynamic loss scale from {prev_scale} to {self.cur_scale}"" <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> logger. info ( ""Grad overflow on iteration: %s"", self. cur_iter ) <",True,skip,skip,0.681114912033081
|
||
|
1351,"def consume ( self, event : Mapping [ str, Any ] ) -> None : <TAB> user_profile_id = event [ ""user_profile_id"" ] <TAB> user_profile = get_user_profile_by_id ( user_profile_id ) <TAB> message : Dict [ str, Any ] = event [ ""message"" ] <TAB> <TAB> services = get_bot_services ( user_profile_id ) <TAB> for service in services : <TAB> <TAB> bot_handler = get_bot_handler ( str ( service. name ) ) <TAB> <TAB> if bot_handler is None : <TAB> <TAB> <TAB> logging. error ( <TAB> <TAB> <TAB> <TAB> ""Error: User %s has bot with invalid embedded bot service %s"", <TAB> <TAB> <TAB> <TAB> user_profile_id, <TAB> <TAB> <TAB> <TAB> service. name, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> continue <TAB> <TAB> try : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> bot_handler. initialize ( self. get_bot_api_client ( user_profile ) ) <TAB> <TAB> <TAB> if event [ ""trigger"" ] == ""mention"" : <TAB> <TAB> <TAB> <TAB> message [ ""content"" ] = extract_query_without_mention ( <TAB> <TAB> <TAB> <TAB> <TAB> message = message, <TAB> <TAB> <TAB> <TAB> <TAB> client = cast ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ExternalBotHandler, self. get_bot_api_client ( user_profile ) <TAB> <TAB> <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> assert message [ ""content"" ] is not None <TAB> <TAB> <TAB> bot_handler. handle_message ( <TAB> <TAB> <TAB> <TAB> message = message, <TAB> <TAB> <TAB> <TAB",False,"hasattr(bot_handler, 'initialize')",bot_handler is None,0.6545403003692627
|
||
|
1352,"def save_bytearray ( self, obj ) : <TAB> if self. proto < 5 : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. save_reduce ( bytearray, ( ), obj = obj ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. save_reduce ( bytearray, ( bytes ( obj ), ), obj = obj ) <TAB> <TAB> return <TAB> n = len ( obj ) <TAB> if n >= self. framer. _FRAME_SIZE_TARGET : <TAB> <TAB> self. _write_large_bytes ( BYTEARRAY8 + pack ( ""<Q"", n ), obj ) <TAB> else : <TAB> <TAB> self. write ( BYTEARRAY8 + pack ( ""<Q"", n ) + obj )",False,not obj,self.framer._FRAME_SIZE_TARGET,0.690361738204956
|
||
|
1353,"def test_grains_overwrite ( self ) : <TAB> <TAB> self. run_function ( ""saltutil.sync_grains"" ) <TAB> <TAB> <TAB> <TAB> <TAB> module = os. path. join ( <TAB> <TAB> RUNTIME_VARS. RUNTIME_CONFIGS [ ""minion"" ] [ ""cachedir"" ], <TAB> <TAB> ""files"", <TAB> <TAB> ""base"", <TAB> <TAB> ""_grains"", <TAB> <TAB> ""custom_grain2.py"", <TAB> ) <TAB> tries = 0 <TAB> while not os. path. exists ( module ) : <TAB> <TAB> tries += 1 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. fail ( <TAB> <TAB> <TAB> <TAB> ""Failed to found custom grains module in cache path {}"". format ( module ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> break <TAB> <TAB> time. sleep ( 1 ) <TAB> grains = self. run_function ( ""grains.items"" ) <TAB> <TAB> self. assertEqual ( { ""k2"" : ""v2"" }, grains [ ""a_custom"" ] )",False,tries > 60,tries > 3,0.689618706703186
|
||
|
1354,"def test_patches ( ) : <TAB> print ( <TAB> <TAB> ""Botocore version: {} aiohttp version: {}"". format ( <TAB> <TAB> <TAB> botocore. __version__, aiohttp. __version__ <TAB> <TAB> ) <TAB> ) <TAB> success = True <TAB> for obj, digests in chain ( _AIOHTTP_DIGESTS. items ( ), _API_DIGESTS. items ( ) ) : <TAB> <TAB> digest = hashlib. sha1 ( getsource ( obj ). encode ( ""utf-8"" ) ). hexdigest ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> ""Digest of {}:{} not found in: {}"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> obj. __qualname__, digest, digests <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> success = False <TAB> assert success",False,digest not in digests,digest,0.6627613306045532
|
||
|
1355,"def clean ( self ) : <TAB> super ( ). clean ( ) <TAB> <TAB> if self. cluster. site is not None : <TAB> <TAB> for device in self. cleaned_data. get ( ""devices"", [ ] ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise ValidationError ( <TAB> <TAB> <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""devices"" : ""{} belongs to a different site ({}) than the cluster ({})"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> device, device. site, self. cluster. site <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> } <TAB> <TAB> <TAB> <TAB> )",True,device.site != self.cluster.site,device.site != self.cluster.site,0.6559698581695557
|
||
|
1356,"def _invoke ( self, args, remote, autoraise ) : <TAB> raise_opt = [ ] <TAB> if remote and self. raise_opts : <TAB> <TAB> <TAB> <TAB> autoraise = int ( bool ( autoraise ) ) <TAB> <TAB> opt = self. raise_opts [ autoraise ] <TAB> <TAB> if opt : <TAB> <TAB> <TAB> raise_opt = [ opt ] <TAB> cmdline = [ self. name ] + raise_opt + args <TAB> if remote or self. background : <TAB> <TAB> inout = file ( os. devnull, ""r+"" ) <TAB> else : <TAB> <TAB> <TAB> <TAB> inout = None <TAB> <TAB> <TAB> setsid = getattr ( os, ""setsid"", None ) <TAB> if not setsid : <TAB> <TAB> setsid = getattr ( os, ""setpgrp"", None ) <TAB> p = subprocess. Popen ( <TAB> <TAB> cmdline, <TAB> <TAB> close_fds = True, <TAB> <TAB> stdin = inout, <TAB> <TAB> stdout = ( self. redirect_stdout and inout or None ), <TAB> <TAB> stderr = inout, <TAB> <TAB> preexec_fn = setsid, <TAB> ) <TAB> if remote : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> time. sleep ( 1 ) <TAB> <TAB> rc = p. poll ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> time. sleep ( 4 ) <TAB> <TAB> <TAB> rc = p. poll ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return True <TAB> <TAB> <TAB> <TAB> return not rc <TAB> elif self. background : <TAB> <TAB> if p. poll ( ) is None : <TAB> <TAB> <TAB> return True <TAB> <TAB> else : <TAB> <TAB> <TAB> return False <TAB> else : <TAB> <TAB> return not p. wait ( )",False,rc is None,rc,0.6618880033493042
|
||
|
1357,"def send_request_check_version ( self, record ) : <TAB> assert record. control. req_resp <TAB> result = wandb_internal_pb2. Result ( uuid = record. uuid ) <TAB> current_version = record. request. check_version. current_version or wandb. __version__ <TAB> messages = update. check_available ( current_version ) <TAB> if messages : <TAB> <TAB> upgrade_message = messages. get ( ""upgrade_message"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> result. response. check_version_response. upgrade_message = upgrade_message <TAB> <TAB> yank_message = messages. get ( ""yank_message"" ) <TAB> <TAB> if yank_message : <TAB> <TAB> <TAB> result. response. check_version_response. yank_message = yank_message <TAB> <TAB> delete_message = messages. get ( ""delete_message"" ) <TAB> <TAB> if delete_message : <TAB> <TAB> <TAB> result. response. check_version_response. delete_message = delete_message <TAB> self. _result_q. put ( result )",True,upgrade_message,upgrade_message,0.6672766208648682
|
||
|
1358,"def __eq__ ( self, other : object ) -> bool : <TAB> if not isinstance ( other, Unk ) : <TAB> <TAB> return NotImplemented <TAB> if not np. allclose ( self. ng, other. ng ) : <TAB> <TAB> return False <TAB> if self. ik!= other. ik : <TAB> <TAB> return False <TAB> if self. is_noncollinear!= other. is_noncollinear : <TAB> <TAB> return False <TAB> if self. nbnd!= other. nbnd : <TAB> <TAB> return False <TAB> for ib in range ( self. nbnd ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if not ( <TAB> <TAB> <TAB> <TAB> np. allclose ( self. data [ ib, 0 ], other. data [ ib, 0 ], atol = 1e-4 ) <TAB> <TAB> <TAB> <TAB> and np. allclose ( self. data [ ib, 1 ], other. data [ ib, 1 ], atol = 1e-4 ) <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> return False <TAB> <TAB> else : <TAB> <TAB> <TAB> if not np. allclose ( self. data [ ib ], other. data [ ib ], atol = 1e-4 ) : <TAB> <TAB> <TAB> <TAB> return False <TAB> return True",False,self.is_noncollinear,len(self.data) != len(other.data),0.6547691822052002
|
||
|
1359,"def _load_test_data ( ) : <TAB> configs = [ ] <TAB> datasets = [ ] <TAB> for _ in range ( NUM_ENVS ) : <TAB> <TAB> config = get_config ( CFG_TEST ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> pytest. skip ( ""Please download Habitat test data to data folder."" ) <TAB> <TAB> datasets. append ( <TAB> <TAB> <TAB> habitat. make_dataset ( id_dataset = config. DATASET. TYPE, config = config. DATASET ) <TAB> <TAB> ) <TAB> <TAB> config. defrost ( ) <TAB> <TAB> config. SIMULATOR. SCENE = datasets [ - 1 ]. episodes [ 0 ]. scene_id <TAB> <TAB> if not os. path. exists ( config. SIMULATOR. SCENE ) : <TAB> <TAB> <TAB> pytest. skip ( ""Please download Habitat test data to data folder."" ) <TAB> <TAB> config. freeze ( ) <TAB> <TAB> configs. append ( config ) <TAB> return configs, datasets",False,not PointNavDatasetV1.check_config_paths_exist(config.DATASET),not os.path.exists(config.DATASET.TYPE),0.6497238874435425
|
||
|
1360,"def update_sysconfig_file ( fn, adjustments, allow_empty = False ) : <TAB> if not adjustments : <TAB> <TAB> return <TAB> ( exists, contents ) = read_sysconfig_file ( fn ) <TAB> updated_am = 0 <TAB> for ( k, v ) in adjustments. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> v = str ( v ) <TAB> <TAB> if len ( v ) == 0 and not allow_empty : <TAB> <TAB> <TAB> continue <TAB> <TAB> contents [ k ] = v <TAB> <TAB> updated_am += 1 <TAB> if updated_am : <TAB> <TAB> lines = [ <TAB> <TAB> <TAB> str ( contents ), <TAB> <TAB> ] <TAB> <TAB> if not exists : <TAB> <TAB> <TAB> lines. insert ( 0, util. make_header ( ) ) <TAB> <TAB> util. write_file ( fn, ""\n"". join ( lines ) + ""\n"", 0o644 )",False,v is None,k == 'TAB > <TAB > <TAB > or exists,0.6659239530563354
|
||
|
1361,"def phpfilter_extract ( content ) : <TAB> ftemp = """" <TAB> found = [ ] <TAB> lines = content. split ( ""\n"" ) <TAB> for line in lines : <TAB> <TAB> ftemp = """" <TAB> <TAB> length = len ( line ) <TAB> <TAB> for x in range ( 0, length ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> ftemp += line [ x ] <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> if ( <TAB> <TAB> <TAB> <TAB> <TAB> length > 100 <TAB> <TAB> <TAB> <TAB> <TAB> and base64_check ( line [ x ] ) is False <TAB> <TAB> <TAB> <TAB> <TAB> and len ( ftemp ) >= int ( ( length / 2 ) ) <TAB> <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> ftemp = """" <TAB> <TAB> if len ( ftemp ) > 0 : <TAB> <TAB> <TAB> found. append ( ftemp ) <TAB> final = """" <TAB> if len ( found ) > 50 : <TAB> <TAB> maxim = 0 <TAB> <TAB> x = """" <TAB> <TAB> index = - 1 <TAB> <TAB> for x in range ( 0, len ( found ) ) : <TAB> <TAB> <TAB> length = len ( found [ x ] ) <TAB> <TAB> <TAB> if length > maxim : <TAB> <TAB> <TAB> <TAB> maxim = length <TAB> <TAB> <TAB> <TAB> index = x <TAB> <TAB> final = found [ x ] <TAB> return final",False,base64_check(line[x]),ftemp,0.6507961750030518
|
||
|
1362,"def __merge_rpc_configs ( self, rpc_params, rpc_config ) : <TAB> config = { } <TAB> options = { <TAB> <TAB> ""nodeId"" : self. UNKNOWN_ARBITRATION_ID, <TAB> <TAB> ""isExtendedId"" : self. DEFAULT_EXTENDED_ID_FLAG, <TAB> <TAB> ""isFd"" : self. DEFAULT_FD_FLAG, <TAB> <TAB> ""bitrateSwitch"" : self. DEFAULT_BITRATE_SWITCH_FLAG, <TAB> <TAB> ""response"" : True, <TAB> <TAB> ""dataLength"" : 1, <TAB> <TAB> ""dataByteorder"" : self. DEFAULT_BYTEORDER, <TAB> <TAB> ""dataSigned"" : self. DEFAULT_SIGNED_FLAG, <TAB> <TAB> ""dataExpression"" : None, <TAB> <TAB> ""dataEncoding"" : self. DEFAULT_ENCODING, <TAB> <TAB> ""dataBefore"" : None, <TAB> <TAB> ""dataAfter"" : None, <TAB> <TAB> ""dataInHex"" : None, <TAB> } <TAB> for option_name, option_value in options. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> config [ option_name ] = rpc_params [ option_name ] <TAB> <TAB> elif option_value is not None : <TAB> <TAB> <TAB> config [ option_name ] = rpc_config. get ( option_name, option_value ) <TAB> return config",True,option_name in rpc_params,option_name in rpc_params,0.663283109664917
|
||
|
1363,"def _form_master_re ( relist, reflags, ldict, toknames ) : <TAB> if not relist : <TAB> <TAB> return [ ] <TAB> regex = ""|"". join ( relist ) <TAB> try : <TAB> <TAB> lexre = re. compile ( regex, reflags ) <TAB> <TAB> <TAB> <TAB> lexindexfunc = [ None ] * ( max ( lexre. groupindex. values ( ) ) + 1 ) <TAB> <TAB> lexindexnames = lexindexfunc [ : ] <TAB> <TAB> for f, i in lexre. groupindex. items ( ) : <TAB> <TAB> <TAB> handle = ldict. get ( f, None ) <TAB> <TAB> <TAB> if type ( handle ) in ( types. FunctionType, types. MethodType ) : <TAB> <TAB> <TAB> <TAB> lexindexfunc [ i ] = ( handle, toknames [ f ] ) <TAB> <TAB> <TAB> <TAB> lexindexnames [ i ] = f <TAB> <TAB> <TAB> elif handle is not None : <TAB> <TAB> <TAB> <TAB> lexindexnames [ i ] = f <TAB> <TAB> <TAB> <TAB> if f. find ( ""ignore_"" ) > 0 : <TAB> <TAB> <TAB> <TAB> <TAB> lexindexfunc [ i ] = ( None, None ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> lexindexfunc [ i ] = ( None, toknames [ f ] ) <TAB> <TAB> return [ ( lexre, lexindexfunc ) ], [ regex ], [ lexindexnames ] <TAB> except Exception : <TAB> <TAB> m = int ( len ( relist ) / 2 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> m = 1 <TAB> <TAB> llist, lre, lnames = _form_master_re ( relist [ : m ], reflags, ldict, toknames ) <TAB> <TAB> rlist, rre, rnames = _form_master_re ( relist [ m : ]",False,m == 0,m > 1,0.6690990924835205
|
||
|
1364,"def remaining_paragraph_count ( self ) : <TAB> """"""Return the remaining paragraph count for this post (does not include teaser)."""""" <TAB> if self. _remaining_paragraph_count is None : <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> document = lxml. html. fragment_fromstring ( <TAB> <TAB> <TAB> <TAB> self. text ( teaser_only = True, show_read_more_link = False ), ""body"" <TAB> <TAB> <TAB> ) <TAB> <TAB> except lxml. etree. ParserError as e : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return """" <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> raise ( e ) <TAB> <TAB> self. _remaining_paragraph_count = self. paragraph_count - int ( <TAB> <TAB> <TAB> document. xpath ( ""count(//p)"" ) <TAB> <TAB> ) <TAB> return self. _remaining_paragraph_count",False,str(e) == 'Document is empty',self.paragraph_count is None,0.6522060036659241
|
||
|
1365,"def get_exe_prefixes ( exe_filename ) : <TAB> """"""Get exe->egg path translations for a given.exe file"""""" <TAB> prefixes = [ <TAB> <TAB> ( ""PURELIB/"", """" ), <TAB> <TAB> ( ""PLATLIB/pywin32_system32"", """" ), <TAB> <TAB> ( ""PLATLIB/"", """" ), <TAB> <TAB> ( ""SCRIPTS/"", ""EGG-INFO/scripts/"" ), <TAB> <TAB> ( ""DATA/lib/site-packages"", """" ), <TAB> ] <TAB> z = zipfile. ZipFile ( exe_filename ) <TAB> try : <TAB> <TAB> for info in z. infolist ( ) : <TAB> <TAB> <TAB> name = info. filename <TAB> <TAB> <TAB> parts = name. split ( ""/"" ) <TAB> <TAB> <TAB> if len ( parts ) == 3 and parts [ 2 ] == ""PKG-INFO"" : <TAB> <TAB> <TAB> <TAB> if parts [ 1 ]. endswith ( "".egg-info"" ) : <TAB> <TAB> <TAB> <TAB> <TAB> prefixes. insert ( 0, ( ""/"". join ( parts [ : 2 ] ), ""EGG-INFO/"" ) ) <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> if len ( parts )!= 2 or not name. endswith ( "".pth"" ) : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if name. endswith ( ""-nspkg.pth"" ) : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if parts [ 0 ]. upper ( ) in ( ""PURELIB"", ""PLATLIB"" ) : <TAB> <TAB> <TAB> <TAB> contents = z. read ( name ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> contents = contents. decode ( ) <TAB> <TAB> <TAB> <TAB> for pth in yield_lines ( contents ) : <TAB> <TAB> <",False,six.PY3,len(contents) > 0,0.6605470180511475
|
||
|
1366,"def is_move_suicidal ( self, move ) : <TAB> potential_libs = set ( ) <TAB> for n in NEIGHBORS [ move ] : <TAB> <TAB> neighbor_group_id = self. lib_tracker. group_index [ n ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return False <TAB> <TAB> neighbor_group = self. lib_tracker. groups [ neighbor_group_id ] <TAB> <TAB> if neighbor_group. color == self. to_play : <TAB> <TAB> <TAB> potential_libs |= neighbor_group. liberties <TAB> <TAB> elif len ( neighbor_group. liberties ) == 1 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return False <TAB> <TAB> <TAB> potential_libs -= set ( [ move ] ) <TAB> return not potential_libs",False,neighbor_group_id == MISSING_GROUP_ID,neighbor_group_id == 0,0.6545580625534058
|
||
|
1367,"def get_build_provider_flags ( build_provider : str, ** kwargs ) -> Dict [ str, str ] : <TAB> """"""Get configured options applicable to build_provider."""""" <TAB> build_provider_flags : Dict [ str, str ] = dict ( ) <TAB> <TAB> if build_provider not in _ALL_PROVIDERS : <TAB> <TAB> raise RuntimeError ( f""Invalid build provider: {build_provider}"" ) <TAB> for option in _PROVIDER_OPTIONS : <TAB> <TAB> key : str = option [ ""param_decls"" ] <TAB> <TAB> is_flag : bool = option. get ( ""is_flag"", False ) <TAB> <TAB> envvar : Optional [ str ] = option. get ( ""envvar"" ) <TAB> <TAB> supported_providers : List [ str ] = option [ ""supported_providers"" ] <TAB> <TAB> <TAB> <TAB> if key == ""--provider"" : <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> key_formatted = _param_decls_to_kwarg ( key ) <TAB> <TAB> if is_flag and not kwargs. get ( key_formatted ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> if envvar is not None and key_formatted in kwargs : <TAB> <TAB> <TAB> build_provider_flags [ envvar ] = kwargs [ key_formatted ] <TAB> return build_provider_flags",False,build_provider not in supported_providers,supported_providers,0.6572281122207642
|
||
|
1368,"def find_exception_in_output ( data ) : <TAB> have_traceback = False <TAB> for line in data. splitlines ( ) : <TAB> <TAB> line = line. decode ( ""ascii"" ) <TAB> <TAB> if line. startswith ( ""Traceback ("" ) : <TAB> <TAB> <TAB> have_traceback = True <TAB> <TAB> <TAB> continue <TAB> <TAB> if line. startswith ( "" "" ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> if have_traceback : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> m = re_exception. match ( line ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> exc_type, args = m. groups ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> bits = exc_type. split ( ""."", 1 ) <TAB> <TAB> <TAB> <TAB> if len ( bits ) > 1 : <TAB> <TAB> <TAB> <TAB> <TAB> mod = __import__ ( bits [ 0 ] ) <TAB> <TAB> <TAB> <TAB> <TAB> exc = getattr ( mod, bits [ 1 ] ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> exc = eval ( bits [ 0 ] ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> exc = eval ( line. strip ( ) ) <TAB> <TAB> <TAB> <TAB> <TAB> args = ""()"" <TAB> <TAB> <TAB> <TAB> except : <TAB> <TAB> <TAB> <TAB> <TAB> return None <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> args = eval ( args ) <TAB",False,m,m is not None,0.7010300159454346
|
||
|
1369,"def extract ( self, png ) : <TAB> if ""header"" in png : <TAB> <TAB> self. useHeader ( png [ ""header"" ] ) <TAB> if ""time"" in png : <TAB> <TAB> self. useTime ( png [ ""time"" ] ) <TAB> if ""physical"" in png : <TAB> <TAB> self. usePhysical ( png [ ""physical"" ] ) <TAB> for comment in png. array ( ""text"" ) : <TAB> <TAB> if ""text"" not in comment : <TAB> <TAB> <TAB> continue <TAB> <TAB> keyword = comment [ ""keyword"" ]. value <TAB> <TAB> text = comment [ ""text"" ]. value <TAB> <TAB> try : <TAB> <TAB> <TAB> key = self. TEXT_TO_ATTR [ keyword. lower ( ) ] <TAB> <TAB> <TAB> setattr ( self, key, text ) <TAB> <TAB> except KeyError : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. comment = ""%s=%s"" % ( keyword, text ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. comment = text <TAB> compr_size = sum ( data. size for data in png. array ( ""data"" ) ) <TAB> computeComprRate ( self, compr_size )",False,keyword.lower() != 'comment',keyword.lower() in self.TEXT_TO_ATTR,0.6543689966201782
|
||
|
1370,"def post_config_hook ( self ) : <TAB> servers = [ ""dunst"", ""mako"", ""xfce4-notifyd"", None ] <TAB> if not self. server : <TAB> <TAB> for server in servers : <TAB> <TAB> <TAB> if server : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> if self. py3. command_output ( [ ""pgrep"", ""-x"", server ] ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. server = server <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> except self. py3. CommandError : <TAB> <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> else : <TAB> <TAB> <TAB> self. server = self. py3. check_commands ( servers [ : - 1 ] ) or ""dunst"" <TAB> elif self. server not in servers : <TAB> <TAB> raise Exception ( STRING_INVALID_SERVER. format ( self. server ) ) <TAB> else : <TAB> <TAB> command = self. server. replace ( ""notifyd"", ""notifyd-config"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise Exception ( STRING_NOT_INSTALLED. format ( command ) ) <TAB> if self. server == ""dunst"" : <TAB> <TAB> self. backend = Dunst ( self ) <TAB> elif self. server == ""mako"" : <TAB> <TAB> self. backend = Mako ( self ) <TAB> elif self. server == ""xfce4-notifyd"" : <TAB> <TAB> self. backend = Xfce4_notifyd ( self ) <TAB> if self. state is not None : <TAB> <TAB> if self. state == ""last"" : <TAB> <TAB> <TAB> self. state = self. py3. storage_get ( ""state"" ) or 0 <TAB> <TAB> if self. state in [ False, True ] : <TAB>",False,not self.py3.check_commands(command),command not in self.COMMAND_MAP,0.6521279215812683
|
||
|
1371,"def writer ( self ) : <TAB> """"""loop forever and copy socket->serial"""""" <TAB> while self. alive : <TAB> <TAB> try : <TAB> <TAB> <TAB> data = self. socket. recv ( 1024 ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> self. serial. write ( b"""". join ( self. rfc2217. filter ( data ) ) ) <TAB> <TAB> except socket. error as msg : <TAB> <TAB> <TAB> self. log. error ( ""{}"". format ( msg ) ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> self. stop ( )",False,not data,len(data) > 0,0.6720389127731323
|
||
|
1372,"def removedir ( self, path ) : <TAB> <TAB> _path = self. validatepath ( path ) <TAB> if _path == ""/"" : <TAB> <TAB> raise errors. RemoveRootError ( ) <TAB> with ftp_errors ( self, path ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> self. ftp. rmd ( _encode ( _path, self. ftp. encoding ) ) <TAB> <TAB> except error_perm as error : <TAB> <TAB> <TAB> code, _ = _parse_ftp_error ( error ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> if self. isfile ( path ) : <TAB> <TAB> <TAB> <TAB> <TAB> raise errors. DirectoryExpected ( path ) <TAB> <TAB> <TAB> <TAB> if not self. isempty ( path ) : <TAB> <TAB> <TAB> <TAB> <TAB> raise errors. DirectoryNotEmpty ( path ) <TAB> <TAB> <TAB> raise",False,code == '550',code == 0,0.6604022979736328
|
||
|
1373,"def parse_raw_res ( raw_res ) : <TAB> """"""this function copied from dagster-airflow.operators.util for now"""""" <TAB> assert isinstance ( raw_res, list ) <TAB> res = None <TAB> <TAB> <TAB> <TAB> <TAB> lines = [ ] <TAB> coalesced = [ ] <TAB> in_split_line = False <TAB> for line in raw_res : <TAB> <TAB> if not in_split_line and line. startswith ( ""{"" ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> lines. append ( line ) <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> coalesced. append ( line ) <TAB> <TAB> <TAB> <TAB> in_split_line = True <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> if in_split_line : <TAB> <TAB> <TAB> coalesced. append ( line ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> lines. append ( """". join ( coalesced ) ) <TAB> <TAB> <TAB> <TAB> coalesced = [ ] <TAB> <TAB> <TAB> <TAB> in_split_line = False <TAB> for line in reversed ( lines ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> res = seven. json. loads ( line ) <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> except seven. JSONDecodeError as e : <TAB> <TAB> <TAB> print ( ""[parse_raw_res error]"", e ) <TAB> <TAB> <TAB> continue <TAB> return res",False,line.endswith('}'),coalesced,0.6589871644973755
|
||
|
1374,"def find_songs_that_start_with_word ( word ) : <TAB> max_titles = 20 <TAB> max_offset = 200 <TAB> offset = 0 <TAB> out = [ ] <TAB> while offset < max_offset and len ( out ) < max_titles : <TAB> <TAB> results = sp. search ( q = word, type = ""track"", limit = 50, offset = offset ) <TAB> <TAB> if len ( results [ ""tracks"" ] [ ""items"" ] ) == 0 : <TAB> <TAB> <TAB> break <TAB> <TAB> for item in results [ ""tracks"" ] [ ""items"" ] : <TAB> <TAB> <TAB> name = item [ ""name"" ]. lower ( ) <TAB> <TAB> <TAB> if name in seen : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> seen. add ( name ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if ""-"" in name : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if ""/"" in name : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> words = name. split ( ) <TAB> <TAB> <TAB> if len ( words ) > 1 and words [ 0 ] == word and words [ - 1 ] not in skiplist : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> out. append ( item ) <TAB> <TAB> offset += 50 <TAB> <TAB> return out",False,'(' in name,not name,0.6635199785232544
|
||
|
1375,"def handle ( self, * args, ** options ) : <TAB> app_name = options. get ( ""app_name"" ) <TAB> job_name = options. get ( ""job_name"" ) <TAB> <TAB> if app_name and not job_name : <TAB> <TAB> job_name = app_name <TAB> <TAB> app_name = None <TAB> if options. get ( ""list_jobs"" ) : <TAB> <TAB> print_jobs ( only_scheduled = False, show_when = True, show_appname = True ) <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> print ( ""Run a single maintenance job. Please specify the name of the job."" ) <TAB> <TAB> <TAB> return <TAB> <TAB> self. runjob ( app_name, job_name, options )",False,not job_name,options.get('list_maintenance_job'),0.6594098806381226
|
||
|
1376,"def _songmeanings ( artist, song ) : <TAB> service_name = ""Songmeanings"" <TAB> url = """" <TAB> try : <TAB> <TAB> searchurl = ""http://songmeanings.com/m/query/?q=%s %s"" % ( artist, song ) <TAB> <TAB> searchresults = requests. get ( searchurl, proxies = proxy ) <TAB> <TAB> soup = BeautifulSoup ( searchresults. text, ""html.parser"" ) <TAB> <TAB> url = """" <TAB> <TAB> for link in soup. find_all ( ""a"", href = True ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> url = ""https:"" + link [ ""href"" ] <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> elif ""/m/songs/view/"" in link [ ""href"" ] : <TAB> <TAB> <TAB> <TAB> result = ""http://songmeanings.com"" + link [ ""href"" ] <TAB> <TAB> <TAB> <TAB> lyricspage = requests. get ( result, proxies = proxy ) <TAB> <TAB> <TAB> <TAB> soup = BeautifulSoup ( lyricspage. text, ""html.parser"" ) <TAB> <TAB> <TAB> <TAB> url = ""http://songmeanings.com"" + link [ ""href"" ] [ 2 : ] <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> templyrics = soup. find_all ( ""li"" ) [ 4 ] <TAB> <TAB> lyrics = templyrics. getText ( ) <TAB> <TAB> lyrics = lyrics. split ( ""(r,s)};})();"" ) [ 1 ] <TAB> except Exception : <TAB> <TAB> lyrics = error <TAB> if lyrics == ""We are currently missing these lyrics."" : <TAB> <TAB> lyrics = error <TAB> <TAB> return ( lyrics, url,",False,'songmeanings.com/m/songs/view/' in link['href'],link['href'],0.6497451663017273
|
||
|
1377,"def test_find_directive_from_block ( self ) : <TAB> blocks = self. config. parser_root. find_blocks ( ""virtualhost"" ) <TAB> found = False <TAB> for vh in blocks : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> servername = vh. find_directives ( ""servername"" ) <TAB> <TAB> <TAB> self. assertEqual ( servername [ 0 ]. parameters [ 0 ], ""certbot.demo"" ) <TAB> <TAB> <TAB> found = True <TAB> self. assertTrue ( found )",False,vh.filepath.endswith('sites-enabled/certbot.conf'),vh.name == 'servername',0.6487401723861694
|
||
|
1378,"def readAll ( self, root, force = False ) : <TAB> """"""Scan positions, looking for @<file> nodes to read."""""" <TAB> at, c = self, self. c <TAB> old_changed = c. changed <TAB> if force : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> c. endEditing ( ) <TAB> t1 = time. time ( ) <TAB> c. init_error_dialogs ( ) <TAB> files = at. findFilesToRead ( force, root ) <TAB> for p in files : <TAB> <TAB> at. readFileAtPosition ( force, p ) <TAB> for p in files : <TAB> <TAB> p. v. clearDirty ( ) <TAB> if not g. unitTesting : <TAB> <TAB> if files : <TAB> <TAB> <TAB> t2 = time. time ( ) <TAB> <TAB> <TAB> g. es ( ""read %s files in %2.2f seconds"" % ( len ( files ), t2 - t1 ) ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> g. es ( ""no @<file> nodes in the selected tree"" ) <TAB> c. changed = old_changed <TAB> c. raise_error_dialogs ( )",False,force,not old_changed,0.6818838715553284
|
||
|
1379,"def _check_witness_program_v0 ( self, witness_solution_stack, witness_program ) : <TAB> size = len ( witness_program ) <TAB> if size == 32 : <TAB> <TAB> if len ( witness_solution_stack ) == 0 : <TAB> <TAB> <TAB> raise ScriptError ( <TAB> <TAB> <TAB> <TAB> ""witness program witness empty"", errno. WITNESS_PROGRAM_WITNESS_EMPTY <TAB> <TAB> <TAB> ) <TAB> <TAB> puzzle_script = witness_solution_stack [ - 1 ] <TAB> <TAB> if sha256 ( puzzle_script ). digest ( )!= witness_program : <TAB> <TAB> <TAB> raise ScriptError ( <TAB> <TAB> <TAB> <TAB> ""witness program mismatch"", errno. WITNESS_PROGRAM_MISMATCH <TAB> <TAB> <TAB> ) <TAB> <TAB> stack = list ( witness_solution_stack [ : - 1 ] ) <TAB> elif size == 20 : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ScriptError ( <TAB> <TAB> <TAB> <TAB> ""witness program mismatch"", errno. WITNESS_PROGRAM_MISMATCH <TAB> <TAB> <TAB> ) <TAB> <TAB> puzzle_script = self. _puzzle_script_for_len20_segwit ( witness_program ) <TAB> <TAB> stack = list ( witness_solution_stack ) <TAB> else : <TAB> <TAB> raise ScriptError ( <TAB> <TAB> <TAB> ""witness program wrong length"", errno. WITNESS_PROGRAM_WRONG_LENGTH <TAB> <TAB> ) <TAB> return stack, puzzle_script",False,len(witness_solution_stack) != 2,sha256(puzzle_script) != witness_program,0.6599516868591309
|
||
|
1380,"def getAllRowTablesWidget ( self ) : <TAB> """"""dump all settings from table"""""" <TAB> model = self. TabSettings. model ( ) <TAB> data, datafilter, self. key = [ ], OrderedDict ( ), None <TAB> for row in range ( model. rowCount ( ) ) : <TAB> <TAB> data. append ( [ ] ) <TAB> <TAB> for column in range ( model. columnCount ( ) ) : <TAB> <TAB> <TAB> index = model. index ( row, column ) <TAB> <TAB> <TAB> data [ row ]. append ( str ( model. data ( index ). toString ( ) ) ) <TAB> datafilter [ ""ESP"" ] = { } <TAB> datafilter [ ""LinuxIntelx86"" ] = { } <TAB> datafilter [ ""LinuxIntelx64"" ] = { } <TAB> datafilter [ ""WindowsIntelx86"" ] = { } <TAB> datafilter [ ""WindowsIntelx64"" ] = { } <TAB> datafilter [ ""MachoIntelx86"" ] = { } <TAB> datafilter [ ""MachoIntelx64"" ] = { } <TAB> for count, item in enumerate ( data ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if item [ 0 ]!= """" or item [ 1 ]!= """" : <TAB> <TAB> <TAB> <TAB> datafilter [ ""ESP"" ] [ item [ 0 ] ] = item [ 1 ] <TAB> <TAB> else : <TAB> <TAB> <TAB> if item [ 0 ]!= """" or item [ 1 ]!= """" : <TAB> <TAB> <TAB> <TAB> if item [ 1 ] in datafilter. keys ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> self. key = item [ 1 ] <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> datafilter [ self. key ] [ item [ 0 ] ] = item [ 1 ] <TAB> return datafilter",False,count < 5,count > 0,0.6658114790916443
|
||
|
1381,"def start_span ( <TAB> self, <TAB> operation_name = None, <TAB> child_of = None, <TAB> references = None, <TAB> tags = None, <TAB> start_time = None, <TAB> ignore_active_span = False, ) : <TAB> start_time = time. time ( ) if start_time is None else start_time <TAB> <TAB> parent_ctx = None <TAB> if child_of is not None : <TAB> <TAB> parent_ctx = ( <TAB> <TAB> <TAB> child_of <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> else child_of. context <TAB> <TAB> ) <TAB> elif references is not None and len ( references ) > 0 : <TAB> <TAB> <TAB> <TAB> parent_ctx = references [ 0 ]. referenced_context <TAB> <TAB> if not ignore_active_span and parent_ctx is None : <TAB> <TAB> scope = self. scope_manager. active <TAB> <TAB> if scope is not None : <TAB> <TAB> <TAB> parent_ctx = scope. span. context <TAB> <TAB> ctx = SpanContext ( span_id = self. _generate_id ( ) ) <TAB> if parent_ctx is not None : <TAB> <TAB> if parent_ctx. _baggage is not None : <TAB> <TAB> <TAB> ctx. _baggage = parent_ctx. _baggage. copy ( ) <TAB> <TAB> ctx. trace_id = parent_ctx. trace_id <TAB> else : <TAB> <TAB> ctx. trace_id = self. _generate_id ( ) <TAB> <TAB> return MockSpan ( <TAB> <TAB> self, <TAB> <TAB> operation_name = operation_name, <TAB> <TAB> context = ctx, <TAB> <TAB> parent_id = ( None if parent_ctx is None else parent_ctx. span_id ), <TAB> <TAB> tags = tags, <TAB> <TAB> start_time = start_time, <TAB> )",False,"isinstance(child_of, opentracing.SpanContext)",parent_ctx is None,0.6485050916671753
|
||
|
1382,"def test_raise_for_status ( server ) : <TAB> async with httpx. AsyncClient ( ) as client : <TAB> <TAB> for status_code in ( 200, 400, 404, 500, 505 ) : <TAB> <TAB> <TAB> response = await client. request ( <TAB> <TAB> <TAB> <TAB> ""GET"", server. url. copy_with ( path = f""/status/{status_code}"" ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> with pytest. raises ( httpx. HTTPStatusError ) as exc_info : <TAB> <TAB> <TAB> <TAB> <TAB> response. raise_for_status ( ) <TAB> <TAB> <TAB> <TAB> assert exc_info. value. response == response <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> assert response. raise_for_status ( ) is None",False,400 <= status_code < 600,response.has_error,0.6672827005386353
|
||
|
1383,"def loads ( self, text, profile = False ) : <TAB> self. _pattern_confs = { } <TAB> for line in text. splitlines ( ) : <TAB> <TAB> line = line. strip ( ) <TAB> <TAB> if not line or line. startswith ( ""#"" ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> left, value = line. split ( ""="", 1 ) <TAB> <TAB> value = value. strip ( ) <TAB> <TAB> tokens = left. strip ( ). split ( "":"", 2 ) <TAB> <TAB> if len ( tokens ) == 3 : <TAB> <TAB> <TAB> pattern, conf_module, name = tokens <TAB> <TAB> else : <TAB> <TAB> <TAB> assert len ( tokens ) == 2 <TAB> <TAB> <TAB> conf_module, name = tokens <TAB> <TAB> <TAB> pattern = None <TAB> <TAB> if not _is_profile_module ( conf_module ) : <TAB> <TAB> <TAB> if profile : <TAB> <TAB> <TAB> <TAB> raise ConanException ( ""[conf] '{}' not allowed in profiles"". format ( line ) ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise ConanException ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Conf '{}' cannot have a package pattern"". format ( line ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> conf = self. _pattern_confs. setdefault ( pattern, Conf ( ) ) <TAB> <TAB> conf. set_value ( conf_module, name, value )",False,pattern is not None,not pattern,0.6567394733428955
|
||
|
1384,"def cache_sns_topics_across_accounts ( ) -> bool : <TAB> function : str = f""{__name__}.{sys._getframe().f_code.co_name}"" <TAB> <TAB> accounts_d : list = async_to_sync ( get_account_id_to_name_mapping ) ( ) <TAB> for account_id in accounts_d. keys ( ) : <TAB> <TAB> if config. get ( ""environment"" ) == ""prod"" : <TAB> <TAB> <TAB> cache_sns_topics_for_account. delay ( account_id ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> cache_sns_topics_for_account. delay ( account_id ) <TAB> stats. count ( f""{function}.success"" ) <TAB> return True",False,"account_id in config.get('celery.test_account_ids', [])","config.get( ""environment"""") == 'local'",0.649046003818512
|
||
|
1385,"def process ( self, fuzzresult ) : <TAB> base_url = urljoin ( fuzzresult. url, "".."" ) <TAB> for line in fuzzresult. history. content. splitlines ( ) : <TAB> <TAB> record = line. split ( ""/"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. queue_url ( urljoin ( base_url, record [ 1 ] ) ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if record [ 0 ] == ""D"" : <TAB> <TAB> <TAB> <TAB> self. queue_url ( urljoin ( base_url, record [ 1 ] ) ) <TAB> <TAB> <TAB> <TAB> self. queue_url ( urljoin ( base_url, ""%s/CVS/Entries"" % ( record [ 1 ] ) ) )",False,len(record) == 6 and record[1],record[0] == 'C',0.6494237184524536
|
||
|
1386,"def _set_parse_context ( self, tag, tag_attrs ) : <TAB> <TAB> if not self. _wb_parse_context : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _wb_parse_context = ""style"" <TAB> <TAB> elif tag == ""script"" : <TAB> <TAB> <TAB> if self. _allow_js_type ( tag_attrs ) : <TAB> <TAB> <TAB> <TAB> self. _wb_parse_context = ""script""",True,tag == 'style',tag == 'style',0.6587623953819275
|
||
|
1387,"def download ( request ) : <TAB> if not ENABLE_DOWNLOAD. get ( ) : <TAB> <TAB> return serve_403_error ( request ) <TAB> try : <TAB> <TAB> file_format = ( <TAB> <TAB> <TAB> ""csv"" <TAB> <TAB> <TAB> if ""csv"" == request. POST. get ( ""type"" ) <TAB> <TAB> <TAB> else ""xls"" <TAB> <TAB> <TAB> if ""xls"" == request. POST. get ( ""type"" ) <TAB> <TAB> <TAB> else ""json"" <TAB> <TAB> ) <TAB> <TAB> facet = json. loads ( request. POST. get ( ""facet"", ""{}"" ) ) <TAB> <TAB> json_response = search ( request ) <TAB> <TAB> response = json. loads ( json_response. content ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> response [ ""response"" ] [ ""docs"" ] = response [ ""normalized_facets"" ] [ 0 ] [ ""docs"" ] <TAB> <TAB> <TAB> collection = facet <TAB> <TAB> <TAB> if not collection [ ""template"" ] [ ""fieldsSelected"" ] : <TAB> <TAB> <TAB> <TAB> facet [ ""fields"" ] = facet [ ""template"" ] [ ""fieldsAttributes"" ] <TAB> <TAB> else : <TAB> <TAB> <TAB> collection = json. loads ( request. POST. get ( ""collection"", ""{}"" ) ) <TAB> <TAB> if file_format == ""json"" : <TAB> <TAB> <TAB> docs = response [ ""response"" ] [ ""docs"" ] <TAB> <TAB> <TAB> resp = JsonResponse ( docs, safe = False ) <TAB> <TAB> <TAB> resp [ ""Content-Disposition"" ] = 'attachment; filename=""%s.%s""' % ( <TAB> <TAB> <TAB> <TAB> ""query_result"", <TAB> <TAB> <TAB> <TAB> file_format, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> return resp <TAB> <TAB> else : <TAB> <TAB> <",False,facet,response.get('normalized_facets'),0.7092268466949463
|
||
|
1388,"def __get_right_line ( self, widget_output ) : <TAB> """"""Gets next line for right panel"""""" <TAB> right_line = """" <TAB> if widget_output : <TAB> <TAB> right_line = widget_output. pop ( 0 ) <TAB> <TAB> if len ( right_line ) > self. right_panel_width : <TAB> <TAB> <TAB> right_line_plain = self. markup. clean_markup ( right_line ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> right_line = right_line [ : self. right_panel_width ] + self. markup. RESET <TAB> return right_line",False,len(right_line_plain) > self.right_panel_width,right_line_plain and len(right_line) > self.right_panel_width,0.6472867131233215
|
||
|
1389,"def _parse_gene ( element ) : <TAB> for genename_element in element : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> ann_key = ""gene_%s_%s"" % ( <TAB> <TAB> <TAB> <TAB> genename_element. tag. replace ( NS, """" ), <TAB> <TAB> <TAB> <TAB> genename_element. attrib [ ""type"" ], <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if genename_element. attrib [ ""type"" ] == ""primary"" : <TAB> <TAB> <TAB> <TAB> self. ParsedSeqRecord. annotations [ ann_key ] = genename_element. text <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> append_to_annotations ( ann_key, genename_element. text )",False,'type' in genename_element.attrib,genename_element.attrib[0] == 'gene',0.6544368267059326
|
||
|
1390,"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 fid == 1 : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. req = TRenewDelegationTokenReq ( ) <TAB> <TAB> <TAB> <TAB> self. req. 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 ( )",False,ftype == TType.STRUCT,self.req is None,0.6624554395675659
|
||
|
1391,"def do_endpoints ( conf, endpoints ) : <TAB> service = { } <TAB> for endpoint, ( eclass, indexed ) in endpoints. items ( ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> servs = [ ] <TAB> <TAB> <TAB> i = 1 <TAB> <TAB> <TAB> for args in conf [ endpoint ] : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> args = { ""location"" : args, ""binding"" : DEFAULT_BINDING [ endpoint ] } <TAB> <TAB> <TAB> <TAB> elif isinstance ( args, tuple ) or isinstance ( args, list ) : <TAB> <TAB> <TAB> <TAB> <TAB> if len ( args ) == 2 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> args = { ""location"" : args [ 0 ], ""binding"" : args [ 1 ] } <TAB> <TAB> <TAB> <TAB> <TAB> elif len ( args ) == 3 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> args = { <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""location"" : args [ 0 ], <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""binding"" : args [ 1 ], <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""index"" : args [ 2 ], <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> } <TAB> <TAB> <TAB> <TAB> if indexed : <TAB> <TAB> <TAB> <TAB> <TAB> if ""index"" not in args : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> args [ ""index"" ] = ""%d"" % i <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> i += 1 <TAB> <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB",False,"isinstance(args, six.string_types)",args and eclass in servs,0.6505386233329773
|
||
|
1392,"def move_items ( self, sourceItems, target ) : <TAB> target_model_item = self. __extractData ( target ) <TAB> <TAB> result = [ f for f in sourceItems if f. parent ( ) not in sourceItems ] <TAB> self. window ( ). app. monitor. suspend ( ) <TAB> for source in result : <TAB> <TAB> self. __removeItem ( source ) <TAB> <TAB> source_model_item = self. __extractData ( source ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> target_model_item. add_folder ( source_model_item ) <TAB> <TAB> <TAB> self. __moveRecurseUpdate ( source_model_item ) <TAB> <TAB> else : <TAB> <TAB> <TAB> target_model_item. add_item ( source_model_item ) <TAB> <TAB> <TAB> source_model_item. path = None <TAB> <TAB> <TAB> source_model_item. persist ( ) <TAB> <TAB> target. addChild ( source ) <TAB> self. window ( ). app. monitor. unsuspend ( ) <TAB> self. treeWidget. sortItems ( 0, Qt. AscendingOrder ) <TAB> self. window ( ). app. config_altered ( True )",False,"isinstance(source_model_item, model.Folder)",target_model_item,0.6477488279342651
|
||
|
1393,"def _init_choices ( self, choices, default = None ) : <TAB> <TAB> self. choices = [ ] <TAB> searching_first_choice = True <TAB> for i, c in enumerate ( choices ) : <TAB> <TAB> if isinstance ( c, Separator ) : <TAB> <TAB> <TAB> self. choices. append ( ( c, None, None ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. choices. append ( ( c, c, None ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> name = c. get ( ""name"" ) <TAB> <TAB> <TAB> <TAB> value = c. get ( ""value"", name ) <TAB> <TAB> <TAB> <TAB> disabled = c. get ( ""disabled"", None ) <TAB> <TAB> <TAB> <TAB> self. choices. append ( ( name, value, disabled ) ) <TAB> <TAB> <TAB> if searching_first_choice : <TAB> <TAB> <TAB> <TAB> self. selected_option_index = i <TAB> <TAB> <TAB> <TAB> searching_first_choice = False",False,"isinstance(c, basestring)",default and c,0.6527134776115417
|
||
|
1394,"def configure_logger ( verbose ) : <TAB> <TAB> from polyaxon import settings <TAB> from polyaxon. plugins. sentry import set_raven_client <TAB> if ( <TAB> <TAB> verbose <TAB> <TAB> or settings. CLIENT_CONFIG. debug <TAB> <TAB> or os. environ. get ( POLYAXON_KEYS_DEBUG, False ) <TAB> ) : <TAB> <TAB> log_level = logging. DEBUG <TAB> <TAB> settings. CLIENT_CONFIG. debug = True <TAB> else : <TAB> <TAB> if not settings. CLIENT_CONFIG. disable_errors_reporting : <TAB> <TAB> <TAB> set_raven_client ( ) <TAB> <TAB> log_level = ( <TAB> <TAB> <TAB> logging. DEBUG <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> else logging. INFO <TAB> <TAB> ) <TAB> <TAB> if settings. CLIENT_CONFIG. log_level : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> log_level = logging. getLevelName ( settings. CLIENT_CONFIG. log_level ) <TAB> <TAB> <TAB> except : <TAB> <TAB> <TAB> <TAB> pass <TAB> logging. basicConfig ( format = ""%(message)s"", level = log_level, stream = sys. stdout )",False,"os.environ.get(POLYAXON_KEYS_LOG_LEVEL) in ['debug', 'DEBUG']",verbose,0.6599088311195374
|
||
|
1395,"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<mask> : <TAB> <TAB> <TAB> if ftype == TType. I64 : <TAB> <TAB> <TAB> <TAB> self. numTrues = iprot. readI64 ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif fid == 2 : <TAB> <TAB> <TAB> if ftype == TType. I64 : <TAB> <TAB> <TAB> <TAB> self. numFalses = iprot. readI64 ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif fid == 3 : <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 == 1,fid == 1,0.6735950708389282
|
||
|
1396,"def update_handler ( self, fd, event_state ) : <TAB> if event_state & base_connection. BaseConnection. READ : <TAB> <TAB> if fd not in self. readers : <TAB> <TAB> <TAB> self. loop. add_reader ( <TAB> <TAB> <TAB> <TAB> fd, <TAB> <TAB> <TAB> <TAB> partial ( <TAB> <TAB> <TAB> <TAB> <TAB> self. handlers [ fd ], fd = fd, events = base_connection. BaseConnection. READ <TAB> <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> self. readers. add ( fd ) <TAB> else : <TAB> <TAB> if fd in self. readers : <TAB> <TAB> <TAB> self. loop. remove_reader ( fd ) <TAB> <TAB> <TAB> self. readers. remove ( fd ) <TAB> if event_state & base_connection. BaseConnection. WRITE : <TAB> <TAB> if fd not in self. writers : <TAB> <TAB> <TAB> self. loop. add_writer ( <TAB> <TAB> <TAB> <TAB> fd, <TAB> <TAB> <TAB> <TAB> partial ( <TAB> <TAB> <TAB> <TAB> <TAB> self. handlers [ fd ], <TAB> <TAB> <TAB> <TAB> <TAB> fd = fd, <TAB> <TAB> <TAB> <TAB> <TAB> events = base_connection. BaseConnection. WRITE, <TAB> <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> self. writers. add ( fd ) <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. loop. remove_writer ( fd ) <TAB> <TAB> <TAB> self. writers. remove ( fd )",False,fd in self.writers,fd in self.writer,0.6652296781539917
|
||
|
1397,"def replace_field_to_value ( layout, cb ) : <TAB> for i, lo in enumerate ( layout. fields ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> layout. fields [ i ] = ShowField ( <TAB> <TAB> <TAB> <TAB> cb, * lo. fields, attrs = lo. attrs, wrapper_class = lo. wrapper_class <TAB> <TAB> <TAB> ) <TAB> <TAB> elif isinstance ( lo, basestring ) : <TAB> <TAB> <TAB> layout. fields [ i ] = ShowField ( cb, lo ) <TAB> <TAB> elif hasattr ( lo, ""get_field_names"" ) : <TAB> <TAB> <TAB> replace_field_to_value ( lo, cb )",False,"isinstance(lo, Field) or issubclass(lo.__class__, Field)","isinstance(lo, ShowField)",0.6551836729049683
|
||
|
1398,"def setDatePattern ( self, pattern ) : <TAB> if pattern is None : <TAB> <TAB> self. dateDetector = None <TAB> <TAB> return <TAB> else : <TAB> <TAB> dd = DateDetector ( ) <TAB> <TAB> dd. default_tz = self. __logtimezone <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> pattern = filter ( bool, map ( str. strip, re. split ( ""\n+"", pattern ) ) ) <TAB> <TAB> for pattern in pattern : <TAB> <TAB> <TAB> dd. appendTemplate ( pattern ) <TAB> <TAB> self. dateDetector = dd",False,"not isinstance(pattern, (list, tuple))","isinstance(pattern, string_types)",0.6524550914764404
|
||
|
1399,"def _import_hash ( self, operator ) : <TAB> <TAB> <TAB> for key in sorted ( operator. import_hash. keys ( ) ) : <TAB> <TAB> module_list = "", "". join ( sorted ( operator. import_hash [ key ] ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> exec ( ""from {} import {}"". format ( key [ 4 : ], module_list ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> exec ( ""from {} import {}"". format ( key, module_list ) ) <TAB> <TAB> for var in operator. import_hash [ key ] : <TAB> <TAB> <TAB> self. operators_context [ var ] = eval ( var )",False,key.startswith('tpot.'),len(module_list) > 4,0.6503951549530029
|
||
|
1400,"def iter_event_handlers ( <TAB> self, <TAB> resource : resources_. Resource, <TAB> event : bodies. RawEvent, ) -> Iterator [ handlers. ResourceWatchingHandler ] : <TAB> warnings. warn ( <TAB> <TAB> ""SimpleRegistry.iter_event_handlers() is deprecated; use "" <TAB> <TAB> ""ResourceWatchingRegistry.iter_handlers()."", <TAB> <TAB> DeprecationWarning, <TAB> ) <TAB> cause = _create_watching_cause ( resource, event ) <TAB> for handler in self. _handlers : <TAB> <TAB> if not isinstance ( handler, handlers. ResourceWatchingHandler ) : <TAB> <TAB> <TAB> pass <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> yield handler",False,"registries.match(handler=handler, cause=cause, ignore_fields=True)","isinstance(handler, cause)",0.6483447551727295
|
||
|
1401,"def send_packed_command ( self, command, check_health = True ) : <TAB> if not self. _sock : <TAB> <TAB> self. connect ( ) <TAB> try : <TAB> <TAB> if isinstance ( command, str ) : <TAB> <TAB> <TAB> command = [ command ] <TAB> <TAB> for item in command : <TAB> <TAB> <TAB> self. _sock. sendall ( item ) <TAB> except socket. error as e : <TAB> <TAB> self. disconnect ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> _errno, errmsg = ""UNKNOWN"", e. args [ 0 ] <TAB> <TAB> else : <TAB> <TAB> <TAB> _errno, errmsg = e. args <TAB> <TAB> raise ConnectionError ( <TAB> <TAB> <TAB> ""Error %s while writing to socket. %s."" % ( _errno, errmsg ) <TAB> <TAB> ) <TAB> except Exception : <TAB> <TAB> self. disconnect ( ) <TAB> <TAB> raise",False,len(e.args) == 1,check_health,0.6547377109527588
|
||
|
1402,"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 ftype == TType. STRUCT : <TAB> <TAB> <TAB> <TAB> self. success = Results ( ) <TAB> <TAB> <TAB> <TAB> self. success. read ( iprot ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> if ftype == TType. STRUCT : <TAB> <TAB> <TAB> <TAB> self. error = QueryNotFoundException ( ) <TAB> <TAB> <TAB> <TAB> self. error. 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. error2 = BeeswaxException ( ) <TAB> <TAB> <TAB> <TAB> self. error2. read ( iprot ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> else : <TAB> <TAB> <",True,fid == 1,fid == 1,0.6793604493141174
|
||
|
1403,"def _bc_covmat ( self, cov_naive ) : <TAB> cov_naive = cov_naive / self. scaling_factor <TAB> endog = self. endog_li <TAB> exog = self. exog_li <TAB> varfunc = self. family. variance <TAB> cached_means = self. cached_means <TAB> scale = self. estimate_scale ( ) <TAB> bcm = 0 <TAB> for i in range ( self. num_group ) : <TAB> <TAB> expval, lpr = cached_means [ i ] <TAB> <TAB> resid = endog [ i ] - expval <TAB> <TAB> dmat = self. mean_deriv ( exog [ i ], lpr ) <TAB> <TAB> sdev = np. sqrt ( varfunc ( expval ) ) <TAB> <TAB> rslt = self. cov_struct. covariance_matrix_solve ( expval, i, sdev, ( dmat, ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return None <TAB> <TAB> vinv_d = rslt [ 0 ] <TAB> <TAB> vinv_d /= scale <TAB> <TAB> hmat = np. dot ( vinv_d, cov_naive ) <TAB> <TAB> hmat = np. dot ( hmat, dmat. T ). T <TAB> <TAB> f = self. weights_li [ i ] if self. weights is not None else 1.0 <TAB> <TAB> aresid = np. linalg. solve ( np. eye ( len ( resid ) ) - hmat, resid ) <TAB> <TAB> rslt = self. cov_struct. covariance_matrix_solve ( expval, i, sdev, ( aresid, ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return None <TAB> <TAB> srt = rslt [ 0 ] <TAB> <TAB> srt = f * np. dot ( dmat. T, srt ) / scale <TAB> <TAB> bcm += np. outer ( srt, srt ) <TAB> cov_robust_bc = np. dot ( cov_naive, np. dot",False,rslt is None,scale > self.max_scale,0.6712028980255127
|
||
|
1404,"def register_rule_types ( ) : <TAB> LOG. debug ( ""Start : register default RuleTypes."" ) <TAB> registered_count = 0 <TAB> for rule_type in RULE_TYPES : <TAB> <TAB> rule_type = copy. deepcopy ( rule_type ) <TAB> <TAB> try : <TAB> <TAB> <TAB> rule_type_db = RuleType. get_by_name ( rule_type [ ""name"" ] ) <TAB> <TAB> <TAB> update = True <TAB> <TAB> except StackStormDBObjectNotFoundError : <TAB> <TAB> <TAB> rule_type_db = None <TAB> <TAB> <TAB> update = False <TAB> <TAB> rule_type_api = RuleTypeAPI ( ** rule_type ) <TAB> <TAB> rule_type_api. validate ( ) <TAB> <TAB> rule_type_model = RuleTypeAPI. to_model ( rule_type_api ) <TAB> <TAB> if rule_type_db : <TAB> <TAB> <TAB> rule_type_model. id = rule_type_db. id <TAB> <TAB> try : <TAB> <TAB> <TAB> rule_type_db = RuleType. add_or_update ( rule_type_model ) <TAB> <TAB> <TAB> extra = { ""rule_type_db"" : rule_type_db } <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> LOG. audit ( ""RuleType updated. RuleType %s"", rule_type_db, extra = extra ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> LOG. audit ( ""RuleType created. RuleType %s"", rule_type_db, extra = extra ) <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> LOG. exception ( ""Unable to register RuleType %s."", rule_type [ ""name"" ] ) <TAB> <TAB> else : <TAB> <TAB> <TAB> registered_count += 1 <TAB> LOG. debug ( ""End : register default RuleTypes."" ) <TAB> return registered_count",True,update,update,0.6884036660194397
|
||
|
1405,"def check_backward ( self, s_data, i_data, gx_data, gt_data ) : <TAB> <TAB> gt_old = gt_data. copy ( ) <TAB> s = chainer. Variable ( s_data ) <TAB> i = chainer. Variable ( i_data ) <TAB> x, t = thin_stack. thin_stack_get ( s, i ) <TAB> x. grad = gx_data <TAB> t. grad = gt_data <TAB> t. backward ( ) <TAB> for j, ind in enumerate ( i_data ) : <TAB> <TAB> for k in range ( self. shape [ 1 ] ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> testing. assert_allclose ( s. grad [ j, k ], gt_old [ j, k ] + gx_data [ j ] ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> testing. assert_allclose ( s. grad [ j, k ], gt_old [ j, k ] ) <TAB> self. assertIsNone ( i. grad ) <TAB> <TAB> self. assertIs ( s. grad, gt_data )",False,k == ind,ind == 0,0.6705917119979858
|
||
|
1406,"def is_notebook ( ) : <TAB> try : <TAB> <TAB> <TAB> <TAB> shell = get_ipython ( ). __class__. __name__ <TAB> <TAB> if shell == ""ZMQInteractiveShell"" : <TAB> <TAB> <TAB> return True <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> return False <TAB> <TAB> else : <TAB> <TAB> <TAB> return False <TAB> except NameError : <TAB> <TAB> return False",True,shell == 'TerminalInteractiveShell',shell == 'TerminalInteractiveShell',0.6718345880508423
|
||
|
1407,"def token_access ( endpoint, client_id, token_info ) : <TAB> <TAB> <TAB> allow = False <TAB> if endpoint == ""revocation_endpoint"" : <TAB> <TAB> if ""azr"" in token_info and client_id == token_info [ ""azr"" ] : <TAB> <TAB> <TAB> allow = True <TAB> <TAB> elif len ( token_info [ ""aud"" ] ) == 1 and token_info [ ""aud"" ] == [ client_id ] : <TAB> <TAB> <TAB> allow = True <TAB> else : <TAB> <TAB> if ""azr"" in token_info and client_id == token_info [ ""azr"" ] : <TAB> <TAB> <TAB> allow = True <TAB> <TAB> elif ""aud"" in token_info : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> allow = True <TAB> return allow",False,client_id in token_info['aud'],client_id == token_info['aud'],0.6551052331924438
|
||
|
1408,"def _pair_samples_with_pipelines ( run_info_yaml, config ) : <TAB> """"""Map samples defined in input file to pipelines to run."""""" <TAB> samples = config_utils. load_config ( run_info_yaml ) <TAB> if isinstance ( samples, dict ) : <TAB> <TAB> resources = samples. pop ( ""resources"" ) <TAB> <TAB> samples = samples [ ""details"" ] <TAB> else : <TAB> <TAB> resources = { } <TAB> ready_samples = [ ] <TAB> for sample in samples : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> del sample [ ""files"" ] <TAB> <TAB> <TAB> <TAB> usample = copy. deepcopy ( sample ) <TAB> <TAB> usample. pop ( ""algorithm"", None ) <TAB> <TAB> if ""resources"" not in usample : <TAB> <TAB> <TAB> usample [ ""resources"" ] = { } <TAB> <TAB> for prog, pkvs in resources. items ( ) : <TAB> <TAB> <TAB> if prog not in usample [ ""resources"" ] : <TAB> <TAB> <TAB> <TAB> usample [ ""resources"" ] [ prog ] = { } <TAB> <TAB> <TAB> if pkvs is not None : <TAB> <TAB> <TAB> <TAB> for key, val in pkvs. items ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> usample [ ""resources"" ] [ prog ] [ key ] = val <TAB> <TAB> config = config_utils. update_w_custom ( config, usample ) <TAB> <TAB> sample [ ""resources"" ] = { } <TAB> <TAB> ready_samples. append ( sample ) <TAB> paired = [ ( x, _get_pipeline ( x ) ) for x in ready_samples ] <TAB> d = defaultdict ( list ) <TAB> for x in paired : <TAB> <TAB> d [ x [ 1 ] ]. append ( [ x [ 0 ] ] ) <TAB> return d, config",True,'files' in sample,'files' in sample,0.6599195003509521
|
||
|
1409,"def add_permissions ( self ) : <TAB> for permission in self. permissions : <TAB> <TAB> try : <TAB> <TAB> <TAB> kwargs = { <TAB> <TAB> <TAB> <TAB> ""FunctionName"" : self. name, <TAB> <TAB> <TAB> <TAB> ""StatementId"" : permission [ ""statement_id"" ], <TAB> <TAB> <TAB> <TAB> ""Action"" : permission [ ""action"" ], <TAB> <TAB> <TAB> <TAB> ""Principal"" : permission [ ""principal"" ], <TAB> <TAB> <TAB> } <TAB> <TAB> <TAB> source_arn = permission. get ( ""source_arn"", None ) <TAB> <TAB> <TAB> if source_arn : <TAB> <TAB> <TAB> <TAB> kwargs [ ""SourceArn"" ] = source_arn <TAB> <TAB> <TAB> source_account = permission. get ( ""source_account"", None ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> kwargs [ ""SourceAccount"" ] = source_account <TAB> <TAB> <TAB> response = self. _lambda_svc. add_permission ( ** kwargs ) <TAB> <TAB> <TAB> LOG. debug ( response ) <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> LOG. exception ( ""Unable to add permission"" )",True,source_account,source_account,0.6680928468704224
|
||
|
1410,"def create_tree ( self ) : <TAB> """"""The vs-create-tree command."""""" <TAB> c = self. c <TAB> p = c. p <TAB> tag = ""valuespace"" <TAB> <TAB> if p. h == tag : <TAB> <TAB> r = p <TAB> else : <TAB> <TAB> r = p. insertAsLastChild ( ) <TAB> <TAB> r. h = tag <TAB> <TAB> for k, v in self. d. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> child = r. insertAsLastChild ( ) <TAB> <TAB> <TAB> child. h = ""@@r "" + k <TAB> <TAB> <TAB> self. render_value ( child, v ) <TAB> c. bodyWantsFocus ( ) <TAB> c. redraw ( )",False,not k.startswith('__'),r.h == tag,0.6543979644775391
|
||
|
1411,"def generate_supported_providers_table ( api, provider_matrix ) : <TAB> data = [ ] <TAB> header = [ <TAB> <TAB> ""Provider"", <TAB> <TAB> ""Documentation"", <TAB> <TAB> ""Provider Constant"", <TAB> <TAB> ""Supported Regions"", <TAB> <TAB> ""Module"", <TAB> <TAB> ""Class Name"", <TAB> ] <TAB> data. append ( header ) <TAB> for provider, values in sorted ( provider_matrix. items ( ) ) : <TAB> <TAB> name_str = ""`%s`_"" % ( values [ ""name"" ] ) <TAB> <TAB> module_str = "":mod:`%s`"" % ( values [ ""module"" ] ) <TAB> <TAB> class_str = "":class:`%s`"" % ( values [ ""class"" ] ) <TAB> <TAB> params = { ""api"" : api, ""provider"" : provider. lower ( ) } <TAB> <TAB> driver_docs_path = pjoin ( <TAB> <TAB> <TAB> this_dir, ""../docs/%(api)s/drivers/%(provider)s.rst"" % params <TAB> <TAB> ) <TAB> <TAB> if os. path. exists ( driver_docs_path ) : <TAB> <TAB> <TAB> docs_link = "":doc:`Click </%(api)s/drivers/%(provider)s>`"" % params <TAB> <TAB> else : <TAB> <TAB> <TAB> docs_link = """" <TAB> <TAB> cls = values [ ""cls"" ] <TAB> <TAB> supported_regions = cls. list_regions ( ) if hasattr ( cls, ""list_regions"" ) else None <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> supported_regions = sorted ( supported_regions ) <TAB> <TAB> <TAB> supported_regions = "", "". join ( supported_regions ) <TAB> <TAB> else : <TAB> <TAB> <TAB> supported_regions = ""single region driver"" <TAB> <TAB> row = [ <TAB> <TAB> <TAB> name_str, <TAB",True,supported_regions,supported_regions,0.6623059511184692
|
||
|
1412,"def add_directory_csv_files ( dir_path, paths = None ) : <TAB> if not paths : <TAB> <TAB> paths = [ ] <TAB> for p in listdir ( dir_path ) : <TAB> <TAB> path = join ( dir_path, p ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> paths = add_directory_csv_files ( path, paths ) <TAB> <TAB> elif isfile ( path ) and path. endswith ( "".csv"" ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> paths. append ( path ) <TAB> return paths",True,isdir(path),isdir(path),0.6547225713729858
|
||
|
1413,"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<mask> : <TAB> <TAB> <TAB> if ftype == TType. STRING : <TAB> <TAB> <TAB> <TAB> self. guid = iprot. readString ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif fid == 2 : <TAB> <TAB> <TAB> if ftype == TType. STRING : <TAB> <TAB> <TAB> <TAB> self. noteKey = 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 == 1,fid == 1,0.6750129461288452
|
||
|
1414,"def get_step_query ( request, units_queryset ) : <TAB> """"""Narrows down unit query to units matching conditions in GET and POST"""""" <TAB> if ""unit"" in request. GET or ""page"" in request. GET : <TAB> <TAB> return units_queryset <TAB> if ""unitstates"" in request. GET : <TAB> <TAB> unitstates = request. GET [ ""unitstates"" ]. split ( "","" ) <TAB> <TAB> if unitstates : <TAB> <TAB> <TAB> state_queryset = units_queryset. none ( ) <TAB> <TAB> <TAB> for unitstate in unitstates : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> state_queryset = state_queryset | units_queryset. filter ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> state = UNTRANSLATED <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> elif unitstate == ""translated"" : <TAB> <TAB> <TAB> <TAB> <TAB> state_queryset = state_queryset | units_queryset. filter ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> state = TRANSLATED <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> elif unitstate == ""fuzzy"" : <TAB> <TAB> <TAB> <TAB> <TAB> state_queryset = state_queryset | units_queryset. filter ( state = FUZZY ) <TAB> <TAB> <TAB> units_queryset = state_queryset <TAB> if ""matchnames"" in request. GET : <TAB> <TAB> matchnames = request. GET [ ""matchnames"" ]. split ( "","" ) <TAB> <TAB> if matchnames : <TAB> <TAB> <TAB> match_queryset = units_queryset. none ( ) <TAB> <TAB> <TAB> if ""hassuggestion"" in matchnames : <TAB> <TAB> <TAB> <TAB> match_queryset = units_queryset. exclude ( suggestion = None ) <TAB> <TAB> <TAB",True,unitstate == 'untranslated',unitstate == 'untranslated',0.6639132499694824
|
||
|
1415,"def _enc_dec_rsa ( backend, key, data, padding ) : <TAB> if not isinstance ( padding, AsymmetricPadding ) : <TAB> <TAB> raise TypeError ( ""Padding must be an instance of AsymmetricPadding."" ) <TAB> if isinstance ( padding, PKCS1v15 ) : <TAB> <TAB> padding_enum = backend. _lib. RSA_PKCS1_PADDING <TAB> elif isinstance ( padding, OAEP ) : <TAB> <TAB> padding_enum = backend. _lib. RSA_PKCS1_OAEP_PADDING <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise UnsupportedAlgorithm ( <TAB> <TAB> <TAB> <TAB> ""Only MGF1 is supported by this backend."", _Reasons. UNSUPPORTED_MGF <TAB> <TAB> <TAB> ) <TAB> <TAB> if not backend. rsa_padding_supported ( padding ) : <TAB> <TAB> <TAB> raise UnsupportedAlgorithm ( <TAB> <TAB> <TAB> <TAB> ""This combination of padding and hash algorithm is not "" <TAB> <TAB> <TAB> <TAB> ""supported by this backend."", <TAB> <TAB> <TAB> <TAB> _Reasons. UNSUPPORTED_PADDING, <TAB> <TAB> <TAB> ) <TAB> else : <TAB> <TAB> raise UnsupportedAlgorithm ( <TAB> <TAB> <TAB> ""{} is not supported by this backend."". format ( padding. name ), <TAB> <TAB> <TAB> _Reasons. UNSUPPORTED_PADDING, <TAB> <TAB> ) <TAB> return _enc_dec_rsa_pkey_ctx ( backend, key, data, padding_enum, padding )",False,"not isinstance(padding._mgf, MGF1)",not backend.rsa_MGF1_supported(padding),0.6498615741729736
|
||
|
1416,"def regenerate_curve ( <TAB> self, <TAB> curve_name : str, <TAB> vertices : Union [ List [ list ], List [ np. ndarray ] ], <TAB> spline_type : str = ""POLY"", <TAB> vertices_radius : Union [ List [ list ], List [ np. ndarray ] ] = None, <TAB> close_spline : Union [ List [ bool ], List [ int ] ] = None, <TAB> use_smooth : bool = True, <TAB> tilt : Union [ List [ list ], List [ np. ndarray ] ] = None, ) : <TAB> <TAB> if not self. curve : <TAB> <TAB> self. curve = bpy. data. curves. new ( <TAB> <TAB> <TAB> name = curve_name, type = ""CURVE"" <TAB> <TAB> ) <TAB> if len ( self. curve. splines )!= len ( vertices ) or any ( <TAB> <TAB> len ( s. points )!= len ( v ) for s, v in zip ( self. curve. splines, vertices ) <TAB> ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. curve. splines. clear ( ) <TAB> <TAB> [ self. curve. splines. new ( spline_type ) for _ in range ( len ( vertices ) ) ] <TAB> <TAB> [ s. points. add ( len ( v ) - 1 ) for s, v in zip ( self. curve. splines, vertices ) ] <TAB> for s, v, r, t, c in zip ( <TAB> <TAB> self. curve. splines, <TAB> <TAB> vertices, <TAB> <TAB> repeat_last ( vertices_radius or [ None ] ), <TAB> <TAB> repeat_last ( tilt or [ None ] ), <TAB> <TAB> repeat_last ( close_spline ), <TAB> ) : <TAB> <TAB> v = np. asarray ( v, dtype = np. float32 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> r = np. ones ( len ( v ), dtype = np. float32 ) <TAB> <TAB> r =",False,r is None,len(v) == 0,0.664576530456543
|
||
|
1417,"def process ( self ) : <TAB> if not any ( socket. is_linked for socket in self. outputs ) : <TAB> <TAB> return <TAB> solids_in = self. inputs [ 0 ]. sv_get ( deepcopy = False ) <TAB> matrixes = self. inputs [ 1 ]. sv_get ( deepcopy = False ) <TAB> slices = [ ] <TAB> slices_face = [ ] <TAB> faces_add = slices_face. extend if self. flat_output else slices_face. append <TAB> slices_add = slices. extend if self. flat_output else slices. append <TAB> for solid, matrix in zip ( * mlr ( [ solids_in, matrixes ] ) ) : <TAB> <TAB> location = matrix. decompose ( ) [ 0 ] <TAB> <TAB> norm = ( matrix @ Vector ( ( 0, 0, 1 ) ) ) - location <TAB> <TAB> dist = norm. dot ( location ) <TAB> <TAB> wires = solid. slice ( Base. Vector ( norm ), dist ) <TAB> <TAB> edges_curves = [ ] <TAB> <TAB> faces = [ ] <TAB> <TAB> for wire in wires : <TAB> <TAB> <TAB> for edge in wire. Edges : <TAB> <TAB> <TAB> <TAB> curve = SvSolidEdgeCurve ( edge ) <TAB> <TAB> <TAB> <TAB> edges_curves. append ( curve ) <TAB> <TAB> if wires : <TAB> <TAB> <TAB> face = Part. Face ( wires ) <TAB> <TAB> <TAB> faces. append ( SvSolidFaceSurface ( face ). to_nurbs ( ) ) <TAB> <TAB> if faces : <TAB> <TAB> <TAB> faces_add ( faces ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> slices_add ( edges_curves ) <TAB> self. outputs [ ""Edges"" ]. sv_set ( slices ) <TAB> self. outputs [ ""Faces"" ]. sv_set ( slices_face )",True,edges_curves,edges_curves,0.6743174195289612
|
||
|
1418,"def wrapped_f ( * args, ** kwargs ) : <TAB> if request_method and request_method!= request. method : <TAB> <TAB> raise HTTPMethodNotAllowed ( ). exception <TAB> result = f ( * args, ** kwargs ) <TAB> tmpl = template <TAB> if tmpl == ""string"" : <TAB> <TAB> return result <TAB> if hasattr ( request, ""override_template"" ) : <TAB> <TAB> tmpl = request. override_template <TAB> if tmpl == ""json"" : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> msg = ( <TAB> <TAB> <TAB> <TAB> ""JSON responses with Array envelopes are susceptible "" <TAB> <TAB> <TAB> <TAB> ""to cross-site data leak attacks, see "" <TAB> <TAB> <TAB> <TAB> ""http://wiki.pylonshq.com/display/pylonsfaq/Warnings"" <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if config [ ""debug"" ] : <TAB> <TAB> <TAB> <TAB> raise TypeError ( msg ) <TAB> <TAB> <TAB> warnings. warn ( msg, Warning, 2 ) <TAB> <TAB> <TAB> log. warning ( msg ) <TAB> <TAB> response. headers [ ""Content-Type"" ] = ""application/json"" <TAB> <TAB> return simplejson. dumps ( result ) <TAB> if request. environ. get ( ""paste.testing"", False ) : <TAB> <TAB> <TAB> <TAB> request. environ [ ""paste.testing_variables"" ] [ ""tmpl_vars"" ] = result <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if response. content_type == ""text/html"" : <TAB> <TAB> <TAB> response. content_type = ""application/xhtml+xml"" <TAB> return render ( tmpl, tmpl_vars = result, method = ""auto"" )",False,"isinstance(result, (list, tuple))",result,0.6519782543182373
|
||
|
1419,"def _put_tasklet ( self, todo, options ) : <TAB> if not todo : <TAB> <TAB> raise RuntimeError ( ""Nothing to do."" ) <TAB> <TAB> <TAB> datastore_entities = [ ] <TAB> for unused_fut, ent in todo : <TAB> <TAB> datastore_entities. append ( ent ) <TAB> <TAB> keys = yield self. _conn. async_put ( options, datastore_entities ) <TAB> for key, ( fut, ent ) in zip ( keys, todo ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if ent. _has_complete_key ( ) : <TAB> <TAB> <TAB> <TAB> raise datastore_errors. BadKeyError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Entity key differs from the one returned by the datastore. "" <TAB> <TAB> <TAB> <TAB> <TAB> ""Expected %r, got %r"" % ( key, ent. _key ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ent. _key = key <TAB> <TAB> fut. set_result ( key )",True,key != ent._key,key != ent._key,0.6613764762878418
|
||
|
1420,"def _listen_output ( self ) : <TAB> ""NB! works in background thread"" <TAB> try : <TAB> <TAB> while True : <TAB> <TAB> <TAB> chars = self. _proc. read ( 1 ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> as_bytes = chars. encode ( self. encoding ) <TAB> <TAB> <TAB> <TAB> self. _make_output_available ( as_bytes ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. _error = ""EOF"" <TAB> <TAB> <TAB> <TAB> break <TAB> except Exception as e : <TAB> <TAB> self. _error = str ( e )",True,len(chars) > 0,len(chars) > 0,0.6568546891212463
|
||
|
1421,def encode ( self ) : <TAB> for char in self. text : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. ctext += self. galactic_dict [ char ] <TAB> <TAB> else : <TAB> <TAB> <TAB> self. ctext += char <TAB> return self. ctext,False,char in self.galactic_dict.keys(),char in self.galactic_dict,0.6574978828430176
|
||
|
1422,"def _rpc_request_loop_thread ( self ) : <TAB> while True : <TAB> <TAB> ( peer, data ) = self. _rpc_events. get ( ) <TAB> <TAB> msgid, target_method, params = data <TAB> <TAB> error = None <TAB> <TAB> result = None <TAB> <TAB> try : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> result = self. _config ( msgid, params ) <TAB> <TAB> <TAB> elif target_method == b""vrrp_list"" : <TAB> <TAB> <TAB> <TAB> result = self. _list ( msgid, params ) <TAB> <TAB> <TAB> elif target_method == b""vrrp_config_change"" : <TAB> <TAB> <TAB> <TAB> result = self. _config_change ( msgid, params ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> error = ""Unknown method %s"" % ( target_method ) <TAB> <TAB> except RPCError as e : <TAB> <TAB> <TAB> error = str ( e ) <TAB> <TAB> peer. _endpoint. send_response ( msgid, error = error, result = result )",False,target_method == b'vrrp_config',target_method == b'config',0.652177095413208
|
||
|
1423,"def parse_fqdn_whitelist ( self, fqdn_whitelist_location ) : <TAB> fqdns = [ ] <TAB> with open ( fqdn_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> fqdns. append ( line ) <TAB> return fqdns",False,isFQDN(line),line and (not line.startswith('#')),0.6519243121147156
|
||
|
1424,"def _get_sort_map ( tags ) : <TAB> """"""See TAG_TO_SORT"""""" <TAB> tts = { } <TAB> for name, tag in tags. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if tag. user : <TAB> <TAB> <TAB> <TAB> tts [ name ] = ""%ssort"" % name <TAB> <TAB> <TAB> if tag. internal : <TAB> <TAB> <TAB> <TAB> tts [ ""~%s"" % name ] = ""~%ssort"" % name <TAB> return tts",False,tag.has_sort,name in tts,0.6583970785140991
|
||
|
1425,"def end_a ( self ) : <TAB> self. doc. do_translation = False <TAB> if self. a_href : <TAB> <TAB> last_write = self. doc. pop_write ( ) <TAB> <TAB> last_write = last_write. rstrip ( "" "" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if "":"" in last_write : <TAB> <TAB> <TAB> <TAB> last_write = last_write. replace ( "":"", r""\:"" ) <TAB> <TAB> <TAB> self. doc. push_write ( last_write ) <TAB> <TAB> <TAB> self. doc. push_write ( "" <%s>`__"" % self. a_href ) <TAB> <TAB> elif last_write == ""`"" : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. doc. push_write ( ""`<%s>`__"" % self. a_href ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. doc. push_write ( self. a_href ) <TAB> <TAB> <TAB> self. doc. hrefs [ self. a_href ] = self. a_href <TAB> <TAB> <TAB> self. doc. write ( ""`__"" ) <TAB> <TAB> self. a_href = None <TAB> self. doc. write ( "" "" )",False,last_write and last_write != '`',last_write,0.656735360622406
|
||
|
1426,"def _retrieve_key ( self ) : <TAB> url = ""http://www.canadapost.ca/cpo/mc/personal/postalcode/fpc.jsf"" <TAB> text = """" <TAB> try : <TAB> <TAB> r = requests. get ( url, timeout = self. timeout, proxies = self. proxies ) <TAB> <TAB> text = r. text <TAB> except : <TAB> <TAB> self. error = ""ERROR - URL Connection"" <TAB> if text : <TAB> <TAB> expression = r""'(....-....-....-....)';"" <TAB> <TAB> pattern = re. compile ( expression ) <TAB> <TAB> match = pattern. search ( text ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. key = match. group ( 1 ) <TAB> <TAB> <TAB> return self. key <TAB> <TAB> else : <TAB> <TAB> <TAB> self. error = ""ERROR - No API Key""",True,match,match,0.6769827604293823
|
||
|
1427,"def execute_spark ( <TAB> self, cell, output_var, samplemethod, maxrows, samplefraction, session_name, coerce ) : <TAB> ( success, out, mimetype ) = self. spark_controller. run_command ( <TAB> <TAB> Command ( cell ), session_name <TAB> ) <TAB> if not success : <TAB> <TAB> if conf. shutdown_session_on_spark_statement_errors ( ) : <TAB> <TAB> <TAB> self. spark_controller. cleanup ( ) <TAB> <TAB> raise SparkStatementException ( out ) <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if mimetype == MIMETYPE_TEXT_HTML : <TAB> <TAB> <TAB> <TAB> self. ipython_display. html ( out ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. ipython_display. write ( out ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. ipython_display. display ( out ) <TAB> <TAB> if output_var is not None : <TAB> <TAB> <TAB> spark_store_command = self. _spark_store_command ( <TAB> <TAB> <TAB> <TAB> output_var, samplemethod, maxrows, samplefraction, coerce <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> df = self. spark_controller. run_command ( spark_store_command, session_name ) <TAB> <TAB> <TAB> self. shell. user_ns [ output_var ] = df",False,"isinstance(out, string_types)",mimetype is not None,0.6489458084106445
|
||
|
1428,"def mode ( <TAB> self, <TAB> expression, <TAB> binby = [ ], <TAB> limits = None, <TAB> shape = 256, <TAB> mode_shape = 64, <TAB> mode_limits = None, <TAB> progressbar = False, <TAB> selection = None, ) : <TAB> """"""Calculate/estimate the mode."""""" <TAB> if len ( binby ) == 0 : <TAB> <TAB> raise ValueError ( ""only supported with binby argument given"" ) <TAB> else : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> len ( shape ) <TAB> <TAB> <TAB> shape = tuple ( shape ) <TAB> <TAB> except : <TAB> <TAB> <TAB> shape = len ( binby ) * ( shape, ) <TAB> <TAB> shape = ( mode_shape, ) + shape <TAB> <TAB> subspace = self ( * ( list ( binby ) + [ expression ] ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> subspace = subspace. selected ( ) <TAB> <TAB> limits = self. limits ( list ( binby ), limits ) <TAB> <TAB> mode_limits = self. limits ( [ expression ], mode_limits ) <TAB> <TAB> limits = list ( limits ) + list ( mode_limits ) <TAB> <TAB> counts = subspace. histogram ( limits = limits, size = shape, progressbar = progressbar ) <TAB> <TAB> indices = np. argmax ( counts, axis = 0 ) <TAB> <TAB> pmin, pmax = limits [ - 1 ] <TAB> <TAB> centers = np. linspace ( pmin, pmax, mode_shape + 1 ) [ : - 1 ] <TAB> <TAB> centers += ( centers [ 1 ] - centers [ 0 ] ) / 2 <TAB> <TAB> modes = centers [ indices ] <TAB> <TAB> ok = counts. sum ( axis = 0 ) > 0 <TAB> <TAB> modes [ ~ ok ] = np. nan <TAB> <TAB> return modes",False,selection,mode_limits is not None,0.6832214593887329
|
||
|
1429,"def getMTRoute ( self, order ) : <TAB> mtroutes = self. mt_routing_table. getAll ( ) <TAB> for e in mtroutes : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. log. debug ( ""getMTRoute [order:%s] returned a MTRoute"", order ) <TAB> <TAB> <TAB> return e [ order ] <TAB> self. log. debug ( ""getMTRoute [order:%s] returned None"", order ) <TAB> return None",False,order == list(e)[0],e[order],0.6612941026687622
|
||
|
1430,"def iterate_batches ( env, net, batch_size ) : <TAB> batch = [ ] <TAB> episode_reward = 0.0 <TAB> episode_steps = [ ] <TAB> obs = env. reset ( ) <TAB> sm = nn. Softmax ( dim = 1 ) <TAB> while True : <TAB> <TAB> obs_v = torch. FloatTensor ( [ obs ] ) <TAB> <TAB> act_probs_v = sm ( net ( obs_v ) ) <TAB> <TAB> act_probs = act_probs_v. data. numpy ( ) [ 0 ] <TAB> <TAB> action = np. random. choice ( len ( act_probs ), p = act_probs ) <TAB> <TAB> next_obs, reward, is_done, _ = env. step ( action ) <TAB> <TAB> episode_reward += reward <TAB> <TAB> episode_steps. append ( EpisodeStep ( observation = obs, action = action ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> batch. append ( Episode ( reward = episode_reward, steps = episode_steps ) ) <TAB> <TAB> <TAB> episode_reward = 0.0 <TAB> <TAB> <TAB> episode_steps = [ ] <TAB> <TAB> <TAB> next_obs = env. reset ( ) <TAB> <TAB> <TAB> if len ( batch ) == batch_size : <TAB> <TAB> <TAB> <TAB> yield batch <TAB> <TAB> <TAB> <TAB> batch = [ ] <TAB> <TAB> obs = next_obs",True,is_done,is_done,0.6616964340209961
|
||
|
1431,"def __init__ ( <TAB> self, test_env, args, stdin, stdout, stderr, returncode, files_before, files_after ) : <TAB> self. test_env = test_env <TAB> self. args = args <TAB> self. stdin = stdin <TAB> self. stdout = stdout <TAB> self. stderr = stderr <TAB> self. returncode = returncode <TAB> self. files_before = files_before <TAB> self. files_after = files_after <TAB> self. files_deleted = { } <TAB> self. files_updated = { } <TAB> self. files_created = files_after. copy ( ) <TAB> for path, f in files_before. items ( ) : <TAB> <TAB> if path not in files_after : <TAB> <TAB> <TAB> self. files_deleted [ path ] = f <TAB> <TAB> <TAB> continue <TAB> <TAB> del self. files_created [ path ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. files_updated [ path ] = files_after [ path ]",False,f.mtime < files_after[path].mtime,path in files_after,0.6528380513191223
|
||
|
1432,"def wrap_keypress ( self, key ) : <TAB> """"""Handle confirmation and throw event on bad input."""""" <TAB> try : <TAB> <TAB> key = self. keypress ( key ) <TAB> except ColumnDeleteEvent as e : <TAB> <TAB> if e. letter == COLUMN_KEYS [ 1 ] : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> if not self. column_empty ( e. letter ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> raise e <TAB> <TAB> self. delete_column ( e. letter ) <TAB> except UpdateParentEvent as e : <TAB> <TAB> self. update_parent_columns ( ) <TAB> <TAB> return <TAB> if key is None : <TAB> <TAB> return <TAB> if self. columns. get_focus_column ( ) == 0 : <TAB> <TAB> if key not in ( ""up"", ""down"", ""page up"", ""page down"" ) : <TAB> <TAB> <TAB> raise CalcEvent ( E_invalid_in_help_col ) <TAB> if key not in EDIT_KEYS and key not in MOVEMENT_KEYS : <TAB> <TAB> raise CalcEvent ( E_invalid_key % key. upper ( ) )",False,"not isinstance(self.event, ColumnDeleteEvent)",e.letter == 'delete',0.6519345045089722
|
||
|
1433,"def getExtras ( self, ArtistID, newstyle = False, ** kwargs ) : <TAB> <TAB> <TAB> <TAB> <TAB> if not newstyle : <TAB> <TAB> extras = ""1,2,3,4,5,6,7,8,9,10,11,12,13,14"" <TAB> else : <TAB> <TAB> temp_extras_list = [ ] <TAB> <TAB> i = 1 <TAB> <TAB> for extra in headphones. POSSIBLE_EXTRAS : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> temp_extras_list. append ( i ) <TAB> <TAB> <TAB> i += 1 <TAB> <TAB> extras = "","". join ( str ( n ) for n in temp_extras_list ) <TAB> myDB = db. DBConnection ( ) <TAB> controlValueDict = { ""ArtistID"" : ArtistID } <TAB> newValueDict = { ""IncludeExtras"" : 1, ""Extras"" : extras } <TAB> myDB. upsert ( ""artists"", newValueDict, controlValueDict ) <TAB> thread = threading. Thread ( <TAB> <TAB> target = importer. addArtisttoDB, args = [ ArtistID, True, False ] <TAB> ) <TAB> thread. start ( ) <TAB> thread. join ( 1 ) <TAB> raise cherrypy. HTTPRedirect ( ""artistPage?ArtistID=%s"" % ArtistID )",False,extra in kwargs,extra,0.6789532899856567
|
||
|
1434,"def traverse_trees ( node_pos, sample, trees : List [ HeteroDecisionTreeGuest ] ) : <TAB> if node_pos [ ""reach_leaf_node"" ]. all ( ) : <TAB> <TAB> return node_pos <TAB> for t_idx, tree in enumerate ( trees ) : <TAB> <TAB> cur_node_idx = node_pos [ ""node_pos"" ] [ t_idx ] <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> rs, reach_leaf = HeteroSecureBoostingTreeGuest. traverse_a_tree ( <TAB> <TAB> <TAB> tree, sample, cur_node_idx <TAB> <TAB> ) <TAB> <TAB> if reach_leaf : <TAB> <TAB> <TAB> node_pos [ ""reach_leaf_node"" ] [ t_idx ] = True <TAB> <TAB> node_pos [ ""node_pos"" ] [ t_idx ] = rs <TAB> return node_pos",False,cur_node_idx == -1,cur_node_idx == 0,0.6567609310150146
|
||
|
1435,"def run ( self ) : <TAB> for k, v in iteritems ( self. objs ) : <TAB> <TAB> if k. startswith ( ""_"" ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> if v [ ""_class"" ] == ""Dataset"" : <TAB> <TAB> <TAB> limit = v [ ""time_limit"" ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if limit == 0.0 : <TAB> <TAB> <TAB> <TAB> limit = None <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if limit is not None and limit <= 0.0 : <TAB> <TAB> <TAB> <TAB> logger. warning ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Previous time limit %s was updated, "" <TAB> <TAB> <TAB> <TAB> <TAB> ""no time limit is enforced now."", <TAB> <TAB> <TAB> <TAB> <TAB> limit, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> limit = None <TAB> <TAB> <TAB> v [ ""time_limit"" ] = limit <TAB> <TAB> <TAB> limit = v [ ""memory_limit"" ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> limit = None <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if limit is not None and limit <= 0 : <TAB> <TAB> <TAB> <TAB> logger. warning ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Previous memory limit %s was updated, "" <TAB> <TAB> <TAB> <TAB> <TAB> ""no memory limit is enforced now."", <TAB> <TAB> <TAB> <TAB> <TAB> limit, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> limit = None <TAB> <TAB> <TAB> v [ ""memory_limit"" ] = limit <TAB> return self. objs",False,limit == 0,limit is None,0.6795771718025208
|
||
|
1436,"def numpy_match_long_cycle ( list_of_arrays ) : <TAB> """"""match numpy arrays length by cycling over the array"""""" <TAB> out = [ ] <TAB> maxl = 0 <TAB> for array in list_of_arrays : <TAB> <TAB> maxl = max ( maxl, array. shape [ 0 ] ) <TAB> for array in list_of_arrays : <TAB> <TAB> length_diff = maxl - array. shape [ 0 ] <TAB> <TAB> if length_diff > 0 : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> array = np_concatenate ( ( array, array [ : length_diff ] ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> new_part = np_repeat ( array, ceil ( length_diff / array. shape [ 0 ] ), axis = 0 ) <TAB> <TAB> <TAB> <TAB> if len ( array. shape ) > 1 : <TAB> <TAB> <TAB> <TAB> <TAB> shape = ( ceil ( length_diff / array. shape [ 0 ] ), 1 ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> shape = ceil ( length_diff / array. shape [ 0 ] ) <TAB> <TAB> <TAB> <TAB> new_part = np_tile ( array, shape ) <TAB> <TAB> <TAB> <TAB> array = np_concatenate ( ( array, new_part [ : length_diff ] ) ) <TAB> <TAB> out. append ( array ) <TAB> return out",False,length_diff < array.shape[0],length_diff > array.shape[0],0.6534295082092285
|
||
|
1437,"def connect ( self ) : <TAB> <TAB> host = cleanHost ( self. conf ( ""host"" ), protocol = False ). split ( "":"" ) <TAB> if not isInt ( host [ 1 ] ) : <TAB> <TAB> log. error ( ""Config properties are not filled in correctly, port is missing."" ) <TAB> <TAB> return False <TAB> <TAB> if self. conf ( ""version"" ) == ""v4"" : <TAB> <TAB> if not self. conf ( ""api_key"" ) : <TAB> <TAB> <TAB> log. error ( <TAB> <TAB> <TAB> <TAB> ""Config properties are not filled in correctly, API key is missing."" <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> return False <TAB> <TAB> url = ""http://"" + str ( host [ 0 ] ) + "":"" + str ( host [ 1 ] ) + ""/jsonrpc"" <TAB> <TAB> client = JsonRpcClient ( url, ""Token "" + self. conf ( ""api_key"" ) ) <TAB> <TAB> self. hadouken_api = HadoukenAPIv4 ( client ) <TAB> <TAB> return True <TAB> else : <TAB> <TAB> auth_type = self. conf ( ""auth_type"" ) <TAB> <TAB> header = None <TAB> <TAB> if auth_type == ""api_key"" : <TAB> <TAB> <TAB> header = ""Token "" + self. conf ( ""api_key"" ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> header = ""Basic "" + b64encode ( <TAB> <TAB> <TAB> <TAB> self. conf ( ""auth_user"" ) + "":"" + self. conf ( ""auth_pass"" ) <TAB> <TAB> <TAB> ) <TAB> <TAB> url = ""http://"" + str ( host [ 0 ] ) + "":"" + str ( host [ 1 ] ) + ""/api"" <TAB> <TAB> client = JsonRpcClient ( url, header ) <TAB> <TAB> self. hadouken_api = HadoukenAPIv5 ( client ) <TAB> <TAB> return True <TAB> return",False,auth_type == 'user_pass',auth_type == 'auth_user',0.6496493220329285
|
||
|
1438,"def results ( parsed, original_query ) : <TAB> settings = json. load ( open ( ""preferences.json"" ) ) <TAB> shortcuts = settings [ ""shortcuts"" ] <TAB> count = len ( shortcuts ) <TAB> for i in range ( count ) : <TAB> <TAB> url = shortcuts [ i ] [ ""url"" ] <TAB> <TAB> shortcut = shortcuts [ i ] [ ""shortcut"" ] <TAB> <TAB> if shortcut. lower ( ) == original_query. lower ( ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> if not ""//"" in url : <TAB> <TAB> <TAB> <TAB> <TAB> url = ""http://"" + url <TAB> <TAB> <TAB> link = ""<a href='{0}'>{0}</a>"". format ( url ) <TAB> <TAB> <TAB> return { <TAB> <TAB> <TAB> <TAB> ""title"" : u""Open "" + url, <TAB> <TAB> <TAB> <TAB> ""run_args"" : [ url ], <TAB> <TAB> <TAB> <TAB> ""html"" : centered_text ( <TAB> <TAB> <TAB> <TAB> <TAB> link, hint_text = ""Press enter to launch a browser"" <TAB> <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> <TAB> ""webview_transparent_background"" : True, <TAB> <TAB> <TAB> }",False,url.startswith('http') == False,url,0.6529065370559692
|
||
|
1439,"def login ( ) : <TAB> error = None <TAB> if request. method == ""POST"" : <TAB> <TAB> form = await request. form <TAB> <TAB> if form [ ""username"" ]!= app. config [ ""USERNAME"" ] : <TAB> <TAB> <TAB> error = ""Invalid username"" <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> error = ""Invalid password"" <TAB> <TAB> else : <TAB> <TAB> <TAB> session [ ""logged_in"" ] = True <TAB> <TAB> <TAB> await flash ( ""You were logged in"" ) <TAB> <TAB> <TAB> return redirect ( url_for ( ""posts"" ) ) <TAB> return await render_template ( ""login.html"", error = error )",True,form['password'] != app.config['PASSWORD'],form['password'] != app.config['PASSWORD'],0.6505357027053833
|
||
|
1440,"def resources_include_url ( name ) : <TAB> env = self. environment <TAB> mime_type, encoding = mimetypes. guess_type ( name ) <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> data = env. loader. get_source ( env, name ) [ 0 ]. encode ( ""utf8"" ) <TAB> except UnicodeDecodeError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> pieces = split_template_path ( name ) <TAB> <TAB> searchpaths = self. get_template_paths ( ) <TAB> <TAB> for searchpath in searchpaths : <TAB> <TAB> <TAB> filename = os. path. join ( searchpath, * pieces ) <TAB> <TAB> <TAB> print ( filename, os. path. exists ( filename ) ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> with open ( filename, ""rb"" ) as f : <TAB> <TAB> <TAB> <TAB> <TAB> data = f. read ( ) <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> else : <TAB> <TAB> <TAB> raise ValueError ( ""No file %r found in %r"" % ( name, searchpaths ) ) <TAB> data = base64. b64encode ( data ) <TAB> data = data. replace ( b""\n"", b"""" ). decode ( ""ascii"" ) <TAB> src = ""data:{mime_type};base64,{data}"". format ( mime_type = mime_type, data = data ) <TAB> return jinja2. Markup ( src )",True,os.path.exists(filename),os.path.exists(filename),0.6482568979263306
|
||
|
1441,"def value ( self, new_value ) : <TAB> <TAB> old_value = self. _value <TAB> self. _value = new_value <TAB> for i, [ _, value ] in enumerate ( self. _options ) : <TAB> <TAB> if value == new_value : <TAB> <TAB> <TAB> self. _line = i <TAB> <TAB> <TAB> break <TAB> else : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _line = 0 <TAB> <TAB> <TAB> self. _value = self. _options [ self. _line ] [ 1 ] <TAB> <TAB> else : <TAB> <TAB> <TAB> self. _line = - 1 <TAB> <TAB> <TAB> self. _value = None <TAB> if self. _validator : <TAB> <TAB> self. _is_valid = self. _validator ( self. _value ) <TAB> if old_value!= self. _value and self. _on_change : <TAB> <TAB> self. _on_change ( ) <TAB> <TAB> self. _start_line = max ( <TAB> <TAB> 0, max ( self. _line - self. _h + 1, min ( self. _start_line, self. _line ) ) <TAB> )",False,len(self._options) > 0,self._line > len(self._options),0.6534853577613831
|
||
|
1442,"def _renderObject ( self, obj, brightness = 0, addSink = True ) : <TAB> glPushMatrix ( ) <TAB> if addSink : <TAB> <TAB> glTranslate ( <TAB> <TAB> <TAB> obj. getPosition ( ) [ 0 ], <TAB> <TAB> <TAB> obj. getPosition ( ) [ 1 ], <TAB> <TAB> <TAB> obj. getSize ( ) [ 2 ] / 2 - profile. getProfileSettingFloat ( ""object_sink"" ), <TAB> <TAB> ) <TAB> else : <TAB> <TAB> glTranslate ( obj. getPosition ( ) [ 0 ], obj. getPosition ( ) [ 1 ], obj. getSize ( ) [ 2 ] / 2 ) <TAB> if self. tempMatrix is not None and obj == self. _selectedObj : <TAB> <TAB> glMultMatrixf ( openglHelpers. convert3x3MatrixTo4x4 ( self. tempMatrix ) ) <TAB> offset = obj. getDrawOffset ( ) <TAB> glTranslate ( - offset [ 0 ], - offset [ 1 ], - offset [ 2 ] - obj. getSize ( ) [ 2 ] / 2 ) <TAB> glMultMatrixf ( openglHelpers. convert3x3MatrixTo4x4 ( obj. getMatrix ( ) ) ) <TAB> n = 0 <TAB> for m in obj. _meshList : <TAB> <TAB> if m. vbo is None : <TAB> <TAB> <TAB> m. vbo = openglHelpers. GLVBO ( GL_TRIANGLES, m. vertexes, m. normal ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> glColor4fv ( map ( lambda idx : idx * brightness, self. _objColors [ n ] ) ) <TAB> <TAB> <TAB> n += 1 <TAB> <TAB> m. vbo. render ( ) <TAB> glPopMatrix ( )",False,brightness != 0,bubble,0.6689261198043823
|
||
|
1443,"def __init__ ( self, filename = None ) : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> self. _config = ConfigParser ( strict = False ) <TAB> except TypeError : <TAB> <TAB> <TAB> <TAB> self. _config = ConfigParser ( ) <TAB> if filename : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _config. readfp ( filename ) <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if not os. path. exists ( filename ) : <TAB> <TAB> <TAB> <TAB> sys. exit ( ""Configuration file '%s' does not exist"" % filename ) <TAB> <TAB> <TAB> self. _config. read ( os. path. expanduser ( filename ) ) <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for path in self. CONFIG_FILES : <TAB> <TAB> <TAB> full_path = os. path. expanduser ( path ) <TAB> <TAB> <TAB> if os. path. exists ( full_path ) and full_path in self. _config. read ( full_path ) : <TAB> <TAB> <TAB> <TAB> filename = full_path <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> else : <TAB> <TAB> <TAB> sys. exit ( <TAB> <TAB> <TAB> <TAB> ""Could not find any configuration file at "" <TAB> <TAB> <TAB> <TAB> ""default locations.\n"" <TAB> <TAB> <TAB> <TAB> ""Check Barman's documentation for more help."" <TAB> <TAB> <TAB> ) <TAB> self. config_file = filename <TAB> self. _servers = None <TAB> self. servers_msg_list = [ ] <TAB> self. _parse_global_config ( )",False,"hasattr(filename, 'read')",os.path.isfile(filename),0.6545233130455017
|
||
|
1444,"def get_files ( d ) : <TAB> res = [ ] <TAB> for p in glob. glob ( os. path. join ( d, ""*"" ) ) : <TAB> <TAB> if not p : <TAB> <TAB> <TAB> continue <TAB> <TAB> ( pth, fname ) = os. path. split ( p ) <TAB> <TAB> if skip_file ( fname ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> if os. path. isdir ( p ) : <TAB> <TAB> <TAB> res += get_dir ( p ) <TAB> <TAB> else : <TAB> <TAB> <TAB> res. append ( p ) <TAB> return res",False,os.path.islink(p),not os.path.exists(p),0.648548424243927
|
||
|
1445,"def __init__ ( self, type, object_or_type = None ) : <TAB> self. __thisclass__ = type <TAB> if object_or_type is None : <TAB> <TAB> self. __self__ = self. __self_class__ = None <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> debugger ( ) <TAB> <TAB> <TAB> JS ( ""@{{_issubtype}}(@{{object_or_type}}, @{{type}})"" ) <TAB> <TAB> <TAB> raise TypeError ( <TAB> <TAB> <TAB> <TAB> ""super(type, obj): obj must be an instance or subtype of type"" <TAB> <TAB> <TAB> ) <TAB> <TAB> if JS ( ""@{{object_or_type}}['$inst'] === true"" ) : <TAB> <TAB> <TAB> self. __self_class__ = object_or_type. __class__ <TAB> <TAB> else : <TAB> <TAB> <TAB> self. __self_class__ = object_or_type <TAB> <TAB> self. __self__ = object_or_type",False,"JS('!@{{_issubtype}}(@{{object_or_type}}, @{{type}})')","isinstance(object_or_type, basestring)",0.6665154695510864
|
||
|
1446,"def deleteHold ( ) : <TAB> v = buildGAPIObject ( ) <TAB> hold = sys. argv [ 3 ] <TAB> matterId = None <TAB> i = 4 <TAB> while i < len ( sys. argv ) : <TAB> <TAB> myarg = sys. argv [ i ]. lower ( ). replace ( ""_"", """" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> matterId = getMatterItem ( v, sys. argv [ i + 1 ] ) <TAB> <TAB> <TAB> holdId = convertHoldNameToID ( v, hold, matterId ) <TAB> <TAB> <TAB> i += 2 <TAB> <TAB> else : <TAB> <TAB> <TAB> controlflow. invalid_argument_exit ( myarg, ""gam delete hold"" ) <TAB> if not matterId : <TAB> <TAB> controlflow. system_error_exit ( 3, ""you must specify a matter for the hold."" ) <TAB> print ( f""Deleting hold {hold} / {holdId}"" ) <TAB> gapi. call ( v. matters ( ). holds ( ), ""delete"", matterId = matterId, holdId = holdId )",False,myarg == 'matter',i + 1 < len(sys.argv),0.6635769605636597
|
||
|
1447,"def _tags_to_preslots ( tags, tokens, is_start_of_slot, is_end_of_slot ) : <TAB> slots = [ ] <TAB> current_slot_start = 0 <TAB> for i, tag in enumerate ( tags ) : <TAB> <TAB> if is_start_of_slot ( tags, i ) : <TAB> <TAB> <TAB> current_slot_start = i <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> slots. append ( <TAB> <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> <TAB> RANGE : { <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> START : tokens [ current_slot_start ]. start, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> END : tokens [ i ]. end, <TAB> <TAB> <TAB> <TAB> <TAB> }, <TAB> <TAB> <TAB> <TAB> <TAB> SLOT_NAME : tag_name_to_slot_name ( tag ), <TAB> <TAB> <TAB> <TAB> } <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> current_slot_start = i <TAB> return slots",True,"is_end_of_slot(tags, i)","is_end_of_slot(tags, i)",0.6529837846755981
|
||
|
1448,"def pipeline_template_post_save_handler ( sender, instance, created, ** kwargs ) : <TAB> template = instance <TAB> if template. is_deleted : <TAB> <TAB> TemplateRelationship. objects. filter ( <TAB> <TAB> <TAB> ancestor_template_id = template. template_id <TAB> <TAB> ). delete ( ) <TAB> <TAB> return <TAB> with transaction. atomic ( ) : <TAB> <TAB> TemplateRelationship. objects. filter ( <TAB> <TAB> <TAB> ancestor_template_id = template. template_id <TAB> <TAB> ). delete ( ) <TAB> <TAB> acts = list ( template. data [ PE. activities ]. values ( ) ) <TAB> <TAB> subprocess_nodes = [ act for act in acts if act [ ""type"" ] == PE. SubProcess ] <TAB> <TAB> rs = [ ] <TAB> <TAB> for sp in subprocess_nodes : <TAB> <TAB> <TAB> version = ( <TAB> <TAB> <TAB> <TAB> sp. get ( ""version"" ) <TAB> <TAB> <TAB> <TAB> or PipelineTemplate. objects. get ( template_id = sp [ ""template_id"" ] ). version <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> rs. append ( <TAB> <TAB> <TAB> <TAB> TemplateRelationship ( <TAB> <TAB> <TAB> <TAB> <TAB> ancestor_template_id = template. template_id, <TAB> <TAB> <TAB> <TAB> <TAB> descendant_template_id = sp [ ""template_id"" ], <TAB> <TAB> <TAB> <TAB> <TAB> subprocess_node_id = sp [ ""id"" ], <TAB> <TAB> <TAB> <TAB> <TAB> version = version, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> TemplateRelationship. objects. bulk_create ( rs ) <TAB> <TAB> TemplateVersion. objects. track ( template ) <TAB> <TAB> TemplateCurrentVersion. objects. update_current_version",False,rs,created,0.6844005584716797
|
||
|
1449,"def getSimilar ( ) : <TAB> myDB = db. DBConnection ( ) <TAB> results = myDB. select ( ""SELECT ArtistID from artists ORDER BY HaveTracks DESC"" ) <TAB> logger. info ( ""Fetching similar artists from Last.FM for tag cloud"" ) <TAB> artistlist = [ ] <TAB> for result in results [ : 12 ] : <TAB> <TAB> data = request_lastfm ( ""artist.getsimilar"", mbid = result [ ""ArtistId"" ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> artists = data [ ""similarartists"" ] [ ""artist"" ] <TAB> <TAB> <TAB> for artist in artists : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> artist_mbid = artist [ ""mbid"" ] <TAB> <TAB> <TAB> <TAB> <TAB> artist_name = artist [ ""name"" ] <TAB> <TAB> <TAB> <TAB> except KeyError : <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> if not any ( artist_mbid in x for x in results ) : <TAB> <TAB> <TAB> <TAB> <TAB> artistlist. append ( ( artist_name, artist_mbid ) ) <TAB> <TAB> logger. debug ( ""Fetched %d artists from Last.FM"", len ( artistlist ) ) <TAB> count = defaultdict ( int ) <TAB> for artist, mbid in artistlist : <TAB> <TAB> count [ artist, mbid ] += 1 <TAB> items = count. items ( ) <TAB> top_list = sorted ( items, key = lambda x : x [ 1 ], reverse = True ) [ : 25 ] <TAB> random. shuffle ( top_list ) <TAB> myDB. action ( ""DELETE from lastfmcloud"" ) <TAB> for item in top_list : <TAB> <TAB> artist_name, artist_mbid = item [ 0 ] <TAB> <TAB> count = item [ 1 ] <TAB> <TAB> myDB. action ( <TAB> <",False,data and 'similarartists' in data,data != {},0.6625669002532959
|
||
|
1450,"def ident_values ( self ) : <TAB> value = self. _ident_values <TAB> if value is False : <TAB> <TAB> value = None <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> wrapped = self. wrapped <TAB> <TAB> <TAB> idents = getattr ( wrapped, ""ident_values"", None ) <TAB> <TAB> <TAB> if idents : <TAB> <TAB> <TAB> <TAB> value = [ self. _wrap_hash ( ident ) for ident in idents ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _ident_values = value <TAB> return value",False,not self.orig_prefix,"hasattr(self, 'wrapped')",0.6577386260032654
|
||
|
1451,"def xontrib_data ( ns ) : <TAB> """"""Collects and returns the data about xontribs."""""" <TAB> meta = get_xontribs ( ) <TAB> data = { } <TAB> names : tp. Set [ str ] = set ( ) if not ns else set ( ns. names ) <TAB> for xo_name in meta : <TAB> <TAB> if xo_name not in names : <TAB> <TAB> <TAB> continue <TAB> <TAB> spec = find_xontrib ( xo_name ) <TAB> <TAB> if spec is None : <TAB> <TAB> <TAB> installed = loaded = False <TAB> <TAB> else : <TAB> <TAB> <TAB> installed = True <TAB> <TAB> <TAB> loaded = spec. name in sys. modules <TAB> <TAB> data [ xo_name ] = { ""name"" : xo_name, ""installed"" : installed, ""loaded"" : loaded } <TAB> installed_xontribs = xontrib_installed ( names ) <TAB> for name in installed_xontribs : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> loaded = f""xontrib.{name}"" in sys. modules <TAB> <TAB> <TAB> data [ name ] = { ""name"" : name, ""installed"" : True, ""loaded"" : loaded } <TAB> return dict ( sorted ( data. items ( ) ) )",False,name not in data,name in installed_xontribs,0.6616744995117188
|
||
|
1452,"def lines_filter ( self, lines : List [ str ], location : Tuple [ str, int ] = None ) -> List [ str ] : <TAB> linespec = self. options. get ( ""lines"" ) <TAB> if linespec : <TAB> <TAB> linelist = parselinenos ( linespec, len ( lines ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> logger. warning ( <TAB> <TAB> <TAB> <TAB> __ ( ""line number spec is out of range(1-%d): %r"" ) <TAB> <TAB> <TAB> <TAB> % ( len ( lines ), linespec ), <TAB> <TAB> <TAB> <TAB> location = location, <TAB> <TAB> <TAB> ) <TAB> <TAB> if ""lineno-match"" in self. options : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> first = linelist [ 0 ] <TAB> <TAB> <TAB> if all ( first + i == n for i, n in enumerate ( linelist ) ) : <TAB> <TAB> <TAB> <TAB> self. lineno_start += linelist [ 0 ] <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> <TAB> __ ( 'Cannot use ""lineno-match"" with a disjoint''set of ""lines""' ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> lines = [ lines [ n ] for n in linelist if n < len ( lines ) ] <TAB> <TAB> if lines == [ ] : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> __ ( ""Line spec %r: no lines pulled from include file %r"" ) <TAB> <TAB> <TAB> <TAB> % ( linespec, self. filename ) <TAB> <TAB> <TAB> ) <TAB> return lines",False,any((i >= len(lines) for i in linelist)),location and location < linelist[0],0.6610935926437378
|
||
|
1453,"def PyJs_anonymous_1847_ ( a, b, this, arguments, var = var ) : <TAB> var = Scope ( { u""a"" : a, u""this"" : this, u""b"" : b, u""arguments"" : arguments }, var ) <TAB> var. registers ( [ u""a"", u""b"", u""result"" ] ) <TAB> if ( <TAB> <TAB> var. get ( u""isObject"" ) ( var. get ( u""a"" ) ) <TAB> <TAB> and var. get ( u""isExtensible"" ) ( var. get ( u""a"" ) ). neg ( ) <TAB> ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> var. get ( u""this"" ). put ( u""_f"", var. get ( u""InternalMap"" ). create ( ) ) <TAB> <TAB> var. put ( <TAB> <TAB> <TAB> u""result"", <TAB> <TAB> <TAB> var. get ( u""this"" ) <TAB> <TAB> <TAB>. get ( u""_f"" ) <TAB> <TAB> <TAB>. callprop ( var. get ( u""key"" ), var. get ( u""a"" ), var. get ( u""b"" ) ), <TAB> <TAB> ) <TAB> <TAB> return ( <TAB> <TAB> <TAB> var. get ( u""this"" ) if ( var. get ( u""key"" ) == Js ( u""set"" ) ) else var. get ( u""result"" ) <TAB> <TAB> ) <TAB> return var. get ( u""method"" ). callprop ( <TAB> <TAB> u""call"", var. get ( u""this"" ), var. get ( u""a"" ), var. get ( u""b"" ) <TAB> )",False,var.get(u'this').get(u'_f').neg(),"hasattr(var, '__getitem__')",0.6477598547935486
|
||
|
1454,"def assertTagInTemplateScript ( self, needle, haystack, count = None, msg_prefix = """" ) : <TAB> needle = assert_and_parse_html ( <TAB> <TAB> self, needle, None, ""First argument is not valid HTML:"" <TAB> ) <TAB> haystack = assert_and_parse_html ( <TAB> <TAB> self, haystack, None, ""Second argument is not valid HTML:"" <TAB> ) <TAB> real_count = 0 <TAB> for script_tag in self. _find_template_script_tags ( haystack ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. assertEqual ( len ( script_tag. children ), 1 ) <TAB> <TAB> <TAB> script_html = assert_and_parse_html ( <TAB> <TAB> <TAB> <TAB> self, <TAB> <TAB> <TAB> <TAB> script_tag. children [ 0 ], <TAB> <TAB> <TAB> <TAB> None, <TAB> <TAB> <TAB> <TAB> ""Script tag content is not valid HTML:"", <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> real_count += self. _count_tag_occurrences ( needle, script_html ) <TAB> if count is not None : <TAB> <TAB> self. assertEqual ( <TAB> <TAB> <TAB> real_count, <TAB> <TAB> <TAB> count, <TAB> <TAB> <TAB> msg_prefix <TAB> <TAB> <TAB> + ""Found %d instances of '%s' in template script (expected %d)"" <TAB> <TAB> <TAB> % ( real_count, needle, count ), <TAB> <TAB> ) <TAB> else : <TAB> <TAB> self. assertTrue ( <TAB> <TAB> <TAB> real_count!= 0, <TAB> <TAB> <TAB> msg_prefix + ""Couldn't find '%s' in template script"" % needle, <TAB> <TAB> )",False,script_tag.children,script_tag is not None,0.6564608812332153
|
||
|
1455,"def parse_production ( xml_text ) : <TAB> """"""Returns a tuple containing two lists."""""" <TAB> if not xml_text : <TAB> <TAB> return None <TAB> soup = BeautifulSoup ( xml_text, ""html.parser"" ) <TAB> <TAB> productions = [ ] <TAB> datetimes = [ ] <TAB> for timeseries in soup. find_all ( ""timeseries"" ) : <TAB> <TAB> resolution = timeseries. find_all ( ""resolution"" ) [ 0 ]. contents [ 0 ] <TAB> <TAB> datetime_start = arrow. get ( timeseries. find_all ( ""start"" ) [ 0 ]. contents [ 0 ] ) <TAB> <TAB> is_production = ( <TAB> <TAB> <TAB> len ( timeseries. find_all ( ""inBiddingZone_Domain.mRID"". lower ( ) ) ) > 0 <TAB> <TAB> ) <TAB> <TAB> psr_type = ( <TAB> <TAB> <TAB> timeseries. find_all ( ""mktpsrtype"" ) [ 0 ]. find_all ( ""psrtype"" ) [ 0 ]. contents [ 0 ] <TAB> <TAB> ) <TAB> <TAB> for entry in timeseries. find_all ( ""point"" ) : <TAB> <TAB> <TAB> quantity = float ( entry. find_all ( ""quantity"" ) [ 0 ]. contents [ 0 ] ) <TAB> <TAB> <TAB> position = int ( entry. find_all ( ""position"" ) [ 0 ]. contents [ 0 ] ) <TAB> <TAB> <TAB> datetime = datetime_from_position ( datetime_start, position, resolution ) <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> i = datetimes. index ( datetime ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> productions [ i ] [ psr_type ] += quantity <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> productions [ i ] [ psr_type ] -= quantity <TAB> <TAB> <TAB> except ValueError : <TAB> <TAB",True,is_production,is_production,0.6595161557197571
|
||
|
1456,"def _ensure_virtualenv ( self ) : <TAB> if hasattr ( self, ""venv"" ) : <TAB> <TAB> return <TAB> self. venv = join ( self. buildozer_dir, ""venv"" ) <TAB> if not self. file_exists ( self. venv ) : <TAB> <TAB> self. cmd ( ""virtualenv --python=python2.7./venv"", cwd = self. buildozer_dir ) <TAB> <TAB> output = self. cmd ( <TAB> <TAB> 'bash -c ""source venv/bin/activate && env""', <TAB> <TAB> get_stdout = True, <TAB> <TAB> cwd = self. buildozer_dir, <TAB> ) <TAB> self. env_venv = copy ( self. environ ) <TAB> for line in output [ 0 ]. splitlines ( ) : <TAB> <TAB> args = line. split ( ""="", 1 ) <TAB> <TAB> if len ( args )!= 2 : <TAB> <TAB> <TAB> continue <TAB> <TAB> key, value = args <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. env_venv [ key ] = value <TAB> if ""PYTHONHOME"" in self. env_venv : <TAB> <TAB> del self. env_venv [ ""PYTHONHOME"" ] <TAB> <TAB> self. env_venv [ ""CC"" ] = ""/bin/false"" <TAB> self. env_venv [ ""CXX"" ] = ""/bin/false""",False,"key in ('VIRTUAL_ENV', 'PATH')",key in self.env_venv,0.6636096239089966
|
||
|
1457,"def __call__ ( self, req ) : <TAB> access_key = str ( req. params [ ""AWSAccessKeyId"" ] ) <TAB> failures_key = ""authfailures-%s"" % access_key <TAB> failures = int ( self. mc. get ( failures_key ) or 0 ) <TAB> if failures >= FLAGS. lockout_attempts : <TAB> <TAB> detail = _ ( ""Too many failed authentications."" ) <TAB> <TAB> raise webob. exc. HTTPForbidden ( detail = detail ) <TAB> res = req. get_response ( self. application ) <TAB> if res. status_int == 403 : <TAB> <TAB> failures = self. mc. incr ( failures_key ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. mc. set ( failures_key, ""1"", time = FLAGS. lockout_window * 60 ) <TAB> <TAB> elif failures >= FLAGS. lockout_attempts : <TAB> <TAB> <TAB> lock_mins = FLAGS. lockout_minutes <TAB> <TAB> <TAB> msg = ( <TAB> <TAB> <TAB> <TAB> _ ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Access key %(access_key)s has had %(failures)d"" <TAB> <TAB> <TAB> <TAB> <TAB> "" failed authentications and will be locked out"" <TAB> <TAB> <TAB> <TAB> <TAB> "" for %(lock_mins)d minutes."" <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> % locals ( ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> LOG. warn ( msg ) <TAB> <TAB> <TAB> self. mc. set ( failures_key, str ( failures ), time = FLAGS. lockout_minutes * 60 ) <TAB> return res",False,failures is None,failures >= FLAGS.lockout_window,0.6843120455741882
|
||
|
1458,"def zapToCharacter ( self, event ) : <TAB> """"""Kill characters from the insertion point to a given character."""""" <TAB> k = self. c. k <TAB> w = self. editWidget ( event ) <TAB> if not w : <TAB> <TAB> return <TAB> state = k. getState ( ""zap-to-char"" ) <TAB> if state == 0 : <TAB> <TAB> k. setLabelBlue ( ""Zap To Character: "" ) <TAB> <TAB> k. setState ( ""zap-to-char"", 1, handler = self. zapToCharacter ) <TAB> else : <TAB> <TAB> ch = event. char if event else "" "" <TAB> <TAB> k. resetLabel ( ) <TAB> <TAB> k. clearState ( ) <TAB> <TAB> s = w. getAllText ( ) <TAB> <TAB> ins = w. getInsertPoint ( ) <TAB> <TAB> i = s. find ( ch, ins ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return <TAB> <TAB> self. beginCommand ( w, undoType = ""zap-to-char"" ) <TAB> <TAB> self. addToKillBuffer ( s [ ins : i ] ) <TAB> <TAB> g. app. gui. replaceClipboardWith ( s [ ins : i ] ) <TAB> <TAB> w. setAllText ( s [ : ins ] + s [ i : ] ) <TAB> <TAB> w. setInsertPoint ( ins ) <TAB> <TAB> self. endCommand ( changed = True, setLabel = True )",False,i == -1,i < 0,0.6703222990036011
|
||
|
1459,"def children ( self, ** kwargs ) : <TAB> """"""Build a list of treeview nodes from the child nodes."""""" <TAB> if ""sid"" not in kwargs : <TAB> <TAB> return precondition_required ( gettext ( ""Required properties are missing."" ) ) <TAB> from pgadmin. utils. driver import get_driver <TAB> manager = get_driver ( PG_DEFAULT_DRIVER ). connection_manager ( sid = kwargs [ ""sid"" ] ) <TAB> did = None <TAB> if ""did"" in kwargs : <TAB> <TAB> did = kwargs [ ""did"" ] <TAB> try : <TAB> <TAB> conn = manager. connection ( did = did ) <TAB> <TAB> if not conn. connected ( ) : <TAB> <TAB> <TAB> status, msg = conn. connect ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return internal_server_error ( errormsg = msg ) <TAB> except ( ConnectionLost, SSHTunnelConnectionLost, CryptKeyMissing ) : <TAB> <TAB> raise <TAB> except Exception : <TAB> <TAB> return precondition_required ( gettext ( ""Connection to the server has been lost."" ) ) <TAB> <TAB> return make_json_response ( <TAB> <TAB> data = sorted ( <TAB> <TAB> <TAB> self. get_children_nodes ( manager, ** kwargs ), key = lambda c : c [ ""label"" ] <TAB> <TAB> ) <TAB> )",False,not status,status,0.6787869334220886
|
||
|
1460,"def scan_exist_ip_worker ( self ) : <TAB> while self. running and self. keep_scan_all_exist_ip : <TAB> <TAB> try : <TAB> <TAB> <TAB> ip_str = self. scan_exist_ip_queue. get_nowait ( ) <TAB> <TAB> except : <TAB> <TAB> <TAB> break <TAB> <TAB> result = self. check_ip ( ip_str ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. ip_lock. acquire ( ) <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> if ip_str not in self. ip_dict : <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> if self. ip_dict [ ip_str ] [ ""fail_times"" ] == 0 : <TAB> <TAB> <TAB> <TAB> <TAB> self. _add_ip_num ( ip_str, - 1 ) <TAB> <TAB> <TAB> <TAB> self. ip_dict [ ip_str ] [ ""fail_times"" ] += 1 <TAB> <TAB> <TAB> <TAB> self. ip_dict [ ip_str ] [ ""fail_time"" ] = time. time ( ) <TAB> <TAB> <TAB> finally : <TAB> <TAB> <TAB> <TAB> self. ip_lock. release ( ) <TAB> <TAB> elif result. ok : <TAB> <TAB> <TAB> self. add_ip ( ip_str, result. request_time, result. domain ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. report_connect_fail ( ip_str, force_remove = True )",False,not result,result.ok,0.6645494103431702
|
||
|
1461,"def testParseModel ( self ) : <TAB> res_dir = os. path. join ( self. results_dir, ""baseml"", ""model"" ) <TAB> for results_file in os. listdir ( res_dir ) : <TAB> <TAB> version = results_file. split ( ""-"" ) [ 1 ]. split ( ""."" ) [ 0 ] <TAB> <TAB> model = results_file [ 5 ] <TAB> <TAB> version_msg = ""Improper parsing for model %s version %s"" % ( <TAB> <TAB> <TAB> model, <TAB> <TAB> <TAB> version. replace ( ""_"", ""."" ), <TAB> <TAB> ) <TAB> <TAB> results_path = os. path. join ( res_dir, results_file ) <TAB> <TAB> results = baseml. read ( results_path ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. assertEqual ( len ( results ), 6, version_msg ) <TAB> <TAB> self. assertIn ( ""parameters"", results, version_msg ) <TAB> <TAB> params = results [ ""parameters"" ] <TAB> <TAB> self. assertIn ( ""alpha"", params, version_msg ) <TAB> <TAB> self. assertIn ( ""rates"", params, version_msg ) <TAB> <TAB> self. assertIn ( ""parameter list"", params, version_msg ) <TAB> <TAB> self. assertIn ( ""rate frequencies"", params, version_msg ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. assertIn ( ""kappa"", params, version_msg ) <TAB> <TAB> if model in [ ""7"", ""8"" ] : <TAB> <TAB> <TAB> self. assertIn ( ""base frequencies"", params, version_msg ) <TAB> <TAB> <TAB> self. assertIn ( ""rate parameters"", params, version_msg ) <TAB> <TAB> <TAB> self. assertIn ( ""Q matrix"", params, version_msg ) <TAB> <TAB> <TAB> qmat = params [ ""Q matrix"" ] <TAB> <TAB> <TAB> self. assertEqual",False,"model in ['1', '3', '4', '5', '6']","model in ['6', '7']",0.6486180424690247
|
||
|
1462,"def set_version ( self, value ) : <TAB> value = value. strip ( ). replace ( "" "", """" ) <TAB> if re. match ( r""^\d+(\.\d+){1,3}$"", value ) is not None : <TAB> <TAB> check = True <TAB> <TAB> v_i = value. split ( ""."" ) <TAB> <TAB> for item in v_i : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> i = int ( item ) <TAB> <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> <TAB> check = False <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self [ ""arm_project_version"" ] = value",True,check,check,0.6907080411911011
|
||
|
1463,"def load_dataset ( self ) : <TAB> cfg = self. cfg <TAB> file_name = os. path. join ( self. cfg. project_path, cfg. dataset ) <TAB> <TAB> mlab = sio. loadmat ( file_name ) <TAB> self. raw_data = mlab <TAB> mlab = mlab [ ""dataset"" ] <TAB> num_images = mlab. shape [ 1 ] <TAB> <TAB> data = [ ] <TAB> has_gt = True <TAB> for i in range ( num_images ) : <TAB> <TAB> sample = mlab [ 0, i ] <TAB> <TAB> item = DataItem ( ) <TAB> <TAB> item. image_id = i <TAB> <TAB> item. im_path = sample [ 0 ] [ 0 ] <TAB> <TAB> item. im_size = sample [ 1 ] [ 0 ] <TAB> <TAB> if len ( sample ) >= 3 : <TAB> <TAB> <TAB> joints = sample [ 2 ] [ 0 ] [ 0 ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> joint_id = joints [ :, 0 ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> assert ( joint_id < cfg. num_joints ). any ( ) <TAB> <TAB> <TAB> joints [ :, 0 ] = joint_id <TAB> <TAB> <TAB> item. joints = [ joints ] <TAB> <TAB> else : <TAB> <TAB> <TAB> has_gt = False <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> data. append ( item ) <TAB> self. has_gt = has_gt <TAB> return data",False,joint_id.size != 0,cfg.num_joints > 0,0.6641768217086792
|
||
|
1464,"def _ReadHereLines ( <TAB> line_reader, <TAB> h, <TAB> delimiter, ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> here_lines = [ ] <TAB> last_line = None <TAB> strip_leading_tabs = h. op. id == Id. Redir_DLessDash <TAB> while True : <TAB> <TAB> line_id, line, unused_offset = line_reader. GetLine ( ) <TAB> <TAB> if line is None : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> p_die ( ""Couldn't find terminator for here doc that starts here"", token = h. op ) <TAB> <TAB> assert len ( line )!= 0 <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> start_offset = 0 <TAB> <TAB> if strip_leading_tabs : <TAB> <TAB> <TAB> n = len ( line ) <TAB> <TAB> <TAB> i = 0 <TAB> <TAB> <TAB> while i < n : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> i += 1 <TAB> <TAB> <TAB> start_offset = i <TAB> <TAB> if line [ start_offset : ]. rstrip ( ) == delimiter : <TAB> <TAB> <TAB> last_line = ( line_id, line, start_offset ) <TAB> <TAB> <TAB> break <TAB> <TAB> here_lines. append ( ( line_id, line, start_offset ) ) <TAB> return here_lines, last_line",False,line[i] != '\t',last_line is None,0.6575617790222168
|
||
|
1465,"def flatten_nest_dict ( d ) : <TAB> """"""Return the dict with all nested keys flattened joined with '/'."""""" <TAB> <TAB> flat_dict = NonMutableDict ( ) <TAB> for k, v in d. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> flat_dict. update ( <TAB> <TAB> <TAB> <TAB> { ""{}/{}"". format ( k, k2 ) : v2 for k2, v2 in flatten_nest_dict ( v ). items ( ) } <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> flat_dict [ k ] = v <TAB> return flat_dict",True,"isinstance(v, dict)","isinstance(v, dict)",0.6524205207824707
|
||
|
1466,"def export_speaker_csv_task ( event_id ) : <TAB> try : <TAB> <TAB> os. mkdir ( app. config [ ""TEMP_UPLOADS_FOLDER"" ] ) <TAB> except OSError as exc : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise exc <TAB> filename = ""speaker-{}.csv"". format ( uuid. uuid1 ( ). hex ) <TAB> file_path = app. config [ ""TEMP_UPLOADS_FOLDER"" ] + ""/"" + filename <TAB> with open ( file_path, ""w"" ) as temp_file : <TAB> <TAB> writer = csv. writer ( temp_file ) <TAB> <TAB> content = SpeakerCsv. export ( event_id ) <TAB> <TAB> for row in content : <TAB> <TAB> <TAB> row = [ s. encode ( ""utf-8"" ) for s in row ] <TAB> <TAB> <TAB> writer. writerow ( row ) <TAB> speaker_csv_file = UploadedFile ( file_path = file_path, filename = filename ) <TAB> speaker_csv_url = upload ( <TAB> <TAB> speaker_csv_file, UPLOAD_PATHS [ ""exports"" ] [ ""csv"" ]. format ( event_id = event_id ) <TAB> ) <TAB> return speaker_csv_url",False,exc.errno != errno.EEXIST,not exc.has_error,0.6544767618179321
|
||
|
1467,"def test_fit2 ( self ) : <TAB> scale_param = self. get_scale_param ( ) <TAB> scale_param. scale_column_idx = [ ] <TAB> scale_param. feat_upper = [ 2, 2, 2, 2, 2, 2 ] <TAB> scale_param. feat_lower = [ 1, 1, 1, 1, 1, 1 ] <TAB> scale_obj = MinMaxScale ( scale_param ) <TAB> fit_instance = scale_obj. fit ( self. table_instance ) <TAB> column_min_value = scale_obj. column_min_value <TAB> column_max_value = scale_obj. column_max_value <TAB> for i, line in enumerate ( self. test_data ) : <TAB> <TAB> for j, value in enumerate ( line ) : <TAB> <TAB> <TAB> if value > 2 : <TAB> <TAB> <TAB> <TAB> self. test_data [ i ] [ j ] = 2 <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> self. test_data [ i ] [ j ] = 1 <TAB> scaler = MMS ( ) <TAB> scaler. fit ( self. test_data ) <TAB> self. assertListEqual ( <TAB> <TAB> self. get_table_instance_feature ( fit_instance ), <TAB> <TAB> np. around ( scaler. transform ( self. test_data ), 6 ). tolist ( ), <TAB> ) <TAB> data_min = list ( scaler. data_min_ ) <TAB> data_max = list ( scaler. data_max_ ) <TAB> self. assertListEqual ( column_min_value, data_min ) <TAB> self. assertListEqual ( column_max_value, data_max ) <TAB> transform_data = scale_obj. transform ( self. table_instance ) <TAB> self. assertListEqual ( <TAB> <TAB> self. get_table_instance_feature ( fit_instance ), <TAB> <TAB> self. get_table_instance_feature ( transform_data ), <TAB> )",False,value < 1,value > 1,0.6671333312988281
|
||
|
1468,"def PyJs_normaliseOptions_261_ ( this, arguments, var = var ) : <TAB> var = Scope ( <TAB> <TAB> { <TAB> <TAB> <TAB> u""this"" : this, <TAB> <TAB> <TAB> u""normaliseOptions"" : PyJs_normaliseOptions_261_, <TAB> <TAB> <TAB> u""arguments"" : arguments, <TAB> <TAB> }, <TAB> <TAB> var, <TAB> ) <TAB> var. registers ( [ u""_key3"", u""val"", u""option"", u""opts"" ] ) <TAB> var. put ( u""opts"", var. get ( u""this"" ). get ( u""options"" ) ) <TAB> for PyJsTemp in var. get ( u""_config3"" ). get ( u""default"" ) : <TAB> <TAB> var. put ( u""_key3"", PyJsTemp ) <TAB> <TAB> var. put ( u""option"", var. get ( u""_config3"" ). get ( u""default"" ). get ( var. get ( u""_key3"" ) ) ) <TAB> <TAB> var. put ( u""val"", var. get ( u""opts"" ). get ( var. get ( u""_key3"" ) ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> if var. get ( u""option"" ). get ( u""alias"" ) : <TAB> <TAB> <TAB> var. get ( u""opts"" ). put ( <TAB> <TAB> <TAB> <TAB> var. get ( u""option"" ). get ( u""alias"" ), <TAB> <TAB> <TAB> <TAB> ( <TAB> <TAB> <TAB> <TAB> <TAB> var. get ( u""opts"" ). get ( var. get ( u""option"" ). get ( u""alias"" ) ) <TAB> <TAB> <TAB> <TAB> <TAB> or var. get ( u""val"" ) <TAB> <TAB> <TAB> <TAB> ), <TAB> <",False,var.get(u'val').neg() and var.get(u'option').get(u'optional'),not var,0.6499732732772827
|
||
|
1469,"def kurfile ( request, example_directory, jinja_engine ) : <TAB> result = Kurfile ( os. path. join ( example_directory, request. param ), jinja_engine ) <TAB> modify_kurfile ( result. data ) <TAB> for k in ( ""train"", ""validate"", ""test"", ""evaluate"" ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> for data_source in result. data [ k ] [ ""data"" ] : <TAB> <TAB> <TAB> <TAB> if ( <TAB> <TAB> <TAB> <TAB> <TAB> ""speech_recognition"" in data_source <TAB> <TAB> <TAB> <TAB> <TAB> and ""normalization"" in data_source [ ""speech_recognition"" ] <TAB> <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> <TAB> del data_source [ ""speech_recognition"" ] [ ""normalization"" ] <TAB> result. parse ( ) <TAB> return result",False,k in result.data and 'data' in result.data[k],k in result.data,0.6520867347717285
|
||
|
1470,"def convert_core ( capi1_file, capi2_file ) : <TAB> try : <TAB> <TAB> core = open_core ( capi1_file ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return <TAB> <TAB> coredata = { } <TAB> <TAB> coredata [ ""name"" ] = str ( core. name ) <TAB> <TAB> if core. main. description : <TAB> <TAB> <TAB> coredata [ ""description"" ] = strip_quotes ( core. main. description ) <TAB> <TAB> if core. provider : <TAB> <TAB> <TAB> coredata [ ""provider"" ] = core. provider. config <TAB> <TAB> if core. scripts : <TAB> <TAB> <TAB> coredata [ ""scripts"" ] = gather_scripts ( core ) <TAB> <TAB> filesets = gather_filesets ( core ) <TAB> <TAB> if filesets : <TAB> <TAB> <TAB> coredata [ ""filesets"" ] = filesets <TAB> <TAB> targets = gather_targets ( core ) <TAB> <TAB> if targets : <TAB> <TAB> <TAB> coredata [ ""targets"" ] = targets <TAB> <TAB> if core. parameter : <TAB> <TAB> <TAB> parameters = gather_parameters ( core ) <TAB> <TAB> <TAB> if parameters : <TAB> <TAB> <TAB> <TAB> coredata [ ""parameters"" ] = parameters <TAB> <TAB> if core. vpi : <TAB> <TAB> <TAB> coredata [ ""vpi"" ] = gather_vpi ( core ) <TAB> <TAB> write_core ( capi2_file, coredata ) <TAB> except Exception as e : <TAB> <TAB> logger. error ( ""Unable to convert core {}: {}"". format ( capi1_file, str ( e ) ) ) <TAB> <TAB> sys. exit ( 1 )",False,not core,core is None,0.7023690938949585
|
||
|
1471,"def _expand_file_annotations ( src_path, dst_path, nas_mode ) : <TAB> with open ( src_path ) as src, open ( dst_path, ""w"" ) as dst : <TAB> <TAB> try : <TAB> <TAB> <TAB> annotated_code = code_generator. parse ( src. read ( ), nas_mode ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> shutil. copyfile ( src_path, dst_path ) <TAB> <TAB> <TAB> <TAB> return False <TAB> <TAB> <TAB> dst. write ( annotated_code ) <TAB> <TAB> <TAB> return True <TAB> <TAB> except Exception as exc : <TAB> <TAB> <TAB> if exc. args : <TAB> <TAB> <TAB> <TAB> raise RuntimeError ( <TAB> <TAB> <TAB> <TAB> <TAB> src_path + "" "" + ""\n"". join ( str ( arg ) for arg in exc. args ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> raise RuntimeError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Failed to expand annotations for %s: %r"" % ( src_path, exc ) <TAB> <TAB> <TAB> <TAB> )",False,annotated_code is None,"hasattr(dst, 'read')",0.6705628633499146
|
||
|
1472,"def wrapped ( * args ) : <TAB> if not manual_session and not use_fixture : <TAB> <TAB> s, p = new_session ( <TAB> <TAB> <TAB> mapgen = mapgen, human_player = human_player, ai_players = ai_players <TAB> <TAB> ) <TAB> elif use_fixture : <TAB> <TAB> path = os. path. join ( TEST_FIXTURES_DIR, use_fixture + "".sqlite"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise Exception ( ""Savegame {} not found"". format ( path ) ) <TAB> <TAB> s = load_session ( path ) <TAB> timelimit = Timer ( handler ) <TAB> timelimit. start ( timeout ) <TAB> try : <TAB> <TAB> if use_fixture : <TAB> <TAB> <TAB> return func ( s, * args ) <TAB> <TAB> elif not manual_session : <TAB> <TAB> <TAB> return func ( s, p, * args ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return func ( * args ) <TAB> finally : <TAB> <TAB> try : <TAB> <TAB> <TAB> if use_fixture : <TAB> <TAB> <TAB> <TAB> s. end ( remove_savegame = False, keep_map = True ) <TAB> <TAB> <TAB> elif not manual_session : <TAB> <TAB> <TAB> <TAB> s. end ( ) <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> finally : <TAB> <TAB> <TAB> SPTestSession. cleanup ( ) <TAB> <TAB> timelimit. stop ( )",True,not os.path.exists(path),not os.path.exists(path),0.6483596563339233
|
||
|
1473,"def box_nms ( boxes, scores, proposals, thresh, topk, nms_type = ""normal"" ) : <TAB> assert nms_type in [ ""normal"", ""rotate"" ], ""unknown nms type {}"". format ( nms_type ) <TAB> order = np. argsort ( - scores ) <TAB> boxes = boxes [ order ] <TAB> scores = scores [ order ] <TAB> proposals = proposals [ order ] <TAB> nmsed_scores = [ ] <TAB> nmsed_proposals = [ ] <TAB> cnt = 0 <TAB> while boxes. shape [ 0 ] : <TAB> <TAB> nmsed_scores. append ( scores [ 0 ] ) <TAB> <TAB> nmsed_proposals. append ( proposals [ 0 ] ) <TAB> <TAB> cnt += 1 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> break <TAB> <TAB> iou = box_iou ( boxes [ 0 ], boxes [ 1 : ], nms_type ) <TAB> <TAB> boxes = boxes [ 1 : ] [ iou < thresh ] <TAB> <TAB> scores = scores [ 1 : ] [ iou < thresh ] <TAB> <TAB> proposals = proposals [ 1 : ] [ iou < thresh ] <TAB> return nmsed_scores, nmsed_proposals",False,cnt >= topk or boxes.shape[0] == 1,cnt > 3,0.6555474996566772
|
||
|
1474,"def on_activated_async ( self, view ) : <TAB> if settings [ ""modified_lines_only"" ] : <TAB> <TAB> self. freeze_last_version ( view ) <TAB> if settings [ ""enabled"" ] : <TAB> <TAB> match_trailing_spaces ( view ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> active_views [ view. id ( ) ] = view. visible_region ( ) <TAB> <TAB> <TAB> self. update_on_region_change ( view )",False,not view.id() in active_views,view.id() not in active_views,0.6515470743179321
|
||
|
1475,"def setTopGeometry ( self, w, h, x, y, adjustSize = True ) : <TAB> <TAB> x = max ( 10, x ) <TAB> y = max ( 10, y ) <TAB> if adjustSize : <TAB> <TAB> top = self. top <TAB> <TAB> sw = top. winfo_screenwidth ( ) <TAB> <TAB> sh = top. winfo_screenheight ( ) <TAB> <TAB> <TAB> <TAB> w = min ( sw - 10, w ) <TAB> <TAB> h = min ( sh - 10, h ) <TAB> <TAB> <TAB> <TAB> if x + w > sw : <TAB> <TAB> <TAB> x = 10 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> y = 10 <TAB> geom = ""%dx%d%+d%+d"" % ( w, h, x, y ) <TAB> self. top. geometry ( geom )",False,y + h > sh,y + y > sw,0.6667530536651611
|
||
|
1476,"def __init__ ( <TAB> self, <TAB> classifier, <TAB> layer_name = None, <TAB> transpose = None, <TAB> distance = None, <TAB> copy_weights = True, ) : <TAB> super ( ). __init__ ( ) <TAB> self. copy_weights = copy_weights <TAB> <TAB> if layer_name is not None : <TAB> <TAB> self. set_weights ( getattr ( classifier, layer_name ) ) <TAB> else : <TAB> <TAB> for x in self. possible_layer_names : <TAB> <TAB> <TAB> layer = getattr ( classifier, x, None ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. set_weights ( layer ) <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> self. distance = classifier. distance if distance is None else distance <TAB> self. transpose = transpose",True,layer is not None,layer is not None,0.6652194857597351
|
||
|
1477,"def check_services_health ( self ) : <TAB> """"""Check connectivity of all services"""""" <TAB> for name, service in self. _service_map. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> try : <TAB> <TAB> <TAB> await Server. from_orm ( service. orm. server ). wait_up ( timeout = 1 ) <TAB> <TAB> except TimeoutError : <TAB> <TAB> <TAB> self. log. warning ( <TAB> <TAB> <TAB> <TAB> ""Cannot connect to %s service %s at %s"", <TAB> <TAB> <TAB> <TAB> service. kind, <TAB> <TAB> <TAB> <TAB> name, <TAB> <TAB> <TAB> <TAB> service. url, <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. log. debug ( <TAB> <TAB> <TAB> <TAB> ""%s service %s running at %s"", <TAB> <TAB> <TAB> <TAB> service. kind. title ( ), <TAB> <TAB> <TAB> <TAB> name, <TAB> <TAB> <TAB> <TAB> service. url, <TAB> <TAB> <TAB> )",False,not service.url,service.kind == 'server',0.6602045297622681
|
||
|
1478,"def undo_filter_paeth ( filter_unit, scanline, previous, result ) : <TAB> """"""Undo Paeth filter."""""" <TAB> <TAB> ai = - filter_unit <TAB> for i in range ( len ( result ) ) : <TAB> <TAB> x = scanline [ i ] <TAB> <TAB> if ai < 0 : <TAB> <TAB> <TAB> a = c = 0 <TAB> <TAB> else : <TAB> <TAB> <TAB> a = result [ ai ] <TAB> <TAB> <TAB> c = previous [ ai ] <TAB> <TAB> b = previous [ i ] <TAB> <TAB> p = a + b - c <TAB> <TAB> pa = abs ( p - a ) <TAB> <TAB> pb = abs ( p - b ) <TAB> <TAB> pc = abs ( p - c ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> pr = a <TAB> <TAB> elif pb <= pc : <TAB> <TAB> <TAB> pr = b <TAB> <TAB> else : <TAB> <TAB> <TAB> pr = c <TAB> <TAB> result [ i ] = ( x + pr ) & 0xFF <TAB> <TAB> ai += 1",False,pa <= pb and pa <= pc,pa <= pc,0.6689061522483826
|
||
|
1479,"def test_errors ( self ) : <TAB> self. assertRaises ( TypeError, grp. getgrgid ) <TAB> self. assertRaises ( TypeError, grp. getgrnam ) <TAB> self. assertRaises ( TypeError, grp. getgrall, 42 ) <TAB> <TAB> self. assertRaises ( ValueError, grp. getgrnam, ""a\x00b"" ) <TAB> <TAB> bynames = { } <TAB> bygids = { } <TAB> for ( n, p, g, mem ) in grp. getgrall ( ) : <TAB> <TAB> if not n or n == ""+"" : <TAB> <TAB> <TAB> continue <TAB> <TAB> bynames [ n ] = g <TAB> <TAB> bygids [ g ] = n <TAB> allnames = list ( bynames. keys ( ) ) <TAB> namei = 0 <TAB> fakename = allnames [ namei ] <TAB> while fakename in bynames : <TAB> <TAB> chars = list ( fakename ) <TAB> <TAB> for i in range ( len ( chars ) ) : <TAB> <TAB> <TAB> if chars [ i ] == ""z"" : <TAB> <TAB> <TAB> <TAB> chars [ i ] = ""A"" <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> chars [ i ] = chr ( ord ( chars [ i ] ) + 1 ) <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> else : <TAB> <TAB> <TAB> namei = namei + 1 <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> fakename = allnames [ namei ] <TAB> <TAB> <TAB> except IndexError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> fakename = """". join ( chars ) <TAB> self. assertRaises ( KeyError,",False,chars[i] == 'Z',chars[i] == 't',0.6575480699539185
|
||
|
1480,"def validate ( self ) : <TAB> super ( CloudTrailMode, self ). validate ( ) <TAB> from c7n import query <TAB> events = self. policy. data [ ""mode"" ]. get ( ""events"" ) <TAB> assert events, ""cloud trail mode requires specifiying events to subscribe"" <TAB> for e in events : <TAB> <TAB> if isinstance ( e, str ) : <TAB> <TAB> <TAB> assert e in CloudWatchEvents. trail_events, ( <TAB> <TAB> <TAB> <TAB> ""event shortcut not defined: %s"" % e <TAB> <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> jmespath. compile ( e [ ""ids"" ] ) <TAB> if isinstance ( self. policy. resource_manager, query. ChildResourceManager ) : <TAB> <TAB> if not getattr ( <TAB> <TAB> <TAB> self. policy. resource_manager. resource_type, ""supports_trailevents"", False <TAB> <TAB> ) : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""resource:%s does not support cloudtrail mode policies"" <TAB> <TAB> <TAB> <TAB> % ( self. policy. resource_type ) <TAB> <TAB> <TAB> )",False,"isinstance(e, dict)",e,0.6523284912109375
|
||
|
1481,"def discover_hdfstore ( f ) : <TAB> d = dict ( ) <TAB> for key in f. keys ( ) : <TAB> <TAB> d2 = d <TAB> <TAB> key2 = key. lstrip ( ""/"" ) <TAB> <TAB> while ""/"" in key2 : <TAB> <TAB> <TAB> group, key2 = key2. split ( ""/"", 1 ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> d2 [ group ] = dict ( ) <TAB> <TAB> <TAB> d2 = d2 [ group ] <TAB> <TAB> d2 [ key2 ] = f. get_storer ( key ) <TAB> return discover ( d )",True,group not in d2,group not in d2,0.6638458371162415
|
||
|
1482,"def callUpdate ( ii ) : <TAB> if ii % updateMultiply!= 0 : <TAB> <TAB> return <TAB> if updateFunction is True : <TAB> <TAB> tasksDone = min ( [ ii, iterLength ] ) <TAB> <TAB> print ( f""Done {tasksDone} tasks of {iterLength}"" ) <TAB> elif updateFunction not in ( False, None ) : <TAB> <TAB> for thisPosition in range ( ii - updateMultiply, ii ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if thisPosition >= len ( resultsList ) : <TAB> <TAB> <TAB> <TAB> thisResult = None <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> thisResult = resultsList [ thisPosition ] <TAB> <TAB> <TAB> if updateSendsIterable is False : <TAB> <TAB> <TAB> <TAB> updateFunction ( thisPosition, iterLength, thisResult ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> updateFunction ( <TAB> <TAB> <TAB> <TAB> <TAB> thisPosition, iterLength, thisResult, iterable [ thisPosition ] <TAB> <TAB> <TAB> <TAB> )",False,thisPosition < 0,thisPosition >= len(resultsList),0.6682397127151489
|
||
|
1483,"def __getitem__ ( self, name ) : <TAB> nstat = os. stat ( name ) <TAB> if name in self. cache : <TAB> <TAB> stat, pixmap = self. cache [ name ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return pixmap <TAB> <TAB> else : <TAB> <TAB> <TAB> del self. cache [ name ] <TAB> pixmap = self. loadImage ( name ) <TAB> self. cache [ name ] = ( nstat, pixmap ) <TAB> return pixmap",False,stat.st_size == nstat.st_size and stat.st_mtime == nstat.st_mtime,nstat in [TAB>,0.6516166925430298
|
||
|
1484,"def create_default_site ( <TAB> app_config, <TAB> verbosity = 2, <TAB> interactive = True, <TAB> using = DEFAULT_DB_ALIAS, <TAB> apps = global_apps, <TAB> ** kwargs ) : <TAB> try : <TAB> <TAB> Site = apps. get_model ( ""sites"", ""Site"" ) <TAB> except LookupError : <TAB> <TAB> return <TAB> if not router. allow_migrate_model ( using, Site ) : <TAB> <TAB> return <TAB> if not Site. objects. using ( using ). exists ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if verbosity >= 2 : <TAB> <TAB> <TAB> print ( ""Creating example.com Site object"" ) <TAB> <TAB> Site ( <TAB> <TAB> <TAB> pk = getattr ( settings, ""SITE_ID"", 1 ), domain = ""example.com"", name = ""example.com"" <TAB> <TAB> ). save ( using = using ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> sequence_sql = connections [ using ]. ops. sequence_reset_sql ( no_style ( ), [ Site ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if verbosity >= 2 : <TAB> <TAB> <TAB> <TAB> print ( ""Resetting sequence"" ) <TAB> <TAB> <TAB> with connections [ using ]. cursor ( ) as cursor : <TAB> <TAB> <TAB> <TAB> for command in sequence_sql : <TAB> <TAB> <TAB> <TAB> <TAB> cursor. execute ( command )",False,sequence_sql,verbosity >= 1,0.6666785478591919
|
||
|
1485,"def rename ( checkpoint, op, dry_run ) : <TAB> import tensorflow as tf <TAB> tf. compat. v1. reset_default_graph ( ) <TAB> with tf. compat. v1. Session ( ) as sess : <TAB> <TAB> for var_name, _ in tf. compat. v1. train. list_variables ( checkpoint ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> var = tf. compat. v1. train. load_variable ( checkpoint, var_name ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> new_name = op ( var_name ) <TAB> <TAB> <TAB> if dry_run : <TAB> <TAB> <TAB> <TAB> logger. info ( f""{var_name} would be renamed to {new_name}."" ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> if var_name == new_name : <TAB> <TAB> <TAB> <TAB> <TAB> logger. info ( f""No change for {var_name}"" ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> logger. info ( f""Renaming {var_name} to {new_name}."" ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> tf. Variable ( var, name = new_name ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> saver = tf. compat. v1. train. Saver ( ) <TAB> <TAB> <TAB> sess. run ( tf. compat. v1. global_variables_initializer ( ) ) <TAB> <TAB> <TAB> saver. save ( sess, checkpoint ) <TAB> tf. compat. v1. reset_default_graph ( )",False,not dry_run,op == tf.compat.v1.train.save_variable and (not dry_run),0.6640776991844177
|
||
|
1486,"def _init_scheme_list ( self, data ) : <TAB> """"""initialize.handlers and.schemes attributes"""""" <TAB> handlers = [ ] <TAB> schemes = [ ] <TAB> if isinstance ( data, native_string_types ) : <TAB> <TAB> data = splitcomma ( data ) <TAB> for elem in data or ( ) : <TAB> <TAB> <TAB> <TAB> if hasattr ( elem, ""name"" ) : <TAB> <TAB> <TAB> handler = elem <TAB> <TAB> <TAB> scheme = handler. name <TAB> <TAB> <TAB> _validate_handler_name ( scheme ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> handler = get_crypt_handler ( elem ) <TAB> <TAB> <TAB> scheme = handler. name <TAB> <TAB> else : <TAB> <TAB> <TAB> raise TypeError ( <TAB> <TAB> <TAB> <TAB> ""scheme must be name or CryptHandler, "" ""not %r"" % type ( elem ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> if scheme in schemes : <TAB> <TAB> <TAB> raise KeyError ( ""multiple handlers with same name: %r"" % ( scheme, ) ) <TAB> <TAB> <TAB> <TAB> handlers. append ( handler ) <TAB> <TAB> schemes. append ( scheme ) <TAB> self. handlers = tuple ( handlers ) <TAB> self. schemes = tuple ( schemes )",False,"isinstance(elem, native_string_types)","hasattr(elem, 'crypt_handler')",0.6519653797149658
|
||
|
1487,"def to_value ( self, value ) : <TAB> <TAB> <TAB> ret = { } <TAB> for key, val in value. items ( ) : <TAB> <TAB> if key in [ ""attachments"", ""custom_attributes"", ""description_diff"" ] : <TAB> <TAB> <TAB> ret [ key ] = val <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> ret [ key ] = { k : { ""from"" : v [ 0 ], ""to"" : v [ 1 ] } for k, v in val. items ( ) } <TAB> <TAB> else : <TAB> <TAB> <TAB> ret [ key ] = { ""from"" : val [ 0 ], ""to"" : val [ 1 ] } <TAB> return ret",False,key == 'points',"isinstance(val, dict)",0.6632466912269592
|
||
|
1488,"def lint ( ) : <TAB> """"""Run linter on the provided text and return the results."""""" <TAB> if ""text"" in request. values : <TAB> <TAB> text = unquote ( request. values [ ""text"" ] ) <TAB> <TAB> job = q. enqueue ( worker_function, text ) <TAB> <TAB> return jsonify ( job_id = job. id ), 202 <TAB> elif ""job_id"" in request. values : <TAB> <TAB> job = q. fetch_job ( request. values [ ""job_id"" ] ) <TAB> <TAB> if not job : <TAB> <TAB> <TAB> return jsonify ( status = ""error"", message = ""No job with requested job_id."" ), 404 <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> return jsonify ( status = ""error"", message = ""Job is not yet ready."" ), 202 <TAB> <TAB> else : <TAB> <TAB> <TAB> errors = [ ] <TAB> <TAB> <TAB> for i, e in enumerate ( job. result ) : <TAB> <TAB> <TAB> <TAB> app. logger. debug ( e ) <TAB> <TAB> <TAB> <TAB> errors. append ( <TAB> <TAB> <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""check"" : e [ 0 ], <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""message"" : e [ 1 ], <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""line"" : e [ 2 ], <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""column"" : e [ 3 ], <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""start"" : e [ 4 ], <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""end"" : e [ 5 ], <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""extent"" : e [ 5 ] - e [ 4 ], <TAB> <TAB> <TAB> <TAB> <TAB",False,job.result is None,job.status == 'not_ready',0.6600863933563232
|
||
|
1489,"def execute_select ( self, query : Query, custom_fields : Optional [ list ] = None ) -> list : <TAB> _, raw_results = await self. db. execute_query ( query. get_sql ( ) ) <TAB> instance_list = [ ] <TAB> for row in raw_results : <TAB> <TAB> if self. select_related_idx : <TAB> <TAB> <TAB> _, current_idx, _, _ = self. select_related_idx [ 0 ] <TAB> <TAB> <TAB> dict_row = dict ( row ) <TAB> <TAB> <TAB> keys = list ( dict_row. keys ( ) ) <TAB> <TAB> <TAB> values = list ( dict_row. values ( ) ) <TAB> <TAB> <TAB> instance : ""Model"" = self. model. _init_from_db ( <TAB> <TAB> <TAB> <TAB> ** dict ( zip ( keys [ : current_idx ], values [ : current_idx ] ) ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> instances = [ instance ] <TAB> <TAB> <TAB> for model, index, model_name, parent_model in self. select_related_idx [ 1 : ] : <TAB> <TAB> <TAB> <TAB> obj = model. _init_from_db ( <TAB> <TAB> <TAB> <TAB> <TAB> ** dict ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> zip ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> map ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> lambda x : x. split ( ""."" ) [ 1 ], <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> keys [ current_idx : current_idx + index ], <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> values [ current_idx : current_idx + index ], <TAB> <",False,"isinstance(ins, parent_model)",custom_fields,0.6493746638298035
|
||
|
1490,"def run ( self ) : <TAB> while True : <TAB> <TAB> if not self. initialized : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> with Client ( ) as c : <TAB> <TAB> <TAB> <TAB> <TAB> self. disks = c. call ( ""disk.disks_for_temperature_monitoring"" ) <TAB> <TAB> <TAB> <TAB> <TAB> self. powermode = c. call ( ""smart.config"" ) [ ""powermode"" ] <TAB> <TAB> <TAB> except Exception as e : <TAB> <TAB> <TAB> <TAB> print ( f""Failed to query disks for temperature monitoring: {e!r}"" ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. initialized = True <TAB> <TAB> if not self. initialized : <TAB> <TAB> <TAB> time. sleep ( self. interval ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if not self. disks : <TAB> <TAB> <TAB> return <TAB> <TAB> try : <TAB> <TAB> <TAB> with Client ( ) as c : <TAB> <TAB> <TAB> <TAB> self. temperatures = { <TAB> <TAB> <TAB> <TAB> <TAB> disk : temperature * 1000 <TAB> <TAB> <TAB> <TAB> <TAB> for disk, temperature in c. call ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""disk.temperatures"", self. disks, self. powermode <TAB> <TAB> <TAB> <TAB> <TAB> ). items ( ) <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> } <TAB> <TAB> except Exception as e : <TAB> <TAB> <TAB> print ( f""Failed to collect disks temperatures: {e!r}"" ) <TAB> <TAB> <TAB> self. temperatures = { } <TAB> <TAB> time. sleep ( self. interval )",False,temperature is not None,self.temperatures,0.6723409295082092
|
||
|
1491,"def _finalize_sv ( solution_file, data ) : <TAB> """"""Add output files from TitanCNA calling optional solution."""""" <TAB> out = { ""variantcaller"" : ""titancna"" } <TAB> with open ( solution_file ) as in_handle : <TAB> <TAB> solution = dict ( <TAB> <TAB> <TAB> zip ( <TAB> <TAB> <TAB> <TAB> in_handle. readline ( ). strip ( ""\r\n"" ). split ( ""\t"" ), <TAB> <TAB> <TAB> <TAB> in_handle. readline ( ). strip ( ""\r\n"" ). split ( ""\t"" ), <TAB> <TAB> <TAB> ) <TAB> <TAB> ) <TAB> if solution. get ( ""path"" ) : <TAB> <TAB> out [ ""purity"" ] = solution [ ""purity"" ] <TAB> <TAB> out [ ""ploidy"" ] = solution [ ""ploidy"" ] <TAB> <TAB> out [ ""cellular_prevalence"" ] = [ <TAB> <TAB> <TAB> x. strip ( ) for x in solution [ ""cellPrev"" ]. split ( "","" ) <TAB> <TAB> ] <TAB> <TAB> base = os. path. basename ( solution [ ""path"" ] ) <TAB> <TAB> out [ ""plot"" ] = dict ( <TAB> <TAB> <TAB> [ <TAB> <TAB> <TAB> <TAB> ( n, solution [ ""path"" ] + ext ) <TAB> <TAB> <TAB> <TAB> for ( n, ext ) in [ <TAB> <TAB> <TAB> <TAB> <TAB> ( ""rplots"", "".Rplots.pdf"" ), <TAB> <TAB> <TAB> <TAB> <TAB> ( ""cf"", ""/%s_CF.pdf"" % base ), <TAB> <TAB> <TAB> <TAB> <TAB> ( ""cna"", ""/%s_CNA.pdf"" % base ), <TAB> <TAB> <TAB> <TAB> <TAB> ( ""loh"", ""/%s_LOH.pdf"" % base ), <TAB> <TAB>",False,os.path.exists(solution['path'] + ext),d.get('vq'),0.6477440595626831
|
||
|
1492,"def reconfigure_levels ( self ) : <TAB> """"""Adjust the log levels for some modules."""""" <TAB> self. log_level = get_default_level ( ) <TAB> mapping = dict ( ) <TAB> modules_config = { ""subliminal"" : app. SUBLIMINAL_LOG, ""tornado"" : app. WEB_LOG } <TAB> for modname, active in viewitems ( modules_config ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> mapping. update ( { modname : CRITICAL } ) <TAB> for logger in self. loggers : <TAB> <TAB> fullname = logger. name <TAB> <TAB> basename = fullname. split ( ""."" ) [ 0 ] <TAB> <TAB> level = mapping. get ( fullname ) or mapping. get ( basename ) or self. log_level <TAB> <TAB> logger. setLevel ( level ) <TAB> for handler in ( self. console_handler, self. file_handler ) : <TAB> <TAB> if handler : <TAB> <TAB> <TAB> handler. setLevel ( self. log_level )",False,not active,active,0.6758536696434021
|
||
|
1493,"def get_all_values ( self, project ) : <TAB> if isinstance ( project, models. Model ) : <TAB> <TAB> project_id = project. id <TAB> else : <TAB> <TAB> project_id = project <TAB> if project_id not in self. __cache : <TAB> <TAB> cache_key = self. _make_key ( project_id ) <TAB> <TAB> result = cache. get ( cache_key ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> result = self. reload_cache ( project_id ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. __cache [ project_id ] = result <TAB> return self. __cache. get ( project_id, { } )",False,result is None,result == {},0.6683422327041626
|
||
|
1494,"def check_message ( neighbor, message ) : <TAB> message = message. replace ( "":"", """" ) <TAB> raw = concat_bytes_i ( <TAB> <TAB> character ( int ( _, 16 ) ) <TAB> <TAB> for _ in ( message [ i * 2 : ( i * 2 ) + 2 ] for i in range ( len ( message ) // 2 ) ) <TAB> ) <TAB> if raw. startswith ( b""\xff"" * 16 ) : <TAB> <TAB> kind = ordinal ( raw [ 18 ] ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if kind == 1 : <TAB> <TAB> <TAB> return check_open ( neighbor, raw [ 18 : ] ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> return check_update ( neighbor, raw ) <TAB> <TAB> elif kind == 3 : <TAB> <TAB> <TAB> return check_notification ( raw ) <TAB> else : <TAB> <TAB> return check_update ( neighbor, raw )",True,kind == 2,kind == 2,0.6761634945869446
|
||
|
1495,"def reload ( self, begin = True ) : <TAB> """"""Begin or end of reloading resp. refreshing of all parameters"""""" <TAB> if begin : <TAB> <TAB> self. _reload_actions = dict ( ) <TAB> else : <TAB> <TAB> if hasattr ( self, ""_reload_actions"" ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for name, initOpts in self. _reload_actions. iteritems ( ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> self. _actions [ name ]. reload ( ** ( initOpts if initOpts else { } ) ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> delacts = OrderedDict ( <TAB> <TAB> <TAB> <TAB> ( name, action ) <TAB> <TAB> <TAB> <TAB> for name, action in self. _actions. iteritems ( ) <TAB> <TAB> <TAB> <TAB> if name not in self. _reload_actions <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if len ( delacts ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. __flushBan ( db = False, actions = delacts ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. stopActions ( actions = delacts ) <TAB> <TAB> <TAB> delattr ( self, ""_reload_actions"" )",True,name in self._actions,name in self._actions,0.6712414622306824
|
||
|
1496,"def merge ( self, other ) : <TAB> d = self. _name2ft <TAB> for name, ( f, t ) in other. _name2ft. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> f2, t2 = d [ name ] <TAB> <TAB> <TAB> f = f + f2 <TAB> <TAB> <TAB> t = t + t2 <TAB> <TAB> d [ name ] = f, t",True,name in d,name in d,0.6783638000488281
|
||
|
1497,"def __new__ ( meta, name, bases, clsdict ) : <TAB> if not ( ""__doc__"" in clsdict and clsdict [ ""__doc__"" ] ) : <TAB> <TAB> for mro_cls in ( mro_cls for base in bases for mro_cls in base. mro ( ) ) : <TAB> <TAB> <TAB> doc = mro_cls. __doc__ <TAB> <TAB> <TAB> if doc : <TAB> <TAB> <TAB> <TAB> clsdict [ ""__doc__"" ] = doc <TAB> <TAB> <TAB> <TAB> break <TAB> for attr, attribute in listitems ( clsdict ) : <TAB> <TAB> if not attribute. __doc__ : <TAB> <TAB> <TAB> for mro_cls in ( <TAB> <TAB> <TAB> <TAB> mro_cls <TAB> <TAB> <TAB> <TAB> for base in bases <TAB> <TAB> <TAB> <TAB> for mro_cls in base. mro ( ) <TAB> <TAB> <TAB> <TAB> if hasattr ( mro_cls, attr ) <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> doc = getattr ( getattr ( mro_cls, attr ), ""__doc__"" ) <TAB> <TAB> <TAB> <TAB> if doc : <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> clsdict [ attr ] = property ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> attribute. fget, attribute. fset, attribute. fdel, doc <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> attribute. __doc__ = doc <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> return type. __new__ ( meta, name, bases, clsdict )",False,"isinstance(attribute, property)","hasattr(attribute, '__fget')",0.6502389907836914
|
||
|
1498,"def stop ( self, timeout = 5 ) : <TAB> <TAB> <TAB> for worker in self. _threads : <TAB> <TAB> self. _queue. put ( _SHUTDOWNREQUEST ) <TAB> <TAB> current = threading. currentThread ( ) <TAB> if timeout and timeout >= 0 : <TAB> <TAB> endtime = time. time ( ) + timeout <TAB> while self. _threads : <TAB> <TAB> worker = self. _threads. pop ( ) <TAB> <TAB> if worker is not current and worker. isAlive ( ) : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> if timeout is None or timeout < 0 : <TAB> <TAB> <TAB> <TAB> <TAB> worker. join ( ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> remaining_time = endtime - time. time ( ) <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> worker. join ( remaining_time ) <TAB> <TAB> <TAB> <TAB> <TAB> if worker. isAlive ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> c = worker. conn <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if c and not c. rfile. closed : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> c. socket. shutdown ( socket. SHUT_RD ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> except TypeError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> c. socket",False,remaining_time > 0,remaining_time is not None,0.6739023923873901
|
||
|
1499,"def _token_led_lparen ( self, left ) : <TAB> if left [ ""type"" ]!= ""field"" : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> prev_t = self. _lookahead_token ( - 2 ) <TAB> <TAB> raise exceptions. ParseError ( <TAB> <TAB> <TAB> prev_t [ ""start"" ], <TAB> <TAB> <TAB> prev_t [ ""value"" ], <TAB> <TAB> <TAB> prev_t [ ""type"" ], <TAB> <TAB> <TAB> ""Invalid function name '%s'"" % prev_t [ ""value"" ], <TAB> <TAB> ) <TAB> name = left [ ""value"" ] <TAB> args = [ ] <TAB> while not self. _current_token ( ) == ""rparen"" : <TAB> <TAB> expression = self. _expression ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _match ( ""comma"" ) <TAB> <TAB> args. append ( expression ) <TAB> self. _match ( ""rparen"" ) <TAB> function_node = ast. function_expression ( name, args ) <TAB> return function_node",False,self._current_token() == 'comma',expression,0.6553242206573486
|
||
|
1500,"def example_reading_spec ( self ) : <TAB> data_fields = { ""targets"" : tf. VarLenFeature ( tf. int64 ) } <TAB> if<mask> : <TAB> <TAB> data_fields [ ""inputs"" ] = tf. VarLenFeature ( tf. int64 ) <TAB> if self. packed_length : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> data_fields [ ""inputs_segmentation"" ] = tf. VarLenFeature ( tf. int64 ) <TAB> <TAB> <TAB> data_fields [ ""inputs_position"" ] = tf. VarLenFeature ( tf. int64 ) <TAB> <TAB> data_fields [ ""targets_segmentation"" ] = tf. VarLenFeature ( tf. int64 ) <TAB> <TAB> data_fields [ ""targets_position"" ] = tf. VarLenFeature ( tf. int64 ) <TAB> data_items_to_decoders = None <TAB> return ( data_fields, data_items_to_decoders )",False,self.has_inputs,self.stochastic_length,0.6544179916381836
|
||
|
1501,"def _augment_images_by_samples ( <TAB> self, images, samples, image_shapes = None, return_matrices = False ) : <TAB> nb_images = len ( images ) <TAB> input_was_array = ia. is_np_array ( images ) <TAB> input_dtype = None if not input_was_array else images. dtype <TAB> result = [ ] <TAB> if<mask> : <TAB> <TAB> matrices = [ None ] * nb_images <TAB> for i in sm. xrange ( nb_images ) : <TAB> <TAB> image = images [ i ] <TAB> <TAB> image_shape = image. shape if image_shapes is None else image_shapes [ i ] <TAB> <TAB> matrix, output_shape = samples. to_matrix ( <TAB> <TAB> <TAB> i, image. shape, image_shape, self. fit_output <TAB> <TAB> ) <TAB> <TAB> cval = samples. cval [ i ] <TAB> <TAB> mode = samples. mode [ i ] <TAB> <TAB> order = samples. order [ i ] <TAB> <TAB> if not _is_identity_matrix ( matrix ) : <TAB> <TAB> <TAB> image_warped = _warp_affine_arr ( <TAB> <TAB> <TAB> <TAB> image, <TAB> <TAB> <TAB> <TAB> matrix, <TAB> <TAB> <TAB> <TAB> order = order, <TAB> <TAB> <TAB> <TAB> mode = mode, <TAB> <TAB> <TAB> <TAB> cval = cval, <TAB> <TAB> <TAB> <TAB> output_shape = output_shape, <TAB> <TAB> <TAB> <TAB> backend = self. backend, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> result. append ( image_warped ) <TAB> <TAB> else : <TAB> <TAB> <TAB> result. append ( image ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> matrices [ i ] = matrix <TAB> <TAB> <TAB> if input_was_array : <TAB> <TAB",True,return_matrices,return_matrices,0.658023476600647
|
||
|
1502,"def update_download_visibility ( self ) : <TAB> for i in range ( self. window ( ). downloads_list. topLevelItemCount ( ) ) : <TAB> <TAB> item = self. window ( ). downloads_list. topLevelItem ( i ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> filter_match = ( <TAB> <TAB> <TAB> self. window ( ). downloads_filter_input. text ( ). lower ( ) <TAB> <TAB> <TAB> in item. download_info [ ""name"" ]. lower ( ) <TAB> <TAB> ) <TAB> <TAB> is_channel = item. download_info [ ""channel_download"" ] <TAB> <TAB> if self. filter == DOWNLOADS_FILTER_CHANNELS : <TAB> <TAB> <TAB> item. setHidden ( not is_channel or not filter_match ) <TAB> <TAB> else : <TAB> <TAB> <TAB> item. setHidden ( <TAB> <TAB> <TAB> <TAB> not item. get_raw_download_status ( ) <TAB> <TAB> <TAB> <TAB> in DOWNLOADS_FILTER_DEFINITION [ self. filter ] <TAB> <TAB> <TAB> <TAB> or not filter_match <TAB> <TAB> <TAB> <TAB> or is_channel <TAB> <TAB> <TAB> )",False,"not isinstance(item, DownloadWidgetItem)",item is None,0.6617163419723511
|
||
|
1503,"def step ( self ) -> None : <TAB> """"""Performs a single optimization step."""""" <TAB> for group in self. param_groups : <TAB> <TAB> for p in group [ ""params"" ] : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> p. add_ ( p. grad, alpha = ( - group [ ""lr"" ] * self. num_data ) ) <TAB> return None",True,p.grad is None,p.grad is None,0.6571645736694336
|
||
|
1504,"def setup_package ( version ) : <TAB> <TAB> cmdclass = { ""test"" : PyTest, ""flake8"" : Flake8 } <TAB> install_requires = [ ] <TAB> for r in read ( ""requirements.txt"" ). split ( ""\n"" ) : <TAB> <TAB> r = r. strip ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> extra = False <TAB> <TAB> for e, v in EXTRAS_REQUIRE. items ( ) : <TAB> <TAB> <TAB> if v and r. startswith ( v [ 0 ] ) : <TAB> <TAB> <TAB> <TAB> EXTRAS_REQUIRE [ e ] = ( <TAB> <TAB> <TAB> <TAB> <TAB> [ r ] if e!= ""kubernetes"" or sys. version_info < ( 3, 0, 0 ) else [ ] <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> extra = True <TAB> <TAB> if not extra : <TAB> <TAB> <TAB> install_requires. append ( r ) <TAB> command_options = { ""test"" : { } } <TAB> if COVERAGE_XML : <TAB> <TAB> command_options [ ""test"" ] [ ""cov_xml"" ] = ""setup.py"", True <TAB> if COVERAGE_HTML : <TAB> <TAB> command_options [ ""test"" ] [ ""cov_html"" ] = ""setup.py"", True <TAB> setup ( <TAB> <TAB> name = NAME, <TAB> <TAB> version = version, <TAB> <TAB> url = URL, <TAB> <TAB> author = AUTHOR, <TAB> <TAB> author_email = AUTHOR_EMAIL, <TAB> <TAB> description = DESCRIPTION, <TAB> <TAB> license = LICENSE, <TAB> <TAB> keywords = KEYWORDS, <TAB> <TAB> long_description = read ( ""README.rst"" ), <TAB> <TAB> classifiers = CLASSIFIERS, <TAB> <TAB> packages = find_packages ( exclude = [ ""tests"", ""tests.*",True,r == '',r == '',0.6907327175140381
|
||
|
1505,"def _get_ispdb ( self, email, domain ) : <TAB> domain = self. _clean_domain ( domain ) <TAB> if domain in ( ""localhost"", ) : <TAB> <TAB> return None <TAB> self. _progress ( _ ( ""Checking ISPDB for %s"" ) % domain ) <TAB> settings = self. _get_xml_autoconfig ( <TAB> <TAB> self. ISPDB_URL % { ""domain"" : domain }, domain, email <TAB> ) <TAB> if settings : <TAB> <TAB> self. _log_result ( _ ( ""Found %s in ISPDB"" ) % domain ) <TAB> <TAB> return settings <TAB> dparts = domain. split ( ""."" ) <TAB> if len ( dparts ) > 2 : <TAB> <TAB> domain = ""."". join ( dparts [ 1 : ] ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return self. _get_xml_autoconfig ( <TAB> <TAB> <TAB> <TAB> self. ISPDB_URL % { ""domain"" : domain }, domain, email <TAB> <TAB> <TAB> ) <TAB> return None",False,"domain not in ('co.uk', 'pagekite.me')",domain,0.6490097641944885
|
||
|
1506,"def __gt__ ( self, other ) : <TAB> <TAB> if isinstance ( other, self. __class__ ) : <TAB> <TAB> <TAB> <TAB> if almost_equal ( self. intersection, other. intersection, self. accuracy ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return False <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> return self. product > other. product <TAB> <TAB> else : <TAB> <TAB> <TAB> return self. intersection > other. intersection <TAB> <TAB> else : <TAB> <TAB> if almost_equal ( self. intersection, other, self. accuracy ) : <TAB> <TAB> <TAB> return False <TAB> <TAB> else : <TAB> <TAB> <TAB> return self. intersection > other",False,"almost_equal(self.product, other.product, self.accuracy)",self.product is not None and other.product is not None,0.651659369468689
|
||
|
1507,"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<mask> : <TAB> <TAB> <TAB> break <TAB> <TAB> if fid == 1 : <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. STRING : <TAB> <TAB> <TAB> <TAB> self. delegationToken = ( <TAB> <TAB> <TAB> <TAB> <TAB> iprot. readString ( ). decode ( ""utf-8"" ) <TAB> <TAB> <TAB> <TAB> <TAB> if sys. version_info [ 0 ] == 2 <TAB> <TAB> <TAB> <TAB> <TAB> else iprot. readString ( ) <TAB> <TAB> <TAB> <TAB> ) <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.STOP,fid == 0,0.6614224910736084
|
||
|
1508,"def short_repr ( obj ) : <TAB> if isinstance ( <TAB> <TAB> obj, <TAB> <TAB> ( type, types. ModuleType, types. BuiltinMethodType, types. BuiltinFunctionType ), <TAB> ) : <TAB> <TAB> return obj. __name__ <TAB> if isinstance ( obj, types. MethodType ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return obj. im_func. __name__ + "" (bound)"" <TAB> <TAB> else : <TAB> <TAB> <TAB> return obj. im_func. __name__ <TAB> if isinstance ( obj, ( tuple, list, dict, set ) ) : <TAB> <TAB> return ""%d items"" % len ( obj ) <TAB> if isinstance ( obj, weakref. ref ) : <TAB> <TAB> return ""all_weakrefs_are_one"" <TAB> return repr ( obj ) [ : 40 ]",False,obj.im_self is not None,"isinstance(obj, types.ParameterType)",0.6586785316467285
|
||
|
1509,"def validate_domain ( domain : Optional [ str ] ) -> None : <TAB> if domain is None or len ( domain ) == 0 : <TAB> <TAB> raise ValidationError ( _ ( ""Domain can't be empty."" ) ) <TAB> if ""."" not in domain : <TAB> <TAB> raise ValidationError ( _ ( ""Domain must have at least one dot (.)"" ) ) <TAB> if len ( domain ) > 255 : <TAB> <TAB> raise ValidationError ( _ ( ""Domain is too long"" ) ) <TAB> if domain [ 0 ] == ""."" or domain [ - 1 ] == ""."" : <TAB> <TAB> raise ValidationError ( _ ( ""Domain cannot start or end with a dot (.)"" ) ) <TAB> for subdomain in domain. split ( ""."" ) : <TAB> <TAB> if not subdomain : <TAB> <TAB> <TAB> raise ValidationError ( _ ( ""Consecutive '.' are not allowed."" ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValidationError ( _ ( ""Subdomains cannot start or end with a '-'."" ) ) <TAB> <TAB> if not re. match ( ""^[a-z0-9-]*$"", subdomain ) : <TAB> <TAB> <TAB> raise ValidationError ( <TAB> <TAB> <TAB> <TAB> _ ( ""Domain can only have letters, numbers, '.' and '-'s."" ) <TAB> <TAB> <TAB> )",False,subdomain[0] == '-' or subdomain[-1] == '-','-' in domain,0.6548717021942139
|
||
|
1510,"def _write_image ( <TAB> out, imgName, data, append, icon, catalog, functionCompatible, old_index ) : <TAB> out. write ( ""#"" + ""-"" * 70 + ""\n"" ) <TAB> if not append : <TAB> <TAB> out. write ( ""# This file was generated by %s\n#\n"" % sys. argv [ 0 ] ) <TAB> <TAB> out. write ( ""from wx.lib.embeddedimage import PyEmbeddedImage\n\n"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> out. write ( ""catalog = {}\n"" ) <TAB> <TAB> <TAB> out. write ( ""index = []\n\n"" ) <TAB> varName = _replace_non_alphanumeric_with_underscore ( imgName ) <TAB> out. write ( ""%s = PyEmbeddedImage(\n%s\n"" % ( varName, data ) ) <TAB> if<mask> : <TAB> <TAB> if imgName in old_index : <TAB> <TAB> <TAB> print ( ""Warning: %s already in catalog."" % imgName ) <TAB> <TAB> <TAB> print ( "" Only the last entry will be accessible.\n"" ) <TAB> <TAB> old_index. append ( imgName ) <TAB> <TAB> out. write ( ""index.append('%s')\n"" % imgName ) <TAB> <TAB> out. write ( ""catalog['%s'] = %s\n"" % ( imgName, varName ) ) <TAB> if functionCompatible : <TAB> <TAB> out. write ( ""get%sData = %s.GetData\n"" % ( varName, varName ) ) <TAB> <TAB> out. write ( ""get%sImage = %s.GetImage\n"" % ( varName, varName ) ) <TAB> <TAB> out. write ( ""get%sBitmap = %s.GetBitmap\n"" % ( varName, varName ) ) <TAB> <TAB> if icon : <TAB> <TAB> <TAB> out. write ( ""get%sIcon = %s.GetIcon\n"" % ( varName, varName ) ) <TAB> out. write ( ""\n"" )",True,catalog,catalog,0.7033922672271729
|
||
|
1511,"def __init__ ( self, data = None, ** params ) : <TAB> if isinstance ( data, Element ) : <TAB> <TAB> params = dict ( get_param_values ( data ), ** params ) <TAB> <TAB> if ""kdims"" not in params : <TAB> <TAB> <TAB> params [ ""kdims"" ] = data. kdims <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> params [ ""vdims"" ] = data. vdims <TAB> <TAB> data = data. mapping ( ) <TAB> super ( Collator, self ). __init__ ( data, ** params )",False,'vdims' not in params,"""vdims' not in params",0.6707237362861633
|
||
|
1512,"def tree ( self, media = None, media_id = None ) : <TAB> db = get_db ( ) <TAB> if media : <TAB> <TAB> result = media <TAB> elif media_id : <TAB> <TAB> result = db. get ( ""id"", media_id, with_doc = True ) <TAB> else : <TAB> <TAB> return None <TAB> <TAB> items = db. get_many ( ""media_children"", result [ ""_id"" ], with_doc = True ) <TAB> keys = [ ] <TAB> <TAB> for item in items : <TAB> <TAB> key = self. key ( item [ ""doc"" ] [ ""type"" ] ) + ""s"" <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> result [ key ] = { } <TAB> <TAB> elif type ( result [ key ] ) is not dict : <TAB> <TAB> <TAB> result [ key ] = { } <TAB> <TAB> if key not in keys : <TAB> <TAB> <TAB> keys. append ( key ) <TAB> <TAB> result [ key ] [ item [ ""_id"" ] ] = fireEvent ( ""library.tree"", item [ ""doc"" ], single = True ) <TAB> <TAB> for key in keys : <TAB> <TAB> result [ key ] = result [ key ]. values ( ) <TAB> <TAB> result [ ""releases"" ] = fireEvent ( ""release.for_media"", result [ ""_id"" ], single = True ) <TAB> return result",True,key not in result,key not in result,0.6674259305000305
|
||
|
1513,"def start ( self ) : <TAB> self. logger. debug ( ""Starting..."" ) <TAB> self. server = ThreadedTCPServer ( <TAB> <TAB> ( self. local_ip, int ( self. config [ ""port"" ] ) ), ThreadedTCPRequestHandler <TAB> ) <TAB> if self. config. get ( ""usessl"" ) == ""Yes"" : <TAB> <TAB> self. logger. debug ( ""Using SSL socket"" ) <TAB> <TAB> keyfile_path = ""listeners/ssl_utils/privkey.pem"" <TAB> <TAB> keyfile_path = ListenerBase. abs_config_path ( keyfile_path ) <TAB> <TAB> if keyfile_path is None : <TAB> <TAB> <TAB> self. logger. error ( ""Could not locate %s"", keyfile_path ) <TAB> <TAB> <TAB> sys. exit ( 1 ) <TAB> <TAB> certfile_path = ""listeners/ssl_utils/server.pem"" <TAB> <TAB> certfile_path = ListenerBase. abs_config_path ( certfile_path ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. logger. error ( ""Could not locate %s"", certfile_path ) <TAB> <TAB> <TAB> sys. exit ( 1 ) <TAB> <TAB> self. server. socket = ssl. wrap_socket ( <TAB> <TAB> <TAB> self. server. socket, <TAB> <TAB> <TAB> keyfile = ""privkey.pem"", <TAB> <TAB> <TAB> certfile = ""server.pem"", <TAB> <TAB> <TAB> server_side = True, <TAB> <TAB> <TAB> ciphers = ""RSA"", <TAB> <TAB> ) <TAB> self. server. logger = self. logger <TAB> self. server. config = self. config <TAB> self. server_thread = threading. Thread ( target = self. server. serve_forever ) <TAB> self. server_thread. daemon = True <TAB> self. server_thread. start ( )",True,certfile_path is None,certfile_path is None,0.653950035572052
|
||
|
1514,"def test_primitive_options_class_names ( es ) : <TAB> options1 = { ""mean"" : { ""include_entities"" : [ ""customers"" ] } } <TAB> options2 = { Mean : { ""include_entities"" : [ ""customers"" ] } } <TAB> bad_options = { <TAB> <TAB> ""mean"" : { ""include_entities"" : [ ""customers"" ] }, <TAB> <TAB> Mean : { ""ignore_entities"" : [ ""customers"" ] }, <TAB> } <TAB> conflicting_error_text = ""Multiple options found for primitive mean"" <TAB> primitives = [ [ ""mean"" ], [ Mean ] ] <TAB> options = [ options1, options2 ] <TAB> features = [ ] <TAB> for primitive in primitives : <TAB> <TAB> with pytest. raises ( KeyError, match = conflicting_error_text ) : <TAB> <TAB> <TAB> DeepFeatureSynthesis ( <TAB> <TAB> <TAB> <TAB> target_entity_id = ""cohorts"", <TAB> <TAB> <TAB> <TAB> entityset = es, <TAB> <TAB> <TAB> <TAB> agg_primitives = primitive, <TAB> <TAB> <TAB> <TAB> trans_primitives = [ ], <TAB> <TAB> <TAB> <TAB> primitive_options = bad_options, <TAB> <TAB> <TAB> ) <TAB> <TAB> for option in options : <TAB> <TAB> <TAB> dfs_obj = DeepFeatureSynthesis ( <TAB> <TAB> <TAB> <TAB> target_entity_id = ""cohorts"", <TAB> <TAB> <TAB> <TAB> entityset = es, <TAB> <TAB> <TAB> <TAB> agg_primitives = primitive, <TAB> <TAB> <TAB> <TAB> trans_primitives = [ ], <TAB> <TAB> <TAB> <TAB> primitive_options = option, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> features. append ( set ( dfs_obj. build_features ( ) ) ) <TAB> for f in features [ 0 ] : <TAB> <TAB>",False,"isinstance(f.primitive, Mean)",primitives,0.6532958745956421
|
||
|
1515,"def readAtAutoNodes ( self ) : <TAB> c = self. c <TAB> p = c. p <TAB> after = p. nodeAfterTree ( ) <TAB> found = False <TAB> while p and p!= after : <TAB> <TAB> if p. isAtAutoNode ( ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> g. warning ( ""ignoring"", p. h ) <TAB> <TAB> <TAB> <TAB> p. moveToThreadNext ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> fileName = p. atAutoNodeName ( ) <TAB> <TAB> <TAB> <TAB> c. atFileCommands. readOneAtAutoNode ( fileName, p ) <TAB> <TAB> <TAB> <TAB> found = True <TAB> <TAB> <TAB> <TAB> p. moveToNodeAfterTree ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> p. moveToThreadNext ( ) <TAB> if not g. unitTesting : <TAB> <TAB> message = ""finished"" if found else ""no @auto nodes in the selected tree"" <TAB> <TAB> g. blue ( message ) <TAB> c. redraw ( )",False,p.isAtIgnoreNode(),found,0.6575652360916138
|
||
|
1516,"def _LeaseMessageHandlerRequests ( self, lease_time, limit ) : <TAB> """"""Read and lease some outstanding message handler requests."""""" <TAB> leased_requests = [ ] <TAB> now = rdfvalue. RDFDatetime. Now ( ) <TAB> zero = rdfvalue. RDFDatetime. FromSecondsSinceEpoch ( 0 ) <TAB> expiration_time = now + lease_time <TAB> leases = self. message_handler_leases <TAB> for requests in self. message_handler_requests. values ( ) : <TAB> <TAB> for r in requests. values ( ) : <TAB> <TAB> <TAB> existing_lease = leases. get ( r. handler_name, { } ). get ( r. request_id, zero ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> leases. setdefault ( r. handler_name, { } ) [ r. request_id ] = expiration_time <TAB> <TAB> <TAB> <TAB> r. leased_until = expiration_time <TAB> <TAB> <TAB> <TAB> r. leased_by = utils. ProcessIdString ( ) <TAB> <TAB> <TAB> <TAB> leased_requests. append ( r ) <TAB> <TAB> <TAB> <TAB> if len ( leased_requests ) >= limit : <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> return leased_requests",False,existing_lease < now,existing_lease,0.6596664786338806
|
||
|
1517,"def inner ( collection = ""test"" ) : <TAB> if collection is None : <TAB> <TAB> return davical_args <TAB> assert collection. startswith ( ""test"" ) <TAB> for _ in range ( 4 ) : <TAB> <TAB> args = self. storage_class. create_collection ( <TAB> <TAB> <TAB> collection + str ( uuid. uuid4 ( ) ), ** davical_args <TAB> <TAB> ) <TAB> <TAB> s = self. storage_class ( ** args ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> request. addfinalizer ( lambda : s. session. request ( ""DELETE"", """" ) ) <TAB> <TAB> <TAB> return args <TAB> raise RuntimeError ( ""Failed to find free collection."" )",False,not list(s.list()),s.session is not None,0.6495428085327148
|
||
|
1518,"def determine_local_world_size ( nproc_per_node : str ) : <TAB> try : <TAB> <TAB> logging. info ( f""Using nproc_per_node={nproc_per_node}."" ) <TAB> <TAB> return int ( nproc_per_node ) <TAB> except ValueError : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> num_proc = os. cpu_count ( ) <TAB> <TAB> <TAB> device_type = ""cpu"" <TAB> <TAB> elif nproc_per_node == ""gpu"" : <TAB> <TAB> <TAB> if not torch. cuda. is_available ( ) : <TAB> <TAB> <TAB> <TAB> raise ValueError ( ""Cuda is not available."" ) <TAB> <TAB> <TAB> device_type = ""gpu"" <TAB> <TAB> <TAB> num_proc = torch. cuda. device_count ( ) <TAB> <TAB> elif nproc_per_node == ""auto"" : <TAB> <TAB> <TAB> if torch. cuda. is_available ( ) : <TAB> <TAB> <TAB> <TAB> num_proc = torch. cuda. device_count ( ) <TAB> <TAB> <TAB> <TAB> device_type = ""gpu"" <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> num_proc = os. cpu_count ( ) <TAB> <TAB> <TAB> <TAB> device_type = ""cpu"" <TAB> <TAB> else : <TAB> <TAB> <TAB> raise ValueError ( f""Unsupported nproc_per_node value: {nproc_per_node}"" ) <TAB> <TAB> log. info ( <TAB> <TAB> <TAB> f""Using nproc_per_node={nproc_per_node},"" <TAB> <TAB> <TAB> f"" seting to {num_proc} since the instance "" <TAB> <TAB> <TAB> f""has {os.cpu_count()} {device_type}"" <TAB> <TAB> ) <TAB> <TAB> return num_proc",False,nproc_per_node == 'cpu',nproc_per_node == 'auto',0.6565909385681152
|
||
|
1519,"def change_status ( self, enabled_accounts, status_message ) : <TAB> if not self. interface : <TAB> <TAB> try : <TAB> <TAB> <TAB> self. interface = Gio. DBusProxy. new_for_bus_sync ( <TAB> <TAB> <TAB> <TAB> Gio. BusType. SESSION, <TAB> <TAB> <TAB> <TAB> Gio. DBusProxyFlags. NONE, <TAB> <TAB> <TAB> <TAB> None, <TAB> <TAB> <TAB> <TAB> ""org.gajim.dbus"", <TAB> <TAB> <TAB> <TAB> ""/org/gajim/dbus/RemoteObject"", <TAB> <TAB> <TAB> <TAB> ""org.gajim.dbus.RemoteInterface"", <TAB> <TAB> <TAB> <TAB> None, <TAB> <TAB> <TAB> ) <TAB> <TAB> except GLib. Error : <TAB> <TAB> <TAB> self. interface = None <TAB> if self. interface : <TAB> <TAB> try : <TAB> <TAB> <TAB> for account in self. interface. list_accounts ( ) : <TAB> <TAB> <TAB> <TAB> status = self. interface. get_status ( ""(s)"", account ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> if status in self. statuses : <TAB> <TAB> <TAB> <TAB> <TAB> self. interface. change_status ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""(sss)"", status, status_message, account <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> except GLib. Error : <TAB> <TAB> <TAB> self. interface = None",False,enabled_accounts != [] and account not in enabled_accounts,enabled_accounts,0.65614253282547
|
||
|
1520,"def dot ( self, other, sparse = True ) : <TAB> other_shape = other. shape <TAB> try : <TAB> <TAB> other = naked ( other ) <TAB> except TypeError : <TAB> <TAB> return NotImplemented <TAB> if not sparse : <TAB> <TAB> a = self. toarray ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> other = other. toarray ( ). reshape ( other_shape ) <TAB> <TAB> x = a. dot ( other ) <TAB> else : <TAB> <TAB> if len ( other_shape ) == 1 : <TAB> <TAB> <TAB> x = self. spmatrix. dot ( other. T ) <TAB> <TAB> else : <TAB> <TAB> <TAB> x = self. spmatrix. dot ( other ) <TAB> if issparse ( x ) : <TAB> <TAB> if x. shape == ( 1, 1 ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return x. toarray ( ) [ 0, 0 ] <TAB> <TAB> shape = ( x. shape [ 1 ], ) <TAB> <TAB> return SparseNDArray ( x, shape = shape ) <TAB> return get_array_module ( x ). asarray ( x )",False,issparse(other),len(other_shape) == 2,0.6557013988494873
|
||
|
1521,"def test_statvfs_result_pickle ( self ) : <TAB> result = os. statvfs ( self. fname ) <TAB> for proto in range ( pickle. HIGHEST_PROTOCOL + 1 ) : <TAB> <TAB> p = pickle. dumps ( result, proto ) <TAB> <TAB> self. assertIn ( b""statvfs_result"", p ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. assertIn ( b""cos\nstatvfs_result\n"", p ) <TAB> <TAB> unpickled = pickle. loads ( p ) <TAB> <TAB> self. assertEqual ( result, unpickled )",False,proto < 4,b'cos' in p,0.6694612503051758
|
||
|
1522,"def __new__ ( mcs, name, bases, attrs, ** kw ) : <TAB> if name in ( ""Event"", ) : <TAB> <TAB> return super ( ). __new__ ( mcs, name, bases, attrs, ** kw ) <TAB> if not ( <TAB> <TAB> name. startswith ( ""Evt"" ) or name. startswith ( ""_Evt"" ) or name. startswith ( ""_Msg"" ) <TAB> ) : <TAB> <TAB> raise ValueError ( 'Event class names must begin with ""Evt (%s)""' % name ) <TAB> if ""__doc__"" not in attrs : <TAB> <TAB> raise ValueError ( ""Event classes must have a docstring"" ) <TAB> props = set ( ) <TAB> for base in bases : <TAB> <TAB> if hasattr ( base, ""_props"" ) : <TAB> <TAB> <TAB> props. update ( base. _props ) <TAB> newattrs = { ""_internal"" : False } <TAB> for k, v in attrs. items ( ) : <TAB> <TAB> if k [ 0 ] == ""_"" : <TAB> <TAB> <TAB> newattrs [ k ] = v <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""Event class %s duplicates property %s defined in superclass"" % ( mcs, k ) <TAB> <TAB> <TAB> ) <TAB> <TAB> props. add ( k ) <TAB> <TAB> newattrs [ k ] = docstr ( v ) <TAB> newattrs [ ""_props"" ] = props <TAB> newattrs [ ""_props_sorted"" ] = sorted ( props ) <TAB> if name [ 0 ] == ""_"" : <TAB> <TAB> newattrs [ ""_internal"" ] = True <TAB> <TAB> name = name [ 1 : ] <TAB> <TAB> newattrs [ ""event_name"" ] = _rprop ( name ) <TAB> return super ( ). __new__ ( mcs, name, bases, newattrs, ** kw )",False,k in props,newattrs.has_key(k),0.6743497252464294
|
||
|
1523,"def htmlify ( path, text ) : <TAB> fname = os. path. basename ( path ) <TAB> if any ( ( fnmatch. fnmatchcase ( fname, p ) for p in _patterns ) ) : <TAB> <TAB> <TAB> <TAB> sql = ""SELECT files.id FROM files WHERE path =? LIMIT 1"" <TAB> <TAB> row = _conn. execute ( sql, ( path, ) ). fetchone ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return ClangHtmlifier ( _tree, _conn, path, text, row [ 0 ] ) <TAB> return None",False,row,row[0],0.6894035935401917
|
||
|
1524,"def on_button_press ( self, target, event, user_data ) : <TAB> if event. button == 3 : <TAB> <TAB> <TAB> <TAB> if not event. get_state ( ) & Gdk. ModifierType. SHIFT_MASK : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return True <TAB> <TAB> menu = mk_terminal_context_menu ( <TAB> <TAB> <TAB> self. terminal, <TAB> <TAB> <TAB> self. get_window ( ), <TAB> <TAB> <TAB> self. get_settings ( ), <TAB> <TAB> <TAB> TerminalContextMenuCallbacks ( <TAB> <TAB> <TAB> <TAB> self. terminal, <TAB> <TAB> <TAB> <TAB> self. get_window ( ), <TAB> <TAB> <TAB> <TAB> self. get_settings ( ), <TAB> <TAB> <TAB> <TAB> self. get_root_box ( ). get_notebook ( ), <TAB> <TAB> <TAB> ), <TAB> <TAB> ) <TAB> <TAB> menu. connect ( ""hide"", MenuHideCallback ( self. get_window ( ) ). on_hide ) <TAB> <TAB> HidePrevention ( self. get_window ( ) ). prevent ( ) <TAB> <TAB> try : <TAB> <TAB> <TAB> menu. popup_at_pointer ( event ) <TAB> <TAB> except AttributeError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> menu. popup ( None, None, None, None, event. button, event. time ) <TAB> <TAB> self. terminal. grab_focus ( ) <TAB> <TAB> return True <TAB> self. terminal. grab_focus ( ) <TAB> return False",False,"Vte.Terminal.do_button_press_event(self.terminal, event)",self.terminal.get_context(),0.6471275091171265
|
||
|
1525,"def validate ( self, name, object ) : <TAB> if not isinstance ( object, dict ) : <TAB> <TAB> yield ""%s is not sourced properties (not a dict)"" % ( name, ) <TAB> <TAB> return <TAB> for k, v in iteritems ( object ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> yield ""%s property name %r is not unicode"" % ( name, k ) <TAB> <TAB> if not isinstance ( v, tuple ) or len ( v )!= 2 : <TAB> <TAB> <TAB> yield ""%s property value for '%s' is not a 2-tuple"" % ( name, k ) <TAB> <TAB> <TAB> return <TAB> <TAB> propval, propsrc = v <TAB> <TAB> if not isinstance ( propsrc, text_type ) : <TAB> <TAB> <TAB> yield ""%s[%s] source %r is not unicode"" % ( name, k, propsrc ) <TAB> <TAB> try : <TAB> <TAB> <TAB> json. loads ( bytes2NativeString ( propval ) ) <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> yield ""%s[%r] value is not JSON-able"" % ( name, k )",False,"not isinstance(k, text_type)","not isinstance(v, text_type)",0.6480089426040649
|
||
|
1526,"def query ( self, qtype, value ) : <TAB> url = ""https://whois.arin.net/rest/"" <TAB> if qtype == ""domain"" : <TAB> <TAB> url += ""pocs;domain=@"" + value <TAB> try : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> fname, lname = value. split ( "" "", 1 ) <TAB> <TAB> <TAB> if fname. endswith ( "","" ) : <TAB> <TAB> <TAB> <TAB> t = fname <TAB> <TAB> <TAB> <TAB> fname = lname <TAB> <TAB> <TAB> <TAB> lname = t <TAB> <TAB> <TAB> url += ""pocs;first="" + fname + "";last="" + lname <TAB> except Exception as e : <TAB> <TAB> self. sf. debug ( ""Couldn't process name: "" + value + "" ("" + str ( e ) + "")"" ) <TAB> <TAB> return None <TAB> if qtype == ""contact"" : <TAB> <TAB> url = value <TAB> res = self. fetchRir ( url ) <TAB> if res [ ""content"" ] is None : <TAB> <TAB> self. sf. debug ( ""No info found/available for "" + value + "" at ARIN."" ) <TAB> <TAB> return None <TAB> try : <TAB> <TAB> j = json. loads ( res [ ""content"" ] ) <TAB> <TAB> return j <TAB> except Exception as e : <TAB> <TAB> self. sf. debug ( f""Error processing JSON response: {e}"" ) <TAB> <TAB> return None",False,qtype == 'name',qtype == 'string',0.6622380018234253
|
||
|
1527,"def _parse_display ( display ) : <TAB> """"""Parse an X11 display value"""""" <TAB> try : <TAB> <TAB> host, dpynum = display. rsplit ( "":"", 1 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> host = host [ 1 : - 1 ] <TAB> <TAB> idx = dpynum. find ( ""."" ) <TAB> <TAB> if idx >= 0 : <TAB> <TAB> <TAB> screen = int ( dpynum [ idx + 1 : ] ) <TAB> <TAB> <TAB> dpynum = dpynum [ : idx ] <TAB> <TAB> else : <TAB> <TAB> <TAB> screen = 0 <TAB> except ( ValueError, UnicodeEncodeError ) : <TAB> <TAB> raise ValueError ( ""Invalid X11 display"" ) from None <TAB> return host, dpynum, screen",False,host.startswith('[') and host.endswith(']'),host.startswith('.'),0.6479363441467285
|
||
|
1528,"def __init__ ( self, selectable, name = None ) : <TAB> baseselectable = selectable <TAB> while isinstance ( baseselectable, Alias ) : <TAB> <TAB> baseselectable = baseselectable. element <TAB> self. original = baseselectable <TAB> self. supports_execution = baseselectable. supports_execution <TAB> if self. supports_execution : <TAB> <TAB> self. _execution_options = baseselectable. _execution_options <TAB> self. element = selectable <TAB> if name is None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> name = getattr ( self. original, ""name"", None ) <TAB> <TAB> name = _anonymous_label ( ""%%(%d %s)s"" % ( id ( self ), name or ""anon"" ) ) <TAB> self. name = name",False,self.original.named_with_column,self.original.name is not None,0.650634229183197
|
||
|
1529,"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 ftype == TType. STRUCT : <TAB> <TAB> <TAB> <TAB> self. success = SyncChunk ( ) <TAB> <TAB> <TAB> <TAB> self. success. read ( iprot ) <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. userException = evernote. edam. error. ttypes. EDAMUserException ( ) <TAB> <TAB> <TAB> <TAB> self. userException. read ( iprot ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> if ftype == TType. STRUCT : <TAB> <TAB> <TAB> <TAB> self. systemException = evernote. edam. error. ttypes. EDAMSystemException ( ) <TAB> <TAB> <TAB> <TAB> self. systemException. read ( iprot ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB",True,fid == 2,fid == 2,0.6801624298095703
|
||
|
1530,"def all_reduce_params ( params ) : <TAB> buffer = self. buffer <TAB> nonzero_buffer = False <TAB> if len ( params ) > 1 : <TAB> <TAB> offset = 0 <TAB> <TAB> for p in params : <TAB> <TAB> <TAB> sz = p. numel ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> buffer [ offset : offset + sz ]. copy_ ( p. grad. data. view ( - 1 ) ) <TAB> <TAB> <TAB> <TAB> nonzero_buffer = True <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> buffer [ offset : offset + sz ]. zero_ ( ) <TAB> <TAB> <TAB> offset += sz <TAB> else : <TAB> <TAB> <TAB> <TAB> p = params [ 0 ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> buffer = p. grad. data <TAB> <TAB> <TAB> nonzero_buffer = True <TAB> <TAB> elif p. numel ( ) <= self. buffer. numel ( ) : <TAB> <TAB> <TAB> buffer = buffer [ : p. numel ( ) ] <TAB> <TAB> <TAB> buffer. zero_ ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> buffer = torch. zeros_like ( p ) <TAB> if nonzero_buffer : <TAB> <TAB> buffer. div_ ( self. world_size ) <TAB> distributed_utils. all_reduce ( buffer, self. process_group ) <TAB> <TAB> offset = 0 <TAB> for p in params : <TAB> <TAB> sz = p. numel ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> p. grad. data. copy_ ( buffer [ offset : offset + sz ]. view_as ( p ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> p. grad = buffer [ offset : offset + sz ]. view_as ( p ). clone ( ) <TAB> <TAB> offset += sz",True,p.grad is not None,p.grad is not None,0.6614325642585754
|
||
|
1531,"def decode_pickle ( <TAB> sample, mode, seg_num, seglen, short_size, target_size, img_mean, img_std ) : <TAB> pickle_path = sample [ 0 ] <TAB> try : <TAB> <TAB> if python_ver < ( 3, 0 ) : <TAB> <TAB> <TAB> data_loaded = pickle. load ( open ( pickle_path, ""rb"" ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> data_loaded = pickle. load ( open ( pickle_path, ""rb"" ), encoding = ""bytes"" ) <TAB> <TAB> vid, label, frames = data_loaded <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> logger. error ( <TAB> <TAB> <TAB> <TAB> ""{} frame length {} less than 1."". format ( pickle_path, len ( frames ) ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> return None, None <TAB> except : <TAB> <TAB> logger. info ( ""Error when loading {}"". format ( pickle_path ) ) <TAB> <TAB> return None, None <TAB> if mode == ""train"" or mode == ""valid"" or mode == ""test"" : <TAB> <TAB> ret_label = label <TAB> elif mode == ""infer"" : <TAB> <TAB> ret_label = vid <TAB> imgs = video_loader ( frames, seg_num, seglen, mode ) <TAB> return ( <TAB> <TAB> imgs_transform ( <TAB> <TAB> <TAB> imgs, mode, seg_num, seglen, short_size, target_size, img_mean, img_std <TAB> <TAB> ), <TAB> <TAB> ret_label, <TAB> )",False,len(frames) < 1,len(frames) > 1,0.6532013416290283
|
||
|
1532,"def fromutc ( self, dt ) : <TAB> ""datetime in UTC -> datetime in local time."" <TAB> if not isinstance ( dt, datetime ) : <TAB> <TAB> raise TypeError ( ""fromutc() requires a datetime argument"" ) <TAB> if dt. tzinfo is not self : <TAB> <TAB> raise ValueError ( ""dt.tzinfo is not self"" ) <TAB> dtoff = dt. utcoffset ( ) <TAB> if dtoff is None : <TAB> <TAB> raise ValueError ( ""fromutc() requires a non-None utcoffset() "" ""result"" ) <TAB> <TAB> <TAB> dtdst = dt. dst ( ) <TAB> if<mask> : <TAB> <TAB> raise ValueError ( ""fromutc() requires a non-None dst() result"" ) <TAB> delta = dtoff - dtdst <TAB> if delta : <TAB> <TAB> dt += delta <TAB> <TAB> dtdst = dt. dst ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""fromutc(): dt.dst gave inconsistent "" ""results; cannot convert"" <TAB> <TAB> <TAB> ) <TAB> if dtdst : <TAB> <TAB> return dt + dtdst <TAB> else : <TAB> <TAB> return dt",True,dtdst is None,dtdst is None,0.6813958883285522
|
||
|
1533,"def _matches_metadata ( <TAB> *, <TAB> pattern : filters. MetaFilter, <TAB> content : Mapping [ str, str ], <TAB> kwargs : MutableMapping [ str, Any ], <TAB> cause : causation. ResourceCause, ) -> bool : <TAB> for key, value in pattern. items ( ) : <TAB> <TAB> if value is filters. MetaFilterToken. ABSENT and key not in content : <TAB> <TAB> <TAB> continue <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> elif value is None and key in content : <TAB> <TAB> <TAB> continue <TAB> <TAB> elif callable ( value ) : <TAB> <TAB> <TAB> if not kwargs : <TAB> <TAB> <TAB> <TAB> kwargs. update ( invocation. build_kwargs ( cause = cause ) ) <TAB> <TAB> <TAB> if value ( content. get ( key, None ), ** kwargs ) : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> return False <TAB> <TAB> elif key not in content : <TAB> <TAB> <TAB> return False <TAB> <TAB> elif value!= content [ key ] : <TAB> <TAB> <TAB> return False <TAB> <TAB> else : <TAB> <TAB> <TAB> continue <TAB> return True",False,value is filters.MetaFilterToken.PRESENT and key in content,"isinstance(content, str)",0.6558524370193481
|
||
|
1534,"def __str__ ( self ) : <TAB> t = "" "" <TAB> if self. _name!= ""root"" : <TAB> <TAB> r = f""{t * (self._level-1)}{self._name}:\n"" <TAB> else : <TAB> <TAB> r = """" <TAB> level = self. _level <TAB> for i, ( k, v ) in enumerate ( self. _pointer. items ( ) ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> r += f""{t * (self._level)}{v}\n"" <TAB> <TAB> <TAB> self. _level += 1 <TAB> <TAB> else : <TAB> <TAB> <TAB> r += f""{t * (self._level)}{k}: {v} ({type(v).__name__})\n"" <TAB> <TAB> self. _level = level <TAB> return r [ : - 1 ]",False,"isinstance(v, Config)",i % 2,0.6512355208396912
|
||
|
1535,"def _add_communication_type ( apps, schema_editor, communication_type ) : <TAB> Worker = apps. get_model ( ""orchestra"", ""Worker"" ) <TAB> CommunicationPreference = apps. get_model ( ""orchestra"", ""CommunicationPreference"" ) <TAB> for worker in Worker. objects. all ( ) : <TAB> <TAB> ( <TAB> <TAB> <TAB> communication_preference, <TAB> <TAB> <TAB> created, <TAB> <TAB> ) = CommunicationPreference. objects. get_or_create ( <TAB> <TAB> <TAB> worker = worker, communication_type = communication_type <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> communication_preference. methods. slack = True <TAB> <TAB> <TAB> communication_preference. methods. email = True <TAB> <TAB> communication_preference. save ( )",False,created,communication_type,0.6908230781555176
|
||
|
1536,"def _graph_info ( nn_layers ) : <TAB> <TAB> blob_dst = dict ( ) <TAB> <TAB> blob_src = dict ( ) <TAB> for i, layer in enumerate ( nn_layers ) : <TAB> <TAB> for inp in layer. input : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> blob_dst [ inp ]. append ( i ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> blob_dst [ inp ] = [ i ] <TAB> <TAB> for out in layer. output : <TAB> <TAB> <TAB> if out in blob_src : <TAB> <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Blob %s has been generated by more than 1 layers"" % ( out ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> blob_src [ out ] = i <TAB> return blob_dst, blob_src",True,inp in blob_dst,inp in blob_dst,0.6704934239387512
|
||
|
1537,"def server_udp_post_decrypt ( self, buf ) : <TAB> uid = buf [ - 8 : - 4 ] <TAB> if uid in self. server_info. users : <TAB> <TAB> user_key = self. hashfunc ( self. server_info. users [ uid ] ). digest ( ) <TAB> else : <TAB> <TAB> uid = None <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> user_key = self. server_info. key <TAB> <TAB> else : <TAB> <TAB> <TAB> user_key = self. server_info. recv_iv <TAB> if hmac. new ( user_key, buf [ : - 4 ], self. hashfunc ). digest ( ) [ : 4 ]!= buf [ - 4 : ] : <TAB> <TAB> return ( b"""", None ) <TAB> return ( buf [ : - 8 ], uid )",False,not self.server_info.users,self.server_info.key,0.6496450901031494
|
||
|
1538,"def get_therapy_sessions_to_invoice ( patient, company ) : <TAB> therapy_sessions_to_invoice = [ ] <TAB> therapy_plans = frappe. db. get_all ( <TAB> <TAB> ""Therapy Plan"", { ""therapy_plan_template"" : ( ""!="", """" ) } <TAB> ) <TAB> therapy_plans_created_from_template = [ ] <TAB> for entry in therapy_plans : <TAB> <TAB> therapy_plans_created_from_template. append ( entry. name ) <TAB> therapy_sessions = frappe. get_list ( <TAB> <TAB> ""Therapy Session"", <TAB> <TAB> fields = ""*"", <TAB> <TAB> filters = { <TAB> <TAB> <TAB> ""patient"" : patient. name, <TAB> <TAB> <TAB> ""invoiced"" : 0, <TAB> <TAB> <TAB> ""company"" : company, <TAB> <TAB> <TAB> ""therapy_plan"" : ( ""not in"", therapy_plans_created_from_template ), <TAB> <TAB> }, <TAB> ) <TAB> for therapy in therapy_sessions : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if therapy. therapy_type and frappe. db. get_value ( <TAB> <TAB> <TAB> <TAB> ""Therapy Type"", therapy. therapy_type, ""is_billable"" <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> therapy_sessions_to_invoice. append ( <TAB> <TAB> <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""reference_type"" : ""Therapy Session"", <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""reference_name"" : therapy. name,",False,not therapy.appointment,therapy.therapy_id and therapy.therapy_id,0.6551961898803711
|
||
|
1539,"def cb_import_data_from_elem ( self, elem ) : <TAB> alias = elem. get ( ""alias"" ) <TAB> symbol = elem. get ( ""symbol"" ) <TAB> module = elem. get ( ""module"" ) <TAB> if symbol : <TAB> <TAB> if symbol == ""*"" : <TAB> <TAB> <TAB> name = module <TAB> <TAB> <TAB> detail = ""use %s"" % module <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> name = module <TAB> <TAB> <TAB> detail = ""use %s qw(:<tag>)"" % module <TAB> <TAB> else : <TAB> <TAB> <TAB> name = ""::"". join ( [ module, symbol ] ) <TAB> <TAB> <TAB> detail = ""use %s qw(%s)"" % ( module, symbol ) <TAB> else : <TAB> <TAB> name = module <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> detail = ""require %s"" % module <TAB> return { ""name"" : name, ""detail"" : detail }",False,symbol == '**',alias == '__tag__',0.6705427169799805
|
||
|
1540,"def parseNode ( self, node ) : <TAB> for child in node. childNodes : <TAB> <TAB> if child. nodeType == ELEMENT_NODE : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> self. parseMenuname ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> child. childNodes [ 0 ]. nodeValue, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> child. getAttribute ( ""show_empty"" ) or ""false"", <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> child. getAttribute ( ""inline"" ) or ""false"", <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> child. getAttribute ( ""inline_limit"" ) or 4, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> child. getAttribute ( ""inline_header"" ) or ""true"", <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> child. getAttribute ( ""inline_alias"" ) or ""false"", <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> except IndexError : <TAB> <TAB> <TAB> <TAB> <TAB> raise ValidationError ( ""Menuname cannot be empty"", """" ) <TAB> <TAB> <TAB> elif child. tagName == ""Separator"" : <TAB> <TAB> <TAB> <TAB> self. parseSeparator ( ) <TAB> <TAB> <TAB> elif child. tagName == ""Filename"" : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> self. parseFilename ( child. childNodes [ 0 ]. nodeValue ) <TAB> <TAB> <TAB> <TAB> except IndexError : <TAB> <TAB> <TAB> <TAB> <TAB> raise ValidationError ( ""Filename cannot be empty"", """" ) <TAB> <TAB> <TAB> elif child. tagName == ""Merge"" : <TAB> <TAB> <TAB> <TAB> self. parseMerge ( child. getAttribute (",False,child.tagName == 'Menuname',child.nodeType == NODE_ELEMENT_NODE,0.6599260568618774
|
||
|
1541,"def _connect_job_io ( self, imported_job, job_attrs, _find_hda, _find_hdca, _find_dce ) : <TAB> for output_key in job_attrs [ ""output_datasets"" ] : <TAB> <TAB> output_hda = _find_hda ( output_key ) <TAB> <TAB> if output_hda : <TAB> <TAB> <TAB> if not self. dataset_state_serialized : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> output_hda. state = imported_job. state <TAB> <TAB> <TAB> imported_job. add_output_dataset ( output_hda. name, output_hda ) <TAB> if ""input_mapping"" in job_attrs : <TAB> <TAB> for input_name, input_key in job_attrs [ ""input_mapping"" ]. items ( ) : <TAB> <TAB> <TAB> input_hda = _find_hda ( input_key ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> imported_job. add_input_dataset ( input_name, input_hda )",True,input_hda,input_hda,0.6629029512405396
|
||
|
1542,"def _init ( self ) : <TAB> <TAB> <TAB> <TAB> <TAB> self. row_length = None <TAB> self. y_direction = False <TAB> good_x = [ ] <TAB> good_y = [ ] <TAB> for vert in self. bmesh. verts : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> for loop in vert. link_loops : <TAB> <TAB> <TAB> <TAB> other_vert = loop. edge. other_vert ( vert ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if other_vert. co. x > vert. co. x : <TAB> <TAB> <TAB> <TAB> <TAB> good_x. append ( loop ) <TAB> <TAB> <TAB> <TAB> if other_vert. co. y > vert. co. y : <TAB> <TAB> <TAB> <TAB> <TAB> good_y. append ( loop ) <TAB> if good_x : <TAB> <TAB> loop = good_x [ 0 ] <TAB> elif good_y : <TAB> <TAB> loop = good_y [ 0 ] <TAB> <TAB> self. y_direction = True <TAB> else : <TAB> <TAB> raise Exception ( ""Could not find a vertex to start from"" ) <TAB> vert = loop. vert <TAB> <TAB> self. current_loop = loop <TAB> self. current_vert = vert <TAB> self. start_loop = loop <TAB> self. start_vert = vert",False,len(vert.link_edges) == 2,"hasattr(vert, 'link_loops')",0.6582843661308289
|
||
|
1543,"def update ( self, * event ) : <TAB> <TAB> if event : <TAB> <TAB> self. _last_keypress = time. time ( ) <TAB> <TAB> self. grammar = grammar = self. grammarbox. get ( ""1.0"", ""end"" ) <TAB> <TAB> normalized_grammar = self. normalize_grammar ( grammar ) <TAB> if normalized_grammar == self. normalized_grammar : <TAB> <TAB> return <TAB> else : <TAB> <TAB> self. normalized_grammar = normalized_grammar <TAB> <TAB> <TAB> if self. _history_index < len ( self. _history ) - 1 : <TAB> <TAB> self. grammarlabel [ ""text"" ] = ""Grammar:"" <TAB> self. _syntax_highlight_grammar ( grammar ) <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> rules = [ <TAB> <TAB> <TAB> <TAB> RegexpChunkRule. parse ( line ) for line in normalized_grammar. split ( ""\n"" ) <TAB> <TAB> <TAB> ] <TAB> <TAB> else : <TAB> <TAB> <TAB> rules = [ ] <TAB> except ValueError as e : <TAB> <TAB> <TAB> <TAB> self. _grammarcheck ( grammar ) <TAB> <TAB> self. chunker = None <TAB> <TAB> return <TAB> self. chunker = RegexpChunkParser ( rules ) <TAB> self. grammarbox. tag_remove ( ""error"", ""1.0"", ""end"" ) <TAB> self. grammar_changed = time. time ( ) <TAB> <TAB> if self. _showing_trace : <TAB> <TAB> self. show_trace ( ) <TAB> else : <TAB> <TAB> self. _highlight_devset ( ) <TAB> <TAB> if not self. _eval_demon_running : <TAB> <TAB> self. _eval_demon ( )",False,normalized_grammar,self._grammar_in_grammar,0.6662144660949707
|
||
|
1544,"def detect_source_destination ( self, message : Message ) : <TAB> participants = self. simulator_config. participants <TAB> source = None if len ( participants ) < 2 else participants [ 0 ] <TAB> destination = self. simulator_config. broadcast_part <TAB> if message. participant : <TAB> <TAB> source = message. participant <TAB> <TAB> dst_address_label = next ( <TAB> <TAB> <TAB> ( <TAB> <TAB> <TAB> <TAB> lbl <TAB> <TAB> <TAB> <TAB> for lbl in message. message_type <TAB> <TAB> <TAB> <TAB> if lbl. field_type <TAB> <TAB> <TAB> <TAB> and lbl. field_type. function == FieldType. Function. DST_ADDRESS <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> None, <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> start, end = message. get_label_range ( dst_address_label, view = 1, decode = True ) <TAB> <TAB> <TAB> dst_address = message. decoded_hex_str [ start : end ] <TAB> <TAB> <TAB> dst = next ( ( p for p in participants if p. address_hex == dst_address ), None ) <TAB> <TAB> <TAB> if dst is not None and dst!= source : <TAB> <TAB> <TAB> <TAB> destination = dst <TAB> return source, destination",True,dst_address_label,dst_address_label,0.6548735499382019
|
||
|
1545,"def _get_orientation ( self ) : <TAB> if self. state : <TAB> <TAB> rotation = [ 0 ] * 9 <TAB> <TAB> inclination = [ 0 ] * 9 <TAB> <TAB> gravity = [ ] <TAB> <TAB> geomagnetic = [ ] <TAB> <TAB> gravity = self. listener_a. values <TAB> <TAB> geomagnetic = self. listener_m. values <TAB> <TAB> if gravity [ 0 ] is not None and geomagnetic [ 0 ] is not None : <TAB> <TAB> <TAB> ff_state = SensorManager. getRotationMatrix ( <TAB> <TAB> <TAB> <TAB> rotation, inclination, gravity, geomagnetic <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> values = [ 0, 0, 0 ] <TAB> <TAB> <TAB> <TAB> values = SensorManager. getOrientation ( rotation, values ) <TAB> <TAB> <TAB> return values",True,ff_state,ff_state,0.6766324043273926
|
||
|
1546,"def _get_links ( self, link_to_self ) : <TAB> links = { } <TAB> for service, link_name in self. links : <TAB> <TAB> for container in service. containers ( ) : <TAB> <TAB> <TAB> links [ link_name or service. name ] = container. name <TAB> <TAB> <TAB> links [ container. name ] = container. name <TAB> <TAB> <TAB> links [ container. name_without_project ] = container. name <TAB> if link_to_self : <TAB> <TAB> for container in self. containers ( ) : <TAB> <TAB> <TAB> links [ self. name ] = container. name <TAB> <TAB> <TAB> links [ container. name ] = container. name <TAB> <TAB> <TAB> links [ container. name_without_project ] = container. name <TAB> for external_link in self. options. get ( ""external_links"" ) or [ ] : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> link_name = external_link <TAB> <TAB> else : <TAB> <TAB> <TAB> external_link, link_name = external_link. split ( "":"" ) <TAB> <TAB> links [ link_name ] = external_link <TAB> return [ ( alias, container_name ) for ( container_name, alias ) in links. items ( ) ]",False,':' not in external_link,"isinstance(external_link, str)",0.655548095703125
|
||
|
1547,"def set_mypy_args ( self, mypy_args = None ) : <TAB> """"""Set MyPy arguments."""""" <TAB> if mypy_args is None : <TAB> <TAB> self. mypy_args = None <TAB> else : <TAB> <TAB> self. mypy_errs = [ ] <TAB> <TAB> self. mypy_args = list ( mypy_args ) <TAB> <TAB> if not any ( arg. startswith ( ""--python-version"" ) for arg in mypy_args ) : <TAB> <TAB> <TAB> self. mypy_args += [ <TAB> <TAB> <TAB> <TAB> ""--python-version"", <TAB> <TAB> <TAB> <TAB> ""."". join ( <TAB> <TAB> <TAB> <TAB> <TAB> str ( v ) <TAB> <TAB> <TAB> <TAB> <TAB> for v in get_target_info_len2 ( self. comp. target, mode = ""nearest"" ) <TAB> <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> ] <TAB> <TAB> if logger. verbose : <TAB> <TAB> <TAB> for arg in verbose_mypy_args : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> self. mypy_args. append ( arg ) <TAB> <TAB> logger. log ( ""MyPy args:"", self. mypy_args )",False,arg not in self.mypy_args,arg,0.6659483313560486
|
||
|
1548,"def __init__ ( self ) : <TAB> global pymongo <TAB> import pymongo <TAB> try : <TAB> <TAB> self. m = pymongo. MongoClient ( mongodb_host ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. m. admin. authenticate ( mongodb_user, mongodb_pwd ) <TAB> <TAB> self. db = self. m. admin <TAB> except Exception as e : <TAB> <TAB> raise Exception ( ""Cannot interface with MongoDB server: %s"" % e ) <TAB> self. name = ""mongodb queues"" <TAB> self. nick = ( ""ar"", ""aw"", ""qt"", ""qw"" ) <TAB> self. vars = ( ""ar"", ""aw"", ""qt"", ""qw"" ) <TAB> self. type = ""d"" <TAB> self. width = 5 <TAB> self. scale = 2 <TAB> self. lastVal = { }",False,mongodb_pwd,mongo_user,0.6775995492935181
|
||
|
1549,"def TryMerge ( self, d ) : <TAB> while d. avail ( ) > 0 : <TAB> <TAB> tt = d. getVarInt32 ( ) <TAB> <TAB> if tt == 10 : <TAB> <TAB> <TAB> self. set_content ( d. getPrefixedString ( ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if tt == 16 : <TAB> <TAB> <TAB> self. set_statuscode ( d. getVarInt32 ( ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if tt == 27 : <TAB> <TAB> <TAB> self. add_header ( ). TryMerge ( d ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. set_contentwastruncated ( d. getBoolean ( ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if tt == 56 : <TAB> <TAB> <TAB> self. set_externalbytessent ( d. getVarInt64 ( ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if tt == 64 : <TAB> <TAB> <TAB> self. set_externalbytesreceived ( d. getVarInt64 ( ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if tt == 74 : <TAB> <TAB> <TAB> self. set_finalurl ( d. getPrefixedString ( ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if tt == 80 : <TAB> <TAB> <TAB> self. set_apicpumilliseconds ( d. getVarInt64 ( ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if tt == 88 : <TAB> <TAB> <TAB> self. set_apibytessent ( d. getVarInt64 ( ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if tt == 96 : <TAB> <TAB> <TAB> self. set_apibytesreceived ( d. getVarInt64 ( ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if tt == 0 : <TAB>",False,tt == 48,tt == 32,0.6848076581954956
|
||
|
1550,"def _1_0_cloud_ips_cip_jsjc5_map ( self, method, url, body, headers ) : <TAB> if method == ""POST"" : <TAB> <TAB> body = json. loads ( body ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return self. test_response ( httplib. ACCEPTED, """" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> data = '{""error_name"":""bad destination"", ""errors"": [""Bad destination""]}' <TAB> <TAB> <TAB> return self. test_response ( httplib. BAD_REQUEST, data )",False,'destination' in body,body.find('<') > -1,0.6726816892623901
|
||
|
1551,"def execute ( self ) : <TAB> self. _cache_factory. get_write_cache ( ) <TAB> with self. invalidated ( self. context. targets ( ) ) as invalidation : <TAB> <TAB> for vt in invalidation. all_vts : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if self. get_options ( ). regular_file_in_results_dir : <TAB> <TAB> <TAB> <TAB> <TAB> regular_file_path = os. path. join ( vt. results_dir, DUMMY_FILE_NAME ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> with temporary_dir ( cleanup = False ) as tmpdir : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> regular_file_path = os. path. join ( tmpdir, DUMMY_FILE_NAME ) <TAB> <TAB> <TAB> <TAB> with safe_open ( regular_file_path, mode = ""wb"" ) as fp : <TAB> <TAB> <TAB> <TAB> <TAB> fp. write ( DUMMY_FILE_CONTENT ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> with temporary_dir ( ) as tmpdir : <TAB> <TAB> <TAB> <TAB> <TAB> regular_file_path = os. path. join ( tmpdir, DUMMY_FILE_NAME ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> symlink_y = os. path. join ( vt. results_dir, SYMLINK_NAME ) <TAB> <TAB> <TAB> os. symlink ( regular_file_path, symlink_y ) <TAB> <TAB> return invalidation. all_vts",False,self.get_options().regular_file,self.get_options().create_out_of_file,0.6490850448608398
|
||
|
1552,"def glyph_to_bzs ( g ) : <TAB> bzs = [ ] <TAB> for i in range ( g. numberOfContours ) : <TAB> <TAB> beg = 0 if i == 0 else g. endPtsOfContours [ i - 1 ] + 1 <TAB> <TAB> end = g. endPtsOfContours [ i ] + 1 <TAB> <TAB> n = end - beg <TAB> <TAB> pts = g. coordinates [ beg : end ] <TAB> <TAB> flags = g. flags [ beg : end ] <TAB> <TAB> bz = [ ] <TAB> <TAB> for j in range ( n ) : <TAB> <TAB> <TAB> x1, y1 = pts [ ( j + 1 ) % n ] <TAB> <TAB> <TAB> if flags [ j ] and flags [ ( j + 1 ) % n ] : <TAB> <TAB> <TAB> <TAB> bz. append ( ( pts [ j ], ( x1, y1 ) ) ) <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> if flags [ j - 1 ] : <TAB> <TAB> <TAB> <TAB> <TAB> x0, y0 = pts [ j - 1 ] <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> x0, y0 = lerppt ( 0.5, pts [ j - 1 ], pts [ j ] ) <TAB> <TAB> <TAB> <TAB> if not flags [ ( j + 1 ) % n ] : <TAB> <TAB> <TAB> <TAB> <TAB> x1, y1 = lerppt ( 0.5, ( x1, y1 ), pts [ j ] ) <TAB> <TAB> <TAB> <TAB> if pts [ j ] == ( x0, y0 ) or pts [ j ] == ( x1, y1 ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> bz. append ( ( ( x0, y0 ), ( x1, y1 ) ) ) <TAB> <TAB",False,not flags[j],j >= 0,0.6621302366256714
|
||
|
1553,"def test_reductions ( expr, rdd ) : <TAB> result = compute ( expr, rdd ) <TAB> expected = compute ( expr, data ) <TAB> if not result == expected : <TAB> <TAB> print ( result ) <TAB> <TAB> print ( expected ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> assert abs ( result - expected ) < 0.001 <TAB> <TAB> else : <TAB> <TAB> <TAB> assert result == expected",False,"isinstance(result, float)",result > expected,0.6520752906799316
|
||
|
1554,"def run_step ( self ) -> None : <TAB> to_delete = set ( self. watches ) <TAB> for path in _find_watchdog_paths ( self. extra_files, self. exclude_patterns ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> self. watches [ path ] = self. observer. schedule ( <TAB> <TAB> <TAB> <TAB> <TAB> self. event_handler, path, recursive = True <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> except OSError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. watches [ path ] = None <TAB> <TAB> to_delete. discard ( path ) <TAB> for path in to_delete : <TAB> <TAB> watch = self. watches. pop ( path, None ) <TAB> <TAB> if watch is not None : <TAB> <TAB> <TAB> self. observer. unschedule ( watch )",False,path not in self.watches,path in self.watchdog_list,0.6600096225738525
|
||
|
1555,"def launch_repl ( self, targets ) : <TAB> with temporary_dir ( ) as temp_dir : <TAB> <TAB> node_paths = self. context. products. get_data ( NodePaths ) <TAB> <TAB> package_json_path = os. path. join ( temp_dir, ""package.json"" ) <TAB> <TAB> package = { <TAB> <TAB> <TAB> ""name"" : self. SYNTHETIC_NODE_TARGET_NAME, <TAB> <TAB> <TAB> ""version"" : ""0.0.0"", <TAB> <TAB> <TAB> ""dependencies"" : { <TAB> <TAB> <TAB> <TAB> target. package_name : node_paths. node_path ( target ) <TAB> <TAB> <TAB> <TAB> if self. is_node_module ( target ) <TAB> <TAB> <TAB> <TAB> else target. version <TAB> <TAB> <TAB> <TAB> for target in targets <TAB> <TAB> <TAB> }, <TAB> <TAB> } <TAB> <TAB> with open ( package_json_path, ""w"" ) as fp : <TAB> <TAB> <TAB> json. dump ( package, fp, indent = 2 ) <TAB> <TAB> args = self. get_passthru_args ( ) <TAB> <TAB> node_repl = self. node_distribution. node_command ( <TAB> <TAB> <TAB> args = args, node_paths = node_paths. all_node_paths if node_paths else None <TAB> <TAB> ) <TAB> <TAB> with pushd ( temp_dir ) : <TAB> <TAB> <TAB> result, command = self. install_module ( <TAB> <TAB> <TAB> <TAB> package_manager = self. node_distribution. get_package_manager ( <TAB> <TAB> <TAB> <TAB> <TAB> package_manager = PACKAGE_MANAGER_NPM <TAB> <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> <TAB> workunit_name = self. SYNTHETIC_NODE_TARGET_NAME, <TAB> <TAB> <TAB",False,result != 0,self.node_distribution is not None,0.6751778721809387
|
||
|
1556,"def __init__ ( self ) : <TAB> component. Component. __init__ ( self, ""PreferencesManager"" ) <TAB> self. config = deluge. configmanager. ConfigManager ( ""core.conf"", DEFAULT_PREFS ) <TAB> if ""proxies"" in self. config : <TAB> <TAB> log. warning ( <TAB> <TAB> <TAB> 'Updating config file for proxy, using ""peer"" values to fill new ""proxy"" setting' <TAB> <TAB> ) <TAB> <TAB> self. config [ ""proxy"" ]. update ( self. config [ ""proxies"" ] [ ""peer"" ] ) <TAB> <TAB> log. warning ( ""New proxy config is: %s"", self. config [ ""proxy"" ] ) <TAB> <TAB> del self. config [ ""proxies"" ] <TAB> if ""i2p_proxy"" in self. config and self. config [ ""i2p_proxy"" ] [ ""hostname"" ] : <TAB> <TAB> self. config [ ""proxy"" ]. update ( self. config [ ""i2p_proxy"" ] ) <TAB> <TAB> self. config [ ""proxy"" ] [ ""type"" ] = 6 <TAB> <TAB> del self. config [ ""i2p_proxy"" ] <TAB> if ""anonymous_mode"" in self. config : <TAB> <TAB> self. config [ ""proxy"" ] [ ""anonymous_mode"" ] = self. config [ ""anonymous_mode"" ] <TAB> <TAB> del self. config [ ""anonymous_mode"" ] <TAB> if ""proxy"" in self. config : <TAB> <TAB> for key in DEFAULT_PREFS [ ""proxy"" ] : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. config [ ""proxy"" ] [ key ] = DEFAULT_PREFS [ ""proxy"" ] [ key ] <TAB> self. core = component. get ( ""Core"" ) <TAB> self. new_release_timer = None",False,key not in self.config['proxy'],key in self.config['proxy'],0.6520766019821167
|
||
|
1557,"def _send_event_data ( self, timeout_time = None, last_exception = None ) : <TAB> <TAB> if self. _unsent_events : <TAB> <TAB> self. _open ( ) <TAB> <TAB> self. _set_msg_timeout ( timeout_time, last_exception ) <TAB> <TAB> self. _handler. queue_message ( * self. _unsent_events ) <TAB> <TAB> self. _handler. wait ( ) <TAB> <TAB> self. _unsent_events = self. _handler. pending_messages <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if self. _outcome == constants. MessageSendResult. Timeout : <TAB> <TAB> <TAB> <TAB> self. _condition = OperationTimeoutError ( ""Send operation timed out"" ) <TAB> <TAB> <TAB> if self. _condition : <TAB> <TAB> <TAB> <TAB> raise self. _condition",False,self._outcome != constants.MessageSendResult.Ok,self._outcome == constants.MessageSendResult.OK,0.6533485651016235
|
||
|
1558,"def get_score ( string : str, query_chars : str ) -> float : <TAB> <TAB> best_score : float = float ( len ( string ) ) <TAB> head, tail = query_chars [ 0 ], query_chars [ 1 : ] <TAB> <TAB> for first_index in ( idx for idx, val in enumerate ( string ) if val == head ) : <TAB> <TAB> <TAB> <TAB> score, last_index = find_end_of_match ( string, tail, first_index ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> best_score = score <TAB> <TAB> <TAB> best_score = best_score * ( len ( string ) ** 0.5 ) <TAB> return best_score",False,last_index and score and (score < best_score),score != None,0.6526854634284973
|
||
|
1559,"def _set_rl_property_value ( self, obj, key, val, path = """" ) : <TAB> """"""Sets a property on obj to val, or to a sub-object within obj if key looks like ""foo.bar"" """""" <TAB> if key. find ( ""."" ) >= 0 : <TAB> <TAB> top_key, sub_keys = key_list = key. split ( ""."", 1 ) <TAB> <TAB> if top_key. startswith ( ""__"" ) : <TAB> <TAB> <TAB> raise ValueError ( ""Attempting to set unsafe property name %s"" % top_key ) <TAB> <TAB> if isinstance ( obj, dict ) : <TAB> <TAB> <TAB> sub_obj = obj [ top_key ] <TAB> <TAB> else : <TAB> <TAB> <TAB> sub_obj = obj. __dict__ [ top_key ] <TAB> <TAB> <TAB> <TAB> return self. _set_rl_property_value ( <TAB> <TAB> <TAB> sub_obj, sub_keys, val, ""%s.%s"" % ( path, top_key ) <TAB> <TAB> ) <TAB> else : <TAB> <TAB> key, val = self. _parse_type ( key, val ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( ""Attempting to set unsafe property name %s"" % key ) <TAB> <TAB> if isinstance ( obj, dict ) : <TAB> <TAB> <TAB> obj [ key ] = val <TAB> <TAB> else : <TAB> <TAB> <TAB> obj. __dict__ [ key ] = val",False,key.startswith('__'),val is None,0.6516975164413452
|
||
|
1560,"def search ( self, query ) : <TAB> results = [ ] <TAB> search = { ""q"" : query } <TAB> response = requests. session ( ). get ( self. _base_url + ""search"", params = search ) <TAB> content = parse ( response. content, namespaceHTMLElements = False ) <TAB> for result in content. findall ( "".//*[@class='package-snippet']"" ) : <TAB> <TAB> name = result. find ( ""h3/*[@class='package-snippet__name']"" ). text <TAB> <TAB> version = result. find ( ""h3/*[@class='package-snippet__version']"" ). text <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> description = result. find ( ""p[@class='package-snippet__description']"" ). text <TAB> <TAB> if not description : <TAB> <TAB> <TAB> description = """" <TAB> <TAB> try : <TAB> <TAB> <TAB> result = Package ( name, version, description ) <TAB> <TAB> <TAB> result. description = to_str ( description. strip ( ) ) <TAB> <TAB> <TAB> results. append ( result ) <TAB> <TAB> except ParseVersionError : <TAB> <TAB> <TAB> self. _log ( <TAB> <TAB> <TAB> <TAB> 'Unable to parse version ""{}"" for the {} package, skipping'. format ( <TAB> <TAB> <TAB> <TAB> <TAB> version, name <TAB> <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> <TAB> level = ""debug"", <TAB> <TAB> <TAB> ) <TAB> return results",False,not name or not version,version is None,0.65926593542099
|
||
|
1561,"def startElement ( self, name, attrs ) : <TAB> if name == ""regexp"" : <TAB> <TAB> self. _regexp = sanitizeStr ( attrs. get ( ""value"" ) ) <TAB> <TAB> _ = re. match ( <TAB> <TAB> <TAB> r""\A[A-Za-z0-9]+"", self. _regexp <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _match = re. search ( self. _regexp, self. _banner, re. I | re. M ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. _match = None <TAB> if name == ""info"" and self. _match : <TAB> <TAB> self. _feedInfo ( ""type"", attrs. get ( ""type"" ) ) <TAB> <TAB> self. _feedInfo ( ""distrib"", attrs. get ( ""distrib"" ) ) <TAB> <TAB> self. _feedInfo ( ""release"", attrs. get ( ""release"" ) ) <TAB> <TAB> self. _feedInfo ( ""codename"", attrs. get ( ""codename"" ) ) <TAB> <TAB> self. _dbmsVersion = sanitizeStr ( attrs. get ( ""dbms_version"" ) ) <TAB> <TAB> self. _techVersion = sanitizeStr ( attrs. get ( ""tech_version"" ) ) <TAB> <TAB> self. _sp = sanitizeStr ( attrs. get ( ""sp"" ) ) <TAB> <TAB> if self. _dbmsVersion and self. _dbmsVersion. isdigit ( ) : <TAB> <TAB> <TAB> self. _feedInfo ( ""dbmsVersion"", self. _match. group ( int ( self. _dbmsVersion ) ) ) <TAB> <TAB> if self. _techVersion and self. _techVersion. isdigit ( ) : <TAB> <TAB> <TAB> self. _feedInfo ( <TAB> <TAB> <TAB> <TAB> ""technology"", <TAB> <TAB> <TAB> <TAB> ""%s %s"" <TAB> <TAB> <TAB> <TAB> % ( attrs. get ( """,False,_ and self._banner and (_.group(0).lower() in self._banner.lower()) or not _,self._banner,0.65169358253479
|
||
|
1562,def _to_pbs ( self ) : <TAB> pbs = [ ] <TAB> if self. _start : <TAB> <TAB> if self. _start_incl : <TAB> <TAB> <TAB> op = datastore_pb. Query_Filter. GREATER_THAN_OR_EQUAL <TAB> <TAB> else : <TAB> <TAB> <TAB> op = datastore_pb. Query_Filter. GREATER_THAN <TAB> <TAB> pb = datastore_pb. Query_Filter ( ) <TAB> <TAB> pb. set_op ( op ) <TAB> <TAB> pb. add_property ( ). CopyFrom ( self. _start ) <TAB> <TAB> pbs. append ( pb ) <TAB> if self. _end : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> op = datastore_pb. Query_Filter. LESS_THAN_OR_EQUAL <TAB> <TAB> else : <TAB> <TAB> <TAB> op = datastore_pb. Query_Filter. LESS_THAN <TAB> <TAB> pb = datastore_pb. Query_Filter ( ) <TAB> <TAB> pb. set_op ( op ) <TAB> <TAB> pb. add_property ( ). CopyFrom ( self. _end ) <TAB> <TAB> pbs. append ( pb ) <TAB> return pbs,False,self._end_incl,self._start_incl,0.6690181493759155
|
||
|
1563,"def _get_matched_layout ( command ) : <TAB> <TAB> <TAB> cmd = command. script. split ( "" "" ) <TAB> for source_layout in source_layouts : <TAB> <TAB> is_all_match = True <TAB> <TAB> for cmd_part in cmd : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> is_all_match = False <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> if is_all_match : <TAB> <TAB> <TAB> return source_layout",False,not all([ch in source_layout or ch in '-_' for ch in cmd_part]),cmd_part.find(' ') >= 0,0.6501979827880859
|
||
|
1564,"def process_bind_param ( self, value, dialect ) : <TAB> """"""Encrypt a value on the way in."""""" <TAB> if value is not None : <TAB> <TAB> self. _update_key ( ) <TAB> <TAB> try : <TAB> <TAB> <TAB> value = self. underlying_type. process_bind_param ( value, dialect ) <TAB> <TAB> except AttributeError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> type_ = self. underlying_type. python_type <TAB> <TAB> <TAB> if issubclass ( type_, bool ) : <TAB> <TAB> <TAB> <TAB> value = ""true"" if value else ""false"" <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> value = value. isoformat ( ) <TAB> <TAB> <TAB> elif issubclass ( type_, JSONType ) : <TAB> <TAB> <TAB> <TAB> value = six. text_type ( json. dumps ( value ) ) <TAB> <TAB> return self. engine. encrypt ( value )",False,"issubclass(type_, (datetime.date, datetime.time))","issubclass(type_, datetime)",0.6534264087677002
|
||
|
1565,"def link_pantsrefs ( soups, precomputed ) : <TAB> """"""Transorm soups: <a pantsref=""foo""> becomes <a href=""../foo_page.html#foo"">"""""" <TAB> for ( page, soup ) in soups. items ( ) : <TAB> <TAB> for a in soup. find_all ( ""a"" ) : <TAB> <TAB> <TAB> if not a. has_attr ( ""pantsref"" ) : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> pantsref = a [ ""pantsref"" ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise TaskError ( <TAB> <TAB> <TAB> <TAB> <TAB> f'Page {page} has pantsref ""{pantsref}"" and I cannot find pantsmark for it' <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> a [ ""href"" ] = rel_href ( page, precomputed. pantsref [ pantsref ] )",False,pantsref not in precomputed.pantsref,pantsref in precomputed.pantsref,0.6592947244644165
|
||
|
1566,"def html_before_write ( self, book, chapter ) : <TAB> from lxml import etree, html <TAB> from pygments import highlight <TAB> from pygments. formatters import HtmlFormatter <TAB> from ebooklib import epub <TAB> try : <TAB> <TAB> tree = parse_html_string ( chapter. content ) <TAB> except : <TAB> <TAB> return <TAB> root = tree. getroottree ( ) <TAB> had_source = False <TAB> if len ( root. find ( ""body"" ) )!= 0 : <TAB> <TAB> body = tree. find ( ""body"" ) <TAB> <TAB> <TAB> <TAB> for source in body. xpath ( '//pre[contains(@class,""source-"")]' ) : <TAB> <TAB> <TAB> css_class = source. get ( ""class"" ) <TAB> <TAB> <TAB> source_text = ( source. text or """" ) + """". join ( <TAB> <TAB> <TAB> <TAB> [ html. tostring ( child ) for child in source. iterchildren ( ) ] <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if ""source-python"" in css_class : <TAB> <TAB> <TAB> <TAB> from pygments. lexers import PythonLexer <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> _text = highlight ( source_text, PythonLexer ( ), HtmlFormatter ( ) ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> from pygments. lexers import CssLexer <TAB> <TAB> <TAB> <TAB> _text = highlight ( source_text, CssLexer ( ), HtmlFormatter ( ) ) <TAB> <TAB> <TAB> _parent = source. getparent ( ) <TAB> <TAB> <TAB> _parent. replace ( source, etree. XML ( _text ) ) <TAB> <TAB> <TAB> had_source = True <TAB> if had_source : <TAB> <TAB> chapter. add_link ( href = ""style/code.css"", rel = ""stylesheet"", type = ""text/css""",False,'source-css' in css_class,'css-lexer' in css_class,0.652148962020874
|
||
|
1567,"def command ( self ) : <TAB> session_id = self. session. ui. html_variables. get ( ""http_session"" ) <TAB> if self. data. get ( ""_method"", """" ) == ""POST"" : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> with GLOBAL_LOGIN_LOCK : <TAB> <TAB> <TAB> <TAB> return self. _do_login ( <TAB> <TAB> <TAB> <TAB> <TAB> self. data. get ( ""user"", [ None ] ) [ 0 ], <TAB> <TAB> <TAB> <TAB> <TAB> self. data [ ""pass"" ] [ 0 ], <TAB> <TAB> <TAB> <TAB> <TAB> redirect = True, <TAB> <TAB> <TAB> <TAB> ) <TAB> elif not self. data : <TAB> <TAB> password = self. session. ui. get_password ( _ ( ""Your password: "" ) ) <TAB> <TAB> return self. _do_login ( None, password, load_index = True ) <TAB> elif ( <TAB> <TAB> session_id in SESSION_CACHE <TAB> <TAB> and SESSION_CACHE [ session_id ]. auth <TAB> <TAB> and ""_method"" in self. data <TAB> ) : <TAB> <TAB> self. _do_redirect ( ) <TAB> return self. _success ( _ ( ""Please log in"" ) )",False,'pass' in self.data,self.data,0.6540184020996094
|
||
|
1568,"def generate_sitemaps ( filename ) : <TAB> rows = ( line. strip ( ). split ( ""\t"" ) for line in open ( filename ) ) <TAB> for sortkey, chunk in itertools. groupby ( rows, lambda row : row [ 0 ] ) : <TAB> <TAB> things = [ ] <TAB> <TAB> _chunk = list ( chunk ) <TAB> <TAB> for segment in _chunk : <TAB> <TAB> <TAB> sortkey = segment. pop ( 0 ) <TAB> <TAB> <TAB> last_modified = segment. pop ( - 1 ) <TAB> <TAB> <TAB> path = """". join ( segment ) <TAB> <TAB> <TAB> things. append ( web. storage ( path = path, last_modified = last_modified ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> write ( ""sitemaps/sitemap_%s.xml.gz"" % sortkey, sitemap ( things ) )",True,things,things,0.6706187725067139
|
||
|
1569,"def TryMerge ( self, d ) : <TAB> while d. avail ( ) > 0 : <TAB> <TAB> tt = d. getVarInt32 ( ) <TAB> <TAB> if tt == 10 : <TAB> <TAB> <TAB> self. set_query_kind ( d. getPrefixedString ( ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if tt == 18 : <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_query_ancestor ( ). TryMerge ( tmp ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if tt == 25 : <TAB> <TAB> <TAB> self. set_query_thiscursor ( d. get64 ( ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. set_query_nextcursor ( d. get64 ( ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if tt == 40 : <TAB> <TAB> <TAB> self. add_get_successful_fetch ( d. getBoolean ( ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if tt == 50 : <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. add_keys_read ( ). TryMerge ( tmp ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if tt == 58 : <TAB> <TAB> <TAB> length = d. getVarInt32 ( ) <TAB> <TAB> <TAB> tmp = ProtocolBuffer. Decoder ( d. buffer ( ), d. pos ( ), d. pos ( ) + length",False,tt == 33,tt == 33554432,0.6741406917572021
|
||
|
1570,"def _add_middleware ( self, conf, app ) : <TAB> errorware = conf [ ""tg.errorware"" ] <TAB> if errorware. get ( ""enable"", True ) and not asbool ( conf. get ( ""debug"" ) ) : <TAB> <TAB> reporters = [ ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> from backlash. tracing. reporters. mail import EmailReporter <TAB> <TAB> <TAB> reporters. append ( EmailReporter ( ** errorware ) ) <TAB> <TAB> if errorware. get ( ""sentry_dsn"" ) : <TAB> <TAB> <TAB> from backlash. tracing. reporters. sentry import SentryReporter <TAB> <TAB> <TAB> reporters. append ( SentryReporter ( ** errorware ) ) <TAB> <TAB> if errorware. get ( ""reporters"", [ ] ) : <TAB> <TAB> <TAB> for reporter in errorware [ ""reporters"" ] : <TAB> <TAB> <TAB> <TAB> reporters. append ( reporter ) <TAB> <TAB> try : <TAB> <TAB> <TAB> import backlash <TAB> <TAB> except ImportError : <TAB> <TAB> <TAB> log. warning ( ""backlash not installed, email tracebacks won't be available"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return backlash. TraceErrorsMiddleware ( <TAB> <TAB> <TAB> <TAB> app, reporters, context_injectors = [ _turbogears_backlash_context ] <TAB> <TAB> <TAB> ) <TAB> return app",False,errorware.get('error_email'),errorware.get('mail_dsn'),0.650448203086853
|
||
|
1571,"def find_strings ( start_address ) : <TAB> strings = [ ] <TAB> <TAB> import_ea = start_address <TAB> while import_ea < SegEnd ( start_address ) : <TAB> <TAB> import_name = Name ( import_ea ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> xref_start = import_ea <TAB> <TAB> <TAB> xref_cur = DfirstB ( xref_start ) <TAB> <TAB> <TAB> while xref_cur!= BADADDR : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> string_arg = get_arguments ( xref_cur ) <TAB> <TAB> <TAB> <TAB> if string_arg and string_arg not in strings : <TAB> <TAB> <TAB> <TAB> <TAB> strings. append ( string_arg ) <TAB> <TAB> <TAB> <TAB> xref_cur = DnextB ( xref_start, xref_cur ) <TAB> <TAB> import_ea += 4 <TAB> <TAB> for function_ea in Functions ( SegByName ( "".text"" ), SegEnd ( start_address ) ) : <TAB> <TAB> flags = GetFunctionFlags ( function_ea ) <TAB> <TAB> if flags & FUNC_LIB : <TAB> <TAB> <TAB> lib_name = GetFunctionName ( function_ea ) <TAB> <TAB> <TAB> if len ( lib_name ) > 1 and ""cmp"" in lib_name : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> xref_start = function_ea <TAB> <TAB> <TAB> <TAB> xref_cur = RfirstB ( xref_start ) <TAB> <TAB> <TAB> <TAB> while xref_cur!= BADADDR : <TAB> <TAB> <TAB> <TAB> <TAB> string_arg = get_arguments ( xref_cur ) <TAB> <TAB> <TAB> <TAB> <TAB> if string_arg and string_arg not in strings : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> strings. append ( string_",False,len(import_name) > 1 and 'cmp' in import_name,len(import_ea) > 0,0.6562709808349609
|
||
|
1572,"def run ( self, execution_info ) -> driver_output_pb2. DriverOutput : <TAB> <TAB> <TAB> span = 2 <TAB> with self. _mlmd_connection as m : <TAB> <TAB> previous_output = inputs_utils. resolve_input_artifacts ( m, self. _self_output ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> version = 0 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> version = ( <TAB> <TAB> <TAB> <TAB> max ( <TAB> <TAB> <TAB> <TAB> <TAB> [ <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> artifact. get_int_custom_property ( ""version"" ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for artifact in previous_output [ ""examples"" ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if artifact. get_int_custom_property ( ""span"" ) == span <TAB> <TAB> <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> <TAB> <TAB> or [ - 1 ] <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> + 1 <TAB> <TAB> <TAB> ) <TAB> output_example = copy. deepcopy ( <TAB> <TAB> execution_info. output_dict [ ""output_examples"" ] [ 0 ]. mlmd_artifact <TAB> ) <TAB> output_example. custom_properties [ ""span"" ]. int_value = span <TAB> output_example. custom_properties [ ""version"" ]. int_value = version <TAB> result = driver_output_pb2. DriverOutput ( ) <TAB> result. output_artifacts [ ""output_examples"" ]. artifacts. append ( output_example ) <TAB> result. exec_properties [ ""span"" ]. int_value = span <TAB> result. exec_properties [ ""version"" ]. int_value = version <TAB> return result",False,previous_output,has_artifacts(previous_output),0.667296290397644
|
||
|
1573,"def remove_dead_csv ( csv_node, lives, arg_aliases, alias_map, func_ir, typemap ) : <TAB> <TAB> new_df_colnames = [ ] <TAB> new_out_vars = [ ] <TAB> new_out_types = [ ] <TAB> new_usecols = [ ] <TAB> for i, col_var in enumerate ( csv_node. out_vars ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> new_df_colnames. append ( csv_node. df_colnames [ i ] ) <TAB> <TAB> <TAB> new_out_vars. append ( csv_node. out_vars [ i ] ) <TAB> <TAB> <TAB> new_out_types. append ( csv_node. out_types [ i ] ) <TAB> <TAB> <TAB> new_usecols. append ( csv_node. usecols [ i ] ) <TAB> csv_node. df_colnames = new_df_colnames <TAB> csv_node. out_vars = new_out_vars <TAB> csv_node. out_types = new_out_types <TAB> csv_node. usecols = new_usecols <TAB> if len ( csv_node. out_vars ) == 0 : <TAB> <TAB> return None <TAB> return csv_node",False,col_var.name in lives,col_var.dead_csv,0.6563782691955566
|
||
|
1574,"def _calc_cmrc2018_f1_score ( answers, prediction ) : <TAB> f1_scores = [ ] <TAB> for ans in answers : <TAB> <TAB> ans_segs = _cn_segmentation ( ans, rm_punc = True ) <TAB> <TAB> prediction_segs = _cn_segmentation ( prediction, rm_punc = True ) <TAB> <TAB> lcs, lcs_len = _find_lcs ( ans_segs, prediction_segs ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> f1_scores. append ( 0 ) <TAB> <TAB> <TAB> continue <TAB> <TAB> precision = 1.0 * lcs_len / len ( prediction_segs ) <TAB> <TAB> recall = 1.0 * lcs_len / len ( ans_segs ) <TAB> <TAB> f1 = ( 2 * precision * recall ) / ( precision + recall ) <TAB> <TAB> f1_scores. append ( f1 ) <TAB> return max ( f1_scores )",True,lcs_len == 0,lcs_len == 0,0.6590019464492798
|
||
|
1575,"def add_reversed_tensor ( i, X, reversed_X ) : <TAB> <TAB> if X in stop_mapping_at_tensors : <TAB> <TAB> return <TAB> if X not in reversed_tensors : <TAB> <TAB> reversed_tensors [ X ] = { ""id"" : ( nid, i ), ""tensor"" : reversed_X } <TAB> else : <TAB> <TAB> tmp = reversed_tensors [ X ] <TAB> <TAB> if ""tensor"" in tmp and ""tensors"" in tmp : <TAB> <TAB> <TAB> raise Exception ( ""Wrong order, tensors already aggregated!"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> tmp [ ""tensors"" ] = [ tmp [ ""tensor"" ], reversed_X ] <TAB> <TAB> <TAB> del tmp [ ""tensor"" ] <TAB> <TAB> else : <TAB> <TAB> <TAB> tmp [ ""tensors"" ]. append ( reversed_X )",False,'tensor' in tmp,'tensors' in tmp,0.6678755283355713
|
||
|
1576,"def eventFilter ( self, obj, event ) : <TAB> if event. type ( ) == QEvent. MouseButtonPress : <TAB> <TAB> button = event. button ( ) <TAB> <TAB> if button == Qt. BackButton : <TAB> <TAB> <TAB> self. _app. browser. back ( ) <TAB> <TAB> <TAB> return True <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> self. _app. browser. forward ( ) <TAB> <TAB> <TAB> return True <TAB> return False",True,button == Qt.ForwardButton,button == Qt.ForwardButton,0.6688909530639648
|
||
|
1577,"def validate ( self, entry, field_uri = None ) : <TAB> super ( ). validate ( entry, field_uri ) <TAB> if entry is None : <TAB> <TAB> return <TAB> field_uri = field_uri or self. field_uri <TAB> try : <TAB> <TAB> path = Path ( entry ) <TAB> except TypeError : <TAB> <TAB> self. raise_error ( entry, field_uri, ""values is expected to be path-like"" ) <TAB> if self. check_exists and not path. exists ( ) : <TAB> <TAB> self. raise_error ( entry, field_uri, ""path does not exist"" ) <TAB> else : <TAB> <TAB> if self. is_directory and not path. is_dir ( ) : <TAB> <TAB> <TAB> self. raise_error ( entry, field_uri, ""is not a directory"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. raise_error ( entry, field_uri, ""is a directory, regular file expected"" )",False,self.is_directory is False and (not path.is_file()),self.is_regular_file and (not path.is_dir()),0.6444675922393799
|
||
|
1578,"def host_local_traverse_tree ( <TAB> data_inst, tree_node, use_missing = True, zero_as_missing = True ) : <TAB> nid = 0 <TAB> while True : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return nid <TAB> <TAB> cur_node = tree_node [ nid ] <TAB> <TAB> fid, bid = cur_node. fid, cur_node. bid <TAB> <TAB> missing_dir = cur_node. missing_dir <TAB> <TAB> if use_missing and zero_as_missing : <TAB> <TAB> <TAB> if ( <TAB> <TAB> <TAB> <TAB> data_inst. features. get_data ( fid ) == NoneType ( ) <TAB> <TAB> <TAB> <TAB> or data_inst. features. get_data ( fid, None ) is None <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> nid = ( <TAB> <TAB> <TAB> <TAB> <TAB> tree_node [ nid ]. right_nodeid <TAB> <TAB> <TAB> <TAB> <TAB> if missing_dir == 1 <TAB> <TAB> <TAB> <TAB> <TAB> else tree_node [ nid ]. left_nodeid <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> elif data_inst. features. get_data ( fid ) <= bid : <TAB> <TAB> <TAB> <TAB> nid = tree_node [ nid ]. left_nodeid <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> nid = tree_node [ nid ]. right_nodeid <TAB> <TAB> elif data_inst. features. get_data ( fid ) == NoneType ( ) : <TAB> <TAB> <TAB> nid = ( <TAB> <TAB> <TAB> <TAB> tree_node [ nid ]. right_nodeid <TAB> <TAB> <TAB> <TAB> if missing_dir == 1 <TAB> <TAB> <TAB> <TAB> else tree_node [ nid ]. left_nodeid <",False,tree_node[nid].is_leaf,nid >= len(tree_node),0.6573371887207031
|
||
|
1579,"def _filter_paths ( basename, path, is_dir, exclude ) : <TAB> """""".gitignore style file filtering."""""" <TAB> for item in exclude : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> match = path if item. startswith ( ""/"" ) else basename <TAB> <TAB> if fnmatch. fnmatch ( match, item. strip ( ""/"" ) ) : <TAB> <TAB> <TAB> return True <TAB> return False",False,item.endswith('/') and (not is_dir),is_dir,0.6449323892593384
|
||
|
1580,"def has_dirty_objects ( self ) : <TAB> language = self. current_lang <TAB> if self. page : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> dirty = self. page. has_translation ( language ) <TAB> <TAB> else : <TAB> <TAB> <TAB> dirty = self. page. is_dirty ( language ) or self. page_is_pending ( <TAB> <TAB> <TAB> <TAB> self. page, language <TAB> <TAB> <TAB> ) <TAB> else : <TAB> <TAB> dirty = bool ( self. dirty_statics ) <TAB> return dirty",False,self.dirty_statics,self.page.has_translation(language),0.6614997386932373
|
||
|
1581,"def get_snmp_information ( self ) : <TAB> snmp_information = { } <TAB> command = ""show running-config"" <TAB> output = self. _send_command ( command ) <TAB> snmp_config = helpers. textfsm_extractor ( self, ""snmp_config"", output ) <TAB> if not snmp_config : <TAB> <TAB> return snmp_information <TAB> snmp_information = { <TAB> <TAB> ""contact"" : str ( """" ), <TAB> <TAB> ""location"" : str ( """" ), <TAB> <TAB> ""community"" : { }, <TAB> <TAB> ""chassis_id"" : str ( """" ), <TAB> } <TAB> for snmp_entry in snmp_config : <TAB> <TAB> contact = str ( snmp_entry. get ( ""contact"", """" ) ) <TAB> <TAB> if contact : <TAB> <TAB> <TAB> snmp_information [ ""contact"" ] = contact <TAB> <TAB> location = str ( snmp_entry. get ( ""location"", """" ) ) <TAB> <TAB> if location : <TAB> <TAB> <TAB> snmp_information [ ""location"" ] = location <TAB> <TAB> community_name = str ( snmp_entry. get ( ""community"", """" ) ) <TAB> <TAB> if not community_name : <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> snmp_information [ ""community"" ] [ community_name ] = { <TAB> <TAB> <TAB> <TAB> ""acl"" : str ( snmp_entry. get ( ""acl"", """" ) ), <TAB> <TAB> <TAB> <TAB> ""mode"" : str ( snmp_entry. get ( ""mode"", """" ). lower ( ) ), <TAB> <TAB> <TAB> } <TAB> <TAB> else : <TAB> <TAB> <TAB> acl = str ( snmp_entry. get ( ""acl"", """" ) ) <TAB> <TAB> <TAB> if acl : <TAB> <TAB> <TAB> <TAB> snmp_information [ ""community"" ] [ community_name ] [ ""acl"" ] =",False,community_name not in snmp_information['community'].keys(),community_name in snmp_information['community'],0.6492284536361694
|
||
|
1582,"def docs ( self ) : <TAB> proc = subprocess. Popen ( <TAB> <TAB> [ <TAB> <TAB> <TAB> ""python"", <TAB> <TAB> <TAB> self. wiki_extractor, <TAB> <TAB> <TAB> ""--no-templates"", <TAB> <TAB> <TAB> ""--processes"", <TAB> <TAB> <TAB> str ( self. n_jobs ), <TAB> <TAB> <TAB> ""--output"", <TAB> <TAB> <TAB> ""-"", <TAB> <TAB> <TAB> self. fawiki_dump, <TAB> <TAB> ], <TAB> <TAB> stdout = subprocess. PIPE, <TAB> ) <TAB> doc_pattern = re. compile ( r'<doc id=""(\d+)"" url=""([^\""]+)"" title=""([^\""]+)"">' ) <TAB> doc = [ ] <TAB> for line in iter ( proc. stdout. readline, """" ) : <TAB> <TAB> line = line. strip ( ). decode ( ""utf8"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> doc. append ( line ) <TAB> <TAB> if line == ""</doc>"" : <TAB> <TAB> <TAB> del doc [ 1 ] <TAB> <TAB> <TAB> id, url, title = doc_pattern. match ( doc [ 0 ] ). groups ( ) <TAB> <TAB> <TAB> html = ""\n"". join ( doc [ 1 : - 1 ] ) <TAB> <TAB> <TAB> yield { ""id"" : id, ""url"" : url, ""title"" : title, ""html"" : html, ""text"" : html } <TAB> <TAB> <TAB> doc = [ ]",False,line,line != '',0.688806414604187
|
||
|
1583,"def _maybe_namespace ( <TAB> cls, <TAB> data : Any, <TAB> *, <TAB> preferred_type : Type [ ModelT ] = None, <TAB> fast_types : Tuple [ Type,... ] = ( bytes, str ), <TAB> isinstance : Callable = isinstance ) -> Optional [ Type [ ModelT ] ] : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if data is None or isinstance ( data, fast_types ) : <TAB> <TAB> return None <TAB> try : <TAB> <TAB> ns = data [ cls. _blessed_key ] [ ""ns"" ] <TAB> except ( KeyError, TypeError ) : <TAB> <TAB> pass <TAB> else : <TAB> <TAB> <TAB> <TAB> type_is_abstract = ( <TAB> <TAB> <TAB> preferred_type is None <TAB> <TAB> <TAB> or preferred_type is ModelT <TAB> <TAB> <TAB> or preferred_type is Model <TAB> <TAB> ) <TAB> <TAB> try : <TAB> <TAB> <TAB> model = registry [ ns ] <TAB> <TAB> except KeyError : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise <TAB> <TAB> <TAB> return None <TAB> <TAB> else : <TAB> <TAB> <TAB> if ( <TAB> <TAB> <TAB> <TAB> type_is_abstract <TAB> <TAB> <TAB> <TAB> or model. _options. allow_blessed_key <TAB> <TAB> <TAB> <TAB> or model. _options. polymorphic_fields <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> return model <TAB> return None",False,type_is_abstract,model is None,0.6619807481765747
|
||
|
1584,"def modify ( cls, profile ) : <TAB> if<mask> : <TAB> <TAB> profile. add_overlay ( svcscan_base_x86 ) <TAB> else : <TAB> <TAB> <TAB> <TAB> profile. add_overlay ( svcscan_base_x64 ) <TAB> <TAB> version = profile. metadata ( ""version"" ) <TAB> if version < 6.0 : <TAB> <TAB> profile. add_classes ( <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> ""_SERVICE_RECORD"" : _SERVICE_RECORD_LEGACY, <TAB> <TAB> <TAB> <TAB> ""_SERVICE_HEADER"" : _SERVICE_HEADER, <TAB> <TAB> <TAB> } <TAB> <TAB> ) <TAB> <TAB> profile. add_constants ( dict ( ServiceTag = b""sErv"" ) ) <TAB> <TAB> elif 6.0 <= version <= 6.2 : <TAB> <TAB> profile. add_classes ( <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> ""_SERVICE_RECORD"" : _SERVICE_RECORD_RECENT, <TAB> <TAB> <TAB> <TAB> ""_SERVICE_HEADER"" : _SERVICE_HEADER, <TAB> <TAB> <TAB> } <TAB> <TAB> ) <TAB> <TAB> profile. add_constants ( dict ( ServiceTag = b""serH"" ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> profile. add_overlay ( _SERVICE_RECORD_VISTA_X86 ) <TAB> <TAB> else : <TAB> <TAB> <TAB> profile. add_overlay ( _SERVICE_RECORD_VISTA_X64 ) <TAB> <TAB> elif 6.2 <= version : <TAB> <TAB> profile. add_classes ( <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> ""_SERVICE_RECORD"" : _SERVICE_RECORD_RECENT, <TAB> <TAB> <TAB> <TAB> ""_SERVICE_HEADER"" : _SERVICE_HEADER, <TAB> <TAB> <TAB> } <TAB> <TAB> ) <TAB> <",False,profile.metadata('arch') == 'I386',version > 6.2,0.6534208059310913
|
||
|
1585,"def _entries_kraken ( self, channel_name, broadcast_type, sort ) : <TAB> access_token = self. _download_access_token ( channel_name ) <TAB> channel_id = self. _extract_channel_id ( access_token [ ""token"" ], channel_name ) <TAB> offset = 0 <TAB> counter_override = None <TAB> for counter in itertools. count ( 1 ) : <TAB> <TAB> response = self. _call_api ( <TAB> <TAB> <TAB> ""kraken/channels/%s/videos/"" % channel_id, <TAB> <TAB> <TAB> channel_id, <TAB> <TAB> <TAB> ""Downloading video JSON page %s"" % ( counter_override or counter ), <TAB> <TAB> <TAB> query = { <TAB> <TAB> <TAB> <TAB> ""offset"" : offset, <TAB> <TAB> <TAB> <TAB> ""limit"" : self. _PAGE_LIMIT, <TAB> <TAB> <TAB> <TAB> ""broadcast_type"" : broadcast_type, <TAB> <TAB> <TAB> <TAB> ""sort"" : sort, <TAB> <TAB> <TAB> }, <TAB> <TAB> ) <TAB> <TAB> videos = response. get ( ""videos"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> break <TAB> <TAB> for video in videos : <TAB> <TAB> <TAB> if not isinstance ( video, dict ) : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> video_url = url_or_none ( video. get ( ""url"" ) ) <TAB> <TAB> <TAB> if not video_url : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> yield { <TAB> <TAB> <TAB> <TAB> ""_type"" : ""url_transparent"", <TAB> <TAB> <TAB> <TAB> ""ie_key"" : TwitchVodIE. ie_key ( ), <TAB> <TAB> <TAB> <TAB> ""id"" : video. get ( ""_id"" ),",False,"not isinstance(videos, list)",videos,0.657272219657898
|
||
|
1586,"def process_package_tag_set ( self, elem, message, skip_actions_tags = True ) : <TAB> elem_altered = False <TAB> new_elem = copy. deepcopy ( elem ) <TAB> for sub_index, sub_elem in enumerate ( elem ) : <TAB> <TAB> altered = False <TAB> <TAB> error_message = """" <TAB> <TAB> if sub_elem. tag == ""install"" : <TAB> <TAB> <TAB> altered, new_sub_elem, error_message = self. process_install_tag_set ( <TAB> <TAB> <TAB> <TAB> elem = sub_elem, message = message, skip_actions_tags = skip_actions_tags <TAB> <TAB> <TAB> ) <TAB> <TAB> elif sub_elem. tag == ""repository"" : <TAB> <TAB> <TAB> altered, new_sub_elem, error_message = self. process_repository_tag_set ( <TAB> <TAB> <TAB> <TAB> parent_elem = elem, elem_index = sub_index, elem = sub_elem, message = message <TAB> <TAB> <TAB> ) <TAB> <TAB> if error_message and error_message not in message : <TAB> <TAB> <TAB> message += error_message <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if not self. altered : <TAB> <TAB> <TAB> <TAB> self. altered = True <TAB> <TAB> <TAB> if not elem_altered : <TAB> <TAB> <TAB> <TAB> elem_altered = True <TAB> <TAB> <TAB> new_elem [ sub_index ] = new_sub_elem <TAB> return elem_altered, new_elem, message",False,altered,skip_actions_tags,0.6898657083511353
|
||
|
1587,"def on_api_command ( self, command, data ) : <TAB> if command == ""select"" : <TAB> <TAB> if not Permissions. PLUGIN_ACTION_COMMAND_PROMPT_INTERACT. can ( ) : <TAB> <TAB> <TAB> return flask. abort ( 403, ""Insufficient permissions"" ) <TAB> <TAB> if self. _prompt is None : <TAB> <TAB> <TAB> return flask. abort ( 409, ""No active prompt"" ) <TAB> <TAB> choice = data [ ""choice"" ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return flask. abort ( <TAB> <TAB> <TAB> <TAB> 400, ""{!r} is not a valid value for choice"". format ( choice ) <TAB> <TAB> <TAB> ) <TAB> <TAB> self. _answer_prompt ( choice )",False,"not isinstance(choice, int) or not self._prompt.validate_choice(choice)",not choice.valid(),0.6513665914535522
|
||
|
1588,"def workflow_tag_handler ( view, left, operator, right ) : <TAB> if operator == ""="" : <TAB> <TAB> view. do_query = True <TAB> <TAB> view. query = view. query. filter ( <TAB> <TAB> <TAB> StoredWorkflow. id == StoredWorkflowTagAssociation. stored_workflow_id <TAB> <TAB> ) <TAB> <TAB> tmp = right. split ( "":"" ) <TAB> <TAB> view. query = view. query. filter ( <TAB> <TAB> <TAB> StoredWorkflowTagAssociation. user_tname == tmp [ 0 ] <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> view. query = view. query. filter ( <TAB> <TAB> <TAB> <TAB> StoredWorkflowTagAssociation. user_value == tmp [ 1 ] <TAB> <TAB> <TAB> ) <TAB> else : <TAB> <TAB> raise GalaxyParseError ( ""Invalid comparison operator: %s"" % ( operator ) )",False,len(tmp) > 1,operator == 'delete',0.6611274480819702
|
||
|
1589,"def _wrap_df ( cls, op, value, index = None ) : <TAB> xdf = cudf if op. gpu else pd <TAB> axis = op. axis <TAB> ndim = op. inputs [ 0 ]. ndim <TAB> if ndim == 2 : <TAB> <TAB> dtype = None <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> value = xdf. DataFrame ( [ value ], columns = index ) <TAB> <TAB> elif not isinstance ( value, xdf. DataFrame ) : <TAB> <TAB> <TAB> new_index = None if not op. gpu else getattr ( value, ""index"", None ) <TAB> <TAB> <TAB> dtype = getattr ( value, ""dtype"", None ) <TAB> <TAB> <TAB> value = xdf. DataFrame ( value, columns = index, index = new_index ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return value <TAB> <TAB> value = value. T if axis == 0 else value <TAB> <TAB> if ( <TAB> <TAB> <TAB> dtype == np. dtype ( ""O"" ) <TAB> <TAB> <TAB> and getattr ( op. outputs [ 0 ], ""dtypes"", None ) is not None <TAB> <TAB> ) : <TAB> <TAB> <TAB> value = value. astype ( op. outputs [ 0 ]. dtypes ) <TAB> <TAB> return value <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> value = xdf. Series ( [ value ], index = index ) <TAB> <TAB> elif isinstance ( value, np. ndarray ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> value = xdf. Series ( value. tolist ( ), index = index ) <TAB> <TAB> return value",False,"isinstance(value, (np.generic, int, float, complex))","isinstance(value, xdf.Series)",0.6513369083404541
|
||
|
1590,"def process ( self ) : <TAB> if not self. outputs [ ""Angles"" ]. is_linked : <TAB> <TAB> return <TAB> vertices_s = self. inputs [ ""Vertices"" ]. sv_get ( default = [ [ ] ] ) <TAB> edges_s = self. inputs [ ""Edges"" ]. sv_get ( default = [ [ ] ] ) <TAB> faces_s = self. inputs [ ""Polygons"" ]. sv_get ( default = [ [ ] ] ) <TAB> result_angles = [ ] <TAB> meshes = match_long_repeat ( [ vertices_s, edges_s, faces_s ] ) <TAB> for vertices, edges, faces in zip ( * meshes ) : <TAB> <TAB> new_angles = [ ] <TAB> <TAB> bm = bmesh_from_pydata ( vertices, edges, faces ) <TAB> <TAB> bm. normal_update ( ) <TAB> <TAB> for edge in bm. edges : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if self. signed : <TAB> <TAB> <TAB> <TAB> angle = edge. calc_face_angle_signed ( 180 ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> angle = edge. calc_face_angle ( 180 ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if self. complement : <TAB> <TAB> <TAB> <TAB> angle = math. copysign ( math. pi, angle ) - angle <TAB> <TAB> <TAB> if self. is_degenerated ( edge ) : <TAB> <TAB> <TAB> <TAB> angle = self. get_degenerated_angle ( angle ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> angle = math. degrees ( angle ) <TAB> <TAB> <TAB> new_angles. append ( angle ) <TAB> <TAB> if edges : <TAB> <TAB> <TAB> new_angles = untangle_edges ( edges, bm. edges, new_angles )",False,self.angles_mode == 'degrees' and angle is not None,self.is_tangle,0.656069278717041
|
||
|
1591,"def _reinit_optimizers_with_oss ( self ) : <TAB> optimizers = self. lightning_module. trainer. optimizers <TAB> for x, optimizer in enumerate ( optimizers ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> optimizer = optimizer. _optimizer <TAB> <TAB> if not isinstance ( optimizer, OSS ) : <TAB> <TAB> <TAB> optim_class = type ( optimizer ) <TAB> <TAB> <TAB> zero_optimizer = OSS ( <TAB> <TAB> <TAB> <TAB> params = optimizer. param_groups, optim = optim_class, ** optimizer. defaults <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> optimizers [ x ] = zero_optimizer <TAB> <TAB> <TAB> del optimizer <TAB> trainer = self. lightning_module. trainer <TAB> trainer. optimizers = optimizers <TAB> trainer. convert_to_lightning_optimizers ( )",False,is_lightning_optimizer(optimizer),"hasattr(optimizer, '_optimizer')",0.652013897895813
|
||
|
1592,"def OnKey ( self, evt ) : <TAB> key = evt. GetKeyCode ( ) <TAB> if key >= 32 and key <= 127 : <TAB> <TAB> self. typedText = self. typedText + chr ( key ) <TAB> <TAB> item = self. FindPrefix ( self. typedText ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. SetSelection ( item ) <TAB> elif key == wx. WXK_BACK : <TAB> <TAB> self. typedText = self. typedText [ : - 1 ] <TAB> <TAB> if not self. typedText : <TAB> <TAB> <TAB> self. SetSelection ( 0 ) <TAB> <TAB> else : <TAB> <TAB> <TAB> item = self. FindPrefix ( self. typedText ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. SetSelection ( item ) <TAB> else : <TAB> <TAB> self. typedText = """" <TAB> <TAB> evt. Skip ( )",False,item != -1,not self.typedText,0.670193076133728
|
||
|
1593,"def write ( self, key, value = None, ttl = None, dir = False ) : <TAB> key = _normalize_path ( key ) <TAB> segments = key. lstrip ( ""/"" ). split ( ""/"" ) <TAB> path = """" <TAB> parent = ""/"" <TAB> event_paths = [ ] <TAB> for s in segments : <TAB> <TAB> if parent not in self. _children : <TAB> <TAB> <TAB> self. _children [ parent ] = set ( ) <TAB> <TAB> self. _children [ parent ]. add ( s ) <TAB> <TAB> event_paths. append ( parent ) <TAB> <TAB> path += ""/"" + s <TAB> <TAB> if path!= key and path in self. _store : <TAB> <TAB> <TAB> raise KeyError ( f""Not a directory: {key}"" ) <TAB> <TAB> parent = path <TAB> if dir : <TAB> <TAB> self. _children [ key ] = set ( ) <TAB> else : <TAB> <TAB> self. _store [ key ] = value <TAB> <TAB> if ttl : <TAB> <TAB> <TAB> self. _expire_time [ key ] = datetime. now ( ) + timedelta ( seconds = ttl ) <TAB> event_paths. append ( key ) <TAB> for p in event_paths : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> [ e. set ( ) for e in list ( self. _watch_event_r [ p ] ) ] <TAB> if key in self. _watch_event : <TAB> <TAB> [ e. set ( ) for e in list ( self. _watch_event [ key ] ) ]",True,p in self._watch_event_r,p in self._watch_event_r,0.657435417175293
|
||
|
1594,"def _add_select ( self, table_set ) : <TAB> to_select = [ ] <TAB> has_select_star = False <TAB> for expr in self. select_set : <TAB> <TAB> if isinstance ( expr, ir. ValueExpr ) : <TAB> <TAB> <TAB> arg = self. _translate ( expr, named = True ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> if expr. equals ( self. table_set ) : <TAB> <TAB> <TAB> <TAB> cached_table = self. context. get_table ( expr ) <TAB> <TAB> <TAB> <TAB> if cached_table is None : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> has_select_star = True <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> arg = table_set <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> arg = self. context. get_table ( expr ) <TAB> <TAB> <TAB> <TAB> if arg is None : <TAB> <TAB> <TAB> <TAB> <TAB> raise ValueError ( expr ) <TAB> <TAB> to_select. append ( arg ) <TAB> if has_select_star : <TAB> <TAB> if table_set is None : <TAB> <TAB> <TAB> raise ValueError ( ""table_set cannot be None here"" ) <TAB> <TAB> clauses = [ table_set ] + to_select <TAB> else : <TAB> <TAB> clauses = to_select <TAB> if self. exists : <TAB> <TAB> result = sa. exists ( clauses ) <TAB> else : <TAB> <TAB> result = sa. select ( clauses ) <TAB> if self. distinct : <TAB> <TAB> result = result. distinct ( ) <TAB> if not has_select_star : <TAB> <TAB> if table_set is not None : <TAB> <TAB> <TAB> return result. select_",False,"isinstance(expr, ir.TableExpr)",self.table_set is not None,0.6515713930130005
|
||
|
1595,"def _finish_closing ( self, _ ) : <TAB> if self. socket_type == SERVER_SOCKET : <TAB> <TAB> log. debug ( ""Shutting down server socket parent group"", extra = { ""sock"" : self } ) <TAB> <TAB> self. parent_group. shutdownGracefully ( 0, 100, TimeUnit. MILLISECONDS ) <TAB> <TAB> self. accepted_children -= 1 <TAB> <TAB> while True : <TAB> <TAB> <TAB> child = self. child_queue. poll ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> log. debug ( <TAB> <TAB> <TAB> <TAB> ""Closed child socket %s not yet accepted"", child, extra = { ""sock"" : self } <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> child. close ( ) <TAB> else : <TAB> <TAB> msgs = [ ] <TAB> <TAB> self. incoming. drainTo ( msgs ) <TAB> <TAB> for msg in msgs : <TAB> <TAB> <TAB> if msg is not _PEER_CLOSED : <TAB> <TAB> <TAB> <TAB> msg. release ( ) <TAB> log. debug ( ""Closed socket"", extra = { ""sock"" : self } )",True,child is None,child is None,0.6680395603179932
|
||
|
1596,"def format_ret ( self, arg ) : <TAB> """"""Format arg, the value returned by a ""return"" statement."""""" <TAB> try : <TAB> <TAB> if isinstance ( arg, types. GeneratorType ) : <TAB> <TAB> <TAB> ret = ""<generator>"" <TAB> <TAB> elif isinstance ( arg, ( tuple, list ) ) : <TAB> <TAB> <TAB> ret = ""[%s]"" % "","". join ( [ self. show ( z ) for z in arg ] ) <TAB> <TAB> <TAB> if len ( ret ) > 40 : <TAB> <TAB> <TAB> <TAB> ret = ""[\n%s]"" % ( ""\n,"". join ( [ self. show ( z ) for z in arg ] ) ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> ret = self. show ( arg ) <TAB> <TAB> <TAB> if len ( ret ) > 40 : <TAB> <TAB> <TAB> <TAB> ret = ""\n %s"" % ret <TAB> <TAB> else : <TAB> <TAB> <TAB> ret = """" if arg is None else repr ( arg ) <TAB> except Exception : <TAB> <TAB> exctype, value = sys. exc_info ( ) [ : 2 ] <TAB> <TAB> s = ""<**exception: %s,%s arg: %r**>"" % ( exctype. __name__, value, arg ) <TAB> <TAB> ret = "" ->\n %s"" % ( s ) if len ( s ) > 40 else "" -> %s"" % ( s ) <TAB> return "" -> %s"" % ret",False,arg,"isinstance(arg, string_types)",0.7060309648513794
|
||
|
1597,"def get_sink_args_which_propagate ( sink, ast_node ) : <TAB> sink_args_with_positions = CallVisitor. get_call_visit_results ( <TAB> <TAB> sink. trigger. call, ast_node <TAB> ) <TAB> sink_args = [ ] <TAB> kwargs_present = set ( ) <TAB> for i, vars in enumerate ( sink_args_with_positions. args ) : <TAB> <TAB> kwarg = sink. trigger. get_kwarg_from_position ( i ) <TAB> <TAB> if kwarg : <TAB> <TAB> <TAB> kwargs_present. add ( kwarg ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> sink_args. extend ( vars ) <TAB> for keyword, vars in sink_args_with_positions. kwargs. items ( ) : <TAB> <TAB> kwargs_present. add ( keyword ) <TAB> <TAB> if sink. trigger. kwarg_propagates ( keyword ) : <TAB> <TAB> <TAB> sink_args. extend ( vars ) <TAB> if ( <TAB> <TAB> <TAB> <TAB> not sink. trigger. arg_list_propagates <TAB> <TAB> or <TAB> <TAB> <TAB> <TAB> sink. trigger. kwarg_list - kwargs_present <TAB> ) : <TAB> <TAB> sink_args. extend ( sink_args_with_positions. unknown_args ) <TAB> <TAB> sink_args. extend ( sink_args_with_positions. unknown_kwargs ) <TAB> return sink_args",False,sink.trigger.kwarg_propagates(kwarg),vars,0.6532992124557495
|
||
|
1598,"def read ( self, item, recursive = False, sort = False ) : <TAB> item = _normalize_path ( item ) <TAB> if item in self. _store : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> del self. _store [ item ] <TAB> <TAB> <TAB> raise KeyError ( item ) <TAB> <TAB> return PathResult ( item, value = self. _store [ item ] ) <TAB> else : <TAB> <TAB> return self. _read_dir ( item, recursive = recursive, sort = sort )",False,item in self._expire_time and self._expire_time[item] < datetime.now(),recursive,0.653357744216919
|
||
|
1599,"def _get_new_version ( <TAB> config_file : str = ""./setup.cfg"", <TAB> current_version : str = None, <TAB> micro_release : bool = False, ) : <TAB> if micro_release : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return _change_micro_version ( current_version ) <TAB> <TAB> elif config_file : <TAB> <TAB> <TAB> return _change_micro_version ( _fetch_current_version ( config_file ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return _fetch_default_calendar_release_version ( ) <TAB> else : <TAB> <TAB> return _fetch_default_calendar_release_version ( )",True,current_version,current_version,0.6658474206924438
|
||
|
1600,"def test_list ( self ) : <TAB> self. _create_locations ( ) <TAB> response = self. client. get ( self. geojson_boxedlocation_list_url ) <TAB> self. assertEqual ( response. status_code, 200 ) <TAB> self. assertEqual ( len ( response. data [ ""features"" ] ), 2 ) <TAB> for feature in response. data [ ""features"" ] : <TAB> <TAB> self. assertIn ( ""bbox"", feature ) <TAB> <TAB> fid = feature [ ""id"" ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. assertEqual ( feature [ ""bbox"" ], self. bl1. bbox_geometry. extent ) <TAB> <TAB> elif fid == 2 : <TAB> <TAB> <TAB> self. assertEqual ( feature [ ""bbox"" ], self. bl2. bbox_geometry. extent ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. fail ( ""Unexpected id: {0}"". format ( fid ) ) <TAB> BoxedLocation. objects. all ( ). delete ( )",True,fid == 1,fid == 1,0.6808070540428162
|
||
|
1601,"def fee_amount_in_quote ( self, trading_pair : str, price : Decimal, order_amount : Decimal ) : <TAB> fee_amount = Decimal ( ""0"" ) <TAB> if self. percent > 0 : <TAB> <TAB> fee_amount = ( price * order_amount ) * self. percent <TAB> base, quote = trading_pair. split ( ""-"" ) <TAB> for flat_fee in self. flat_fees : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> fee_amount += flat_fee [ 1 ] * price <TAB> <TAB> elif interchangeable ( flat_fee [ 0 ], quote ) : <TAB> <TAB> <TAB> fee_amount += flat_fee [ 1 ] <TAB> return fee_amount",False,"interchangeable(flat_fee[0], base)",base,0.6503372192382812
|
||
|
1602,"def _ProcessName ( self, name, dependencies ) : <TAB> """"""Retrieve a module name from a node name."""""" <TAB> module_name, dot, base_name = name. rpartition ( ""."" ) <TAB> if dot : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if module_name in dependencies : <TAB> <TAB> <TAB> <TAB> dependencies [ module_name ]. add ( base_name ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> dependencies [ module_name ] = { base_name } <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> logging. warning ( ""Empty package name: %s"", name )",False,module_name,base_name,0.6689913868904114
|
||
|
1603,"def _build_args ( self ) : <TAB> <TAB> queue = Queue ( ) <TAB> <TAB> <TAB> <TAB> for i, arg in enumerate ( self. real_args ) : <TAB> <TAB> if isinstance ( arg, ( list, tuple ) ) : <TAB> <TAB> <TAB> self. real_args [ i ] = self. data_addr + len ( self. payload ) + queue. size ( ) <TAB> <TAB> <TAB> queue. extend ( arg ) <TAB> <TAB> elif isinstance ( arg, bytes ) : <TAB> <TAB> <TAB> self. real_args [ i ] = self. data_addr + len ( self. payload ) + queue. size ( ) <TAB> <TAB> <TAB> queue. append ( MarkedBytes ( arg ) ) <TAB> <TAB> <TAB> <TAB> <TAB> while len ( queue ) > 0 : <TAB> <TAB> top = queue [ 0 ] <TAB> <TAB> if isinstance ( top, ( list, tuple ) ) : <TAB> <TAB> <TAB> top = pack ( self. data_addr + len ( self. payload ) + queue. size ( ) ) <TAB> <TAB> <TAB> queue. extend ( queue [ 0 ] ) <TAB> <TAB> elif isinstance ( top, MarkedBytes ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> top = pack ( self. data_addr + len ( self. payload ) + queue. size ( ) ) <TAB> <TAB> <TAB> queue. append ( MarkedBytes ( queue [ 0 ] ) ) <TAB> <TAB> elif isinstance ( top, six. integer_types ) : <TAB> <TAB> <TAB> top = pack ( top ) <TAB> <TAB> self. payload += top <TAB> <TAB> queue. pop ( 0 )",False,"isinstance(top, bytes)",top == 0,0.6495963335037231
|
||
|
1604,"def __init__ ( self, debugger ) : <TAB> infos = [ ] <TAB> frame = debugger. currentframe <TAB> <TAB> while frame : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> cc = debugger. codeContainerProvider. FromFileName ( frame. f_code. co_filename ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> address = frame. f_locals [ ""__axstack_address__"" ] <TAB> <TAB> <TAB> except KeyError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> address = axdebug. GetStackAddress ( ) <TAB> <TAB> <TAB> frameInfo = ( <TAB> <TAB> <TAB> <TAB> DebugStackFrame ( frame, frame. f_lineno - 1, cc ), <TAB> <TAB> <TAB> <TAB> address, <TAB> <TAB> <TAB> <TAB> address + 1, <TAB> <TAB> <TAB> <TAB> 0, <TAB> <TAB> <TAB> <TAB> None, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> infos. append ( frameInfo ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> frame = frame. f_back <TAB> gateways. EnumDebugStackFrames. __init__ ( self, infos, 0 )",False,cc is not None,"hasattr(frame, 'f_locals')",0.6673362851142883
|
||
|
1605,"def generate_png ( self, info, png_filename, svg_data ) : <TAB> with tempfile. NamedTemporaryFile ( <TAB> <TAB> ""w+"", encoding = ""utf-8"", suffix = "".svg"", delete = False <TAB> ) as tmpfile : <TAB> <TAB> tmpfile. write ( svg_data ) <TAB> <TAB> tmpfile. flush ( ) <TAB> <TAB> command = [ <TAB> <TAB> <TAB> self. inkscape, <TAB> <TAB> <TAB> ""--without-gui"", <TAB> <TAB> <TAB> ""-f"", <TAB> <TAB> <TAB> tmpfile. name, <TAB> <TAB> <TAB> ""-e"", <TAB> <TAB> <TAB> png_filename, <TAB> <TAB> <TAB> ""--export-area-drawing"", <TAB> <TAB> <TAB> ""--export-area-snap"", <TAB> <TAB> ] <TAB> <TAB> if info. get ( ""background"" ) : <TAB> <TAB> <TAB> command. append ( ""--export-background=%s"" % info [ ""background"" ] ) <TAB> <TAB> if info. get ( ""dpi"" ) : <TAB> <TAB> <TAB> command. append ( ""--export-dpi=%s"" % info [ ""dpi"" ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> command. append ( ""--export-width=%s"" % info [ ""width"" ] ) <TAB> <TAB> if info. get ( ""height"" ) : <TAB> <TAB> <TAB> command. append ( ""--export-height=%s"" % info [ ""height"" ] ) <TAB> <TAB> subprocess. check_call ( command )",True,info.get('width'),info.get('width'),0.6529386043548584
|
||
|
1606,"def start ( self, * args, ** kwargs ) : <TAB> try : <TAB> <TAB> super ( ). start ( * args, ** kwargs ) <TAB> except testprocess. ProcessExited : <TAB> <TAB> is_dl_inconsistency = str ( self. captured_log [ - 1 ] ). endswith ( <TAB> <TAB> <TAB> ""_dl_allocate_tls_init: Assertion "" <TAB> <TAB> <TAB> ""`listp->slotinfo[cnt].gen <= GL(dl_tls_generation)' failed!"" <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. captured_log = [ ] <TAB> <TAB> <TAB> self. _log ( ""NOTE: Restarted after libc DL inconsistency!"" ) <TAB> <TAB> <TAB> self. clear_data ( ) <TAB> <TAB> <TAB> super ( ). start ( * args, ** kwargs ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise",False,testutils.ON_CI and is_dl_inconsistency,is_dl_inconsistency,0.6467252969741821
|
||
|
1607,"def _execute_combine ( cls, xp, a, v, op ) : <TAB> inp_indices, inp_data = a <TAB> if np. isscalar ( v ) : <TAB> <TAB> ind = xp. searchsorted ( inp_data, v, side = op. side ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> ind -= 1 <TAB> <TAB> return inp_indices [ ind ], inp_data [ ind ] <TAB> else : <TAB> <TAB> ret_indices = np. empty ( v. shape, dtype = np. intp ) <TAB> <TAB> ret_data = np. empty ( v. shape, dtype = inp_data. dtype ) <TAB> <TAB> for idx in itertools. product ( * ( range ( s ) for s in v. shape ) ) : <TAB> <TAB> <TAB> ind = xp. searchsorted ( inp_data [ ( slice ( None ), ) + idx ], v [ idx ], side = op. side ) <TAB> <TAB> <TAB> if ind >= len ( inp_indices ) : <TAB> <TAB> <TAB> <TAB> ind -= 1 <TAB> <TAB> <TAB> ret_indices [ idx ] = inp_indices [ ( ind, ) + idx ] <TAB> <TAB> <TAB> ret_data [ idx ] = inp_data [ ( ind, ) + idx ] <TAB> <TAB> return ret_indices, ret_data",False,ind >= len(inp_data),ind >= len(inp_indices),0.6530814170837402
|
||
|
1608,"def close ( self ) : <TAB> self. _callbacks. clear ( ) <TAB> if self. _saved_sighandler is not None : <TAB> <TAB> handler = signal. getsignal ( signal. SIGCHLD ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> logger. warning ( ""SIGCHLD handler was changed by outside code"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> signal. signal ( signal. SIGCHLD, self. _saved_sighandler ) <TAB> <TAB> self. _saved_sighandler = None",False,handler != self._sig_chld,handler != None,0.6657562255859375
|
||
|
1609,"def emitSubDomainData ( self, subDomainData, event ) : <TAB> self. emitRawRirData ( subDomainData, event ) <TAB> for subDomainElem in subDomainData : <TAB> <TAB> if self. checkForStop ( ) : <TAB> <TAB> <TAB> return None <TAB> <TAB> subDomain = subDomainElem. get ( ""subdomain"", """" ). strip ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. emitHostname ( subDomain, event )",True,subDomain,subDomain,0.6842691898345947
|
||
|
1610,"def create_xxh_env ( self ) : <TAB> home = p ( self. local_xxh_home ) <TAB> check_dirs = [ home, home / "".xxh/shells"", home / "".xxh/plugins"" ] <TAB> for d in check_dirs : <TAB> <TAB> if not d. exists ( ) : <TAB> <TAB> <TAB> self. S ( f""mkdir -p {d}"" ) <TAB> xxh_version_file = home / "".xxh/xxh_version"" <TAB> if not xxh_version_file. exists ( ) : <TAB> <TAB> self. S ( f""echo {__version__} > {xxh_version_file}"" ) <TAB> config_file = p ( self. config_file ) <TAB> sample_config_file = self. package_dir_path / ""config.xxhc"" <TAB> if not config_file. exists ( ) and sample_config_file. exists ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> eprint ( f""Create sample config file in {config_file}"" ) <TAB> <TAB> self. S ( <TAB> <TAB> <TAB> f""mkdir -p {config_file.parent} && cp {sample_config_file} {config_file}"" <TAB> <TAB> )",False,not self.quiet,config_file.exists(),0.6715287566184998
|
||
|
1611,"def validate_directory ( d, msg = ""{} {}"" ) : <TAB> if not os. path. exists ( d ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> os. makedirs ( d ) <TAB> <TAB> except OSError as e : <TAB> <TAB> <TAB> logger. error ( e ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise PatroniException ( msg. format ( d, ""couldn't create the directory"" ) ) <TAB> elif os. path. isdir ( d ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> fd, tmpfile = tempfile. mkstemp ( dir = d ) <TAB> <TAB> <TAB> os. close ( fd ) <TAB> <TAB> <TAB> os. remove ( tmpfile ) <TAB> <TAB> except OSError : <TAB> <TAB> <TAB> raise PatroniException ( msg. format ( d, ""the directory is not writable"" ) ) <TAB> else : <TAB> <TAB> raise PatroniException ( msg. format ( d, ""is not a directory"" ) )",False,e.errno != errno.EEXIST,not os.path.isdir(d),0.6558647155761719
|
||
|
1612,"def _remove_obsolete_leafs ( input_dict ) : <TAB> if not isinstance ( input_dict, dict ) : <TAB> <TAB> return <TAB> if input_dict [ LEAF_MARKER ] : <TAB> <TAB> bottom_leafs = input_dict [ LEAF_MARKER ] <TAB> <TAB> for leaf in bottom_leafs : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> input_dict [ LEAF_MARKER ]. remove ( leaf ) <TAB> for subtree in input_dict. keys ( ) : <TAB> <TAB> _remove_obsolete_leafs ( input_dict [ subtree ] )",False,leaf in input_dict,leaf in input_dict[LEAF_MARKER],0.6701984405517578
|
||
|
1613,"def fix_e712 ( self, result ) : <TAB> """"""Fix (trivial case of) comparison with boolean."""""" <TAB> ( line_index, offset, target ) = get_index_offset_contents ( result, self. source ) <TAB> <TAB> if re. match ( r'^\s*if [\w.""\'\[\]]+ == False:$', target ) : <TAB> <TAB> self. source [ line_index ] = re. sub ( <TAB> <TAB> <TAB> r'if ([\w.""\'\[\]]+) == False:', r""if not \1:"", target, count = 1 <TAB> <TAB> ) <TAB> elif re. match ( r'^\s*if [\w.""\'\[\]]+!= True:$', target ) : <TAB> <TAB> self. source [ line_index ] = re. sub ( <TAB> <TAB> <TAB> r'if ([\w.""\'\[\]]+)!= True:', r""if not \1:"", target, count = 1 <TAB> <TAB> ) <TAB> else : <TAB> <TAB> right_offset = offset + 2 <TAB> <TAB> if right_offset >= len ( target ) : <TAB> <TAB> <TAB> return [ ] <TAB> <TAB> left = target [ : offset ]. rstrip ( ) <TAB> <TAB> center = target [ offset : right_offset ] <TAB> <TAB> right = target [ right_offset : ]. lstrip ( ) <TAB> <TAB> <TAB> <TAB> new_right = None <TAB> <TAB> if center. strip ( ) == ""=="" : <TAB> <TAB> <TAB> if re. match ( r""\bTrue\b"", right ) : <TAB> <TAB> <TAB> <TAB> new_right = re. sub ( r""\bTrue\b *"", """", right, count = 1 ) <TAB> <TAB> elif center. strip ( ) == ""!="" : <TAB> <TAB> <TAB> if re. match ( r""\bFalse\b"", right ) : <TAB> <TAB> <TAB> <TAB> new_right = re. sub ( r""\bFalse\b *"", """",",False,new_right is None,target[count] == True,0.6584903597831726
|
||
|
1614,"def __init__ ( self, ** kwargs ) : <TAB> <TAB> dfl = get_model_label ( self. default_model_class ) <TAB> if ""to"" in kwargs. keys ( ) : <TAB> <TAB> old_to = get_model_label ( kwargs. pop ( ""to"" ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> msg = ""%s can only be a ForeignKey to %s; %s passed"" % ( <TAB> <TAB> <TAB> <TAB> self. __class__. __name__, <TAB> <TAB> <TAB> <TAB> dfl, <TAB> <TAB> <TAB> <TAB> old_to, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> warnings. warn ( msg, SyntaxWarning ) <TAB> kwargs [ ""to"" ] = dfl <TAB> super ( ). __init__ ( ** kwargs )",False,old_to.lower() != dfl.lower(),old_to and dfl < self.default_model_class,0.6516293287277222
|
||
|
1615,"def _list_outputs ( self ) : <TAB> outputs = self. _outputs ( ). get ( ) <TAB> outputs [ ""outlier_files"" ] = [ ] <TAB> outputs [ ""intensity_files"" ] = [ ] <TAB> outputs [ ""statistic_files"" ] = [ ] <TAB> outputs [ ""mask_files"" ] = [ ] <TAB> if<mask> : <TAB> <TAB> outputs [ ""norm_files"" ] = [ ] <TAB> <TAB> if self. inputs. bound_by_brainmask : <TAB> <TAB> <TAB> outputs [ ""displacement_files"" ] = [ ] <TAB> if isdefined ( self. inputs. save_plot ) and self. inputs. save_plot : <TAB> <TAB> outputs [ ""plot_files"" ] = [ ] <TAB> for i, f in enumerate ( ensure_list ( self. inputs. realigned_files ) ) : <TAB> <TAB> ( <TAB> <TAB> <TAB> outlierfile, <TAB> <TAB> <TAB> intensityfile, <TAB> <TAB> <TAB> statsfile, <TAB> <TAB> <TAB> normfile, <TAB> <TAB> <TAB> plotfile, <TAB> <TAB> <TAB> displacementfile, <TAB> <TAB> <TAB> maskfile, <TAB> <TAB> ) = self. _get_output_filenames ( f, os. getcwd ( ) ) <TAB> <TAB> outputs [ ""outlier_files"" ]. insert ( i, outlierfile ) <TAB> <TAB> outputs [ ""intensity_files"" ]. insert ( i, intensityfile ) <TAB> <TAB> outputs [ ""statistic_files"" ]. insert ( i, statsfile ) <TAB> <TAB> outputs [ ""mask_files"" ]. insert ( i, maskfile ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> outputs [ ""norm_files"" ]. insert ( i, normfile ) <TAB> <TAB> <TAB> if self. inputs. bound_by_brainmask : <TAB> <TAB> <TAB> <TAB> outputs [ ""displacement_files"" ]. insert ( i, displacementfile ) <",False,isdefined(self.inputs.use_norm) and self.inputs.use_norm,self.inputs.save_norm,0.6469634771347046
|
||
|
1616,"def generate_io ( chart_type, race_configs, environment ) : <TAB> <TAB> structures = [ ] <TAB> for race_config in race_configs : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> title = chart_type. format_title ( <TAB> <TAB> <TAB> <TAB> environment, <TAB> <TAB> <TAB> <TAB> race_config. track, <TAB> <TAB> <TAB> <TAB> es_license = race_config. es_license, <TAB> <TAB> <TAB> <TAB> suffix = ""%s-io"" % race_config. label, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> structures. append ( chart_type. io ( title, environment, race_config ) ) <TAB> return structures",False,'io' in race_config.charts,race_config.label and race_config.es_license,0.6538827419281006
|
||
|
1617,"def _check_fit_params ( <TAB> X : TwoDimArrayLikeType, fit_params : Dict, indices : OneDimArrayLikeType ) -> Dict : <TAB> fit_params_validated = { } <TAB> for key, value in fit_params. items ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> fit_params_validated [ key ] = value <TAB> <TAB> else : <TAB> <TAB> <TAB> fit_params_validated [ key ] = _make_indexable ( value ) <TAB> <TAB> <TAB> fit_params_validated [ key ] = _safe_indexing ( <TAB> <TAB> <TAB> <TAB> fit_params_validated [ key ], indices <TAB> <TAB> <TAB> ) <TAB> return fit_params_validated",False,not _is_arraylike(value) or _num_samples(value) != _num_samples(X),key == 'TAB > <TAB > <TAB > <TAB > <TAB >,0.6508034467697144
|
||
|
1618,"def acquire ( self, timeout = None, check_interval = None, fail_when_locked = None ) : <TAB> if self. _lock : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> raise exceptions. LockException ( ) <TAB> <TAB> if self. _pid!= os. getpid ( ) : <TAB> <TAB> self. _pid = os. getpid ( ) <TAB> <TAB> self. _acquire_count = 0 <TAB> <TAB> if self. fh : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> portalocker. unlock ( self. fh ) <TAB> <TAB> <TAB> <TAB> self. fh. close ( ) <TAB> <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> self. fh = None <TAB> if self. _acquire_count >= 1 : <TAB> <TAB> fh = self. fh <TAB> else : <TAB> <TAB> fh = super ( RLock, self ). acquire ( timeout, check_interval, fail_when_locked ) <TAB> self. _acquire_count += 1 <TAB> return fh",False,"not self._lock.acquire(block=timeout != 0, timeout=timeout)",self._acquire_count >= 2,0.6550785303115845
|
||
|
1619,"def _GetMSBuildConfigurationDetails ( spec, build_file ) : <TAB> properties = { } <TAB> for name, settings in spec [ ""configurations"" ]. iteritems ( ) : <TAB> <TAB> msbuild_attributes = _GetMSBuildAttributes ( spec, settings, build_file ) <TAB> <TAB> condition = _GetConfigurationCondition ( name, settings ) <TAB> <TAB> character_set = msbuild_attributes. get ( ""CharacterSet"" ) <TAB> <TAB> _AddConditionalProperty ( <TAB> <TAB> <TAB> properties, <TAB> <TAB> <TAB> condition, <TAB> <TAB> <TAB> ""ConfigurationType"", <TAB> <TAB> <TAB> msbuild_attributes [ ""ConfigurationType"" ], <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if ""msvs_enable_winrt"" not in spec : <TAB> <TAB> <TAB> <TAB> _AddConditionalProperty ( <TAB> <TAB> <TAB> <TAB> <TAB> properties, condition, ""CharacterSet"", character_set <TAB> <TAB> <TAB> <TAB> ) <TAB> return _GetMSBuildPropertyGroup ( spec, ""Configuration"", properties )",False,character_set,'msvs_enable_stdrt' in spec,0.6597793102264404
|
||
|
1620,"def test_build_root_config_overwrite ( self ) : <TAB> cfg = build_root_config ( ""tests.files.settings_overwrite"" ) <TAB> for key, val in DEFAULT_SPIDER_GLOBAL_CONFIG. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. assertEqual ( cfg [ ""global"" ] [ key ], [ ""zzz"" ] ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. assertEqual ( cfg [ ""global"" ] [ key ], val )",False,key == 'spider_modules',key in cfg,0.6519770622253418
|
||
|
1621,"def sha_update ( sha_info, buffer ) : <TAB> if isinstance ( buffer, str ) : <TAB> <TAB> raise TypeError ( ""Unicode strings must be encoded before hashing"" ) <TAB> count = len ( buffer ) <TAB> buffer_idx = 0 <TAB> clo = ( sha_info [ ""count_lo"" ] + ( count << 3 ) ) & 0xFFFFFFFF <TAB> if clo < sha_info [ ""count_lo"" ] : <TAB> <TAB> sha_info [ ""count_hi"" ] += 1 <TAB> sha_info [ ""count_lo"" ] = clo <TAB> sha_info [ ""count_hi"" ] += count >> 29 <TAB> if sha_info [ ""local"" ] : <TAB> <TAB> i = SHA_BLOCKSIZE - sha_info [ ""local"" ] <TAB> <TAB> if i > count : <TAB> <TAB> <TAB> i = count <TAB> <TAB> <TAB> <TAB> for x in enumerate ( buffer [ buffer_idx : buffer_idx + i ] ) : <TAB> <TAB> <TAB> sha_info [ ""data"" ] [ sha_info [ ""local"" ] + x [ 0 ] ] = x [ 1 ] <TAB> <TAB> count -= i <TAB> <TAB> buffer_idx += i <TAB> <TAB> sha_info [ ""local"" ] += i <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> sha_transform ( sha_info ) <TAB> <TAB> <TAB> sha_info [ ""local"" ] = 0 <TAB> <TAB> else : <TAB> <TAB> <TAB> return <TAB> while count >= SHA_BLOCKSIZE : <TAB> <TAB> <TAB> <TAB> sha_info [ ""data"" ] = list ( buffer [ buffer_idx : buffer_idx + SHA_BLOCKSIZE ] ) <TAB> <TAB> count -= SHA_BLOCKSIZE <TAB> <TAB> buffer_idx += SHA_BLOCKSIZE <TAB> <TAB> sha_transform ( sha_info ) <TAB> <TAB> pos = sha_info [ ""local"" ] <TAB> sha_info [ ""data"" ] [ pos : pos + count ] = list ( buffer [ buffer_idx : buffer",False,sha_info['local'] == SHA_BLOCKSIZE,sha_info['local'] == 0,0.6547240018844604
|
||
|
1622,"def _check_load_bbox ( self, coco, entry ) : <TAB> """"""Check and load ground-truth labels"""""" <TAB> entry_id = entry [ ""id"" ] <TAB> <TAB> entry_id = [ entry_id ] if not isinstance ( entry_id, ( list, tuple ) ) else entry_id <TAB> ann_ids = coco. getAnnIds ( imgIds = entry_id, iscrowd = None ) <TAB> objs = coco. loadAnns ( ann_ids ) <TAB> <TAB> valid_objs = [ ] <TAB> width = entry [ ""width"" ] <TAB> height = entry [ ""height"" ] <TAB> for obj in objs : <TAB> <TAB> if obj [ ""area"" ] < self. _min_object_area : <TAB> <TAB> <TAB> continue <TAB> <TAB> if obj. get ( ""ignore"", 0 ) == 1 : <TAB> <TAB> <TAB> continue <TAB> <TAB> if not self. _use_crowd and obj. get ( ""iscrowd"", 0 ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> xmin, ymin, xmax, ymax = bbox_clip_xyxy ( <TAB> <TAB> <TAB> bbox_xywh_to_xyxy ( obj [ ""bbox"" ] ), width, height <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> if obj [ ""area"" ] > 0 and xmax > xmin and ymax > ymin : <TAB> <TAB> <TAB> contiguous_cid = self. json_id_to_contiguous [ obj [ ""category_id"" ] ] <TAB> <TAB> <TAB> valid_objs. append ( [ xmin, ymin, xmax, ymax, contiguous_cid ] ) <TAB> if not valid_objs : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> valid_objs. append ( [ - 1, - 1, - 1, - 1, - 1 ] ) <TAB> return valid_objs",False,not self._skip_empty,self.norm_width > 0.0 or self.norm_height > 0.0,0.6570522785186768
|
||
|
1623,"def check_build_dir ( build_dir ) : <TAB> profiles_per_benchmark = defaultdict ( list ) <TAB> for path in glob. glob ( os. path. join ( build_dir, ""ssg-*-ds.xml"" ) ) : <TAB> <TAB> gather_profiles_from_datastream ( path, build_dir, profiles_per_benchmark ) <TAB> for bench_short_id in STABLE_PROFILE_IDS. keys ( ) : <TAB> <TAB> if respective_datastream_absent ( bench_short_id, build_dir ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> if bench_short_id not in profiles_per_benchmark : <TAB> <TAB> <TAB> raise RuntimeError ( <TAB> <TAB> <TAB> <TAB> ""Expected benchmark ID '%s' has to be "" <TAB> <TAB> <TAB> <TAB> ""prefixed with '%s'."" % ( bench_short_id, BENCHMARK_ID_PREFIX ) <TAB> <TAB> <TAB> ) <TAB> <TAB> for profile_id in STABLE_PROFILE_IDS [ bench_short_id ] : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise RuntimeError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Profile '%s' is required to be in the "" <TAB> <TAB> <TAB> <TAB> <TAB> ""'%s' benchmark. It is a stable profile "" <TAB> <TAB> <TAB> <TAB> <TAB> ""that can't be renamed or removed!"" % ( profile_id, bench_short_id ) <TAB> <TAB> <TAB> <TAB> )",False,profile_id not in profiles_per_benchmark[bench_short_id],profile_id not in profiles_per_benchmark,0.6485183238983154
|
||
|
1624,"def candidates ( ) -> Generator [ ""Symbol"", None, None ] : <TAB> s = self <TAB> if<mask> : <TAB> <TAB> Symbol. debug_print ( ""searching in self:"" ) <TAB> <TAB> print ( s. to_string ( Symbol. debug_indent + 1 ), end = """" ) <TAB> while True : <TAB> <TAB> if matchSelf : <TAB> <TAB> <TAB> yield s <TAB> <TAB> if recurseInAnon : <TAB> <TAB> <TAB> yield from s. children_recurse_anon <TAB> <TAB> else : <TAB> <TAB> <TAB> yield from s. _children <TAB> <TAB> if s. siblingAbove is None : <TAB> <TAB> <TAB> break <TAB> <TAB> s = s. siblingAbove <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> Symbol. debug_print ( ""searching in sibling:"" ) <TAB> <TAB> <TAB> print ( s. to_string ( Symbol. debug_indent + 1 ), end = """" )",False,Symbol.debug_lookup,s.siblingAbove is None,0.6518721580505371
|
||
|
1625,"def tagSelected ( tag ) : <TAB> tag = tag. lower ( ). strip ( ) <TAB> if tag == ""bold"" : <TAB> <TAB> app. textAreaToggleFontSelected ( ""ta"", ""BOLD"" ) <TAB> if tag == ""underline"" : <TAB> <TAB> app. textAreaToggleFontSelected ( ""ta"", ""UNDERLINE"" ) <TAB> if tag == ""italic"" : <TAB> <TAB> app. textAreaToggleFontSelected ( ""ta"", ""ITALIC"" ) <TAB> if tag == ""boldItalic"" : <TAB> <TAB> app. textAreaToggleFontSelected ( ""ta"", ""BOLD_ITALIC"" ) <TAB> else : <TAB> <TAB> op = app. radio ( ""operation"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> app. textAreaToggleTagSelected ( ""ta"", tag ) <TAB> <TAB> elif op == ""remove"" : <TAB> <TAB> <TAB> app. textAreaUntagSelected ( ""ta"", tag ) <TAB> <TAB> elif op == ""delete"" : <TAB> <TAB> <TAB> app. textAreaDeleteTag ( ""ta"", tag )",False,op == 'add',"op == 'open""",0.6601884961128235
|
||
|
1626,"def _get_field_actual ( cant_be_number, raw_string, field_names ) : <TAB> for line in raw_string. splitlines ( ) : <TAB> <TAB> for field_name in field_names : <TAB> <TAB> <TAB> field_name = field_name. lower ( ) <TAB> <TAB> <TAB> if "":"" in line : <TAB> <TAB> <TAB> <TAB> left, right = line. split ( "":"", 1 ) <TAB> <TAB> <TAB> <TAB> left = left. strip ( ). lower ( ) <TAB> <TAB> <TAB> <TAB> right = right. strip ( ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> if cant_be_number : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if not right. isdigit ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return right <TAB> <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return right <TAB> return None",False,left == field_name and len(right) > 0,left.count(),0.6519061326980591
|
||
|
1627,"def _format_unencoded_with_lineno ( self, tokensource, outfile ) : <TAB> self. _write_lineno ( outfile ) <TAB> for ttype, value in tokensource : <TAB> <TAB> if value. endswith ( ""\n"" ) : <TAB> <TAB> <TAB> self. _write_lineno ( outfile ) <TAB> <TAB> <TAB> value = value [ : - 1 ] <TAB> <TAB> color = self. colorscheme. get ( ttype ) <TAB> <TAB> while color is None : <TAB> <TAB> <TAB> ttype = ttype [ : - 1 ] <TAB> <TAB> <TAB> color = self. colorscheme. get ( ttype ) <TAB> <TAB> if color : <TAB> <TAB> <TAB> color = color [ self. darkbg ] <TAB> <TAB> <TAB> spl = value. split ( ""\n"" ) <TAB> <TAB> <TAB> for line in spl [ : - 1 ] : <TAB> <TAB> <TAB> <TAB> self. _write_lineno ( outfile ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> outfile. write ( ircformat ( color, line [ : - 1 ] ) ) <TAB> <TAB> <TAB> if spl [ - 1 ] : <TAB> <TAB> <TAB> <TAB> outfile. write ( ircformat ( color, spl [ - 1 ] ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> outfile. write ( value ) <TAB> outfile. write ( ""\n"" )",False,line,spl,0.6757024526596069
|
||
|
1628,"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 fid == 1 : <TAB> <TAB> <TAB> if ftype == TType. STRUCT : <TAB> <TAB> <TAB> <TAB> self. operationId = THandleIdentifier ( ) <TAB> <TAB> <TAB> <TAB> self. operationId. read ( iprot ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif fid == 2 : <TAB> <TAB> <TAB> if ftype == TType. I32 : <TAB> <TAB> <TAB> <TAB> self. operationType = iprot. readI32 ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> if ftype == TType. BOOL : <TAB> <TAB> <TAB> <TAB> self. hasResultSet = iprot. readBool ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif fid == 4 : <TAB> <TAB> <TAB> if ftype == TType. DOUBLE : <TAB> <TAB> <TAB> <TAB> self. modifiedRowCount = iprot. readDouble ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB>",True,fid == 3,fid == 3,0.6749258041381836
|
||
|
1629,"def _check_redirects ( self, result ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if result. history and self. _base_url. startswith ( ""http:"" ) : <TAB> <TAB> for item in result. history : <TAB> <TAB> <TAB> if item. status_code not in ( 301, 302 ) : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if item. request. method == ""GET"" : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> location = item. headers. get ( ""Location"", None ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise RedirectError ( REDIRECT_MSG )",False,location and location.startswith('https://'),location and location.startswith(self._base_url),0.6451317667961121
|
||
|
1630,"def _check_seed ( self, seed ) : <TAB> if seed is not None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _raise_error ( <TAB> <TAB> <TAB> <TAB> ""The random number generator seed value, seed, should be integer type or None."" <TAB> <TAB> <TAB> ) <TAB> <TAB> if seed < 0 : <TAB> <TAB> <TAB> self. _raise_error ( <TAB> <TAB> <TAB> <TAB> ""The random number generator seed value, seed, should be non-negative integer or None."" <TAB> <TAB> <TAB> )",False,type(seed) != int,"seed < 0 and isinstance(seed, int) or seed > 65535",0.6684019565582275
|
||
|
1631,"def __add__ ( self, f ) : <TAB> if isinstance ( f. value, dict ) : <TAB> <TAB> for field in f. fields : <TAB> <TAB> <TAB> self. slice [ field ] = f. value <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. fields = f. fields <TAB> el if<mask> : <TAB> <TAB> self. fields = f. fields <TAB> <TAB> self. value = f. value <TAB> <TAB> self. slice = { } <TAB> elif self. value is self. ONLY and f. value is self. ONLY : <TAB> <TAB> self. _clean_slice ( ) <TAB> <TAB> if self. _only_called : <TAB> <TAB> <TAB> self. fields = self. fields. union ( f. fields ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. fields = f. fields <TAB> elif self. value is self. EXCLUDE and f. value is self. EXCLUDE : <TAB> <TAB> self. fields = self. fields. union ( f. fields ) <TAB> <TAB> self. _clean_slice ( ) <TAB> elif self. value is self. ONLY and f. value is self. EXCLUDE : <TAB> <TAB> self. fields -= f. fields <TAB> <TAB> self. _clean_slice ( ) <TAB> elif self. value is self. EXCLUDE and f. value is self. ONLY : <TAB> <TAB> self. value = self. ONLY <TAB> <TAB> self. fields = f. fields - self. fields <TAB> <TAB> self. _clean_slice ( ) <TAB> if ""_id"" in f. fields : <TAB> <TAB> self. _id = f. value <TAB> if self. always_include : <TAB> <TAB> if self. value is self. ONLY and self. fields : <TAB> <TAB> <TAB> if sorted ( self. slice. keys ( ) )!= sorted ( self. fields ) : <TAB> <TAB> <TAB> <TAB> self. fields = self. fields. union ( self. always_include ) <TAB> <TAB> else : <TAB",False,not self.fields,self._only_called,0.6647045612335205
|
||
|
1632,"def __init__ ( self ) : <TAB> self. DEBUG_SENDBACK = False <TAB> self. DEBUG_SHOW_GUI = True <TAB> self. previous_grey_img = None <TAB> self. cv2_major = None <TAB> self. cv2_minor = None <TAB> self. MOTION_DETECTION_THRESHOLD = 1000 <TAB> self. NO_MOTION_DURATION = 5 <TAB> self. no_motion_start_time = None <TAB> self. no_motion_image = None <TAB> for value in cv2. __version__. split ( ""."" ) : <TAB> <TAB> if self. cv2_major is None : <TAB> <TAB> <TAB> self. cv2_major = value <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> self. cv2_minor = value <TAB> <TAB> <TAB> break <TAB> print ( ""self.cv2_major={}, self.cv2_minor={}"". format ( self. cv2_major, self. cv2_minor ) )",True,self.cv2_minor is None,self.cv2_minor is None,0.6618829965591431
|
||
|
1633,"def _lint ( self ) : <TAB> lints = { } <TAB> lint_errors = set ( ) <TAB> for name, test in self. _config. config. tests. items ( ) : <TAB> <TAB> lints [ name ] = { ""regions"" : self. _filter_unsupported_regions ( test. regions ) } <TAB> <TAB> lints [ name ] [ ""template"" ] = self. _templates [ name ]. template_path <TAB> <TAB> lints [ name ] [ ""results"" ] = { } <TAB> <TAB> templates = [ ] <TAB> <TAB> for template in self. _templates. values ( ) : <TAB> <TAB> <TAB> templates. append ( template ) <TAB> <TAB> <TAB> templates += list ( template. descendents ) <TAB> <TAB> templates = set ( templates ) <TAB> <TAB> for template in templates : <TAB> <TAB> <TAB> self. _run_checks ( template, name, lint_errors, lints ) <TAB> <TAB> for err in lint_errors : <TAB> <TAB> <TAB> LOG. error ( err ) <TAB> for test in lints : <TAB> <TAB> for result in lints [ test ] [ ""results"" ] : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> if self. _is_error ( lints [ test ] [ ""results"" ] [ result ] ) : <TAB> <TAB> <TAB> <TAB> <TAB> lint_errors. add ( result ) <TAB> return lints, lint_errors",False,lints[test]['results'][result],self._is_error(result),0.6587398052215576
|
||
|
1634,"def _unsubscribe ( self, subscription, session ) : <TAB> <TAB> <TAB> was_subscribed, was_last_subscriber = self. _subscription_map. drop_observer ( <TAB> <TAB> session, subscription <TAB> ) <TAB> <TAB> <TAB> if was_subscribed : <TAB> <TAB> self. _session_to_subscriptions [ session ]. discard ( subscription ) <TAB> <TAB> <TAB> if self. _router. _realm : <TAB> <TAB> service_session = self. _router. _realm. session <TAB> <TAB> if service_session and not subscription. uri. startswith ( u""wamp."" ) : <TAB> <TAB> <TAB> if was_subscribed : <TAB> <TAB> <TAB> <TAB> service_session. publish ( <TAB> <TAB> <TAB> <TAB> <TAB> u""wamp.subscription.on_unsubscribe"", <TAB> <TAB> <TAB> <TAB> <TAB> session. _session_id, <TAB> <TAB> <TAB> <TAB> <TAB> subscription. id, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> service_session. publish ( <TAB> <TAB> <TAB> <TAB> <TAB> u""wamp.subscription.on_delete"", session. _session_id, subscription. id <TAB> <TAB> <TAB> <TAB> ) <TAB> return was_subscribed, was_last_subscriber",True,was_last_subscriber,was_last_subscriber,0.6567608118057251
|
||
|
1635,"def _create_examples ( cls, lines, set_type ) : <TAB> examples = [ ] <TAB> for ( i, line ) in enumerate ( lines ) : <TAB> <TAB> if ""gold_label"" in line : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> examples. append ( <TAB> <TAB> <TAB> <TAB> Example ( <TAB> <TAB> <TAB> <TAB> <TAB> guid = ""%s-%s"" % ( set_type, i ), <TAB> <TAB> <TAB> <TAB> <TAB> input_premise = line [ ""sentence1"" ], <TAB> <TAB> <TAB> <TAB> <TAB> input_hypothesis = line [ ""sentence2"" ], <TAB> <TAB> <TAB> <TAB> <TAB> label = line [ ""gold_label"" ] if set_type!= ""test"" else cls. LABELS [ - 1 ], <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if line [ ""label"" ] == - 1 : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> examples. append ( <TAB> <TAB> <TAB> <TAB> Example ( <TAB> <TAB> <TAB> <TAB> <TAB> guid = ""%s-%s"" % ( set_type, i ), <TAB> <TAB> <TAB> <TAB> <TAB> input_premise = line [ ""premise"" ], <TAB> <TAB> <TAB> <TAB> <TAB> input_hypothesis = line [ ""hypothesis"" ], <TAB> <TAB> <TAB> <TAB> <TAB> label = line [ ""label"" ] if set_type!= ""test"" else cls. LABELS [ - 1 ], <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> return examples",False,line['gold_label'] == '-',line['label'] == None,0.6572644710540771
|
||
|
1636,"def _parse_args ( cls, args ) : <TAB> <TAB> <TAB> parts = [ ] <TAB> for a in args : <TAB> <TAB> if isinstance ( a, PurePath ) : <TAB> <TAB> <TAB> parts += a. _parts <TAB> <TAB> else : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> a = os. fspath ( a ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if hasattr ( a, ""__fspath__"" ) : <TAB> <TAB> <TAB> <TAB> <TAB> a = a. __fspath__ ( ) <TAB> <TAB> <TAB> if isinstance ( a, str ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> parts. append ( str ( a ) ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> elif six. PY2 and isinstance ( a, six. text_type ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> parts. append ( a. encode ( sys. getfilesystemencoding ( ) ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> raise TypeError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""argument should be a str object or an os.PathLike "" <TAB> <TAB> <TAB> <TAB> <TAB> ""object returning str, not %r"" % type ( a ) <TAB> <TAB> <TAB> <TAB> ) <TAB> return cls. _flavour. parse_parts ( parts )",False,"sys.version_info >= (3, 6)","hasattr(a, '__fspath__')",0.652714729309082
|
||
|
1637,"def enrichTarget ( self, target ) : <TAB> ret = list ( ) <TAB> <TAB> self. sf. info ( ""Identifying aliases for specified target(s)"" ) <TAB> ret = self. sf. resolveTargets ( target, self. opts [ ""validatereverse"" ] ) <TAB> if not ret : <TAB> <TAB> return target <TAB> for host in ret : <TAB> <TAB> self. sf. debug ( ""Found an alias: "" + host ) <TAB> <TAB> if self. sf. validIP ( host ) : <TAB> <TAB> <TAB> target. setAlias ( host, ""IP_ADDRESS"" ) <TAB> <TAB> elif self. sf. validIP6 ( host ) : <TAB> <TAB> <TAB> target. setAlias ( host, ""IPV6_ADDRESS"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> target. setAlias ( host, ""INTERNET_NAME"" ) <TAB> <TAB> <TAB> idnahost = host. encode ( ""idna"" ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> target. setAlias ( <TAB> <TAB> <TAB> <TAB> <TAB> idnahost. decode ( ""ascii"", errors = ""replace"" ), ""INTERNET_NAME"" <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. sf. info ( ""Aliases identified: "" + str ( target. targetAliases ) ) <TAB> return target",False,idnahost != host,idnahost,0.6686146855354309
|
||
|
1638,"def get_states ( idxs, labels, cls_num, weights = None ) : <TAB> ins_num = idxs. shape [ 0 ] <TAB> <TAB> states = np. zeros ( ( cls_num, 4 ) ). astype ( ""float32"" ) <TAB> for i in range ( ins_num ) : <TAB> <TAB> w = weights [ i ] if weights is not None else 1.0 <TAB> <TAB> idx = idxs [ i ] [ 0 ] <TAB> <TAB> label = labels [ i ] [ 0 ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> states [ idx ] [ 0 ] += w <TAB> <TAB> <TAB> for j in range ( cls_num ) : <TAB> <TAB> <TAB> <TAB> states [ j ] [ 2 ] += w <TAB> <TAB> <TAB> states [ idx ] [ 2 ] -= w <TAB> <TAB> else : <TAB> <TAB> <TAB> states [ label ] [ 3 ] += w <TAB> <TAB> <TAB> states [ idx ] [ 1 ] += w <TAB> <TAB> <TAB> for j in range ( cls_num ) : <TAB> <TAB> <TAB> <TAB> states [ j ] [ 2 ] += w <TAB> <TAB> <TAB> states [ label ] [ 2 ] -= w <TAB> <TAB> <TAB> states [ idx ] [ 2 ] -= w <TAB> return states",False,idx == label,label == None,0.6789555549621582
|
||
|
1639,"def write_index ( docs ) : <TAB> for chunk in web. group ( docs, 1000 ) : <TAB> <TAB> chunk = list ( chunk ) <TAB> <TAB> thing_ids = [ doc [ ""id"" ] for doc in chunk ] <TAB> <TAB> t = db. transaction ( ) <TAB> <TAB> db. query ( ""DELETE FROM work_ref WHERE thing_id IN $thing_ids"", vars = locals ( ) ) <TAB> <TAB> data = [ ] <TAB> <TAB> for doc in chunk : <TAB> <TAB> <TAB> thing_id = doc [ ""id"" ] <TAB> <TAB> <TAB> type = doc [ ""type"" ] [ ""key"" ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> for name, value in doc [ ""_refs"" ] : <TAB> <TAB> <TAB> <TAB> <TAB> key_id = get_property_id ( type, name ) <TAB> <TAB> <TAB> <TAB> <TAB> data. append ( dict ( thing_id = thing_id, key_id = key_id, value = value ) ) <TAB> <TAB> if data : <TAB> <TAB> <TAB> db. multiple_insert ( ""work_ref"", data, seqname = False ) <TAB> <TAB> t. commit ( )",False,type == '/type/work',doc[_refs],0.6525618433952332
|
||
|
1640,"def question_vote ( request, question_id ) : <TAB> """"""I have this problem too."""""" <TAB> question = get_object_or_404 ( Question, pk = question_id, is_spam = False ) <TAB> if not question. editable : <TAB> <TAB> raise PermissionDenied <TAB> if not question. has_voted ( request ) : <TAB> <TAB> vote = QuestionVote ( question = question ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> vote. creator = request. user <TAB> <TAB> else : <TAB> <TAB> <TAB> vote. anonymous_id = request. anonymous. anonymous_id <TAB> <TAB> if not request. limited : <TAB> <TAB> <TAB> vote. save ( ) <TAB> <TAB> <TAB> if ""referrer"" in request. REQUEST : <TAB> <TAB> <TAB> <TAB> referrer = request. REQUEST. get ( ""referrer"" ) <TAB> <TAB> <TAB> <TAB> vote. add_metadata ( ""referrer"", referrer ) <TAB> <TAB> <TAB> <TAB> if referrer == ""search"" and ""query"" in request. REQUEST : <TAB> <TAB> <TAB> <TAB> <TAB> vote. add_metadata ( ""query"", request. REQUEST. get ( ""query"" ) ) <TAB> <TAB> <TAB> ua = request. META. get ( ""HTTP_USER_AGENT"" ) <TAB> <TAB> <TAB> if ua : <TAB> <TAB> <TAB> <TAB> vote. add_metadata ( ""ua"", ua ) <TAB> <TAB> <TAB> statsd. incr ( ""questions.votes.question"" ) <TAB> <TAB> if request. is_ajax ( ) : <TAB> <TAB> <TAB> tmpl = ""questions/includes/question_vote_thanks.html"" <TAB> <TAB> <TAB> form = _init_watch_form ( request ) <TAB> <TAB> <TAB> html = render_to_string ( <TAB> <TAB> <TAB> <TAB> tmpl, <TAB> <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB>",False,request.user.is_authenticated(),is_spam,0.6517141461372375
|
||
|
1641,"def __getitem__ ( self, k ) -> ""SimMemView"" : <TAB> if isinstance ( k, slice ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( ""Slices with strides are not supported"" ) <TAB> <TAB> elif k. start is None : <TAB> <TAB> <TAB> raise ValueError ( ""Must specify start index"" ) <TAB> <TAB> elif k. stop is not None : <TAB> <TAB> <TAB> raise ValueError ( ""Slices with stop index are not supported"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> addr = k. start <TAB> elif self. _type is not None and self. _type. _can_refine_int : <TAB> <TAB> return self. _type. _refine ( self, k ) <TAB> else : <TAB> <TAB> addr = k <TAB> return self. _deeper ( addr = addr )",False,k.step is not None,k.stop is not None,0.6621825695037842
|
||
|
1642,"def create_and_return_ids ( self, tags = None ) : <TAB> tags_list = [ ] <TAB> <TAB> if type ( tags ) is dict : <TAB> <TAB> for group, tag in tags. items ( ) : <TAB> <TAB> <TAB> group_id = tag_groups_model. get_or_create_by_name ( group ) <TAB> <TAB> <TAB> _id = self. get_or_create ( name = tag, group_id = group_id ) <TAB> <TAB> <TAB> tags_list. append ( _id ) <TAB> <TAB> if type ( tags ) is list : <TAB> <TAB> for t in tags : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> group, tag = t. split ( "":"" ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> <TAB> tag = t <TAB> <TAB> <TAB> <TAB> group = False <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> group_id = tag_groups_model. get_or_create_by_name ( group ) <TAB> <TAB> <TAB> <TAB> _id = self. get_or_create ( name = tag, group_id = group_id ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> _id = self. get_or_create_by_name ( name = tag ) <TAB> <TAB> <TAB> tags_list. append ( _id ) <TAB> return tags_list",False,group,group is not None,0.6836246252059937
|
||
|
1643,"def general ( metadata, value ) : <TAB> if metadata. get ( ""commands"" ) and value : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> v = quote ( value ) <TAB> <TAB> else : <TAB> <TAB> <TAB> v = value <TAB> <TAB> return u""{0} {1}"". format ( metadata [ ""commands"" ] [ 0 ], v ) <TAB> else : <TAB> <TAB> if not value : <TAB> <TAB> <TAB> return None <TAB> <TAB> el if<mask> : <TAB> <TAB> <TAB> return quote ( value ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return value",False,not metadata.get('nargs'),metadata.get('el') and (not metadata.get('el'),0.6477402448654175
|
||
|
1644,"def _pick ( self, cum ) : <TAB> if self. _isleaf ( ) : <TAB> <TAB> return self. bd [ 0 ], self. s <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return self. left. _pick ( cum ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return self. right. _pick ( cum - self. left. s )",False,cum < self.left.s,self.abs(cum),0.667629599571228
|
||
|
1645,"def _key_response_head ( self, bucket_name, query, key_name, headers ) : <TAB> response_headers = { } <TAB> version_id = query. get ( ""versionId"", [ None ] ) [ 0 ] <TAB> part_number = query. get ( ""partNumber"", [ None ] ) [ 0 ] <TAB> if part_number : <TAB> <TAB> part_number = int ( part_number ) <TAB> if_modified_since = headers. get ( ""If-Modified-Since"", None ) <TAB> if_match = headers. get ( ""If-Match"", None ) <TAB> if_none_match = headers. get ( ""If-None-Match"", None ) <TAB> if_unmodified_since = headers. get ( ""If-Unmodified-Since"", None ) <TAB> key = self. backend. get_object ( <TAB> <TAB> bucket_name, key_name, version_id = version_id, part_number = part_number <TAB> ) <TAB> if key : <TAB> <TAB> response_headers. update ( key. metadata ) <TAB> <TAB> response_headers. update ( key. response_dict ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if_unmodified_since = str_to_rfc_1123_datetime ( if_unmodified_since ) <TAB> <TAB> <TAB> if key. last_modified > if_unmodified_since : <TAB> <TAB> <TAB> <TAB> return 412, response_headers, """" <TAB> <TAB> if if_match and key. etag!= if_match : <TAB> <TAB> <TAB> return 412, response_headers, """" <TAB> <TAB> if if_modified_since : <TAB> <TAB> <TAB> if_modified_since = str_to_rfc_1123_datetime ( if_modified_since ) <TAB> <TAB> <TAB> if key. last_modified < if_modified_since : <TAB> <TAB> <TAB> <TAB> return 304, response_headers, ""Not Modified"" <TAB> <TAB> if if_none_match and key. etag == if_none",True,if_unmodified_since,if_unmodified_since,0.6518108248710632
|
||
|
1646,"def draw_markers ( self, gc, marker_path, marker_trans, path, trans, rgbFace = None ) : <TAB> write = self. _svgwriter. write <TAB> key = self. _convert_path ( marker_path, marker_trans + Affine2D ( ). scale ( 1.0, - 1.0 ) ) <TAB> name = self. _markers. get ( key ) <TAB> if name is None : <TAB> <TAB> name = ""m%s"" % md5 ( key ). hexdigest ( ) <TAB> <TAB> write ( '<defs><path id=""%s"" d=""%s""/></defs>\n' % ( name, key ) ) <TAB> <TAB> self. _markers [ key ] = name <TAB> clipid = self. _get_gc_clip_svg ( gc ) <TAB> if clipid is None : <TAB> <TAB> clippath = """" <TAB> else : <TAB> <TAB> clippath = 'clip-path=""url(#%s)""' % clipid <TAB> write ( ""<g %s>"" % clippath ) <TAB> trans_and_flip = self. _make_flip_transform ( trans ) <TAB> tpath = trans_and_flip. transform_path ( path ) <TAB> for vertices, code in tpath. iter_segments ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> x, y = vertices [ - 2 : ] <TAB> <TAB> <TAB> details = 'xlink:href=""#%s"" x=""%f"" y=""%f""' % ( name, x, y ) <TAB> <TAB> <TAB> style = self. _get_style ( gc, rgbFace ) <TAB> <TAB> <TAB> self. _svgwriter. write ( '<use style=""%s"" %s/>\n' % ( style, details ) ) <TAB> write ( ""</g>"" )",False,len(vertices),code.startswith('<') and vertices[-2:] == 'true',0.6615938544273376
|
||
|
1647,"def scan ( self ) : <TAB> """"""Scan source and grab tokens."""""" <TAB> self. pre_scan ( ) <TAB> token = None <TAB> end = len ( self. source ) <TAB> while self. pos < end : <TAB> <TAB> best_pat = None <TAB> <TAB> best_pat_len = 0 <TAB> <TAB> <TAB> <TAB> for p, regexp in self. patterns : <TAB> <TAB> <TAB> m = regexp. match ( self. source, self. pos ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> best_pat = p <TAB> <TAB> <TAB> <TAB> best_pat_len = len ( m. group ( 0 ) ) <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> if best_pat is None : <TAB> <TAB> <TAB> raise SyntaxError ( <TAB> <TAB> <TAB> <TAB> ""SyntaxError[@char {0}: {1}]"". format ( self. pos, ""Bad token."" ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> if best_pat in self. ignore : <TAB> <TAB> <TAB> self. pos += best_pat_len <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> token = ( <TAB> <TAB> <TAB> best_pat, <TAB> <TAB> <TAB> self. source [ self. pos : self. pos + best_pat_len ], <TAB> <TAB> <TAB> self. pos, <TAB> <TAB> <TAB> self. pos + best_pat_len, <TAB> <TAB> ) <TAB> <TAB> self. pos = token [ - 1 ] <TAB> <TAB> self. tokens. append ( token )",False,m,m is not None,0.7003533840179443
|
||
|
1648,"def get_version ( self ) : <TAB> fh = self. _data_file ( ADJ ) <TAB> for line in fh : <TAB> <TAB> match = re. search ( r""WordNet (\d+\.\d+) Copyright"", line ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> version = match. group ( 1 ) <TAB> <TAB> <TAB> fh. seek ( 0 ) <TAB> <TAB> <TAB> return version",False,match is not None,match,0.6580902934074402
|
||
|
1649,"def get_recipe_env ( self, arch = None, with_flags_in_cc = True ) : <TAB> env = super ( PythonRecipe, self ). get_recipe_env ( arch, with_flags_in_cc ) <TAB> env [ ""PYTHONNOUSERSITE"" ] = ""1"" <TAB> <TAB> <TAB> env [ ""LANG"" ] = ""en_GB.UTF-8"" <TAB> if not self. call_hostpython_via_targetpython : <TAB> <TAB> python_name = self. ctx. python_recipe. name <TAB> <TAB> env [ ""CFLAGS"" ] += "" -I{}"". format ( self. ctx. python_recipe. include_root ( arch. arch ) ) <TAB> <TAB> env [ ""LDFLAGS"" ] += "" -L{} -lpython{}"". format ( <TAB> <TAB> <TAB> self. ctx. python_recipe. link_root ( arch. arch ), <TAB> <TAB> <TAB> self. ctx. python_recipe. major_minor_version_string, <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> env [ ""LDFLAGS"" ] += ""m"" <TAB> <TAB> hppath = [ ] <TAB> <TAB> hppath. append ( join ( dirname ( self. hostpython_location ), ""Lib"" ) ) <TAB> <TAB> hppath. append ( join ( hppath [ 0 ], ""site-packages"" ) ) <TAB> <TAB> builddir = join ( dirname ( self. hostpython_location ), ""build"" ) <TAB> <TAB> if exists ( builddir ) : <TAB> <TAB> <TAB> hppath += [ <TAB> <TAB> <TAB> <TAB> join ( builddir, d ) for d in listdir ( builddir ) if isdir ( join ( builddir, d ) ) <TAB> <TAB> <TAB> ] <TAB> <TAB> if len ( hppath ) > 0 : <TAB> <TAB> <TAB> if ""PYTHONPATH"" in env : <TAB> <TAB> <TAB> <",False,python_name == 'python3',"hasattr(self, 'hostpython_location')",0.6552754044532776
|
||
|
1650,"def on_accounts ( accounts, owner ) : <TAB> log. debug ( ""Got Accounts"" ) <TAB> selected_iter = None <TAB> for account in accounts : <TAB> <TAB> acc_iter = self. accounts. append ( ) <TAB> <TAB> self. accounts. set_value ( acc_iter, 0, account [ ""username"" ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> selected_iter = acc_iter <TAB> self. builder. get_object ( ""OwnerCombobox"" ). set_active_iter ( selected_iter )",False,account['username'] == owner,owner,0.661219596862793
|
||
|
1651,"def _get_columns_text ( <TAB> self, context : Context, candidate : Candidate ) -> typing. Tuple [ str, Highlights ] : <TAB> texts : typing. List [ str ] = [ ] <TAB> variable_texts : typing. List [ str ] = [ ] <TAB> ret_highlights : typing. List [ typing. Tuple [ str, int, int ] ] = [ ] <TAB> start = 0 <TAB> for column in self. _columns : <TAB> <TAB> if self. _ns > 0 : <TAB> <TAB> <TAB> column. start = start <TAB> <TAB> if column. is_stop_variable : <TAB> <TAB> <TAB> if variable_texts : <TAB> <TAB> <TAB> <TAB> variable_texts. append ( """" ) <TAB> <TAB> <TAB> ( text, highlights ) = column. get_with_variable_text ( <TAB> <TAB> <TAB> <TAB> context, "" "". join ( variable_texts ), candidate <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> texts. append ( text ) <TAB> <TAB> <TAB> ret_highlights += highlights <TAB> <TAB> <TAB> variable_texts = [ ] <TAB> <TAB> else : <TAB> <TAB> <TAB> if column. has_get_with_highlights : <TAB> <TAB> <TAB> <TAB> ( text, highlights ) = column. get_with_highlights ( context, candidate ) <TAB> <TAB> <TAB> <TAB> ret_highlights += highlights <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> text = column. get ( context, candidate ) <TAB> <TAB> <TAB> if column. is_start_variable or column. is_within_variable : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> variable_texts. append ( text ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> texts. append ( text ) <TAB",False,text,variable_texts,0.6898124814033508
|
||
|
1652,"def wait_connect ( module, pid, timeout = 10 ) : <TAB> module. success ( ""waiting for a connection from the DLL..."" ) <TAB> for x in xrange ( timeout ) : <TAB> <TAB> c = has_proc_migrated ( module. client, pid ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> module. success ( ""got a connection from migrated DLL!"" ) <TAB> <TAB> <TAB> c. pupsrv. move_id ( c, module. client ) <TAB> <TAB> <TAB> time. sleep ( 0.5 ) <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> module. success ( ""exiting old connection"" ) <TAB> <TAB> <TAB> <TAB> module. client. conn. exit ( ) <TAB> <TAB> <TAB> <TAB> module. success ( ""exited old connection"" ) <TAB> <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> break <TAB> <TAB> time. sleep ( 1 )",True,c,c,0.6910111308097839
|
||
|
1653,"def get_first_film ( soup, section, year = None, session = None ) : <TAB> tag_part = SectionsParts [ section ] <TAB> tag = None <TAB> headers = soup. find ( ""div"", ""search-result"" ). find_all ( ""h2"" ) <TAB> for header in headers : <TAB> <TAB> if tag_part in header. text : <TAB> <TAB> <TAB> tag = header <TAB> <TAB> <TAB> break <TAB> if not tag : <TAB> <TAB> return <TAB> url = None <TAB> url = SITE_DOMAIN + tag. findNext ( ""ul"" ). find ( ""li"" ). div. a. get ( ""href"" ) <TAB> for t in tag. findNext ( ""ul"" ). findAll ( ""li"" ) : <TAB> <TAB> if isinstance ( t, NavigableString ) or not t. div : <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> url = SITE_DOMAIN + t. div. a. get ( ""href"" ) <TAB> <TAB> <TAB> break <TAB> return Film. from_url ( url, session = session )",False,str(year) in t.div.a.string,url is None,0.6508709192276001
|
||
|
1654,"def update_topic_attr_as_not ( modeladmin, request, queryset, attr ) : <TAB> for topic in queryset : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> topic. sticky = not topic. sticky <TAB> <TAB> elif attr == ""closed"" : <TAB> <TAB> <TAB> topic. closed = not topic. closed <TAB> <TAB> elif attr == ""hidden"" : <TAB> <TAB> <TAB> topic. hidden = not topic. hidden <TAB> <TAB> topic. save ( )",False,attr == 'sticky',attr == 'stst',0.6646889448165894
|
||
|
1655,"def visit_Constant ( self, node ) : <TAB> value = node. value <TAB> type_name = _const_node_type_names. get ( type ( value ) ) <TAB> if type_name is None : <TAB> <TAB> for cls, name in _const_node_type_names. items ( ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> type_name = name <TAB> <TAB> <TAB> <TAB> break <TAB> if type_name is not None : <TAB> <TAB> method = ""visit_"" + type_name <TAB> <TAB> try : <TAB> <TAB> <TAB> visitor = getattr ( self, method ) <TAB> <TAB> except AttributeError : <TAB> <TAB> <TAB> pass <TAB> <TAB> else : <TAB> <TAB> <TAB> import warnings <TAB> <TAB> <TAB> warnings. warn ( <TAB> <TAB> <TAB> <TAB> f""{method} is deprecated; add visit_Constant"", <TAB> <TAB> <TAB> <TAB> PendingDeprecationWarning, <TAB> <TAB> <TAB> <TAB> 2, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> return visitor ( node ) <TAB> return self. generic_visit ( node )",False,"isinstance(value, cls)",cls == node.type,0.6539881825447083
|
||
|
1656,"def TryMerge ( self, d ) : <TAB> while d. avail ( ) > 0 : <TAB> <TAB> tt = d. getVarInt32 ( ) <TAB> <TAB> if tt == 8 : <TAB> <TAB> <TAB> self. set_mime_type ( d. getVarInt32 ( ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. set_quality ( d. getVarInt32 ( ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if tt == 0 : <TAB> <TAB> <TAB> raise ProtocolBuffer. ProtocolBufferDecodeError <TAB> <TAB> d. skipData ( tt )",False,tt == 16,tt == 8,0.6876143217086792
|
||
|
1657,"def search_deep_keys ( search_text, arm_dict, path ) : <TAB> """"""Search deep for keys and get their values"""""" <TAB> keys = [ ] <TAB> if isinstance ( arm_dict, dict ) : <TAB> <TAB> for key in arm_dict : <TAB> <TAB> <TAB> pathprop = path [ : ] <TAB> <TAB> <TAB> pathprop. append ( key ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> pathprop. append ( arm_dict [ key ] ) <TAB> <TAB> <TAB> <TAB> keys. append ( pathprop ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> pathprop = pathprop [ : - 1 ] <TAB> <TAB> <TAB> if isinstance ( arm_dict [ key ], dict ) : <TAB> <TAB> <TAB> <TAB> keys. extend ( <TAB> <TAB> <TAB> <TAB> <TAB> ContextParser. search_deep_keys ( search_text, arm_dict [ key ], pathprop ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> elif isinstance ( arm_dict [ key ], list ) : <TAB> <TAB> <TAB> <TAB> for index, item in enumerate ( arm_dict [ key ] ) : <TAB> <TAB> <TAB> <TAB> <TAB> pathproparr = pathprop [ : ] <TAB> <TAB> <TAB> <TAB> <TAB> pathproparr. append ( index ) <TAB> <TAB> <TAB> <TAB> <TAB> keys. extend ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ContextParser. search_deep_keys ( search_text, item, pathproparr ) <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> elif isinstance ( arm_dict, list ) : <TAB> <TAB> for index, item in enumerate ( arm_dict ) : <TAB> <TAB> <TAB> pathprop = path [ : ] <TAB> <TAB>",False,key == search_text,"isinstance(arm_dict[key], dict)",0.6612805128097534
|
||
|
1658,"def expr ( self, arg_type ) : <TAB> pass <TAB> self. prec0_expr ( arg_type ) <TAB> while True : <TAB> <TAB> if self. LA ( 1 ) >= EQ and self. LA ( 1 ) <= LE : <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> la1 = self. LA ( 1 ) <TAB> <TAB> <TAB> if False : <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> elif la1 and la1 in [ EQ ] : <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> <TAB> self. match ( EQ ) <TAB> <TAB> <TAB> <TAB> op = struct. pack ( ""B"", ptgEQ ) <TAB> <TAB> <TAB> elif la1 and la1 in [ NE ] : <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> <TAB> self. match ( NE ) <TAB> <TAB> <TAB> <TAB> op = struct. pack ( ""B"", ptgNE ) <TAB> <TAB> <TAB> elif la1 and la1 in [ GT ] : <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> <TAB> self. match ( GT ) <TAB> <TAB> <TAB> <TAB> op = struct. pack ( ""B"", ptgGT ) <TAB> <TAB> <TAB> elif la1 and la1 in [ LT ] : <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> <TAB> self. match ( LT ) <TAB> <TAB> <TAB> <TAB> op = struct. pack ( ""B"", ptgLT ) <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> <TAB> self. match ( GE ) <TAB> <TAB> <TAB> <TAB> op = struct. pack ( ""B"", ptgGE ) <TAB> <TAB> <TAB> elif la1 and la1 in [ LE ] : <",False,la1 and la1 in [GE],ge in [GE],0.6673319339752197
|
||
|
1659,"def _load_config ( ) : <TAB> from thirdparty. configobj import ConfigObj <TAB> from thirdparty. validate import Validator <TAB> rcfileloc = osp. join ( osp. expanduser ( ""~/.cgtrc"" ) ) <TAB> specfilename = osp. join ( get_cgt_src_root ( ), ""cgtrc_spec.ini"" ) <TAB> config = ConfigObj ( rcfileloc, configspec = specfilename ) <TAB> val = Validator ( ) <TAB> test = config. validate ( val, preserve_errors = True ) <TAB> if test is not True : <TAB> <TAB> for ( k, v ) in test. items ( ) : <TAB> <TAB> <TAB> if v is not True : <TAB> <TAB> <TAB> <TAB> utils. error ( ""%s: %s in %s"" % ( k, v. message, rcfileloc ) ) <TAB> <TAB> raise ValueError <TAB> envflags = os. getenv ( ""CGT_FLAGS"" ) <TAB> if envflags : <TAB> <TAB> pairs = envflags. split ( "","" ) <TAB> <TAB> for pair in pairs : <TAB> <TAB> <TAB> lhs, rhs = pair. split ( ""="" ) <TAB> <TAB> <TAB> assert lhs in config, ""Unrecognized config option %s provided"" % lhs <TAB> <TAB> <TAB> oldrhs = config [ lhs ] <TAB> <TAB> <TAB> config [ lhs ] = rhs <TAB> <TAB> <TAB> assert isinstance ( <TAB> <TAB> <TAB> <TAB> rhs, ( str, bool, int, float, list ) <TAB> <TAB> <TAB> ), ""You set %s=%s but rhs is invalid"" % ( lhs, rhs ) <TAB> <TAB> <TAB> if isinstance ( oldrhs, str ) : <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> elif isinstance ( oldrhs, bool ) : <TAB> <TAB> <TAB> <TAB> config [ lhs ] = config. as_bool ( lhs ) <TAB> <TAB> <TAB> elif isinstance ( oldrhs, int ) : <TAB> <TAB> <TAB",False,"isinstance(oldrhs, list)",lhs is not None,0.6598580479621887
|
||
|
1660,"def nspawn_params_for_blockdev_access ( <TAB> args : CommandLineArguments, loopdev : str ) -> List [ str ] : <TAB> params = [ <TAB> <TAB> f""--bind-ro={loopdev}"", <TAB> <TAB> f""--bind-ro=/dev/block"", <TAB> <TAB> f""--bind-ro=/dev/disk"", <TAB> <TAB> f""--property=DeviceAllow={loopdev}"", <TAB> ] <TAB> for partno in ( <TAB> <TAB> args. esp_partno, <TAB> <TAB> args. bios_partno, <TAB> <TAB> args. root_partno, <TAB> <TAB> args. xbootldr_partno, <TAB> ) : <TAB> <TAB> if partno is not None : <TAB> <TAB> <TAB> p = partition ( loopdev, partno ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> params += [ f""--bind-ro={p}"", f""--property=DeviceAllow={p}"" ] <TAB> return params",False,os.path.exists(p),p is not None,0.6503428220748901
|
||
|
1661,"def handle ( self, filename, fields = """", delimiter = b"","", ** options ) : <TAB> fields = [ field. strip ( ) for field in fields. split ( "","" ) ] <TAB> with open ( filename, ""rb"" ) as f : <TAB> <TAB> for row in UnicodeReader ( f, delimiter = delimiter ) : <TAB> <TAB> <TAB> data = dict ( zip ( fields, row ) ) <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> dev_id = int ( data [ ""id"" ] ) <TAB> <TAB> <TAB> except ( ValueError, KeyError ) : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if not dev_id : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> dev = Device. objects. get ( id = dev_id ) <TAB> <TAB> <TAB> except Device. DoesNotExist : <TAB> <TAB> <TAB> <TAB> sys. stderr. write ( ""Device with id=%r doesn't exist!\n"" % dev_id ) <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> for field, value in data. iteritems ( ) : <TAB> <TAB> <TAB> <TAB> if field in ( ""id"", """" ) : <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> value = None <TAB> <TAB> <TAB> <TAB> if value is None and field in ( ""remarks"", ) : <TAB> <TAB> <TAB> <TAB> <TAB> value = """" <TAB> <TAB> <TAB> <TAB> print ( ""%r.%s = %r"" % ( dev, field, value ) ) <TAB> <TAB> <TAB> <TAB> setattr ( dev, field, value ) <TAB> <TAB> <TAB> <TAB> dev. save ( priority = 50 )",False,"value in ('None', '')","field in (undefined, False)",0.6525683403015137
|
||
|
1662,"def serve ( q : Q ) : <TAB> if q. client. plot_added : <TAB> <TAB> example = q. page [ ""example"" ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> example. title = ( ""Plot (Log Scale)"", ) <TAB> <TAB> <TAB> example. specification = spec_log_scale <TAB> <TAB> <TAB> example. commands = [ linear_scale_command ] <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> example. title = ( ""Plot (Linear Scale)"", ) <TAB> <TAB> <TAB> example. specification = spec_linear_scale <TAB> <TAB> <TAB> example. commands = [ log_scale_command ] <TAB> else : <TAB> <TAB> q. page [ ""example"" ] = ui. vega_card ( <TAB> <TAB> <TAB> box = ""1 1 2 4"", <TAB> <TAB> <TAB> title = ""Plot (Linear Scale)"", <TAB> <TAB> <TAB> specification = spec_linear_scale, <TAB> <TAB> <TAB> data = plot_data, <TAB> <TAB> <TAB> commands = [ log_scale_command ], <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> q. client. plot_added = True <TAB> await q. page. save ( )",False,q.args.to_log_scale,q.client.plot_added,0.6536799073219299
|
||
|
1663,"def get_files ( d ) : <TAB> res = [ ] <TAB> for p in glob. glob ( os. path. join ( d, ""*"" ) ) : <TAB> <TAB> if not p : <TAB> <TAB> <TAB> continue <TAB> <TAB> ( pth, fname ) = os. path. split ( p ) <TAB> <TAB> if fname == ""output"" : <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> if fname [ - 4 : ] == "".pyc"" : <TAB> <TAB> <TAB> continue <TAB> <TAB> if os. path. isdir ( p ) : <TAB> <TAB> <TAB> get_dir ( p ) <TAB> <TAB> else : <TAB> <TAB> <TAB> res. append ( p ) <TAB> return res",False,fname == 'PureMVC_Python_1_0',fname[-4:] == '.pyc',0.6494544148445129
|
||
|
1664,"def get ( self ) : <TAB> if ""twitter"" in self. get_user_social ( self. current_user. id ) : <TAB> <TAB> enabled = self. get_argument ( ""enabled"", ""a"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. redirect ( ""/account/setting"" ) <TAB> <TAB> <TAB> return <TAB> <TAB> q = self. db. query ( Social ). filter_by ( service = ""twitter"" ) <TAB> <TAB> t = q. filter_by ( user_id = self. current_user. id ). first ( ) <TAB> <TAB> t. enabled = enabled <TAB> <TAB> self. db. add ( t ) <TAB> <TAB> self. db. commit ( ) <TAB> <TAB> self. cache. delete ( ""social:%s"" % self. current_user. id ) <TAB> <TAB> self. redirect ( ""/account/setting"" ) <TAB> <TAB> return <TAB> if self. get_argument ( ""oauth_token"", None ) : <TAB> <TAB> self. get_authenticated_user ( self. _on_auth ) <TAB> <TAB> return <TAB> self. authorize_redirect ( )",False,"enabled not in ('y', 'n')",enabled,0.6513879895210266
|
||
|
1665,"def _get_nlu_target_format ( export_path : Text ) -> Text : <TAB> guessed_format = loading. guess_format ( export_path ) <TAB> if guessed_format not in { MARKDOWN, RASA, RASA_YAML } : <TAB> <TAB> if rasa. shared. data. is_likely_json_file ( export_path ) : <TAB> <TAB> <TAB> guessed_format = RASA <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> guessed_format = MARKDOWN <TAB> <TAB> elif rasa. shared. data. is_likely_yaml_file ( export_path ) : <TAB> <TAB> <TAB> guessed_format = RASA_YAML <TAB> return guessed_format",True,rasa.shared.data.is_likely_markdown_file(export_path),rasa.shared.data.is_likely_markdown_file(export_path),0.6502915024757385
|
||
|
1666,"def _cmd_add ( self, ctx, command ) : <TAB> table_name = command. args [ 0 ] <TAB> record_id = command. args [ 1 ] <TAB> column = command. args [ 2 ] <TAB> column_key_value_strings = [ ] <TAB> for value in command. args [ 3 : ] : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> column_key_value_strings. append ( ""%s:%s"" % ( column, value ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> column_key_value_strings. append ( ""%s=%s"" % ( column, value ) ) <TAB> table_schema = self. schema. tables [ table_name ] <TAB> column_values = [ <TAB> <TAB> ctx. parse_column_key_value ( table_schema, column_key_value_string ) <TAB> <TAB> for column_key_value_string in column_key_value_strings <TAB> ] <TAB> self. _add ( ctx, table_name, record_id, column_values )",False,'=' in value,"isinstance(value, str)",0.6678308248519897
|
||
|
1667,"def callback ( actions, form, tablename = None ) : <TAB> if actions : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> actions = actions. get ( tablename, [ ] ) <TAB> <TAB> if not isinstance ( actions, ( list, tuple ) ) : <TAB> <TAB> <TAB> actions = [ actions ] <TAB> <TAB> [ action ( form ) for action in actions ]",False,"tablename and isinstance(actions, dict)",tabname,0.6579087972640991
|
||
|
1668,"def processMovie ( self, atom ) : <TAB> for field in atom : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. processTrack ( field [ ""track"" ] ) <TAB> <TAB> if ""movie_hdr"" in field : <TAB> <TAB> <TAB> self. processMovieHeader ( field [ ""movie_hdr"" ] )",True,'track' in field,'track' in field,0.6639220118522644
|
||
|
1669,"def replaceRackPosition ( self, rackPosition, mod ) : <TAB> listPositions = [ ] <TAB> for currPos in range ( len ( self ) ) : <TAB> <TAB> currMod = self [ currPos ] <TAB> <TAB> if currMod. slot == mod. slot : <TAB> <TAB> <TAB> listPositions. append ( currPos ) <TAB> listPositions. sort ( ) <TAB> try : <TAB> <TAB> modListPosition = listPositions [ rackPosition ] <TAB> except IndexError : <TAB> <TAB> self. appendIgnoreEmpty ( mod ) <TAB> else : <TAB> <TAB> oldMod = self [ modListPosition ] <TAB> <TAB> if mod. isEmpty : <TAB> <TAB> <TAB> self. __toDummy ( modListPosition ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. __toModule ( modListPosition, mod ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if mod. isInvalid : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> self. __toDummy ( modListPosition ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> self. __toModule ( modListPosition, oldMod )",True,oldMod.isEmpty,oldMod.isEmpty,0.6644895076751709
|
||
|
1670,"def _check_load_coco_bbox ( coco, entry, min_object_area = 0, use_crowd = False ) : <TAB> """"""Check and load ground-truth labels"""""" <TAB> entry_id = entry [ ""id"" ] <TAB> <TAB> entry_id = [ entry_id ] if not isinstance ( entry_id, ( list, tuple ) ) else entry_id <TAB> ann_ids = coco. getAnnIds ( imgIds = entry_id, iscrowd = None ) <TAB> objs = coco. loadAnns ( ann_ids ) <TAB> <TAB> valid_objs = [ ] <TAB> width = entry [ ""width"" ] <TAB> height = entry [ ""height"" ] <TAB> for obj in objs : <TAB> <TAB> if obj [ ""area"" ] < min_object_area : <TAB> <TAB> <TAB> continue <TAB> <TAB> if obj. get ( ""ignore"", 0 ) == 1 : <TAB> <TAB> <TAB> continue <TAB> <TAB> is_crowd = obj. get ( ""iscrowd"", 0 ) <TAB> <TAB> if not use_crowd and is_crowd : <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> xmin, ymin, xmax, ymax = bbox_clip_xyxy ( <TAB> <TAB> <TAB> bbox_xywh_to_xyxy ( obj [ ""bbox"" ] ), width, height <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> cname = coco. loadCats ( obj [ ""category_id"" ] ) [ 0 ] [ ""name"" ] <TAB> <TAB> <TAB> valid_objs. append ( <TAB> <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> <TAB> ""xmin"" : xmin / width, <TAB> <TAB> <TAB> <TAB> <TAB> ""ymin"" : ymin / height, <TAB> <TAB> <TAB> <TAB> <TAB> ""xmax"" : xmax / width, <TAB>",False,obj['area'] > 0 and xmax > xmin and (ymax > ymin),obj.has_key('category_id'),0.6565530300140381
|
||
|
1671,"def table_entry ( mode1, bind_type1, mode2, bind_type2 ) : <TAB> with sock ( mode1 ) as sock1 : <TAB> <TAB> bind ( sock1, bind_type1 ) <TAB> <TAB> try : <TAB> <TAB> <TAB> with sock ( mode2 ) as sock2 : <TAB> <TAB> <TAB> <TAB> bind ( sock2, bind_type2 ) <TAB> <TAB> except OSError as exc : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return ""INUSE"" <TAB> <TAB> <TAB> elif exc. winerror == errno. WSAEACCES : <TAB> <TAB> <TAB> <TAB> return ""ACCESS"" <TAB> <TAB> <TAB> raise <TAB> <TAB> else : <TAB> <TAB> <TAB> return ""Success""",False,exc.winerror == errno.WSAEADDRINUSE,exc.winerror == errno.ENOENT,0.6603638529777527
|
||
|
1672,"def pretty ( self, n, comment = True ) : <TAB> if isinstance ( n, ( str, bytes, list, tuple, dict ) ) : <TAB> <TAB> r = repr ( n ) <TAB> <TAB> if not comment : <TAB> <TAB> <TAB> r = r. replace ( ""*/"", r""\x2a/"" ) <TAB> <TAB> return r <TAB> if not isinstance ( n, six. integer_types ) : <TAB> <TAB> return n <TAB> if isinstance ( n, constants. Constant ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return ""%s /* %s */"" % ( n, self. pretty ( int ( n ) ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return ""%s (%s)"" % ( n, self. pretty ( int ( n ) ) ) <TAB> elif abs ( n ) < 10 : <TAB> <TAB> return str ( n ) <TAB> else : <TAB> <TAB> return hex ( n )",False,comment,n < 0,0.6837930679321289
|
||
|
1673,"def __repr__ ( self ) : <TAB> <TAB> r_repr = [ ] <TAB> if len ( self ) > 0 : <TAB> <TAB> nb_col = len ( self [ 0 ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> r_repr. append ( self. headers ) <TAB> <TAB> else : <TAB> <TAB> <TAB> r_repr. append ( [ ""Field"" ] * nb_col ) <TAB> for r in self : <TAB> <TAB> r1_repr = [ ] <TAB> <TAB> for r1 in r : <TAB> <TAB> <TAB> if isinstance ( r1, bytes ) : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> r1 = r1. decode ( ""utf-8"" ) <TAB> <TAB> <TAB> <TAB> except UnicodeDecodeError : <TAB> <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> r1 = repr ( r1 ) <TAB> <TAB> <TAB> r1_repr. append ( r1 ) <TAB> <TAB> r_repr. append ( r1_repr ) <TAB> <TAB> cs = list ( zip ( * r_repr ) ) <TAB> c_ws = [ max ( len ( value ) for value in c ) for c in cs ] <TAB> line = [ ""-"" * w for w in c_ws ] <TAB> r_repr. insert ( 1, line ) <TAB> r_repr. append ( line ) <TAB> format = "" | "". join ( [ ""%%-%ds"" % w for w in c_ws ] ) <TAB> <TAB> result = [ ( format % tuple ( r ) ) for r in r_repr ] <TAB> return ""\n"". join ( result )",False,self.headers is not None and len(self.headers) == nb_col,nb_col > 0,0.6543200016021729
|
||
|
1674,"def __init__ ( self, filename ) : <TAB> DatasetArrays. __init__ ( self, filename ) <TAB> self. filename = filename <TAB> self. path = filename <TAB> votable = astropy. io. votable. parse ( self. filename ) <TAB> self. first_table = votable. get_first_table ( ) <TAB> self. description = self. first_table. description <TAB> for field in self. first_table. fields : <TAB> <TAB> name = field. name <TAB> <TAB> data = self. first_table. array [ name ] <TAB> <TAB> type = self. first_table. array [ name ]. dtype <TAB> <TAB> clean_name = _python_save_name ( name, self. columns. keys ( ) ) <TAB> <TAB> if field. ucd : <TAB> <TAB> <TAB> self. ucds [ clean_name ] = field. ucd <TAB> <TAB> if field. unit : <TAB> <TAB> <TAB> unit = _try_unit ( field. unit ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. units [ clean_name ] = unit <TAB> <TAB> if field. description : <TAB> <TAB> <TAB> self. descriptions [ clean_name ] = field. description <TAB> <TAB> if type. kind in ""fiubSU"" : <TAB> <TAB> <TAB> self. add_column ( clean_name, data ) <TAB> <TAB> if type. kind == ""O"" : <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> ""column %r is of unsupported object type, will try to convert it to string"" <TAB> <TAB> <TAB> <TAB> % ( name, ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> data = data. astype ( ""S"" ) <TAB> <TAB> <TAB> <TAB> self. add_column ( name, data ) <TAB> <TAB> <TAB> except Exception as e : <TAB",True,unit,unit,0.6909773945808411
|
||
|
1675,"def forward ( <TAB> self, <TAB> img_feats : Tensor, <TAB> question_feats : Tensor, <TAB> actions_in : Tensor, <TAB> action_lengths : Tensor, <TAB> hidden : bool = False, ) -> Union [ Tuple [ Tensor, Tensor ], Tuple [ Tensor, Tensor, Tensor ] ] : <TAB> T = False <TAB> if self. image_input is True : <TAB> <TAB> N, T, _ = img_feats. size ( ) <TAB> <TAB> input_feats = img_feats <TAB> if self. question_input is True : <TAB> <TAB> N, D = question_feats. size ( ) <TAB> <TAB> question_feats = question_feats. view ( N, 1, D ) <TAB> <TAB> if T is False : <TAB> <TAB> <TAB> T = actions_in. size ( 1 ) <TAB> <TAB> question_feats = question_feats. repeat ( 1, T, 1 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> input_feats = question_feats <TAB> <TAB> else : <TAB> <TAB> <TAB> input_feats = torch. cat ( [ input_feats, question_feats ], 2 ) <TAB> if self. action_input is True : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> input_feats = self. action_embed ( actions_in ) <TAB> <TAB> else : <TAB> <TAB> <TAB> input_feats = torch. cat ( <TAB> <TAB> <TAB> <TAB> [ input_feats, self. action_embed ( actions_in. long ( ) ) ], 2 <TAB> <TAB> <TAB> ) <TAB> packed_input_feats = pack_padded_sequence ( <TAB> <TAB> input_feats, action_lengths, batch_first = True <TAB> ) <TAB> packed_output, hidden = self. rnn ( packed_input_feats ) <TAB> rnn_output, _ = pad_packed_sequence ( packed_output, batch_first = True ) <TAB> output = self. decoder ( <TAB> <TAB> rnn_output. contiguous (",False,len(input_feats) == 0,hidden,0.6537646055221558
|
||
|
1676,"def build ( opt ) : <TAB> dpath = os. path. join ( opt [ ""datapath"" ], ""QA-ZRE"" ) <TAB> version = None <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> <TAB> <TAB> build_data. mark_done ( dpath, version_string = version )",False,build_data.built(dpath),dpath in RESOURCES,0.6493850350379944
|
||
|
1677,"def _executables_in_windows ( path ) : <TAB> if not os. path. isdir ( path ) : <TAB> <TAB> return <TAB> extensions = builtins. __xonsh__. env [ ""PATHEXT"" ] <TAB> if PYTHON_VERSION_INFO < ( 3, 5, 0 ) : <TAB> <TAB> for fname in os. listdir ( path ) : <TAB> <TAB> <TAB> fpath = os. path. join ( path, fname ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> base_name, ext = os. path. splitext ( fname ) <TAB> <TAB> <TAB> <TAB> if ext. upper ( ) in extensions : <TAB> <TAB> <TAB> <TAB> <TAB> yield fname <TAB> else : <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 is_file : <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",False,os.path.exists(fpath) and (not os.path.isdir(fpath)),os.path.isdir(fpath),0.646652340888977
|
||
|
1678,"def printStatus ( self ) : <TAB> try : <TAB> <TAB> names = sorted ( self. buildRequests. keys ( ) ) <TAB> <TAB> for n in names : <TAB> <TAB> <TAB> if n not in self. outstanding : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> code, text = self. results [ n ] <TAB> <TAB> <TAB> <TAB> t = builder. Results [ code ] <TAB> <TAB> <TAB> <TAB> if text : <TAB> <TAB> <TAB> <TAB> <TAB> t += "" (%s)"" % "" "". join ( text ) <TAB> <TAB> <TAB> elif self. builds [ n ] : <TAB> <TAB> <TAB> <TAB> t = self. currentStep [ n ] or ""building"" <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> t += "" [ETA %ds]"" % ( self. ETA [ n ] - now ( ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> t = ""no build"" <TAB> <TAB> <TAB> self. announce ( ""%s: %s"" % ( n, t ) ) <TAB> <TAB> self. announce ( """" ) <TAB> except Exception : <TAB> <TAB> log. err ( None, ""printing status"" )",True,self.ETA[n],self.ETA[n],0.6654027104377747
|
||
|
1679,"def main ( self ) -> None : <TAB> if self. _pool is None : <TAB> <TAB> self. _pool = await create_pool ( self. redis_settings ) <TAB> logger. info ( <TAB> <TAB> ""Starting worker for %d functions: %s"", <TAB> <TAB> len ( self. functions ), <TAB> <TAB> "", "". join ( self. functions ), <TAB> ) <TAB> await log_redis_info ( self. pool, logger. info ) <TAB> self. ctx [ ""redis"" ] = self. pool <TAB> if self. on_startup : <TAB> <TAB> await self. on_startup ( self. ctx ) <TAB> async for _ in poll ( self. poll_delay_s ) : <TAB> <TAB> await self. _poll_iteration ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if 0 <= self. max_burst_jobs <= self. _jobs_started ( ) : <TAB> <TAB> <TAB> <TAB> await asyncio. gather ( * self. tasks ) <TAB> <TAB> <TAB> <TAB> return None <TAB> <TAB> <TAB> queued_jobs = await self. pool. zcard ( self. queue_name ) <TAB> <TAB> <TAB> if queued_jobs == 0 : <TAB> <TAB> <TAB> <TAB> await asyncio. gather ( * self. tasks ) <TAB> <TAB> <TAB> <TAB> return None",False,self.burst,self.max_burst_jobs > 0,0.6701306104660034
|
||
|
1680,"def endElement ( self, name, value, connection ) : <TAB> if name == ""CreationTime"" : <TAB> <TAB> try : <TAB> <TAB> <TAB> self. creation_time = datetime. strptime ( value, ""%Y-%m-%dT%H:%M:%SZ"" ) <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> self. creation_time = datetime. strptime ( value, ""%Y-%m-%dT%H:%M:%S.%fZ"" ) <TAB> elif name == ""Description"" : <TAB> <TAB> self. description = value <TAB> elif name == ""DisableRollback"" : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. disable_rollback = True <TAB> <TAB> else : <TAB> <TAB> <TAB> self. disable_rollback = False <TAB> elif name == ""StackId"" : <TAB> <TAB> self. stack_id = value <TAB> elif name == ""StackName"" : <TAB> <TAB> self. stack_name = value <TAB> elif name == ""StackStatus"" : <TAB> <TAB> self. stack_status = value <TAB> elif name == ""StackStatusReason"" : <TAB> <TAB> self. stack_status_reason = value <TAB> elif name == ""TimeoutInMinutes"" : <TAB> <TAB> self. timeout_in_minutes = int ( value ) <TAB> elif name == ""member"" : <TAB> <TAB> pass <TAB> else : <TAB> <TAB> setattr ( self, name, value )",False,str(value).lower() == 'true',name == 'Enablerollback',0.6523566246032715
|
||
|
1681,"def tz_from_string ( _option, _opt_str, value, parser ) : <TAB> """"""Stores a tzinfo object from a string"""""" <TAB> if value is not None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> valarray = [ value [ i : i + 2 ] for i in range ( 1, len ( value ), 2 ) ] <TAB> <TAB> <TAB> multipliers = [ 3600, 60 ] <TAB> <TAB> <TAB> offset = 0 <TAB> <TAB> <TAB> for i in range ( min ( len ( valarray ), len ( multipliers ) ) ) : <TAB> <TAB> <TAB> <TAB> offset += int ( valarray [ i ] ) * multipliers [ i ] <TAB> <TAB> <TAB> if value [ 0 ] == ""-"" : <TAB> <TAB> <TAB> <TAB> offset = - offset <TAB> <TAB> <TAB> timezone = OffsetTzInfo ( offset = offset ) <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if tz_pytz : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> timezone = pytz. timezone ( value ) <TAB> <TAB> <TAB> <TAB> except pytz. UnknownTimeZoneError : <TAB> <TAB> <TAB> <TAB> <TAB> debug. error ( ""Unknown display timezone specified"" ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> if not hasattr ( time, ""tzset"" ) : <TAB> <TAB> <TAB> <TAB> <TAB> debug. error ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""This operating system doesn't support tzset, please either specify an offset (eg. +1000) or install pytz"" <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> timezone = value <TAB> <TAB> parser. values. tz = timezone",False,"value[0] in ['+', '-']",parser.values.tz is None,0.6626071929931641
|
||
|
1682,"def extract ( self, url, ** kwargs ) : <TAB> if ""163.fm"" in url : <TAB> <TAB> url = get_location ( url ) <TAB> if ""music.163.com"" in url : <TAB> <TAB> self. need_download = False <TAB> <TAB> self. netease_cloud_music_download ( url, ** kwargs ) <TAB> else : <TAB> <TAB> html = get_content ( url ) <TAB> <TAB> title = match1 ( html, ""movieDescription='([^']+)'"" ) or match1 ( <TAB> <TAB> <TAB> html, ""<title>(.+)</title>"" <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> title = title [ 1 : ] <TAB> <TAB> src = match1 ( html, r'<source src=""([^""]+)""' ) or match1 ( <TAB> <TAB> <TAB> html, r'<source type=""[^""]+"" src=""([^""]+)""' <TAB> <TAB> ) <TAB> <TAB> if src : <TAB> <TAB> <TAB> url = src <TAB> <TAB> <TAB> _, ext, size = url_info ( src ) <TAB> <TAB> else : <TAB> <TAB> <TAB> url = ( <TAB> <TAB> <TAB> <TAB> match1 ( html, r'[""\'](.+)-list.m3u8[""\']' ) <TAB> <TAB> <TAB> <TAB> or match1 ( html, r'[""\'](.+).m3u8[""\']' ) <TAB> <TAB> <TAB> ) + "".mp4"" <TAB> <TAB> <TAB> _, _, size = url_info ( url ) <TAB> <TAB> <TAB> ext = ""mp4"" <TAB> <TAB> return { <TAB> <TAB> <TAB> ""urls"" : [ url ], <TAB> <TAB> <TAB> ""title"" : title, <TAB> <TAB> <TAB> ""file_format"" : ext, <TAB> <TAB> <TAB> ""size"" : size, <TAB> <TAB> }",False,title[0] == '',title,0.6579124331474304
|
||
|
1683,"def DecodeRepeatedField ( buffer, pos, end, message, field_dict ) : <TAB> value = field_dict. get ( key ) <TAB> if value is None : <TAB> <TAB> value = field_dict. setdefault ( key, new_default ( message ) ) <TAB> while 1 : <TAB> <TAB> ( element, new_pos ) = _DecodeSignedVarint32 ( buffer, pos ) <TAB> <TAB> if element in enum_type. values_by_number : <TAB> <TAB> <TAB> value. append ( element ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> message. _unknown_fields = [ ] <TAB> <TAB> <TAB> message. _unknown_fields. append ( ( tag_bytes, buffer [ pos : new_pos ] ) ) <TAB> <TAB> pos = new_pos + tag_len <TAB> <TAB> if buffer [ new_pos : pos ]!= tag_bytes or new_pos >= end : <TAB> <TAB> <TAB> if new_pos > end : <TAB> <TAB> <TAB> <TAB> raise _DecodeError ( ""Truncated message."" ) <TAB> <TAB> <TAB> return new_pos",False,not message._unknown_fields,new_pos > 0 and tag_bytes in buffer,0.6551991701126099
|
||
|
1684,"def test_connection_grouping ( self ) : <TAB> """"""Make sure group_connections returns list of (lang, connections)"""""" <TAB> connections = ( <TAB> <TAB> self. create_lang_connection ( ""1000000000"", ""en"" ), <TAB> <TAB> self. create_lang_connection ( ""1000000001"", ""en"" ), <TAB> <TAB> self. create_lang_connection ( ""1000000002"", ""en"" ), <TAB> <TAB> self. create_lang_connection ( ""1000000003"", ""es"" ), <TAB> <TAB> self. create_lang_connection ( ""1000000004"", ""es"" ), <TAB> <TAB> self. create_lang_connection ( ""1000000005"", ""fr"" ), <TAB> ) <TAB> grouped_conns = list ( trans_helpers. group_connections ( connections ) ) <TAB> for lang, conns in grouped_conns : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. assertEqual ( 3, len ( conns ) ) <TAB> <TAB> elif lang == ""es"" : <TAB> <TAB> <TAB> self. assertEqual ( 2, len ( conns ) ) <TAB> <TAB> elif lang == ""fr"" : <TAB> <TAB> <TAB> self. assertEqual ( 1, len ( conns ) )",True,lang == 'en',lang == 'en',0.6592690944671631
|
||
|
1685,"def process ( self, In, display = True ) : <TAB> if display and self. plot is not None : <TAB> <TAB> items = set ( ) <TAB> <TAB> <TAB> <TAB> for name, vals in In. items ( ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if type ( vals ) is not list : <TAB> <TAB> <TAB> <TAB> vals = [ vals ] <TAB> <TAB> <TAB> for val in vals : <TAB> <TAB> <TAB> <TAB> vid = id ( val ) <TAB> <TAB> <TAB> <TAB> if vid in self. items and self. items [ vid ]. scene ( ) is self. plot. scene ( ) : <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> items. add ( vid ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if isinstance ( val, QtGui. QGraphicsItem ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. plot. addItem ( val ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> item = val <TAB> <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> item = self. plot. plot ( val ) <TAB> <TAB> <TAB> <TAB> <TAB> self. items [ vid ] = item <TAB> <TAB> <TAB> <TAB> <TAB> items. add ( vid ) <TAB> <TAB> <TAB> <TAB> for vid in list ( self. items. keys ( ) ) : <TAB> <TAB> <TAB> if vid not in items : <TAB> <TAB> <",False,vals is None,name in items,0.6844977140426636
|
||
|
1686,"def set_history ( self, history ) : <TAB> <TAB> <TAB> <TAB> with self. update_lock : <TAB> <TAB> self. draw_times = [ <TAB> <TAB> <TAB> ( entry [ ""timestamp"" ], entry [ ""drift"" ] ) <TAB> <TAB> <TAB> for entry in history <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> ] <TAB> <TAB> if self. draw_times : <TAB> <TAB> <TAB> drifts = [ entry [ 1 ] for entry in self. draw_times ] <TAB> <TAB> <TAB> self. median_drift = round ( statistics. median ( drifts ), 5 ) <TAB> <TAB> <TAB> self. mean_drift = round ( statistics. mean ( drifts ), 5 ) <TAB> <TAB> <TAB> if len ( drifts ) > 1 : <TAB> <TAB> <TAB> <TAB> self. walk_interval_target = round ( <TAB> <TAB> <TAB> <TAB> <TAB> self. draw_times [ - 1 ] [ 0 ] <TAB> <TAB> <TAB> <TAB> <TAB> - self. draw_times [ - 2 ] [ 0 ] <TAB> <TAB> <TAB> <TAB> <TAB> - self. draw_times [ - 1 ] [ 1 ], <TAB> <TAB> <TAB> <TAB> <TAB> 4, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. walk_interval_target = ""?"" <TAB> <TAB> else : <TAB> <TAB> <TAB> self. median_drift = ""?"" <TAB> <TAB> <TAB> self. mean_drift = ""?"" <TAB> <TAB> <TAB> self. walk_interval_target = ""?""",False,entry['timestamp'] > time.time() - 11.0,self.print_times,0.6541649103164673
|
||
|
1687,"def parse_struc ( img ) : <TAB> nbs = neighbors ( img. shape ) <TAB> acc = np. cumprod ( ( 1, ) + img. shape [ : : - 1 ] [ : - 1 ] ) [ : : - 1 ] <TAB> img = img. ravel ( ) <TAB> pts = np. array ( np. where ( img == 2 ) ) [ 0 ] <TAB> buf = np. zeros ( 131072, dtype = np. int64 ) <TAB> num = 10 <TAB> nodes = [ ] <TAB> for p in pts : <TAB> <TAB> if img [ p ] == 2 : <TAB> <TAB> <TAB> nds = fill ( img, p, num, nbs, acc, buf ) <TAB> <TAB> <TAB> num += 1 <TAB> <TAB> <TAB> nodes. append ( nds ) <TAB> edges = [ ] <TAB> for p in pts : <TAB> <TAB> for dp in nbs : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> edge = trace ( img, p + dp, nbs, acc, buf ) <TAB> <TAB> <TAB> <TAB> edges. append ( edge ) <TAB> return nodes, edges",False,img[p + dp] == 1,img[p] == 1,0.6583623886108398
|
||
|
1688,"def parse_config_v2 ( self, skip_broken = True ) : <TAB> for command_type, command in self. _config. items ( ) : <TAB> <TAB> if command_type in [ ""version"", ""renderer"" ] : <TAB> <TAB> <TAB> continue <TAB> <TAB> try : <TAB> <TAB> <TAB> handler = self. command_handlers [ command_type ] <TAB> <TAB> except KeyError as e : <TAB> <TAB> <TAB> raise RuntimeError ( <TAB> <TAB> <TAB> <TAB> ""No handler found for command '%s'"" % command_type <TAB> <TAB> <TAB> ) from e <TAB> <TAB> try : <TAB> <TAB> <TAB> handler ( self, command ) <TAB> <TAB> <TAB> self. _v2_common ( command ) <TAB> <TAB> except InvalidCommand : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> LOG. warning ( ""Skipping invalid command: %s"", command, exc_info = True ) <TAB> <TAB> <TAB> <TAB> LOG. debug ( self. dump_network_state ( ) )",False,not skip_broken,skip_broken,0.6610915660858154
|
||
|
1689,"def config_dict ( filename ) : <TAB> """"""Convert content of config-file into dictionary."""""" <TAB> with open ( filename, ""r"" ) as f : <TAB> <TAB> cfglines = f. readlines ( ) <TAB> cfgdict = { } <TAB> for line in cfglines : <TAB> <TAB> line = line. strip ( ) <TAB> <TAB> if not line or line. startswith ( ""#"" ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> try : <TAB> <TAB> <TAB> key, value = line. split ( ""="" ) <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> print ( ""Bad line in config-file %s:\n%s"" % ( filename, line ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> key = key. strip ( ) <TAB> <TAB> value = value. strip ( ) <TAB> <TAB> if value in [ ""True"", ""False"", ""None"", ""''"", '""""' ] : <TAB> <TAB> <TAB> value = eval ( value ) <TAB> <TAB> else : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> value = float ( value ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> value = int ( value ) <TAB> <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> cfgdict [ key ] = value <TAB> return cfgdict",False,'.' in value,value in [False],0.6701300740242004
|
||
|
1690,"def run ( self ) : <TAB> while True : <TAB> <TAB> context_id_list_tuple = self. _inflated_addresses. get ( block = True ) <TAB> <TAB> if context_id_list_tuple is _SHUTDOWN_SENTINEL : <TAB> <TAB> <TAB> break <TAB> <TAB> c_id, inflated_address_list = context_id_list_tuple <TAB> <TAB> inflated_value_map = dict ( inflated_address_list ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _contexts [ c_id ]. set_from_tree ( inflated_value_map )",True,c_id in self._contexts,c_id in self._contexts,0.659544825553894
|
||
|
1691,"def _handlewebError ( self, msg ) : <TAB> print ( """" ) <TAB> print ( "" ERROR: %s"" % msg ) <TAB> if not self. interactive : <TAB> <TAB> raise self. failureException ( msg ) <TAB> p = "" Show: [B]ody [H]eaders [S]tatus [U]RL; [I]gnore, [R]aise, or sys.e[X]it >> "" <TAB> sys. stdout. write ( p ) <TAB> sys. stdout. flush ( ) <TAB> while True : <TAB> <TAB> i = getchar ( ). upper ( ) <TAB> <TAB> if not isinstance ( i, type ( """" ) ) : <TAB> <TAB> <TAB> i = i. decode ( ""ascii"" ) <TAB> <TAB> if i not in ""BHSUIRX"" : <TAB> <TAB> <TAB> continue <TAB> <TAB> print ( i. upper ( ) ) <TAB> <TAB> if i == ""B"" : <TAB> <TAB> <TAB> for x, line in enumerate ( self. body. splitlines ( ) ) : <TAB> <TAB> <TAB> <TAB> if ( x + 1 ) % self. console_height == 0 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> sys. stdout. write ( ""<-- More -->\r"" ) <TAB> <TAB> <TAB> <TAB> <TAB> m = getchar ( ). lower ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> sys. stdout. write ( "" \r"" ) <TAB> <TAB> <TAB> <TAB> <TAB> if m == ""q"" : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> print ( line ) <TAB> <TAB> elif i == ""H"" : <TAB> <TAB> <TAB> pprint. pprint ( self. headers ) <TAB> <TAB> elif i == ""S"" : <TAB> <TAB>",False,i == 'R',self.console_height == 0,0.6609758138656616
|
||
|
1692,"def app_check ( self ) : <TAB> """"""Check if a target app has been selected, otherwise launch a wizard. Then retrieve its metadata."""""" <TAB> app = self. _global_options [ ""app"" ] <TAB> <TAB> if not app : <TAB> <TAB> self. printer. info ( ""Target app not selected. Launching wizard..."" ) <TAB> <TAB> self. device. _list_apps ( self. _global_options [ ""hide_system_apps"" ] ) <TAB> <TAB> app = self. device. select_target_app ( ) <TAB> <TAB> self. _global_options [ ""app"" ] = app <TAB> <TAB> if app is None : <TAB> <TAB> <TAB> self. printer. error ( ""Error selecting app. Please retry."" ) <TAB> <TAB> <TAB> return None <TAB> <TAB> self. printer. notify ( ""Target app: %s"" % app ) <TAB> if not self. APP_METADATA or self. APP_METADATA [ ""bundle_id"" ]!= app : <TAB> <TAB> <TAB> <TAB> self. printer. info ( ""Retrieving app's metadata..."" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. device. _list_apps ( self. _global_options [ ""hide_system_apps"" ] ) <TAB> <TAB> self. APP_METADATA = Framework. APP_METADATA = self. device. app. get_metadata ( app ) <TAB> return app",False,self.device._applist is None,self.device.app is not None,0.6613767743110657
|
||
|
1693,"def _limit_value ( key, value, config ) : <TAB> if config [ key ]. get ( ""upper_limit"" ) : <TAB> <TAB> limit = config [ key ] [ ""upper_limit"" ] <TAB> <TAB> <TAB> <TAB> if isinstance ( value, datetime ) and isinstance ( limit, timedelta ) : <TAB> <TAB> <TAB> if config [ key ] [ ""inverse"" ] is True : <TAB> <TAB> <TAB> <TAB> if ( datetime. now ( ) - limit ) > value : <TAB> <TAB> <TAB> <TAB> <TAB> value = datetime. now ( ) - limit <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> if ( datetime. now ( ) + limit ) < value : <TAB> <TAB> <TAB> <TAB> <TAB> value = datetime. now ( ) + limit <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> value = limit <TAB> return value",True,value > limit,value > limit,0.6721374988555908
|
||
|
1694,"def do_action ( <TAB> self, context : UserContext, action_name : str, targets : Candidates ) -> bool : <TAB> action = self. _get_action_targets ( context, action_name, targets ) <TAB> if not action : <TAB> <TAB> return True <TAB> for target in targets : <TAB> <TAB> source = self. _current_sources [ int ( target [ ""source_index"" ] ) ] <TAB> <TAB> target [ ""source_context"" ] = ( <TAB> <TAB> <TAB> { k : v for k, v in source. context. items ( ) if k. startswith ( ""__"" ) } <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> else { } <TAB> <TAB> ) <TAB> context [ ""targets"" ] = targets <TAB> index = action [ ""kind"" ] + "",source/"" + action [ ""source"" ] <TAB> new_context = ( <TAB> <TAB> action [ ""func"" ] ( context ) <TAB> <TAB> if action [ ""func"" ] <TAB> <TAB> else self. _vim. call ( <TAB> <TAB> <TAB> ""denite#custom#_call_action"", index, action [ ""name"" ], context <TAB> <TAB> ) <TAB> ) <TAB> if new_context : <TAB> <TAB> context. update ( new_context ) <TAB> return False",False,source.is_public_context,target['targets'],0.6525206565856934
|
||
|
1695,"def test_flow_register_uses_default_storage ( self, monkeypatch, storage ) : <TAB> monkeypatch. setattr ( ""prefect.Client"", MagicMock ( ) ) <TAB> f = Flow ( name = ""test"" ) <TAB> assert f. storage is None <TAB> with set_temporary_config ( { ""flows.defaults.storage.default_class"" : storage } ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> f. register ( <TAB> <TAB> <TAB> <TAB> ""My-project"", <TAB> <TAB> <TAB> <TAB> registry_url = ""FOO"", <TAB> <TAB> <TAB> <TAB> image_name = ""BAR"", <TAB> <TAB> <TAB> <TAB> image_tag = ""BIG"", <TAB> <TAB> <TAB> <TAB> no_url = True, <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> f. register ( ""My-project"" ) <TAB> assert isinstance ( f. storage, from_qualified_name ( storage ) ) <TAB> assert f. result == from_qualified_name ( storage ) ( ). result",False,'Docker' in storage,storage,0.6646945476531982
|
||
|
1696,"def _create_profile_cache ( ssg_root ) : <TAB> profile_cache = { } <TAB> product_list = [ <TAB> <TAB> ""debian9"", <TAB> <TAB> ""debian10"", <TAB> <TAB> ""fedora"", <TAB> <TAB> ""ol7"", <TAB> <TAB> ""opensuse"", <TAB> <TAB> ""rhel7"", <TAB> <TAB> ""sle12"", <TAB> <TAB> ""ubuntu1604"", <TAB> <TAB> ""ubuntu1804"", <TAB> <TAB> ""ubuntu2004"", <TAB> <TAB> ""wrlinux"", <TAB> ] <TAB> for product in product_list : <TAB> <TAB> found_obj_name = False <TAB> <TAB> prod_profiles_dir = os. path. join ( ssg_root, product, ""profiles"" ) <TAB> <TAB> for _, _, files in os. walk ( prod_profiles_dir ) : <TAB> <TAB> <TAB> for filename in files : <TAB> <TAB> <TAB> <TAB> profile_path = os. path. join ( prod_profiles_dir, filename ) <TAB> <TAB> <TAB> <TAB> parsed_profile = yaml. load ( open ( profile_path, ""r"" ) ) <TAB> <TAB> <TAB> <TAB> for _obj in parsed_profile [ ""selections"" ] : <TAB> <TAB> <TAB> <TAB> <TAB> obj = _obj <TAB> <TAB> <TAB> <TAB> <TAB> if ""="" in obj : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> obj = _obj [ : _obj. index ( ""="" ) ] <TAB> <TAB> <TAB> <TAB> <TAB> if not obj [ 0 ]. isalpha ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> obj = obj [ 1 : ] <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <",False,obj not in profile_cache,found_obj_name,0.6528384685516357
|
||
|
1697,"def test_memory_maps ( self ) : <TAB> p = psutil. Process ( ) <TAB> maps = p. memory_maps ( ) <TAB> paths = [ x for x in maps ] <TAB> self. assertEqual ( len ( paths ), len ( set ( paths ) ) ) <TAB> ext_maps = p. memory_maps ( grouped = False ) <TAB> for nt in maps : <TAB> <TAB> if not nt. path. startswith ( ""["" ) : <TAB> <TAB> <TAB> assert os. path. isabs ( nt. path ), nt. path <TAB> <TAB> <TAB> if POSIX : <TAB> <TAB> <TAB> <TAB> assert os. path. exists ( nt. path ), nt. path <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if ""64"" not in os. path. basename ( nt. path ) : <TAB> <TAB> <TAB> <TAB> <TAB> assert os. path. exists ( nt. path ), nt. path <TAB> for nt in ext_maps : <TAB> <TAB> for fname in nt. _fields : <TAB> <TAB> <TAB> value = getattr ( nt, fname ) <TAB> <TAB> <TAB> if fname == ""path"" : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> assert value, value <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. assertIsInstance ( value, ( int, long ) ) <TAB> <TAB> <TAB> <TAB> assert value >= 0, value",False,"fname in ('addr', 'perms')",fname == 'instance',0.654965877532959
|
||
|
1698,"def load_sys ( paths ) : <TAB> src, tgt, hypos, log_probs = { }, { }, { }, { } <TAB> for path in paths : <TAB> <TAB> with open ( path ) as f : <TAB> <TAB> <TAB> for line in f : <TAB> <TAB> <TAB> <TAB> line = line. rstrip ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if line. startswith ( ( ""S-"", ""T-"", ""D-"" ) ) : <TAB> <TAB> <TAB> <TAB> <TAB> i = int ( line [ line. find ( ""-"" ) + 1 : line. find ( ""\t"" ) ] ) <TAB> <TAB> <TAB> <TAB> <TAB> if line. startswith ( ""S-"" ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> src [ i ] = line. split ( ""\t"" ) [ 1 ] <TAB> <TAB> <TAB> <TAB> <TAB> if line. startswith ( ""T-"" ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> tgt [ i ] = line. split ( ""\t"" ) [ 1 ] <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if i not in hypos : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> hypos [ i ] = [ ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> log_probs [ i ] = [ ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> hypos [ i ]. append ( line. split ( ""\t"" ) [ 2 ] ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> log_probs [ i ]. append ( float ( line. split ( ""\t"" ) [ 1 ] ) ) <TAB> return dictolist ( src ), dictolist",False,line.startswith('D-'),i >= 0,0.6493213176727295
|
||
|
1699,"def shutdown ( sups ) : <TAB> global SHOULD_STOP <TAB> SHOULD_STOP = True <TAB> LOG. warn ( ""Supervisor shutting down!"" ) <TAB> for pid in CHILD_PIDS : <TAB> <TAB> try : <TAB> <TAB> <TAB> os. kill ( pid, signal. SIGINT ) <TAB> <TAB> except OSError : <TAB> <TAB> <TAB> pass <TAB> LOG. warn ( ""Waiting for children to exit for %d seconds..."" % WAIT_FOR_DEATH ) <TAB> t = time. time ( ) <TAB> still_alive = False <TAB> while time. time ( ) < t + WAIT_FOR_DEATH : <TAB> <TAB> still_alive = False <TAB> <TAB> for sup in sups : <TAB> <TAB> <TAB> sup. join ( 0.2 ) <TAB> <TAB> <TAB> still_alive = still_alive or sup. isAlive ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> break <TAB> if still_alive : <TAB> <TAB> LOG. warn ( <TAB> <TAB> <TAB> ""Children have not exited after %d seconds. Killing them with SIGKILL."" <TAB> <TAB> <TAB> % WAIT_FOR_DEATH <TAB> <TAB> ) <TAB> <TAB> for pid in CHILD_PIDS : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> os. kill ( pid, signal. SIGKILL ) <TAB> <TAB> <TAB> except OSError : <TAB> <TAB> <TAB> <TAB> pass <TAB> sys. exit ( 1 )",False,not still_alive,SHOULD_STOP,0.6603798866271973
|
||
|
1700,"def post_mortem ( t = None ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> t = sys. exc_info ( ) [ 2 ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""A valid traceback must be passed if no exception is being handled."" <TAB> <TAB> <TAB> ) <TAB> p = BPdb ( ) <TAB> p. reset ( ) <TAB> p. interaction ( None, t )",True,t is None,t is None,0.6743518114089966
|
||
|
1701,"def filtered_tooltip ( options, filter ) : <TAB> """"""Returns tooltip for the filter icon if the filter matches one of the filter options"""""" <TAB> for option in options : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return ""Showing only %s"" % option [ 0 ] <TAB> <TAB> if ( ""daterange"" == option [ 1 ] ) and filter. startswith ( option [ 4 ] ) : <TAB> <TAB> <TAB> return ""Showing only %s"" % option [ 0 ] <TAB> return """"",False,filter == option[1],'daterange' == option[0] and filter.startswith(option[2]),0.6566956043243408
|
||
|
1702,"def _get_documented_completions ( self, table, startswith = None ) : <TAB> names = [ ] <TAB> for key, command in table. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> if startswith is not None and not key. startswith ( startswith ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> if getattr ( command, ""positional_arg"", False ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> names. append ( key ) <TAB> return names",False,"getattr(command, '_UNDOCUMENTED', False)",command == 'document',0.6609865427017212
|
||
|
1703,"def TryMerge ( self, d ) : <TAB> while d. avail ( ) > 0 : <TAB> <TAB> tt = d. getVarInt32 ( ) <TAB> <TAB> if tt == 10 : <TAB> <TAB> <TAB> self. set_app_id ( d. getPrefixedString ( ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if tt == 16 : <TAB> <TAB> <TAB> self. set_max_rows ( 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.681990385055542
|
||
|
1704,"def _get_fp ( self, config_file ) : <TAB> if not os. path. isdir ( static. STARCLUSTER_CFG_DIR ) : <TAB> <TAB> os. makedirs ( static. STARCLUSTER_CFG_DIR ) <TAB> cfg_file = config_file or static. STARCLUSTER_CFG_FILE <TAB> log. debug ( ""Loading file: %s"" % cfg_file ) <TAB> if os. path. exists ( cfg_file ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise exception. ConfigError ( <TAB> <TAB> <TAB> <TAB> ""config %s exists but is not a regular file"" % cfg_file <TAB> <TAB> <TAB> ) <TAB> else : <TAB> <TAB> raise exception. ConfigNotFound ( <TAB> <TAB> <TAB> ( ""config file %s does not exist\n"" ) % cfg_file, <TAB> <TAB> <TAB> cfg_file, <TAB> <TAB> ) <TAB> return open ( cfg_file )",False,not os.path.isfile(cfg_file),os.path.isfile(cfg_file),0.6476112604141235
|
||
|
1705,"def get_default_queryset ( self ) : <TAB> qs = [ ] <TAB> for addon in ADDONS_OAUTH : <TAB> <TAB> obj = self. get_addon_settings ( <TAB> <TAB> <TAB> provider = addon, fail_if_absent = False, check_object_permissions = False <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> qs. append ( obj ) <TAB> sorted ( qs, key = lambda addon : addon. id, reverse = True ) <TAB> return qs",True,obj,obj,0.6900901794433594
|
||
|
1706,"def fetch_ssl_details ( paths = None ) : <TAB> ssl_details = { } <TAB> <TAB> ssl_cert_paths = [ <TAB> <TAB> ""/var/lib/cloud/data/ssl"", <TAB> <TAB> ""/var/lib/cloud/instance/data/ssl"", <TAB> ] <TAB> if paths : <TAB> <TAB> ssl_cert_paths. extend ( <TAB> <TAB> <TAB> [ <TAB> <TAB> <TAB> <TAB> os. path. join ( paths. get_ipath_cur ( ""data"" ), ""ssl"" ), <TAB> <TAB> <TAB> <TAB> os. path. join ( paths. get_cpath ( ""data"" ), ""ssl"" ), <TAB> <TAB> <TAB> ] <TAB> <TAB> ) <TAB> ssl_cert_paths = uniq_merge ( ssl_cert_paths ) <TAB> ssl_cert_paths = [ d for d in ssl_cert_paths if d and os. path. isdir ( d ) ] <TAB> cert_file = None <TAB> for d in ssl_cert_paths : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> cert_file = os. path. join ( d, ""cert.pem"" ) <TAB> <TAB> <TAB> break <TAB> key_file = None <TAB> for d in ssl_cert_paths : <TAB> <TAB> if os. path. isfile ( os. path. join ( d, ""key.pem"" ) ) : <TAB> <TAB> <TAB> key_file = os. path. join ( d, ""key.pem"" ) <TAB> <TAB> <TAB> break <TAB> if cert_file and key_file : <TAB> <TAB> ssl_details [ ""cert_file"" ] = cert_file <TAB> <TAB> ssl_details [ ""key_file"" ] = key_file <TAB> elif cert_file : <TAB> <TAB> ssl_details [ ""cert_file"" ] = cert_file <TAB> return ssl_details",False,"os.path.isfile(os.path.join(d, 'cert.pem'))",os.path.isfile(d),0.6437021493911743
|
||
|
1707,"def handle ( self, * args, ** options ) : <TAB> if options [ ""missing"" ] : <TAB> <TAB> self. verify_references ( options ) <TAB> if options [ ""delete_missing"" ] : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> msg = ( <TAB> <TAB> <TAB> <TAB> ""\nThis will delete entries from your database. Are you sure you want to do this?\n\n"" <TAB> <TAB> <TAB> <TAB> ""Type 'yes' to continue, or 'no' to cancel: "" <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if input ( msg )!= ""yes"" : <TAB> <TAB> <TAB> <TAB> self. stdout. write ( ""Aborted: Delete missing file entries from database."" ) <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> self. verify_references ( options ) <TAB> if options [ ""orphans"" ] : <TAB> <TAB> self. verify_storages ( options ) <TAB> if options [ ""delete_orphans"" ] : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> msg = ( <TAB> <TAB> <TAB> <TAB> ""\nThis will delete orphaned files from your storage. Are you sure you want to do this?\n\n"" <TAB> <TAB> <TAB> <TAB> ""Type 'yes' to continue, or 'no' to cancel: "" <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if input ( msg )!= ""yes"" : <TAB> <TAB> <TAB> <TAB> self. stdout. write ( ""Aborted: Delete orphaned files from storage."" ) <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> self. verify_storages ( options )",False,options['interactive'],self.delete_from_storage(),0.6622346043586731
|
||
|
1708,"def _HasPrecedence ( tok ) : <TAB> """"""Whether a binary operation has precedence within its context."""""" <TAB> node = tok. node <TAB> <TAB> <TAB> ancestor = node. parent. parent <TAB> while ancestor is not None : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> predecessor_type = pytree_utils. NodeName ( ancestor ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return True <TAB> <TAB> if predecessor_type!= ""atom"" : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return False <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ancestor = ancestor. parent",False,"predecessor_type in ['arith_expr', 'term']",predecess_type == 'atom',0.654313325881958
|
||
|
1709,"def build ( self ) : <TAB> max_matched = 0 <TAB> for head in self. heads : <TAB> <TAB> for chain in self. combine_chain ( head ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> max_matched = chain. num_matched <TAB> <TAB> <TAB> self. chains. append ( chain ) <TAB> for chain in self. chains : <TAB> <TAB> chain. weights. append ( <TAB> <TAB> <TAB> chain. num_matched / float ( max_matched or chain. num_matched or 1 ) <TAB> <TAB> ) <TAB> <TAB> chain. finish ( ) <TAB> self. chains. sort ( key = lambda chain : chain. weight, reverse = True ) <TAB> for chain in self. chains : <TAB> <TAB> Logr. debug ( ""chain weight: %.02f"", chain. weight ) <TAB> <TAB> Logr. debug ( ""\tInfo: %s"", chain. info ) <TAB> <TAB> Logr. debug ( ""\tWeights: %s"", chain. weights ) <TAB> <TAB> Logr. debug ( ""\tNumber of Fragments Matched: %s"", chain. num_matched )",False,chain.num_matched > max_matched,len(self.chain) > max_matched,0.6527489423751831
|
||
|
1710,"def test_source_address ( self ) : <TAB> for addr, is_ipv6 in VALID_SOURCE_ADDRESSES : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> warnings. warn ( ""No IPv6 support: skipping."", NoIPv6Warning ) <TAB> <TAB> <TAB> continue <TAB> <TAB> pool = HTTPConnectionPool ( <TAB> <TAB> <TAB> self. host, self. port, source_address = addr, retries = False <TAB> <TAB> ) <TAB> <TAB> self. addCleanup ( pool. close ) <TAB> <TAB> r = pool. request ( ""GET"", ""/source_address"" ) <TAB> <TAB> self. assertEqual ( r. data, b ( addr [ 0 ] ) )",False,is_ipv6 and (not HAS_IPV6_AND_DNS),is_ipv6,0.6554077863693237
|
||
|
1711,"def setLabel ( self, s, protect = False ) : <TAB> """"""Set the label of the minibuffer."""""" <TAB> c, k, w = self. c, self, self. w <TAB> if w : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> g. app. gui. set_minibuffer_label ( c, s ) <TAB> <TAB> w. setAllText ( s ) <TAB> <TAB> n = len ( s ) <TAB> <TAB> w. setSelectionRange ( n, n, insert = n ) <TAB> <TAB> if protect : <TAB> <TAB> <TAB> k. mb_prefix = s",False,"hasattr(g.app.gui, 'set_minibuffer_label')",c,0.6540514230728149
|
||
|
1712,"def get_setup_script ( cls ) : <TAB> script = """" <TAB> <TAB> if cls. INTERNAL_TESTMODE : <TAB> <TAB> script += ""\nCONFIGURE SESSION SET __internal_testmode := true;"" <TAB> <TAB> <TAB> schema = [ ""\nmodule test {}"" ] <TAB> for name in dir ( cls ) : <TAB> <TAB> m = re. match ( r""^SCHEMA(?:_(\w+))?"", name ) <TAB> <TAB> if m : <TAB> <TAB> <TAB> module_name = ( m. group ( 1 ) or ""test"" ). lower ( ). replace ( ""__"", ""."" ) <TAB> <TAB> <TAB> schema_fn = getattr ( cls, name ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> with open ( schema_fn, ""r"" ) as sf : <TAB> <TAB> <TAB> <TAB> <TAB> module = sf. read ( ) <TAB> <TAB> <TAB> <TAB> schema. append ( f""\nmodule {module_name} {{ {module} }}"" ) <TAB> script += f""\nSTART MIGRATION"" <TAB> script += f' TO {{ {"""".join(schema)} }};' <TAB> script += f""\nPOPULATE MIGRATION;"" <TAB> script += f""\nCOMMIT MIGRATION;"" <TAB> if cls. SETUP : <TAB> <TAB> if not isinstance ( cls. SETUP, ( list, tuple ) ) : <TAB> <TAB> <TAB> scripts = [ cls. SETUP ] <TAB> <TAB> else : <TAB> <TAB> <TAB> scripts = cls. SETUP <TAB> <TAB> for scr in scripts : <TAB> <TAB> <TAB> if ""\n"" not in scr and os. path. exists ( scr ) : <TAB> <TAB> <TAB> <TAB> with open ( scr, ""rt"" ) as f : <TAB> <TAB> <TAB> <TAB> <TAB> setup = f. read ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> setup = scr <TAB> <TAB> <",False,schema_fn is not None,schema_fn,0.6590206027030945
|
||
|
1713,"def do_sub ( m ) : <TAB> c = m. groupdict ( ) <TAB> if c [ ""htmlchars"" ] : <TAB> <TAB> return cgi. escape ( c [ ""htmlchars"" ] ) <TAB> if c [ ""lineend"" ] : <TAB> <TAB> return ""<br>"" <TAB> elif c [ ""space"" ] : <TAB> <TAB> t = m. group ( ). replace ( ""\t"", u"" "" * tabstop ) <TAB> <TAB> t = t. replace ( "" "", "" "" ) <TAB> <TAB> return t <TAB> elif c [ ""space"" ] == ""\t"" : <TAB> <TAB> return "" "" * tabstop <TAB> else : <TAB> <TAB> url = m. group ( ""protocol"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> prefix = "" "" <TAB> <TAB> <TAB> url = url [ 1 : ] <TAB> <TAB> else : <TAB> <TAB> <TAB> prefix = """" <TAB> <TAB> last = m. groups ( ) [ - 1 ] <TAB> <TAB> if last in [ ""\n"", ""\r"", ""\r\n"" ] : <TAB> <TAB> <TAB> last = ""<br>"" <TAB> <TAB> return u'{0}<a href=""{1}"">{2}</a>{3}'. format ( prefix, url, url, last )",False,url.startswith(' '),url.startswith('/'),0.6510301828384399
|
||
|
1714,"def validate_email ( self, data ) : <TAB> email = data. get ( ""email"" ) <TAB> if email is None : <TAB> <TAB> return <TAB> existing_team = Teams. query. filter_by ( email = email ). first ( ) <TAB> if is_admin ( ) : <TAB> <TAB> team_id = data. get ( ""id"" ) <TAB> <TAB> if team_id : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise ValidationError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Email address has already been used"", field_names = [ ""email"" ] <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if existing_team : <TAB> <TAB> <TAB> <TAB> raise ValidationError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Email address has already been used"", field_names = [ ""email"" ] <TAB> <TAB> <TAB> <TAB> ) <TAB> else : <TAB> <TAB> current_team = get_current_team ( ) <TAB> <TAB> if email == current_team. email : <TAB> <TAB> <TAB> return data <TAB> <TAB> else : <TAB> <TAB> <TAB> if existing_team : <TAB> <TAB> <TAB> <TAB> raise ValidationError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Email address has already been used"", field_names = [ ""email"" ] <TAB> <TAB> <TAB> <TAB> )",False,existing_team and existing_team.id != team_id,email == team_id,0.6556707620620728
|
||
|
1715,"def process ( self ) : <TAB> if not self. outputs [ 0 ]. is_linked : <TAB> <TAB> return <TAB> var_names = self. get_variables ( ) <TAB> inputs = self. get_input ( ) <TAB> results = [ ] <TAB> if var_names : <TAB> <TAB> input_values = [ inputs. get ( name, [ [ 0 ] ] ) for name in var_names ] <TAB> <TAB> parameters = match_long_repeat ( input_values ) <TAB> else : <TAB> <TAB> parameters = [ [ [ None ] ] ] <TAB> for objects in zip ( * parameters ) : <TAB> <TAB> object_results = [ ] <TAB> <TAB> for values in zip_long_repeat ( * objects ) : <TAB> <TAB> <TAB> variables = dict ( zip ( var_names, values ) ) <TAB> <TAB> <TAB> vector = [ ] <TAB> <TAB> <TAB> for formula in self. formulas ( ) : <TAB> <TAB> <TAB> <TAB> if formula : <TAB> <TAB> <TAB> <TAB> <TAB> value = safe_eval ( formula, variables ) <TAB> <TAB> <TAB> <TAB> <TAB> vector. append ( value ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> object_results. append ( vector ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> object_results. extend ( vector ) <TAB> <TAB> results. append ( object_results ) <TAB> if self. wrap : <TAB> <TAB> results = [ results ] <TAB> self. outputs [ ""Result"" ]. sv_set ( results )",False,self.separate,self.wrap,0.660106360912323
|
||
|
1716,"def user_line ( self, frame ) : <TAB> traceenter ( ""user_line"", _dumpf ( frame ) ) <TAB> <TAB> if frame. f_lineno!= 0 : <TAB> <TAB> breakReason = self. breakReason <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> breakReason = axdebug. BREAKREASON_STEP <TAB> <TAB> self. _HandleBreakPoint ( frame, None, breakReason )",True,breakReason is None,breakReason is None,0.6683458685874939
|
||
|
1717,"def startDemo ( self ) : <TAB> self. refreshCanvas ( ) <TAB> self. dirty = True <TAB> turtle. TurtleScreen. _RUNNING = True <TAB> self. configGUI ( DISABLED, DISABLED, NORMAL, DISABLED, ""demo running..."", ""black"" ) <TAB> self. screen. clear ( ) <TAB> self. screen. mode ( ""standard"" ) <TAB> self. state = RUNNING <TAB> try : <TAB> <TAB> result = self. module. main ( ) <TAB> <TAB> if result == ""EVENTLOOP"" : <TAB> <TAB> <TAB> self. state = EVENTDRIVEN <TAB> <TAB> else : <TAB> <TAB> <TAB> self. state = DONE <TAB> except turtle. Terminator : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return <TAB> <TAB> self. state = DONE <TAB> <TAB> result = ""stopped!"" <TAB> if self. state == DONE : <TAB> <TAB> self. configGUI ( NORMAL, NORMAL, DISABLED, NORMAL, result ) <TAB> elif self. state == EVENTDRIVEN : <TAB> <TAB> self. exitflag = True <TAB> <TAB> self. configGUI ( <TAB> <TAB> <TAB> DISABLED, DISABLED, NORMAL, DISABLED, ""use mouse/keys or STOP"", ""red"" <TAB> <TAB> )",False,self.root is None,self.state == STATE_STOPPED,0.6546293497085571
|
||
|
1718,"def get_filter_based_on_pattern ( <TAB> pattern : str, <TAB> fields : Sequence [ str ] = ( "".name"", ), <TAB> flag : str = """", <TAB> *, <TAB> filter_and : str = """", <TAB> filter_or : str = """", ) -> Tuple [ str, Dict [ str, str ] ] : <TAB> <TAB> <TAB> if flag : <TAB> <TAB> flag = f""(?{flag})"" <TAB> qkw : Dict [ str, str ] = { } <TAB> filter_cond = """" <TAB> if pattern and fields : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> qkw = { ""re_filter"" : flag + pattern } <TAB> <TAB> filters = [ ] <TAB> <TAB> for field in fields : <TAB> <TAB> <TAB> filters. append ( f""re_test(<str>$re_filter, {field})"" ) <TAB> <TAB> filter_cond = f'({"" OR "".join(filters)})' <TAB> filter_clause = """" <TAB> if filter_cond : <TAB> <TAB> filter_clause += filter_cond <TAB> if filter_and : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> filter_clause += "" AND "" <TAB> <TAB> filter_clause += filter_and <TAB> if filter_or : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> filter_clause += "" OR "" <TAB> <TAB> filter_clause += filter_or <TAB> if<mask> : <TAB> <TAB> filter_clause = ""FILTER "" + filter_clause <TAB> <TAB> return filter_clause, qkw <TAB> return """", qkw",False,filter_clause,filter_and and filter_or,0.661453902721405
|
||
|
1719,"def __init__ ( self, isofile ) : <TAB> try : <TAB> <TAB> f = open ( isofile, ""rb"" ) <TAB> except ( IOError ) : <TAB> <TAB> sys. stderr. write ( ""can't open {0}"". format ( isofile ) ) <TAB> <TAB> raise <TAB> if os. path. getsize ( isofile ) == 0 : <TAB> <TAB> raise IOError ( ""File {0} appears to be empty"". format ( isofile ) ) <TAB> self. isoFile = f <TAB> self. priVol = None <TAB> self. rootDir = None <TAB> self. rripOffset = - 1 <TAB> desc_nr = 0 <TAB> while True : <TAB> <TAB> desc_nr = desc_nr + 1 <TAB> <TAB> try : <TAB> <TAB> <TAB> self. isoFile. seek ( BLOCK_SIZE * ( 15 + desc_nr ) ) <TAB> <TAB> <TAB> volume_dsc = self. isoFile. read ( BLOCK_SIZE ) <TAB> <TAB> <TAB> flag = struct. unpack ( ""B"", volume_dsc [ 0 : 1 ] ) [ 0 ] <TAB> <TAB> <TAB> if flag == 1 : <TAB> <TAB> <TAB> <TAB> self. __readPrimaryVolume__ ( volume_dsc ) <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> except Exception as e : <TAB> <TAB> <TAB> gen. log ( ""Got exception when init iso file:"", sys. exc_info ( ) [ 0 ] ) <TAB> <TAB> <TAB> self. priVol = None <TAB> <TAB> <TAB> self. rootDir = None <TAB> <TAB> <TAB> break",False,flag == 255,flag == False,0.6714748740196228
|
||
|
1720,"def text_to_sequence ( self, text, inference = False ) : <TAB> if inference : <TAB> <TAB> pinyin = self. pinyin_parser ( text, style = Style. TONE3, errors = ""ignore"" ) <TAB> <TAB> new_pinyin = [ ] <TAB> <TAB> for x in pinyin : <TAB> <TAB> <TAB> x = """". join ( x ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> new_pinyin. append ( x ) <TAB> <TAB> phonemes = self. get_phoneme_from_char_and_pinyin ( text, new_pinyin ) <TAB> <TAB> text = "" "". join ( phonemes ) <TAB> <TAB> print ( f""phoneme seq: {text}"" ) <TAB> sequence = [ ] <TAB> for symbol in text. split ( ) : <TAB> <TAB> idx = self. symbol_to_id [ symbol ] <TAB> <TAB> sequence. append ( idx ) <TAB> <TAB> sequence += [ self. eos_id ] <TAB> return sequence",False,'#' not in x,inclan,0.675324022769928
|
||
|
1721,"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. LIST : <TAB> <TAB> <TAB> <TAB> self. names = [ ] <TAB> <TAB> <TAB> <TAB> ( _etype360, _size357 ) = iprot. readListBegin ( ) <TAB> <TAB> <TAB> <TAB> for _i361 in xrange ( _size357 ) : <TAB> <TAB> <TAB> <TAB> <TAB> _elem362 = iprot. readString ( ) <TAB> <TAB> <TAB> <TAB> <TAB> self. names. append ( _elem362 ) <TAB> <TAB> <TAB> <TAB> iprot. readListEnd ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> if ftype == TType. LIST : <TAB> <TAB> <TAB> <TAB> self. exprs = [ ] <TAB> <TAB> <TAB> <TAB> ( _etype366, _size363 ) = iprot. readListBegin ( ) <TAB> <TAB> <TAB> <TAB> for _i367 in xrange ( _size363 ) : <TAB> <TAB> <TAB> <",True,fid == 2,fid == 2,0.6812487840652466
|
||
|
1722,"def __init__ ( self, slither, logger ) : <TAB> super ( ). __init__ ( slither, logger ) <TAB> inheritance = [ x. inheritance for x in slither. contracts ] <TAB> self. inheritance = { item for sublist in inheritance for item in sublist } <TAB> self. overshadowing_state_variables = { } <TAB> shadows = detect_state_variable_shadowing ( slither. contracts ) <TAB> for overshadowing_instance in shadows : <TAB> <TAB> overshadowing_state_var = overshadowing_instance [ 1 ] <TAB> <TAB> overshadowed_state_var = overshadowing_instance [ 3 ] <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. overshadowing_state_variables [ overshadowing_state_var ] = set ( ) <TAB> <TAB> self. overshadowing_state_variables [ overshadowing_state_var ]. add ( <TAB> <TAB> <TAB> overshadowed_state_var <TAB> <TAB> )",True,overshadowing_state_var not in self.overshadowing_state_variables,overshadowing_state_var not in self.overshadowing_state_variables,0.653820276260376
|
||
|
1723,"def reduce_NodeName_LPAREN_OptFuncArgList_RPAREN ( self, * kids ) : <TAB> module = kids [ 0 ]. val. module <TAB> func_name = kids [ 0 ]. val. name <TAB> name = func_name if not module else ( module, func_name ) <TAB> last_named_seen = None <TAB> args = [ ] <TAB> kwargs = { } <TAB> for argname, argname_ctx, arg in kids [ 2 ]. val : <TAB> <TAB> if argname is not None : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise EdgeQLSyntaxError ( <TAB> <TAB> <TAB> <TAB> <TAB> f""duplicate named argument `{argname}`"", context = argname_ctx <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> last_named_seen = argname <TAB> <TAB> <TAB> kwargs [ argname ] = arg <TAB> <TAB> else : <TAB> <TAB> <TAB> if last_named_seen is not None : <TAB> <TAB> <TAB> <TAB> raise EdgeQLSyntaxError ( <TAB> <TAB> <TAB> <TAB> <TAB> f""positional argument after named "" f""argument `{last_named_seen}`"", <TAB> <TAB> <TAB> <TAB> <TAB> context = arg. context, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> args. append ( arg ) <TAB> self. val = qlast. FunctionCall ( func = name, args = args, kwargs = kwargs )",False,argname in kwargs,argname in last_named_seen,0.6746421456336975
|
||
|
1724,"def find_prefix_cce ( directory ) : <TAB> results = find_rules ( directory, has_prefix_cce ) <TAB> print ( ""Number of rules with prefixed CCEs: %d"" % len ( results ) ) <TAB> for result in results : <TAB> <TAB> rule_path = result [ 0 ] <TAB> <TAB> product_yaml_path = result [ 1 ] <TAB> <TAB> product_yaml = None <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> product_yaml = yaml. open_raw ( product_yaml_path ) <TAB> <TAB> fix_file ( rule_path, product_yaml, fix_prefix_cce )",False,product_yaml_path is not None,yaml is not None,0.6574790477752686
|
||
|
1725,"def set_json_body ( cls, request_builder ) : <TAB> old_body = request_builder. info. pop ( ""data"", { } ) <TAB> if isinstance ( old_body, abc. Mapping ) : <TAB> <TAB> body = request_builder. info. setdefault ( ""json"", { } ) <TAB> <TAB> for path in old_body : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> cls. _sequence_path_resolver ( path, old_body [ path ], body ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> body [ path ] = old_body [ path ] <TAB> else : <TAB> <TAB> request_builder. info. setdefault ( ""json"", old_body )",False,"isinstance(path, tuple)","isinstance(path, abc.Mapping)",0.6489537954330444
|
||
|
1726,"def __init__ ( <TAB> self, <TAB> sequence : Optional [ Sequence ] = None, <TAB> np_histogram : Optional [ ""NumpyHistogram"" ] = None, <TAB> num_bins : int = 64, ) -> None : <TAB> if np_histogram : <TAB> <TAB> if len ( np_histogram ) == 2 : <TAB> <TAB> <TAB> self. histogram = ( <TAB> <TAB> <TAB> <TAB> np_histogram [ 0 ]. tolist ( ) <TAB> <TAB> <TAB> <TAB> if hasattr ( np_histogram [ 0 ], ""tolist"" ) <TAB> <TAB> <TAB> <TAB> else np_histogram [ 0 ] <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> self. bins = ( <TAB> <TAB> <TAB> <TAB> np_histogram [ 1 ]. tolist ( ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> else np_histogram [ 1 ] <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""Expected np_histogram to be a tuple of (values, bin_edges) or sequence to be specified"" <TAB> <TAB> <TAB> ) <TAB> else : <TAB> <TAB> np = util. get_module ( <TAB> <TAB> <TAB> ""numpy"", required = ""Auto creation of histograms requires numpy"" <TAB> <TAB> ) <TAB> <TAB> self. histogram, self. bins = np. histogram ( sequence, bins = num_bins ) <TAB> <TAB> self. histogram = self. histogram. tolist ( ) <TAB> <TAB> self. bins = self. bins. tolist ( ) <TAB> if len ( self. histogram ) > self. MAX_LENGTH : <TAB> <TAB> raise ValueError ( ""The maximum length of a histogram is %i"" % self. MAX_LENGTH ) <TAB> if len ( self. histogram ) + 1!= len ( self. bins ) : <TAB> <TAB> raise ValueError ( ""len(bins) must be len(histogram) +",False,"hasattr(np_histogram[1], 'tolist')","hasattr(np_histogram[1], 'bin_edges')",0.6648555994033813
|
||
|
1727,"def extract ( self ) : <TAB> for l in self. splitlines ( ) : <TAB> <TAB> if len ( l ) < 2 : <TAB> <TAB> <TAB> continue <TAB> <TAB> l [ 0 ]. split ( ) <TAB> <TAB> name = l [ 0 ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. set2 [ name ] = int ( l [ 2 ] ) <TAB> for i, name in enumerate ( self. vars ) : <TAB> <TAB> if self. counter [ i ] : <TAB> <TAB> <TAB> self. val [ name ] = ( self. set2 [ name ] - self. set1 [ name ] ) * 1.0 / elapsed <TAB> <TAB> else : <TAB> <TAB> <TAB> self. val [ name ] = self. set2 [ name ] <TAB> self. val [ ""total"" ] = self. val [ ""hits"" ] + self. val [ ""misses"" ] <TAB> if self. val [ ""total"" ] > 0 : <TAB> <TAB> self. val [ ""hit_rate"" ] = self. val [ ""hits"" ] / self. val [ ""total"" ] * 100.0 <TAB> else : <TAB> <TAB> self. val [ ""hit_rate"" ] = 0 <TAB> if step == op. delay : <TAB> <TAB> self. set1. update ( self. set2 )",True,name in self.vars,name in self.vars,0.6574908494949341
|
||
|
1728,"def __init__ ( <TAB> self, <TAB> env, <TAB> reward_scale = 1.0, <TAB> obs_mean = None, <TAB> obs_std = None, ) : <TAB> ProxyEnv. __init__ ( self, env ) <TAB> self. _should_normalize = not ( obs_mean is None and obs_std is None ) <TAB> if self. _should_normalize : <TAB> <TAB> if obs_mean is None : <TAB> <TAB> <TAB> obs_mean = np. zeros_like ( env. observation_space. low ) <TAB> <TAB> else : <TAB> <TAB> <TAB> obs_mean = np. array ( obs_mean ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> obs_std = np. ones_like ( env. observation_space. low ) <TAB> <TAB> else : <TAB> <TAB> <TAB> obs_std = np. array ( obs_std ) <TAB> self. _reward_scale = reward_scale <TAB> self. _obs_mean = obs_mean <TAB> self. _obs_std = obs_std <TAB> ub = np. ones ( self. _wrapped_env. action_space. shape ) <TAB> self. action_space = Box ( - 1 * ub, ub )",True,obs_std is None,obs_std is None,0.6698172092437744
|
||
|
1729,"def run_actor ( <TAB> agent : Agent, <TAB> rng_key : jnp. ndarray, <TAB> get_params : Callable [ [ ], hk. Params ], <TAB> enqueue_traj : Callable [ [ Transition ], None ], <TAB> unroll_len : int, <TAB> num_trajectories : int, ) : <TAB> """"""Runs an actor to produce num_trajectories trajectories."""""" <TAB> env = catch. Catch ( ) <TAB> state = env. reset ( ) <TAB> traj = [ ] <TAB> for i in range ( num_trajectories ) : <TAB> <TAB> params = get_params ( ) <TAB> <TAB> <TAB> <TAB> for _ in range ( unroll_len + int ( i == 0 ) ) : <TAB> <TAB> <TAB> rng_key, step_key = jax. random. split ( rng_key ) <TAB> <TAB> <TAB> state = preprocess_step ( state ) <TAB> <TAB> <TAB> action, logits = agent. step ( params, step_key, state ) <TAB> <TAB> <TAB> transition = Transition ( state, action, logits ) <TAB> <TAB> <TAB> traj. append ( transition ) <TAB> <TAB> <TAB> state = env. step ( action ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> logging. log_every_n ( <TAB> <TAB> <TAB> <TAB> <TAB> logging. INFO, ""Episode ended with reward: %s"", 5, state. reward <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> stacked_traj = jax. tree_multimap ( lambda * ts : np. stack ( ts ), * traj ) <TAB> <TAB> enqueue_traj ( stacked_traj ) <TAB> <TAB> <TAB> <TAB> traj = traj [ - 1 : ]",False,state.step_type == dm_env.StepType.LAST,state.reward is not None,0.6495782136917114
|
||
|
1730,"def dump ( self ) : <TAB> for field in self. _fields_ : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> print ( ""%s: 0x%x"" % ( field [ 0 ], getattr ( self, field [ 0 ] ). value ) ) <TAB> <TAB> elif isinstance ( getattr ( self, field [ 0 ] ), sysctl_oid_t. slist_entry ) : <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> ""%s: Struct( 0x%x )"" <TAB> <TAB> <TAB> <TAB> % ( field [ 0 ], getattr ( self, field [ 0 ] ). sle_next. value ) <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> print ( ""%s: 0x%x"" % ( field [ 0 ], getattr ( self, field [ 0 ] ) ) )",False,"isinstance(getattr(self, field[0]), POINTER64)","isinstance(field[0], six.string_types)",0.6474175453186035
|
||
|
1731,"def _set_uid ( self, val ) : <TAB> if val is not None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. bus. log ( ""pwd module not available; ignoring uid."", level = 30 ) <TAB> <TAB> <TAB> val = None <TAB> <TAB> elif isinstance ( val, text_or_bytes ) : <TAB> <TAB> <TAB> val = pwd. getpwnam ( val ) [ 2 ] <TAB> self. _uid = val",False,pwd is None,not pwd,0.6692845821380615
|
||
|
1732,"def compute_work_statistics ( self ) : <TAB> """"""Computes statistics from all work pieces stored in this class."""""" <TAB> result = { } <TAB> for v in itervalues ( self. work ) : <TAB> <TAB> submission_id = v [ ""submission_id"" ] <TAB> <TAB> if submission_id not in result : <TAB> <TAB> <TAB> result [ submission_id ] = { <TAB> <TAB> <TAB> <TAB> ""completed"" : 0, <TAB> <TAB> <TAB> <TAB> ""num_errors"" : 0, <TAB> <TAB> <TAB> <TAB> ""error_messages"" : set ( ), <TAB> <TAB> <TAB> <TAB> ""eval_times"" : [ ], <TAB> <TAB> <TAB> <TAB> ""min_eval_time"" : None, <TAB> <TAB> <TAB> <TAB> ""max_eval_time"" : None, <TAB> <TAB> <TAB> <TAB> ""mean_eval_time"" : None, <TAB> <TAB> <TAB> <TAB> ""median_eval_time"" : None, <TAB> <TAB> <TAB> } <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> result [ submission_id ] [ ""completed"" ] += 1 <TAB> <TAB> if ""error"" in v and v [ ""error"" ] : <TAB> <TAB> <TAB> result [ submission_id ] [ ""num_errors"" ] += 1 <TAB> <TAB> <TAB> result [ submission_id ] [ ""error_messages"" ]. add ( v [ ""error"" ] ) <TAB> <TAB> else : <TAB> <TAB> <TAB> result [ submission_id ] [ ""eval_times"" ]. append ( float ( v [ ""elapsed_time"" ] ) ) <TAB> for v in itervalues ( result ) : <TAB> <TAB> if v [ ""eval_times"" ] : <TAB> <TAB> <TAB> v [ ""min_eval_time"" ] = np. min ( v [ ""eval_times"" ] ) <TAB> <TAB> <TAB> v [ ""max_eval_time""",False,not v['is_completed'],'result' in result and result[submission_id],0.6580171585083008
|
||
|
1733,"def _find_base ( self, ptr ) : <TAB> page_size = 0x1000 <TAB> page_mask = ~ ( page_size - 1 ) <TAB> ptr &= page_mask <TAB> w = None <TAB> while True : <TAB> <TAB> if self. leak. compare ( ptr, b""\x7fELF"" ) : <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> fast = self. _find_base_optimized ( ptr ) <TAB> <TAB> if fast : <TAB> <TAB> <TAB> ptr = fast <TAB> <TAB> <TAB> continue <TAB> <TAB> ptr -= page_size <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( ""Address is negative, something is wrong!"" ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> w = w or self. waitfor ( ""Finding base address"" ) <TAB> <TAB> self. status ( ""%#x"" % ptr ) <TAB> <TAB> if w : <TAB> <TAB> self. success ( ""%#x"" % ptr ) <TAB> return ptr",True,ptr < 0,ptr < 0,0.6740406155586243
|
||
|
1734,"def _run ( args, fallback = None, only_first_line = False ) : <TAB> <TAB> try : <TAB> <TAB> lines = ( <TAB> <TAB> <TAB> subprocess. Popen ( args, stdout = subprocess. PIPE ). communicate ( ) [ 0 ]. splitlines ( ) <TAB> <TAB> ) <TAB> <TAB> result_lines = [ line. decode ( ""utf-8"" ) for line in lines ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return result_lines [ 0 ] <TAB> <TAB> else : <TAB> <TAB> <TAB> return result_lines <TAB> except : <TAB> <TAB> return fallback",True,only_first_line,only_first_line,0.6492031812667847
|
||
|
1735,"def substitute_out ( self, outvar, expr, subject = None, solver = None ) : <TAB> multiplier = self. terms. pop ( outvar ) <TAB> self. constant = self. constant + multiplier * expr. constant <TAB> for clv, coeff in expr. terms. items ( ) : <TAB> <TAB> old_coefficient = self. terms. get ( clv ) <TAB> <TAB> if old_coefficient : <TAB> <TAB> <TAB> new_coefficient = old_coefficient + multiplier * coeff <TAB> <TAB> <TAB> if approx_equal ( new_coefficient, 0 ) : <TAB> <TAB> <TAB> <TAB> solver. note_removed_variable ( clv, subject ) <TAB> <TAB> <TAB> <TAB> del self. terms [ clv ] <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. set_variable ( clv, new_coefficient ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. set_variable ( clv, multiplier * coeff ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> solver. note_added_variable ( clv, subject )",False,solver,"approx_equal(clv, 0)",0.7109112739562988
|
||
|
1736,"def get ( self, resultSpec, kwargs ) : <TAB> if ""buildid"" in kwargs : <TAB> <TAB> dbdict = yield self. master. db. builds. getBuild ( kwargs [ ""buildid"" ] ) <TAB> else : <TAB> <TAB> bldr = yield self. getBuilderId ( kwargs ) <TAB> <TAB> if bldr is None : <TAB> <TAB> <TAB> return <TAB> <TAB> num = kwargs [ ""number"" ] <TAB> <TAB> dbdict = yield self. master. db. builds. getBuildByNumber ( bldr, num ) <TAB> data = yield self. db2data ( dbdict ) if dbdict else None <TAB> <TAB> if data : <TAB> <TAB> filters = ( <TAB> <TAB> <TAB> resultSpec. popProperties ( ) if hasattr ( resultSpec, ""popProperties"" ) else [ ] <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> props = yield self. master. db. builds. getBuildProperties ( data [ ""buildid"" ] ) <TAB> <TAB> <TAB> except ( KeyError, TypeError ) : <TAB> <TAB> <TAB> <TAB> props = { } <TAB> <TAB> <TAB> filtered_properties = self. _generate_filtered_properties ( props, filters ) <TAB> <TAB> <TAB> if filtered_properties : <TAB> <TAB> <TAB> <TAB> data [ ""properties"" ] = filtered_properties <TAB> defer. returnValue ( data )",False,filters,data,0.7000559568405151
|
||
|
1737,"def _gethostbyname_ex ( self, hostname_bytes, family ) : <TAB> while True : <TAB> <TAB> ares = self. cares <TAB> <TAB> try : <TAB> <TAB> <TAB> waiter = Waiter ( self. hub ) <TAB> <TAB> <TAB> ares. gethostbyname ( waiter, hostname_bytes, family ) <TAB> <TAB> <TAB> result = waiter. get ( ) <TAB> <TAB> <TAB> if not result [ - 1 ] : <TAB> <TAB> <TAB> <TAB> raise herror ( EAI_NONAME, self. EAI_NONAME_MSG ) <TAB> <TAB> <TAB> return result <TAB> <TAB> except herror as ex : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> if ex. args [ 0 ] == 1 : <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> raise gaierror ( EAI_NONAME, self. EAI_NONAME_MSG ) <TAB> <TAB> <TAB> <TAB> raise",False,ares is self.cares,len(ex.args) > 0,0.6622622013092041
|
||
|
1738,"def get_context_data ( self, ** kwargs ) : <TAB> if not self. device. verified : <TAB> <TAB> messages. error ( <TAB> <TAB> <TAB> self. request, <TAB> <TAB> <TAB> ""{} - is not verified, you cannot "" <TAB> <TAB> <TAB> ""deploy this device"". format ( self. device ), <TAB> <TAB> ) <TAB> <TAB> <TAB> next_hostname = None <TAB> first_free_ip_addresses = [ ] <TAB> rack = self. device. find_rack ( ) <TAB> if rack : <TAB> <TAB> networks = rack. network_set. filter ( <TAB> <TAB> <TAB> environment__isnull = False, <TAB> <TAB> ). order_by ( ""name"" ) <TAB> <TAB> for network in networks : <TAB> <TAB> <TAB> next_hostname = get_next_free_hostname ( network. environment ) <TAB> <TAB> <TAB> if next_hostname : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> for network in networks : <TAB> <TAB> <TAB> first_free_ip = get_first_free_ip ( network. name ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> first_free_ip_addresses. append ( <TAB> <TAB> <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""network_name"" : network. name, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""first_free_ip"" : first_free_ip, <TAB> <TAB> <TAB> <TAB> <TAB> } <TAB> <TAB> <TAB> <TAB> ) <TAB> return { <TAB> <TAB> ""form"" : kwargs [ ""form"" ], <TAB> <TAB> ""device"" : self. device, <TAB> <TAB> ""next_hostname"" : next_hostname, <TAB> <TAB> ""first_free_ip_addresses"" : first_free_ip_addresses, <TAB> }",True,first_free_ip,first_free_ip,0.6588336229324341
|
||
|
1739,"def assertValidTree ( self, expected_tree ) : <TAB> root = Category. objects. root_category ( ) <TAB> queryset = Category. objects. filter ( tree_id = root. tree_id ). order_by ( ""lft"" ) <TAB> current_tree = [ ] <TAB> for category in queryset : <TAB> <TAB> current_tree. append ( <TAB> <TAB> <TAB> ( category, category. get_level ( ), category. lft, category. rght ) <TAB> <TAB> ) <TAB> for i, category in enumerate ( expected_tree ) : <TAB> <TAB> _category = current_tree [ i ] <TAB> <TAB> if category [ 0 ]!= _category [ 0 ] : <TAB> <TAB> <TAB> self. fail ( <TAB> <TAB> <TAB> <TAB> ( ""expected category at index #%s to be %s, "" ""found %s instead"" ) <TAB> <TAB> <TAB> <TAB> % ( i, category [ 0 ], _category [ 0 ] ) <TAB> <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. fail ( <TAB> <TAB> <TAB> <TAB> ( ""expected level at index #%s to be %s, "" ""found %s instead"" ) <TAB> <TAB> <TAB> <TAB> % ( i, category [ 1 ], _category [ 1 ] ) <TAB> <TAB> <TAB> ) <TAB> <TAB> if category [ 2 ]!= _category [ 2 ] : <TAB> <TAB> <TAB> self. fail ( <TAB> <TAB> <TAB> <TAB> ( ""expected lft at index #%s to be %s, "" ""found %s instead"" ) <TAB> <TAB> <TAB> <TAB> % ( i, category [ 2 ], _category [ 2 ] ) <TAB> <TAB> <TAB> ) <TAB> <TAB> if category [ 3 ]!= _category [ 3 ] : <TAB> <TAB> <TAB> self. fail ( <TAB> <TAB> <TAB> <TAB> ( ""expected lft at index #%s to be %s, "" ""found %s instead",True,category[1] != _category[1],category[1] != _category[1],0.6555683016777039
|
||
|
1740,"def evaluate_attribute_node ( self, node, to_string = False ) : <TAB> identifier = node. value. id + ""."" + node. attr <TAB> if isinstance ( self. simulator_config. item_dict [ identifier ], SimulatorProtocolLabel ) : <TAB> <TAB> label = self. simulator_config. item_dict [ identifier ] <TAB> <TAB> message = label. parent ( ) <TAB> <TAB> start, end = message. get_label_range ( label, 2 if<mask> : else 0, False ) <TAB> <TAB> return ( <TAB> <TAB> <TAB> message. plain_ascii_str [ start : end ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> else int ( message. plain_bits_str [ start : end ], 2 ) <TAB> <TAB> ) <TAB> elif isinstance ( <TAB> <TAB> self. simulator_config. item_dict [ identifier ], SimulatorCounterAction <TAB> ) : <TAB> <TAB> return self. simulator_config. item_dict [ identifier ]. value <TAB> elif isinstance ( <TAB> <TAB> self. simulator_config. item_dict [ identifier ], SimulatorTriggerCommandAction <TAB> ) : <TAB> <TAB> return self. simulator_config. item_dict [ identifier ]. return_code",True,to_string,to_string,0.6586556434631348
|
||
|
1741,"def _make_headers ( self ) : <TAB> libraries = self. _df. columns. to_list ( ) <TAB> columns = [ ] <TAB> for library in libraries : <TAB> <TAB> version = self. _package_versions [ library ] <TAB> <TAB> library_description = self. _libraries_description. get ( library ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> library += "" {}"". format ( library_description ) <TAB> <TAB> columns. append ( <TAB> <TAB> <TAB> ""{library}<br><small>{version}</small>"". format ( <TAB> <TAB> <TAB> <TAB> library = library, version = version <TAB> <TAB> <TAB> ) <TAB> <TAB> ) <TAB> return [ """" ] + columns",True,library_description,library_description,0.6712574362754822
|
||
|
1742,"def test_binary_grid_unaries ( ) : <TAB> <TAB> for ds in binary : <TAB> <TAB> X, Y = ds ( n_samples = 1 ) <TAB> <TAB> x, y = X [ 0 ], Y [ 0 ] <TAB> <TAB> for inference_method in get_installed ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> crf = GridCRF ( inference_method = inference_method ) <TAB> <TAB> <TAB> crf. initialize ( X, Y ) <TAB> <TAB> <TAB> w_unaries_only = np. zeros ( 7 ) <TAB> <TAB> <TAB> w_unaries_only [ : 4 ] = np. eye ( 2 ). ravel ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> inf_unaries = crf. inference ( x, w_unaries_only ) <TAB> <TAB> <TAB> assert_array_equal ( <TAB> <TAB> <TAB> <TAB> inf_unaries, <TAB> <TAB> <TAB> <TAB> np. argmax ( x, axis = 2 ), <TAB> <TAB> <TAB> <TAB> ""Wrong unary inference for %s"" % inference_method, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> assert np. mean ( inf_unaries == y ) > 0.5 <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> X, Y = ds ( n_samples = 1, noise = 0 ) <TAB> <TAB> <TAB> inf_unaries = crf. inference ( X [ 0 ], w_unaries_only ) <TAB> <TAB> <TAB> assert_array_equal ( <TAB> <TAB> <TAB> <TAB> inf_unaries, Y [ 0 ], ""Wrong unary result for %s"" % inference_method <TAB> <TAB> <TAB> )",False,inference_method == 'ad3+',"hasattr(i2, 'train_grid_unaries')",0.6619477868080139
|
||
|
1743,"def user_delete ( request, user_id, response_format = ""html"" ) : <TAB> ""User delete"" <TAB> profile = get_object_or_404 ( User, pk = user_id ) <TAB> message = """" <TAB> if profile == request. user. profile : <TAB> <TAB> message = _ ( ""This is you!"" ) <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if ""delete"" in request. POST : <TAB> <TAB> <TAB> <TAB> profile. delete ( ) <TAB> <TAB> <TAB> <TAB> return HttpResponseRedirect ( reverse ( ""core_admin_index_users"" ) ) <TAB> <TAB> <TAB> elif ""cancel"" in request. POST : <TAB> <TAB> <TAB> <TAB> return HttpResponseRedirect ( <TAB> <TAB> <TAB> <TAB> <TAB> reverse ( ""core_admin_user_view"", args = [ profile. id ] ) <TAB> <TAB> <TAB> <TAB> ) <TAB> return render_to_response ( <TAB> <TAB> ""core/administration/user_delete"", <TAB> <TAB> { ""profile"" : profile, ""message"" : message }, <TAB> <TAB> context_instance = RequestContext ( request ), <TAB> <TAB> response_format = response_format, <TAB> )",False,request.POST,profile.id in request.POST,0.6697162985801697
|
||
|
1744,"def gradients_X ( self, dL_dK, X, X2 = None ) : <TAB> <TAB> <TAB> if hasattr ( X, ""values"" ) : <TAB> <TAB> X = X. values <TAB> index = np. int_ ( X [ :, 1 ] ) <TAB> index = index. reshape ( <TAB> <TAB> index. size, <TAB> ) <TAB> X_flag = index [ 0 ] >= self. output_dim <TAB> <TAB> <TAB> <TAB> gX = np. zeros ( X. shape ) <TAB> if X2 is None : <TAB> <TAB> if X_flag : <TAB> <TAB> <TAB> index -= self. output_dim <TAB> <TAB> <TAB> gX [ :, 0 ] = 2.0 * ( dL_dK * self. _gkuu_X ( X, index ) ). sum ( 0 ) <TAB> <TAB> <TAB> return gX <TAB> <TAB> else : <TAB> <TAB> <TAB> raise NotImplementedError <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if hasattr ( X2, ""values"" ) : <TAB> <TAB> <TAB> X2 = X2. values <TAB> <TAB> index2 = np. int_ ( X2 [ :, 1 ] ) <TAB> <TAB> index2 = index2. reshape ( <TAB> <TAB> <TAB> index2. size, <TAB> <TAB> ) <TAB> <TAB> X2_flag = index2 [ 0 ] >= self. output_dim <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> index -= self. output_dim <TAB> <TAB> <TAB> gX [ :, 0 ] = ( dL_dK * self. _gkfu_z ( X2, index2, X, index ). T ). sum ( 1 ) <TAB> <TAB> <TAB> return gX <TAB> <TAB> else : <TAB> <TAB> <TAB> raise NotImplementedError",False,X_flag and (not X2_flag),X2_flag,0.651221752166748
|
||
|
1745,"def json ( self ) : <TAB> try : <TAB> <TAB> if self. is_json ( ) : <TAB> <TAB> <TAB> raw_data = self. raw_data ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raw_data = raw_data. decode ( ""utf-8"" ) <TAB> <TAB> <TAB> return json. loads ( raw_data ) <TAB> except ValueError : <TAB> <TAB> pass",False,"not isinstance(raw_data, text_type)",type(raw_data) == bytes,0.6492528915405273
|
||
|
1746,"def __getstate__ ( self ) : <TAB> prefs = { } <TAB> for id, ( val, typ ) in self. prefs. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> val = UnwrapObject ( val ) <TAB> <TAB> <TAB> except COMException : <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if val. _is_shadow : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> prefs [ id ] = val, typ <TAB> return ( self. id, self. preftype, self. idref, prefs )",False,typ == 'object',id == 0,0.661811351776123
|
||
|
1747,"def r_verb ( self ) : <TAB> <TAB> <TAB> self. ket = self. cursor <TAB> <TAB> among_var = self. find_among_b ( RussianStemmer. a_4, 46 ) <TAB> if among_var == 0 : <TAB> <TAB> return False <TAB> <TAB> self. bra = self. cursor <TAB> if among_var == 0 : <TAB> <TAB> return False <TAB> elif among_var == 1 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> v_1 = self. limit - self. cursor <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if not self. eq_s_b ( 1, u""\u0430"" ) : <TAB> <TAB> <TAB> <TAB> <TAB> raise lab1 ( ) <TAB> <TAB> <TAB> <TAB> raise lab0 ( ) <TAB> <TAB> <TAB> except lab1 : <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> self. cursor = self. limit - v_1 <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return False <TAB> <TAB> except lab0 : <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> <TAB> if not self. slice_del ( ) : <TAB> <TAB> <TAB> return False <TAB> elif among_var == 2 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if not self. slice_del ( ) : <TAB> <TAB> <TAB> return False <TAB> return True",False,"not self.eq_s_b(1, u'я')",not self.has_l_h(),0.6593855619430542
|
||
|
1748,"def mlist_delete ( request, mlist_id, response_format = ""html"" ) : <TAB> ""Delete mlist page"" <TAB> mlist = get_object_or_404 ( MailingList, pk = mlist_id ) <TAB> if not request. user. profile. has_permission ( mlist, mode = ""w"" ) : <TAB> <TAB> return user_denied ( <TAB> <TAB> <TAB> request, <TAB> <TAB> <TAB> message = ""You don't have access to this Mailing List"", <TAB> <TAB> <TAB> response_format = response_format, <TAB> <TAB> ) <TAB> if request. POST : <TAB> <TAB> if ""delete"" in request. POST : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> mlist. trash = True <TAB> <TAB> <TAB> <TAB> mlist. save ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> mlist. delete ( ) <TAB> <TAB> <TAB> return HttpResponseRedirect ( ""/messaging/"" ) <TAB> <TAB> elif ""cancel"" in request. POST : <TAB> <TAB> <TAB> return HttpResponseRedirect ( <TAB> <TAB> <TAB> <TAB> reverse ( ""messaging_mlist_view"", args = [ mlist. id ] ) <TAB> <TAB> <TAB> ) <TAB> context = _get_default_context ( request ) <TAB> context. update ( { ""mlist"" : mlist } ) <TAB> return render_to_response ( <TAB> <TAB> ""messaging/mlist_delete"", <TAB> <TAB> context, <TAB> <TAB> context_instance = RequestContext ( request ), <TAB> <TAB> response_format = response_format, <TAB> )",False,'trash' in request.POST,mlist.trash,0.6564432382583618
|
||
|
1749,"def fragment_count ( self ) : <TAB> table = self. fragmentruntable. payload. fragment_run_entry_table <TAB> first_fragment, end_fragment = None, None <TAB> for i, fragmentrun in enumerate ( table ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if fragmentrun. discontinuity_indicator == 0 : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> elif fragmentrun. discontinuity_indicator > 0 : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> if first_fragment is None : <TAB> <TAB> <TAB> first_fragment = fragmentrun. first_fragment <TAB> <TAB> end_fragment = fragmentrun. first_fragment <TAB> <TAB> fragment_duration = ( <TAB> <TAB> <TAB> fragmentrun. first_fragment_timestamp + fragmentrun. fragment_duration <TAB> <TAB> ) <TAB> <TAB> if self. timestamp > fragment_duration : <TAB> <TAB> <TAB> offset = ( <TAB> <TAB> <TAB> <TAB> self. timestamp - fragment_duration <TAB> <TAB> <TAB> ) / fragmentrun. fragment_duration <TAB> <TAB> <TAB> end_fragment += int ( offset ) <TAB> if first_fragment is None : <TAB> <TAB> first_fragment = 1 <TAB> if end_fragment is None : <TAB> <TAB> end_fragment = 1 <TAB> return first_fragment, end_fragment",False,fragmentrun.discontinuity_indicator is not None,i % 2 == 2,0.6555056571960449
|
||
|
1750,"def get_branch_name ( directory, config_file, get_func, create_watcher ) : <TAB> global branch_name_cache <TAB> with branch_lock : <TAB> <TAB> <TAB> <TAB> fw = branch_watcher ( create_watcher ) <TAB> <TAB> is_watched = fw. is_watching ( directory ) <TAB> <TAB> try : <TAB> <TAB> <TAB> changed = fw ( directory ) <TAB> <TAB> except OSError as e : <TAB> <TAB> <TAB> if getattr ( e, ""errno"", None )!= errno. ENOENT : <TAB> <TAB> <TAB> <TAB> raise <TAB> <TAB> <TAB> changed = True <TAB> <TAB> if changed : <TAB> <TAB> <TAB> branch_name_cache. pop ( config_file, None ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if is_watched : <TAB> <TAB> <TAB> <TAB> fw. unwatch ( directory ) <TAB> <TAB> <TAB> <TAB> fw. unwatch ( config_file ) <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> changed = fw ( config_file ) <TAB> <TAB> <TAB> except OSError as e : <TAB> <TAB> <TAB> <TAB> if getattr ( e, ""errno"", None )!= errno. ENOENT : <TAB> <TAB> <TAB> <TAB> <TAB> raise <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> branch_name_cache [ config_file ] = out_u ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> get_func ( directory, config_file ) <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> if changed : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> branch_name_cache [ config_file ] = out_u (",True,config_file not in branch_name_cache,config_file not in branch_name_cache,0.651280403137207
|
||
|
1751,"def follow_view ( request ) : <TAB> if request. method == ""GET"" : <TAB> <TAB> from auth. view_utils import render_template <TAB> <TAB> from auth. views import after <TAB> <TAB> return render_template ( <TAB> <TAB> <TAB> request, <TAB> <TAB> <TAB> ""twitter/follow"", <TAB> <TAB> <TAB> { ""user_to_follow"" : USER_TO_FOLLOW, ""reason_to_follow"" : REASON_TO_FOLLOW }, <TAB> <TAB> ) <TAB> if request. method == ""POST"" : <TAB> <TAB> follow_p = bool ( request. POST. get ( ""follow_p"", False ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> from auth. security import get_user <TAB> <TAB> <TAB> user = get_user ( request ) <TAB> <TAB> <TAB> twitter_client = _get_client_by_token ( user. token ) <TAB> <TAB> <TAB> result = twitter_client. oauth_request ( <TAB> <TAB> <TAB> <TAB> ""http://api.twitter.com/1/friendships/create.json"", <TAB> <TAB> <TAB> <TAB> args = { ""screen_name"" : USER_TO_FOLLOW }, <TAB> <TAB> <TAB> <TAB> method = ""POST"", <TAB> <TAB> <TAB> ) <TAB> <TAB> from auth. views import after_intervention <TAB> <TAB> return HttpResponseRedirect ( reverse ( after_intervention ) )",True,follow_p,follow_p,0.6676169633865356
|
||
|
1752,"def _merged_column_names_from ( self, dataset_list ) : <TAB> elements = [ ] <TAB> for idx_dataset, dataset in enumerate ( dataset_list ) : <TAB> <TAB> <TAB> <TAB> code = self. __dataset_objects__ ( ) [ idx_dataset ]. code <TAB> <TAB> for index, column_name in enumerate ( dataset. column_names ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if self. _include_column ( dataset, index ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> elements. append ( self. _rename_columns ( code, column_name ) ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> elements. append ( column_name ) <TAB> return list ( unique_everseen ( elements ) )",False,index > 0,code is not None,0.6690303087234497
|
||
|
1753,"def safe_repr ( val ) : <TAB> try : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> val = _obj_with_safe_repr ( val ) <TAB> <TAB> ret = repr ( val ) <TAB> <TAB> if six. PY2 : <TAB> <TAB> <TAB> ret = ret. decode ( ""utf-8"" ) <TAB> except UnicodeEncodeError : <TAB> <TAB> ret = red ( ""a %r that cannot be represented"" % type ( val ) ) <TAB> else : <TAB> <TAB> ret = green ( ret ) <TAB> return ret",False,"isinstance(val, dict)","hasattr(val, '__iter__')",0.6536378264427185
|
||
|
1754,"def extract ( self, obj, k ) : <TAB> if isinstance ( obj, Mapping ) : <TAB> <TAB> return obj. get ( k ) <TAB> elif isinstance ( obj, MutableSequence ) : <TAB> <TAB> cp = [ ] <TAB> <TAB> metadata = [ ] <TAB> <TAB> for l in obj : <TAB> <TAB> <TAB> if isinstance ( l, tuple ) : <TAB> <TAB> <TAB> <TAB> cp. append ( self. extract ( l [ 0 ], k ) ) <TAB> <TAB> <TAB> <TAB> metadata. append ( self. extract ( l [ 1 ], k ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> result = self. extract ( l, k ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> cp. append ( result [ 0 ] ) <TAB> <TAB> <TAB> <TAB> <TAB> metadata. append ( result [ 1 ] ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> cp. append ( result ) <TAB> <TAB> return cp, metadata <TAB> elif isinstance ( obj, tuple ) : <TAB> <TAB> return self. extract ( obj [ 0 ], k ) <TAB> else : <TAB> <TAB> return [ ]",False,"isinstance(result, tuple)","isinstance(result, list)",0.6535873413085938
|
||
|
1755,"def skip_to_close_match ( self ) : <TAB> nestedCount = 1 <TAB> while 1 : <TAB> <TAB> tok = self. tokenizer. get_next_token ( ) <TAB> <TAB> ttype = tok [ ""style"" ] <TAB> <TAB> if ttype == SCE_PL_UNUSED : <TAB> <TAB> <TAB> return <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> tval = tok [ ""text"" ] <TAB> <TAB> <TAB> if self. opHash. has_key ( tval ) : <TAB> <TAB> <TAB> <TAB> if self. opHash [ tval ] [ 1 ] == 1 : <TAB> <TAB> <TAB> <TAB> <TAB> nestedCount += 1 <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> nestedCount -= 1 <TAB> <TAB> <TAB> <TAB> <TAB> if nestedCount <= 0 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> break",False,self.classifier.is_index_op(tok),ttype == TCE_PL_LONG,0.6507596373558044
|
||
|
1756,"def _read_pidfiles ( self, pidfile_paths ) : <TAB> pidfiles = { } <TAB> for pidfile_path in pidfile_paths : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> try : <TAB> <TAB> <TAB> file_object = open ( pidfile_path, ""r"" ) <TAB> <TAB> <TAB> pidfiles [ pidfile_path ] = file_object. read ( ) <TAB> <TAB> <TAB> file_object. close ( ) <TAB> <TAB> except IOError : <TAB> <TAB> <TAB> continue <TAB> return pidfiles",True,not os.path.exists(pidfile_path),not os.path.exists(pidfile_path),0.6514861583709717
|
||
|
1757,"def apply_extractors ( descriptor, template_extractors, extractors ) : <TAB> type_processor_class = FieldTypeManager ( ). type_processor_class <TAB> if isinstance ( template_extractors, dict ) : <TAB> <TAB> template_extractors = template_extractors. items ( ) <TAB> attribute_map = descriptor. attribute_map <TAB> for field_name, field_extractors in template_extractors : <TAB> <TAB> equeue = [ ] <TAB> <TAB> for eid in field_extractors : <TAB> <TAB> <TAB> e_doc = extractors. get ( eid, { } ) <TAB> <TAB> <TAB> if ""regular_expression"" in e_doc : <TAB> <TAB> <TAB> <TAB> equeue. append ( create_regex_extractor ( e_doc [ ""regular_expression"" ] ) ) <TAB> <TAB> <TAB> elif ""type_extractor"" in e_doc : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> display_name = attribute_map [ field_name ]. description <TAB> <TAB> <TAB> <TAB> except KeyError : <TAB> <TAB> <TAB> <TAB> <TAB> display_name = field_name <TAB> <TAB> <TAB> <TAB> field_type = type_processor_class ( e_doc [ ""type_extractor"" ] ) ( ) <TAB> <TAB> <TAB> <TAB> attribute_map [ field_name ] = SlybotFieldDescriptor ( <TAB> <TAB> <TAB> <TAB> <TAB> field_name, display_name, field_type <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> if field_name not in attribute_map : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> attribute_map [ field_name ] = SlybotFieldDescriptor ( <TAB> <TAB> <TAB> <TAB> field_name, field_name, type_processor_class ( ""text"" ) ( ) <TAB> <TAB> <TAB> ) <TAB> <TAB> if",False,equeue,extractors,0.687211811542511
|
||
|
1758,"def process ( data ) : <TAB> if self. decryptor is not None : <TAB> <TAB> eof = not data <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. buffered += """". join ( <TAB> <TAB> <TAB> <TAB> [ c for c in data if c not in ( "" "", ""\t"", ""\r"", ""\n"" ) ] <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. buffered += data or """" <TAB> <TAB> data = """" <TAB> <TAB> for i in ( 256, 64, 8, 1 ) : <TAB> <TAB> <TAB> batch = max ( 1, i * self. decoder_data_bytes ) <TAB> <TAB> <TAB> while eof or ( len ( self. buffered ) >= batch ) : <TAB> <TAB> <TAB> <TAB> if self. decoder_data_bytes : <TAB> <TAB> <TAB> <TAB> <TAB> d = self. buffered [ : batch ] <TAB> <TAB> <TAB> <TAB> <TAB> b = self. buffered [ batch : ] <TAB> <TAB> <TAB> <TAB> <TAB> self. buffered = b <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> d, self. buffered = self. buffered, """" <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> data += self. decryptor ( self. decoder ( d ) ) <TAB> <TAB> <TAB> <TAB> <TAB> eof = False <TAB> <TAB> <TAB> <TAB> except TypeError : <TAB> <TAB> <TAB> <TAB> <TAB> raise IOError ( ""%s: Bad data, failed to decode"" % self. name ) <TAB> return data or """"",False,self.decoder_data_bytes and data,self.decoder_data_bytes,0.6579269170761108
|
||
|
1759,"def query_encrypted_roots_keys ( self, filters = None ) : <TAB> <TAB> <TAB> <TAB> <TAB> datasets = self. middleware. call_sync ( ""datastore.query"", self. dataset_store, filters ) <TAB> zfs_keys = self. middleware. call_sync ( ""kmip.retrieve_zfs_keys"" ) <TAB> keys = { } <TAB> for ds in datasets : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> keys [ ds [ ""name"" ] ] = ds [ ""encryption_key"" ] <TAB> <TAB> elif ds [ ""name"" ] in zfs_keys : <TAB> <TAB> <TAB> keys [ ds [ ""name"" ] ] = zfs_keys [ ds [ ""name"" ] ] <TAB> return keys",False,ds['encryption_key'],ds['encryption_key'] in keys,0.656036376953125
|
||
|
1760,"def capture ( self, run_info_dict ) : <TAB> <TAB> <TAB> logger. info ( f""Capturing repro information to {self._path}"" ) <TAB> with open_tar ( self. _path, ""w:gz"", dereference = True, compresslevel = 6 ) as tarout : <TAB> <TAB> for relpath in os. listdir ( self. _buildroot ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> tarout. add ( os. path. join ( self. _buildroot, relpath ), relpath ) <TAB> <TAB> with temporary_file ( binary_mode = False ) as tmpfile : <TAB> <TAB> <TAB> tmpfile. write ( ""# Pants repro captured for the following build:\n"" ) <TAB> <TAB> <TAB> for k, v in sorted ( run_info_dict. items ( ) ) : <TAB> <TAB> <TAB> <TAB> tmpfile. write ( f""# {k}: {v}\n"" ) <TAB> <TAB> <TAB> cmd_line = list ( sys. argv ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> cmd_line [ 0 ] = ""pants"" <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> cmd_line = [ x for x in cmd_line if not x. startswith ( ""--repro-"" ) ] <TAB> <TAB> <TAB> tmpfile. write ( ""'"" + ""' '"". join ( cmd_line ) + ""'\n"" ) <TAB> <TAB> <TAB> tmpfile. flush ( ) <TAB> <TAB> <TAB> chmod_plus_x ( tmpfile. name ) <TAB> <TAB> <TAB> tarout. add ( tmpfile. name, ""repro.sh"" )",False,relpath not in self._ignore,relpath != '',0.659044086933136
|
||
|
1761,"def _AdjustSashPosition ( self, idx, newPos1, newPos2 = - 1, adjustNeighbor = False ) : <TAB> total = newPos1 + newPos2 <TAB> <TAB> win1 = self. _windows [ idx ] <TAB> win2 = self. _windows [ idx + 1 ] <TAB> <TAB> minSize = self. _GetWindowMin ( win1 ) <TAB> if minSize == - 1 or self. _minimumPaneSize > minSize : <TAB> <TAB> minSize = self. _minimumPaneSize <TAB> minSize += self. _GetBorderSize ( ) <TAB> if newPos1 < minSize : <TAB> <TAB> newPos1 = minSize <TAB> <TAB> newPos2 = total - newPos1 <TAB> if adjustNeighbor : <TAB> <TAB> minSize = self. _GetWindowMin ( win2 ) <TAB> <TAB> if minSize == - 1 or self. _minimumPaneSize > minSize : <TAB> <TAB> <TAB> minSize = self. _minimumPaneSize <TAB> <TAB> minSize += self. _GetBorderSize ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> newPos2 = minSize <TAB> <TAB> <TAB> newPos1 = total - newPos2 <TAB> return ( newPos1, newPos2 )",False,newPos2 < minSize,newPos1 < newPos2,0.6815242767333984
|
||
|
1762,"def get ( self ) : <TAB> threshold = int ( self. get_argument ( ""threshold"", - 1 ) ) <TAB> m = MetricTransaction. get_tr_manager ( ) <TAB> self. write ( <TAB> <TAB> ""<table><tr><td>Id</td><td>Size</td><td>Error count</td><td>Next flush</td></tr>"" <TAB> ) <TAB> transactions = m. get_transactions ( ) <TAB> for tr in transactions : <TAB> <TAB> self. write ( <TAB> <TAB> <TAB> ""<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>"" <TAB> <TAB> <TAB> % ( tr. get_id ( ), tr. get_size ( ), tr. get_error_count ( ), tr. get_next_flush ( ) ) <TAB> <TAB> ) <TAB> self. write ( ""</table>"" ) <TAB> if threshold >= 0 : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. set_status ( 503 )",False,len(transactions) > threshold,self.set_status() >= 5,0.6573941111564636
|
||
|
1763,"def _parseOffer ( self, offer ) : <TAB> cores = 0 <TAB> memory = 0 <TAB> disk = 0 <TAB> preemptable = None <TAB> for attribute in offer. attributes : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> assert preemptable is None, ""Attribute 'preemptable' occurs more than once."" <TAB> <TAB> <TAB> preemptable = strict_bool ( attribute. text. value ) <TAB> if preemptable is None : <TAB> <TAB> log. debug ( <TAB> <TAB> <TAB> ""Agent not marked as either preemptable or not. Assuming non-preemptable."" <TAB> <TAB> ) <TAB> <TAB> preemptable = False <TAB> for resource in offer. resources : <TAB> <TAB> if resource. name == ""cpus"" : <TAB> <TAB> <TAB> cores += resource. scalar. value <TAB> <TAB> elif resource. name == ""mem"" : <TAB> <TAB> <TAB> memory += resource. scalar. value <TAB> <TAB> elif resource. name == ""disk"" : <TAB> <TAB> <TAB> disk += resource. scalar. value <TAB> return cores, memory, disk, preemptable",False,attribute.name == 'preemptable',attribute.text.value != 'preemptable',0.6523033380508423
|
||
|
1764,"def test ( self, text, s, e ) : <TAB> ret = { } <TAB> t = text [ s : e ] <TAB> if self. settings == ""atx"" : <TAB> <TAB> if not re. match ( self. ratx, t ) or re. match ( self. ratxc, t ) : <TAB> <TAB> <TAB> ret [ s ] = ""expected atx"" <TAB> elif self. settings == ""atx_closed"" : <TAB> <TAB> if not re. match ( self. ratxc, t ) : <TAB> <TAB> <TAB> ret [ s ] = ""expected atx_closed"" <TAB> elif self. settings == ""setext"" : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> ret [ s ] = ""expected setext"" <TAB> elif self. settings == ""any"" : <TAB> <TAB> if re. match ( self. ratx, t ) : <TAB> <TAB> <TAB> if re. match ( self. ratxc, t ) : <TAB> <TAB> <TAB> <TAB> self. settings = ""atx_closed"" <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. settings = ""atx"" <TAB> <TAB> <TAB> return self. test ( text, s, e ) <TAB> <TAB> elif re. match ( self. rsetext, t ) : <TAB> <TAB> <TAB> self. settings = ""setext"" <TAB> <TAB> <TAB> return self. test ( text, s, e ) <TAB> return ret",True,"not re.match(self.rsetext, t)","not re.match(self.rsetext, t)",0.648151159286499
|
||
|
1765,"def get_all_subnets ( self, subnet_ids = None, filters = None ) : <TAB> <TAB> matches = itertools. chain ( * [ x. values ( ) for x in self. subnets. values ( ) ] ) <TAB> if subnet_ids : <TAB> <TAB> matches = [ sn for sn in matches if sn. id in subnet_ids ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> unknown_ids = set ( subnet_ids ) - set ( matches ) <TAB> <TAB> <TAB> raise InvalidSubnetIdError ( unknown_ids ) <TAB> if filters : <TAB> <TAB> matches = generic_filter ( filters, matches ) <TAB> return matches",False,len(subnet_ids) > len(matches),subnet_ids,0.6546308398246765
|
||
|
1766,"def _get_item_columns_panel ( items, rows ) : <TAB> hbox = Gtk. HBox ( False, 4 ) <TAB> n_item = 0 <TAB> col_items = 0 <TAB> vbox = Gtk. VBox ( ) <TAB> hbox. pack_start ( vbox, False, False, 0 ) <TAB> while n_item < len ( items ) : <TAB> <TAB> item = items [ n_item ] <TAB> <TAB> vbox. pack_start ( item, False, False, 0 ) <TAB> <TAB> n_item += 1 <TAB> <TAB> col_items += 1 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> vbox = Gtk. VBox ( ) <TAB> <TAB> <TAB> hbox. pack_start ( vbox, False, False, 0 ) <TAB> <TAB> <TAB> col_items = 0 <TAB> return hbox",False,col_items > rows,n_item == len(items) - 1,0.672930896282196
|
||
|
1767,"def _cleanup ( self, exc = None ) : <TAB> """"""Clean up this channel"""""" <TAB> if self. _open_waiter : <TAB> <TAB> if not self. _open_waiter. cancelled ( ) : <TAB> <TAB> <TAB> self. _open_waiter. set_exception ( <TAB> <TAB> <TAB> <TAB> ChannelOpenError ( OPEN_CONNECT_FAILED, ""SSH connection closed"" ) <TAB> <TAB> <TAB> ) <TAB> <TAB> self. _open_waiter = None <TAB> if self. _request_waiters : <TAB> <TAB> for waiter in self. _request_waiters : <TAB> <TAB> <TAB> if not waiter. cancelled ( ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> waiter. set_exception ( exc ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> waiter. set_result ( False ) <TAB> <TAB> self. _request_waiters = [ ] <TAB> if self. _session : <TAB> <TAB> self. _session. connection_lost ( exc ) <TAB> <TAB> self. _session = None <TAB> self. _close_event. set ( ) <TAB> if self. _conn : <TAB> <TAB> self. logger. info ( ""Channel closed%s"", "": "" + str ( exc ) if exc else """" ) <TAB> <TAB> self. _conn. remove_channel ( self. _recv_chan ) <TAB> <TAB> self. _recv_chan = None <TAB> <TAB> self. _conn = None",True,exc,exc,0.6987417340278625
|
||
|
1768,"def _recursive_fx_apply ( input : dict, fx ) : <TAB> for k, v in input. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> v = torch. tensor ( v ) <TAB> <TAB> if isinstance ( v, torch. Tensor ) : <TAB> <TAB> <TAB> v = fx ( v. float ( ) ) <TAB> <TAB> <TAB> input [ k ] = v <TAB> <TAB> else : <TAB> <TAB> <TAB> _recursive_fx_apply ( v, fx )",False,"isinstance(v, list)","isinstance(v, dict)",0.6514344215393066
|
||
|
1769,"def get_student_courses ( self, student_id ) : <TAB> if student_id == ""*"" : <TAB> <TAB> student_id = ""{authenticated_user}"" <TAB> response = None <TAB> try : <TAB> <TAB> response = _query_jupyterhub_api ( ""GET"", ""/users/%s"" % student_id ) <TAB> except JupyterhubEnvironmentError : <TAB> <TAB> self. log. info ( ""Not running on Jupyterhub, not able to GET Jupyterhub user"" ) <TAB> <TAB> raise <TAB> except JupyterhubApiError : <TAB> <TAB> self. log. error ( ""Error: Not able to get Jupyterhub user: "" + student_id ) <TAB> <TAB> self. log. error ( <TAB> <TAB> <TAB> ""Make sure you start your service with a valid admin_user 'api_token' in your Jupyterhub config"" <TAB> <TAB> ) <TAB> <TAB> raise <TAB> courses = set ( ) <TAB> for group in response [ ""groups"" ] : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> course = group. split ( ""-"", 1 ) [ 1 ] <TAB> <TAB> <TAB> if course : <TAB> <TAB> <TAB> <TAB> courses. add ( course ) <TAB> return list ( courses )",False,group.startswith('nbgrader-') or group.startswith('formgrade-'),group,0.6459988355636597
|
||
|
1770,"def get_source ( self, fullname ) : <TAB> if fullname in self. _cache : <TAB> <TAB> compressed = self. _cache [ fullname ] [ 3 ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ModuleNotFoundError ( self. absent_msg % ( fullname, ) ) <TAB> <TAB> source = zlib. decompress ( self. _cache [ fullname ] [ 3 ] ) <TAB> <TAB> if PY3 : <TAB> <TAB> <TAB> return to_text ( source ) <TAB> <TAB> return source",False,compressed is None,compressed,0.6722270250320435
|
||
|
1771,def run ( self ) : <TAB> tid = self. ident <TAB> try : <TAB> <TAB> with self. _lock : <TAB> <TAB> <TAB> _GUIS [ tid ] = self <TAB> <TAB> <TAB> self. _state ( True ) <TAB> <TAB> self. new_mail_notifications ( summarize = True ) <TAB> <TAB> loop_count = 0 <TAB> <TAB> while self. _sock : <TAB> <TAB> <TAB> loop_count += 1 <TAB> <TAB> <TAB> self. _select_sleep ( 1 ) <TAB> <TAB> <TAB> self. change_state ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. new_mail_notifications ( ) <TAB> finally : <TAB> <TAB> del _GUIS [ tid ],False,loop_count % 5 == 0,loop_count >= 2,0.6665794849395752
|
||
|
1772,"def configure_create_table_epilogue ( store ) : <TAB> for val in [ """", "" ENGINE=InnoDB"" ] : <TAB> <TAB> store. config [ ""create_table_epilogue"" ] = val <TAB> <TAB> store. _set_sql_flavour ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> store. log. info ( ""create_table_epilogue='%s'"", val ) <TAB> <TAB> <TAB> return <TAB> raise Exception ( ""Can not create a transactional table."" )",False,store._test_transaction(),store.sql_flavour,0.6588602066040039
|
||
|
1773,"def search ( self, query ) : <TAB> query = query. strip ( ). lower ( ) <TAB> results = [ ] <TAB> for provider in SidebarItemProvider. all ( self. context ) : <TAB> <TAB> for item in provider. provide ( ) : <TAB> <TAB> <TAB> if ""url"" in item : <TAB> <TAB> <TAB> <TAB> search_source = ""$"". join ( <TAB> <TAB> <TAB> <TAB> <TAB> [ item. get ( ""id"", """" ), item. get ( ""name"", """" ) ] <TAB> <TAB> <TAB> <TAB> ). lower ( ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> results. append ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""title"" : item [ ""name"" ], <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""icon"" : item [ ""icon"" ], <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""url"" : item [ ""url"" ], <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> } <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> return results",False,query in search_source,query.find(search_source) >= 0,0.661675214767456
|
||
|
1774,"def list_revision ( <TAB> cmd, <TAB> key = None, <TAB> fields = None, <TAB> name = None, <TAB> label = None, <TAB> datetime = None, <TAB> connection_string = None, <TAB> top = None, <TAB> all_ = False, <TAB> auth_mode = ""key"", <TAB> endpoint = None, ) : <TAB> azconfig_client = get_appconfig_data_client ( <TAB> <TAB> cmd, name, connection_string, auth_mode, endpoint <TAB> ) <TAB> key = key if key else SearchFilterOptions. ANY_KEY <TAB> label = label if label else SearchFilterOptions. ANY_LABEL <TAB> label = prep_label_filter_for_url_encoding ( label ) <TAB> try : <TAB> <TAB> revisions_iterable = azconfig_client. list_revisions ( <TAB> <TAB> <TAB> key_filter = key, label_filter = label, accept_datetime = datetime, fields = fields <TAB> <TAB> ) <TAB> <TAB> retrieved_revisions = [ ] <TAB> <TAB> count = 0 <TAB> <TAB> if all_ : <TAB> <TAB> <TAB> top = float ( ""inf"" ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> top = 100 <TAB> <TAB> for revision in revisions_iterable : <TAB> <TAB> <TAB> kv_revision = convert_configurationsetting_to_keyvalue ( revision ) <TAB> <TAB> <TAB> if fields : <TAB> <TAB> <TAB> <TAB> partial_revision = { } <TAB> <TAB> <TAB> <TAB> for field in fields : <TAB> <TAB> <TAB> <TAB> <TAB> partial_revision [ field. name. lower ( ) ] = kv_revision. __dict__ [ <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> field. name. lower ( ) <TAB> <TAB> <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> <TAB> retrieved_revisions. append ( partial_revision ) <TAB> <TAB> <TAB> else : <TAB> <TAB",False,top is None,todos.count >= top,0.675089955329895
|
||
|
1775,"def read ( self ) : <TAB> if not os. path. exists ( self. filename ) : <TAB> <TAB> raise IOError ( ""Cannot find file '%s'"" % self. filename ) <TAB> self. FILE = open ( self. filename, ""r"" ) <TAB> tmp = [ ] <TAB> for tokens in csv. reader ( self. FILE ) : <TAB> <TAB> if tokens!= [ """" ] : <TAB> <TAB> <TAB> tmp. append ( tokens ) <TAB> self. FILE. close ( ) <TAB> if len ( tmp ) == 0 : <TAB> <TAB> raise IOError ( ""Empty *.csv file"" ) <TAB> elif len ( tmp ) == 1 : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if type ( self. options. param ) in ( list, tuple ) : <TAB> <TAB> <TAB> <TAB> p = self. options. param [ 0 ] <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> p = self. options. param <TAB> <TAB> <TAB> if isinstance ( p, Param ) : <TAB> <TAB> <TAB> <TAB> self. options. model = p. model ( ) <TAB> <TAB> <TAB> <TAB> p = p. name <TAB> <TAB> <TAB> self. _info = [ ""param"", p, "":="", tmp [ 0 ] [ 0 ] ] <TAB> <TAB> elif len ( self. options. symbol_map ) == 1 : <TAB> <TAB> <TAB> self. _info = [ <TAB> <TAB> <TAB> <TAB> ""param"", <TAB> <TAB> <TAB> <TAB> self. options. symbol_map [ self. options. symbol_map. keys ( ) [ 0 ] ], <TAB> <TAB> <TAB> <TAB> "":="", <TAB> <TAB> <TAB> <TAB> tmp [ 0 ] [ 0 ], <TAB> <TAB> <TAB> ] <TAB> <TAB> else : <TAB> <TAB> <TAB> raise IOError ( <TAB> <TAB> <TAB> <TAB> ""Data looks like a parameter, but multiple parameter names have",False,not self.options.param is None,self.options.param,0.6543909311294556
|
||
|
1776,"def _addItemToLayout ( self, sample, label ) : <TAB> col = self. layout. columnCount ( ) <TAB> row = self. layout. rowCount ( ) <TAB> if row : <TAB> <TAB> row -= 1 <TAB> nCol = self. columnCount * 2 <TAB> <TAB> if col == nCol : <TAB> <TAB> for col in range ( 0, nCol, 2 ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> if col + 2 == nCol : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> col = 0 <TAB> <TAB> <TAB> row += 1 <TAB> self. layout. addItem ( sample, row, col ) <TAB> self. layout. addItem ( label, row, col + 1 )",False,"not self.layout.itemAt(row, col)",col + 2 == nCol,0.6500959396362305
|
||
|
1777,"def flush_file ( self, key, f ) : <TAB> f. flush ( ) <TAB> if<mask> : <TAB> <TAB> f. compress = zlib. compressobj ( <TAB> <TAB> <TAB> 9, zlib. DEFLATED, - zlib. MAX_WBITS, zlib. DEF_MEM_LEVEL, 0 <TAB> <TAB> ) <TAB> if len ( self. files ) > self. MAX_OPEN_FILES : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> open_files = sum ( 1 for f in self. files. values ( ) if f. fileobj is not None ) <TAB> <TAB> <TAB> if open_files > self. MAX_OPEN_FILES : <TAB> <TAB> <TAB> <TAB> f. fileobj. close ( ) <TAB> <TAB> <TAB> <TAB> f. fileobj = None <TAB> <TAB> else : <TAB> <TAB> <TAB> f. close ( ) <TAB> <TAB> <TAB> self. files. pop ( key )",False,self.compress,key in self.files,0.6655057668685913
|
||
|
1778,"def update_stack ( self, full_name, template_url, parameters, tags ) : <TAB> """"""Updates an existing stack in CloudFormation."""""" <TAB> try : <TAB> <TAB> logger. info ( ""Attempting to update stack %s."", full_name ) <TAB> <TAB> self. conn. cloudformation. update_stack ( <TAB> <TAB> <TAB> full_name, <TAB> <TAB> <TAB> template_url = template_url, <TAB> <TAB> <TAB> parameters = parameters, <TAB> <TAB> <TAB> tags = tags, <TAB> <TAB> <TAB> capabilities = [ ""CAPABILITY_IAM"" ], <TAB> <TAB> ) <TAB> <TAB> return SUBMITTED <TAB> except BotoServerError as e : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> logger. info ( ""Stack %s did not change, not updating."", full_name ) <TAB> <TAB> <TAB> return SKIPPED <TAB> <TAB> raise",False,'No updates are to be performed.' in e.message,e.response['errorCode'] in ERROR_NO_UPDATE,0.6547338962554932
|
||
|
1779,"def load_modules ( self, modules, config ) : <TAB> """"""Load plugin modules."""""" <TAB> for pluginclass in get_plugin_classes ( modules ) : <TAB> <TAB> name = pluginclass. __name__ <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if issubclass ( pluginclass, _ConnectionPlugin ) : <TAB> <TAB> <TAB> <TAB> log. debug ( LOG_PLUGIN, ""Enable connection plugin %s"", name ) <TAB> <TAB> <TAB> <TAB> self. connection_plugins. append ( pluginclass ( config [ name ] ) ) <TAB> <TAB> <TAB> elif issubclass ( pluginclass, _ContentPlugin ) : <TAB> <TAB> <TAB> <TAB> log. debug ( LOG_PLUGIN, ""Enable content plugin %s"", name ) <TAB> <TAB> <TAB> <TAB> self. content_plugins. append ( pluginclass ( config [ name ] ) ) <TAB> <TAB> <TAB> elif issubclass ( pluginclass, _ParserPlugin ) : <TAB> <TAB> <TAB> <TAB> log. debug ( LOG_PLUGIN, ""Enable parser plugin %s"", name ) <TAB> <TAB> <TAB> <TAB> self. parser_plugins. append ( pluginclass ( config [ name ] ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> raise ValueError ( ""Invalid plugin class %s"" % pluginclass )",False,name in config['enabledplugins'],name in config,0.6623169183731079
|
||
|
1780,"def _move_cursor ( self, event ) : <TAB> Scrollbar. _move_cursor ( self, event ) <TAB> pos = event. clientY - self. line. getY ( ) <TAB> y = pos - self. cursor. getHeight ( ) / 2 <TAB> y = max ( y, 0 ) <TAB> y = min ( y, self. line. getHeight ( ) - self. cursor. getHeight ( ) - 2 ) <TAB> value = ( y / ( self. line. getHeight ( ) - self. cursor. getHeight ( ) - 2 ) ) * ( <TAB> <TAB> self. adjustment. upper - self. adjustment. page_size <TAB> ) <TAB> if event. type == ""click"" : <TAB> <TAB> old_value = self. adjustment. get_value ( ) <TAB> <TAB> if pos < 0 : <TAB> <TAB> <TAB> incr = self. adjustment. step_incr <TAB> <TAB> <TAB> self. adjustment. set_value ( old_value - incr ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> incr = self. adjustment. step_incr <TAB> <TAB> <TAB> self. adjustment. set_value ( old_value + incr ) <TAB> <TAB> else : <TAB> <TAB> <TAB> incr = self. adjustment. page_incr <TAB> <TAB> <TAB> if value > old_value : <TAB> <TAB> <TAB> <TAB> self. adjustment. set_value ( old_value + incr ) <TAB> <TAB> <TAB> elif value < old_value : <TAB> <TAB> <TAB> <TAB> self. adjustment. set_value ( old_value - incr ) <TAB> else : <TAB> <TAB> self. adjustment. set_value ( value )",False,pos > self.line.getHeight(),old_value < 0,0.6561996936798096
|
||
|
1781,"def scan_resource_conf ( self, conf ) : <TAB> if ""properties"" in conf : <TAB> <TAB> if ""logs"" in conf [ ""properties"" ] : <TAB> <TAB> <TAB> if conf [ ""properties"" ] [ ""logs"" ] : <TAB> <TAB> <TAB> <TAB> storage = { } <TAB> <TAB> <TAB> <TAB> for log in conf [ ""properties"" ] [ ""logs"" ] : <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if str ( log [ ""enabled"" ] ). lower ( ) == ""true"" : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> storage [ log [ ""category"" ] ] = True <TAB> <TAB> <TAB> <TAB> if ( <TAB> <TAB> <TAB> <TAB> <TAB> ""StorageRead"" in storage. keys ( ) <TAB> <TAB> <TAB> <TAB> <TAB> and ""StorageWrite"" in storage. keys ( ) <TAB> <TAB> <TAB> <TAB> <TAB> and ""StorageDelete"" in storage. keys ( ) <TAB> <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> <TAB> if ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> storage [ ""StorageRead"" ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> and storage [ ""StorageWrite"" ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> and storage [ ""StorageDelete"" ] <TAB> <TAB> <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return CheckResult. PASSED <TAB> return CheckResult. FAILED",False,'category' in log and 'enabled' in log,log['category'] in conf,0.657490611076355
|
||
|
1782,"def get_doc_object ( obj, what = None, doc = None, name = None, config = { } ) : <TAB> if what is None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> what = ""class"" <TAB> <TAB> elif inspect. ismodule ( obj ) : <TAB> <TAB> <TAB> what = ""module"" <TAB> <TAB> elif callable ( obj ) : <TAB> <TAB> <TAB> what = ""function"" <TAB> <TAB> else : <TAB> <TAB> <TAB> what = ""object"" <TAB> if what == ""class"" : <TAB> <TAB> return SphinxClassDoc ( <TAB> <TAB> <TAB> obj, func_doc = SphinxFunctionDoc, doc = doc, name = name, config = config <TAB> <TAB> ) <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 )",True,inspect.isclass(obj),inspect.isclass(obj),0.6542889475822449
|
||
|
1783,"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. STRING : <TAB> <TAB> <TAB> <TAB> self. ip = iprot. readString ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif fid == 2 : <TAB> <TAB> <TAB> if ftype == TType. I32 : <TAB> <TAB> <TAB> <TAB> self. start_time = iprot. readI32 ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> if ftype == TType. STRUCT : <TAB> <TAB> <TAB> <TAB> self. file = PacketCaptureFile ( ) <TAB> <TAB> <TAB> <TAB> self. file. read ( iprot ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif fid == 4 : <TAB> <TAB> <TAB> if ftype == TType. I32 : <TAB> <TAB> <TAB> <TAB> self. pid = iprot. readI32 ( )",True,fid == 3,fid == 3,0.6759360432624817
|
||
|
1784,"def load_data ( self ) : <TAB> from GPy. util. datasets import download_url, data_path <TAB> if<mask> : <TAB> <TAB> download_url ( Housing. url, self. datapath, messages = True ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return False <TAB> data = np. loadtxt ( os. path. join ( data_path, self. datapath, self. filename ) ) <TAB> self. data = data <TAB> data_train = data [ : 250, : - 1 ] <TAB> label_train = data [ : 250, - 1 : ] <TAB> self. train = ( data_train, label_train ) <TAB> data_test = data [ 250 :, : - 1 ] <TAB> label_test = data [ 250 :, - 1 : ] <TAB> self. test = ( data_test, label_test ) <TAB> return True",False,"not os.path.exists(os.path.join(data_path, self.datapath, self.filename))",not os.path.exists(data_path),0.6485799551010132
|
||
|
1785,"def printsumfp ( fp, filename, out = sys. stdout ) : <TAB> m = md5 ( ) <TAB> try : <TAB> <TAB> while 1 : <TAB> <TAB> <TAB> data = fp. read ( bufsize ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> if isinstance ( data, str ) : <TAB> <TAB> <TAB> <TAB> data = data. encode ( fp. encoding ) <TAB> <TAB> <TAB> m. update ( data ) <TAB> except IOError as msg : <TAB> <TAB> sys. stderr. write ( ""%s: I/O error: %s\n"" % ( filename, msg ) ) <TAB> <TAB> return 1 <TAB> out. write ( ""%s %s\n"" % ( m. hexdigest ( ), filename ) ) <TAB> return 0",True,not data,not data,0.6703860759735107
|
||
|
1786,"def FileHacks ( self ) : <TAB> """"""Hacks to make the filesystem look normal."""""" <TAB> if sys. platform == ""win32"" : <TAB> <TAB> import win32api <TAB> <TAB> <TAB> <TAB> if self. path == ""/"" : <TAB> <TAB> <TAB> self. files = win32api. GetLogicalDriveStrings ( ). split ( ""\x00"" ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. files = [ drive. rstrip ( ""\\"" ) for drive in self. files if drive ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. size = 0x7FFFFFFFFFFFFFFF <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. path = self. path. rstrip ( ""\\"" ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. alignment = 512 <TAB> elif sys. platform == ""darwin"" : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if re. match ( ""/dev/r?disk.*"", self. path ) : <TAB> <TAB> <TAB> self. size = 0x7FFFFFFFFFFFFFFF <TAB> <TAB> <TAB> self. alignment = 512",False,"re.match('/*\\\\\\\\.\\\\[^\\\\]+\\\\?$', self.path) is not None",sys.platform == 'win32',0.6573024988174438
|
||
|
1787,"def write ( self, command ) : <TAB> setting_multiline = get_setting ( ""format_multiline"", True ) <TAB> setting_trimwhitespace = get_setting ( ""format_trim_whitespace"", True ) <TAB> setting_injectlet = get_setting ( ""format_inject_let"", True ) <TAB> new_cmd = """" <TAB> if command. isspace ( ) or ( not setting_multiline and not setting_trimwhitespace ) : <TAB> <TAB> new_cmd = command <TAB> else : <TAB> <TAB> lines = command. splitlines ( True ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> lines = ghci_remove_whitespace ( lines ) <TAB> <TAB> if setting_injectlet : <TAB> <TAB> <TAB> lines = ghci_inject_let ( lines ) <TAB> <TAB> if setting_multiline : <TAB> <TAB> <TAB> lines = ghci_wrap_multiline_syntax ( lines ) <TAB> <TAB> new_cmd = """". join ( lines ) <TAB> return super ( SublimeHaskellRepl, self ). write ( new_cmd )",True,setting_trimwhitespace,setting_trimwhitespace,0.6628965735435486
|
||
|
1788,"def validate ( self, value, model_instance ) : <TAB> super ( ). validate ( value, model_instance ) <TAB> for l in value : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise exceptions. ValidationError ( <TAB> <TAB> <TAB> <TAB> self. error_messages [ ""delimiter_found"" ], <TAB> <TAB> <TAB> <TAB> code = ""delimiter_found"", <TAB> <TAB> <TAB> )",False,DELIMITER in l,l not in self.tables,0.6832408905029297
|
||
|
1789,"def delete ( self, repo, user = None ) : <TAB> if not user : <TAB> <TAB> user = self. username <TAB> try : <TAB> <TAB> self. gg. delete_repository ( user, repo ) <TAB> except ApiFailure as err : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ResourceNotFoundError ( <TAB> <TAB> <TAB> <TAB> ""Cannot delete: repository {}/{} does not exists."". format ( user, repo ) <TAB> <TAB> <TAB> ) from err <TAB> <TAB> elif err. status_code == 403 : <TAB> <TAB> <TAB> raise ResourcePermissionError ( <TAB> <TAB> <TAB> <TAB> ""You don't have enough permissions for deleting the repository. Check the namespace or the private token's privileges"" <TAB> <TAB> <TAB> ) from err <TAB> <TAB> elif err. status_code == 422 : <TAB> <TAB> <TAB> raise ResourceNotFoundError ( <TAB> <TAB> <TAB> <TAB> ""Cannot delete repository {}/{}: user {} does not exists."". format ( <TAB> <TAB> <TAB> <TAB> <TAB> user, repo, user <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) from err <TAB> <TAB> raise ResourceError ( ""Unhandled error: {}"". format ( err ) ) from err <TAB> except Exception as err : <TAB> <TAB> raise ResourceError ( ""Unhandled exception: {}"". format ( err ) ) from err",True,err.status_code == 404,err.status_code == 404,0.6534093022346497
|
||
|
1790,"def display_failures_for_single_test ( result : TestResult ) -> None : <TAB> """"""Display a failure for a single method / endpoint."""""" <TAB> display_subsection ( result ) <TAB> checks = _get_unique_failures ( result. checks ) <TAB> for idx, check in enumerate ( checks, 1 ) : <TAB> <TAB> message : Optional [ str ] <TAB> <TAB> if check. message : <TAB> <TAB> <TAB> message = f""{idx}. {check.message}"" <TAB> <TAB> else : <TAB> <TAB> <TAB> message = None <TAB> <TAB> example = cast ( Case, check. example ) <TAB> <TAB> display_example ( example, check. name, message, result. seed ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> click. echo ( ""\n"" )",False,idx != len(checks),result.print_errors,0.6549217700958252
|
||
|
1791,"def main ( ) : <TAB> pop = toolbox. population ( n = 5 ) <TAB> stats = tools. Statistics ( lambda ind : ind. fitness. values ) <TAB> stats. register ( ""avg"", numpy. mean ) <TAB> stats. register ( ""std"", numpy. std ) <TAB> stats. register ( ""min"", numpy. min ) <TAB> stats. register ( ""max"", numpy. max ) <TAB> logbook = tools. Logbook ( ) <TAB> logbook. header = [ ""gen"", ""evals"" ] + stats. fields <TAB> GEN = 1000 <TAB> best = None <TAB> for g in range ( GEN ) : <TAB> <TAB> for part in pop : <TAB> <TAB> <TAB> part. fitness. values = toolbox. evaluate ( part ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> part. best = creator. Particle ( part ) <TAB> <TAB> <TAB> <TAB> part. best. fitness. values = part. fitness. values <TAB> <TAB> <TAB> if best is None or best. fitness < part. fitness : <TAB> <TAB> <TAB> <TAB> best = creator. Particle ( part ) <TAB> <TAB> <TAB> <TAB> best. fitness. values = part. fitness. values <TAB> <TAB> for part in pop : <TAB> <TAB> <TAB> toolbox. update ( part, best ) <TAB> <TAB> <TAB> <TAB> logbook. record ( gen = g, evals = len ( pop ), ** stats. compile ( pop ) ) <TAB> <TAB> print ( logbook. stream ) <TAB> return pop, logbook, best",False,part.best is None or part.best.fitness < part.fitness,creator is not None,0.6480889916419983
|
||
|
1792,"def batch_iterator ( <TAB> inputs, <TAB> targets = None, <TAB> batch_size = None, <TAB> shuffle = False, <TAB> allow_smaller_batch = False, <TAB> repeat = True, ) : <TAB> """"""A generator that provides batches of samples from the provided inputs."""""" <TAB> if isinstance ( inputs, set ) : <TAB> <TAB> inputs = np. asarray ( list ( inputs ) ) <TAB> if not isinstance ( inputs, ( np. ndarray, list ) ) : <TAB> <TAB> raise TypeError ( ""Unsupported data type %s encountered."" % type ( inputs ) ) <TAB> if targets is not None and not isinstance ( targets, ( np. ndarray, list ) ) : <TAB> <TAB> raise TypeError ( ""Unsupported data type %s encountered."" % type ( targets ) ) <TAB> num_samples = len ( inputs ) <TAB> if batch_size is None : <TAB> <TAB> batch_size = num_samples <TAB> if batch_size > num_samples : <TAB> <TAB> allow_smaller_batch = True <TAB> keep_going = True <TAB> while keep_going : <TAB> <TAB> indexes = np. arange ( 0, num_samples ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> np. random. shuffle ( indexes ) <TAB> <TAB> shuffled_inputs = inputs [ indexes ] <TAB> <TAB> if targets is not None : <TAB> <TAB> <TAB> shuffled_targets = targets [ indexes ] <TAB> <TAB> for start_index in range ( 0, num_samples, batch_size ) : <TAB> <TAB> <TAB> if allow_smaller_batch : <TAB> <TAB> <TAB> <TAB> end_index = min ( start_index + batch_size, num_samples ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> end_index = start_index + batch_size <TAB> <TAB> <TAB> <TAB> if end_index > num_samples : <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> batch_inputs = shuffled",True,shuffle,shuffle,0.7065909504890442
|
||
|
1793,"def get_system_stats ( proc_path = None ) : <TAB> systemStats = { <TAB> <TAB> ""machine"" : platform. machine ( ), <TAB> <TAB> ""platform"" : sys. platform, <TAB> <TAB> ""processor"" : platform. processor ( ), <TAB> <TAB> ""pythonV"" : platform. python_version ( ), <TAB> } <TAB> platf = sys. platform <TAB> try : <TAB> <TAB> if Platform. is_linux ( platf ) : <TAB> <TAB> <TAB> if not proc_path : <TAB> <TAB> <TAB> <TAB> proc_path = ""/proc"" <TAB> <TAB> <TAB> proc_cpuinfo = os. path. join ( proc_path, ""cpuinfo"" ) <TAB> <TAB> <TAB> output, _, _ = get_subprocess_output ( <TAB> <TAB> <TAB> <TAB> [ ""grep"", ""model name"", proc_cpuinfo ], log <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> systemStats [ ""cpuCores"" ] = len ( output. splitlines ( ) ) <TAB> <TAB> if Platform. is_darwin ( platf ) or Platform. is_freebsd ( platf ) : <TAB> <TAB> <TAB> output, _, _ = get_subprocess_output ( [ ""sysctl"", ""hw.ncpu"" ], log ) <TAB> <TAB> <TAB> systemStats [ ""cpuCores"" ] = int ( output. split ( "": "" ) [ 1 ] ) <TAB> except SubprocessOutputEmptyError as e : <TAB> <TAB> log. warning ( ""unable to retrieve number of cpuCores. Failed with error %s"", e ) <TAB> if Platform. is_linux ( platf ) : <TAB> <TAB> name, version, codename = distro. linux_distribution ( <TAB> <TAB> <TAB> full_distribution_name = False <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> name = ""amazon"" <TAB> <TAB> systemStats [ ""nixV"" ] = ( name, version,",False,name == 'amzn',codename,0.653171181678772
|
||
|
1794,"def everythingIsUnicode ( d ) : <TAB> """"""Takes a dictionary, recursively verifies that every value is unicode"""""" <TAB> for k, v in d. iteritems ( ) : <TAB> <TAB> if isinstance ( v, dict ) and k!= ""headers"" : <TAB> <TAB> <TAB> if not everythingIsUnicode ( v ) : <TAB> <TAB> <TAB> <TAB> return False <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> for i in v : <TAB> <TAB> <TAB> <TAB> if isinstance ( i, dict ) and not everythingIsUnicode ( i ) : <TAB> <TAB> <TAB> <TAB> <TAB> return False <TAB> <TAB> <TAB> <TAB> elif isinstance ( i, _bytes ) : <TAB> <TAB> <TAB> <TAB> <TAB> return False <TAB> <TAB> elif isinstance ( v, _bytes ) : <TAB> <TAB> <TAB> return False <TAB> return True",True,"isinstance(v, list)","isinstance(v, list)",0.654982328414917
|
||
|
1795,"def execute ( <TAB> self, <TAB> host, <TAB> port = ""513"", <TAB> luser = ""root"", <TAB> user = """", <TAB> password = None, <TAB> prompt_re = ""\w+:"", <TAB> timeout = ""10"", <TAB> persistent = ""1"", ) : <TAB> fp, _ = self. bind ( host, port, timeout = int ( timeout ) ) <TAB> trace = """" <TAB> timeout = int ( timeout ) <TAB> with Timing ( ) as timing : <TAB> <TAB> if self. need_handshake : <TAB> <TAB> <TAB> fp. write ( ""\x00%s\x00%s\x00vt100/9600\x00"" % ( luser, user ) ) <TAB> <TAB> <TAB> self. need_handshake = False <TAB> <TAB> else : <TAB> <TAB> <TAB> fp. write ( ""%s\r"" % user ) <TAB> <TAB> _, _, resp = fp. expect ( <TAB> <TAB> <TAB> [ prompt_re ], timeout = timeout <TAB> <TAB> ) <TAB> <TAB> trace += resp <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> fp. write ( ""%s\r"" % password ) <TAB> <TAB> <TAB> _, _, resp = fp. expect ( <TAB> <TAB> <TAB> <TAB> [ prompt_re ], timeout = timeout <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> trace += resp <TAB> if persistent == ""0"" : <TAB> <TAB> self. reset ( ) <TAB> mesg = repr ( resp. strip ( ) ) [ 1 : - 1 ] <TAB> return self. Response ( 0, mesg, timing, trace )",False,password is not None,password != None,0.6597955226898193
|
||
|
1796,"def move_stdout_to_stderr ( self ) : <TAB> to_remove = [ ] <TAB> to_add = [ ] <TAB> for consumer_level, consumer in self. consumers : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> to_remove. append ( ( consumer_level, consumer ) ) <TAB> <TAB> <TAB> to_add. append ( ( consumer_level, sys. stderr ) ) <TAB> for item in to_remove : <TAB> <TAB> self. consumers. remove ( item ) <TAB> self. consumers. extend ( to_add )",False,consumer == sys.stdout,consumer,0.6693646311759949
|
||
|
1797,"def import_submodules ( package_name ) : <TAB> package = sys. modules [ package_name ] <TAB> results = { } <TAB> for loader, name, is_pkg in pkgutil. iter_modules ( package. __path__ ) : <TAB> <TAB> full_name = package_name + ""."" + name <TAB> <TAB> module = importlib. import_module ( full_name ) <TAB> <TAB> setattr ( sys. modules [ __name__ ], name, module ) <TAB> <TAB> results [ full_name ] = module <TAB> <TAB> if is_pkg : <TAB> <TAB> <TAB> valid_pkg = import_submodules ( full_name ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> results. update ( valid_pkg ) <TAB> return results",True,valid_pkg,valid_pkg,0.6771539449691772
|
||
|
1798,"def fix_e712 ( self, result ) : <TAB> """"""Fix comparison with boolean."""""" <TAB> line_index = result [ ""line"" ] - 1 <TAB> target = self. source [ line_index ] <TAB> offset = result [ ""column"" ] - 1 <TAB> <TAB> if re. match ( r""^\s*if \w+ == False:$"", target ) : <TAB> <TAB> self. source [ line_index ] = re. sub ( <TAB> <TAB> <TAB> r""if (\w+) == False:"", r""if not \1:"", target, count = 1 <TAB> <TAB> ) <TAB> elif re. match ( r""^\s*if \w+!= True:$"", target ) : <TAB> <TAB> self. source [ line_index ] = re. sub ( <TAB> <TAB> <TAB> r""if (\w+)!= True:"", r""if not \1:"", target, count = 1 <TAB> <TAB> ) <TAB> else : <TAB> <TAB> right_offset = offset + 2 <TAB> <TAB> if right_offset >= len ( target ) : <TAB> <TAB> <TAB> return [ ] <TAB> <TAB> left = target [ : offset ]. rstrip ( ) <TAB> <TAB> center = target [ offset : right_offset ] <TAB> <TAB> right = target [ right_offset : ]. lstrip ( ) <TAB> <TAB> <TAB> <TAB> new_right = None <TAB> <TAB> if center. strip ( ) == ""=="" : <TAB> <TAB> <TAB> if re. match ( r""\bTrue\b"", right ) : <TAB> <TAB> <TAB> <TAB> new_right = re. sub ( r""\bTrue\b *"", """", right, count = 1 ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> if re. match ( r""\bFalse\b"", right ) : <TAB> <TAB> <TAB> <TAB> new_right = re. sub ( r""\bFalse\b *"", """", right, count = 1 ) <TAB> <TAB> if new_right is None : <TAB",False,center.strip() == '!=',"re.match('\\bFalse\\b', left)",0.661246120929718
|
||
|
1799,"def check ( self, runner, script, info ) : <TAB> if isinstance ( info, ast. FunctionDef ) : <TAB> <TAB> for arg in info. args. args : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> if arg. id in script. modelVars : <TAB> <TAB> <TAB> <TAB> <TAB> self. problem ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""Function {0} may shadow model variable {1}"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> info. name, arg. id <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> lineno = info. lineno, <TAB> <TAB> <TAB> <TAB> <TAB> )",False,"isinstance(arg, ast.Name)","hasattr(script, 'modelVars')",0.6494197249412537
|
||
|
1800,"def encryptBlock ( self, plainTextBlock ) : <TAB> """"""CBC block encryption, IV is set with 'encrypt'"""""" <TAB> auto_IV = """" <TAB> if self. encryptBlockCount == 0 : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. iv = """". join ( <TAB> <TAB> <TAB> <TAB> [ chr ( self. r. randrange ( 256 ) ) for i in range ( self. blockSize ) ] <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> self. prior_encr_CT_block = self. iv <TAB> <TAB> <TAB> auto_IV = self. prior_encr_CT_block <TAB> <TAB> else : <TAB> <TAB> <TAB> assert len ( self. iv ) == self. blockSize, ""IV must be same length as block"" <TAB> <TAB> <TAB> self. prior_encr_CT_block = self. iv <TAB> """""" encrypt the prior CT XORed with the PT """""" <TAB> ct = self. baseCipher. encryptBlock ( xor ( self. prior_encr_CT_block, plainTextBlock ) ) <TAB> self. prior_encr_CT_block = ct <TAB> return auto_IV + ct",False,self.iv == None,self.iv_len == 0,0.6667077541351318
|
||
|
1801,"def _extract_config ( self, project, test_suites, target_test_case = None ) : <TAB> execution = [ ] <TAB> scenarios = { } <TAB> project_properties = self. _extract_properties ( project, key_prefix = ""#Project#"" ) <TAB> project_name = project. get ( ""name"" ) <TAB> interface_exec, interface_scen = self. _extract_interface ( <TAB> <TAB> project_name, self. interface <TAB> ) <TAB> execution. append ( interface_exec ) <TAB> scenarios. update ( interface_scen ) <TAB> for suite in test_suites : <TAB> <TAB> suite_props = BetterDict. from_dict ( project_properties ) <TAB> <TAB> suite_props. merge ( self. _extract_properties ( suite, key_prefix = ""#TestSuite#"" ) ) <TAB> <TAB> test_cases = suite. findall ( "".//con:testCase"", namespaces = self. NAMESPACES ) <TAB> <TAB> for case in test_cases : <TAB> <TAB> <TAB> case_name = case. get ( ""name"" ) <TAB> <TAB> <TAB> scenario_name, scenario = self. _extract_test_case ( case, suite, suite_props ) <TAB> <TAB> <TAB> load_exec = self. _extract_execution ( case ) <TAB> <TAB> <TAB> load_exec [ ""scenario"" ] = scenario_name <TAB> <TAB> <TAB> self. log. debug ( ""Extracted execution for scenario %s"", scenario_name ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. log. warning ( <TAB> <TAB> <TAB> <TAB> <TAB> ""No requests extracted for scenario %s, skipping it"" % scenario_name <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if target_test_case is None or target_test_case == case_name : <TAB> <TAB> <TAB> <TAB> self. log. debug ( ""Extracted scenario: %s"", scenario",False,not scenario['requests'],load_exec['scenario'] is None,0.6616487503051758
|
||
|
1802,"def make_node ( self, x, y, ilist ) : <TAB> ctx_name = infer_context_name ( x, y ) <TAB> x_ = as_gpuarray_variable ( x, ctx_name ) <TAB> y_ = as_gpuarray_variable ( y, ctx_name ) <TAB> ilist_ = tensor. as_tensor_variable ( ilist ) <TAB> assert x_. type. ndim >= y_. type. ndim <TAB> if ilist_. type. dtype not in tensor. integer_dtypes : <TAB> <TAB> raise TypeError ( ""index must be integers"" ) <TAB> if ilist_. type. ndim!= 1 : <TAB> <TAB> raise TypeError ( ""index must be vector"" ) <TAB> if x_. type. ndim == 0 : <TAB> <TAB> raise TypeError ( ""cannot index into a scalar"" ) <TAB> if y_. type. ndim > x_. type. ndim : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> opname = ""set"" <TAB> <TAB> else : <TAB> <TAB> <TAB> opname = ""increment"" <TAB> <TAB> raise TypeError ( <TAB> <TAB> <TAB> ""cannot %s x subtensor with ndim=%s by y with ndim=%s "" <TAB> <TAB> <TAB> % ( opname, x_. type. ndim, y_. type. ndim ) <TAB> <TAB> ) <TAB> return gof. Apply ( self, [ x_, y_, ilist_ ], [ x_. type ( ) ] )",False,self.set_instead_of_inc,x_.type.dtype == tensor.integer_dtypes,0.6508128643035889
|
||
|
1803,"def pre_make ( self, data, ** kwargs ) : <TAB> schema = data. get ( ""schema"" ) <TAB> kind = data. get ( ""kind"" ) <TAB> if schema and kind : <TAB> <TAB> schema [ ""kind"" ] = ""custom"" <TAB> <TAB> if kind in V1ConnectionKind. BLOB_VALUES : <TAB> <TAB> <TAB> schema [ ""kind"" ] = V1BucketConnection. IDENTIFIER <TAB> <TAB> if kind == V1ConnectionKind. VOLUME_CLAIM : <TAB> <TAB> <TAB> schema [ ""kind"" ] = V1ClaimConnection. IDENTIFIER <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> schema [ ""kind"" ] = V1HostPathConnection. IDENTIFIER <TAB> <TAB> if kind == V1ConnectionKind. REGISTRY : <TAB> <TAB> <TAB> schema [ ""kind"" ] = V1HostConnection. IDENTIFIER <TAB> <TAB> if kind == V1ConnectionKind. GIT : <TAB> <TAB> <TAB> schema [ ""kind"" ] = V1GitConnection. IDENTIFIER <TAB> return data",False,kind == V1ConnectionKind.HOST_PATH,kind == V1ConnectionKind.PATH,0.662108838558197
|
||
|
1804,"def _sniff ( filename, oxlitype ) : <TAB> try : <TAB> <TAB> with open ( filename, ""rb"" ) as fileobj : <TAB> <TAB> <TAB> header = fileobj. read ( 4 ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> fileobj. read ( 1 ) <TAB> <TAB> <TAB> <TAB> ftype = fileobj. read ( 1 ) <TAB> <TAB> <TAB> <TAB> if binascii. hexlify ( ftype ) == oxlitype : <TAB> <TAB> <TAB> <TAB> <TAB> return True <TAB> <TAB> return False <TAB> except OSError : <TAB> <TAB> return False",False,header == b'OXLI',len(header) > 4,0.6647782921791077
|
||
|
1805,"def close ( self, * args, ** kwargs ) : <TAB> super ( mytqdm, self ). close ( * args, ** kwargs ) <TAB> <TAB> if hasattr ( self, ""sp"" ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. sp ( bar_style = ""danger"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if self. leave : <TAB> <TAB> <TAB> <TAB> self. sp ( bar_style = ""success"" ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. sp ( close = True )",False,self.total and self.n < self.total,self.leave,0.6521770358085632
|
||
|
1806,"def check ( self ) : <TAB> response = b"""" <TAB> payload = b""\x00"" * 8 <TAB> udp_client = self. udp_create ( ) <TAB> udp_client. send ( payload ) <TAB> if udp_client : <TAB> <TAB> response = udp_client. recv ( 1024 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if response. endswith ( b""\xD0\xA5Login:"" ) : <TAB> <TAB> <TAB> <TAB> return True <TAB> <TAB> <TAB> elif response. endswith ( <TAB> <TAB> <TAB> <TAB> b""\x00\x00\x00\x05\x00\x01\x00\x00\x00\x00\x01\x00\x00"" <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> return True <TAB> return False",True,response,response,0.693464994430542
|
||
|
1807,"def visit_Attribute ( self, node ) : <TAB> self. generic_visit ( node ) <TAB> reserved = ( <TAB> <TAB> ""next"", <TAB> <TAB> ""posedge"", <TAB> <TAB> ""negedge"", <TAB> <TAB> ""max"", <TAB> <TAB> ""min"", <TAB> <TAB> ""val"", <TAB> <TAB> ""signed"", <TAB> <TAB> ""verilog_code"", <TAB> <TAB> ""vhdl_code"", <TAB> ) <TAB> if node. attr in reserved : <TAB> <TAB> return node <TAB> <TAB> if not isinstance ( node. value, ast. Name ) : <TAB> <TAB> return node <TAB> <TAB> if node. value. id not in self. data. symdict : <TAB> <TAB> return node <TAB> obj = self. data. symdict [ node. value. id ] <TAB> <TAB> if isinstance ( obj, ( EnumType, FunctionType ) ) : <TAB> <TAB> return node <TAB> elif isinstance ( obj, SignalType ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return node <TAB> attrobj = getattr ( obj, node. attr ) <TAB> orig_name = node. value. id + ""."" + node. attr <TAB> if orig_name not in self. name_map : <TAB> <TAB> base_name = node. value. id + ""_"" + node. attr <TAB> <TAB> self. name_map [ orig_name ] = _suffixer ( base_name, self. data. symdict ) <TAB> new_name = self. name_map [ orig_name ] <TAB> self. data. symdict [ new_name ] = attrobj <TAB> self. data. objlist. append ( new_name ) <TAB> new_node = ast. Name ( id = new_name, ctx = node. value. ctx ) <TAB> return ast. copy_location ( new_node, node )",False,"hasattr(SignalType, node.attr)","hasattr(obj, node.attr)",0.651077389717102
|
||
|
1808,"def get_items ( <TAB> cls, <TAB> *, <TAB> html : str = """", <TAB> url : str = """", <TAB> html_etree : etree. _Element = None, <TAB> ** kwargs, ) : <TAB> if html_etree is None : <TAB> <TAB> html_etree = await cls. _get_html ( html, url, ** kwargs ) <TAB> items_field = getattr ( cls, ""__fields"", { } ). get ( ""target_item"", None ) <TAB> if items_field : <TAB> <TAB> items_field. many = True <TAB> <TAB> items_html_etree = items_field. extract ( html_etree = html_etree, is_source = True ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> for each_html_etree in items_html_etree : <TAB> <TAB> <TAB> <TAB> item = await cls. _parse_html ( html_etree = each_html_etree ) <TAB> <TAB> <TAB> <TAB> if not item. ignore_item : <TAB> <TAB> <TAB> <TAB> <TAB> yield item <TAB> <TAB> else : <TAB> <TAB> <TAB> value_error_info = ""<Item: Failed to get target_item's value from"" <TAB> <TAB> <TAB> if url : <TAB> <TAB> <TAB> <TAB> value_error_info = f""{value_error_info} url: {url}.>"" <TAB> <TAB> <TAB> if html : <TAB> <TAB> <TAB> <TAB> value_error_info = f""{value_error_info} html.>"" <TAB> <TAB> <TAB> raise ValueError ( value_error_info ) <TAB> else : <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> f""<Item: target_item is expected, more info: https://docs.python-ruia.org/en/apis/item.html>"" <TAB> <TAB> )",True,items_html_etree,items_html_etree,0.6595181226730347
|
||
|
1809,"def poll ( timeout = 0.0, map = None ) : <TAB> if map is None : <TAB> <TAB> map = socket_map <TAB> if map : <TAB> <TAB> r = [ ] <TAB> <TAB> w = [ ] <TAB> <TAB> e = [ ] <TAB> <TAB> for fd, obj in list ( map. items ( ) ) : <TAB> <TAB> <TAB> is_r = obj. readable ( ) <TAB> <TAB> <TAB> is_w = obj. writable ( ) <TAB> <TAB> <TAB> if is_r : <TAB> <TAB> <TAB> <TAB> r. append ( fd ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if is_w and not obj. accepting : <TAB> <TAB> <TAB> <TAB> w. append ( fd ) <TAB> <TAB> <TAB> if is_r or is_w : <TAB> <TAB> <TAB> <TAB> e. append ( fd ) <TAB> <TAB> if [ ] == r == w == e : <TAB> <TAB> <TAB> time. sleep ( timeout ) <TAB> <TAB> <TAB> return <TAB> <TAB> r, w, e = select. select ( r, w, e, timeout ) <TAB> <TAB> for fd in r : <TAB> <TAB> <TAB> obj = map. get ( fd ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> read ( obj ) <TAB> <TAB> for fd in w : <TAB> <TAB> <TAB> obj = map. get ( fd ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> write ( obj ) <TAB> <TAB> for fd in e : <TAB> <TAB> <TAB> obj = map. get ( fd ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> _exception ( obj )",False,obj is None,obj == w,0.6680967807769775
|
||
|
1810,"def _execute_combine ( cls, ctx, op : ""DataFrameEwmAgg"" ) : <TAB> try : <TAB> <TAB> cls. _exec_cache [ op. key ] = dict ( ) <TAB> <TAB> if len ( op. inputs )!= 1 : <TAB> <TAB> <TAB> pred_data = ctx [ op. inputs [ 1 ]. key ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> pred_exponent = pred_data [ - 2 ]. shift ( - 1 ) [ : : - 1 ]. cumsum ( ) [ : : - 1 ]. fillna ( 0 ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> succ_counts = pred_data [ - 1 ]. shift ( - 1 ) <TAB> <TAB> <TAB> <TAB> succ_counts. iloc [ - 1 ] = 0 <TAB> <TAB> <TAB> <TAB> pred_exponent = pred_data [ - 2 ]. add ( <TAB> <TAB> <TAB> <TAB> <TAB> succ_counts [ : : - 1 ]. cumsum ( ) [ : : - 1 ], axis = op. axis <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> cls. _exec_cache [ op. key ] [ ""pred_exponent"" ] = pred_exponent <TAB> <TAB> super ( ). _execute_combine ( ctx, op ) <TAB> finally : <TAB> <TAB> cls. _exec_cache. pop ( op. key, None )",False,op.alpha_ignore_na,len(pred_data.shape) == 3,0.660312294960022
|
||
|
1811,def _get_error_file ( self ) -> Optional [ str ] : <TAB> error_file = None <TAB> min_timestamp = sys. maxsize <TAB> for replicas in self. role_replicas. values ( ) : <TAB> <TAB> for replica in replicas : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> mtime = os. path. getmtime ( replica. error_file ) <TAB> <TAB> <TAB> if mtime < min_timestamp : <TAB> <TAB> <TAB> <TAB> min_timestamp = mtime <TAB> <TAB> <TAB> <TAB> error_file = replica. error_file <TAB> return error_file,False,not os.path.exists(replica.error_file),replica.error_file is None,0.6474065780639648
|
||
|
1812,"def _infer_return_type ( * args ) : <TAB> """"""Look at the type of all args and divine their implied return type."""""" <TAB> return_type = None <TAB> for arg in args : <TAB> <TAB> if arg is None : <TAB> <TAB> <TAB> continue <TAB> <TAB> if isinstance ( arg, bytes ) : <TAB> <TAB> <TAB> if return_type is str : <TAB> <TAB> <TAB> <TAB> raise TypeError ( ""Can't mix bytes and non-bytes in "" ""path components."" ) <TAB> <TAB> <TAB> return_type = bytes <TAB> <TAB> else : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise TypeError ( ""Can't mix bytes and non-bytes in "" ""path components."" ) <TAB> <TAB> <TAB> return_type = str <TAB> if return_type is None : <TAB> <TAB> return str <TAB> return return_type",False,return_type is bytes,return_type is str,0.6595941781997681
|
||
|
1813,"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<mask> : <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 fid == 2 : <TAB> <TAB> <TAB> if ftype == TType. STRING : <TAB> <TAB> <TAB> <TAB> self. requestorUserName = 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. roleName = iprot. readString ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif fid == 4 : <TAB> <TAB> <TAB> if ftype == TType. STRING : <TAB> <TAB> <TAB> <TAB> self. component = iprot. readString ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot",False,ftype == TType.STOP,fid == 0,0.6630985736846924
|
||
|
1814,"def get_token ( self ) : <TAB> ""Get a token from the input stream (or from stack if it's nonempty)"" <TAB> if self. pushback : <TAB> <TAB> tok = self. pushback. popleft ( ) <TAB> <TAB> if self. debug >= 1 : <TAB> <TAB> <TAB> print ( ""shlex: popping token "" + repr ( tok ) ) <TAB> <TAB> return tok <TAB> <TAB> raw = self. read_token ( ) <TAB> <TAB> if self. source is not None : <TAB> <TAB> while raw == self. source : <TAB> <TAB> <TAB> spec = self. sourcehook ( self. read_token ( ) ) <TAB> <TAB> <TAB> if spec : <TAB> <TAB> <TAB> <TAB> ( newfile, newstream ) = spec <TAB> <TAB> <TAB> <TAB> self. push_source ( newstream, newfile ) <TAB> <TAB> <TAB> raw = self. get_token ( ) <TAB> <TAB> while raw == self. eof : <TAB> <TAB> if not self. filestack : <TAB> <TAB> <TAB> return self. eof <TAB> <TAB> else : <TAB> <TAB> <TAB> self. pop_source ( ) <TAB> <TAB> <TAB> raw = self. get_token ( ) <TAB> <TAB> if self. debug >= 1 : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> print ( ""shlex: token="" + repr ( raw ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> print ( ""shlex: token=EOF"" ) <TAB> return raw",False,raw != self.eof,raw,0.6653341054916382
|
||
|
1815,"def assert_open ( self, sock, * rest ) : <TAB> if isinstance ( sock, fd_types ) : <TAB> <TAB> self. __assert_fd_open ( sock ) <TAB> else : <TAB> <TAB> fileno = sock. fileno ( ) <TAB> <TAB> assert isinstance ( fileno, fd_types ), fileno <TAB> <TAB> sockname = sock. getsockname ( ) <TAB> <TAB> assert isinstance ( sockname, tuple ), sockname <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. __assert_fd_open ( fileno ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. _assert_sock_open ( sock ) <TAB> if rest : <TAB> <TAB> self. assert_open ( rest [ 0 ], * rest [ 1 : ] )",False,not WIN,"isinstance(sock, fd_types)",0.7034542560577393
|
||
|
1816,"def palindromic_substrings ( s ) : <TAB> if not s : <TAB> <TAB> return [ [ ] ] <TAB> results = [ ] <TAB> for i in range ( len ( s ), 0, - 1 ) : <TAB> <TAB> sub = s [ : i ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> for rest in palindromic_substrings ( s [ i : ] ) : <TAB> <TAB> <TAB> <TAB> results. append ( [ sub ] + rest ) <TAB> return results",False,sub == sub[::-1],sub,0.6545841097831726
|
||
|
1817,"def inner ( self, * iargs, ** ikwargs ) : <TAB> try : <TAB> <TAB> return getattr ( super ( VEXResilienceMixin, self ), func ) ( * iargs, ** ikwargs ) <TAB> except excs as e : <TAB> <TAB> for exc, handler in zip ( excs, handlers ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> v = getattr ( self, handler ) ( * iargs, ** ikwargs ) <TAB> <TAB> <TAB> <TAB> if v is raiseme : <TAB> <TAB> <TAB> <TAB> <TAB> raise <TAB> <TAB> <TAB> <TAB> return v <TAB> <TAB> assert False, ""this should be unreachable if Python is working correctly""",False,"isinstance(e, exc)","hasattr(self, handler)",0.6545758843421936
|
||
|
1818,"def _create_network_filters ( <TAB> self, instance, network_info, instance_secgroup_filter_name ) : <TAB> if instance [ ""image_ref"" ] == str ( FLAGS. vpn_image_id ) : <TAB> <TAB> base_filter = ""nova-vpn"" <TAB> else : <TAB> <TAB> base_filter = ""nova-base"" <TAB> result = [ ] <TAB> for ( _n, mapping ) in network_info : <TAB> <TAB> nic_id = mapping [ ""mac"" ]. replace ( "":"", """" ) <TAB> <TAB> instance_filter_name = self. _instance_filter_name ( instance, nic_id ) <TAB> <TAB> instance_filter_children = [ <TAB> <TAB> <TAB> base_filter, <TAB> <TAB> <TAB> ""nova-provider-rules"", <TAB> <TAB> <TAB> instance_secgroup_filter_name, <TAB> <TAB> ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> instance_filter_children. append ( ""nova-project"" ) <TAB> <TAB> <TAB> if FLAGS. use_ipv6 : <TAB> <TAB> <TAB> <TAB> instance_filter_children. append ( ""nova-project-v6"" ) <TAB> <TAB> result. append ( ( instance_filter_name, instance_filter_children ) ) <TAB> return result",False,FLAGS.allow_same_net_traffic,FLAGS.project,0.6486634016036987
|
||
|
1819,"def select_singularity ( self ) : <TAB> """"""Set singularity executable and related variables"""""" <TAB> conf = Config ( ) <TAB> self. executable = conf. use_singularity_executable <TAB> if self. executable!= ""UDOCKER"" and not self. executable : <TAB> <TAB> self. executable = FileUtil ( ""singularity"" ). find_exec ( ) <TAB> if self. executable == ""UDOCKER"" or not self. executable : <TAB> <TAB> self. executable = """" <TAB> <TAB> arch = HostInfo ( ). arch ( ) <TAB> <TAB> image_list = [ ] <TAB> <TAB> if arch == ""amd64"" : <TAB> <TAB> <TAB> image_list = [ ""singularity-x86_64"", ""singularity"" ] <TAB> <TAB> elif arch == ""i386"" : <TAB> <TAB> <TAB> image_list = [ ""singularity-x86"", ""singularity"" ] <TAB> <TAB> elif arch == ""arm64"" : <TAB> <TAB> <TAB> image_list = [ ""singularity-arm64"", ""singularity"" ] <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> image_list = [ ""singularity-arm"", ""singularity"" ] <TAB> <TAB> f_util = FileUtil ( self. localrepo. bindir ) <TAB> <TAB> self. executable = f_util. find_file_in_dir ( image_list ) <TAB> if not os. path. exists ( self. executable ) : <TAB> <TAB> Msg ( ). err ( ""Error: singularity executable not found"" ) <TAB> <TAB> sys. exit ( 1 )",False,arch == 'arm',arch == 'locallocal',0.6654393672943115
|
||
|
1820,"def check_weights ( x, y, key : str, index = None ) : <TAB> for i in [ 2, 0 ] : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> left = x [ i ]. get_master_weight ( ) <TAB> <TAB> right = y [ i ]. weight. data <TAB> <TAB> if not torch. allclose ( left, right, atol = 1.0e-6 ) or index is not None : <TAB> <TAB> <TAB> print ( f""check_weights {key}-{i}: left = {left}, \nright = {right}"" ) <TAB> <TAB> if not torch. equal ( left, right ) : <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> f""check_weights NOT_EQUAL {key}-{i}: left = {left}, \nright = {right}"" <TAB> <TAB> <TAB> ) <TAB> <TAB> assert torch. allclose ( left, right, atol = 1.0e-6 )",False,index is not None and i != index,x[i] == y[i],0.6566314697265625
|
||
|
1821,"def configuration_install ( <TAB> app, <TAB> uri, <TAB> verify_ssl, <TAB> config_type = None, <TAB> args = None, <TAB> source_folder = None, <TAB> target_folder = None, ) : <TAB> cache, output, requester = app. cache, app. out, app. requester <TAB> configs = [ ] <TAB> configs_file = cache. config_install_file <TAB> if os. path. isfile ( configs_file ) : <TAB> <TAB> configs = _load_configs ( configs_file ) <TAB> if uri is None : <TAB> <TAB> if config_type or args or not verify_ssl : <TAB> <TAB> <TAB> if not configs : <TAB> <TAB> <TAB> <TAB> raise ConanException ( ""Called config install without arguments"" ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> config = configs [ - 1 ] <TAB> <TAB> <TAB> config. config_type = config_type or config. type <TAB> <TAB> <TAB> config. args = args or config. args <TAB> <TAB> <TAB> config. verify_ssl = verify_ssl or config. verify_ssl <TAB> <TAB> <TAB> _process_config ( config, cache, output, requester ) <TAB> <TAB> <TAB> _save_configs ( configs_file, configs ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if not configs : <TAB> <TAB> <TAB> <TAB> raise ConanException ( ""Called config install without arguments"" ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for config in configs : <TAB> <TAB> <TAB> <TAB> output. info ( ""Config install: %s"" % _hide_password ( config. uri ) ) <TAB> <TAB> <TAB> <TAB> _process_config ( config, cache, output, requester ) <TAB> <TAB> <TAB> touch ( cache. config_install_file ) <TAB> else : <TAB> <TAB> <TAB> <TAB> config = _ConfigOrigin. from_item ( <TAB> <TAB> <TAB>",False,config not in configs,source_folder,0.6635862588882446
|
||
|
1822,"def main ( argv = None ) : <TAB> if not argv : <TAB> <TAB> argv = sys. argv <TAB> s = Store ( ) <TAB> if argv [ 1 ] in ( ""help"", ""--help"", ""h"", ""-h"" ) : <TAB> <TAB> help ( ) <TAB> elif argv [ 1 ] == ""whoami"" : <TAB> <TAB> if os. path. exists ( storefn ) : <TAB> <TAB> <TAB> print ( list ( s. who ( ) ) [ 0 ] ) <TAB> <TAB> else : <TAB> <TAB> <TAB> s. who ( argv [ 2 ] ) <TAB> elif argv [ 1 ]. startswith ( ""http://www.imdb.com/title/tt"" ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise <TAB> <TAB> else : <TAB> <TAB> <TAB> i = imdb. IMDb ( ) <TAB> <TAB> <TAB> movie = i. get_movie ( argv [ 1 ] [ len ( ""http://www.imdb.com/title/tt"" ) : - 1 ] ) <TAB> <TAB> <TAB> print ( ""%s (%s)"" % ( movie [ ""title"" ]. encode ( ""utf-8"" ), movie [ ""year"" ] ) ) <TAB> <TAB> <TAB> for director in movie [ ""director"" ] : <TAB> <TAB> <TAB> <TAB> print ( ""directed by: %s"" % director [ ""name"" ]. encode ( ""utf-8"" ) ) <TAB> <TAB> <TAB> for writer in movie [ ""writer"" ] : <TAB> <TAB> <TAB> <TAB> print ( ""written by: %s"" % writer [ ""name"" ]. encode ( ""utf-8"" ) ) <TAB> <TAB> <TAB> s. new_movie ( movie ) <TAB> <TAB> <TAB> rating = None <TAB> <TAB> <TAB> while not rating or ( rating > 5 or rating <= 0 ) : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> rating",False,s.movie_is_in(argv[1]),len(argv) < 3,0.6518588066101074
|
||
|
1823,"def test_assert_set_equal ( estimate : tp. Iterable [ int ], message : str ) -> None : <TAB> reference = { 1, 2, 3 } <TAB> try : <TAB> <TAB> testing. assert_set_equal ( estimate, reference ) <TAB> except AssertionError as error : <TAB> <TAB> if not message : <TAB> <TAB> <TAB> raise AssertionError ( <TAB> <TAB> <TAB> <TAB> ""An error has been raised while it should not."" <TAB> <TAB> <TAB> ) from error <TAB> <TAB> np. testing. assert_equal ( error. args [ 0 ]. split ( ""\n"" ) [ 1 : ], message ) <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise AssertionError ( ""An error should have been raised."" )",False,message,not estimate,0.694068193435669
|
||
|
1824,"def _buffered_generator ( self, size ) : <TAB> buf = [ ] <TAB> c_size = 0 <TAB> push = buf. append <TAB> while 1 : <TAB> <TAB> try : <TAB> <TAB> <TAB> while c_size < size : <TAB> <TAB> <TAB> <TAB> c = next ( self. _gen ) <TAB> <TAB> <TAB> <TAB> push ( c ) <TAB> <TAB> <TAB> <TAB> if c : <TAB> <TAB> <TAB> <TAB> <TAB> c_size += 1 <TAB> <TAB> except StopIteration : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> yield concat ( buf ) <TAB> <TAB> del buf [ : ] <TAB> <TAB> c_size = 0",False,not c_size,len(buf) == 0,0.6614516973495483
|
||
|
1825,"def getExecutionCode ( self, required ) : <TAB> yield ""if material is not None:"" <TAB> yield "" if not material.is_grease_pencil:"" <TAB> yield "" bpy.data.materials.create_gpencil_data(material)"" <TAB> s = self. inputs <TAB> isShowStroke = s [ ""Show Stroke"" ]. isUsed <TAB> isStrokeDrawMode = s [ ""Stroke Draw Mode"" ]. isUsed <TAB> isStrokeColor = s [ ""Stroke Color"" ]. isUsed <TAB> isShowFill = s [ ""Show Fill"" ]. isUsed <TAB> isFillColor = s [ ""Fill Color"" ]. isUsed <TAB> isPassIndex = s [ ""Pass Index"" ]. isUsed <TAB> if any ( <TAB> <TAB> [ <TAB> <TAB> <TAB> isShowStroke, <TAB> <TAB> <TAB> isStrokeDrawMode, <TAB> <TAB> <TAB> isStrokeColor, <TAB> <TAB> <TAB> isShowFill, <TAB> <TAB> <TAB> isFillColor, <TAB> <TAB> <TAB> isPassIndex, <TAB> <TAB> ] <TAB> ) : <TAB> <TAB> yield "" gpMaterial = material.grease_pencil"" <TAB> <TAB> if isShowStroke : <TAB> <TAB> <TAB> yield "" gpMaterial.show_stroke = showStroke"" <TAB> <TAB> if isStrokeDrawMode : <TAB> <TAB> <TAB> yield "" self.setStrokeDrawMode(gpMaterial, strokeDrawMode)"" <TAB> <TAB> if isStrokeColor : <TAB> <TAB> <TAB> yield "" gpMaterial.color = strokeColor"" <TAB> <TAB> if isShowFill : <TAB> <TAB> <TAB> yield "" gpMaterial.show_fill = showFill"" <TAB> <TAB> if isFillColor : <TAB> <TAB> <TAB> yield "" gpMaterial.fill_color = fillColor"" <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> yield "" gpMaterial.pass_index = passIndex""",True,isPassIndex,isPassIndex,0.66862952709198
|
||
|
1826,"def _load_data ( self, addr, size, endness ) : <TAB> if isinstance ( addr, SpOffset ) : <TAB> <TAB> <TAB> <TAB> v = self. state. load_local_variable ( addr. offset, size ) <TAB> <TAB> return v <TAB> elif isinstance ( addr, int ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if self. base_state is not None : <TAB> <TAB> <TAB> <TAB> _l. debug ( ""Loading %d bytes from %x."", size, addr ) <TAB> <TAB> <TAB> <TAB> data = self. base_state. memory. load ( addr, size, endness = endness ) <TAB> <TAB> <TAB> <TAB> if not data. symbolic : <TAB> <TAB> <TAB> <TAB> <TAB> return self. base_state. solver. eval ( data ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> val = self. project. loader. memory. unpack_word ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> addr, size = size, endness = endness <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> return val <TAB> <TAB> <TAB> <TAB> except KeyError : <TAB> <TAB> <TAB> <TAB> <TAB> return None <TAB> return None",False,"self._allow_loading(addr, size)",size > 0,0.651053249835968
|
||
|
1827,"def _sample_translation ( reference, max_len ) : <TAB> translation = reference [ : ] <TAB> while np. random. uniform ( ) < 0.8 and 1 < len ( translation ) < max_len : <TAB> <TAB> trans_len = len ( translation ) <TAB> <TAB> ind = np. random. randint ( trans_len ) <TAB> <TAB> action = np. random. choice ( actions ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> del translation [ ind ] <TAB> <TAB> elif action == ""replacement"" : <TAB> <TAB> <TAB> ind_rep = np. random. randint ( trans_len ) <TAB> <TAB> <TAB> translation [ ind ] = translation [ ind_rep ] <TAB> <TAB> else : <TAB> <TAB> <TAB> ind_insert = np. random. randint ( trans_len ) <TAB> <TAB> <TAB> translation. insert ( ind, translation [ ind_insert ] ) <TAB> return translation",False,action == 'deletion',action == 'replacement',0.6649367809295654
|
||
|
1828,"def backward_impl ( self, inputs, outputs, prop_down, accum ) : <TAB> <TAB> <TAB> <TAB> x0 = inputs [ 0 ]. data <TAB> w0 = inputs [ 1 ]. data <TAB> dy = inputs [ 2 ]. data <TAB> <TAB> dx0 = outputs [ 0 ]. data <TAB> dw0 = outputs [ 1 ]. data <TAB> <TAB> g_x0 = inputs [ 0 ]. grad <TAB> g_w0 = inputs [ 1 ]. grad <TAB> g_dy = inputs [ 2 ]. grad <TAB> <TAB> g_dx0 = outputs [ 0 ]. grad <TAB> g_dw0 = outputs [ 1 ]. grad <TAB> <TAB> if prop_down [ 2 ] : <TAB> <TAB> g_dy_ = F. embed ( x0, g_dw0 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> g_dy += g_dy_ <TAB> <TAB> else : <TAB> <TAB> <TAB> g_dy. copy_from ( g_dy_ )",False,accum[2],prop_down[1],0.6642348766326904
|
||
|
1829,"def convert_ids_to_tokens ( self, ids, skip_special_tokens = False ) : <TAB> """"""Converts a sequence of ids in BPE tokens using the vocab."""""" <TAB> tokens = [ ] <TAB> for i in ids : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if not skip_special_tokens : <TAB> <TAB> <TAB> <TAB> tokens. append ( self. special_tokens_decoder [ i ] ) <TAB> <TAB> else : <TAB> <TAB> <TAB> tokens. append ( self. decoder [ i ] ) <TAB> return tokens",False,i in self.special_tokens_decoder,i in self.decoder,0.6585270166397095
|
||
|
1830,"def rerun_failed_tests ( self ) : <TAB> self. ns. verbose = True <TAB> self. ns. failfast = False <TAB> self. ns. verbose3 = False <TAB> self. first_result = self. get_tests_result ( ) <TAB> self. log ( ) <TAB> self. log ( ""Re-running failed tests in verbose mode"" ) <TAB> self. rerun = self. bad [ : ] <TAB> for test_name in self. rerun : <TAB> <TAB> self. log ( f""Re-running {test_name} in verbose mode"" ) <TAB> <TAB> self. ns. verbose = True <TAB> <TAB> result = runtest ( self. ns, test_name ) <TAB> <TAB> self. accumulate_result ( result, rerun = True ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> break <TAB> if self. bad : <TAB> <TAB> print ( count ( len ( self. bad ), ""test"" ), ""failed again:"" ) <TAB> <TAB> printlist ( self. bad ) <TAB> self. display_result ( )",False,result.result == INTERRUPTED,self.first_result,0.656733512878418
|
||
|
1831,"def imports_as_stmts ( self, expr ) : <TAB> """"""Convert the Result's imports to statements"""""" <TAB> ret = Result ( ) <TAB> for module, names in self. imports. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> ret += self. compile ( <TAB> <TAB> <TAB> <TAB> [ <TAB> <TAB> <TAB> <TAB> <TAB> HyExpression ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> [ <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> HySymbol ( ""import"" ), <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> HySymbol ( module ), <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> <TAB> <TAB> ). replace ( expr ) <TAB> <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> ) <TAB> <TAB> names = sorted ( name for name in names if name ) <TAB> <TAB> if names : <TAB> <TAB> <TAB> ret += self. compile ( <TAB> <TAB> <TAB> <TAB> [ <TAB> <TAB> <TAB> <TAB> <TAB> HyExpression ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> [ <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> HySymbol ( ""import"" ), <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> HyList ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> [ <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> HySymbol ( module ), <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> HyList ( [ HySymbol ( name ) for name in names ] ), <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB",False,None in names,expr,0.6785376071929932
|
||
|
1832,"def _redraw ( self ) : <TAB> Box. _redraw ( self ) <TAB> count = 0 <TAB> fix_width = 0 <TAB> if not self. homogeneous : <TAB> <TAB> for child in self. children : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> count += 1 <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> fix_width += ( <TAB> <TAB> <TAB> <TAB> <TAB> child. minwidth + self. spacing + child. padding + 2 * child. margin <TAB> <TAB> <TAB> <TAB> ) <TAB> else : <TAB> <TAB> count = len ( self. children ) <TAB> container = self. widget_cont <TAB> left = self. margin <TAB> for child in self. children : <TAB> <TAB> if len ( self. children )!= 1 : <TAB> <TAB> <TAB> if child. minheight + 2 * self. margin > self. minheight : <TAB> <TAB> <TAB> <TAB> self. minheight = child. minheight + 2 * self. margin <TAB> <TAB> <TAB> self. minwidth += ( <TAB> <TAB> <TAB> <TAB> child. minwidth + 2 * child. margin + self. spacing + child. padding <TAB> <TAB> <TAB> ) <TAB> container. setPxStyle ( ""minHeight"", self. minheight ) <TAB> container. setPxStyle ( ""minWidth"", self. minwidth ) <TAB> count = max ( count, 1 ) <TAB> horiz_inc = ( container. getWidth ( ) - 2 * self. margin - fix_width ) / count <TAB> for child in self. children : <TAB> <TAB> child_container = child. widget_cont <TAB> <TAB> child_container. setPxStyle ( ""height"", container. getHeight ( ) - 2 * self. margin ) <TAB> <TAB> child_container. setPxStyle ( ""left"", left + self. spacing / 2 + child. padding / 2 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB>",False,child.expand,count > 0,0.6714144945144653
|
||
|
1833,"def set_template_dict ( self, template_dict ) : <TAB> template_dict [ ""self_name"" ] = self. name <TAB> template_dict [ ""self_type"" ] = self. parser_type <TAB> kind = self. function. kind <TAB> cls = self. function. cls <TAB> if ( kind in ( METHOD_NEW, METHOD_INIT ) ) and cls and cls. typedef : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> passed_in_type = self. name <TAB> <TAB> else : <TAB> <TAB> <TAB> passed_in_type = ""Py_TYPE({})"". format ( self. name ) <TAB> <TAB> line = ""({passed_in_type} == {type_object}) &&\n "" <TAB> <TAB> d = { <TAB> <TAB> <TAB> ""type_object"" : self. function. cls. type_object, <TAB> <TAB> <TAB> ""passed_in_type"" : passed_in_type, <TAB> <TAB> } <TAB> <TAB> template_dict [ ""self_type_check"" ] = line. format_map ( d )",False,kind == METHOD_NEW,kind == METHOD_CHECK,0.6639688014984131
|
||
|
1834,"def parseImpl ( self, instring, loc, doActions = True ) : <TAB> maxExcLoc = - 1 <TAB> maxException = None <TAB> matches = [ ] <TAB> for e in self. exprs : <TAB> <TAB> try : <TAB> <TAB> <TAB> loc2 = e. tryParse ( instring, loc ) <TAB> <TAB> except ParseException as err : <TAB> <TAB> <TAB> err. __traceback__ = None <TAB> <TAB> <TAB> if err. loc > maxExcLoc : <TAB> <TAB> <TAB> <TAB> maxException = err <TAB> <TAB> <TAB> <TAB> maxExcLoc = err. loc <TAB> <TAB> except IndexError : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> maxException = ParseException ( instring, len ( instring ), e. errmsg, self ) <TAB> <TAB> <TAB> <TAB> maxExcLoc = len ( instring ) <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> matches. append ( ( loc2, e ) ) <TAB> if matches : <TAB> <TAB> matches. sort ( key = lambda x : - x [ 0 ] ) <TAB> <TAB> for _, e in matches : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> return e. _parse ( instring, loc, doActions ) <TAB> <TAB> <TAB> except ParseException as err : <TAB> <TAB> <TAB> <TAB> err. __traceback__ = None <TAB> <TAB> <TAB> <TAB> if err. loc > maxExcLoc : <TAB> <TAB> <TAB> <TAB> <TAB> maxException = err <TAB> <TAB> <TAB> <TAB> <TAB> maxExcLoc = err. loc <TAB> if maxException is not None : <TAB> <TAB> maxException. msg = self. errmsg <TAB> <TAB> raise maxException <TAB> else : <TAB> <TAB> raise ParseException ( instring, loc, ""no defined alternatives to match"", self )",False,len(instring) > maxExcLoc,maxException is None,0.6602396368980408
|
||
|
1835,"def get_messages ( self, timeout = 0.1, count = 1 ) : <TAB> started = time ( ) <TAB> sleep_time = timeout / 10.0 <TAB> while count : <TAB> <TAB> try : <TAB> <TAB> <TAB> msg = self. subscriber. recv_multipart ( copy = True, flags = zmq. NOBLOCK ) <TAB> <TAB> except zmq. Again : <TAB> <TAB> <TAB> if time ( ) - started > timeout : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> sleep ( sleep_time ) <TAB> <TAB> else : <TAB> <TAB> <TAB> partition_seqno, global_seqno = unpack ( "">II"", msg [ 2 ] ) <TAB> <TAB> <TAB> seqno = global_seqno if self. count_global else partition_seqno <TAB> <TAB> <TAB> if not self. counter : <TAB> <TAB> <TAB> <TAB> self. counter = seqno <TAB> <TAB> <TAB> elif self. counter!= seqno : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> self. logger. warning ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""Sequence counter mismatch: expected %d, got %d. Check if system "" <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""isn't missing messages."" % ( self. counter, seqno ) <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> self. counter = None <TAB> <TAB> <TAB> yield msg [ 1 ] <TAB> <TAB> <TAB> count -= 1 <TAB> <TAB> <TAB> if self. counter : <TAB> <TAB> <TAB> <TAB> self. counter += 1 <TAB> <TAB> <TAB> self. stats [ self. stat_key ] += 1",False,self.seq_warnings,self.logger,0.6623049974441528
|
||
|
1836,"def run ( self, ** kwargs : Any ) -> None : <TAB> for node in self. document. traverse ( nodes. title ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> for i, index in enumerate ( node. traverse ( addnodes. index ) ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> node. remove ( index ) <TAB> <TAB> <TAB> <TAB> node. parent. insert ( i + 1, index )",False,"isinstance(node.parent, nodes.section)","hasattr(node, 'parent')",0.649115800857544
|
||
|
1837,"def _instrument_model ( self, model ) : <TAB> for key, value in list ( <TAB> <TAB> model. __dict__. items ( ) <TAB> ) : <TAB> <TAB> if isinstance ( value, tf. keras. layers. Layer ) : <TAB> <TAB> <TAB> new_layer = self. _instrument ( value ) <TAB> <TAB> <TAB> if new_layer is not value : <TAB> <TAB> <TAB> <TAB> setattr ( model, key, new_layer ) <TAB> <TAB> elif isinstance ( value, list ) : <TAB> <TAB> <TAB> for i, item in enumerate ( value ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> value [ i ] = self. _instrument ( item ) <TAB> return model",False,"isinstance(item, tf.keras.layers.Layer)",value[i] is not None,0.649843692779541
|
||
|
1838,"def emitIpToDomainsData ( self, data, event ) : <TAB> self. emitRawRirData ( data, event ) <TAB> domains = data. get ( ""domains"" ) <TAB> if isinstance ( domains, list ) : <TAB> <TAB> for domain in domains : <TAB> <TAB> <TAB> if self. checkForStop ( ) : <TAB> <TAB> <TAB> <TAB> return None <TAB> <TAB> <TAB> domain = domain. strip ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. emitHostname ( domain, event )",True,domain,domain,0.6864097118377686
|
||
|
1839,"def delete_item ( self, path ) : <TAB> config = get_config ( ) <TAB> headers = { } <TAB> if self. event. auth_token : <TAB> <TAB> headers [ ""Authorization"" ] = f""Bearer {self.event.auth_token}"" <TAB> try : <TAB> <TAB> res = requests. delete ( <TAB> <TAB> <TAB> path, headers = headers, verify = False, timeout = config. network_timeout <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> parsed_content = json. loads ( res. content ) <TAB> <TAB> <TAB> return parsed_content [ ""metadata"" ] [ ""deletionTimestamp"" ] <TAB> except ( requests. exceptions. ConnectionError, KeyError ) : <TAB> <TAB> pass <TAB> return None",False,"res.status_code in [200, 201, 202]",res.status_code == 200,0.6555154323577881
|
||
|
1840,"def add_cells ( self, cells ) : <TAB> for cell in cells : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> id = len ( self. cell_id_map ) <TAB> <TAB> <TAB> self. cell_id_map [ cell ] = id <TAB> <TAB> <TAB> self. id_cell_map [ id ] = cell",False,cell not in self.cell_id_map,cell in self.cell_list,0.6568676829338074
|
||
|
1841,"def _do_directory ( self, make_name, chdir_name, encoded ) : <TAB> if os. path. isdir ( make_name ) : <TAB> <TAB> os. rmdir ( make_name ) <TAB> os. mkdir ( make_name ) <TAB> try : <TAB> <TAB> with change_cwd ( chdir_name ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> cwd_result = os. getcwdu ( ) <TAB> <TAB> <TAB> <TAB> name_result = make_name <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> cwd_result = os. getcwd ( ). decode ( TESTFN_ENCODING ) <TAB> <TAB> <TAB> <TAB> name_result = make_name. decode ( TESTFN_ENCODING ) <TAB> <TAB> <TAB> cwd_result = unicodedata. normalize ( ""NFD"", cwd_result ) <TAB> <TAB> <TAB> name_result = unicodedata. normalize ( ""NFD"", name_result ) <TAB> <TAB> <TAB> self. assertEqual ( os. path. basename ( cwd_result ), name_result ) <TAB> finally : <TAB> <TAB> os. rmdir ( make_name )",False,not encoded,encoded,0.6740992069244385
|
||
|
1842,"def find_file_copyright_notices ( fname ) : <TAB> ret = set ( ) <TAB> f = open ( fname ) <TAB> lines = f. readlines ( ) <TAB> for l in lines [ : 80 ] : <TAB> <TAB> idx = l. lower ( ). find ( ""copyright"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> copyright = l [ idx + 9 : ]. strip ( ) <TAB> <TAB> if not copyright : <TAB> <TAB> <TAB> continue <TAB> <TAB> copyright = sanitise ( copyright ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if not copyright. find ( ""200"" ) >= 0 and not copyright. find ( ""199"" ) >= 0 : <TAB> <TAB> <TAB> continue <TAB> <TAB> ret. add ( copyright ) <TAB> return ret",True,idx < 0,idx < 0,0.6759262084960938
|
||
|
1843,"def __closest ( widget, compare, x, y ) : <TAB> closest = None <TAB> dc2 = 10000000 <TAB> if widget is None : <TAB> <TAB> return closest, dc2 <TAB> for child in widget. winfo_children ( ) : <TAB> <TAB> for class_ in Page. _motionClasses : <TAB> <TAB> <TAB> if isinstance ( child, class_ ) : <TAB> <TAB> <TAB> <TAB> if child [ ""state"" ] == DISABLED : <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> xw = child. winfo_rootx ( ) <TAB> <TAB> <TAB> <TAB> yw = child. winfo_rooty ( ) <TAB> <TAB> <TAB> <TAB> if compare ( x, y, xw, yw ) : <TAB> <TAB> <TAB> <TAB> <TAB> d2 = ( xw - x ) ** 2 + ( yw - y ) ** 2 <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> closest = child <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> dc2 = d2 <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> else : <TAB> <TAB> <TAB> c, d2 = Page. __closest ( child, compare, x, y ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> closest = c <TAB> <TAB> <TAB> <TAB> dc2 = d2 <TAB> return closest, dc2",False,d2 < dc2,closest is None,0.6674395799636841
|
||
|
1844,"def SetChildMenuBar ( self, pChild ) : <TAB> if not pChild : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. SetMenuBar ( self. _pMyMenuBar ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. SetMenuBar ( self. GetMenuBar ( ) ) <TAB> <TAB> <TAB> <TAB> self. _pMyMenuBar = None <TAB> else : <TAB> <TAB> if pChild. GetMenuBar ( ) is None : <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> <TAB> if self. _pMyMenuBar is None : <TAB> <TAB> <TAB> self. _pMyMenuBar = self. GetMenuBar ( ) <TAB> <TAB> self. SetMenuBar ( pChild. GetMenuBar ( ) )",False,self._pMyMenuBar,self._pMyMenuBar is None,0.6639725565910339
|
||
|
1845,"def OnRadioSelect ( self, event ) : <TAB> fitID = self. mainFrame. getActiveFit ( ) <TAB> if fitID is not None : <TAB> <TAB> self. mainFrame. command. Submit ( <TAB> <TAB> <TAB> cmd. GuiChangeImplantLocationCommand ( <TAB> <TAB> <TAB> <TAB> fitID = fitID, <TAB> <TAB> <TAB> <TAB> source = ImplantLocation. FIT <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> else ImplantLocation. CHARACTER, <TAB> <TAB> <TAB> ) <TAB> <TAB> )",False,self.rbFit.GetValue(),source == ImplantLocation.EXCEPTION,0.6545650959014893
|
||
|
1846,"def _Lookup ( self, node ) : <TAB> """"""Look up a node by name."""""" <TAB> module, _, _ = node. name. rpartition ( ""."" ) <TAB> if module : <TAB> <TAB> modules_to_try = [ ( """", module ) ] <TAB> else : <TAB> <TAB> modules_to_try = [ ( """", """" ), ( """", ""builtins"" ), ( ""builtins."", ""builtins"" ) ] <TAB> modules_to_try += [ ( """", ""*"" ), ( ""builtins."", ""*"" ) ] <TAB> for prefix, module in modules_to_try : <TAB> <TAB> mod_ast = self. _lookup_map. get ( module ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> item = mod_ast. Lookup ( prefix + node. name ) <TAB> <TAB> <TAB> except KeyError : <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> yield prefix, item",True,mod_ast,mod_ast,0.6672509908676147
|
||
|
1847,"def _apply_base_delta ( <TAB> self, <TAB> schema : s_schema. Schema, <TAB> context : sd. CommandContext, <TAB> scls : so. InheritingObjectT, ) -> so. ObjectList [ so. InheritingObjectT ] : <TAB> bases = list ( scls. get_bases ( schema ). objects ( schema ) ) <TAB> default_base_name = scls. get_default_base_name ( ) <TAB> if default_base_name : <TAB> <TAB> default_base : Optional [ so. InheritingObjectT ] = self. get_object ( <TAB> <TAB> <TAB> schema, context, name = default_base_name <TAB> <TAB> ) <TAB> <TAB> if bases == [ default_base ] : <TAB> <TAB> <TAB> bases = [ ] <TAB> else : <TAB> <TAB> default_base = None <TAB> removed_bases = { b. name for b in self. removed_bases } <TAB> existing_bases = set ( ) <TAB> for b in bases : <TAB> <TAB> if b. get_name ( schema ) in removed_bases : <TAB> <TAB> <TAB> bases. remove ( b ) <TAB> <TAB> else : <TAB> <TAB> <TAB> existing_bases. add ( b. get_name ( schema ) ) <TAB> index = { b. get_name ( schema ) : i for i, b in enumerate ( bases ) } <TAB> for new_bases, pos in self. added_bases : <TAB> <TAB> if isinstance ( pos, tuple ) : <TAB> <TAB> <TAB> pos, ref = pos <TAB> <TAB> if pos is None or pos == ""LAST"" : <TAB> <TAB> <TAB> idx = len ( bases ) <TAB> <TAB> elif pos == ""FIRST"" : <TAB> <TAB> <TAB> idx = 0 <TAB> <TAB> else : <TAB> <TAB> <TAB> idx = index [ ref. name ] <TAB> <TAB> bases [ idx : idx ] = [ <TAB> <TAB> <TAB> self. get_object ( schema, context, name = b. name ) <TAB",False,b.name not in existing_bases,self.has_object,0.6550068855285645
|
||
|
1848,"def broadcast_events ( self, events ) : <TAB> LOGGER. debug ( ""Broadcasting events: %s"", events ) <TAB> with self. _subscribers_cv : <TAB> <TAB> <TAB> <TAB> subscribers = { conn : sub. copy ( ) for conn, sub in self. _subscribers. items ( ) } <TAB> if subscribers : <TAB> <TAB> for connection_id, subscriber in subscribers. items ( ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> subscriber_events = [ <TAB> <TAB> <TAB> <TAB> <TAB> event for event in events if subscriber. is_subscribed ( event ) <TAB> <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> <TAB> event_list = EventList ( events = subscriber_events ) <TAB> <TAB> <TAB> <TAB> self. _send ( connection_id, event_list. SerializeToString ( ) )",False,subscriber.is_listening(),events,0.6530421376228333
|
||
|
1849,"def continuation_tokens ( self, width, line_number, is_soft_wrap = False ) : <TAB> """"""Displays dots in multiline prompt"""""" <TAB> if is_soft_wrap : <TAB> <TAB> return """" <TAB> width = width - 1 <TAB> dots = builtins. __xonsh__. env. get ( ""MULTILINE_PROMPT"" ) <TAB> dots = dots ( ) if callable ( dots ) else dots <TAB> if not dots : <TAB> <TAB> return """" <TAB> basetoks = self. format_color ( dots ) <TAB> baselen = sum ( len ( t [ 1 ] ) for t in basetoks ) <TAB> if baselen == 0 : <TAB> <TAB> return [ ( Token, "" "" * ( width + 1 ) ) ] <TAB> toks = basetoks * ( width // baselen ) <TAB> n = width % baselen <TAB> count = 0 <TAB> for tok in basetoks : <TAB> <TAB> slen = len ( tok [ 1 ] ) <TAB> <TAB> newcount = slen + count <TAB> <TAB> if slen == 0 : <TAB> <TAB> <TAB> continue <TAB> <TAB> elif newcount <= n : <TAB> <TAB> <TAB> toks. append ( tok ) <TAB> <TAB> else : <TAB> <TAB> <TAB> toks. append ( ( tok [ 0 ], tok [ 1 ] [ : n - count ] ) ) <TAB> <TAB> count = newcount <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> break <TAB> toks. append ( ( Token, "" "" ) ) <TAB> return PygmentsTokens ( toks )",False,n <= count,count > line_number,0.6874635815620422
|
||
|
1850,"def s_style_master_page ( self, tag, attrs ) : <TAB> """"""Collect the formatting for the page layout style."""""" <TAB> name = attrs [ ( STYLENS, ""name"" ) ] <TAB> name = name. replace ( ""."", ""_"" ) <TAB> self. currentstyle = "".MP-"" + name <TAB> self. stylestack. append ( self. currentstyle ) <TAB> self. styledict [ self. currentstyle ] = { ( """", ""position"" ) : ""relative"" } <TAB> <TAB> pagelayout = attrs. get ( ( STYLENS, ""page-layout-name"" ), None ) <TAB> if pagelayout : <TAB> <TAB> pagelayout = "".PL-"" + pagelayout <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> styles = self. styledict [ pagelayout ] <TAB> <TAB> <TAB> for style, val in list ( styles. items ( ) ) : <TAB> <TAB> <TAB> <TAB> self. styledict [ self. currentstyle ] [ style ] = val <TAB> <TAB> else : <TAB> <TAB> <TAB> self. styledict [ self. currentstyle ] [ ""__parent-style-name"" ] = pagelayout <TAB> self. s_ignorexml ( tag, attrs )",False,pagelayout in self.styledict,pagelayout and self.currentstyle in self.stledict,0.6599200963973999
|
||
|
1851,"def resolve_xref ( <TAB> self, <TAB> env : BuildEnvironment, <TAB> fromdocname : str, <TAB> builder : ""Builder"", <TAB> typ : str, <TAB> target : str, <TAB> node : pending_xref, <TAB> contnode : Element, ) -> Element : <TAB> assert typ in ( ""eq"", ""numref"" ) <TAB> docname, number = self. equations. get ( target, ( None, None ) ) <TAB> if docname : <TAB> <TAB> <TAB> <TAB> node_id = make_id ( ""equation-%s"" % target ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if docname in env. toc_fignumbers : <TAB> <TAB> <TAB> <TAB> numbers = env. toc_fignumbers [ docname ] [ ""displaymath"" ]. get ( node_id, ( ) ) <TAB> <TAB> <TAB> <TAB> eqno = ""."". join ( map ( str, numbers ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> eqno = """" <TAB> <TAB> else : <TAB> <TAB> <TAB> eqno = str ( number ) <TAB> <TAB> try : <TAB> <TAB> <TAB> eqref_format = env. config. math_eqref_format or ""({number})"" <TAB> <TAB> <TAB> title = nodes. Text ( eqref_format. format ( number = eqno ) ) <TAB> <TAB> except KeyError as exc : <TAB> <TAB> <TAB> logger. warning ( __ ( ""Invalid math_eqref_format: %r"" ), exc, location = node ) <TAB> <TAB> <TAB> title = nodes. Text ( ""(%d)"" % number ) <TAB> <TAB> <TAB> title = nodes. Text ( ""(%d)"" % number ) <TAB> <TAB> return make_refnode ( builder, fromdocname, docname, node_id, title ) <TAB> else : <TAB> <TAB> return None",False,env.config.math_numfig and env.config.numfig,number,0.651963472366333
|
||
|
1852,"def __get_limits ( self ) : <TAB> dimension = len ( self. __tree. get_root ( ). data ) <TAB> nodes = self. __get_all_nodes ( ) <TAB> max, min = [ float ( ""-inf"" ) ] * dimension, [ float ( ""+inf"" ) ] * dimension <TAB> for node in nodes : <TAB> <TAB> for d in range ( dimension ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> max [ d ] = node. data [ d ] <TAB> <TAB> <TAB> if min [ d ] > node. data [ d ] : <TAB> <TAB> <TAB> <TAB> min [ d ] = node. data [ d ] <TAB> return min, max",False,max[d] < node.data[d],max[d] > node.data[d],0.6522320508956909
|
||
|
1853,def identify_page_at_cursor ( self ) : <TAB> for region in self. view. sel ( ) : <TAB> <TAB> text_on_cursor = None <TAB> <TAB> pos = region. begin ( ) <TAB> <TAB> scope_region = self. view. extract_scope ( pos ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> text_on_cursor = self. view. substr ( scope_region ) <TAB> <TAB> <TAB> return text_on_cursor. strip ( string. punctuation ) <TAB> return None,False,not scope_region.empty(),scope_region,0.6508708000183105
|
||
|
1854,"def set_transaction_execution_result ( <TAB> self, <TAB> txn_signature, <TAB> is_valid, <TAB> context_id, <TAB> state_changes = None, <TAB> events = None, <TAB> data = None, <TAB> error_message = """", <TAB> error_data = b"""", ) : <TAB> with self. _condition : <TAB> <TAB> if txn_signature not in self. _scheduled : <TAB> <TAB> <TAB> raise SchedulerError ( ""transaction not scheduled: {}"". format ( txn_signature ) ) <TAB> <TAB> if txn_signature not in self. _batches_by_txn_id : <TAB> <TAB> <TAB> return <TAB> <TAB> self. _set_least_batch_id ( txn_signature = txn_signature ) <TAB> <TAB> if not is_valid : <TAB> <TAB> <TAB> self. _remove_subsequent_result_because_of_batch_failure ( txn_signature ) <TAB> <TAB> is_rescheduled = self. _reschedule_if_outstanding ( txn_signature ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _txn_results [ txn_signature ] = TxnExecutionResult ( <TAB> <TAB> <TAB> <TAB> signature = txn_signature, <TAB> <TAB> <TAB> <TAB> is_valid = is_valid, <TAB> <TAB> <TAB> <TAB> context_id = context_id if is_valid else None, <TAB> <TAB> <TAB> <TAB> state_hash = self. _first_state_hash if is_valid else None, <TAB> <TAB> <TAB> <TAB> state_changes = state_changes, <TAB> <TAB> <TAB> <TAB> events = events, <TAB> <TAB> <TAB> <TAB> data = data, <TAB> <TAB> <TAB> <TAB> error_message = error_message, <TAB> <TAB> <TAB> <TAB> error_data = error_data, <TAB> <TAB> <TAB> ) <TAB> <TAB> self. _condition. notify_all ( )",False,not is_rescheduled,is_rescheduled,0.6538586616516113
|
||
|
1855,"def replace_ending_white_space ( self, name, newStr, lineNum ) : <TAB> if not newStr : <TAB> <TAB> return <TAB> numChars = len ( newStr ) <TAB> ending_spaces_re = re. compile ( r""[ \t]{1,%d}\Z"" % numChars ) <TAB> m = ending_spaces_re. search ( self. _pendingWhiteSpace [ name ] ) <TAB> if m : <TAB> <TAB> mglen = len ( m. group ( ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self [ name ]. append ( self. _pendingWhiteSpace [ name ] [ : - numChars ] ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self [ name ]. append ( self. _pendingWhiteSpace [ name ] [ : - mglen ] ) <TAB> <TAB> <TAB> <TAB> self. _pendingWhiteSpace [ name ] = """" <TAB> <TAB> self [ name ]. append ( newStr ) <TAB> else : <TAB> <TAB> <TAB> <TAB> if ( <TAB> <TAB> <TAB> self [ name ] <TAB> <TAB> <TAB> and not self. _pendingWhiteSpace [ name ] <TAB> <TAB> <TAB> and not self [ name ] [ - 1 ]. isspace ( ) <TAB> <TAB> ) : <TAB> <TAB> <TAB> self. _pendingWhiteSpace [ name ] += "" "" <TAB> <TAB> self [ name ] = newStr",False,mglen >= numChars,mglen > 0,0.6648894548416138
|
||
|
1856,"def __cmp__ ( self, y ) : <TAB> a_start = 0 if self. start is None else self. start <TAB> a_step = 1 if self. step is None else self. step <TAB> b_start = 0 if y. start is None else y. start <TAB> b_step = 1 if y. step is None else y. step <TAB> if a_start < b_start : <TAB> <TAB> return - 1 <TAB> if a_start > b_start : <TAB> <TAB> return 1 <TAB> if self. stop is not y. stop : <TAB> <TAB> if self. stop is None : <TAB> <TAB> <TAB> return 1 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return - 1 <TAB> <TAB> if self. stop < y. stop : <TAB> <TAB> <TAB> return - 1 <TAB> <TAB> return 1 <TAB> if a_step < b_step : <TAB> <TAB> return - 1 <TAB> if a_step > b_step : <TAB> <TAB> return 1 <TAB> return 0",False,y.stop is None,y.stop,0.6589339375495911
|
||
|
1857,"def onMESSAGE ( self, hwnd, msg, wp, lp ) : <TAB> if msg == fw. WND_WM_NOTIFY : <TAB> <TAB> if wp == fw. WND_NM_MSGREFLECT : <TAB> <TAB> <TAB> msgr = fw. WND_MSGREFLECT. from_address ( lp ) <TAB> <TAB> <TAB> msgr. fReturn = self. _base_fMsgReflect <TAB> <TAB> <TAB> if msgr. msg == self. Msg. WM_NOTIFY : <TAB> <TAB> <TAB> <TAB> nm = NMHDR. from_address ( msgr. lParam ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> if self. onMSG ( hwnd, ""selchanging"", self. GetSelected ( ), 0 ) == False : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return 1 <TAB> <TAB> <TAB> <TAB> elif nm. code == self. Msg. TCN_SELCHANGE : <TAB> <TAB> <TAB> <TAB> <TAB> self. onMSG ( hwnd, ""selchanged"", self. GetSelected ( ), 0 ) <TAB> <TAB> <TAB> <TAB> elif nm. code == self. Msg. NM_RELEASEDCAPTURE : <TAB> <TAB> <TAB> <TAB> <TAB> self. onMSG ( hwnd, ""releasedcapture"", 0, 0 ) <TAB> <TAB> <TAB> <TAB> elif nm. code == self. Msg. NM_CLICK : <TAB> <TAB> <TAB> <TAB> <TAB> self. onMSG ( hwnd, ""click"", 0, 0 ) <TAB> <TAB> <TAB> <TAB> elif nm. code == self. Msg. NM_RCLICK : <TAB> <TAB> <TAB> <TAB> <TAB> self. onMSG ( hwnd, ""rclick"", 0, 0 ) <TAB> <TAB> <TAB> <TAB> elif nm. code == self. Msg. TCN_KEYDOWN : <TAB> <TAB",False,nm.code == self.Msg.TCN_SELCHANGING,nm.code == self.Msg.TCN_SELECTED,0.6615383625030518
|
||
|
1858,"def compute_indices ( text : str, tokens ) : <TAB> indices = [ ] <TAB> for i, token in enumerate ( tokens ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> current_index = indices [ - 1 ] + len ( tokens [ i - 1 ] ) <TAB> <TAB> <TAB> indices. append ( current_index + text [ current_index : ]. find ( token ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> indices. append ( text. find ( token ) ) <TAB> return indices",False,1 <= i,i > 0,0.6778904795646667
|
||
|
1859,"def _cookies_for_domain ( self, domain, request ) : <TAB> cookies = [ ] <TAB> if not self. _policy. domain_return_ok ( domain, request ) : <TAB> <TAB> return [ ] <TAB> _debug ( ""Checking %s for cookies to return"", domain ) <TAB> cookies_by_path = self. _cookies [ domain ] <TAB> for path in cookies_by_path. keys ( ) : <TAB> <TAB> if not self. _policy. path_return_ok ( path, request ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> cookies_by_name = cookies_by_path [ path ] <TAB> <TAB> for cookie in cookies_by_name. values ( ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> _debug ( "" not returning cookie"" ) <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> _debug ( "" it's a match"" ) <TAB> <TAB> <TAB> cookies. append ( cookie ) <TAB> return cookies",False,"not self._policy.return_ok(cookie, request)",cookie not in cookies,0.6499903202056885
|
||
|
1860,"def mine_pow_nonce ( <TAB> block_number : int, mining_hash : Hash32, difficulty : int ) -> Tuple [ bytes, bytes ] : <TAB> cache = get_cache ( block_number ) <TAB> for nonce in range ( MAX_TEST_MINE_ATTEMPTS ) : <TAB> <TAB> mining_output = hashimoto_light ( block_number, cache, mining_hash, nonce ) <TAB> <TAB> result = big_endian_to_int ( mining_output [ b""result"" ] ) <TAB> <TAB> result_cap = 2 ** 256 // difficulty <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return nonce. to_bytes ( 8, ""big"" ), mining_output [ b""mix digest"" ] <TAB> raise Exception ( ""Too many attempts at POW mining, giving up"" )",False,result <= result_cap,result_cap >= result,0.6631282567977905
|
||
|
1861,"def get_order_taxes ( shopify_order, shopify_settings ) : <TAB> taxes = [ ] <TAB> for tax in shopify_order. get ( ""tax_lines"" ) : <TAB> <TAB> taxes. append ( <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> ""charge_type"" : _ ( ""On Net Total"" ), <TAB> <TAB> <TAB> <TAB> ""account_head"" : get_tax_account_head ( tax ), <TAB> <TAB> <TAB> <TAB> ""description"" : ""{0} - {1}%"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> tax. get ( ""title"" ), tax. get ( ""rate"" ) * 100.0 <TAB> <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> <TAB> ""rate"" : tax. get ( ""rate"" ) * 100.00, <TAB> <TAB> <TAB> <TAB> ""included_in_print_rate"" : 1 <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> else 0, <TAB> <TAB> <TAB> <TAB> ""cost_center"" : shopify_settings. cost_center, <TAB> <TAB> <TAB> } <TAB> <TAB> ) <TAB> taxes = update_taxes_with_shipping_lines ( <TAB> <TAB> taxes, shopify_order. get ( ""shipping_lines"" ), shopify_settings <TAB> ) <TAB> return taxes",False,shopify_order.get('taxes_included'),shopify_settings.cost_center is not None,0.6526694297790527
|
||
|
1862,"def analyze_slots ( self ) : <TAB> self. __slots = { } <TAB> for s in Slots : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> meth = self. __methods. get ( s. special ) <TAB> <TAB> <TAB> if meth is not None : <TAB> <TAB> <TAB> <TAB> self. __slots [ s ] = meth <TAB> self. __slots [ TP_NAME ] = '""%s.%s""' % ( self. __module, self. __name__ ) <TAB> if self. __doc__ : <TAB> <TAB> self. __slots [ TP_DOC ] = ""%s_doc"" % self. name <TAB> if self. __struct is not None : <TAB> <TAB> self. __slots [ TP_BASICSIZE ] = ""sizeof(%s)"" % self. __struct. name <TAB> <TAB> self. __slots [ TP_DEALLOC ] = ""%s_dealloc"" % self. name <TAB> if self. __methods : <TAB> <TAB> self. __slots [ TP_METHODS ] = ""%s_methods"" % self. name <TAB> if self. __members : <TAB> <TAB> self. __slots [ TP_MEMBERS ] = ""%s_members"" % self. name",False,s.special is not None,s.special,0.6569875478744507
|
||
|
1863,"def capitalize_utterances ( <TAB> utterances, entities, language, ratio, resources, random_state ) : <TAB> capitalized_utterances = [ ] <TAB> for utterance in utterances : <TAB> <TAB> capitalized_utterance = deepcopy ( utterance ) <TAB> <TAB> for i, chunk in enumerate ( capitalized_utterance [ DATA ] ) : <TAB> <TAB> <TAB> capitalized_utterance [ DATA ] [ i ] [ TEXT ] = chunk [ TEXT ]. lower ( ) <TAB> <TAB> <TAB> if ENTITY not in chunk : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> entity_label = chunk [ ENTITY ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if not entities [ entity_label ] [ CAPITALIZE ] : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if random_state. rand ( ) > ratio : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> capitalized_utterance [ DATA ] [ i ] [ TEXT ] = capitalize ( <TAB> <TAB> <TAB> <TAB> chunk [ TEXT ], language, resources <TAB> <TAB> <TAB> ) <TAB> <TAB> capitalized_utterances. append ( capitalized_utterance ) <TAB> return capitalized_utterances",False,is_builtin_entity(entity_label),entity_label not in entities,0.6504583358764648
|
||
|
1864,"def _optimization_function ( <TAB> self, objective_function : tp. Callable [ [ tp. ArrayLike ], float ] ) -> tp. ArrayLike : <TAB> <TAB> budget = np. inf if self. budget is None else self. budget <TAB> best_res = np. inf <TAB> best_x : np. ndarray = self. current_bests [ ""average"" ]. x <TAB> if self. initial_guess is not None : <TAB> <TAB> best_x = np. array ( <TAB> <TAB> <TAB> self. initial_guess, copy = True <TAB> <TAB> ) <TAB> remaining = budget - self. _num_ask <TAB> while remaining > 0 : <TAB> <TAB> options : tp. Dict [ str, int ] = ( <TAB> <TAB> <TAB> { } if self. budget is None else { ""maxiter"" : remaining } <TAB> <TAB> ) <TAB> <TAB> res = scipyoptimize. minimize ( <TAB> <TAB> <TAB> objective_function, <TAB> <TAB> <TAB> best_x <TAB> <TAB> <TAB> if not self. random_restart <TAB> <TAB> <TAB> else self. _rng. normal ( 0.0, 1.0, self. dimension ), <TAB> <TAB> <TAB> method = self. method, <TAB> <TAB> <TAB> options = options, <TAB> <TAB> <TAB> tol = 0, <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> best_res = res. fun <TAB> <TAB> <TAB> best_x = res. x <TAB> <TAB> remaining = budget - self. _num_ask <TAB> return best_x",False,res.fun < best_res,method in self.method,0.6599200963973999
|
||
|
1865,"def set_defaults ( opt ) : <TAB> init_model = None <TAB> <TAB> if opt. get ( ""init_model"" ) and PathManager. exists ( opt [ ""init_model"" ] ) : <TAB> <TAB> init_model = opt [ ""init_model"" ] <TAB> <TAB> if opt. get ( ""model_file"" ) and PathManager. exists ( opt [ ""model_file"" ] ) : <TAB> <TAB> init_model = opt [ ""model_file"" ] <TAB> if init_model is None : <TAB> <TAB> <TAB> <TAB> opt [ ""embedding_file"" ] = modelzoo_path ( <TAB> <TAB> <TAB> opt. get ( ""datapath"" ), opt [ ""embedding_file"" ] <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if not PathManager. exists ( opt [ ""embedding_file"" ] ) : <TAB> <TAB> <TAB> <TAB> raise IOError ( ""No such file: %s"" % opt [ ""embedding_file"" ] ) <TAB> <TAB> <TAB> with PathManager. open ( opt [ ""embedding_file"" ] ) as f : <TAB> <TAB> <TAB> <TAB> dim = len ( f. readline ( ). strip ( ). split ( "" "" ) ) - 1 <TAB> <TAB> <TAB> <TAB> if dim == 1 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> dim = len ( f. readline ( ). strip ( ). split ( "" "" ) ) - 1 <TAB> <TAB> <TAB> opt [ ""embedding_dim"" ] = dim <TAB> <TAB> elif not opt. get ( ""embedding_dim"" ) : <TAB> <TAB> <TAB> raise RuntimeError ( <TAB> <TAB> <TAB> <TAB> ( ""Either embedding_file or embedding_dim "" ""needs to be specified."" ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> if opt [ ""tune_partial"" ] > 0 and opt [ ""fix_embeddings""",True,opt.get('embedding_file'),opt.get('embedding_file'),0.6556334495544434
|
||
|
1866,"def read ( self, size = None ) : <TAB> if size == 0 : <TAB> <TAB> return """" <TAB> data = list ( ) <TAB> while size is None or size > 0 : <TAB> <TAB> line = self. readline ( size or - 1 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> break <TAB> <TAB> if size is not None : <TAB> <TAB> <TAB> size -= len ( line ) <TAB> <TAB> data. append ( line ) <TAB> return """". join ( data )",True,not line,not line,0.6676050424575806
|
||
|
1867,"def interpolate ( self, mobject1, mobject2, alpha, path_func = straight_path ) : <TAB> for key in self. data : <TAB> <TAB> if key in self. locked_data_keys : <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> if key not in mobject1. data or key not in mobject2. data : <TAB> <TAB> <TAB> continue <TAB> <TAB> if key in ( ""points"", ""bounding_box"" ) : <TAB> <TAB> <TAB> func = path_func <TAB> <TAB> else : <TAB> <TAB> <TAB> func = interpolate <TAB> <TAB> self. data [ key ] [ : ] = func ( mobject1. data [ key ], mobject2. data [ key ], alpha ) <TAB> for key in self. uniforms : <TAB> <TAB> self. uniforms [ key ] = interpolate ( <TAB> <TAB> <TAB> mobject1. uniforms [ key ], mobject2. uniforms [ key ], alpha <TAB> <TAB> ) <TAB> return self",False,len(self.data[key]) == 0,path_func is None,0.6571762561798096
|
||
|
1868,"def text_to_tokens_mask ( self, pair, Y = None, context = None ) : <TAB> out_gen = self. _text_to_ids ( pair, pad_token = self. config. pad_token ) <TAB> for i, out in enumerate ( out_gen ) : <TAB> <TAB> if context is None : <TAB> <TAB> <TAB> feats = { ""tokens"" : out. token_ids, ""mask"" : out. mask } <TAB> <TAB> else : <TAB> <TAB> <TAB> out_forward = ArrayEncodedOutput ( <TAB> <TAB> <TAB> <TAB> token_ids = out. token_ids [ 0 ], <TAB> <TAB> <TAB> <TAB> tokens = out. token_ids [ 0 ], <TAB> <TAB> <TAB> <TAB> labels = None, <TAB> <TAB> <TAB> <TAB> char_locs = out. char_locs, <TAB> <TAB> <TAB> <TAB> mask = out. mask [ 0 ], <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> out_backward = ArrayEncodedOutput ( <TAB> <TAB> <TAB> <TAB> token_ids = out. token_ids [ 1 ], <TAB> <TAB> <TAB> <TAB> tokens = out. token_ids [ 1 ], <TAB> <TAB> <TAB> <TAB> labels = None, <TAB> <TAB> <TAB> <TAB> char_locs = out. char_locs, <TAB> <TAB> <TAB> <TAB> mask = out. mask [ 1 ], <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> tokenized_context_forward = tokenize_context ( <TAB> <TAB> <TAB> <TAB> context [ 0 ], out_forward, self. config <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> tokenized_context_backward = tokenize_context ( <TAB> <TAB> <TAB> <TAB> context [ 1 ], out_backward, self. config <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> tokenized_context = [ tokenized_context_forward",False,Y is None,i == 0,0.6638524532318115
|
||
|
1869,"def watch_directory ( <TAB> self, <TAB> dir_path, <TAB> callback = None, <TAB> recursive = False, <TAB> ignore_extensions = None, <TAB> require_extensions = None, ) : <TAB> dir_path = os. path. abspath ( dir_path ) <TAB> if dir_path not in self. monitored_dirs : <TAB> <TAB> if callback is not None : <TAB> <TAB> <TAB> self. dir_callbacks [ dir_path ] = callback <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. ignore_extensions [ dir_path ] = ignore_extensions <TAB> <TAB> if require_extensions : <TAB> <TAB> <TAB> self. require_extensions [ dir_path ] = require_extensions <TAB> <TAB> self. monitor ( dir_path, recursive = recursive ) <TAB> <TAB> log. debug ( <TAB> <TAB> <TAB> ""Watching for changes in directory%s: %s"", <TAB> <TAB> <TAB> "" (recursively)"" if recursive else """", <TAB> <TAB> <TAB> dir_path, <TAB> <TAB> )",True,ignore_extensions,ignore_extensions,0.6629427075386047
|
||
|
1870,"def _validate_vm_create_nics ( cmd, namespace ) : <TAB> from msrestazure. tools import resource_id <TAB> from azure. cli. core. commands. client_factory import get_subscription_id <TAB> nics_value = namespace. nics <TAB> nics = [ ] <TAB> if not nics_value : <TAB> <TAB> namespace. nic_type = ""new"" <TAB> <TAB> logger. debug ( ""new NIC will be created"" ) <TAB> <TAB> return <TAB> if not isinstance ( nics_value, list ) : <TAB> <TAB> nics_value = [ nics_value ] <TAB> for n in nics_value : <TAB> <TAB> nics. append ( <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> ""id"" : n <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> else resource_id ( <TAB> <TAB> <TAB> <TAB> <TAB> name = n, <TAB> <TAB> <TAB> <TAB> <TAB> resource_group = namespace. resource_group_name, <TAB> <TAB> <TAB> <TAB> <TAB> namespace = ""Microsoft.Network"", <TAB> <TAB> <TAB> <TAB> <TAB> type = ""networkInterfaces"", <TAB> <TAB> <TAB> <TAB> <TAB> subscription = get_subscription_id ( cmd. cli_ctx ), <TAB> <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> <TAB> ""properties"" : { ""primary"" : nics_value [ 0 ] == n }, <TAB> <TAB> <TAB> } <TAB> <TAB> ) <TAB> namespace. nics = nics <TAB> namespace. nic_type = ""existing"" <TAB> namespace. public_ip_address_type = None <TAB> logger. debug ( ""existing NIC(s) will be used"" )",False,'/' in n,not namespace.resource_group,0.6751554012298584
|
||
|
1871,def timeout ( self ) : <TAB> now = ptime. time ( ) <TAB> dt = now - self. lastPlayTime <TAB> if dt < 0 : <TAB> <TAB> return <TAB> n = int ( self. playRate * dt ) <TAB> if n!= 0 : <TAB> <TAB> self. lastPlayTime += float ( n ) / self. playRate <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. play ( 0 ) <TAB> <TAB> self. jumpFrames ( n ),False,self.currentIndex + n > self.image.shape[self.axes['t']],n == 1,0.6506556868553162
|
||
|
1872,"def __call__ ( self, parser, namespace, values, option_string ) : <TAB> instance, settings = get_instance ( namespace ) <TAB> if values : <TAB> <TAB> <TAB> <TAB> for setting in values : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if isinstance ( settings [ setting ], dict ) : <TAB> <TAB> <TAB> <TAB> <TAB> setting_format = ""\n{}:\n{}"" <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> setting_format = ""\n{}: {}"" <TAB> <TAB> <TAB> <TAB> print ( setting_format. format ( setting, pprint. pformat ( settings [ setting ] ) ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> print ( ""\n{} is not a recognized setting."". format ( setting ) ) <TAB> <TAB> <TAB> <TAB> break <TAB> else : <TAB> <TAB> <TAB> <TAB> pprint. pprint ( settings ) <TAB> parser. exit ( )",True,setting in settings,setting in settings,0.6679763793945312
|
||
|
1873,"def _restore_freeze ( self, new ) : <TAB> size_change = [ ] <TAB> for k, v in six. iteritems ( self. _freeze_backup ) : <TAB> <TAB> newv = new. get ( k, [ ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> size_change. append ( ( self. _key_name ( k ), len ( v ), len ( newv ) ) ) <TAB> if size_change : <TAB> <TAB> logger. info ( <TAB> <TAB> <TAB> ""These collections were modified but restored in {}: {}"". format ( <TAB> <TAB> <TAB> <TAB> self. _name, <TAB> <TAB> <TAB> <TAB> "", "". join ( map ( lambda t : ""({}: {}->{})"". format ( * t ), size_change ) ), <TAB> <TAB> <TAB> ) <TAB> <TAB> ) <TAB> restore_collection ( self. _freeze_backup )",False,len(v) != len(newv),newv,0.6495283842086792
|
||
|
1874,"def _find_closest_regex_forwards ( self, regexlist, getGroupPos = None ) : <TAB> sm = self. scimoz ( ) <TAB> closestPos = None <TAB> endpos = startpos = curpos = sm. currentPos <TAB> lastEndPos = sm. length <TAB> while closestPos is None and endpos < lastEndPos : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> endpos += 500 <TAB> <TAB> endpos = min ( lastEndPos, endpos ) <TAB> <TAB> text = sm. getTextRange ( startpos, endpos ) <TAB> <TAB> <TAB> <TAB> for r in regexlist : <TAB> <TAB> <TAB> match = re. search ( r, text ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if getGroupPos : <TAB> <TAB> <TAB> <TAB> <TAB> foundPos = startpos + match. start ( getGroupPos ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> foundPos = startpos + match. start ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if closestPos is None or foundPos < closestPos : <TAB> <TAB> <TAB> <TAB> <TAB> closestPos = foundPos <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> sm. selectionStart = match. start ( ) <TAB> <TAB> <TAB> <TAB> <TAB> sm. selectionEnd = match. end ( ) <TAB> return closestPos",True,match,match,0.6760464310646057
|
||
|
1875,"def mutated ( self, indiv ) : <TAB> """"""mutate some genes of the given individual"""""" <TAB> res = indiv. copy ( ) <TAB> <TAB> for i in range ( self. numParameters ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if self. xBound is None : <TAB> <TAB> <TAB> <TAB> res [ i ] = indiv [ i ] + gauss ( 0, self. mutationStdDev ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> res [ i ] = max ( <TAB> <TAB> <TAB> <TAB> <TAB> min ( indiv [ i ] + gauss ( 0, self. mutationStdDev ), self. maxs [ i ] ), <TAB> <TAB> <TAB> <TAB> <TAB> self. mins [ i ], <TAB> <TAB> <TAB> <TAB> ) <TAB> return res",False,random() < self.mutationProb,i in indiv.keys(),0.6597429513931274
|
||
|
1876,"def read_stanza ( self ) : <TAB> while True : <TAB> <TAB> try : <TAB> <TAB> <TAB> stanza_end = self. _buffer. index ( b""\n"" ) <TAB> <TAB> <TAB> stanza = self. decoder. decode ( self. _buffer [ : stanza_end ] ) <TAB> <TAB> <TAB> self. _buffer = self. _buffer [ stanza_end + 1 : ] <TAB> <TAB> <TAB> colon = stanza. index ( "":"" ) <TAB> <TAB> <TAB> return stanza [ : colon ], stanza [ colon + 1 : ] <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> bytes = self. read_bytes ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return None <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. _buffer += bytes",True,not bytes,not bytes,0.6754790544509888
|
||
|
1877,"def validate_transaction_reference ( self ) : <TAB> bank_account = self. paid_to if self. payment_type == ""Receive"" else self. paid_from <TAB> bank_account_type = frappe. db. get_value ( ""Account"", bank_account, ""account_type"" ) <TAB> if bank_account_type == ""Bank"" : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> frappe. throw ( <TAB> <TAB> <TAB> <TAB> _ ( ""Reference No and Reference Date is mandatory for Bank transaction"" ) <TAB> <TAB> <TAB> )",False,not self.reference_no or not self.reference_date,self.last_transaction_date is None,0.6513961553573608
|
||
|
1878,"def arith_expr ( self, nodelist ) : <TAB> node = self. com_node ( nodelist [ 0 ] ) <TAB> for i in range ( 2, len ( nodelist ), 2 ) : <TAB> <TAB> right = self. com_node ( nodelist [ i ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> node = Add ( node, right, lineno = nodelist [ 1 ]. context ) <TAB> <TAB> elif nodelist [ i - 1 ]. type == token. MINUS : <TAB> <TAB> <TAB> node = Sub ( node, right, lineno = nodelist [ 1 ]. context ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise ValueError ( ""unexpected token: %s"" % nodelist [ i - 1 ] [ 0 ] ) <TAB> return node",False,nodelist[i - 1].type == token.PLUS,nodelist[i - 1].type == token.MAXUS,0.6558165550231934
|
||
|
1879,"def _catch_revision_errors ( <TAB> self, ancestor = None, multiple_heads = None, start = None, end = None, resolution = None ) : <TAB> try : <TAB> <TAB> yield <TAB> except RangeNotAncestorError as rna : <TAB> <TAB> if start is None : <TAB> <TAB> <TAB> start = rna. lower <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> end = rna. upper <TAB> <TAB> if not ancestor : <TAB> <TAB> <TAB> ancestor = ( <TAB> <TAB> <TAB> <TAB> ""Requested range %(start)s:%(end)s does not refer to "" <TAB> <TAB> <TAB> <TAB> ""ancestor/descendant revisions along the same branch"" <TAB> <TAB> <TAB> ) <TAB> <TAB> ancestor = ancestor % { ""start"" : start, ""end"" : end } <TAB> <TAB> raise Exception ( ancestor ) <TAB> except MultipleHeads as mh : <TAB> <TAB> if not multiple_heads : <TAB> <TAB> <TAB> multiple_heads = ( <TAB> <TAB> <TAB> <TAB> ""Multiple head revisions are present for given "" <TAB> <TAB> <TAB> <TAB> ""argument '%(head_arg)s'; please "" <TAB> <TAB> <TAB> <TAB> ""specify a specific target revision, "" <TAB> <TAB> <TAB> <TAB> ""'<branchname>@%(head_arg)s' to "" <TAB> <TAB> <TAB> <TAB> ""narrow to a specific head, or 'heads' for all heads"" <TAB> <TAB> <TAB> ) <TAB> <TAB> multiple_heads = multiple_heads % { <TAB> <TAB> <TAB> ""head_arg"" : end or mh. argument, <TAB> <TAB> <TAB> ""heads"" : str ( mh. heads ), <TAB> <TAB> } <TAB> <TAB> raise Exception ( multiple_heads ) <TAB> except ResolutionError as re : <TAB> <TAB> if resolution is None : <TAB> <TAB> <TAB> resolution = ""Can't locate revision identified by '%s",True,end is None,end is None,0.6718732118606567
|
||
|
1880,"def doc_help ( doc_lines ) : <TAB> """"""print formated command's docstring"""""" <TAB> <TAB> if len ( doc_lines ) < 2 : <TAB> <TAB> return False <TAB> doc_lines. pop ( 0 ) <TAB> while not doc_lines [ 0 ]. strip ( ) : <TAB> <TAB> doc_lines. pop ( 0 ) <TAB> <TAB> trash = len ( doc_lines [ 0 ] ) - len ( doc_lines [ 0 ]. lstrip ( ) ) <TAB> doc_lines = [ line [ trash : ]. rstrip ( ) for line in doc_lines ] <TAB> <TAB> result = """" <TAB> for line in doc_lines : <TAB> <TAB> if line == line. lstrip ( ) : <TAB> <TAB> <TAB> line = colorize ( ""%BoldWhite"", line ) <TAB> <TAB> elif line. startswith ( "" * "" ) : <TAB> <TAB> <TAB> line = colorize ( "" * "", ""%Yellow"", line [ 6 : ] ) <TAB> <TAB> elif line. startswith ( "" > "" ) : <TAB> <TAB> <TAB> line = colorize ( "" > "", ""%Cyan"", line [ 6 : ] ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> line = colorize ( ""%Dim"", line ) <TAB> <TAB> elif line. startswith ( "" -"" ) and line [ 5 ]!= "" "" : <TAB> <TAB> <TAB> line = colorize ( ""%Green"", line ) <TAB> <TAB> result += line + ""\n"" <TAB> print ( result ) <TAB> return True",False,line.startswith(' # '),line.startswith(' -'),0.6523780822753906
|
||
|
1881,"def plot_training_curves ( <TAB> self, file_name : Union [ str, Path ], plot_values : List [ str ] = [ ""loss"", ""F1"" ] ) : <TAB> if type ( file_name ) is str : <TAB> <TAB> file_name = Path ( file_name ) <TAB> fig = plt. figure ( figsize = ( 15, 10 ) ) <TAB> for plot_no, plot_value in enumerate ( plot_values ) : <TAB> <TAB> training_curves = self. _extract_evaluation_data ( file_name, plot_value ) <TAB> <TAB> plt. subplot ( len ( plot_values ), 1, plot_no + 1 ) <TAB> <TAB> if training_curves [ ""train"" ] [ ""score"" ] : <TAB> <TAB> <TAB> x = np. arange ( 0, len ( training_curves [ ""train"" ] [ ""score"" ] ) ) <TAB> <TAB> <TAB> plt. plot ( <TAB> <TAB> <TAB> <TAB> x, training_curves [ ""train"" ] [ ""score"" ], label = f""training {plot_value}"" <TAB> <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> x = np. arange ( 0, len ( training_curves [ ""dev"" ] [ ""score"" ] ) ) <TAB> <TAB> <TAB> plt. plot ( <TAB> <TAB> <TAB> <TAB> x, training_curves [ ""dev"" ] [ ""score"" ], label = f""validation {plot_value}"" <TAB> <TAB> <TAB> ) <TAB> <TAB> if training_curves [ ""test"" ] [ ""score"" ] : <TAB> <TAB> <TAB> x = np. arange ( 0, len ( training_curves [ ""test"" ] [ ""score"" ] ) ) <TAB> <TAB> <TAB> plt. plot ( x, training_curves [ ""test"" ] [ ""score"" ], label = f""test {plot_value}"" ) <TAB> <TAB> plt. legend ( bbox_to_anchor = ( 1.04, 0 )",False,training_curves['dev']['score'],training_curves['dev'],0.6562501192092896
|
||
|
1882,"def step_forward ( <TAB> self, <TAB> img_feats : Tensor, <TAB> question_feats : Tensor, <TAB> actions_in : Tensor, <TAB> hidden : Tensor, ) -> Tuple [ Tensor, Tensor ] : <TAB> T = False <TAB> if self. image_input is True : <TAB> <TAB> N, T, _ = img_feats. size ( ) <TAB> <TAB> input_feats = img_feats <TAB> if self. question_input is True : <TAB> <TAB> N, D = question_feats. size ( ) <TAB> <TAB> question_feats = question_feats. view ( N, 1, D ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> T = actions_in. size ( 1 ) <TAB> <TAB> question_feats = question_feats. repeat ( 1, T, 1 ) <TAB> <TAB> if len ( input_feats ) == 0 : <TAB> <TAB> <TAB> input_feats = question_feats <TAB> <TAB> else : <TAB> <TAB> <TAB> input_feats = torch. cat ( [ input_feats, question_feats ], 2 ) <TAB> if self. action_input is True : <TAB> <TAB> if len ( input_feats ) == 0 : <TAB> <TAB> <TAB> input_feats = self. action_embed ( actions_in ) <TAB> <TAB> else : <TAB> <TAB> <TAB> actions_in = actions_in. long ( ) <TAB> <TAB> <TAB> input_feats = torch. cat ( [ input_feats, self. action_embed ( actions_in ) ], 2 ) <TAB> output, hidden = self. rnn ( input_feats, hidden ) <TAB> output = self. decoder ( <TAB> <TAB> output. contiguous ( ). view ( output. size ( 0 ) * output. size ( 1 ), output. size ( 2 ) ) <TAB> ) <TAB> return output, hidden",False,T is False,self.t_in is True,0.6669957637786865
|
||
|
1883,"def align_comments ( tlist ) : <TAB> tidx, token = tlist. token_next_by ( i = sql. Comment ) <TAB> while token : <TAB> <TAB> pidx, prev_ = tlist. token_prev ( tidx ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> tlist. group_tokens ( sql. TokenList, pidx, tidx, extend = True ) <TAB> <TAB> <TAB> tidx = pidx <TAB> <TAB> tidx, token = tlist. token_next_by ( i = sql. Comment, idx = tidx )",False,"isinstance(prev_, sql.TokenList)",prev_ and token == prev_,0.6487141251564026
|
||
|
1884,"def _check_with_bulk_schema ( self, field, value ) : <TAB> <TAB> if isinstance ( value, _str_type ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return <TAB> <TAB> else : <TAB> <TAB> <TAB> self. known_rules_set_refs. add ( value ) <TAB> <TAB> definition = self. target_validator. rules_set_registry. get ( value ) <TAB> <TAB> if definition is None : <TAB> <TAB> <TAB> self. _error ( field, ""Rules set definition %s not found."" % value ) <TAB> <TAB> <TAB> return <TAB> <TAB> else : <TAB> <TAB> <TAB> value = definition <TAB> _hash = ( <TAB> <TAB> mapping_hash ( { ""turing"" : value } ), <TAB> <TAB> mapping_hash ( self. target_validator. types_mapping ), <TAB> ) <TAB> if _hash in self. target_validator. _valid_schemas : <TAB> <TAB> return <TAB> validator = self. _get_child_validator ( <TAB> <TAB> document_crumb = field, <TAB> <TAB> allow_unknown = False, <TAB> <TAB> schema = self. target_validator. rules, <TAB> ) <TAB> validator ( value, normalize = False ) <TAB> if validator. _errors : <TAB> <TAB> self. _error ( validator. _errors ) <TAB> else : <TAB> <TAB> self. target_validator. _valid_schemas. add ( _hash )",True,value in self.known_rules_set_refs,value in self.known_rules_set_refs,0.6493253707885742
|
||
|
1885,"def get_volume_image_metadata ( image_id, image_meta ) : <TAB> <TAB> base_metadata = { <TAB> <TAB> ""image_id"" : image_id, <TAB> } <TAB> name = image_meta. get ( ""name"", None ) <TAB> if name : <TAB> <TAB> base_metadata [ ""image_name"" ] = name <TAB> <TAB> <TAB> for key in IMAGE_ATTRIBUTES : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> value = image_meta. get ( key, None ) <TAB> <TAB> if value is not None : <TAB> <TAB> <TAB> base_metadata [ key ] = value <TAB> <TAB> property_metadata = { } <TAB> image_properties = image_meta. get ( ""properties"", { } ) <TAB> for ( key, value ) in image_properties. items ( ) : <TAB> <TAB> if value is not None : <TAB> <TAB> <TAB> property_metadata [ key ] = value <TAB> volume_metadata = dict ( property_metadata ) <TAB> volume_metadata. update ( base_metadata ) <TAB> return volume_metadata",False,key not in image_meta,key in base_metadata,0.65754634141922
|
||
|
1886,"def get_data ( row ) : <TAB> data = [ ] <TAB> for field_name, field_xpath in fields : <TAB> <TAB> result = row. xpath ( field_xpath ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> result = "" "". join ( <TAB> <TAB> <TAB> <TAB> text <TAB> <TAB> <TAB> <TAB> for text in map ( <TAB> <TAB> <TAB> <TAB> <TAB> six. text_type. strip, map ( six. text_type, map ( unescape, result ) ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> if text <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> result = None <TAB> <TAB> data. append ( result ) <TAB> return data",True,result,result,0.6867662668228149
|
||
|
1887,"def _update_label ( self ) : <TAB> diff_num = self. table. get_reference_difference ( ) <TAB> if diff_num is None : <TAB> <TAB> <TAB> <TAB> if self. table. version_index == 0 : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> txt = ""the only package"" <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> txt = ""the latest package"" <TAB> <TAB> else : <TAB> <TAB> <TAB> nth = positional_number_string ( self. table. version_index + 1 ) <TAB> <TAB> <TAB> txt = ""the %s latest package"" % nth <TAB> <TAB> if self. table. num_versions > 1 : <TAB> <TAB> <TAB> txt += "" of %d packages"" % self. table. num_versions <TAB> <TAB> txt = ""%s is %s"" % ( self. variant. qualified_package_name, txt ) <TAB> else : <TAB> <TAB> <TAB> <TAB> adj = ""ahead"" if diff_num > 0 else ""behind"" <TAB> <TAB> diff_num = abs ( diff_num ) <TAB> <TAB> unit = ""version"" if diff_num == 1 else ""versions"" <TAB> <TAB> txt = ""Package is %d %s %s"" % ( diff_num, unit, adj ) <TAB> self. label. setText ( txt )",False,self.table.num_versions == 1,self.variant.qualified_package_name,0.6535567045211792
|
||
|
1888,"def finalize_options ( self ) : <TAB> self. set_undefined_options ( ""bdist"", ( ""bdist_base"", ""bdist_base"" ) ) <TAB> if self. rpm_base is None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise DistutilsOptionError ( ""you must specify --rpm-base in RPM 2 mode"" ) <TAB> <TAB> self. rpm_base = os. path. join ( self. bdist_base, ""rpm"" ) <TAB> if self. python is None : <TAB> <TAB> if self. fix_python : <TAB> <TAB> <TAB> self. python = sys. executable <TAB> <TAB> else : <TAB> <TAB> <TAB> self. python = ""python3"" <TAB> elif self. fix_python : <TAB> <TAB> raise DistutilsOptionError ( <TAB> <TAB> <TAB> ""--python and --fix-python are mutually exclusive options"" <TAB> <TAB> ) <TAB> if os. name!= ""posix"" : <TAB> <TAB> raise DistutilsPlatformError ( <TAB> <TAB> <TAB> ""don't know how to create RPM "" ""distributions on platform %s"" % os. name <TAB> <TAB> ) <TAB> if self. binary_only and self. source_only : <TAB> <TAB> raise DistutilsOptionError ( <TAB> <TAB> <TAB> ""cannot supply both '--source-only' and '--binary-only'"" <TAB> <TAB> ) <TAB> <TAB> if not self. distribution. has_ext_modules ( ) : <TAB> <TAB> self. use_rpm_opt_flags = 0 <TAB> self. set_undefined_options ( ""bdist"", ( ""dist_dir"", ""dist_dir"" ) ) <TAB> self. finalize_package_data ( )",False,not self.rpm3_mode,self.bdist_base is None,0.6567996740341187
|
||
|
1889,"def duplicate_shared_dir_validator ( section_key, section_label, pcluster_config ) : <TAB> errors = [ ] <TAB> warnings = [ ] <TAB> config_parser = pcluster_config. config_parser <TAB> section = pcluster_config. get_section ( section_key, section_label ) <TAB> if config_parser : <TAB> <TAB> shared_dir_in_cluster = config_parser. has_option ( <TAB> <TAB> <TAB> get_file_section_name ( ""cluster"", section_label ), ""shared_dir"" <TAB> <TAB> ) <TAB> <TAB> ebs_settings_in_cluster = config_parser. has_option ( <TAB> <TAB> <TAB> get_file_section_name ( ""cluster"", section_label ), ""ebs_settings"" <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> list_of_ebs_sections = [ ] <TAB> <TAB> <TAB> for ebs_section_label in section. get_param_value ( ""ebs_settings"" ). split ( "","" ) : <TAB> <TAB> <TAB> <TAB> ebs_section = pcluster_config. get_section ( <TAB> <TAB> <TAB> <TAB> <TAB> ""ebs"", ebs_section_label. strip ( ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> list_of_ebs_sections. append ( ebs_section ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if len ( list_of_ebs_sections ) == 1 and list_of_ebs_sections [ <TAB> <TAB> <TAB> <TAB> 0 <TAB> <TAB> <TAB> ]. get_param_value ( ""shared_dir"" ) : <TAB> <TAB> <TAB> <TAB> errors. append ( <TAB> <TAB> <TAB> <TAB> <TAB> ""'shared_dir' can not be specified both in cluster section and EBS section"" <TAB> <TAB> <TAB> <TAB> ) <",False,shared_dir_in_cluster and ebs_settings_in_cluster,ebs_settings_in_cluster,0.6518061757087708
|
||
|
1890,"def Main ( argv ) : <TAB> set_profile = set_home = trust_os_path = False <TAB> for arg in argv : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> os. environ [ ""MAILPILE_PROFILE"" ] = arg. split ( ""="", 1 ) [ - 1 ] <TAB> <TAB> <TAB> if ""MAILPILE_HOME"" in os. environ : <TAB> <TAB> <TAB> <TAB> del os. environ [ ""MAILPILE_HOME"" ] <TAB> <TAB> <TAB> set_profile = True <TAB> <TAB> elif arg. startswith ( ""--home="" ) : <TAB> <TAB> <TAB> os. environ [ ""MAILPILE_HOME"" ] = arg. split ( ""="", 1 ) [ - 1 ] <TAB> <TAB> <TAB> if ""MAILPILE_PROFILE"" in os. environ : <TAB> <TAB> <TAB> <TAB> del os. environ [ ""MAILPILE_PROFILE"" ] <TAB> <TAB> <TAB> set_home = True <TAB> <TAB> elif arg == ""--trust-os-path"" : <TAB> <TAB> <TAB> trust_os_path = True <TAB> if set_home and set_profile : <TAB> <TAB> raise ValueError ( ""Please only use one of --home and --profile"" ) <TAB> state = MailpileState ( ). discover ( argv ) <TAB> ActivateTranslation ( None, state. pub_config, None ) <TAB> script = [ <TAB> <TAB> GenerateConfig ( state ), <TAB> <TAB> GenerateBootstrap ( state, trust_os_path = trust_os_path ), <TAB> ] <TAB> if ""--script"" in argv : <TAB> <TAB> print ( ""\n"". join ( script ) ) <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> from mailpile. safe_popen import MakePopenUnsafe <TAB> <TAB> MakePopenUnsafe ( ) <TAB> <TAB> from gui_o_matic. control import GUIPipeControl <TAB> <TAB> gpc = GUIPipeControl ( StringIO ( ""\n"". join",False,arg.startswith('--profile='),arg.startswith('--load-password -CLUNCHER-HOME'),0.6500493884086609
|
||
|
1891,"def font_variant_numeric ( tokens ) : <TAB> if len ( tokens ) == 1 : <TAB> <TAB> keyword = get_keyword ( tokens [ 0 ] ) <TAB> <TAB> if keyword == ""normal"" : <TAB> <TAB> <TAB> return keyword <TAB> values = [ ] <TAB> couples = ( <TAB> <TAB> ( ""lining-nums"", ""oldstyle-nums"" ), <TAB> <TAB> ( ""proportional-nums"", ""tabular-nums"" ), <TAB> <TAB> ( ""diagonal-fractions"", ""stacked-fractions"" ), <TAB> <TAB> ( ""ordinal"", ), <TAB> <TAB> ( ""slashed-zero"", ), <TAB> ) <TAB> all_values = [ ] <TAB> for couple in couples : <TAB> <TAB> all_values. extend ( couple ) <TAB> for token in tokens : <TAB> <TAB> if token. type!= ""ident"" : <TAB> <TAB> <TAB> return None <TAB> <TAB> if token. value in all_values : <TAB> <TAB> <TAB> concurrent_values = [ couple for couple in couples if token. value in couple ] [ <TAB> <TAB> <TAB> <TAB> 0 <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return None <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> values. append ( token. value ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return None <TAB> if values : <TAB> <TAB> return tuple ( values )",False,any((value in values for value in concurrent_values)),len(concurrent_values) == 0,0.6551509499549866
|
||
|
1892,"def find_process_imports ( self, task ) : <TAB> task_space = task. get_process_address_space ( ) <TAB> all_mods = list ( task. get_load_modules ( ) ) <TAB> <TAB> apis = self. _enum_apis ( all_mods ) <TAB> <TAB> if not all_mods : <TAB> <TAB> self. session. logging. error ( ""Cannot load DLLs in process AS"" ) <TAB> <TAB> return <TAB> <TAB> <TAB> base_address = int ( all_mods [ 0 ]. DllBase ) <TAB> size_to_read = int ( all_mods [ 0 ]. SizeOfImage ) <TAB> calls_imported = { } <TAB> for address, iat, destination in self. call_scan ( <TAB> <TAB> task_space, base_address, size_to_read <TAB> ) : <TAB> <TAB> self. session. report_progress ( ""Resolving import %s->%s"" % ( address, iat ) ) <TAB> <TAB> calls_imported [ iat ] = ( address, destination ) <TAB> <TAB> self. _iat_scan ( <TAB> <TAB> task_space, calls_imported, apis, base_address, base_address + size_to_read <TAB> ) <TAB> for iat, ( _, func_pointer ) in sorted ( calls_imported. items ( ) ) : <TAB> <TAB> tmp = apis. get ( func_pointer. obj_offset ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> module, func_pointer, func_name = tmp <TAB> <TAB> <TAB> yield iat, func_pointer, module, func_name",True,tmp,tmp,0.689765214920044
|
||
|
1893,"def output_package_listing ( self, packages, options ) : <TAB> packages = sorted ( <TAB> <TAB> packages, <TAB> <TAB> key = lambda dist : dist. project_name. lower ( ), <TAB> ) <TAB> if options. list_format == ""columns"" and packages : <TAB> <TAB> data, header = format_for_columns ( packages, options ) <TAB> <TAB> self. output_package_listing_columns ( data, header ) <TAB> elif options. list_format == ""freeze"" : <TAB> <TAB> for dist in packages : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> logger. info ( <TAB> <TAB> <TAB> <TAB> <TAB> ""%s==%s (%s)"", dist. project_name, dist. version, dist. location <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> logger. info ( ""%s==%s"", dist. project_name, dist. version ) <TAB> elif options. list_format == ""json"" : <TAB> <TAB> logger. info ( format_for_json ( packages, options ) )",False,options.verbose >= 1,options.list_format == 'location',0.6556912064552307
|
||
|
1894,"def convertDict ( obj ) : <TAB> obj = dict ( obj ) <TAB> for k, v in obj. items ( ) : <TAB> <TAB> del obj [ k ] <TAB> <TAB> if not ( isinstance ( k, str ) or isinstance ( k, unicode ) ) : <TAB> <TAB> <TAB> k = dumps ( k ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> obj [ Types. KEYS ] = [ ] <TAB> <TAB> <TAB> obj [ Types. KEYS ]. append ( k ) <TAB> <TAB> obj [ k ] = convertObjects ( v ) <TAB> return obj",False,Types.KEYS not in obj,k not in obj,0.6762058734893799
|
||
|
1895,"def deleteEditor ( self, event = None ) : <TAB> """"""Delete the presently selected body text editor."""""" <TAB> c, d = self. c, self. editorWidgets <TAB> wrapper = c. frame. body. wrapper <TAB> w = wrapper. widget <TAB> <TAB> <TAB> assert g. isTextWrapper ( wrapper ), wrapper <TAB> assert g. isTextWidget ( w ), w <TAB> if len ( list ( d. keys ( ) ) ) <= 1 : <TAB> <TAB> return <TAB> name = w. leo_name if hasattr ( w, ""leo_name"" ) else ""1"" <TAB> <TAB> <TAB> if name == ""1"" : <TAB> <TAB> g. warning ( ""can not delete leftmost editor"" ) <TAB> <TAB> return <TAB> <TAB> c. p. b = wrapper. getAllText ( ) <TAB> <TAB> <TAB> del d [ name ] <TAB> f = c. frame. top. leo_body_inner_frame <TAB> layout = f. layout ( ) <TAB> for z in ( w, w. leo_label ) : <TAB> <TAB> if z : <TAB> <TAB> <TAB> self. unpackWidget ( layout, z ) <TAB> w. leo_label = None <TAB> <TAB> <TAB> new_wrapper = list ( d. values ( ) ) [ 0 ] <TAB> self. numberOfEditors -= 1 <TAB> if self. numberOfEditors == 1 : <TAB> <TAB> w = new_wrapper. widget <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. unpackWidget ( layout, w. leo_label ) <TAB> <TAB> <TAB> w. leo_label = None <TAB> self. selectEditor ( new_wrapper )",False,"getattr(w, 'leo_label', None)",w,0.6484655737876892
|
||
|
1896,"def match_var_against_type ( self, var, other_type, subst, node, view ) : <TAB> """"""Match a variable against a type."""""" <TAB> if var. bindings : <TAB> <TAB> return self. _match_value_against_type ( view [ var ], other_type, subst, node, view ) <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> other_type = other_type. get_formal_type_parameter ( abstract_utils. T ) <TAB> <TAB> if isinstance ( other_type, abstract. Union ) : <TAB> <TAB> <TAB> right_side_options = other_type. options <TAB> <TAB> else : <TAB> <TAB> <TAB> right_side_options = [ other_type ] <TAB> <TAB> for right in right_side_options : <TAB> <TAB> <TAB> if isinstance ( right, abstract. TypeParameter ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if right. full_name not in subst : <TAB> <TAB> <TAB> <TAB> <TAB> subst = subst. copy ( ) <TAB> <TAB> <TAB> <TAB> <TAB> subst [ right. full_name ] = var. program. NewVariable ( ) <TAB> <TAB> <TAB> <TAB> return subst",False,"isinstance(other_type, abstract.TupleClass)","isinstance(other_type, abstract_utils.Variable)",0.6496050357818604
|
||
|
1897,"def get ( self ) : <TAB> """"""return a secret by name"""""" <TAB> results = self. _get ( ""secrets"", self. name ) <TAB> results [ ""decoded"" ] = { } <TAB> results [ ""exists"" ] = False <TAB> if results [ ""returncode"" ] == 0 and results [ ""results"" ] [ 0 ] : <TAB> <TAB> results [ ""exists"" ] = True <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if ""data"" in results [ ""results"" ] [ 0 ] : <TAB> <TAB> <TAB> <TAB> for sname, value in results [ ""results"" ] [ 0 ] [ ""data"" ]. items ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> results [ ""decoded"" ] [ sname ] = base64. b64decode ( value ) <TAB> if results [ ""returncode"" ]!= 0 and '""%s"" not found' % self. name in results [ ""stderr"" ] : <TAB> <TAB> results [ ""returncode"" ] = 0 <TAB> return results",False,self.decode,results['exists'],0.6638282537460327
|
||
|
1898,"def spawnProcess ( pp, cmd, argv, path, usePTY, env ) : <TAB> self. assertEqual ( <TAB> <TAB> [ cmd, argv, path, usePTY, env ], <TAB> <TAB> [ exp_cmd, exp_argv, exp_path, exp_usePTY, exp_env ], <TAB> ) <TAB> for output in outputs : <TAB> <TAB> if output [ 0 ] == ""out"" : <TAB> <TAB> <TAB> pp. outReceived ( output [ 1 ] ) <TAB> <TAB> elif output [ 0 ] == ""err"" : <TAB> <TAB> <TAB> pp. errReceived ( output [ 1 ] ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> if output [ 1 ]!= 0 : <TAB> <TAB> <TAB> <TAB> so = error. ProcessTerminated ( exitCode = output [ 1 ] ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> so = error. ProcessDone ( None ) <TAB> <TAB> <TAB> pp. processEnded ( failure. Failure ( so ) )",False,output[0] == 'rc',output[0] == 'exit',0.6548707485198975
|
||
|
1899,"def _obj_ref_action ( <TAB> _notify_usage, <TAB> LOG, <TAB> obj_ref, <TAB> extra_info, <TAB> admin_context, <TAB> begin, <TAB> end, <TAB> notify_about_usage, <TAB> type_id_str, <TAB> type_name, ) : <TAB> _notify_usage ( LOG, obj_ref, extra_info, admin_context ) <TAB> if CONF. send_actions : <TAB> <TAB> if begin < obj_ref. created_at < end : <TAB> <TAB> <TAB> _create_action ( <TAB> <TAB> <TAB> <TAB> obj_ref, admin_context, LOG, notify_about_usage, type_id_str, type_name <TAB> <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> _delete_action ( <TAB> <TAB> <TAB> <TAB> obj_ref, admin_context, LOG, notify_about_usage, type_id_str, type_name <TAB> <TAB> <TAB> )",False,obj_ref.deleted_at and begin < obj_ref.deleted_at < end,end < obj_ref.created_at < end,0.6494174003601074
|
||
|
1900,"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<mask> : <TAB> <TAB> <TAB> break <TAB> <TAB> if fid == 0 : <TAB> <TAB> <TAB> if ftype == TType. LIST : <TAB> <TAB> <TAB> <TAB> self. success = [ ] <TAB> <TAB> <TAB> <TAB> ( _etype841, _size838 ) = iprot. readListBegin ( ) <TAB> <TAB> <TAB> <TAB> for _i842 in xrange ( _size838 ) : <TAB> <TAB> <TAB> <TAB> <TAB> _elem843 = Partition ( ) <TAB> <TAB> <TAB> <TAB> <TAB> _elem843. read ( iprot ) <TAB> <TAB> <TAB> <TAB> <TAB> self. success. append ( _elem843 ) <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",False,ftype == TType.STOP,fid == 2,0.6626691818237305
|
||
|
1901,"def backward_impl ( self, inputs, outputs, prop_down, accum ) : <TAB> <TAB> <TAB> <TAB> axis = self. forward_func. info. args [ ""axis"" ] <TAB> <TAB> <TAB> if prop_down [ - 1 ] : <TAB> <TAB> g_dy = inputs [ - 1 ]. grad <TAB> <TAB> g_dy_ = F. stack ( * [ o. grad for o in outputs ], axis = axis ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> g_dy += g_dy_ <TAB> <TAB> else : <TAB> <TAB> <TAB> g_dy. copy_from ( g_dy_ )",False,accum[-1],accum[0],0.6641381978988647
|
||
|
1902,"def dispose ( cls ) : <TAB> <TAB> for inst in cls. instances : <TAB> <TAB> old_session = inst. session <TAB> <TAB> inst. session = None <TAB> <TAB> if old_session : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> old_session. close ( ) <TAB> <TAB> <TAB> except : <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> if old_session. bind : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> old_session. bind. dispose ( ) <TAB> <TAB> <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> <TAB> <TAB> pass <TAB> for attr in list ( Books. __dict__. keys ( ) ) : <TAB> <TAB> if attr. startswith ( ""custom_column_"" ) : <TAB> <TAB> <TAB> setattr ( Books, attr, None ) <TAB> for db_class in cc_classes. values ( ) : <TAB> <TAB> Base. metadata. remove ( db_class. __table__ ) <TAB> cc_classes. clear ( ) <TAB> for table in reversed ( Base. metadata. sorted_tables ) : <TAB> <TAB> name = table. key <TAB> <TAB> if name. startswith ( ""custom_column_"" ) or name. startswith ( ""books_custom_column_"" ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> Base. metadata. remove ( table )",False,table is not None,table.delete_table,0.6606956720352173
|
||
|
1903,"def _get_annotated_template ( self, template ) : <TAB> changed = False <TAB> if template. get ( ""version"", ""0.12.0"" ) >= ""0.13.0"" : <TAB> <TAB> using_js = self. spider. _filter_js_urls ( template [ ""url"" ] ) <TAB> <TAB> body = ""rendered_body"" if using_js else ""original_body"" <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> template [ ""body"" ] = body <TAB> <TAB> <TAB> changed = True <TAB> if changed or not template. get ( ""annotated"" ) : <TAB> <TAB> _build_sample ( template ) <TAB> return template",False,template.get('body') != body,body and body.get('annotated'),0.6574987769126892
|
||
|
1904,"def _count_split ( cls, input_file, chunk_size, subdir_generator_function ) : <TAB> """"""Split a FASTA file into chunks based on counting records."""""" <TAB> log. debug ( <TAB> <TAB> ""Attemping to split FASTA file %s into chunks of %i sequences"" <TAB> <TAB> % ( input_file, chunk_size ) <TAB> ) <TAB> f = open ( input_file ) <TAB> part_file = None <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> part_dir = subdir_generator_function ( ) <TAB> <TAB> part_path = os. path. join ( part_dir, os. path. basename ( input_file ) ) <TAB> <TAB> part_file = open ( part_path, ""w"" ) <TAB> <TAB> log. debug ( ""Writing {} part to {}"". format ( input_file, part_path ) ) <TAB> <TAB> rec_count = 0 <TAB> <TAB> while True : <TAB> <TAB> <TAB> line = f. readline ( ) <TAB> <TAB> <TAB> if not line : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> rec_count += 1 <TAB> <TAB> <TAB> <TAB> if rec_count > chunk_size : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> part_file. close ( ) <TAB> <TAB> <TAB> <TAB> <TAB> part_dir = subdir_generator_function ( ) <TAB> <TAB> <TAB> <TAB> <TAB> part_path = os. path. join ( part_dir, os. path. basename ( input_file ) ) <TAB> <TAB> <TAB> <TAB> <TAB> part_file = open ( part_path, ""w"" ) <TAB> <TAB> <TAB> <TAB> <TAB> log. debug ( ""Writing {} part to {}"". format ( input_file, part_path ) ) <TAB> <TAB> <",False,line[0] == '>',line == '',0.658064603805542
|
||
|
1905,"def _gfal ( self, cmd, * args, retry = None, raise_workflow_error = True ) : <TAB> if retry is None : <TAB> <TAB> retry = self. provider. retry <TAB> _cmd = [ ""gfal-"" + cmd ] + list ( args ) <TAB> for i in range ( retry + 1 ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> logger. debug ( _cmd ) <TAB> <TAB> <TAB> return sp. run ( <TAB> <TAB> <TAB> <TAB> _cmd, check = True, stderr = sp. PIPE, stdout = sp. PIPE <TAB> <TAB> <TAB> ). stdout. decode ( ) <TAB> <TAB> except sp. CalledProcessError as e : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> if raise_workflow_error : <TAB> <TAB> <TAB> <TAB> <TAB> raise WorkflowError ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""Error calling gfal-{}:\n{}"". format ( cmd, e. stderr. decode ( ) ) <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> raise e <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> time. sleep ( 1 ) <TAB> <TAB> <TAB> <TAB> continue",False,i == retry,e.returncode == 0,0.674399733543396
|
||
|
1906,"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<mask> : <TAB> <TAB> <TAB> if ftype == TType. STRUCT : <TAB> <TAB> <TAB> <TAB> self. req = TGetFunctionsReq ( ) <TAB> <TAB> <TAB> <TAB> self. req. 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 ( )",False,fid == 1,fid == TType.START,0.6731555461883545
|
||
|
1907,"def include_file ( name, fdir = tmp_dir, b64 = False ) : <TAB> try : <TAB> <TAB> if fdir is None : <TAB> <TAB> <TAB> fdir = """" <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> with io. open ( os. path. join ( fdir, name ), ""rb"" ) as f : <TAB> <TAB> <TAB> <TAB> return base64. b64encode ( f. read ( ) ). decode ( ""utf-8"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> with io. open ( os. path. join ( fdir, name ), ""r"", encoding = ""utf-8"" ) as f : <TAB> <TAB> <TAB> <TAB> return f. read ( ) <TAB> except ( OSError, IOError ) as e : <TAB> <TAB> logger. error ( ""Could not include file '{}': {}"". format ( name, e ) )",True,b64,b64,0.6819143295288086
|
||
|
1908,"def get_overdue_evergreen_documents ( *, db_session ) -> List [ Optional [ Document ] ] : <TAB> """"""Returns all documents that have need had a recent evergreen notification."""""" <TAB> documents = ( <TAB> <TAB> db_session. query ( Document ). filter ( Document. evergreen == True ) <TAB> ). all ( ) <TAB> overdue_documents = [ ] <TAB> now = datetime. utcnow ( ) <TAB> for d in documents : <TAB> <TAB> next_reminder = d. evergreen_last_reminder_at + timedelta ( <TAB> <TAB> <TAB> days = d. evergreen_reminder_interval <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> overdue_documents. append ( d ) <TAB> return overdue_documents",False,now > next_reminder,next_reminder >= now and days > 1,0.6637026071548462
|
||
|
1909,"def build ( self, input_shape ) : <TAB> assert len ( input_shape ) >= 2 <TAB> if isinstance ( input_shape, list ) and len ( input_shape ) == 2 : <TAB> <TAB> self. data_mode = ""disjoint"" <TAB> <TAB> F = input_shape [ 0 ] [ - 1 ] <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. data_mode = ""single"" <TAB> <TAB> else : <TAB> <TAB> <TAB> self. data_mode = ""batch"" <TAB> <TAB> F = input_shape [ - 1 ] <TAB> <TAB> self. attn_kernel = self. add_weight ( <TAB> <TAB> shape = ( F, 1 ), <TAB> <TAB> initializer = self. attn_kernel_initializer, <TAB> <TAB> regularizer = self. attn_kernel_regularizer, <TAB> <TAB> constraint = self. attn_kernel_constraint, <TAB> <TAB> name = ""attn_kernel"", <TAB> ) <TAB> self. built = True",False,len(input_shape) == 2,"isinstance(input_shape[1], list)",0.6554309129714966
|
||
|
1910,"def get ( self, * args, ** kwargs ) : <TAB> show = self. get_argument ( ""show"" ) <TAB> show_name = None <TAB> show_obj = find_show ( int ( show ) ) <TAB> if show_obj : <TAB> <TAB> show_name = quote_plus ( show_obj. name. encode ( ) ) <TAB> if show_name : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> host = sickrage. app. config. kodi_host. split ( "","" ) [ 0 ]. strip ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> host = sickrage. app. config. kodi_host <TAB> <TAB> if sickrage. app. notifier_providers [ ""kodi"" ]. update_library ( showName = show_name ) : <TAB> <TAB> <TAB> sickrage. app. alerts. message ( <TAB> <TAB> <TAB> <TAB> _ ( ""Library update command sent to KODI host(s): "" ) + host <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> sickrage. app. alerts. error ( <TAB> <TAB> <TAB> <TAB> _ ( ""Unable to contact one or more KODI host(s): "" ) + host <TAB> <TAB> <TAB> ) <TAB> if show_obj : <TAB> <TAB> return self. redirect ( ""/home/displayShow?show="" + str ( show_obj. indexer_id ) ) <TAB> else : <TAB> <TAB> return self. redirect ( ""/home/"" )",False,sickrage.app.config.kodi_update_onlyfirst,is_kodi_host,0.6498985886573792
|
||
|
1911,"def pytest_runtest_setup ( item ) : <TAB> if is_potential_nosetest ( item ) : <TAB> <TAB> if isinstance ( item. parent, pytest. Generator ) : <TAB> <TAB> <TAB> gen = item. parent <TAB> <TAB> <TAB> if not hasattr ( gen, ""_nosegensetup"" ) : <TAB> <TAB> <TAB> <TAB> call_optional ( gen. obj, ""setup"" ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> call_optional ( gen. parent. obj, ""setup"" ) <TAB> <TAB> <TAB> <TAB> gen. _nosegensetup = True <TAB> <TAB> if not call_optional ( item. obj, ""setup"" ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> call_optional ( item. parent. obj, ""setup"" ) <TAB> <TAB> <TAB> <TAB> item. session. _setupstate. addfinalizer ( ( lambda : teardown_nose ( item ) ), item )",False,"isinstance(gen.parent, pytest.Instance)",gen._nosegensetup,0.647995114326477
|
||
|
1912,"def find_end_of_match ( <TAB> to_match : str, chars : str, first_index : int ) -> typing. Tuple [ typing. Optional [ float ], typing. Optional [ int ] ] : <TAB> score, last_index, last_type = 1.0, first_index, None <TAB> for char in chars : <TAB> <TAB> try : <TAB> <TAB> <TAB> index = to_match. index ( char, last_index + 1 ) <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> return None, None <TAB> <TAB> if not index : <TAB> <TAB> <TAB> return None, None <TAB> <TAB> <TAB> <TAB> if index == last_index + 1 : <TAB> <TAB> <TAB> if last_type!= ""sequential"" : <TAB> <TAB> <TAB> <TAB> last_type = ""sequential"" <TAB> <TAB> <TAB> <TAB> score += 1 <TAB> <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> if last_type!= ""boundary"" : <TAB> <TAB> <TAB> <TAB> last_type = ""boundary"" <TAB> <TAB> <TAB> <TAB> score += 1 <TAB> <TAB> <TAB> <TAB> elif ( <TAB> <TAB> <TAB> char in string. ascii_uppercase <TAB> <TAB> <TAB> and to_match [ index - 1 ] in string. ascii_lowercase <TAB> <TAB> ) : <TAB> <TAB> <TAB> if last_type!= ""camelcase"" : <TAB> <TAB> <TAB> <TAB> last_type = ""camelcase"" <TAB> <TAB> <TAB> <TAB> score += 1 <TAB> <TAB> else : <TAB> <TAB> <TAB> last_type = ""normal"" <TAB> <TAB> <TAB> score += index - last_index <TAB> <TAB> last_index = index <TAB> return ( score, last_index )",False,to_match[index - 1] in BOUNDARY_CHARS,first_index == 0,0.654887318611145
|
||
|
1913,"def _get_torch_exploration_action ( <TAB> self, <TAB> action_dist : ActionDistribution, <TAB> timestep : Union [ TensorType, int ], <TAB> explore : Union [ TensorType, bool ], ) : <TAB> <TAB> self. last_timestep = timestep if timestep is not None else self. last_timestep + 1 <TAB> <TAB> if explore : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> action, logp = self. random_exploration. get_torch_exploration_action ( <TAB> <TAB> <TAB> <TAB> action_dist, explore = True <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> action = action_dist. sample ( ) <TAB> <TAB> <TAB> logp = action_dist. sampled_action_logp ( ) <TAB> <TAB> else : <TAB> <TAB> action = action_dist. deterministic_sample ( ) <TAB> <TAB> logp = torch. zeros_like ( action_dist. sampled_action_logp ( ) ) <TAB> return action, logp",False,self.last_timestep < self.random_timesteps,self.random_exploration is not None,0.6579583287239075
|
||
|
1914,"def _on_change ( self ) : <TAB> changed = False <TAB> self. save ( ) <TAB> for key, value in self. data. items ( ) : <TAB> <TAB> if isinstance ( value, bool ) : <TAB> <TAB> <TAB> if value : <TAB> <TAB> <TAB> <TAB> changed = True <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> if isinstance ( value, int ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> changed = True <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> elif value is None : <TAB> <TAB> <TAB> continue <TAB> <TAB> elif len ( value )!= 0 : <TAB> <TAB> <TAB> changed = True <TAB> <TAB> <TAB> break <TAB> self. _reset_button. disabled = not changed",False,value != 1,len(value) == 0,0.6750129461288452
|
||
|
1915,"def gen_partitions_from_args ( partition_set, kwargs ) : <TAB> partition_selector_args = [ <TAB> <TAB> bool ( kwargs. get ( ""all"" ) ), <TAB> <TAB> bool ( kwargs. get ( ""partitions"" ) ), <TAB> <TAB> ( bool ( kwargs. get ( ""from"" ) ) or bool ( kwargs. get ( ""to"" ) ) ), <TAB> ] <TAB> if sum ( partition_selector_args ) > 1 : <TAB> <TAB> raise click. UsageError ( <TAB> <TAB> <TAB> ""error, cannot use more than one of: `--all`, `--partitions`, `--from/--to`"" <TAB> <TAB> ) <TAB> partitions = partition_set. get_partitions ( ) <TAB> if kwargs. get ( ""all"" ) : <TAB> <TAB> return partitions <TAB> if kwargs. get ( ""partitions"" ) : <TAB> <TAB> selected_args = [ <TAB> <TAB> <TAB> s. strip ( ) for s in kwargs. get ( ""partitions"" ). split ( "","" ) if s. strip ( ) <TAB> <TAB> ] <TAB> <TAB> selected_partitions = [ <TAB> <TAB> <TAB> partition for partition in partitions if partition. name in selected_args <TAB> <TAB> ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> selected_names = [ partition. name for partition in selected_partitions ] <TAB> <TAB> <TAB> unknown = [ <TAB> <TAB> <TAB> <TAB> selected for selected in selected_args if selected not in selected_names <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> raise click. UsageError ( ""Unknown partitions: {}"". format ( unknown. join ( "", "" ) ) ) <TAB> <TAB> return selected_partitions <TAB> start = validate_partition_slice ( partitions, ""from"", kwargs. get ( ""from"" ) ) <TAB> end = validate_partition_slice ( partitions, ""to"", kwargs. get ( ""to"" ) ) <TAB> return partitions [ start : end ]",False,len(selected_partitions) < len(selected_args),selected_partitions,0.6476808786392212
|
||
|
1916,"def read ( self ) : <TAB> """"""Reads the robots.txt URL and feeds it to the parser."""""" <TAB> try : <TAB> <TAB> f = urllib. request. urlopen ( self. url ) <TAB> except urllib. error. HTTPError as err : <TAB> <TAB> if err. code in ( 401, 403 ) : <TAB> <TAB> <TAB> self. disallow_all = True <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> self. allow_all = True <TAB> else : <TAB> <TAB> raw = f. read ( ) <TAB> <TAB> self. parse ( raw. decode ( ""utf-8"" ). splitlines ( ) )",False,err.code >= 400 and err.code < 500,"err.code in (502, 404)",0.6559237241744995
|
||
|
1917,"def vi_pos_back_short ( line, index = 0, count = 1 ) : <TAB> line = vi_list ( line ) <TAB> try : <TAB> <TAB> for i in range ( count ) : <TAB> <TAB> <TAB> index -= 1 <TAB> <TAB> <TAB> while vi_is_space ( line [ index ] ) : <TAB> <TAB> <TAB> <TAB> index -= 1 <TAB> <TAB> <TAB> in_word = vi_is_word ( line [ index ] ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> while vi_is_word ( line [ index ] ) : <TAB> <TAB> <TAB> <TAB> <TAB> index -= 1 <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> while not vi_is_word_or_space ( line [ index ] ) : <TAB> <TAB> <TAB> <TAB> <TAB> index -= 1 <TAB> <TAB> return index + 1 <TAB> except IndexError : <TAB> <TAB> return 0",True,in_word,in_word,0.6719998717308044
|
||
|
1918,"def _get_headers ( self, headers = None ) : <TAB> request_headers = headers or { } <TAB> <TAB> if self. _client. client. config : <TAB> <TAB> config = self. _client. client. config <TAB> <TAB> if ""Authorization"" not in request_headers and config. token : <TAB> <TAB> <TAB> request_headers. update ( <TAB> <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> <TAB> ""Authorization"" : ""{} {}"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> config. authentication_type, config. token <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> } <TAB> <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> request_headers. update ( { config. header : config. header_service } ) <TAB> return request_headers",True,config.header and config.header_service,config.header and config.header_service,0.6502023339271545
|
||
|
1919,"def result ( <TAB> metrics : Dict [ metric_types. MetricKey, Any ] ) -> Dict [ metric_types. AttributionsKey, Dict [ Text, Union [ float, np. ndarray ] ] ] : <TAB> """"""Returns mean attributions."""""" <TAB> total_attributions = metrics [ total_attributions_key ] <TAB> weighted_count = metrics [ weighted_example_count_key ] <TAB> attributions = { } <TAB> for k, v in total_attributions. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> attributions [ k ] = float ( ""nan"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> attributions [ k ] = v / weighted_count <TAB> return { key : attributions }",False,"np.isclose(weighted_count, 0.0)",weighted_count == 0,0.6566169857978821
|
||
|
1920,"def listing_items ( method ) : <TAB> marker = None <TAB> once = True <TAB> items = [ ] <TAB> while once or items : <TAB> <TAB> for i in items : <TAB> <TAB> <TAB> yield i <TAB> <TAB> if once or marker : <TAB> <TAB> <TAB> if marker : <TAB> <TAB> <TAB> <TAB> items = method ( parms = { ""marker"" : marker } ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> items = method ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> marker = items [ - 1 ] <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> marker = None <TAB> <TAB> <TAB> once = False <TAB> <TAB> else : <TAB> <TAB> <TAB> items = [ ]",False,len(items) == 10000,items and items > 1,0.6743246912956238
|
||
|
1921,"def byte_WITH_CLEANUP ( self ) : <TAB> <TAB> <TAB> <TAB> v = w = None <TAB> u = self. top ( ) <TAB> if u is None : <TAB> <TAB> exit_func = self. pop ( 1 ) <TAB> elif isinstance ( u, str ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> exit_func = self. pop ( 2 ) <TAB> <TAB> else : <TAB> <TAB> <TAB> exit_func = self. pop ( 1 ) <TAB> <TAB> u = None <TAB> elif issubclass ( u, BaseException ) : <TAB> <TAB> w, v, u = self. popn ( 3 ) <TAB> <TAB> exit_func = self. pop ( ) <TAB> <TAB> self. push ( w, v, u ) <TAB> else : <TAB> <TAB> raise VirtualMachineError ( ""Confused WITH_CLEANUP"" ) <TAB> exit_ret = exit_func ( u, v, w ) <TAB> err = ( u is not None ) and bool ( exit_ret ) <TAB> if err : <TAB> <TAB> <TAB> <TAB> self. popn ( 3 ) <TAB> <TAB> self. push ( None )",False,"u in ('return', 'continue')",u == None,0.6562206149101257
|
||
|
1922,"def remove ( self, name ) : <TAB> for s in [ self. __storage ( self. __category ), self. __storage ( None ) ] : <TAB> <TAB> for i, b in enumerate ( s ) : <TAB> <TAB> <TAB> if b. name == name : <TAB> <TAB> <TAB> <TAB> del s [ i ] <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> self. __save ( ) <TAB> <TAB> <TAB> <TAB> return <TAB> raise KeyError ( name )",False,b.persistent,self.__save(),0.6736152172088623
|
||
|
1923,"def _get_blade_interfaces ( <TAB> self, chassis_number, blade_number, ucsm_ip, ucsm_username, ucsm_password ) : <TAB> """"""Create command"""""" <TAB> data = self. _get_blade_interfaces_post_data ( chassis_number, blade_number ) <TAB> response = self. _post_data ( ucsm_ip, ucsm_username, ucsm_password, data ) <TAB> elements = et. XML ( response ). find ( ""outConfigs"" ). findall ( ""adaptorHostEthIf"" ) <TAB> blade_interfaces = { } <TAB> for element in elements : <TAB> <TAB> dist_name = element. get ( ""dn"", default = None ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> order = element. get ( ""order"", default = None ) <TAB> <TAB> <TAB> blade_interface = { <TAB> <TAB> <TAB> <TAB> const. BLADE_INTF_DN : dist_name, <TAB> <TAB> <TAB> <TAB> const. BLADE_INTF_ORDER : order, <TAB> <TAB> <TAB> <TAB> const. BLADE_INTF_LINK_STATE : None, <TAB> <TAB> <TAB> <TAB> const. BLADE_INTF_OPER_STATE : None, <TAB> <TAB> <TAB> <TAB> const. BLADE_INTF_INST_TYPE : None, <TAB> <TAB> <TAB> <TAB> const. BLADE_INTF_RHEL_DEVICE_NAME : self. _get_rhel_device_name ( order ), <TAB> <TAB> <TAB> } <TAB> <TAB> <TAB> blade_interfaces [ dist_name ] = blade_interface <TAB> return blade_interfaces",True,dist_name,dist_name,0.6642109751701355
|
||
|
1924,"def add_ntds_hash ( ntds_hash, host_id ) : <TAB> add_ntds_hash. ntds_hashes += 1 <TAB> self. logger. highlight ( ntds_hash ) <TAB> if ntds_hash. find ( ""$"" ) == - 1 : <TAB> <TAB> if ntds_hash. find ( ""\\"" )!= - 1 : <TAB> <TAB> <TAB> domain, hash = ntds_hash. split ( ""\\"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> domain = self. domain <TAB> <TAB> <TAB> hash = ntds_hash <TAB> <TAB> try : <TAB> <TAB> <TAB> username, _, lmhash, nthash, _, _, _ = hash. split ( "":"" ) <TAB> <TAB> <TAB> parsed_hash = "":"". join ( ( lmhash, nthash ) ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. db. add_credential ( <TAB> <TAB> <TAB> <TAB> <TAB> ""hash"", domain, username, parsed_hash, pillaged_from = host_id <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> add_ntds_hash. added_to_db += 1 <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> raise <TAB> <TAB> except : <TAB> <TAB> <TAB> logging. debug ( ""Dumped hash is not NTLM, not adding to db for now ;)"" ) <TAB> else : <TAB> <TAB> logging. debug ( ""Dumped hash is a computer account, not adding to db"" )",False,validate_ntlm(parsed_hash),ntds_hash.find(parsed_hash) != -1,0.6490787267684937
|
||
|
1925,"def feed ( self, byte_str, num_bytes ) : <TAB> if self. _done : <TAB> <TAB> return <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> i = self. _need_to_skip_char_num <TAB> while i < num_bytes : <TAB> <TAB> order, char_len = self. get_order ( byte_str [ i : i + 2 ] ) <TAB> <TAB> i += char_len <TAB> <TAB> if i > num_bytes : <TAB> <TAB> <TAB> self. _need_to_skip_char_num = i - num_bytes <TAB> <TAB> <TAB> self. _last_char_order = - 1 <TAB> <TAB> else : <TAB> <TAB> <TAB> if ( order!= - 1 ) and ( self. _last_char_order!= - 1 ) : <TAB> <TAB> <TAB> <TAB> self. _total_rel += 1 <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> self. _done = True <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> self. _rel_sample [ jp2CharContext [ self. _last_char_order ] [ order ] ] += 1 <TAB> <TAB> <TAB> self. _last_char_order = order",False,self._total_rel > self.MAX_REL_THRESHOLD,order >= self._total_rel,0.6545836329460144
|
||
|
1926,"def _repr_info ( self ) : <TAB> info = [ self. _state. lower ( ) ] <TAB> if self. _state == _FINISHED : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> info. append ( ""exception={!r}"". format ( self. _exception ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> result = reprlib. repr ( self. _result ) <TAB> <TAB> <TAB> info. append ( ""result={}"". format ( result ) ) <TAB> if self. _callbacks : <TAB> <TAB> info. append ( self. _format_callbacks ( ) ) <TAB> if self. _source_traceback : <TAB> <TAB> frame = self. _source_traceback [ - 1 ] <TAB> <TAB> info. append ( ""created at %s:%s"" % ( frame [ 0 ], frame [ 1 ] ) ) <TAB> return info",False,self._exception is not None,self._exception,0.6636278033256531
|
||
|
1927,"def get ( self, k ) : <TAB> with self. _lock : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _data1 [ k ] = self. _data2 [ k ] <TAB> <TAB> <TAB> del self. _data2 [ k ] <TAB> return self. _data1. get ( k )",False,k not in self._data1 and k in self._data2,k in self._data1 and k in self._data2,0.6591451168060303
|
||
|
1928,"def string_record_contents ( self, data ) : <TAB> bv = self. biff_version <TAB> bk = self. book <TAB> lenlen = ( bv >= 30 ) + 1 <TAB> nchars_expected = unpack ( ""<"" + ""BH"" [ lenlen - 1 ], data [ : lenlen ] ) [ 0 ] <TAB> offset = lenlen <TAB> if bv < 80 : <TAB> <TAB> enc = bk. encoding or bk. derive_encoding ( ) <TAB> nchars_found = 0 <TAB> result = UNICODE_LITERAL ( """" ) <TAB> while 1 : <TAB> <TAB> if bv >= 80 : <TAB> <TAB> <TAB> flag = BYTES_ORD ( data [ offset ] ) & 1 <TAB> <TAB> <TAB> enc = ( ""latin_1"", ""utf_16_le"" ) [ flag ] <TAB> <TAB> <TAB> offset += 1 <TAB> <TAB> chunk = unicode ( data [ offset : ], enc ) <TAB> <TAB> result += chunk <TAB> <TAB> nchars_found += len ( chunk ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return result <TAB> <TAB> if nchars_found > nchars_expected : <TAB> <TAB> <TAB> msg = ""STRING/CONTINUE: expected %d chars, found %d"" % ( <TAB> <TAB> <TAB> <TAB> nchars_expected, <TAB> <TAB> <TAB> <TAB> nchars_found, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> raise XLRDError ( msg ) <TAB> <TAB> rc, _unused_len, data = bk. get_record_parts ( ) <TAB> <TAB> if rc!= XL_CONTINUE : <TAB> <TAB> <TAB> raise XLRDError ( ""Expected CONTINUE record; found record-type 0x%04X"" % rc ) <TAB> <TAB> offset = 0",False,nchars_found == nchars_expected,nchars_found == len(data),0.6623801589012146
|
||
|
1929,"def _load_dataset_area ( self, dsid, file_handlers, coords ) : <TAB> """"""Get the area for *dsid*."""""" <TAB> try : <TAB> <TAB> return self. _load_area_def ( dsid, file_handlers ) <TAB> except NotImplementedError : <TAB> <TAB> if any ( x is None for x in coords ) : <TAB> <TAB> <TAB> logger. warning ( ""Failed to load coordinates for '{}'"". format ( dsid ) ) <TAB> <TAB> <TAB> return None <TAB> <TAB> area = self. _make_area_from_coords ( coords ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> logger. debug ( ""No coordinates found for %s"", str ( dsid ) ) <TAB> <TAB> return area",True,area is None,area is None,0.6651685833930969
|
||
|
1930,"def __reduce__ ( self ) : <TAB> mod = self. __fn. __module__ <TAB> name = self. __fn. __name__ <TAB> try : <TAB> <TAB> obj = load_back ( mod, name ) <TAB> except ( ImportError, KeyError, AttributeError ) : <TAB> <TAB> raise pickle. PicklingError ( <TAB> <TAB> <TAB> ""Can't pickle as_op(), not found as %s.%s"" % ( mod, name ) <TAB> <TAB> ) <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise pickle. PicklingError ( <TAB> <TAB> <TAB> <TAB> ""Can't pickle as_op(), not the object "" ""at %s.%s"" % ( mod, name ) <TAB> <TAB> <TAB> ) <TAB> return load_back, ( mod, name )",False,obj is not self,obj is None,0.6646921038627625
|
||
|
1931,"def _unquote_to_bytes ( string, unsafe = """" ) : <TAB> if isinstance ( string, text_type ) : <TAB> <TAB> string = string. encode ( ""utf-8"" ) <TAB> if isinstance ( unsafe, text_type ) : <TAB> <TAB> unsafe = unsafe. encode ( ""utf-8"" ) <TAB> unsafe = frozenset ( bytearray ( unsafe ) ) <TAB> groups = iter ( string. split ( b""%"" ) ) <TAB> result = bytearray ( next ( groups, b"""" ) ) <TAB> try : <TAB> <TAB> hex_to_byte = _unquote_maps [ unsafe ] <TAB> except KeyError : <TAB> <TAB> hex_to_byte = _unquote_maps [ unsafe ] = { <TAB> <TAB> <TAB> h : b for h, b in _hextobyte. items ( ) if b not in unsafe <TAB> <TAB> } <TAB> for group in groups : <TAB> <TAB> code = group [ : 2 ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> result. append ( hex_to_byte [ code ] ) <TAB> <TAB> <TAB> result. extend ( group [ 2 : ] ) <TAB> <TAB> else : <TAB> <TAB> <TAB> result. append ( 37 ) <TAB> <TAB> <TAB> result. extend ( group ) <TAB> return bytes ( result )",True,code in hex_to_byte,code in hex_to_byte,0.6571916341781616
|
||
|
1932,"def establish_connection ( self, p ) : <TAB> params = self. get_params ( p. h ) <TAB> host = params [ ""hostname"" ] <TAB> port = params [ ""port"" ] <TAB> user = params [ ""username"" ] <TAB> <TAB> passwd = self. get_password ( user, host ) <TAB> if passwd is None : <TAB> <TAB> return ( None, None ) <TAB> t = paramiko. Transport ( ( host, port ) ) <TAB> t. connect ( username = user, password = passwd ) <TAB> hostkey = t. get_remote_server_key ( ) <TAB> cached_hostkey = self. get_hostkey ( host ) <TAB> if cached_hostkey is None : <TAB> <TAB> store = self. confirm_hostkey ( <TAB> <TAB> <TAB> ""Unknown host: %s"" % host, <TAB> <TAB> <TAB> ""Add the server key for host '%s' to the trusted host list?"" % host, <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. set_hostkey ( host, hostkey ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return ( None, None ) <TAB> elif cached_hostkey!= hostkey : <TAB> <TAB> store = self. confirm_hostkey ( <TAB> <TAB> <TAB> ""Hostkey does not match!"", <TAB> <TAB> <TAB> ""The remote host '%s' provided a key that does not match the stored key. "" <TAB> <TAB> <TAB> + "" This could indicate a man-in-the-middle attack. Continue anyway?"" <TAB> <TAB> <TAB> % host, <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. set_hostkey ( host, hostkey ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return ( None, None ) <TAB> sftp = paramiko. SFTPClient. from_transport ( t ) <TAB> return ( t, sftp )",False,store,hostkey,0.6729249954223633
|
||
|
1933,"def _main_actor ( cls, env_name, env_email, config_reader = None ) : <TAB> actor = Actor ( """", """" ) <TAB> default_email = get_user_id ( ) <TAB> default_name = default_email. split ( ""@"" ) [ 0 ] <TAB> for attr, evar, cvar, default in ( <TAB> <TAB> ( ""name"", env_name, cls. conf_name, default_name ), <TAB> <TAB> ( ""email"", env_email, cls. conf_email, default_email ), <TAB> ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> val = os. environ [ evar ] <TAB> <TAB> <TAB> setattr ( actor, attr, val ) <TAB> <TAB> except KeyError : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> setattr ( actor, attr, config_reader. get_value ( ""user"", cvar, default ) ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if not getattr ( actor, attr ) : <TAB> <TAB> <TAB> <TAB> setattr ( actor, attr, default ) <TAB> <TAB> <TAB> <TAB> return actor",False,config_reader is not None,config_reader,0.6565282344818115
|
||
|
1934,"def _iter_excel_instances ( self ) : <TAB> asn = subprocess. check_output ( <TAB> <TAB> [ ""lsappinfo"", ""visibleprocesslist"", ""-includehidden"" ] <TAB> ). decode ( ""utf-8"" ) <TAB> for asn in asn. split ( "" "" ) : <TAB> <TAB> if ""Microsoft_Excel"" in asn : <TAB> <TAB> <TAB> pid_info = subprocess. check_output ( <TAB> <TAB> <TAB> <TAB> [ ""lsappinfo"", ""info"", ""-only"", ""pid"", asn ] <TAB> <TAB> <TAB> ). decode ( ""utf-8"" ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> yield int ( pid_info. split ( ""="" ) [ 1 ] )",False,"pid_info != '""pid""=[ NULL ] \n'",'Microsoft_Excel' in pid_info,0.6530991196632385
|
||
|
1935,"def _sendExceptionResponse ( <TAB> self, connection, seq, serializer_id, exc_value, tbinfo, flags = 0, annotations = None ) : <TAB> """"""send an exception back including the local traceback info"""""" <TAB> exc_value. _pyroTraceback = tbinfo <TAB> if<mask> : <TAB> <TAB> util. fixIronPythonExceptionForPickle ( exc_value, True ) <TAB> serializer = util. get_serializer_by_id ( serializer_id ) <TAB> try : <TAB> <TAB> data, compressed = serializer. serializeData ( exc_value ) <TAB> except : <TAB> <TAB> <TAB> <TAB> xt, xv, tb = sys. exc_info ( ) <TAB> <TAB> msg = ""Error serializing exception: %s. Original exception: %s: %s"" % ( <TAB> <TAB> <TAB> str ( xv ), <TAB> <TAB> <TAB> type ( exc_value ), <TAB> <TAB> <TAB> str ( exc_value ), <TAB> <TAB> ) <TAB> <TAB> exc_value = errors. PyroError ( msg ) <TAB> <TAB> exc_value. _pyroTraceback = tbinfo <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> util. fixIronPythonExceptionForPickle ( <TAB> <TAB> <TAB> <TAB> exc_value, True <TAB> <TAB> <TAB> ) <TAB> <TAB> data, compressed = serializer. serializeData ( exc_value ) <TAB> flags |= message. FLAGS_EXCEPTION <TAB> if compressed : <TAB> <TAB> flags |= message. FLAGS_COMPRESSED <TAB> annotations = dict ( annotations or { } ) <TAB> annotations. update ( self. annotations ( ) ) <TAB> msg = message. Message ( <TAB> <TAB> message. MSG_RESULT, <TAB> <TAB> data, <TAB> <TAB> serializer. serializer_id, <TAB> <TAB> flags, <TAB> <TAB> seq, <TAB> <TAB> annotations = annotations, <TAB> <TAB> hmac_key = self. _pyroHmacKey, <TAB> ) <TAB> if config.",False,sys.platform == 'cli',exc_value._pyroTraceback,0.6609688997268677
|
||
|
1936,"def step ( self, action ) : <TAB> self. env. step ( action [ self. env. agent_selection ] ) <TAB> obs_d = { } <TAB> rew_d = { } <TAB> done_d = { } <TAB> info_d = { } <TAB> while self. env. agents : <TAB> <TAB> obs, rew, done, info = self. env. last ( ) <TAB> <TAB> a = self. env. agent_selection <TAB> <TAB> obs_d [ a ] = obs <TAB> <TAB> rew_d [ a ] = rew <TAB> <TAB> done_d [ a ] = done <TAB> <TAB> info_d [ a ] = info <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. env. step ( None ) <TAB> <TAB> else : <TAB> <TAB> <TAB> break <TAB> all_done = not self. env. agents <TAB> done_d [ ""__all__"" ] = all_done <TAB> return obs_d, rew_d, done_d, info_d",False,self.env.dones[self.env.agent_selection],self.env.agents == 0,0.6482844948768616
|
||
|
1937,"def __init__ ( <TAB> self, buffer, encoding = None, errors = None, newline = None, line_buffering = False ) : <TAB> if newline not in ( None, """", ""\n"", ""\r"", ""\r\n"" ) : <TAB> <TAB> raise ValueError ( ""illegal newline value: %r"" % ( newline, ) ) <TAB> if encoding is None : <TAB> <TAB> try : <TAB> <TAB> <TAB> encoding = os. device_encoding ( buffer. fileno ( ) ) <TAB> <TAB> except ( AttributeError, UnsupportedOperation ) : <TAB> <TAB> <TAB> pass <TAB> <TAB> if encoding is None : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> import locale <TAB> <TAB> <TAB> except ImportError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> encoding = ""ascii"" <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> encoding = locale. getpreferredencoding ( ) <TAB> if not isinstance ( encoding, basestring ) : <TAB> <TAB> raise ValueError ( ""invalid encoding: %r"" % encoding ) <TAB> if errors is None : <TAB> <TAB> errors = ""strict"" <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( ""invalid errors: %r"" % errors ) <TAB> self. buffer = buffer <TAB> self. _line_buffering = line_buffering <TAB> self. _encoding = encoding <TAB> self. _errors = errors <TAB> self. _readuniversal = not newline <TAB> self. _readtranslate = newline is None <TAB> self. _readnl = newline <TAB> self. _writetranslate = newline!= """" <TAB> self. _writenl = newline or os. linesep <TAB> self. _encoder = None <TAB> self. _decoder = None <TAB> self. _decoded_chars = """" <TAB> self. _decoded_chars_used = 0 <TAB> self. _snapshot = None <TAB> self. _seekable = self. _telling",False,"not isinstance(errors, basestring)",not line_buffering,0.6512417197227478
|
||
|
1938,"def app ( scope, receive, send ) : <TAB> while True : <TAB> <TAB> message = await receive ( ) <TAB> <TAB> if message [ ""type"" ] == ""websocket.connect"" : <TAB> <TAB> <TAB> await send ( { ""type"" : ""websocket.accept"" } ) <TAB> <TAB> elif message [ ""type"" ] == ""websocket.receive"" : <TAB> <TAB> <TAB> pass <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> break",False,message['type'] == 'websocket.disconnect',message['type'] == 'websocket.error',0.6558740139007568
|
||
|
1939,"def verify_model_vm ( <TAB> input_model, ishapes, idtype = torch. float, idata = None, targets = [ ""llvm"" ] ) : <TAB> input_names = [ ""i{}"". format ( idx ) for idx, ish in enumerate ( ishapes ) ] <TAB> input_shapes = list ( zip ( input_names, ishapes ) ) <TAB> input_data = ( <TAB> <TAB> idata if idata else [ torch. randn ( shape, dtype = idtype ) for shape in ishapes ] <TAB> ) <TAB> <TAB> mod, params = relay. frontend. from_pytorch ( input_model, input_shapes ) <TAB> for tgt in targets : <TAB> <TAB> print ( ""Running on target"", tgt ) <TAB> <TAB> ctx = tvm. context ( tgt, 0 ) <TAB> <TAB> executor = relay. create_executor ( ""vm"", mod = mod, ctx = ctx, target = tgt ) <TAB> <TAB> evaluator = executor. evaluate ( ) <TAB> <TAB> <TAB> <TAB> for name, inp in zip ( input_names, input_data ) : <TAB> <TAB> <TAB> params [ name ] = inp. numpy ( ) <TAB> <TAB> vm_res = evaluator ( ** params ) <TAB> <TAB> <TAB> <TAB> with torch. no_grad ( ) : <TAB> <TAB> <TAB> pt_result = input_model ( * input_data ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> tvm_res = vm_res. asnumpy ( ). item ( ) <TAB> <TAB> <TAB> assert pt_result == tvm_res <TAB> <TAB> else : <TAB> <TAB> <TAB> tvm. testing. assert_allclose ( <TAB> <TAB> <TAB> <TAB> vm_res. asnumpy ( ), pt_result. numpy ( ), rtol = 1e-5, atol = 1e-5 <TAB> <TAB> <TAB> )",False,"not isinstance(pt_result, torch.Tensor)",vm_res.has_numpy(),0.6462855339050293
|
||
|
1940,"def __open__ ( filename, * args, ** kwargs ) : <TAB> if os. path. isfile ( filename ) : <TAB> <TAB> return __realopen__ ( filename, * args, ** kwargs ) <TAB> if not os. path. isabs ( filename ) : <TAB> <TAB> datafilename = __papplet__. dataPath ( filename ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return __realopen__ ( datafilename, * args, ** kwargs ) <TAB> <TAB> sketchfilename = __papplet__. sketchPath ( filename ) <TAB> if os. path. isfile ( sketchfilename ) : <TAB> <TAB> return __realopen__ ( sketchfilename, * args, ** kwargs ) <TAB> <TAB> return __realopen__ ( filename, * args, ** kwargs )",True,os.path.isfile(datafilename),os.path.isfile(datafilename),0.6473559141159058
|
||
|
1941,"def sql_select ( explain = False ) : <TAB> statement, params = load_query ( request. args [ ""query"" ] ) <TAB> engine = SQLAlchemy ( ). get_engine ( current_app ) <TAB> if explain : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> statement = ""EXPLAIN QUERY PLAN\n%s"" % statement <TAB> <TAB> else : <TAB> <TAB> <TAB> statement = ""EXPLAIN\n%s"" % statement <TAB> result = engine. execute ( statement, params ) <TAB> return g. debug_toolbar. render ( <TAB> <TAB> ""panels/sqlalchemy_select.html"", <TAB> <TAB> { <TAB> <TAB> <TAB> ""result"" : result. fetchall ( ), <TAB> <TAB> <TAB> ""headers"" : result. keys ( ), <TAB> <TAB> <TAB> ""sql"" : format_sql ( statement, params ), <TAB> <TAB> <TAB> ""duration"" : float ( request. args [ ""duration"" ] ), <TAB> <TAB> }, <TAB> )",False,engine.driver == 'pysqlite',engine.name == 'sql',0.6601969003677368
|
||
|
1942,"def populate_dest_combo ( self ) : <TAB> combo = self. widget ( ""migrate-dest"" ) <TAB> model = combo. get_model ( ) <TAB> idx = combo. get_active ( ) <TAB> idxconn = None <TAB> if idx!= - 1 : <TAB> <TAB> idxconn = model [ idx ] [ 1 ] <TAB> rows = [ [ _ ( ""No connections available."" ), None, False, None ] ] <TAB> if self. destconn_rows : <TAB> <TAB> rows = self. destconn_rows <TAB> model. clear ( ) <TAB> for r in rows : <TAB> <TAB> <TAB> <TAB> if r [ 1 ] == self. conn : <TAB> <TAB> <TAB> continue <TAB> <TAB> model. append ( r ) <TAB> <TAB> idx = - 1 <TAB> for i in range ( len ( model ) ) : <TAB> <TAB> row = model [ i ] <TAB> <TAB> conn = row [ 1 ] <TAB> <TAB> if idxconn : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> idx = i <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> else : <TAB> <TAB> <TAB> if row [ 2 ] : <TAB> <TAB> <TAB> <TAB> idx = i <TAB> <TAB> <TAB> <TAB> break <TAB> combo. set_active ( idx )",False,conn == idxconn and row[2],row[2],0.6590996980667114
|
||
|
1943,"def _make_entry ( filename, rpath = None, relative = None, shell = None, suffix = """", advanced = 0 ) : <TAB> pkg = os. path. basename ( filename ) == ""__init__.py"" <TAB> entry_code = entry_lines [ 0 ] % ( <TAB> <TAB> ""."" if ( relative is True ) or ( ( relative is None ) and pkg ) else """", <TAB> <TAB> suffix, <TAB> ) <TAB> with open ( filename, ""r"" ) as f : <TAB> <TAB> lines = f. readlines ( ) <TAB> <TAB> n = 0 <TAB> for n in range ( len ( lines ) ) : <TAB> <TAB> if lines [ n ]. strip ( ) == """" or lines [ n ]. find ( ""__future__"" ) > 0 : <TAB> <TAB> <TAB> continue <TAB> <TAB> if not lines [ n ] [ 0 ] == ""#"" : <TAB> <TAB> <TAB> break <TAB> for line in lines [ n : ] : <TAB> <TAB> if line. strip ( ) == entry_code. strip ( ) : <TAB> <TAB> <TAB> return <TAB> with open ( filename, ""w"" ) as f : <TAB> <TAB> f. write ( """". join ( lines [ : n ] ) ) <TAB> <TAB> if shell : <TAB> <TAB> <TAB> f. write ( shell ) <TAB> <TAB> f. write ( entry_code ) <TAB> <TAB> paras = [ ] <TAB> <TAB> if rpath is not None : <TAB> <TAB> <TAB> paras. append ( repr ( rpath ) ) <TAB> <TAB> if suffix : <TAB> <TAB> <TAB> paras. append ( ""suffix=%s"" % repr ( suffix ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> paras. append ( ""advanced=1"" ) <TAB> <TAB> f. write ( entry_lines [ 1 ] % "", "". join ( paras ) ) <TAB> <TAB> f. write ( """". join ( lines [ n : ] ) )",False,advanced,advanced > 0,0.7367694973945618
|
||
|
1944,"def _load_from_pytorch ( self, filename, ctx = None ) : <TAB> import torch <TAB> from mxnet import nd <TAB> loaded = torch. load ( filename ) <TAB> params = self. _collect_params_with_prefix ( ) <TAB> new_params = { } <TAB> for name in loaded : <TAB> <TAB> if ""bn"" in name or ""batchnorm"" in name or "".downsample.1."" in name : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> mxnet_name = name. replace ( ""weight"", ""gamma"" ) <TAB> <TAB> <TAB> elif ""bias"" in name : <TAB> <TAB> <TAB> <TAB> mxnet_name = name. replace ( ""bias"", ""beta"" ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> mxnet_name = name <TAB> <TAB> <TAB> new_params [ mxnet_name ] = nd. array ( loaded [ name ]. cpu ( ). data. numpy ( ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> new_params [ name ] = nd. array ( loaded [ name ]. cpu ( ). data. numpy ( ) ) <TAB> for name in new_params : <TAB> <TAB> if name not in params : <TAB> <TAB> <TAB> print ( ""==={}==="". format ( name ) ) <TAB> <TAB> <TAB> raise Exception <TAB> <TAB> if name in params : <TAB> <TAB> <TAB> params [ name ]. _load_init ( new_params [ name ], ctx = ctx )",True,'weight' in name,'weight' in name,0.6620233058929443
|
||
|
1945,"def evaluate_update_notification ( session, state, latest_version ) : <TAB> priv_fact = ConfigFactory ( session, 1 ) <TAB> stored_latest = priv_fact. get_val ( ""latest_version"" ) <TAB> if parse_version ( stored_latest ) < parse_version ( latest_version ) : <TAB> <TAB> Cache. invalidate ( ) <TAB> <TAB> priv_fact. set_val ( ""latest_version"", latest_version ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return <TAB> <TAB> for user_desc in db_get_users ( session, 1, ""admin"" ) : <TAB> <TAB> <TAB> lang = user_desc [ ""language"" ] <TAB> <TAB> <TAB> template_vars = { <TAB> <TAB> <TAB> <TAB> ""type"" : ""software_update_available"", <TAB> <TAB> <TAB> <TAB> ""latest_version"" : latest_version, <TAB> <TAB> <TAB> <TAB> ""node"" : db_admin_serialize_node ( session, 1, lang ), <TAB> <TAB> <TAB> <TAB> ""notification"" : db_get_notification ( session, 1, lang ), <TAB> <TAB> <TAB> <TAB> ""user"" : user_desc, <TAB> <TAB> <TAB> } <TAB> <TAB> <TAB> state. format_and_send_mail ( session, 1, user_desc, template_vars )",False,parse_version(__version__) != parse_version(stored_latest),latest_version == latest_version,0.6465925574302673
|
||
|
1946,"def create_author_dict ( source ) : <TAB> <TAB> authors = [ ] <TAB> with open ( source, ""rt"", encoding = ""utf-8-sig"" ) as csv_file : <TAB> <TAB> csv_reader = csv. reader ( csv_file, delimiter = "","" ) <TAB> <TAB> header_row = next ( csv_reader ) <TAB> <TAB> normalized_header_row = [ col_header. strip ( ) for col_header in header_row ] <TAB> <TAB> logger. info ( ""Debug data"" ) <TAB> <TAB> logger. info ( ""Header row: {}"". format ( header_row ) ) <TAB> <TAB> logger. info ( ""Normalized header row: {}"". format ( normalized_header_row ) ) <TAB> <TAB> name_index = normalized_header_row. index ( ""Name"" ) <TAB> <TAB> email_index = normalized_header_row. index ( ""Email"" ) <TAB> <TAB> for line in csv_reader : <TAB> <TAB> <TAB> row = [ cell for cell in line ] <TAB> <TAB> <TAB> logger. info ( ""Adding user: "" + row [ name_index ] ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> author_dict = { <TAB> <TAB> <TAB> <TAB> <TAB> ""name"" : row [ name_index ]. strip ( ), <TAB> <TAB> <TAB> <TAB> <TAB> ""email"" : row [ email_index ], <TAB> <TAB> <TAB> <TAB> } <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> author_dict = { ""name"" : row [ name_index ]. strip ( ) } <TAB> <TAB> <TAB> authors. append ( author_dict ) <TAB> return authors",False,row[email_index] != '',email_index > 0,0.6603578329086304
|
||
|
1947,"def AddIcon ( self, icon, mask = wx. NullBitmap ) : <TAB> """"""Add an icon to the image list, or get the index if already there"""""" <TAB> index = self. __magicImageListMapping. get ( id ( icon ) ) <TAB> if index is None : <TAB> <TAB> if isinstance ( icon, wxIconPtr ) : <TAB> <TAB> <TAB> index = self. __magicImageList. AddIcon ( icon ) <TAB> <TAB> elif isinstance ( icon, wx. BitmapPtr ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> index = self. __magicImageList. AddWithColourMask ( icon, mask ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> index = self. __magicImageList. Add ( icon, mask ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""Unexpected icon object %s, "" ""expected wx.Icon or wx.Bitmap"" % ( icon ) <TAB> <TAB> <TAB> ) <TAB> <TAB> self. __magicImageListMapping [ id ( icon ) ] = index <TAB> return index",False,"isinstance(mask, wx.Colour)","isinstance(icon, wx.Icon)",0.6660116314888
|
||
|
1948,"def resolve_common_type ( parser, commontype ) : <TAB> try : <TAB> <TAB> return _CACHE [ commontype ] <TAB> except KeyError : <TAB> <TAB> cdecl = COMMON_TYPES. get ( commontype, commontype ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> result, quals = cdecl, 0 <TAB> <TAB> elif cdecl in model. PrimitiveType. ALL_PRIMITIVE_TYPES : <TAB> <TAB> <TAB> result, quals = model. PrimitiveType ( cdecl ), 0 <TAB> <TAB> elif cdecl == ""set-unicode-needed"" : <TAB> <TAB> <TAB> raise FFIError ( <TAB> <TAB> <TAB> <TAB> ""The Windows type %r is only available after "" <TAB> <TAB> <TAB> <TAB> ""you call ffi.set_unicode()"" % ( commontype, ) <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if commontype == cdecl : <TAB> <TAB> <TAB> <TAB> raise FFIError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Unsupported type: %r. Please look at "" <TAB> <TAB> <TAB> <TAB> <TAB> ""http://cffi.readthedocs.io/en/latest/cdef.html#ffi-cdef-limitations "" <TAB> <TAB> <TAB> <TAB> <TAB> ""and file an issue if you think this type should really "" <TAB> <TAB> <TAB> <TAB> <TAB> ""be supported."" % ( commontype, ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> result, quals = parser. parse_type_and_quals ( cdecl ) <TAB> <TAB> assert isinstance ( result, model. BaseTypeByIdentity ) <TAB> <TAB> _CACHE [ commontype ] = result, quals <TAB> <TAB> return result, quals",False,"not isinstance(cdecl, str)",cdecl in model.PrimitiveType.COMMON_TYPES,0.6520634889602661
|
||
|
1949,"def moveToThreadNext ( self ) : <TAB> """"""Move a position to threadNext position."""""" <TAB> p = self <TAB> if p. v : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> p. moveToFirstChild ( ) <TAB> <TAB> elif p. hasNext ( ) : <TAB> <TAB> <TAB> p. moveToNext ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> p. moveToParent ( ) <TAB> <TAB> <TAB> while p : <TAB> <TAB> <TAB> <TAB> if p. hasNext ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> p. moveToNext ( ) <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> p. moveToParent ( ) <TAB> <TAB> <TAB> <TAB> return p",False,p.v.children,p.firstChild(),0.6624227166175842
|
||
|
1950,"def _roll ( self, mapper ) : <TAB> <TAB> t = time. time ( ) <TAB> dt, self. _lastTime = t - self. _lastTime, t <TAB> <TAB> self. _xvel_dq. clear ( ) <TAB> self. _yvel_dq. clear ( ) <TAB> _hyp = sqrt ( ( self. _xvel ** 2 ) + ( self. _yvel ** 2 ) ) <TAB> if _hyp!= 0.0 : <TAB> <TAB> _ax = self. _a * ( abs ( self. _xvel ) / _hyp ) <TAB> <TAB> _ay = self. _a * ( abs ( self. _yvel ) / _hyp ) <TAB> else : <TAB> <TAB> _ax = self. _a <TAB> <TAB> _ay = self. _a <TAB> <TAB> _dvx = min ( abs ( self. _xvel ), _ax * dt ) <TAB> _dvy = min ( abs ( self. _yvel ), _ay * dt ) <TAB> <TAB> _xvel = self. _xvel - copysign ( _dvx, self. _xvel ) <TAB> _yvel = self. _yvel - copysign ( _dvy, self. _yvel ) <TAB> <TAB> dx = ( ( ( _xvel + self. _xvel ) / 2 ) * dt ) / self. _radscale <TAB> dy = ( ( ( _yvel + self. _yvel ) / 2 ) * dt ) / self. _radscale <TAB> self. _xvel = _xvel <TAB> self. _yvel = _yvel <TAB> self. action. add ( mapper, dx * self. speed [ 0 ], dy * self. speed [ 1 ] ) <TAB> if dx or dy : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> WholeHapticAction. add ( self, mapper, dx, dy ) <TAB> <TAB> self. _roll_task = mapper. schedule ( 0.02, self. _roll )",False,self.haptic,self.action is not None,0.6579887270927429
|
||
|
1951,"def allocate_buffers ( self ) : <TAB> if self. child : <TAB> <TAB> self. child. allocate_buffers ( ) <TAB> for ind in range ( len ( self. buffers ) ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if self. max_shape > 0 : <TAB> <TAB> <TAB> <TAB> self. buffers [ ind ] = self. be. iobuf ( <TAB> <TAB> <TAB> <TAB> <TAB> self. max_shape, persist_values = False, parallelism = ""Data"" <TAB> <TAB> <TAB> <TAB> )",False,self.buffers[ind] is None,self.buffers[ind],0.6524829864501953
|
||
|
1952,"def test_all ( self ) : <TAB> if type ( self ) is BaseTestConv : <TAB> <TAB> raise SkipTest ( ""base class"" ) <TAB> ds = self. default_subsamples <TAB> db = self. default_border_mode <TAB> dflip = self. default_filter_flip <TAB> dprovide_shape = self. default_provide_shape <TAB> for ( i, f ) in zip ( self. inputs_shapes, self. filters_shapes ) : <TAB> <TAB> for provide_shape in self. provide_shape : <TAB> <TAB> <TAB> yield ( self. tcase, i, f, ds, db, dflip, provide_shape ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> for fd in self. filters_dilations : <TAB> <TAB> <TAB> <TAB> for s in self. subsamples : <TAB> <TAB> <TAB> <TAB> <TAB> for b in self. border_modes : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> yield ( self. tcase, i, f, s, b, dflip, dprovide_shape, fd ) <TAB> <TAB> <TAB> for flip in self. filter_flip : <TAB> <TAB> <TAB> <TAB> yield ( self. tcase, i, f, ds, db, flip, dprovide_shape )",False,min(i) > 0 and min(f) > 0,self.border_modes is not None,0.6507933139801025
|
||
|
1953,"def serialize ( self ) : <TAB> data = { } <TAB> if not self. ranges : <TAB> <TAB> raise RuntimeError ( ""Invalid ranges"" ) <TAB> data [ ""ranges"" ] = self. ranges <TAB> if self. field : <TAB> <TAB> data [ ""field"" ] = self. field <TAB> elif self. key_field : <TAB> <TAB> data [ ""key_field"" ] = self. key_field <TAB> <TAB> if self. value_field : <TAB> <TAB> <TAB> data [ ""value_field"" ] = self. value_field <TAB> <TAB> else : <TAB> <TAB> <TAB> raise RuntimeError ( ""Invalid key_field: value_field required"" ) <TAB> elif self. key_script : <TAB> <TAB> data [ ""key_script"" ] = self. key_script <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> data [ ""value_script"" ] = self. value_script <TAB> <TAB> else : <TAB> <TAB> <TAB> raise RuntimeError ( ""Invalid key_script: value_script required"" ) <TAB> <TAB> if self. params : <TAB> <TAB> <TAB> data [ ""params"" ] = self. params <TAB> params = self. _base_parameters ( ) <TAB> params [ self. _internal_name ] = data <TAB> return { self. name : params }",True,self.value_script,self.value_script,0.6647767424583435
|
||
|
1954,"def _get_level ( levels, level_ref ) : <TAB> if level_ref in levels : <TAB> <TAB> return levels. index ( level_ref ) <TAB> if isinstance ( level_ref, six. integer_types ) : <TAB> <TAB> if level_ref < 0 : <TAB> <TAB> <TAB> level_ref += len ( levels ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise PatsyError ( ""specified level %r is out of range"" % ( level_ref, ) ) <TAB> <TAB> return level_ref <TAB> raise PatsyError ( ""specified level %r not found"" % ( level_ref, ) )",False,not 0 <= level_ref < len(levels),level_ref > len(levels),0.6495049595832825
|
||
|
1955,"def build_fingerprints ( targets, creds, config ) : <TAB> fingerprints = list ( ) <TAB> logger = logging. getLogger ( ""changeme"" ) <TAB> <TAB> for target in targets : <TAB> <TAB> for c in creds : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if not config. portoverride and ( <TAB> <TAB> <TAB> <TAB> target. port and not c [ ""default_port"" ] == target. port <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> fp = c [ ""fingerprint"" ] <TAB> <TAB> <TAB> for url in fp. get ( ""url"" ) : <TAB> <TAB> <TAB> <TAB> t = Target ( host = target. host, port = target. port, protocol = target. protocol ) <TAB> <TAB> <TAB> <TAB> if c. get ( ""ssl"" ) or config. ssl : <TAB> <TAB> <TAB> <TAB> <TAB> t. protocol = ""https"" <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> t. protocol = ""http"" <TAB> <TAB> <TAB> <TAB> if not t. port : <TAB> <TAB> <TAB> <TAB> <TAB> t. port = c [ ""default_port"" ] <TAB> <TAB> <TAB> <TAB> t. url = url <TAB> <TAB> <TAB> <TAB> hfp = HttpFingerprint ( <TAB> <TAB> <TAB> <TAB> <TAB> t, fp. get ( ""headers"", None ), fp. get ( ""cookie"", None ), config <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> logger. debug ( ""Adding %s to fingerprint list"" % hfp. target ) <TAB> <TAB> <TAB> <TAB> fingerprints. append ( hfp ) <TAB> return fingerprints",False,not c['protocol'] == 'http',c[target.target],0.6550403833389282
|
||
|
1956,"def available ( self ) : <TAB> myenv = os. environ. copy ( ) <TAB> myenv [ ""LANG"" ] = ""C"" <TAB> try : <TAB> <TAB> ( out, _err ) = subp. subp ( [ ""growpart"", ""--help"" ], env = myenv ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return True <TAB> except subp. ProcessExecutionError : <TAB> <TAB> pass <TAB> return False",False,"re.search('--update\\s+', out)",self.has_help(),0.6482461094856262
|
||
|
1957,"def get_package_info ( self, pre = False ) : <TAB> from. vendor. pip_shims. shims import pip_version, parse_version, CandidateEvaluator <TAB> dependency_links = [ ] <TAB> packages = self. get_installed_packages ( ) <TAB> <TAB> if parse_version ( pip_version ) < parse_version ( ""19.0"" ) : <TAB> <TAB> for dist in packages : <TAB> <TAB> <TAB> if dist. has_metadata ( ""dependency_links.txt"" ) : <TAB> <TAB> <TAB> <TAB> dependency_links. extend ( dist. get_metadata_lines ( ""dependency_links.txt"" ) ) <TAB> with self. get_finder ( ) as finder : <TAB> <TAB> if parse_version ( pip_version ) < parse_version ( ""19.0"" ) : <TAB> <TAB> <TAB> finder. add_dependency_links ( dependency_links ) <TAB> <TAB> for dist in packages : <TAB> <TAB> <TAB> typ = ""unknown"" <TAB> <TAB> <TAB> all_candidates = finder. find_all_candidates ( dist. key ) <TAB> <TAB> <TAB> if not self. pipfile. get ( ""pre"", finder. allow_all_prereleases ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> all_candidates = [ <TAB> <TAB> <TAB> <TAB> <TAB> candidate <TAB> <TAB> <TAB> <TAB> <TAB> for candidate in all_candidates <TAB> <TAB> <TAB> <TAB> <TAB> if not candidate. version. is_prerelease <TAB> <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> if not all_candidates : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> candidate_evaluator = finder. make_candidate_evaluator ( project_name = dist. key ) <TAB> <TAB> <TAB> best_candidate_result = candidate_evaluator. compute_best_candidate ( <TAB> <TAB> <TAB> <TAB> all_",False,best_candidate_result.best_candidate.link.is_wheel,pre,0.6498900651931763
|
||
|
1958,"def _run ( self ) : <TAB> try : <TAB> <TAB> empty_sock, empty_chan = None, None <TAB> <TAB> while not self. finished. is_set ( ) : <TAB> <TAB> <TAB> r, w, x = select. select ( [ self. sock, self. channel ], [ ], [ ], 1 ) <TAB> <TAB> <TAB> if self. sock in r : <TAB> <TAB> <TAB> <TAB> empty_sock = self. read_and_write ( <TAB> <TAB> <TAB> <TAB> <TAB> self. sock, self. channel, self. socket_chunk_size <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> empty_chan = self. read_and_write ( <TAB> <TAB> <TAB> <TAB> <TAB> self. channel, self. sock, self. channel_chunk_size <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if empty_sock or empty_chan : <TAB> <TAB> <TAB> <TAB> break <TAB> finally : <TAB> <TAB> self. channel. close ( ) <TAB> <TAB> self. sock. close ( )",False,self.channel in r,empty_chan is None,0.6621233224868774
|
||
|
1959,"def readfifo ( data ) : <TAB> nonlocal fifobuffer <TAB> fifobuffer. extend ( data ) <TAB> while fifobuffer : <TAB> <TAB> message, token, nextmsg = fifobuffer. partition ( b""\00"" ) <TAB> <TAB> if token : <TAB> <TAB> <TAB> splitval = message. split ( b"" "", 1 ) <TAB> <TAB> <TAB> cmd = splitval [ 0 ]. decode ( ""utf-8"" ) <TAB> <TAB> <TAB> if len ( splitval ) > 1 : <TAB> <TAB> <TAB> <TAB> value = splitval [ 1 ]. decode ( ""utf-8"" ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> value = """" <TAB> <TAB> <TAB> if cmd == ""bbplain"" : <TAB> <TAB> <TAB> <TAB> bb. plain ( value ) <TAB> <TAB> <TAB> elif cmd == ""bbnote"" : <TAB> <TAB> <TAB> <TAB> bb. note ( value ) <TAB> <TAB> <TAB> elif cmd == ""bbwarn"" : <TAB> <TAB> <TAB> <TAB> bb. warn ( value ) <TAB> <TAB> <TAB> elif cmd == ""bberror"" : <TAB> <TAB> <TAB> <TAB> bb. error ( value ) <TAB> <TAB> <TAB> elif cmd == ""bbfatal"" : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> bb. error ( value ) <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> bb. error ( value, forcelog = True ) <TAB> <TAB> <TAB> elif cmd == ""bbdebug"" : <TAB> <TAB> <TAB> <TAB> splitval = value. split ( "" "", 1 ) <TAB> <TAB> <TAB> <TAB> level = int ( splitval [ 0 ] ) <TAB> <TAB> <TAB> <TAB> value = splitval [ 1 ] <TAB",False,cmd == 'bbfatal_log',cmd == 'bberror',0.6613268852233887
|
||
|
1960,"def save_long ( self, obj ) : <TAB> if self. bin : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if obj >= 0 : <TAB> <TAB> <TAB> if obj <= 0xFF : <TAB> <TAB> <TAB> <TAB> self. write ( BININT1 + pack ( ""<B"", obj ) ) <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> if obj <= 0xFFFF : <TAB> <TAB> <TAB> <TAB> self. write ( BININT2 + pack ( ""<H"", obj ) ) <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> <TAB> if - 0x80000000 <= obj <= 0x7FFFFFFF : <TAB> <TAB> <TAB> self. write ( BININT + pack ( ""<i"", obj ) ) <TAB> <TAB> <TAB> return <TAB> if self. proto >= 2 : <TAB> <TAB> encoded = encode_long ( obj ) <TAB> <TAB> n = len ( encoded ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. write ( LONG1 + pack ( ""<B"", n ) + encoded ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. write ( LONG4 + pack ( ""<i"", n ) + encoded ) <TAB> <TAB> return <TAB> self. write ( LONG + repr ( obj ). encode ( ""ascii"" ) + b""L\n"" )",False,n < 256,n > 0,0.6833459138870239
|
||
|
1961,"def _decimal_places_for_asset ( self, asset, reference_date ) : <TAB> if isinstance ( asset, Future ) and asset. tick_size : <TAB> <TAB> return number_of_decimal_places ( asset. tick_size ) <TAB> elif isinstance ( asset, ContinuousFuture ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> oc = self. _asset_finder. get_ordered_contracts ( asset. root_symbol ) <TAB> <TAB> contract_sid = oc. contract_before_auto_close ( reference_date. value ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> contract = self. _asset_finder. retrieve_asset ( contract_sid ) <TAB> <TAB> <TAB> if contract. tick_size : <TAB> <TAB> <TAB> <TAB> return number_of_decimal_places ( contract. tick_size ) <TAB> return DEFAULT_ASSET_PRICE_DECIMALS",False,contract_sid is not None,contract_sid,0.6590975522994995
|
||
|
1962,"def __get_photo ( self, person_or_marriage ) : <TAB> """"""returns the first photo in the media list or None"""""" <TAB> media_list = person_or_marriage. get_media_list ( ) <TAB> for media_ref in media_list : <TAB> <TAB> media_handle = media_ref. get_reference_handle ( ) <TAB> <TAB> media = self. database. get_media_from_handle ( media_handle ) <TAB> <TAB> mime_type = media. get_mime_type ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return media <TAB> return None",False,mime_type and mime_type.startswith('image'),mime_type in self.photo_types,0.6461145281791687
|
||
|
1963,"def extract_range ( self ) : <TAB> use_206 = False <TAB> start = None <TAB> end = None <TAB> url = self. url <TAB> range_h = self. env. get ( ""HTTP_RANGE"" ) <TAB> if range_h : <TAB> <TAB> m = self. RANGE_HEADER. match ( range_h ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> start = m. group ( 1 ) <TAB> <TAB> <TAB> end = m. group ( 2 ) <TAB> <TAB> <TAB> use_206 = True <TAB> else : <TAB> <TAB> m = self. RANGE_ARG_RX. match ( url ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> start = m. group ( 2 ) <TAB> <TAB> <TAB> end = m. group ( 3 ) <TAB> <TAB> <TAB> url = url [ : m. start ( 1 ) ] + url [ m. end ( 1 ) : ] <TAB> <TAB> <TAB> use_206 = False <TAB> if not start : <TAB> <TAB> return None <TAB> start = int ( start ) <TAB> if end : <TAB> <TAB> end = int ( end ) <TAB> else : <TAB> <TAB> end = """" <TAB> result = ( url, start, end, use_206 ) <TAB> return result",True,m,m,0.6960936784744263
|
||
|
1964,"def draged ( self, ox, oy, nx, ny, i ) : <TAB> self. update, self. infoupdate ( ), True <TAB> if i [ 0 ] == True : <TAB> <TAB> for j in range ( len ( i [ 1 ] ) ) : <TAB> <TAB> <TAB> i [ 1 ] [ j ] = ( i [ 1 ] [ j ] [ 0 ] + ( nx - ox ), i [ 1 ] [ j ] [ 1 ] + ( ny - oy ) ) <TAB> else : <TAB> <TAB> i [ 0 ] [ i [ 1 ] ] = ( nx, ny ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> i [ 0 ] [ - 1 ] = ( nx, ny ) <TAB> <TAB> if i [ 1 ] == len ( i [ 0 ] ) - 1 : <TAB> <TAB> <TAB> i [ 0 ] [ 0 ] = ( nx, ny )",False,i[1] == 0,i[1] == len(i[0]) - 1,0.6664236783981323
|
||
|
1965,"def _GetObjectAtPos ( self, pos = - 1, bAllowCalls = 0 ) : <TAB> left, right = self. _GetWordSplit ( pos, bAllowCalls ) <TAB> if left : <TAB> <TAB> <TAB> <TAB> namespace = sys. modules. copy ( ) <TAB> <TAB> namespace. update ( __main__. __dict__ ) <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> from pywin. framework import interact <TAB> <TAB> <TAB> if interact. edit is not None and interact. edit. currentView is not None : <TAB> <TAB> <TAB> <TAB> globs, locs = interact. edit. currentView. GetContext ( ) [ : 2 ] <TAB> <TAB> <TAB> <TAB> if globs : <TAB> <TAB> <TAB> <TAB> <TAB> namespace. update ( globs ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> namespace. update ( locs ) <TAB> <TAB> except ImportError : <TAB> <TAB> <TAB> pass <TAB> <TAB> try : <TAB> <TAB> <TAB> return eval ( left, namespace ) <TAB> <TAB> except : <TAB> <TAB> <TAB> pass <TAB> return None",True,locs,locs,0.7155642509460449
|
||
|
1966,"def do_button_press_event ( self, event ) : <TAB> <TAB> if event. button > 3 : <TAB> <TAB> if event. button == self. preferences [ ""mouse_nav_button_back"" ] : <TAB> <TAB> <TAB> self. open_page_back ( ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> self. open_page_forward ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> logger. debug ( ""Unused mouse button %i"", event. button )",False,event.button == self.preferences['mouse_nav_button_forw'],event.button == self.preferences['mouse_nav_button_forward'],0.6502617001533508
|
||
|
1967,"def _initPosScale ( self, pos, size, stretch, log = True ) : <TAB> """"""position (x,y) and size (magnification) of the rating scale"""""" <TAB> <TAB> if pos : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> offsetHoriz, offsetVert = pos <TAB> <TAB> elif log and self. autoLog : <TAB> <TAB> <TAB> msg = ""RatingScale %s: pos expects a tuple (x,y)"" <TAB> <TAB> <TAB> logging. warning ( msg % self. name ) <TAB> try : <TAB> <TAB> self. offsetHoriz = float ( offsetHoriz ) <TAB> except Exception : <TAB> <TAB> if self. savedWinUnits == ""pix"" : <TAB> <TAB> <TAB> self. offsetHoriz = 0 <TAB> <TAB> else : <TAB> <TAB> <TAB> self. offsetHoriz = 0.0 <TAB> try : <TAB> <TAB> self. offsetVert = float ( offsetVert ) <TAB> except Exception : <TAB> <TAB> if self. savedWinUnits == ""pix"" : <TAB> <TAB> <TAB> self. offsetVert = int ( self. win. size [ 1 ] / - 5.0 ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. offsetVert = - 0.4 <TAB> <TAB> <TAB> if self. savedWinUnits == ""pix"" : <TAB> <TAB> self. offsetHoriz = float ( self. offsetHoriz ) / self. win. size [ 0 ] / 0.5 <TAB> <TAB> self. offsetVert = float ( self. offsetVert ) / self. win. size [ 1 ] / 0.5 <TAB> <TAB> self. pos = [ self. offsetHoriz, self. offsetVert ] <TAB> <TAB> try : <TAB> <TAB> self. stretch = float ( stretch ) <TAB> except ValueError : <TAB> <TAB> self. stretch = 1.0 <TAB> try : <TAB> <TAB> self. size = float ( size ) * 0.6 <TAB> except ValueError : <TAB> <TAB> self. size = 0",False,len(list(pos)) == 2,size,0.6567631363868713
|
||
|
1968,"def store ( self, addr, data, size = None, condition = None, ** kwargs ) : <TAB> if ( <TAB> <TAB> self. state. solver. symbolic ( addr ) <TAB> <TAB> and options. AVOID_MULTIVALUED_WRITES in self. state. options <TAB> ) : <TAB> <TAB> <TAB> <TAB> return <TAB> try : <TAB> <TAB> concrete_addrs = self. _interleave_ints ( sorted ( self. concretize_write_addr ( addr ) ) ) <TAB> except SimMemoryError : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return <TAB> <TAB> else : <TAB> <TAB> <TAB> raise <TAB> <TAB> trivial = type ( addr ) is int or ( <TAB> <TAB> len ( concrete_addrs ) == 1 and ( addr == concrete_addrs [ 0 ] ). is_true ( ) <TAB> ) <TAB> if not trivial : <TAB> <TAB> <TAB> <TAB> constraint_options = [ addr == concrete_addr for concrete_addr in concrete_addrs ] <TAB> <TAB> conditional_constraint = self. state. solver. Or ( * constraint_options ) <TAB> <TAB> self. _add_constraints ( conditional_constraint, condition = condition, ** kwargs ) <TAB> <TAB> if len ( concrete_addrs ) == 1 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> super ( ). store ( concrete_addrs [ 0 ], data, size = size, ** kwargs ) <TAB> <TAB> <TAB> return <TAB> for concrete_addr in concrete_addrs : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if trivial : <TAB> <TAB> <TAB> sub_condition = condition <TAB> <TAB> else : <TAB> <TAB> <TAB> sub_condition = addr == concrete_addr <TAB> <TAB> <TAB> if condition is not None : <TAB> <TAB> <TAB> <TAB> sub_condition = condition & sub_condition <TAB> <TAB> super ( ). store ( concrete_addr, data, size = size, condition = sub_condition",False,options.CONSERVATIVE_WRITE_STRATEGY in self.state.options,addr == concrete_addr,0.6553521156311035
|
||
|
1969,"def getnotes ( self, origin = None ) : <TAB> if origin is None : <TAB> <TAB> result = self. translator_comments <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if result : <TAB> <TAB> <TAB> <TAB> result += ""\n"" + self. developer_comments <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> result = self. developer_comments <TAB> <TAB> return result <TAB> elif origin == ""translator"" : <TAB> <TAB> return self. translator_comments <TAB> elif origin in ( ""programmer"", ""developer"", ""source code"" ) : <TAB> <TAB> return self. developer_comments <TAB> else : <TAB> <TAB> raise ValueError ( ""Comment type not valid"" )",False,self.developer_comments,origin == 'developer',0.6638951897621155
|
||
|
1970,"def _from_word2vec_text ( fname ) : <TAB> with _open ( fname, ""rb"" ) as fin : <TAB> <TAB> words = [ ] <TAB> <TAB> header = unicode ( fin. readline ( ) ) <TAB> <TAB> vocab_size, layer1_size = list ( <TAB> <TAB> <TAB> map ( int, header. split ( ) ) <TAB> <TAB> ) <TAB> <TAB> vectors = [ ] <TAB> <TAB> for line_no, line in enumerate ( fin ) : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> parts = unicode ( line, encoding = ""utf-8"" ). strip ( ). split ( ) <TAB> <TAB> <TAB> except TypeError as e : <TAB> <TAB> <TAB> <TAB> parts = line. strip ( ). split ( ) <TAB> <TAB> <TAB> except Exception as e : <TAB> <TAB> <TAB> <TAB> logger. warning ( <TAB> <TAB> <TAB> <TAB> <TAB> ""We ignored line number {} because of erros in parsing"" <TAB> <TAB> <TAB> <TAB> <TAB> ""\n{}"". format ( line_no, e ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if len ( parts ) == layer1_size + 1 : <TAB> <TAB> <TAB> <TAB> word, weights = parts [ 0 ], list ( map ( float32, parts [ 1 : ] ) ) <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> word, weights = parts [ : 2 ], list ( map ( float32, parts [ 2 : ] ) ) <TAB> <TAB> <TAB> <TAB> word = u"" "". join ( word ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> logger. warning ( <TAB> <TAB> <TAB> <",False,len(parts) == layer1_size + 2,len(parts) == layer1_size,0.652237057685852
|
||
|
1971,"def run ( self, app, editor, args ) : <TAB> line_nums = [ ] <TAB> for cursor in editor. cursors : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> line_nums. append ( cursor. y ) <TAB> <TAB> <TAB> data = editor. lines [ cursor. y ]. get_data ( ). upper ( ) <TAB> <TAB> <TAB> editor. lines [ cursor. y ]. set_data ( data )",False,cursor.y not in line_nums,cursor.y >= 0 and cursor.y < line_nums,0.6618049144744873
|
||
|
1972,"def check_action ( self ) : <TAB> params = BorgCheckThread. prepare ( self. profile ( ) ) <TAB> if not params [ ""ok"" ] : <TAB> <TAB> self. _set_status ( params [ ""message"" ] ) <TAB> <TAB> return <TAB> <TAB> row_selected = self. archiveTable. selectionModel ( ). selectedRows ( ) <TAB> if row_selected : <TAB> <TAB> archive_cell = self. archiveTable. item ( row_selected [ 0 ]. row ( ), 4 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> archive_name = archive_cell. text ( ) <TAB> <TAB> <TAB> params [ ""cmd"" ] [ - 1 ] += f""::{archive_name}"" <TAB> thread = BorgCheckThread ( params [ ""cmd"" ], params, parent = self. app ) <TAB> thread. updated. connect ( self. _set_status ) <TAB> thread. result. connect ( self. check_result ) <TAB> self. _toggle_all_buttons ( False ) <TAB> thread. start ( )",True,archive_cell,archive_cell,0.6667417287826538
|
||
|
1973,"def GetLogHandlers ( ) : <TAB> formatter = logging. Formatter ( LOG_FORMAT ) <TAB> engines = config. CONFIG [ ""Logging.engines"" ] <TAB> logging. debug ( ""Will use logging engines %s"", engines ) <TAB> for engine in engines : <TAB> <TAB> try : <TAB> <TAB> <TAB> if engine == ""stderr"" : <TAB> <TAB> <TAB> <TAB> handler = logging. StreamHandler ( ) <TAB> <TAB> <TAB> <TAB> handler. setFormatter ( formatter ) <TAB> <TAB> <TAB> <TAB> yield handler <TAB> <TAB> <TAB> elif engine == ""event_log"" : <TAB> <TAB> <TAB> <TAB> handler = handlers. NTEventLogHandler ( ""GRR"" ) <TAB> <TAB> <TAB> <TAB> handler. setFormatter ( formatter ) <TAB> <TAB> <TAB> <TAB> yield handler <TAB> <TAB> <TAB> elif engine == ""syslog"" : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> socket_name = config. CONFIG [ ""Logging.syslog_path"" ] <TAB> <TAB> <TAB> <TAB> if "":"" in socket_name : <TAB> <TAB> <TAB> <TAB> <TAB> addr, port = socket_name. split ( "":"", 1 ) <TAB> <TAB> <TAB> <TAB> <TAB> handler = RobustSysLogHandler ( ( addr, int ( port ) ) ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> handler = RobustSysLogHandler ( socket_name ) <TAB> <TAB> <TAB> <TAB> handler. setFormatter ( formatter ) <TAB> <TAB> <TAB> <TAB> yield handler <TAB> <TAB> <TAB> elif engine == ""file"" : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> path = config. CONFIG [ ""Logging.filename"" ] <TAB> <TAB> <TAB> <TAB> logging. info ( ""Writing log file to %s"", path ) <TAB> <TAB> <",False,not os.path.isdir(os.path.dirname(path)),engine != 'global',0.6487890481948853
|
||
|
1974,"def best_match ( self, supported_content_types ) : <TAB> <TAB> <TAB> best_quality = - 1 <TAB> best_content_type = None <TAB> best_params = { } <TAB> best_match = ""*/*"" <TAB> for content_type in supported_content_types : <TAB> <TAB> for content_mask, params in self. _content_types : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> quality = float ( params. get ( ""q"", 1 ) ) <TAB> <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if quality < best_quality : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> elif best_quality == quality : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if self. _match_mask ( content_mask, content_type ) : <TAB> <TAB> <TAB> <TAB> best_quality = quality <TAB> <TAB> <TAB> <TAB> best_content_type = content_type <TAB> <TAB> <TAB> <TAB> best_params = params <TAB> <TAB> <TAB> <TAB> best_match = content_mask <TAB> return best_content_type, best_params",False,best_match.count('*') <= content_mask.count('*'),best_match == content_type,0.6548671126365662
|
||
|
1975,"def test_field_attr_existence ( self ) : <TAB> for name, item in ast. __dict__. items ( ) : <TAB> <TAB> if self. _is_ast_node ( name, item ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> x = item ( ) <TAB> <TAB> <TAB> if isinstance ( x, ast. AST ) : <TAB> <TAB> <TAB> <TAB> self. assertEqual ( type ( x. _fields ), tuple )",False,name == 'Index',"isinstance(item, ast.Enter)",0.6626070737838745
|
||
|
1976,"def check_buffer ( self ) : <TAB> for i, pkt in enumerate ( self. buffer ) : <TAB> <TAB> last = self. packets [ - 1 : ] [ 0 ] <TAB> <TAB> <TAB> <TAB> if Raw in last : <TAB> <TAB> <TAB> next_seq = self. seq + len ( last [ Raw ]. load ) <TAB> <TAB> else : <TAB> <TAB> <TAB> next_seq = self. seq <TAB> <TAB> <TAB> <TAB> if next_seq == pkt [ TCP ]. seq : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. packets += self. buffer. pop ( i ) <TAB> <TAB> <TAB> self. seq = pkt [ TCP ]. seq <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. payload += str ( pkt [ Raw ]. load ) <TAB> <TAB> <TAB> <TAB> self. data_transfered += len ( pkt [ Raw ]. load ) <TAB> <TAB> <TAB> return True <TAB> return False",True,Raw in pkt,Raw in pkt,0.6689813137054443
|
||
|
1977,"def _process ( self ) : <TAB> while True : <TAB> <TAB> try : <TAB> <TAB> <TAB> process = await asyncio. create_subprocess_exec ( <TAB> <TAB> <TAB> <TAB> ""iostat"", <TAB> <TAB> <TAB> <TAB> ""-d"", <TAB> <TAB> <TAB> <TAB> ""-x"", <TAB> <TAB> <TAB> <TAB> ""-z"", <TAB> <TAB> <TAB> <TAB> str ( self. interval ), <TAB> <TAB> <TAB> <TAB> stdout = subprocess. PIPE, <TAB> <TAB> <TAB> <TAB> stderr = subprocess. DEVNULL, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> lines = [ ] <TAB> <TAB> <TAB> is_first_reading = True <TAB> <TAB> <TAB> while True : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> line = await asyncio. wait_for ( process. stdout. readline ( ), 5 ) <TAB> <TAB> <TAB> <TAB> except asyncio. TimeoutError : <TAB> <TAB> <TAB> <TAB> <TAB> if lines : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _on_iostat_output ( lines ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> is_first_reading = False <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> lines = [ ] <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> if not line : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> <TAB> lines. append ( line. decode ( ""utf-8"", ""ignore"" ) )",False,not is_first_reading,is_first_reading,0.6502025127410889
|
||
|
1978,"def get_result ( self ) : <TAB> try : <TAB> <TAB> sz = len ( self. dataset ) <TAB> except NotImplementedError : <TAB> <TAB> sz = 0 <TAB> with get_tqdm ( total = sz, disable = ( sz == 0 ) ) as pbar : <TAB> <TAB> die_cnt = 0 <TAB> <TAB> while True : <TAB> <TAB> <TAB> res = self. result_queue. get ( ) <TAB> <TAB> <TAB> pbar. update ( ) <TAB> <TAB> <TAB> if res [ 0 ]!= DIE : <TAB> <TAB> <TAB> <TAB> yield res [ 1 ] <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> die_cnt += 1 <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> self. inqueue_proc. join ( ) <TAB> self. inqueue_proc. terminate ( ) <TAB> if self. ordered : <TAB> <TAB> self. result_queue. join ( ) <TAB> <TAB> self. result_queue. terminate ( ) <TAB> for p in self. workers : <TAB> <TAB> p. join ( ) <TAB> <TAB> p. terminate ( )",False,die_cnt == self.nr_proc,die_cnt > 10,0.6527413725852966
|
||
|
1979,"def stream_docker_log ( log_stream ) : <TAB> async for line in log_stream : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> logger. debug ( line [ ""stream"" ]. strip ( ) ) <TAB> <TAB> elif ""status"" in line : <TAB> <TAB> <TAB> logger. debug ( line [ ""status"" ]. strip ( ) ) <TAB> <TAB> elif ""error"" in line : <TAB> <TAB> <TAB> logger. error ( line [ ""error"" ]. strip ( ) ) <TAB> <TAB> <TAB> raise DockerBuildError",False,'stream' in line and line['stream'].strip(),'stream' in line,0.6532998085021973
|
||
|
1980,"def as_dict ( path = """", version = ""latest"", section = ""meta-data"" ) : <TAB> result = { } <TAB> dirs = dir ( path, version, section ) <TAB> if not dirs : <TAB> <TAB> return None <TAB> for item in dirs : <TAB> <TAB> if item. endswith ( ""/"" ) : <TAB> <TAB> <TAB> records = as_dict ( path + item, version, section ) <TAB> <TAB> <TAB> if records : <TAB> <TAB> <TAB> <TAB> result [ item [ : - 1 ] ] = records <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> idx, name = is_dict. match ( item ). groups ( ) <TAB> <TAB> <TAB> records = as_dict ( path + idx + ""/"", version, section ) <TAB> <TAB> <TAB> if records : <TAB> <TAB> <TAB> <TAB> result [ name ] = records <TAB> <TAB> else : <TAB> <TAB> <TAB> result [ item ] = valueconv ( get ( path + item, version, section ) ) <TAB> return result",False,is_dict.match(item),"isinstance(item, dict)",0.6471608877182007
|
||
|
1981,"def _collects_refs_to_upload ( self, package_id, reference_or_pattern, confirm ) : <TAB> """"""validate inputs and compute the refs (without revisions) to be uploaded"""""" <TAB> if package_id and not check_valid_ref ( reference_or_pattern, strict_mode = False ) : <TAB> <TAB> raise ConanException ( <TAB> <TAB> <TAB> ""-p parameter only allowed with a valid recipe reference, "" <TAB> <TAB> <TAB> ""not with a pattern"" <TAB> <TAB> ) <TAB> if package_id or check_valid_ref ( reference_or_pattern ) : <TAB> <TAB> <TAB> <TAB> ref = ConanFileReference. loads ( reference_or_pattern ) <TAB> <TAB> if ref. revision and not self. _cache. config. revisions_enabled : <TAB> <TAB> <TAB> raise ConanException ( <TAB> <TAB> <TAB> <TAB> ""Revisions not enabled in the client, specify a "" <TAB> <TAB> <TAB> <TAB> ""reference without revision"" <TAB> <TAB> <TAB> ) <TAB> <TAB> refs = [ <TAB> <TAB> <TAB> ref, <TAB> <TAB> ] <TAB> <TAB> confirm = True <TAB> else : <TAB> <TAB> refs = search_recipes ( self. _cache, reference_or_pattern ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise NotFoundException ( <TAB> <TAB> <TAB> <TAB> ( ""No packages found matching pattern '%s'"" % reference_or_pattern ) <TAB> <TAB> <TAB> ) <TAB> return refs, confirm",True,not refs,not refs,0.6721539497375488
|
||
|
1982,"def unlink_asset_reference ( self ) : <TAB> for d in self. get ( ""accounts"" ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> asset = frappe. get_doc ( ""Asset"", d. reference_name ) <TAB> <TAB> <TAB> for s in asset. get ( ""schedules"" ) : <TAB> <TAB> <TAB> <TAB> if s. journal_entry == self. name : <TAB> <TAB> <TAB> <TAB> <TAB> s. db_set ( ""journal_entry"", None ) <TAB> <TAB> <TAB> <TAB> <TAB> idx = cint ( s. finance_book_id ) or 1 <TAB> <TAB> <TAB> <TAB> <TAB> finance_books = asset. get ( ""finance_books"" ) [ idx - 1 ] <TAB> <TAB> <TAB> <TAB> <TAB> finance_books. value_after_depreciation += s. depreciation_amount <TAB> <TAB> <TAB> <TAB> <TAB> finance_books. db_update ( ) <TAB> <TAB> <TAB> <TAB> <TAB> asset. set_status ( )",False,d.reference_type == 'Asset' and d.reference_name,d.reference_name,0.6489284634590149
|
||
|
1983,"def read_oclc ( rec ) : <TAB> found = [ ] <TAB> tag_001 = rec. get_fields ( ""001"" ) <TAB> tag_003 = rec. get_fields ( ""003"" ) <TAB> if tag_001 and tag_003 and re_ocolc. match ( tag_003 [ 0 ] ) : <TAB> <TAB> oclc = tag_001 [ 0 ] <TAB> <TAB> m = re_ocn_or_ocm. match ( oclc ) <TAB> <TAB> if m : <TAB> <TAB> <TAB> oclc = m. group ( 1 ) <TAB> <TAB> if oclc. isdigit ( ) : <TAB> <TAB> <TAB> found. append ( oclc ) <TAB> for f in rec. get_fields ( ""035"" ) : <TAB> <TAB> for k, v in f. get_subfields ( [ ""a"" ] ) : <TAB> <TAB> <TAB> m = re_oclc. match ( v ) <TAB> <TAB> <TAB> if not m : <TAB> <TAB> <TAB> <TAB> m = re_ocn_or_ocm. match ( v ) <TAB> <TAB> <TAB> <TAB> if m and not m. group ( 1 ). isdigit ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> m = None <TAB> <TAB> <TAB> if m : <TAB> <TAB> <TAB> <TAB> oclc = m. group ( 1 ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> found. append ( oclc ) <TAB> return remove_duplicates ( found )",False,oclc not in found,oclc,0.6690476536750793
|
||
|
1984,"def substitute ( substitutions, fname ) : <TAB> import re <TAB> var_re = re. compile ( r""\$\{([A-Za-z_0-9]+)\}"" ) <TAB> string_var_re = re. compile ( r""\$str\{([A-Za-z_0-9]+)\}"" ) <TAB> fname_in = fname + "".in"" <TAB> lines = open ( fname_in, ""r"" ). readlines ( ) <TAB> new_lines = [ ] <TAB> for line in lines : <TAB> <TAB> made_change = True <TAB> <TAB> while made_change : <TAB> <TAB> <TAB> made_change = False <TAB> <TAB> <TAB> match = var_re. search ( line ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> varname = match. group ( 1 ) <TAB> <TAB> <TAB> <TAB> line = ( <TAB> <TAB> <TAB> <TAB> <TAB> line [ : match. start ( ) ] <TAB> <TAB> <TAB> <TAB> <TAB> + str ( substitutions [ varname ] ) <TAB> <TAB> <TAB> <TAB> <TAB> + line [ match. end ( ) : ] <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> made_change = True <TAB> <TAB> <TAB> match = string_var_re. search ( line ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> varname = match. group ( 1 ) <TAB> <TAB> <TAB> <TAB> subst = substitutions [ varname ] <TAB> <TAB> <TAB> <TAB> if subst is None : <TAB> <TAB> <TAB> <TAB> <TAB> subst = """" <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> subst = '""%s""' % subst <TAB> <TAB> <TAB> <TAB> line = line [ : match. start ( ) ] + subst + line [ match. end ( ) : ] <TAB> <TAB> <",True,match,match,0.6830191612243652
|
||
|
1985,"def translation ( <TAB> domain, localedir = None, languages = None, class_ = None, fallback = False, codeset = None ) : <TAB> if class_ is None : <TAB> <TAB> class_ = GNUTranslations <TAB> mofiles = find ( domain, localedir, languages, all = True ) <TAB> if not mofiles : <TAB> <TAB> if fallback : <TAB> <TAB> <TAB> return NullTranslations ( ) <TAB> <TAB> raise OSError ( ENOENT, ""No translation file found for domain"", domain ) <TAB> <TAB> <TAB> result = None <TAB> for mofile in mofiles : <TAB> <TAB> key = ( class_, os. path. abspath ( mofile ) ) <TAB> <TAB> t = _translations. get ( key ) <TAB> <TAB> if t is None : <TAB> <TAB> <TAB> with open ( mofile, ""rb"" ) as fp : <TAB> <TAB> <TAB> <TAB> t = _translations. setdefault ( key, class_ ( fp ) ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> t = copy. copy ( t ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> t. set_output_charset ( codeset ) <TAB> <TAB> if result is None : <TAB> <TAB> <TAB> result = t <TAB> <TAB> else : <TAB> <TAB> <TAB> result. add_fallback ( t ) <TAB> return result",False,codeset,codeset is not None,0.6781377792358398
|
||
|
1986,def is_all_qud ( world ) : <TAB> m = True <TAB> for obj in world : <TAB> <TAB> if obj. blond : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> m = m and True <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> m = m and False <TAB> <TAB> else : <TAB> <TAB> <TAB> m = m and True <TAB> return m,False,obj.nice,m,0.6619960069656372
|
||
|
1987,"def sendCommand ( <TAB> self, <TAB> cmd, <TAB> cmd_type = None, <TAB> part_of_job = False, <TAB> processed = False, <TAB> force = False, <TAB> on_sent = None, <TAB> tags = None, ) : <TAB> if not isinstance ( cmd, QueueMarker ) : <TAB> <TAB> cmd = to_unicode ( cmd, errors = ""replace"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> cmd = process_gcode_line ( cmd ) <TAB> <TAB> <TAB> if not cmd : <TAB> <TAB> <TAB> <TAB> return False <TAB> <TAB> gcode = gcode_command_for_cmd ( cmd ) <TAB> <TAB> force = force or gcode in self. _emergency_commands <TAB> if tags is None : <TAB> <TAB> tags = set ( ) <TAB> if part_of_job : <TAB> <TAB> self. _job_queue. put ( ( cmd, cmd_type, on_sent, tags | { ""source:job"" } ) ) <TAB> <TAB> return True <TAB> elif ( <TAB> <TAB> self. isPrinting ( ) <TAB> <TAB> and not self. isSdFileSelected ( ) <TAB> <TAB> and not self. job_on_hold <TAB> <TAB> and not force <TAB> ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> self. _command_queue. put ( ( cmd, cmd_type, on_sent, tags ), item_type = cmd_type ) <TAB> <TAB> <TAB> return True <TAB> <TAB> except TypeAlreadyInQueue as e : <TAB> <TAB> <TAB> self. _logger. debug ( ""Type already in command queue: "" + e. type ) <TAB> <TAB> <TAB> return False <TAB> elif self. isOperational ( ) or force : <TAB> <TAB> return self. _sendCommand ( cmd, cmd_type = cmd_type, on_sent = on_sent, tags = tags )",False,not processed,processed,0.6793094873428345
|
||
|
1988,"def initial_form_count ( self ) : <TAB> """"""Returns the number of forms that are required in this FormSet."""""" <TAB> if self. is_bound : <TAB> <TAB> return self. management_form. cleaned_data [ INITIAL_FORM_COUNT ] <TAB> else : <TAB> <TAB> <TAB> <TAB> initial_forms = self. initial and len ( self. initial ) or 0 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> initial_forms = self. max_num <TAB> return initial_forms",False,initial_forms > self.max_num >= 0,self.max_num is not None,0.654896080493927
|
||
|
1989,"def _setVolume ( self, value, setClient = True ) : <TAB> <TAB> <TAB> <TAB> if value is None : <TAB> <TAB> self. _volume = None <TAB> elif hasattr ( value, ""getDynamicContext"" ) : <TAB> <TAB> if setClient : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> value = copy. deepcopy ( value ) <TAB> <TAB> <TAB> value. client = self <TAB> <TAB> self. _volume = value <TAB> elif common. isNum ( value ) and setClient : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> vol = self. _getVolume ( ) <TAB> <TAB> if value < 1 : <TAB> <TAB> <TAB> vol. velocityScalar = value <TAB> <TAB> else : <TAB> <TAB> <TAB> vol. velocity = value <TAB> else : <TAB> <TAB> raise Exception ( f""this must be a Volume object, not {value}"" )",False,value.client is not None,common.isNum(value),0.6574002504348755
|
||
|
1990,"def get_url ( token, base_url ) : <TAB> """"""Parse an <url> token."""""" <TAB> if token. type == ""url"" : <TAB> <TAB> return _get_url_tuple ( token. value, base_url ) <TAB> elif token. type == ""function"" : <TAB> <TAB> if token. name == ""attr"" : <TAB> <TAB> <TAB> return check_attr_function ( token, ""url"" ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return _get_url_tuple ( token. arguments [ 0 ]. value, base_url )",False,"token.name == 'url' and len(token.arguments) in (1, 2)",token.name == 'arg',0.6497083902359009
|
||
|
1991,"def initialize ( ) : <TAB> global args, term_mode <TAB> <TAB> if ""READTHEDOCS"" in os. environ : <TAB> <TAB> os. environ [ ""PWNLIB_NOTERM"" ] = ""1"" <TAB> for k, v in os. environ. items ( ) : <TAB> <TAB> if not k. startswith ( env_prefix ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> k = k [ len ( env_prefix ) : ] <TAB> <TAB> if k in hooks : <TAB> <TAB> <TAB> hooks [ k ] ( v ) <TAB> <TAB> elif isident ( k ) : <TAB> <TAB> <TAB> args [ k ] = v <TAB> argv = sys. argv [ : ] <TAB> for arg in sys. argv [ : ] : <TAB> <TAB> orig = arg <TAB> <TAB> value = ""True"" <TAB> <TAB> if ""="" in arg : <TAB> <TAB> <TAB> arg, value = arg. split ( ""="", 1 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> sys. argv. remove ( orig ) <TAB> <TAB> <TAB> hooks [ arg ] ( value ) <TAB> <TAB> elif free_form and isident ( arg ) : <TAB> <TAB> <TAB> sys. argv. remove ( orig ) <TAB> <TAB> <TAB> args [ arg ] = value <TAB> if term_mode : <TAB> <TAB> term. init ( )",False,arg in hooks,free_form and isident(arg),0.6889987587928772
|
||
|
1992,"def test_training_script_with_max_history_set ( tmpdir ) : <TAB> train_dialogue_model ( <TAB> <TAB> DEFAULT_DOMAIN_PATH, <TAB> <TAB> DEFAULT_STORIES_FILE, <TAB> <TAB> tmpdir. strpath, <TAB> <TAB> interpreter = RegexInterpreter ( ), <TAB> <TAB> policy_config = ""data/test_config/max_hist_config.yml"", <TAB> <TAB> kwargs = { }, <TAB> ) <TAB> agent = Agent. load ( tmpdir. strpath ) <TAB> for policy in agent. policy_ensemble. policies : <TAB> <TAB> if hasattr ( policy. featurizer, ""max_history"" ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> assert policy. featurizer. max_history == 2 <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> assert policy. featurizer. max_history == 5",False,type(policy) == FormPolicy,policy.featurizer.max_history == 1 <TAB > <TAB > <TAB > 5,0.6545754075050354
|
||
|
1993,"def test_evname_in_mp_events_testcases ( ) : <TAB> ok = True <TAB> for evname in ins. mp_events : <TAB> <TAB> if evname == ""version"" : <TAB> <TAB> <TAB> continue <TAB> <TAB> for i, args in enumerate ( ins. mp_events [ evname ] [ ""test_cases"" ] ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> msg = ""Error, for evname %s the testase #%d does not match evname"" <TAB> <TAB> <TAB> <TAB> print ( msg % ( evname, i ) ) <TAB> <TAB> <TAB> <TAB> ok = False <TAB> if ok : <TAB> <TAB> print ( ""test_evname_in_mp_events_testcases: passed"" )",False,evname != args[0],not args[0],0.6629520654678345
|
||
|
1994,"def split_curve ( curve, splits, rescale = False ) : <TAB> if hasattr ( curve, ""split_at"" ) : <TAB> <TAB> result = [ ] <TAB> <TAB> for split in splits : <TAB> <TAB> <TAB> head, tail = curve. split_at ( split ) <TAB> <TAB> <TAB> if rescale : <TAB> <TAB> <TAB> <TAB> head = reparametrize_curve ( head, 0, 1 ) <TAB> <TAB> <TAB> result. append ( head ) <TAB> <TAB> <TAB> curve = tail <TAB> <TAB> if rescale : <TAB> <TAB> <TAB> tail = reparametrize_curve ( tail, 0, 1 ) <TAB> <TAB> result. append ( tail ) <TAB> <TAB> return result <TAB> else : <TAB> <TAB> t_min, t_max = curve. get_u_bounds ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> splits. insert ( 0, t_min ) <TAB> <TAB> if splits [ - 1 ]!= t_max : <TAB> <TAB> <TAB> splits. append ( t_max ) <TAB> <TAB> pairs = zip ( splits, splits [ 1 : ] ) <TAB> <TAB> result = [ ] <TAB> <TAB> for start, end in pairs : <TAB> <TAB> <TAB> segment = SvCurveSegment ( curve, start, end, rescale ) <TAB> <TAB> <TAB> result. append ( segment ) <TAB> <TAB> return result",False,splits[0] != t_min,t_min != t_max,0.663965106010437
|
||
|
1995,"def _ensure_header_written ( self, datasize ) : <TAB> if not self. _headerwritten : <TAB> <TAB> if not self. _nchannels : <TAB> <TAB> <TAB> raise Error ( ""# channels not specified"" ) <TAB> <TAB> if not self. _sampwidth : <TAB> <TAB> <TAB> raise Error ( ""sample width not specified"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise Error ( ""sampling rate not specified"" ) <TAB> <TAB> self. _write_header ( datasize )",False,not self._framerate,not self._samprate,0.6710440516471863
|
||
|
1996,"def backend_supported ( module, manager, ** kwargs ) : <TAB> if CollectionNodeModule. backend_supported ( module, manager, ** kwargs ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return True <TAB> <TAB> conn = manager. connection ( did = kwargs [ ""did"" ] ) <TAB> <TAB> template_path = ""partitions/sql/{0}/#{0}#{1}#"". format ( <TAB> <TAB> <TAB> manager. server_type, manager. version <TAB> <TAB> ) <TAB> <TAB> SQL = render_template ( <TAB> <TAB> <TAB> ""/"". join ( [ template_path, ""backend_support.sql"" ] ), tid = kwargs [ ""tid"" ] <TAB> <TAB> ) <TAB> <TAB> status, res = conn. execute_scalar ( SQL ) <TAB> <TAB> <TAB> <TAB> if not status : <TAB> <TAB> <TAB> return internal_server_error ( errormsg = res ) <TAB> <TAB> return res",False,'tid' not in kwargs,not kwargs,0.6611295938491821
|
||
|
1997,"def getTTGlyphList ( font ) : <TAB> if isinstance ( font, str ) : <TAB> <TAB> font = ttLib. TTFont ( font ) <TAB> if not ""cmap"" in font : <TAB> <TAB> raise Exception ( ""missing cmap table"" ) <TAB> gl = { } <TAB> bestCodeSubTable = None <TAB> bestCodeSubTableFormat = 0 <TAB> for st in font [ ""cmap"" ]. tables : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if st. format > bestCodeSubTableFormat : <TAB> <TAB> <TAB> <TAB> bestCodeSubTable = st <TAB> <TAB> <TAB> <TAB> bestCodeSubTableFormat = st. format <TAB> if bestCodeSubTable is not None : <TAB> <TAB> for cp, glyphname in bestCodeSubTable. cmap. items ( ) : <TAB> <TAB> <TAB> if glyphname in gl : <TAB> <TAB> <TAB> <TAB> gl [ glyphname ]. append ( cp ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> gl [ glyphname ] = [ cp ] <TAB> return gl, font",False,st.platformID == 0,st.format > bestCodeSubTableFormat,0.6589378118515015
|
||
|
1998,"def get_type_and_shape ( cls, bitmap ) : <TAB> w = _FI. FreeImage_GetWidth ( bitmap ) <TAB> h = _FI. FreeImage_GetHeight ( bitmap ) <TAB> fi_type = _FI. FreeImage_GetImageType ( bitmap ) <TAB> if not fi_type : <TAB> <TAB> raise ValueError ( ""mahotas.freeimage: unknown image pixel type"" ) <TAB> dtype = cls. dtypes [ fi_type ] <TAB> if fi_type == cls. FIT_BITMAP : <TAB> <TAB> bpp = _FI. FreeImage_GetBPP ( bitmap ) <TAB> <TAB> if bpp == 1 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return ""bit"", None <TAB> <TAB> elif bpp == 8 : <TAB> <TAB> <TAB> extra_dims = [ ] <TAB> <TAB> elif bpp == 16 : <TAB> <TAB> <TAB> extra_dims = [ ] <TAB> <TAB> <TAB> dtype = np. uint16 <TAB> <TAB> elif bpp == 24 : <TAB> <TAB> <TAB> extra_dims = [ 3 ] <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> extra_dims = [ 4 ] <TAB> <TAB> else : <TAB> <TAB> <TAB> raise ValueError ( ""mahotas.freeimage: cannot convert %d BPP bitmap"" % bpp ) <TAB> else : <TAB> <TAB> extra_dims = cls. extra_dims [ fi_type ] <TAB> return np. dtype ( dtype ), extra_dims + [ w, h ]",True,bpp == 32,bpp == 32,0.6772236824035645
|
||
|
1999,"def Decorator ( * args, ** kwargs ) : <TAB> delay = 0.2 <TAB> num_attempts = 15 <TAB> cur_attempt = 0 <TAB> while True : <TAB> <TAB> try : <TAB> <TAB> <TAB> return f ( * args, ** kwargs ) <TAB> <TAB> except exceptions. WebDriverException as e : <TAB> <TAB> <TAB> logging. warning ( ""Selenium raised %s"", utils. SmartUnicode ( e ) ) <TAB> <TAB> <TAB> cur_attempt += 1 <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise <TAB> <TAB> <TAB> time. sleep ( delay )",False,cur_attempt == num_attempts,cur_attempt > num_attempts,0.6543393135070801
|
||
|
2000,"def cleanLinks ( self, links ) : <TAB> returnLinks = dict ( ) <TAB> for link in links : <TAB> <TAB> linkBase = self. sf. urlBaseUrl ( link ) <TAB> <TAB> linkFQDN = self. sf. urlFQDN ( link ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> if self. opts [ ""nosubs"" ] and not self. getTarget ( ). matches ( <TAB> <TAB> <TAB> linkFQDN, includeChildren = False <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> if not self. getTarget ( ). matches ( linkFQDN, includeParents = False ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> if self. opts [ ""filterusers"" ] and ""/~"" in link : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> if linkBase in self. robotsRules and self. opts [ ""robotsonly"" ] : <TAB> <TAB> <TAB> if list ( <TAB> <TAB> <TAB> <TAB> filter ( <TAB> <TAB> <TAB> <TAB> <TAB> lambda blocked : type ( blocked ). lower ( blocked ) in link. lower ( ) <TAB> <TAB> <TAB> <TAB> <TAB> or blocked == ""*"", <TAB> <TAB> <TAB> <TAB> <TAB> self. robotsRules [ linkBase ], <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> self. sf. debug ( ""Adding URL for spidering: "" + link ) <TAB> <TAB> returnLinks [ link ] = links [ link ] <TAB> return returnLinks",False,not self.getTarget().matches(linkFQDN),linkBase in self.opts,0.6576526165008545
|
||
|
2001,"def subscriptions_cancel ( s_id ) : <TAB> os. system ( ""sudo chown admin:admin {0}"". format ( SUBSCRIPTIONS_FILE ) ) <TAB> subs = toml. load ( SUBSCRIPTIONS_FILE ) <TAB> new_list = [ ] <TAB> removed_cert = None <TAB> for idx, sub in enumerate ( subs [ ""subscriptions_letsencrypt"" ] ) : <TAB> <TAB> if sub [ ""id"" ]!= s_id : <TAB> <TAB> <TAB> new_list. append ( sub ) <TAB> <TAB> else : <TAB> <TAB> <TAB> removed_cert = sub <TAB> subs [ ""subscriptions_letsencrypt"" ] = new_list <TAB> <TAB> if removed_cert : <TAB> <TAB> acme_result = subprocess. Popen ( <TAB> <TAB> <TAB> [ <TAB> <TAB> <TAB> <TAB> ""/home/admin/config.scripts/bonus.letsencrypt.sh"", <TAB> <TAB> <TAB> <TAB> ""remove-cert"", <TAB> <TAB> <TAB> <TAB> removed_cert [ ""id"" ], <TAB> <TAB> <TAB> <TAB> removed_cert [ ""target"" ], <TAB> <TAB> <TAB> ], <TAB> <TAB> <TAB> stdout = subprocess. PIPE, <TAB> <TAB> <TAB> stderr = subprocess. STDOUT, <TAB> <TAB> <TAB> encoding = ""utf8"", <TAB> <TAB> ) <TAB> <TAB> out, err = acme_result. communicate ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> time. sleep ( 6 ) <TAB> <TAB> <TAB> raise BlitzError ( ""letsencrypt acme failed"", out ) <TAB> <TAB> with open ( SUBSCRIPTIONS_FILE, ""w"" ) as writer : <TAB> <TAB> writer. write ( toml. dumps ( subs ) ) <TAB> <TAB> writer. close ( ) <TAB> print ( json. dumps ( subs, indent = 2 ) )",False,out.find('error=') > -1,err,0.6472088098526001
|
||
|
2002,"def nq ( t ) : <TAB> p = t [ 0 ] if ( t and t [ 0 ] in ""-+"" ) else """" <TAB> t = t [ len ( p ) : ] <TAB> if t. startswith ( ""tag:"" ) or t. startswith ( ""in:"" ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> raw_tag = session. config. get_tag ( t. split ( "":"" ) [ 1 ] ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> t = ""in:%s"" % raw_tag. slug <TAB> <TAB> except ( IndexError, KeyError, TypeError ) : <TAB> <TAB> <TAB> pass <TAB> return p + t",False,raw_tag and raw_tag.hasattr(slug),raw_tag,0.6510717272758484
|
||
|
2003,"def nodes_action ( self, action, node_id, username, ** kwargs ) : <TAB> if not self. has_node ( node_id ) : <TAB> <TAB> message = ""node[node_id={node_id}] not found in task[task_id={task_id}]"". format ( <TAB> <TAB> <TAB> node_id = node_id, task_id = self. id <TAB> <TAB> ) <TAB> <TAB> return { ""result"" : False, ""message"" : message } <TAB> if action not in NODE_ACTIONS : <TAB> <TAB> return { ""result"" : False, ""message"" : ""task action is invalid"" } <TAB> try : <TAB> <TAB> if action == ""callback"" : <TAB> <TAB> <TAB> action_result = NODE_ACTIONS [ action ] ( node_id, kwargs [ ""data"" ] ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> action_result = NODE_ACTIONS [ action ] ( node_id, kwargs [ ""flow_id"" ] ) <TAB> <TAB> elif action == ""retry"" : <TAB> <TAB> <TAB> action_result = NODE_ACTIONS [ action ] ( node_id, kwargs [ ""inputs"" ] ) <TAB> <TAB> elif action == ""forced_fail"" : <TAB> <TAB> <TAB> action_result = NODE_ACTIONS [ action ] ( <TAB> <TAB> <TAB> <TAB> node_id, ex_data = ""forced fail by {}"". format ( username ) <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> action_result = NODE_ACTIONS [ action ] ( node_id ) <TAB> except Exception as e : <TAB> <TAB> message = ""task[id=%s] node[id=%s] action failed:%s"" % ( self. id, node_id, e ) <TAB> <TAB> logger. exception ( traceback. format_exc ( ) ) <TAB> <TAB> return { ""result"" : False, ""message"" : message } <TAB> if action_result. result : <TAB> <TAB> return { ""result""",False,action == 'skip_exg',action == 'flow',0.6521509885787964
|
||
|
2004,"def execute ( self, quals, columns ) : <TAB> gc. collect ( ) <TAB> result = [ ] <TAB> for obj in gc. get_objects ( ) : <TAB> <TAB> tobj = type ( obj ) <TAB> <TAB> if isinstance ( obj, bytes ) : <TAB> <TAB> <TAB> obj = obj. decode ( ""utf8"" ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> pass <TAB> <TAB> else : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> obj = bytes ( obj ). decode ( ""utf8"" ) <TAB> <TAB> <TAB> except ( UnicodeEncodeError, UnicodeDecodeError ) : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> obj = unicode_ ( obj ) <TAB> <TAB> <TAB> <TAB> except ( UnicodeEncodeError, UnicodeDecodeError ) : <TAB> <TAB> <TAB> <TAB> <TAB> obj = unicode_ ( ""<NA>"" ) <TAB> <TAB> result. append ( <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> ""object"" : obj, <TAB> <TAB> <TAB> <TAB> ""type"" : unicode_ ( tobj ), <TAB> <TAB> <TAB> <TAB> ""id"" : unicode_ ( id ( obj ) ), <TAB> <TAB> <TAB> <TAB> ""refcount"" : unicode_ ( sys. getrefcount ( obj ) ), <TAB> <TAB> <TAB> } <TAB> <TAB> ) <TAB> return result",False,"isinstance(obj, unicode_)","isinstance(obj, six.string_types)",0.6486866474151611
|
||
|
2005,"def events_eventId ( dbsession, request_inputs, eventId ) : <TAB> user_auth = request_inputs [ ""auth"" ] <TAB> method = request_inputs [ ""method"" ] <TAB> params = request_inputs [ ""params"" ] <TAB> userId = request_inputs [ ""userId"" ] <TAB> return_object = { } <TAB> httpcode = 500 <TAB> try : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> ret = db_events. get_byevent_id ( <TAB> <TAB> <TAB> <TAB> userId = userId, eventId = eventId, session = dbsession <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if not ret : <TAB> <TAB> <TAB> <TAB> httpcode = 404 <TAB> <TAB> <TAB> <TAB> raise Exception ( ""Event not found"" ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> return_object = ret <TAB> <TAB> <TAB> <TAB> httpcode = 200 <TAB> <TAB> elif method == ""DELETE"" : <TAB> <TAB> <TAB> ret = db_events. delete_byevent_id ( <TAB> <TAB> <TAB> <TAB> userId = userId, eventId = eventId, session = dbsession <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if not ret : <TAB> <TAB> <TAB> <TAB> httpcode = 404 <TAB> <TAB> <TAB> <TAB> raise Exception ( ""Event not found"" ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> return_object = True <TAB> <TAB> <TAB> <TAB> httpcode = 200 <TAB> except Exception as err : <TAB> <TAB> return_object = anchore_engine. common. helpers. make_response_error ( <TAB> <TAB> <TAB> err, in_httpcode = httpcode <TAB> <TAB> ) <TAB> return return_object, httpcode",True,method == 'GET',method == 'GET',0.6685078740119934
|
||
|
2006,"def get_all_topic_src_files ( self ) : <TAB> """"""Retrieves the file paths of all the topics in directory"""""" <TAB> topic_full_paths = [ ] <TAB> topic_names = os. listdir ( self. topic_dir ) <TAB> for topic_name in topic_names : <TAB> <TAB> <TAB> <TAB> if not topic_name. startswith ( ""."" ) : <TAB> <TAB> <TAB> topic_full_path = os. path. join ( self. topic_dir, topic_name ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> topic_full_paths. append ( topic_full_path ) <TAB> return topic_full_paths",False,topic_full_path != self.index_file,os.path.exists(topic_full_path),0.6495609283447266
|
||
|
2007,"def generate_primary_file ( self, dataset = None ) : <TAB> rval = [ ""<html><head><title>Spaln Database</title></head><p/>"" ] <TAB> rval. append ( <TAB> <TAB> ""<div>This composite dataset is composed of the following files:<p/><ul>"" <TAB> ) <TAB> for composite_name, composite_file in self. get_composite_files ( <TAB> <TAB> dataset = dataset <TAB> ). items ( ) : <TAB> <TAB> fn = composite_name <TAB> <TAB> opt_text = """" <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> rval. append ( <TAB> <TAB> <TAB> <TAB> '<li><a href=""%s"" type=""application/binary"">%s (%s)</a>%s</li>' <TAB> <TAB> <TAB> <TAB> % ( fn, fn, composite_file. get ( ""description"" ), opt_text ) <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> rval. append ( <TAB> <TAB> <TAB> <TAB> '<li><a href=""%s"" type=""application/binary"">%s</a>%s</li>' <TAB> <TAB> <TAB> <TAB> % ( fn, fn, opt_text ) <TAB> <TAB> <TAB> ) <TAB> rval. append ( ""</ul></div></html>"" ) <TAB> return ""\n"". join ( rval )",False,composite_file.get('description'),"hasattr(composite_file, 'get')",0.653140127658844
|
||
|
2008,"def _load ( self, name ) : <TAB> image_glob = os. path. join ( self. data_root, ""images"", name, ""*.jpg"" ) <TAB> image_files = glob. glob ( image_glob ) <TAB> gt_dir = os. path. join ( self. data_root, ""groundTruth"", name ) <TAB> self. data = np. zeros ( ( len ( image_files ), IMG_H, IMG_W, 3 ), dtype = ""uint8"" ) <TAB> self. label = np. zeros ( ( len ( image_files ), IMG_H, IMG_W ), dtype = ""float32"" ) <TAB> for idx, f in enumerate ( image_files ) : <TAB> <TAB> im = cv2. imread ( f, cv2. IMREAD_COLOR ) <TAB> <TAB> assert im is not None <TAB> <TAB> if im. shape [ 0 ] > im. shape [ 1 ] : <TAB> <TAB> <TAB> im = np. transpose ( im, ( 1, 0, 2 ) ) <TAB> <TAB> assert im. shape [ : 2 ] == ( IMG_H, IMG_W ), ""{}!= {}"". format ( <TAB> <TAB> <TAB> im. shape [ : 2 ], ( IMG_H, IMG_W ) <TAB> <TAB> ) <TAB> <TAB> imgid = os. path. basename ( f ). split ( ""."" ) [ 0 ] <TAB> <TAB> gt_file = os. path. join ( gt_dir, imgid ) <TAB> <TAB> gt = loadmat ( gt_file ) [ ""groundTruth"" ] [ 0 ] <TAB> <TAB> n_annot = gt. shape [ 0 ] <TAB> <TAB> gt = sum ( gt [ k ] [ ""Boundaries"" ] [ 0 ] [ 0 ] for k in range ( n_annot ) ) <TAB> <TAB> gt = gt. astype ( ""float32"" ) <TAB> <TAB> gt *= 1.0 / n_annot <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> gt = gt. transpose ( ) <TAB> <TAB> assert gt. shape == ( IMG_H,",False,gt.shape[0] > gt.shape[1],gt.shape[0] > 0,0.6514050960540771
|
||
|
2009,"def get_connection ( self ) : <TAB> if self. config. proxy_host!= """" : <TAB> <TAB> return httplib. HTTPConnection ( self. config. proxy_host, self. config. proxy_port ) <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return httplib. HTTPSConnection ( self. config. simpledb_host ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return httplib. HTTPConnection ( self. config. simpledb_host )",False,self.config.use_https,self.config.simpledb_host != '',0.6504498720169067
|
||
|
2010,"def __init__ ( self, fileobj ) : <TAB> """"""Raises MonkeysAudioHeaderError"""""" <TAB> header = fileobj. read ( 76 ) <TAB> if len ( header )!= 76 or not header. startswith ( b""MAC "" ) : <TAB> <TAB> raise MonkeysAudioHeaderError ( ""not a Monkey's Audio file"" ) <TAB> self. version = cdata. ushort_le ( header [ 4 : 6 ] ) <TAB> if self. version >= 3980 : <TAB> <TAB> ( <TAB> <TAB> <TAB> blocks_per_frame, <TAB> <TAB> <TAB> final_frame_blocks, <TAB> <TAB> <TAB> total_frames, <TAB> <TAB> <TAB> self. bits_per_sample, <TAB> <TAB> <TAB> self. channels, <TAB> <TAB> <TAB> self. sample_rate, <TAB> <TAB> ) = struct. unpack ( ""<IIIHHI"", header [ 56 : 76 ] ) <TAB> else : <TAB> <TAB> compression_level = cdata. ushort_le ( header [ 6 : 8 ] ) <TAB> <TAB> self. channels, self. sample_rate = struct. unpack ( ""<HI"", header [ 10 : 16 ] ) <TAB> <TAB> total_frames, final_frame_blocks = struct. unpack ( ""<II"", header [ 24 : 32 ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> blocks_per_frame = 73728 * 4 <TAB> <TAB> elif self. version >= 3900 or ( self. version >= 3800 and compression_level == 4 ) : <TAB> <TAB> <TAB> blocks_per_frame = 73728 <TAB> <TAB> else : <TAB> <TAB> <TAB> blocks_per_frame = 9216 <TAB> <TAB> self. bits_per_sample = 0 <TAB> <TAB> if header [ 48 : ]. startswith ( b""WAVEfmt"" ) : <TAB> <TAB> <TAB> self. bits_per_sample = struct. unpack ( ""<H"", header [ 74 : 76 ] ) [ 0 ] <TAB> self. version /= 1000.0 <TAB> self",False,self.version >= 3950,self.version >= 900,0.6752477884292603
|
||
|
2011,"def extract_line_count ( filename, target_dir ) : <TAB> <TAB> example_file = os. path. join ( target_dir, filename ) <TAB> if six. PY2 : <TAB> <TAB> lines = open ( example_file ). readlines ( ) <TAB> else : <TAB> <TAB> lines = open ( example_file, encoding = ""utf-8"" ). readlines ( ) <TAB> start_row = 0 <TAB> if lines and lines [ 0 ]. startswith ( ""#!"" ) : <TAB> <TAB> lines. pop ( 0 ) <TAB> <TAB> start_row = 1 <TAB> line_iterator = iter ( lines ) <TAB> tokens = tokenize. generate_tokens ( lambda : next ( line_iterator ) ) <TAB> check_docstring = True <TAB> erow_docstring = 0 <TAB> for tok_type, _, _, ( erow, _ ), _ in tokens : <TAB> <TAB> tok_type = token. tok_name [ tok_type ] <TAB> <TAB> if tok_type in ( ""NEWLINE"", ""COMMENT"", ""NL"", ""INDENT"", ""DEDENT"" ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> erow_docstring = erow <TAB> <TAB> <TAB> check_docstring = False <TAB> return erow_docstring + 1 + start_row, erow + 1 + start_row",False,tok_type == 'STRING' and check_docstring,check_docstring,0.6520117521286011
|
||
|
2012,"def init_errorhandler ( ) : <TAB> <TAB> for ex in default_exceptions : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> app. register_error_handler ( ex, error_http ) <TAB> <TAB> elif ex == 500 : <TAB> <TAB> <TAB> app. register_error_handler ( ex, internal_error ) <TAB> if services. ldap : <TAB> <TAB> <TAB> <TAB> @ app. errorhandler ( services. ldap. LDAPException ) <TAB> <TAB> def handle_exception ( e ) : <TAB> <TAB> <TAB> log. debug ( ""LDAP server not accessible while trying to login to opds feed"" ) <TAB> <TAB> <TAB> return error_http ( FailedDependency ( ) )",False,ex < 500,ex == 500,0.7078532576560974
|
||
|
2013,"def _process_checkpoint_store_for_checklist ( self ) : <TAB> config_commented_map : CommentedMap = self. data_context. get_config ( ). commented_map <TAB> checkpoint_store_name : Optional [ str ] = config_commented_map. get ( <TAB> <TAB> ""checkpoint_store_name"" <TAB> ) <TAB> stores : dict = config_commented_map [ ""stores"" ] <TAB> if checkpoint_store_name : <TAB> <TAB> if stores. get ( checkpoint_store_name ) : <TAB> <TAB> <TAB> self. upgrade_log [ ""skipped_upgrade"" ] = True <TAB> <TAB> else : <TAB> <TAB> <TAB> self. upgrade_checklist [ ""stores"" ] = { <TAB> <TAB> <TAB> <TAB> checkpoint_store_name : DataContextConfigDefaults. DEFAULT_STORES. value [ <TAB> <TAB> <TAB> <TAB> <TAB> DataContextConfigDefaults. DEFAULT_CHECKPOINT_STORE_NAME. value <TAB> <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> } <TAB> else : <TAB> <TAB> checkpoint_store_name = ( <TAB> <TAB> <TAB> DataContextConfigDefaults. DEFAULT_CHECKPOINT_STORE_NAME. value <TAB> <TAB> ) <TAB> <TAB> self. upgrade_checklist [ ""checkpoint_store_name"" ] = checkpoint_store_name <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. upgrade_checklist [ ""stores"" ] = { <TAB> <TAB> <TAB> <TAB> checkpoint_store_name : DataContextConfigDefaults. DEFAULT_STORES. value [ <TAB> <TAB> <TAB> <TAB> <TAB> checkpoint_store_name <TAB> <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> }",False,not stores.get(checkpoint_store_name),stores.get(checkpoint_store_name),0.6544827222824097
|
||
|
2014,"def TryMerge ( self, d ) : <TAB> while d. avail ( ) > 0 : <TAB> <TAB> tt = d. getVarInt32 ( ) <TAB> <TAB> if tt == 8 : <TAB> <TAB> <TAB> self. set_value ( 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.6846723556518555
|
||
|
2015,"def update_actions ( self, items, changed ) : <TAB> if len ( items ) > 0 : <TAB> <TAB> can_create = isinstance ( items [ 0 ], model. Folder ) and len ( items ) == 1 <TAB> <TAB> can_copy = True <TAB> <TAB> for item in items : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> can_copy = False <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> self. action_new_top_folder. setEnabled ( True ) <TAB> <TAB> self. action_new_sub_folder. setEnabled ( can_create ) <TAB> <TAB> self. action_new_phrase. setEnabled ( can_create ) <TAB> <TAB> self. action_new_script. setEnabled ( can_create ) <TAB> <TAB> self. action_copy_item. setEnabled ( can_copy ) <TAB> <TAB> self. action_clone_item. setEnabled ( can_copy ) <TAB> <TAB> self. action_paste_item. setEnabled ( <TAB> <TAB> <TAB> can_create and len ( self. central_widget. cutCopiedItems ) > 0 <TAB> <TAB> ) <TAB> <TAB> self. action_record_script. setEnabled ( <TAB> <TAB> <TAB> isinstance ( items [ 0 ], model. Script ) and len ( items ) == 1 <TAB> <TAB> ) <TAB> <TAB> self. action_run_script. setEnabled ( <TAB> <TAB> <TAB> isinstance ( items [ 0 ], model. Script ) and len ( items ) == 1 <TAB> <TAB> ) <TAB> <TAB> self. menu_insert_macros. setEnabled ( <TAB> <TAB> <TAB> isinstance ( items [ 0 ], model. Phrase ) and len ( items ) == 1 <TAB> <TAB> ) <TAB> <TAB> if changed : <TAB> <TAB> <TAB> self. action_save. setEnabled ( False ) <TAB> <TAB> <TAB> self. action_undo. setEnabled ( False ) <TAB> <TAB> <TAB> self. action_redo. setEnabled ( False )",True,"isinstance(item, model.Folder)","isinstance(item, model.Folder)",0.6504238247871399
|
||
|
2016,"def __str__ ( self ) : <TAB> <TAB> wires_print = lambda ob : ""'"". join ( map ( str, ob. wires. tolist ( ) ) ) <TAB> terms_ls = [ ] <TAB> for i, obs in enumerate ( self. ops ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> obs_strs = [ <TAB> <TAB> <TAB> <TAB> f""{OBS_MAP.get(ob.name, ob.name)}{wires_print(ob)}"" for ob in obs. obs <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> ob_str = "" "". join ( obs_strs ) <TAB> <TAB> elif isinstance ( obs, Observable ) : <TAB> <TAB> <TAB> ob_str = f""{OBS_MAP.get(obs.name, obs.name)}{wires_print(obs)}"" <TAB> <TAB> term_str = f""({self.coeffs[i]}) [{ob_str}]"" <TAB> <TAB> terms_ls. append ( term_str ) <TAB> return ""\n+ "". join ( terms_ls )",False,"isinstance(obs, Tensor)","isinstance(obs, Observable)",0.6577979326248169
|
||
|
2017,"def _moments ( <TAB> self, inputs : tf. Tensor, use_batch_stats : types. BoolLike ) -> Tuple [ tf. Tensor, tf. Tensor ] : <TAB> if use_batch_stats : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> mean = self. _fused_constant <TAB> <TAB> <TAB> variance = self. _fused_constant <TAB> <TAB> else : <TAB> <TAB> <TAB> mean, variance = tf. nn. moments ( inputs, self. _axis, keepdims = True ) <TAB> else : <TAB> <TAB> mean = self. moving_mean. value <TAB> <TAB> variance = self. moving_variance. value <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> mean = tf. squeeze ( mean, self. _axis ) <TAB> <TAB> <TAB> variance = tf. squeeze ( variance, self. _axis ) <TAB> return mean, variance",False,self._fused,self.moving_mean is None,0.6724948287010193
|
||
|
2018,"def show_message ( self, message, title = None, important = False, widget = None ) : <TAB> if important : <TAB> <TAB> dlg = Gtk. MessageDialog ( <TAB> <TAB> <TAB> self. main_window, <TAB> <TAB> <TAB> Gtk. DialogFlags. MODAL, <TAB> <TAB> <TAB> Gtk. MessageType. INFO, <TAB> <TAB> <TAB> Gtk. ButtonsType. OK, <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> dlg. set_title ( str ( title ) ) <TAB> <TAB> <TAB> dlg. set_markup ( <TAB> <TAB> <TAB> <TAB> '<span weight=""bold"" size=""larger"">%s</span>\n\n%s' % ( title, message ) <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> dlg. set_markup ( '<span weight=""bold"" size=""larger"">%s</span>' % ( message ) ) <TAB> <TAB> dlg. run ( ) <TAB> <TAB> dlg. destroy ( ) <TAB> else : <TAB> <TAB> gpodder. user_extensions. on_notification_show ( title, message )",True,title,title,0.707625150680542
|
||
|
2019,"def devices ( self ) : <TAB> """"""Wait for new DS4 devices to appear."""""" <TAB> context = Context ( ) <TAB> existing_devices = context. list_devices ( subsystem = ""hidraw"" ) <TAB> future_devices = self. _get_future_devices ( context ) <TAB> for hidraw_device in itertools. chain ( existing_devices, future_devices ) : <TAB> <TAB> hid_device = hidraw_device. parent <TAB> <TAB> if hid_device. subsystem!= ""hid"" : <TAB> <TAB> <TAB> continue <TAB> <TAB> cls = HID_DEVICES. get ( hid_device. get ( ""HID_NAME"" ) ) <TAB> <TAB> if not cls : <TAB> <TAB> <TAB> continue <TAB> <TAB> for child in hid_device. parent. children : <TAB> <TAB> <TAB> event_device = child. get ( ""DEVNAME"", """" ) <TAB> <TAB> <TAB> if event_device. startswith ( ""/dev/input/event"" ) : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> else : <TAB> <TAB> <TAB> continue <TAB> <TAB> try : <TAB> <TAB> <TAB> device_addr = hid_device. get ( ""HID_UNIQ"", """" ). upper ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> device_name = ""{0} {1}"". format ( device_addr, hidraw_device. sys_name ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> device_name = hidraw_device. sys_name <TAB> <TAB> <TAB> yield cls ( <TAB> <TAB> <TAB> <TAB> name = device_name, <TAB> <TAB> <TAB> <TAB> addr = device_addr, <TAB> <TAB> <TAB> <TAB> type = cls. __type__, <TAB> <TAB> <TAB> <TAB> hidraw_device = hidraw_device. device_node,",False,device_addr,device_addr and hidraw_device.sys_name,0.6695295572280884
|
||
|
2020,"def iterfieldselect ( source, field, where, complement, missing ) : <TAB> it = iter ( source ) <TAB> hdr = next ( it ) <TAB> yield tuple ( hdr ) <TAB> indices = asindices ( hdr, field ) <TAB> getv = operator. itemgetter ( * indices ) <TAB> for row in it : <TAB> <TAB> try : <TAB> <TAB> <TAB> v = getv ( row ) <TAB> <TAB> except IndexError : <TAB> <TAB> <TAB> v = missing <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> yield tuple ( row )",False,bool(where(v)) != complement,v != None and complement and (v != missing),0.6525516510009766
|
||
|
2021,"def test_connect ( <TAB> ipaddr, port, device, partition, method, path, headers = None, query_string = None ) : <TAB> if path == ""/a"" : <TAB> <TAB> for k, v in headers. iteritems ( ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> else : <TAB> <TAB> <TAB> test_errors. append ( ""%s: %s not in %s"" % ( test_header, test_value, headers ) )",False,k.lower() == test_header.lower() and v == test_value,test_header in v,0.6469519138336182
|
||
|
2022,"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. txn_high_water_mark = iprot. readI64 ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif fid == 2 : <TAB> <TAB> <TAB> if ftype == TType. SET : <TAB> <TAB> <TAB> <TAB> self. open_txns = set ( ) <TAB> <TAB> <TAB> <TAB> ( _etype416, _size413 ) = iprot. readSetBegin ( ) <TAB> <TAB> <TAB> <TAB> for _i417 in xrange ( _size413 ) : <TAB> <TAB> <TAB> <TAB> <TAB> _elem418 = iprot. readI64 ( ) <TAB> <TAB> <TAB> <TAB> <TAB> self. open_txns. add ( _elem418 ) <TAB> <TAB> <TAB> <TAB> iprot. readSetEnd ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif<mask> : <TAB>",True,fid == 3,fid == 3,0.6739218831062317
|
||
|
2023,"def _get_dbutils ( ) : <TAB> try : <TAB> <TAB> import IPython <TAB> <TAB> ip_shell = IPython. get_ipython ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise _NoDbutilsError <TAB> <TAB> return ip_shell. ns_table [ ""user_global"" ] [ ""dbutils"" ] <TAB> except ImportError : <TAB> <TAB> raise _NoDbutilsError <TAB> except KeyError : <TAB> <TAB> raise _NoDbutilsError",False,ip_shell is None,'user_global' not in ip_shell.ns_table,0.6661030054092407
|
||
|
2024,"def split_artists ( self, json ) : <TAB> if len ( json ) == 0 : <TAB> <TAB> ( [ ], [ ] ) <TAB> elif len ( json ) == 1 : <TAB> <TAB> artist = Artist. query. filter_by ( name = json [ 0 ] [ ""name"" ] ). first ( ) <TAB> <TAB> return ( [ artist ], [ ] ) <TAB> my_artists = [ ] <TAB> other_artists = [ ] <TAB> for artist_dict in json : <TAB> <TAB> artist = Artist. query. filter_by ( name = artist_dict [ ""name"" ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> my_artists. append ( artist. first ( ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> del artist_dict [ ""thumb_url"" ] <TAB> <TAB> <TAB> other_artists. append ( artist_dict ) <TAB> return ( my_artists, other_artists )",False,artist.count(),artist.first(),0.6635749340057373
|
||
|
2025,"def _get_image ( self, image_list, source ) : <TAB> if source. startswith ( ""wx"" ) : <TAB> <TAB> img = wx. ArtProvider_GetBitmap ( source, wx. ART_OTHER, _SIZE ) <TAB> else : <TAB> <TAB> path = os. path. join ( _BASE, source ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> img = wx. Image ( path, wx. BITMAP_TYPE_GIF ). ConvertToBitmap ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> img = wx. Image ( path, wx. BITMAP_TYPE_PNG ). ConvertToBitmap ( ) <TAB> return image_list. Add ( img )",False,source.endswith('gif'),os.path.isdir(path),0.6591418981552124
|
||
|
2026,"def _load_windows_store_certs ( self, storename, purpose ) : <TAB> certs = bytearray ( ) <TAB> try : <TAB> <TAB> for cert, encoding, trust in enum_certificates ( storename ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> if trust is True or purpose. oid in trust : <TAB> <TAB> <TAB> <TAB> <TAB> certs. extend ( cert ) <TAB> except OSError : <TAB> <TAB> warnings. warn ( ""unable to enumerate Windows certificate store"" ) <TAB> if certs : <TAB> <TAB> self. load_verify_locations ( cadata = certs ) <TAB> return certs",False,encoding == 'x509_asn',encoding.oid == 'windows',0.6530070304870605
|
||
|
2027,"def process ( self ) : <TAB> objects = self. inputs [ ""Object"" ]. sv_get ( ) <TAB> if not objects : <TAB> <TAB> return <TAB> include_vertex = self. outputs [ ""Vertex Mask"" ]. is_linked <TAB> include_edges = self. outputs [ ""Edge Mask"" ]. is_linked <TAB> include_faces = self. outputs [ ""Face Mask"" ]. is_linked <TAB> face_mask, edge_mask, vertex_mask = [ ], [ ], [ ] <TAB> get_selected_from = lambda data : [ i. select for i in data ] <TAB> for obj in objects : <TAB> <TAB> mesh = obj. data <TAB> <TAB> if obj == bpy. context. edit_object : <TAB> <TAB> <TAB> bm = bmesh. from_edit_mesh ( mesh ) <TAB> <TAB> <TAB> face_data = bm. faces <TAB> <TAB> <TAB> edge_data = bm. edges <TAB> <TAB> <TAB> vertex_data = bm. verts <TAB> <TAB> else : <TAB> <TAB> <TAB> face_data = mesh. polygons <TAB> <TAB> <TAB> edge_data = mesh. edges <TAB> <TAB> <TAB> vertex_data = mesh. vertices <TAB> <TAB> if include_faces : <TAB> <TAB> <TAB> face_mask. append ( get_selected_from ( face_data ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> edge_mask. append ( get_selected_from ( edge_data ) ) <TAB> <TAB> if include_vertex : <TAB> <TAB> <TAB> vertex_mask. append ( get_selected_from ( vertex_data ) ) <TAB> self. outputs [ ""Vertex Mask"" ]. sv_set ( vertex_mask ) <TAB> self. outputs [ ""Edge Mask"" ]. sv_set ( edge_mask ) <TAB> self. outputs [ ""Face Mask"" ]. sv_set ( face_mask )",True,include_edges,include_edges,0.6661674380302429
|
||
|
2028,"def PyMemoryView_GetContiguous ( obj, buffertype, order_int ) : <TAB> PyBUF_READ = 0x100 <TAB> PyBUF_WRITE = 0x200 <TAB> assert buffertype == PyBUF_READ or buffertype == PyBUF_WRITE <TAB> order = chr ( order_int ) <TAB> assert order == ""C"" or order == ""F"" or order == ""A"" <TAB> mv = memoryview ( obj ) <TAB> release = True <TAB> try : <TAB> <TAB> if buffertype == PyBUF_WRITE and mv. readonly : <TAB> <TAB> <TAB> raise BufferError ( ""underlying buffer is not writable"" ) <TAB> <TAB> if mv. contiguous : <TAB> <TAB> <TAB> release = False <TAB> <TAB> <TAB> return mv <TAB> <TAB> if buffertype == PyBUF_WRITE : <TAB> <TAB> <TAB> raise BufferError ( <TAB> <TAB> <TAB> <TAB> ""writable contiguous buffer requested for a non-contiguous object."" <TAB> <TAB> <TAB> ) <TAB> <TAB> mv_bytes = memoryview ( mv. tobytes ( order ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return mv_bytes <TAB> <TAB> else : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> return mv_bytes. cast ( mv. format ) <TAB> <TAB> <TAB> finally : <TAB> <TAB> <TAB> <TAB> mv_bytes. release ( ) <TAB> finally : <TAB> <TAB> if release : <TAB> <TAB> <TAB> mv. release ( )",False,mv.format == 'B',mv.format is None,0.656246542930603
|
||
|
2029,"def monitor_filter ( self ) : <TAB> """"""Return filtered running container objects list"""""" <TAB> running_containers = self. running_filter ( ) <TAB> monitored_containers = [ ] <TAB> for container in running_containers : <TAB> <TAB> ouro_label = container. labels. get ( ""com.ouroboros.enable"", False ) <TAB> <TAB> <TAB> <TAB> if self. config. label_enable and ouro_label : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> monitored_containers. append ( container ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> elif not self. config. labels_only : <TAB> <TAB> <TAB> if self. config. monitor : <TAB> <TAB> <TAB> <TAB> if ( <TAB> <TAB> <TAB> <TAB> <TAB> container. name in self. config. monitor <TAB> <TAB> <TAB> <TAB> <TAB> and container. name not in self. config. ignore <TAB> <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> <TAB> monitored_containers. append ( container ) <TAB> <TAB> <TAB> elif container. name not in self. config. ignore : <TAB> <TAB> <TAB> <TAB> monitored_containers. append ( container ) <TAB> self. data_manager. monitored_containers [ self. socket ] = len ( monitored_containers ) <TAB> self. data_manager. set ( self. socket ) <TAB> return monitored_containers",False,"ouro_label.lower() in ['true', 'yes']",self.config.test_mode,0.6508021950721741
|
||
|
2030,"def get_source ( self, fullname = None ) : <TAB> fullname = self. _fix_name ( fullname ) <TAB> if self. source is None : <TAB> <TAB> mod_type = self. etc [ 2 ] <TAB> <TAB> if mod_type == imp. PY_SOURCE : <TAB> <TAB> <TAB> self. _reopen ( ) <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> self. source = self. file. read ( ) <TAB> <TAB> <TAB> finally : <TAB> <TAB> <TAB> <TAB> self. file. close ( ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> if os. path. exists ( self. filename [ : - 1 ] ) : <TAB> <TAB> <TAB> <TAB> f = open ( self. filename [ : - 1 ], ""rU"" ) <TAB> <TAB> <TAB> <TAB> self. source = f. read ( ) <TAB> <TAB> <TAB> <TAB> f. close ( ) <TAB> <TAB> elif mod_type == imp. PKG_DIRECTORY : <TAB> <TAB> <TAB> self. source = self. _get_delegate ( ). get_source ( ) <TAB> return self. source",False,mod_type == imp.PY_COMPILED,mod_type == imp.FILE_FILE,0.6570153832435608
|
||
|
2031,"def scan_address ( ip_address, ** kwargs ) : <TAB> snmp_name = kwargs. get ( ""snmp_name"", """" ) or """" <TAB> http_family = kwargs. get ( ""http_family"", """" ) or """" <TAB> if ""nx-os"" in snmp_name. lower ( ) : <TAB> <TAB> raise NoMatchError ( ""Incompatible Nexus found."" ) <TAB> if ""xen"" not in snmp_name and ""xen"" not in http_family. lower ( ) : <TAB> <TAB> raise NoMatchError ( ""XEN not found."" ) <TAB> auths = SETTINGS. get ( ""xen_auths"" ) <TAB> messages = [ ] <TAB> result = get_base_result_template ( ""ssh_xen"", messages ) <TAB> if not auths : <TAB> <TAB> result [ ""status"" ] = ""error"" <TAB> <TAB> messages. append ( <TAB> <TAB> <TAB> ""Not configured. Set XEN_AUTHS in your configuration file."", <TAB> <TAB> ) <TAB> else : <TAB> <TAB> for user, password in auths : <TAB> <TAB> <TAB> if user is None or password is None : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> ssh = _connect_ssh ( ip_address, user, password ) <TAB> <TAB> <TAB> except AuthError : <TAB> <TAB> <TAB> <TAB> ssh = None <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> result [ ""status"" ] = ""error"" <TAB> <TAB> <TAB> messages. append ( ""Authorization failed."" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> device_info = _ssh_xen ( ssh, ip_address ) <TAB> <TAB> <TAB> except ( Error,",False,not ssh,ssh is None,0.6746110320091248
|
||
|
2032,"def get_location ( device ) : <TAB> location = [ ] <TAB> node = device <TAB> while node : <TAB> <TAB> position = node. get_position ( ) or """" <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> position = "" [%s]"" % position <TAB> <TAB> location. append ( node. name + position ) <TAB> <TAB> node = node. parent <TAB> return "" / "". join ( reversed ( location ) )",True,position,position,0.6921048760414124
|
||
|
2033,"def _analyze ( self ) : <TAB> region = self. _region. recursive_copy ( ) <TAB> <TAB> parent_map = { } <TAB> stack = [ region ] <TAB> while stack : <TAB> <TAB> current_region = stack [ - 1 ] <TAB> <TAB> has_region = False <TAB> <TAB> for node in networkx. dfs_postorder_nodes ( <TAB> <TAB> <TAB> current_region. graph, current_region. head <TAB> <TAB> ) : <TAB> <TAB> <TAB> subnodes = [ ] <TAB> <TAB> <TAB> if type ( node ) is GraphRegion : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> subnodes. append ( node ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> subnodes. insert ( 0, node ) <TAB> <TAB> <TAB> <TAB> parent_map [ node ] = current_region <TAB> <TAB> <TAB> <TAB> has_region = True <TAB> <TAB> <TAB> stack. extend ( subnodes ) <TAB> <TAB> if not has_region : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> stack. pop ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> parent_region = parent_map. get ( current_region, None ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> st = self. project. analyses. Structurer ( <TAB> <TAB> <TAB> <TAB> current_region, <TAB> <TAB> <TAB> <TAB> parent_map = parent_map, <TAB> <TAB> <TAB> <TAB> condition_processor = self. cond_proc, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if not parent_region : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. result = st. result <TAB> <TAB",False,node.cyclic,has_region,0.6726874709129333
|
||
|
2034,"def _expect_success ( self, config, name = ""block"" ) : <TAB> if not self. fails : <TAB> <TAB> return <TAB> for fail in self. fails : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> break <TAB> else : <TAB> <TAB> raise AssertionError ( <TAB> <TAB> <TAB> ""Unexpected success for '%s' (%s)"" <TAB> <TAB> <TAB> % ( name, "" and "". join ( fail. _as_string ( config ) for fail in self. fails ) ) <TAB> <TAB> )",False,not fail(config),fail.fail_code == 0,0.6516794562339783
|
||
|
2035,"def test_mix_alloc_dealloc5_3_7 ( ) : <TAB> allocs = mixed_alloc_dealloc_list ( [ 5, 3, 7 ], count = 50 ) <TAB> capacity = sum ( [ a for a in allocs if a > 0 ] ) <TAB> allocator = RegionAllocator ( capacity ) <TAB> regions = [ ] <TAB> for alloc in allocs : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> regions. append ( allocator. alloc ( alloc ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> region = regions [ abs ( alloc ) ] <TAB> <TAB> <TAB> allocator. dealloc ( region ) <TAB> assert allocator. get_free_size ( ) == allocator. capacity",False,alloc > 0,count > 10,0.6734553575515747
|
||
|
2036,"def __save_ledger_entry_as_je ( self, ledger_entry, quickbooks_id ) : <TAB> try : <TAB> <TAB> accounts = [ ] <TAB> <TAB> for line in ledger_entry [ ""lines"" ] : <TAB> <TAB> <TAB> account_line = { <TAB> <TAB> <TAB> <TAB> ""account"" : line [ ""account"" ], <TAB> <TAB> <TAB> <TAB> ""cost_center"" : self. default_cost_center, <TAB> <TAB> <TAB> } <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> account_line [ ""credit_in_account_currency"" ] = line [ ""credit"" ] <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> account_line [ ""debit_in_account_currency"" ] = line [ ""debit"" ] <TAB> <TAB> <TAB> accounts. append ( account_line ) <TAB> <TAB> posting_date = ledger_entry [ ""date"" ] <TAB> <TAB> self. __save_journal_entry ( quickbooks_id, accounts, posting_date ) <TAB> except Exception as e : <TAB> <TAB> self. _log_error ( e, ledger_entry )",False,line['credit'],"isinstance(line, dict)",0.6667290925979614
|
||
|
2037,def stimulus ( ) : <TAB> stopped. next = 0 <TAB> yield delay ( 10 ) <TAB> exp = intbv ( 0 ) [ W : ] <TAB> val = intbv ( 0 ) [ W : ] <TAB> random_word = intbv ( 0 ) [ 32 : ] <TAB> random_word [ : ] = 93 <TAB> for i in range ( 2 ** 18 ) : <TAB> <TAB> exp [ : ] = 0 <TAB> <TAB> for s in range ( L ) : <TAB> <TAB> <TAB> random_word [ : ] = glibc_random ( random_word ) <TAB> <TAB> <TAB> val [ : ] = random_word [ W : ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> exp [ : ] = val <TAB> <TAB> <TAB> a [ s ]. next = val <TAB> <TAB> yield clock. negedge <TAB> <TAB> assert z == exp <TAB> stopped. next = 1 <TAB> yield delay ( 10 ),False,exp < val,s == 0,0.6713956594467163
|
||
|
2038,"def __init__ ( self, coverage ) : <TAB> self. coverage = coverage <TAB> self. config = self. coverage. config <TAB> self. source_paths = set ( ) <TAB> if self. config. source : <TAB> <TAB> for src in self. config. source : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> if not self. config. relative_files : <TAB> <TAB> <TAB> <TAB> <TAB> src = files. canonical_filename ( src ) <TAB> <TAB> <TAB> <TAB> self. source_paths. add ( src ) <TAB> self. packages = { } <TAB> self. xml_out = None",False,os.path.exists(src),src and src.endswith('.git'),0.6563808917999268
|
||
|
2039,"def _parse_tag_specifications ( self, spec ) : <TAB> try : <TAB> <TAB> tag_spec_num = max ( <TAB> <TAB> <TAB> [ <TAB> <TAB> <TAB> <TAB> int ( key. split ( ""."" ) [ 1 ] ) <TAB> <TAB> <TAB> <TAB> for key in spec <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> ] <TAB> <TAB> ) <TAB> except ValueError : <TAB> <TAB> return { } <TAB> tag_specifications = { } <TAB> for si in range ( 1, tag_spec_num + 1 ) : <TAB> <TAB> resource_type = spec [ ""tag_specification_set.{si}._resource_type"". format ( si = si ) ] <TAB> <TAB> tags = [ <TAB> <TAB> <TAB> key <TAB> <TAB> <TAB> for key in spec <TAB> <TAB> <TAB> if key. startswith ( ""tag_specification_set.{si}._tag"". format ( si = si ) ) <TAB> <TAB> ] <TAB> <TAB> tag_num = max ( [ int ( key. split ( ""."" ) [ 3 ] ) for key in tags ] ) <TAB> <TAB> tag_specifications [ resource_type ] = dict ( <TAB> <TAB> <TAB> ( <TAB> <TAB> <TAB> <TAB> spec [ ""tag_specification_set.{si}._tag.{ti}._key"". format ( si = si, ti = ti ) ], <TAB> <TAB> <TAB> <TAB> spec [ <TAB> <TAB> <TAB> <TAB> <TAB> ""tag_specification_set.{si}._tag.{ti}._value"". format ( si = si, ti = ti ) <TAB> <TAB> <TAB> <TAB> ], <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> for ti in range ( 1, tag_num + 1 ) <TAB> <TAB> ) <TAB> return tag_specifications",False,key.startswith('tag_specification_set'),tag_spec_num == 0,0.6500779390335083
|
||
|
2040,"def _build_index ( self ) : <TAB> self. _index = { } <TAB> for start_char, sorted_offsets in self. _offsets. items ( ) : <TAB> <TAB> self. _index [ start_char ] = { } <TAB> <TAB> for i, offset in enumerate ( sorted_offsets. get_offsets ( ) ) : <TAB> <TAB> <TAB> identifier = sorted_offsets. get_identifier_by_offset ( offset ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. _index [ start_char ] [ identifier [ 0 : self. index_depth ] ] = i",False,identifier[0:self.index_depth] not in self._index[start_char],identifier[self.index_depth] > 0,0.6565222144126892
|
||
|
2041,"def custom_generator ( use_weights = False ) : <TAB> batch_size = 10 <TAB> n_samples = 50 <TAB> while True : <TAB> <TAB> batch_index = np. random. randint ( 0, n_samples - batch_size ) <TAB> <TAB> start = batch_index <TAB> <TAB> end = start + batch_size <TAB> <TAB> X = arr_data [ start : end ] <TAB> <TAB> y = arr_labels [ start : end ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> w = arr_weights [ start : end ] <TAB> <TAB> <TAB> yield X, y, w <TAB> <TAB> else : <TAB> <TAB> <TAB> yield X, y",True,use_weights,use_weights,0.6656997203826904
|
||
|
2042,"def _output_step ( step_input_def, step_output_def ) : <TAB> multiple = False <TAB> if step_input_def in [ ""dataset"", ""dataset_multiple"" ] : <TAB> <TAB> input_type = ""dataset"" <TAB> <TAB> collection_types = None <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> multiple = True <TAB> else : <TAB> <TAB> input_type = ""dataset_collection"" <TAB> <TAB> collection_types = ( <TAB> <TAB> <TAB> step_input_def if isinstance ( step_input_def, list ) else [ step_input_def ] <TAB> <TAB> ) <TAB> output = { ""name"" : ""output"", ""extensions"" : [ ""data"" ] } <TAB> if step_output_def!= ""dataset"" : <TAB> <TAB> output [ ""collection"" ] = True <TAB> <TAB> output [ ""collection_type"" ] = step_output_def <TAB> input_connection_input = [ <TAB> <TAB> { ""id"" : 0, ""output_name"" : ""output"", ""input_type"" : input_type } <TAB> ] <TAB> if step_input_def == ""dataset"" : <TAB> <TAB> <TAB> <TAB> input_connection_input = input_connection_input [ 0 ] <TAB> return { <TAB> <TAB> ""id"" : 1, <TAB> <TAB> ""type"" : ""tool"", <TAB> <TAB> ""inputs"" : [ <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> ""name"" : ""input"", <TAB> <TAB> <TAB> <TAB> ""multiple"" : multiple, <TAB> <TAB> <TAB> <TAB> ""input_type"" : input_type, <TAB> <TAB> <TAB> <TAB> ""collection_types"" : collection_types, <TAB> <TAB> <TAB> <TAB> ""extensions"" : [ ""data"" ], <TAB> <TAB> <TAB> } <TAB> <TAB> ], <TAB> <TAB> ""input_connections"" : { """,False,step_input_def == 'dataset_multiple',step_input_def == 'multiple',0.6507815718650818
|
||
|
2043,"def test_set_get_priority ( self ) : <TAB> base = os. getpriority ( os. PRIO_PROCESS, os. getpid ( ) ) <TAB> os. setpriority ( os. PRIO_PROCESS, os. getpid ( ), base + 1 ) <TAB> try : <TAB> <TAB> new_prio = os. getpriority ( os. PRIO_PROCESS, os. getpid ( ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise unittest. SkipTest ( <TAB> <TAB> <TAB> <TAB> ""unable to reliably test setpriority "" <TAB> <TAB> <TAB> <TAB> ""at current nice level of %s"" % base <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. assertEqual ( new_prio, base + 1 ) <TAB> finally : <TAB> <TAB> try : <TAB> <TAB> <TAB> os. setpriority ( os. PRIO_PROCESS, os. getpid ( ), base ) <TAB> <TAB> except OSError as err : <TAB> <TAB> <TAB> if err. errno!= errno. EACCES : <TAB> <TAB> <TAB> <TAB> raise",False,base >= 19 and new_prio <= 19,"new_prio == os.getpriority(os.PRIO_PROCESS, os.getpid(base))",0.6617233753204346
|
||
|
2044,"def convert_to_py2 ( ) : <TAB> global PY2_CONVERTED <TAB> if ""+"" not in version : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return <TAB> if source_dir == ""python2_source"" and not PY2_CONVERTED : <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> subprocess. check_output ( [ ""3to2"", ""--help"" ] ) <TAB> <TAB> <TAB> subprocess. check_output ( [ ""pasteurize"", ""--help"" ] ) <TAB> <TAB> except OSError as e : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise <TAB> <TAB> <TAB> if not os. path. exists ( os. path. join ( source_dir, ""pylatex"" ) ) : <TAB> <TAB> <TAB> <TAB> raise ImportError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""3to2 and future need to be installed "" <TAB> <TAB> <TAB> <TAB> <TAB> ""before installing when PyLaTeX for Python "" <TAB> <TAB> <TAB> <TAB> <TAB> ""2.7 when it is not installed using one of "" <TAB> <TAB> <TAB> <TAB> <TAB> ""the pip releases."" <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> converter = ( <TAB> <TAB> <TAB> <TAB> os. path. dirname ( os. path. realpath ( __file__ ) ) + ""/convert_to_py2.sh"" <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> subprocess. check_call ( [ converter ] ) <TAB> <TAB> <TAB> PY2_CONVERTED = True",False,e.errno != errno.ENOENT,e.args[0] != 0,0.6606593132019043
|
||
|
2045,"def __handle_death_before_start ( self, args ) : <TAB> <TAB> if self. _exc_info is None and self. dead : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if len ( args ) == 1 : <TAB> <TAB> <TAB> arg = args [ 0 ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> args = ( arg, arg ( ), None ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> args = ( type ( arg ), arg, None ) <TAB> <TAB> elif not args : <TAB> <TAB> <TAB> args = ( GreenletExit, GreenletExit ( ), None ) <TAB> <TAB> assert issubclass ( args [ 0 ], BaseException ) <TAB> <TAB> self. __report_error ( args )",False,"issubclass(arg, BaseException)",callable(arg),0.6623687744140625
|
||
|
2046,"def check_for_elastic_ip ( ec2_info ) : <TAB> <TAB> elastic_ips = [ ] <TAB> for region in ec2_info [ ""regions"" ] : <TAB> <TAB> if ""elastic_ips"" in ec2_info [ ""regions"" ] [ region ] : <TAB> <TAB> <TAB> for eip in ec2_info [ ""regions"" ] [ region ] [ ""elastic_ips"" ] : <TAB> <TAB> <TAB> <TAB> elastic_ips. append ( eip ) <TAB> new_items = [ ] <TAB> new_macro_items = [ ] <TAB> for i, item in enumerate ( <TAB> <TAB> ec2_info [ ""violations"" ] [ ""non-elastic-ec2-public-ip-whitelisted"" ]. items <TAB> ) : <TAB> <TAB> ip = netaddr. IPNetwork ( item ) <TAB> <TAB> found = False <TAB> <TAB> for eip in elastic_ips : <TAB> <TAB> <TAB> eip = netaddr. IPNetwork ( eip ) <TAB> <TAB> <TAB> if ip in eip : <TAB> <TAB> <TAB> <TAB> found = True <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> new_items. append ( <TAB> <TAB> <TAB> <TAB> ec2_info [ ""violations"" ] [ ""non-elastic-ec2-public-ip-whitelisted"" ]. items [ i ] <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> new_macro_items. append ( <TAB> <TAB> <TAB> <TAB> ec2_info [ ""violations"" ] [ <TAB> <TAB> <TAB> <TAB> <TAB> ""non-elastic-ec2-public-ip-whitelisted"" <TAB> <TAB> <TAB> <TAB> ]. macro_items [ i ] <TAB> <TAB> <TAB> ) <TAB> ec2_info [ ""violations"" ] [ ""non-elastic-ec2-public-ip-whitelisted"" ]",False,not found,found,0.6775128245353699
|
||
|
2047,"def testTokenProcessMetadata ( self ) : <TAB> from music21. abcFormat import testFiles <TAB> <TAB> for ( tf, titleEncoded, meterEncoded, keyEncoded ) in [ <TAB> <TAB> ( testFiles. fyrareprisarn, ""Fyrareprisarn"", ""3/4"", ""F"" ), <TAB> <TAB> ( testFiles. mysteryReel, ""Mystery Reel"", ""C|"", ""G"" ), <TAB> <TAB> ( <TAB> <TAB> <TAB> testFiles. aleIsDear, <TAB> <TAB> <TAB> ""Ale is Dear, The"", <TAB> <TAB> <TAB> ""4/4"", <TAB> <TAB> <TAB> ""D"", <TAB> <TAB> ), <TAB> <TAB> ( testFiles. kitchGirl, ""Kitchen Girl"", ""4/4"", ""D"" ), <TAB> <TAB> ( testFiles. williamAndNancy, ""William and Nancy"", ""6/8"", ""G"" ), <TAB> ] : <TAB> <TAB> handler = ABCHandler ( ) <TAB> <TAB> handler. tokenize ( tf ) <TAB> <TAB> handler. tokenProcess ( ) <TAB> <TAB> tokens = handler. tokens <TAB> <TAB> for t in tokens : <TAB> <TAB> <TAB> if isinstance ( t, ABCMetadata ) : <TAB> <TAB> <TAB> <TAB> if t. tag == ""T"" : <TAB> <TAB> <TAB> <TAB> <TAB> self. assertEqual ( t. data, titleEncoded ) <TAB> <TAB> <TAB> <TAB> elif t. tag == ""M"" : <TAB> <TAB> <TAB> <TAB> <TAB> self. assertEqual ( t. data, meterEncoded ) <TAB> <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> self. assertEqual ( t. data, keyEncoded )",True,t.tag == 'K',t.tag == 'K',0.658808708190918
|
||
|
2048,"def _to_group_name ( self, field ) : <TAB> <TAB> <TAB> group = field. replace ( ""."", ""_"" ). replace ( ""["", ""_"" ). replace ( ""]"", ""_"" ) <TAB> <TAB> n = 1 <TAB> while group in self. _group_to_name_map : <TAB> <TAB> n += 1 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> group = field. replace ( ""."", ""_"" * n ) <TAB> <TAB> elif ""_"" in field : <TAB> <TAB> <TAB> group = field. replace ( ""_"", ""_"" * n ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise KeyError ( ""duplicated group name %r"" % ( field, ) ) <TAB> <TAB> self. _group_to_name_map [ group ] = field <TAB> self. _name_to_group_map [ field ] = group <TAB> return group",False,'.' in field,'' in field,0.6703853011131287
|
||
|
2049,"def _build_for_eval ( self, ds ) : <TAB> ds. name = ""eval"" <TAB> program = F. Program ( ) <TAB> startup_prog = F. Program ( ) <TAB> with F. program_guard ( program, startup_prog ) : <TAB> <TAB> <TAB> <TAB> log. info ( ""Building Eval Graph"" ) <TAB> <TAB> fea = ds. features ( ) <TAB> <TAB> fea = unflatten ( fea, ds. data_schema ) <TAB> <TAB> model_spec = _build_net ( <TAB> <TAB> <TAB> self. model_fn, fea, RunMode. EVAL, self. params, self. run_config <TAB> <TAB> ) <TAB> <TAB> log. info ( ""Done"" ) <TAB> <TAB> <TAB> optimizer_ops = { ""sgd"", ""adam"", ""adagrad"" } <TAB> for op in program. global_block ( ). ops : <TAB> <TAB> if op. type == ""dropout"" : <TAB> <TAB> <TAB> op. _set_attr ( ""is_test"", True ) <TAB> <TAB> if op. type == ""batch_norm"" : <TAB> <TAB> <TAB> op. _set_attr ( ""is_test"", True ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise RuntimeError ( ""Found optimizer op in eval graph, op: %s"" % repr ( op ) ) <TAB> log. info ( <TAB> <TAB> ""Eval with: \n> Run_config: %s\n> Params: %s\n> Train_model_spec: %s\n"" <TAB> <TAB> % ( repr ( self. run_config ), repr ( self. params ), repr ( model_spec ) ) <TAB> ) <TAB> return ProgramPair ( train_program = program, startup_program = startup_prog ), model_spec",False,op.type in optimizer_ops,op.type == 'eval_graph',0.6562021970748901
|
||
|
2050,"def create_unix_server ( <TAB> self, protocol_factory, path = None, *, sock = None, backlog = 100, ssl = None ) : <TAB> if isinstance ( ssl, bool ) : <TAB> <TAB> raise TypeError ( ""ssl argument must be an SSLContext or None"" ) <TAB> if path is not None : <TAB> <TAB> if sock is not None : <TAB> <TAB> <TAB> raise ValueError ( ""path and sock can not be specified at the same time"" ) <TAB> <TAB> sock = socket. socket ( socket. AF_UNIX, socket. SOCK_STREAM ) <TAB> <TAB> try : <TAB> <TAB> <TAB> sock. bind ( path ) <TAB> <TAB> except OSError as exc : <TAB> <TAB> <TAB> sock. close ( ) <TAB> <TAB> <TAB> if exc. errno == errno. EADDRINUSE : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> msg = ""Address {!r} is already in use"". format ( path ) <TAB> <TAB> <TAB> <TAB> raise OSError ( errno. EADDRINUSE, msg ) from None <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> raise <TAB> <TAB> except : <TAB> <TAB> <TAB> sock. close ( ) <TAB> <TAB> <TAB> raise <TAB> else : <TAB> <TAB> if sock is None : <TAB> <TAB> <TAB> raise ValueError ( ""path was not specified, and no sock specified"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( ""A UNIX Domain Socket was expected, got {!r}"". format ( sock ) ) <TAB> server = base_events. Server ( self, [ sock ] ) <TAB> sock. listen ( backlog ) <TAB> sock. setblocking ( False ) <TAB> self. _start_serving ( protocol_factory, sock, ssl, server ) <TAB> return server",False,sock.family != socket.AF_UNIX,sock is None,0.6491050124168396
|
||
|
2051,"def test_fvalue ( self ) : <TAB> if not getattr ( self, ""skip_f"", False ) : <TAB> <TAB> rtol = getattr ( self, ""rtol"", 1e-10 ) <TAB> <TAB> assert_allclose ( self. res1. fvalue, self. res2. F, rtol = rtol ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> assert_allclose ( self. res1. f_pvalue, self. res2. Fp, rtol = rtol ) <TAB> else : <TAB> <TAB> raise pytest. skip ( ""TODO: document why this test is skipped"" )",False,"hasattr(self.res2, 'Fp')","getattr(self, 'skip_pvalue', False)",0.6479915976524353
|
||
|
2052,"def can_delete ( conn, vol, path ) : <TAB> """"""Is the passed path even deleteable"""""" <TAB> ret = True <TAB> msg = None <TAB> if vol : <TAB> <TAB> <TAB> <TAB> if vol. get_pool ( ). get_type ( ) == virtinst. Storage. StoragePool. TYPE_ISCSI : <TAB> <TAB> <TAB> msg = _ ( ""Cannot delete iscsi share."" ) <TAB> else : <TAB> <TAB> if conn. is_remote ( ) : <TAB> <TAB> <TAB> msg = _ ( ""Cannot delete unmanaged remote storage."" ) <TAB> <TAB> elif not os. path. exists ( path ) : <TAB> <TAB> <TAB> msg = _ ( ""Path does not exist."" ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> msg = _ ( ""No write access to parent directory."" ) <TAB> <TAB> elif stat. S_ISBLK ( os. stat ( path ) [ stat. ST_MODE ] ) : <TAB> <TAB> <TAB> msg = _ ( ""Cannot delete unmanaged block device."" ) <TAB> if msg : <TAB> <TAB> ret = False <TAB> return ( ret, msg )",False,"not os.access(os.path.dirname(path), os.W_OK)",not os.path.isdir(path),0.6497271656990051
|
||
|
2053,"def __print_receiver ( self, package, receiver, prefix, include_intent_filters = False ) : <TAB> self. stdout. write ( ""%s%s\n"" % ( prefix, receiver. name ) ) <TAB> if include_intent_filters : <TAB> <TAB> intent_filters = self. find_intent_filters ( receiver, ""receiver"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> for intent_filter in intent_filters : <TAB> <TAB> <TAB> <TAB> self. stdout. write ( ""%s Intent Filter:\n"" % ( prefix ) ) <TAB> <TAB> <TAB> <TAB> if len ( intent_filter. actions ) > 0 : <TAB> <TAB> <TAB> <TAB> <TAB> self. stdout. write ( ""%s Actions:\n"" % ( prefix ) ) <TAB> <TAB> <TAB> <TAB> <TAB> for action in intent_filter. actions : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. stdout. write ( ""%s - %s\n"" % ( prefix, action ) ) <TAB> <TAB> <TAB> <TAB> if len ( intent_filter. categories ) > 0 : <TAB> <TAB> <TAB> <TAB> <TAB> self. stdout. write ( ""%s Categories:\n"" % ( prefix ) ) <TAB> <TAB> <TAB> <TAB> <TAB> for category in intent_filter. categories : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. stdout. write ( ""%s - %s\n"" % ( prefix, category ) ) <TAB> <TAB> <TAB> <TAB> if len ( intent_filter. datas ) > 0 : <TAB> <TAB> <TAB> <TAB> <TAB> self. stdout. write ( ""%s Data:\n"" % ( prefix ) ) <TAB> <TAB> <TAB> <TAB> <TAB> for data in intent_filter. datas : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. stdout. write ( ""%s - %s\n"" % ( prefix, data ) ) <TAB> self",False,len(intent_filters) > 0,intent_filters,0.6563029289245605
|
||
|
2054,"def filter_out_test_code ( file_handle ) : <TAB> found_test_code = False <TAB> for line in file_handle. readlines ( ) : <TAB> <TAB> if line. startswith ( "".. testcode:"" ) : <TAB> <TAB> <TAB> found_test_code = True <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if line. startswith ( "" "" ) : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> empty_line = line. strip ( ) <TAB> <TAB> <TAB> <TAB> if len ( empty_line ) == 0 : <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> found_test_code = False <TAB> <TAB> <TAB> <TAB> <TAB> yield line <TAB> <TAB> else : <TAB> <TAB> <TAB> for keyword in [ ""|version|"", ""|today|"" ] : <TAB> <TAB> <TAB> <TAB> if keyword in line : <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> yield line",False,found_test_code is True,found_test_code,0.6561294794082642
|
||
|
2055,"def dataspec ( config ) : <TAB> master = yield fakemaster. make_master ( ) <TAB> data = connector. DataConnector ( ) <TAB> data. setServiceParent ( master ) <TAB> if config [ ""out"" ]!= ""--"" : <TAB> <TAB> dirs = os. path. dirname ( config [ ""out"" ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> os. makedirs ( dirs ) <TAB> <TAB> f = open ( config [ ""out"" ], ""w"" ) <TAB> else : <TAB> <TAB> f = sys. stdout <TAB> if config [ ""global"" ] is not None : <TAB> <TAB> f. write ( ""window."" + config [ ""global"" ] + ""="" ) <TAB> f. write ( json. dumps ( data. allEndpoints ( ), indent = 2 ) ) <TAB> f. close ( ) <TAB> defer. returnValue ( 0 )",False,dirs and (not os.path.exists(dirs)),not os.path.exists(dirs),0.6531575918197632
|
||
|
2056,"def _condition ( ct ) : <TAB> for qobj in args : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for child in qobj. children : <TAB> <TAB> <TAB> <TAB> kwargs. update ( dict ( [ child ] ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise NotImplementedError ( ""Unsupported Q object"" ) <TAB> for attr, val in kwargs. items ( ) : <TAB> <TAB> if getattr ( ct, attr )!= val : <TAB> <TAB> <TAB> return False <TAB> return True",False,qobj.connector == 'AND' and (not qobj.negated),"isinstance(qobj, QObject)",0.6548824310302734
|
||
|
2057,"def get_filtering ( self ) : <TAB> """"""Return filering as a dict for submissions queryset"""""" <TAB> self. select_date_form = SelectDateForm ( self. request. GET ) <TAB> result = dict ( ) <TAB> if self. select_date_form. is_valid ( ) : <TAB> <TAB> date_from = self. select_date_form. cleaned_data. get ( ""date_from"" ) <TAB> <TAB> date_to = self. select_date_form. cleaned_data. get ( ""date_to"" ) <TAB> <TAB> if date_to : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> date_to += datetime. timedelta ( days = 1 ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> result [ ""submit_time__range"" ] = [ date_from, date_to ] <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> result [ ""submit_time__lte"" ] = date_to <TAB> <TAB> el if<mask> : <TAB> <TAB> <TAB> result [ ""submit_time__gte"" ] = date_from <TAB> return result",False,date_from,self.request.POST,0.660735547542572
|
||
|
2058,"def test_bgr2hls ( ) : <TAB> in_img = np. random. rand ( 10, 10, 3 ). astype ( np. float32 ) <TAB> out_img = mmcv. bgr2hls ( in_img ) <TAB> argmax = in_img. argmax ( axis = 2 ) <TAB> computed_hls = np. empty_like ( in_img ) <TAB> for i in range ( in_img. shape [ 0 ] ) : <TAB> <TAB> for j in range ( in_img. shape [ 1 ] ) : <TAB> <TAB> <TAB> b, g, r = in_img [ i, j ] <TAB> <TAB> <TAB> maxc = max ( r, g, b ) <TAB> <TAB> <TAB> minc = min ( r, g, b ) <TAB> <TAB> <TAB> _l = ( minc + maxc ) / 2.0 <TAB> <TAB> <TAB> if minc == maxc : <TAB> <TAB> <TAB> <TAB> h = 0.0 <TAB> <TAB> <TAB> <TAB> s = 0.0 <TAB> <TAB> <TAB> if _l <= 0.5 : <TAB> <TAB> <TAB> <TAB> s = ( maxc - minc ) / ( maxc + minc ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> s = ( maxc - minc ) / ( 2.0 - maxc - minc ) <TAB> <TAB> <TAB> if argmax [ i, j ] == 2 : <TAB> <TAB> <TAB> <TAB> h = 60 * ( g - b ) / ( maxc - minc ) <TAB> <TAB> <TAB> elif argmax [ i, j ] == 1 : <TAB> <TAB> <TAB> <TAB> h = 60 * ( 2.0 + ( b - r ) / ( maxc - minc ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> h = 60 * ( 4.0 + ( r - g ) / ( maxc - minc ) ) <TAB> <TAB>",False,h < 0,np.random.random() < 0.6,0.67082279920578
|
||
|
2059,"def _fixture_setup ( self ) : <TAB> for db_name in self. _databases_names ( include_mirrors = False ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _reset_sequences ( db_name ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if self. serialized_rollback and hasattr ( <TAB> <TAB> <TAB> connections [ db_name ], ""_test_serialized_contents"" <TAB> <TAB> ) : <TAB> <TAB> <TAB> if self. available_apps is not None : <TAB> <TAB> <TAB> <TAB> apps. unset_available_apps ( ) <TAB> <TAB> <TAB> connections [ db_name ]. creation. deserialize_db_from_string ( <TAB> <TAB> <TAB> <TAB> connections [ db_name ]. _test_serialized_contents <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if self. available_apps is not None : <TAB> <TAB> <TAB> <TAB> apps. set_available_apps ( self. available_apps ) <TAB> <TAB> if self. fixtures : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> call_command ( <TAB> <TAB> <TAB> <TAB> ""loaddata"", * self. fixtures, ** { ""verbosity"" : 0, ""database"" : db_name } <TAB> <TAB> <TAB> )",False,self.reset_sequences,self.has_sequences,0.6590416431427002
|
||
|
2060,"def _parse_json_track ( self, json ) : <TAB> formats = [ ] <TAB> file_ = json. get ( ""file"" ) <TAB> if isinstance ( file_, dict ) : <TAB> <TAB> for format_id, format_url in file_. items ( ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> ext, abr_str = format_id. split ( ""-"", 1 ) <TAB> <TAB> <TAB> formats. append ( <TAB> <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> <TAB> ""format_id"" : format_id, <TAB> <TAB> <TAB> <TAB> <TAB> ""url"" : self. _proto_relative_url ( format_url, ""http:"" ), <TAB> <TAB> <TAB> <TAB> <TAB> ""ext"" : ext, <TAB> <TAB> <TAB> <TAB> <TAB> ""vcodec"" : ""none"", <TAB> <TAB> <TAB> <TAB> <TAB> ""acodec"" : ext, <TAB> <TAB> <TAB> <TAB> <TAB> ""abr"" : int_or_none ( abr_str ), <TAB> <TAB> <TAB> <TAB> } <TAB> <TAB> <TAB> ) <TAB> return { <TAB> <TAB> ""duration"" : float_or_none ( json. get ( ""duration"" ) ), <TAB> <TAB> ""id"" : str_or_none ( json. get ( ""track_id"" ) or json. get ( ""id"" ) ), <TAB> <TAB> ""title"" : json. get ( ""title"" ), <TAB> <TAB> ""title_link"" : json. get ( ""title_link"" ), <TAB> <TAB> ""number"" : int_or_none ( json. get ( ""track_num"" ) ), <TAB> <TAB> ""formats"" : formats, <TAB> }",False,not url_or_none(format_url),format_url is None,0.6458032131195068
|
||
|
2061,"def _indent ( self, row, step ) : <TAB> line, level, bullet = self [ row ] <TAB> self. _indent_row ( row, step ) <TAB> if row == 0 : <TAB> <TAB> <TAB> <TAB> for i in range ( 1, len ( self ) ) : <TAB> <TAB> <TAB> if self [ i ] [ self. INDENT_COL ] >= level : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _indent_row ( i, step ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> break <TAB> else : <TAB> <TAB> <TAB> <TAB> for i in range ( row + 1, len ( self ) ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. _indent_row ( i, step ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. buffer. renumber_list_after_indent ( line, level )",False,self[i][self.INDENT_COL] > level,bullet,0.6587383151054382
|
||
|
2062,"def process_style_box ( self, options ) : <TAB> if self. has_form ( ""StyleBox"", 1, None ) : <TAB> <TAB> rules = self. _leaves [ 1 : ] <TAB> <TAB> for rule in rules : <TAB> <TAB> <TAB> if rule. has_form ( ""Rule"", 2 ) : <TAB> <TAB> <TAB> <TAB> name = rule. _leaves [ 0 ]. get_name ( ) <TAB> <TAB> <TAB> <TAB> value = rule. _leaves [ 1 ] <TAB> <TAB> <TAB> <TAB> if name == ""System`ShowStringCharacters"" : <TAB> <TAB> <TAB> <TAB> <TAB> value = value. is_true ( ) <TAB> <TAB> <TAB> <TAB> <TAB> options = options. copy ( ) <TAB> <TAB> <TAB> <TAB> <TAB> options [ ""show_string_characters"" ] = value <TAB> <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> if value. has_form ( ""List"", 2 ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> m1 = value. _leaves [ 0 ]. round_to_float ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> m2 = value. _leaves [ 1 ]. round_to_float ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if m1 is not None and m2 is not None : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> options = options. copy ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> options [ ""image_size_multipliers"" ] = ( m1, m2 ) <TAB> <TAB> return True, options <TAB> else : <TAB> <TAB> return False, options",False,name == 'System`ImageSizeMultipliers',"has_form('List', 1)",0.6658504009246826
|
||
|
2063,"def add_actors ( self ) : <TAB> """"""Adds `self.actors` to the scene."""""" <TAB> if not self. _actors_added : <TAB> <TAB> self. reader. render_window = self. scene. render_window <TAB> <TAB> self. _update_reader ( ) <TAB> <TAB> self. _actors_added = True <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _visible_changed ( self. visible ) <TAB> <TAB> self. scene. render ( )",False,not self.visible,self.visible is not None,0.6624195575714111
|
||
|
2064,"def file_fetch ( fh, fromTime, untilTime, now = None, archiveToSelect = None ) : <TAB> header = __readHeader ( fh ) <TAB> if now is None : <TAB> <TAB> now = int ( time. time ( ) ) <TAB> if untilTime is None : <TAB> <TAB> untilTime = now <TAB> fromTime = int ( fromTime ) <TAB> untilTime = int ( untilTime ) <TAB> <TAB> <TAB> <TAB> if fromTime > untilTime : <TAB> <TAB> raise InvalidTimeInterval ( <TAB> <TAB> <TAB> ""Invalid time interval: from time '%s' is after until time '%s'"" <TAB> <TAB> <TAB> % ( fromTime, untilTime ) <TAB> <TAB> ) <TAB> oldestTime = now - header [ ""maxRetention"" ] <TAB> <TAB> if fromTime > now : <TAB> <TAB> return None <TAB> <TAB> if untilTime < oldestTime : <TAB> <TAB> return None <TAB> <TAB> if fromTime < oldestTime : <TAB> <TAB> fromTime = oldestTime <TAB> <TAB> if untilTime > now : <TAB> <TAB> untilTime = now <TAB> diff = now - fromTime <TAB> <TAB> if archiveToSelect : <TAB> <TAB> retentionStr = str ( archiveToSelect ) + "":1"" <TAB> <TAB> archiveToSelect = parseRetentionDef ( retentionStr ) [ 0 ] <TAB> for archive in header [ ""archives"" ] : <TAB> <TAB> if archiveToSelect : <TAB> <TAB> <TAB> if archive [ ""secondsPerPoint"" ] == archiveToSelect : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> archive = None <TAB> <TAB> else : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> break <TAB> if archiveToSelect and not archive : <TAB> <TAB> raise ValueError ( ""Invalid granularity: %s"" % ( archiveToSelect ) ) <TAB> return __archive_fetch ( fh, archive, fromTime, untilTime )",False,archive['retention'] >= diff,not archive,0.6581726670265198
|
||
|
2065,"def get_operation_order_from_stack ( state ) : <TAB> stack_items = list ( reversed ( stack ( ) ) ) <TAB> <TAB> if state. current_deploy_filename : <TAB> <TAB> for i, stack_item in enumerate ( stack_items ) : <TAB> <TAB> <TAB> frame = getframeinfo ( stack_item [ 0 ] ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> break <TAB> else : <TAB> <TAB> i = 0 <TAB> <TAB> line_numbers = [ ] <TAB> for stack_item in stack_items [ i : ] : <TAB> <TAB> frame = getframeinfo ( stack_item [ 0 ] ) <TAB> <TAB> if frame. filename. startswith ( PYINFRA_API_DIR ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> if state. loop_filename and frame. filename == state. loop_filename : <TAB> <TAB> <TAB> line_numbers. extend ( [ state. loop_line, state. loop_counter ] ) <TAB> <TAB> line_numbers. append ( frame. lineno ) <TAB> del stack_items <TAB> return line_numbers",False,frame.filename == state.current_deploy_filename,frame.filename.startswith(PYINFRA_API_DIR),0.6496627330780029
|
||
|
2066,"def parseXmlNode ( node ) : <TAB> for element in node. findall ( ""boundary"" ) : <TAB> <TAB> boundary = AttribDict ( ) <TAB> <TAB> for child in element : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> values = cleanupVals ( child. text, child. tag ) <TAB> <TAB> <TAB> <TAB> boundary [ child. tag ] = values <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> boundary [ child. tag ] = None <TAB> <TAB> conf. boundaries. append ( boundary ) <TAB> for element in node. findall ( ""test"" ) : <TAB> <TAB> test = AttribDict ( ) <TAB> <TAB> for child in element : <TAB> <TAB> <TAB> if child. text and child. text. strip ( ) : <TAB> <TAB> <TAB> <TAB> values = cleanupVals ( child. text, child. tag ) <TAB> <TAB> <TAB> <TAB> test [ child. tag ] = values <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> if len ( child. findall ( ""*"" ) ) == 0 : <TAB> <TAB> <TAB> <TAB> <TAB> test [ child. tag ] = None <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> test [ child. tag ] = AttribDict ( ) <TAB> <TAB> <TAB> <TAB> for gchild in child : <TAB> <TAB> <TAB> <TAB> <TAB> if gchild. tag in test [ child. tag ] : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> prevtext = test [ child. tag ] [ gchild. tag ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> test [ child. tag ] [ gchild. tag ] = [ prevtext, gchild. text ] <TAB> <TAB> <TAB> <TAB> <TAB> else : <TAB>",False,child.text,child.tag == 'con',0.6656943559646606
|
||
|
2067,"def usgs_eros ( self, scene, path ) : <TAB> """"""Downloads the image from USGS"""""" <TAB> <TAB> if self. usgs_user and self. usgs_pass : <TAB> <TAB> try : <TAB> <TAB> <TAB> api_key = api. login ( self. usgs_user, self. usgs_pass ) <TAB> <TAB> except USGSError as e : <TAB> <TAB> <TAB> error_tree = ElementTree. fromstring ( str ( e. message ) ) <TAB> <TAB> <TAB> error_text = error_tree. find ( <TAB> <TAB> <TAB> <TAB> ""SOAP-ENV:Body/SOAP-ENV:Fault/faultstring"", api. NAMESPACES <TAB> <TAB> <TAB> ). text <TAB> <TAB> <TAB> raise USGSInventoryAccessMissing ( error_text ) <TAB> <TAB> download_url = api. download ( ""LANDSAT_8"", ""EE"", [ scene ], api_key = api_key ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. output ( ""Source: USGS EarthExplorer"", normal = True, arrow = True ) <TAB> <TAB> <TAB> return self. fetch ( download_url [ 0 ], path ) <TAB> <TAB> raise RemoteFileDoesntExist ( <TAB> <TAB> <TAB> ""%s is not available on AWS S3, Google or USGS Earth Explorer"" % scene <TAB> <TAB> ) <TAB> raise RemoteFileDoesntExist ( <TAB> <TAB> ""%s is not available on AWS S3 or Google Storage"" % scene <TAB> )",True,download_url,download_url,0.6673058271408081
|
||
|
2068,"def _unbyte ( d ) : <TAB> if d is None : <TAB> <TAB> return <TAB> for k, v in list ( d. items ( ) ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> del d [ k ] <TAB> <TAB> <TAB> d [ k. decode ( ""utf8"" ) ] = v <TAB> <TAB> if isinstance ( v, dict ) : <TAB> <TAB> <TAB> _unbyte ( v ) <TAB> for k, v in d. items ( ) : <TAB> <TAB> if isinstance ( v, ( list, tuple ) ) : <TAB> <TAB> <TAB> l = [ ] <TAB> <TAB> <TAB> for sub in v : <TAB> <TAB> <TAB> <TAB> if isinstance ( sub, dict ) : <TAB> <TAB> <TAB> <TAB> <TAB> l. append ( _unbyte ( sub ) ) <TAB> <TAB> <TAB> <TAB> elif isinstance ( sub, bytes ) : <TAB> <TAB> <TAB> <TAB> <TAB> l. append ( sub. decode ( ""utf8"" ) ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> l. append ( sub ) <TAB> <TAB> <TAB> d [ k ] = tuple ( l ) <TAB> <TAB> elif isinstance ( v, bytes ) : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> d [ k ] = v. decode ( ""utf8"" ) <TAB> <TAB> <TAB> except UnicodeDecodeError : <TAB> <TAB> <TAB> <TAB> d [ k ] = v <TAB> return d",False,"isinstance(k, bytes)",k in d,0.6499552726745605
|
||
|
2069,"def generateRandomConfigurations ( parser, randomizer ) : <TAB> <TAB> while True : <TAB> <TAB> randomArgs = randomizer. getRandomSubset ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> randomArgs. append ( ""--run-with-valgrind"" ) <TAB> <TAB> build_options = parser. parse_args ( randomArgs ) <TAB> <TAB> if areArgsValid ( build_options ) [ 0 ] : <TAB> <TAB> <TAB> build_options. build_options_str = "" "". join ( <TAB> <TAB> <TAB> <TAB> randomArgs <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> build_options. enableRandom = ( <TAB> <TAB> <TAB> <TAB> True <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> return build_options",False,'--build-with-valgrind' in randomArgs and chance(0.95),len(randomArgs) > 0,0.6532500982284546
|
||
|
2070,"def _get_activity ( self, request, group, num ) : <TAB> activity_items = set ( ) <TAB> activity = [ ] <TAB> activity_qs = ( <TAB> <TAB> Activity. objects. filter ( <TAB> <TAB> <TAB> group = group, <TAB> <TAB> ) <TAB> <TAB>. order_by ( ""-datetime"" ) <TAB> <TAB>. select_related ( ""user"" ) <TAB> ) <TAB> <TAB> for item in activity_qs [ : num * 2 ] : <TAB> <TAB> sig = ( item. type, item. ident, item. user_id ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> activity. append ( item ) <TAB> <TAB> elif sig not in activity_items : <TAB> <TAB> <TAB> activity_items. add ( sig ) <TAB> <TAB> <TAB> activity. append ( item ) <TAB> activity. append ( <TAB> <TAB> Activity ( <TAB> <TAB> <TAB> project = group. project, <TAB> <TAB> <TAB> group = group, <TAB> <TAB> <TAB> type = Activity. FIRST_SEEN, <TAB> <TAB> <TAB> datetime = group. first_seen, <TAB> <TAB> ) <TAB> ) <TAB> return activity [ : num ]",False,item.type == Activity.NOTE,sig == -datetime,0.6628049612045288
|
||
|
2071,def _exitfunc ( cls ) : <TAB> <TAB> <TAB> <TAB> reenable_gc = False <TAB> try : <TAB> <TAB> if cls. _registry : <TAB> <TAB> <TAB> import gc <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> reenable_gc = True <TAB> <TAB> <TAB> <TAB> gc. disable ( ) <TAB> <TAB> <TAB> pending = None <TAB> <TAB> <TAB> while True : <TAB> <TAB> <TAB> <TAB> if pending is None or finalize. _dirty : <TAB> <TAB> <TAB> <TAB> <TAB> pending = cls. _select_for_exit ( ) <TAB> <TAB> <TAB> <TAB> <TAB> finalize. _dirty = False <TAB> <TAB> <TAB> <TAB> if not pending : <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> f = pending. pop ( ) <TAB> <TAB> <TAB> <TAB> try : <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> f ( ) <TAB> <TAB> <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> <TAB> <TAB> sys. excepthook ( * sys. exc_info ( ) ) <TAB> <TAB> <TAB> <TAB> assert f not in cls. _registry <TAB> finally : <TAB> <TAB> <TAB> <TAB> finalize. _shutdown = True <TAB> <TAB> if reenable_gc : <TAB> <TAB> <TAB> gc. enable ( ),False,gc.isenabled(),gc is False,0.6595113277435303
|
||
|
2072,"def _performance_by_month ( user_id, months = 12, end_month = None, end_year = None ) : <TAB> monthly_data = OrderedDict ( ) <TAB> now = datetime. now ( ) <TAB> if not end_month : <TAB> <TAB> end_month = now. month <TAB> if not end_year : <TAB> <TAB> end_year = now. year <TAB> end_time = time. mktime ( ( end_year, end_month + 1, 1, 0, 0, 0, 0, 0, - 1 ) ) <TAB> start_time = time. mktime ( ( end_year, end_month + 1 - months, 1, 0, 0, 0, 0, 0, - 1 ) ) <TAB> sql = PerformanceGraph. objects. filter_raw ( <TAB> <TAB> ""log_activity.created >="", date. fromtimestamp ( start_time ). isoformat ( ) <TAB> ). filter_raw ( ""log_activity.created <"", date. fromtimestamp ( end_time ). isoformat ( ) ) <TAB> for row in sql. all ( ) : <TAB> <TAB> label = row. approval_created. isoformat ( ) [ : 7 ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> xaxis = row. approval_created. strftime ( ""%b %Y"" ) <TAB> <TAB> <TAB> monthly_data [ label ] = dict ( teamcount = 0, usercount = 0, teamamt = 0, label = xaxis ) <TAB> <TAB> monthly_data [ label ] [ ""teamamt"" ] = monthly_data [ label ] [ ""teamamt"" ] + 1 <TAB> <TAB> monthly_data_count = monthly_data [ label ] [ ""teamcount"" ] <TAB> <TAB> monthly_data [ label ] [ ""teamcount"" ] = monthly_data_count + row. total <TAB> <TAB> if row. user_id == user_id : <TAB> <TAB> <TAB> user_count = monthly_data [ label ] [ ""usercount"" ] <TAB> <TAB> <TAB> monthly_data [ label ] [ ""usercount"" ] = user_count + row. total <TAB",False,label not in monthly_data,row.user_id == user_id,0.6623097658157349
|
||
|
2073,"def queries ( self ) : <TAB> if DEV : <TAB> <TAB> cmd = ShellCommand ( ""docker"", ""ps"", ""-qf"", ""name=%s"" % self. path. k8s ) <TAB> <TAB> if not cmd. check ( f""docker check for {self.path.k8s}"" ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> log_cmd = ShellCommand ( <TAB> <TAB> <TAB> <TAB> <TAB> ""docker"", ""logs"", self. path. k8s, stderr = subprocess. STDOUT <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> if log_cmd. check ( f""docker logs for {self.path.k8s}"" ) : <TAB> <TAB> <TAB> <TAB> <TAB> print ( cmd. stdout ) <TAB> <TAB> <TAB> <TAB> pytest. exit ( f""container failed to start for {self.path.k8s}"" ) <TAB> return ( )",False,not cmd.stdout.strip(),not cmd.check(f 'docker run < /dev/null 2>&1' + self.path.k8s),0.6573504209518433
|
||
|
2074,"def __init__ ( self, backend, key, algorithm, ctx = None ) : <TAB> self. _algorithm = algorithm <TAB> self. _backend = backend <TAB> if ctx is None : <TAB> <TAB> ctx = self. _backend. _lib. Cryptography_HMAC_CTX_new ( ) <TAB> <TAB> self. _backend. openssl_assert ( ctx!= self. _backend. _ffi. NULL ) <TAB> <TAB> ctx = self. _backend. _ffi. gc ( ctx, self. _backend. _lib. Cryptography_HMAC_CTX_free ) <TAB> <TAB> evp_md = self. _backend. _lib. EVP_get_digestbyname ( algorithm. name. encode ( ""ascii"" ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise UnsupportedAlgorithm ( <TAB> <TAB> <TAB> <TAB> ""{0} is not a supported hash on this backend."". format ( algorithm. name ), <TAB> <TAB> <TAB> <TAB> _Reasons. UNSUPPORTED_HASH, <TAB> <TAB> <TAB> ) <TAB> <TAB> res = self. _backend. _lib. Cryptography_HMAC_Init_ex ( <TAB> <TAB> <TAB> ctx, key, len ( key ), evp_md, self. _backend. _ffi. NULL <TAB> <TAB> ) <TAB> <TAB> self. _backend. openssl_assert ( res!= 0 ) <TAB> self. _ctx = ctx <TAB> self. _key = key",False,evp_md == self._backend._ffi.NULL,evp_md and evp_md < self._backend.hash,0.6596512794494629
|
||
|
2075,"def format_args ( self, args, has_variadic, *, include_defaults = True ) : <TAB> if not args : <TAB> <TAB> return """" <TAB> args_buf = [ ] <TAB> for argi, arg in enumerate ( args, 1 ) : <TAB> <TAB> vararg = has_variadic and ( len ( args ) == argi ) <TAB> <TAB> arg_expr = ""VARIADIC "" if vararg else """" <TAB> <TAB> if isinstance ( arg, tuple ) : <TAB> <TAB> <TAB> if arg [ 0 ] is not None : <TAB> <TAB> <TAB> <TAB> arg_expr += qn ( arg [ 0 ] ) <TAB> <TAB> <TAB> if len ( arg ) > 1 : <TAB> <TAB> <TAB> <TAB> arg_expr += "" "" + qt ( arg [ 1 ] ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> if len ( arg ) > 2 and arg [ 2 ] is not None : <TAB> <TAB> <TAB> <TAB> <TAB> arg_expr += "" = "" + arg [ 2 ] <TAB> <TAB> else : <TAB> <TAB> <TAB> arg_expr = arg <TAB> <TAB> args_buf. append ( arg_expr ) <TAB> return "", "". join ( args_buf )",True,include_defaults,include_defaults,0.6723951101303101
|
||
|
2076,"def _get_chunks ( self, shape, max_shape, chunks, dtype, chunksize ) : <TAB> if chunks is None : <TAB> <TAB> prod = _tuple_product ( max_shape [ 1 : ] ) <TAB> <TAB> if dtype == ""object"" : <TAB> <TAB> <TAB> return ( self. _object_chunking, ) + max_shape [ 1 : ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> sz = dtype. itemsize <TAB> <TAB> <TAB> chunks = int ( math. ceil ( chunksize / ( prod * sz ) ) ) <TAB> <TAB> <TAB> return ( chunks, ) + max_shape [ 1 : ] <TAB> <TAB> else : <TAB> <TAB> <TAB> return ( 1, ) + self. _determine_chunksizes ( max_shape [ 1 : ], dtype, chunksize ) <TAB> elif isinstance ( chunks, int ) : <TAB> <TAB> assert chunks > 0 <TAB> <TAB> if chunks > 1 : <TAB> <TAB> <TAB> return ( chunks, ) + tuple ( <TAB> <TAB> <TAB> <TAB> [ s or ms for s, ms in zip ( shape [ 1 : ], max_shape [ 1 : ] ) ] <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return ( 1, ) + self. _determine_chunksizes ( max_shape [ 1 : ], dtype, chunksize ) <TAB> else : <TAB> <TAB> chunks = tuple ( chunks ) <TAB> <TAB> if len ( chunks ) == 1 : <TAB> <TAB> <TAB> return self. _get_chunks ( shape, max_shape, chunks [ 0 ], dtype, chunksize ) <TAB> <TAB> else : <TAB> <TAB> <TAB> assert len ( chunks ) == len ( shape ) <TAB> <TAB> <TAB> assert chunks [ 0 ] == 1 <TAB> <TAB> <TAB> return chunks",False,prod <= 2 * chunksize,dtype == 'float32',0.6815425753593445
|
||
|
2077,"def _test ( ) : <TAB> testfiles = [ arg for arg in sys. argv [ 1 : ] if arg and arg [ 0 ]!= ""-"" ] <TAB> if not testfiles : <TAB> <TAB> name = os. path. basename ( sys. argv [ 0 ] ) <TAB> <TAB> if ""__loader__"" in globals ( ) : <TAB> <TAB> <TAB> name, _ = os. path. splitext ( name ) <TAB> <TAB> print ( ""usage: {0} [-v] file..."". format ( name ) ) <TAB> <TAB> return 2 <TAB> for filename in testfiles : <TAB> <TAB> if filename. endswith ( "".py"" ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> dirname, filename = os. path. split ( filename ) <TAB> <TAB> <TAB> sys. path. insert ( 0, dirname ) <TAB> <TAB> <TAB> m = __import__ ( filename [ : - 3 ] ) <TAB> <TAB> <TAB> del sys. path [ 0 ] <TAB> <TAB> <TAB> failures, _ = testmod ( m ) <TAB> <TAB> else : <TAB> <TAB> <TAB> failures, _ = testfile ( filename, module_relative = False ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return 1 <TAB> return 0",True,failures,failures,0.7307915687561035
|
||
|
2078,"def OnPopup ( self, form, popup_handle ) : <TAB> for num, action_name, menu_name, shortcut in self. actions : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> ida_kernwin. attach_action_to_popup ( form, popup_handle, None ) <TAB> <TAB> else : <TAB> <TAB> <TAB> handler = command_handler_t ( self, num, 2 ) <TAB> <TAB> <TAB> desc = ida_kernwin. action_desc_t ( action_name, menu_name, handler, shortcut ) <TAB> <TAB> <TAB> ida_kernwin. attach_dynamic_action_to_popup ( form, popup_handle, desc )",False,menu_name is None,num == 0,0.6513662338256836
|
||
|
2079,"def _init_auxiliary_head ( self, auxiliary_head ) : <TAB> """"""Initialize ``auxiliary_head``"""""" <TAB> if auxiliary_head is not None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. auxiliary_head = nn. ModuleList ( ) <TAB> <TAB> <TAB> for head_cfg in auxiliary_head : <TAB> <TAB> <TAB> <TAB> self. auxiliary_head. append ( builder. build_head ( head_cfg ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. auxiliary_head = builder. build_head ( auxiliary_head )",True,"isinstance(auxiliary_head, list)","isinstance(auxiliary_head, list)",0.6627303957939148
|
||
|
2080,"def check ( self, xp, nout ) : <TAB> input = xp. asarray ( self. x ). astype ( numpy. float32 ) <TAB> with warnings. catch_warnings ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> warnings. simplefilter ( ""ignore"", self. ignore_warning ) <TAB> <TAB> if self. result : <TAB> <TAB> <TAB> self. check_positive ( xp, self. func, input, self. eps, nout ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. check_negative ( xp, self. func, input, self. eps, nout )",True,self.ignore_warning,self.ignore_warning,0.6564961671829224
|
||
|
2081,"def compute ( self, split ) : <TAB> for t in self. rdd. iterator ( split ) : <TAB> <TAB> for k, v in six. iteritems ( self. filters ) : <TAB> <TAB> <TAB> value = getattr ( t, k ) <TAB> <TAB> <TAB> if isinstance ( v, types. FunctionType ) : <TAB> <TAB> <TAB> <TAB> if not v ( value ) : <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> v = [ v ] <TAB> <TAB> <TAB> <TAB> if value not in v : <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> else : <TAB> <TAB> <TAB> yield t",False,"not isinstance(v, list)","isinstance(v, types.StringTypes)",0.6533823609352112
|
||
|
2082,"def convertstore ( self, mydict ) : <TAB> targetheader = self. mypofile. header ( ) <TAB> targetheader. addnote ( ""extracted from web2py"", ""developer"" ) <TAB> for source_str in mydict. keys ( ) : <TAB> <TAB> target_str = mydict [ source_str ] <TAB> <TAB> if target_str == source_str : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> target_str = u"""" <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> target_str = u"""" <TAB> <TAB> pounit = self. convertunit ( source_str, target_str ) <TAB> <TAB> self. mypofile. addunit ( pounit ) <TAB> return self. mypofile",False,target_str.startswith(u'*** '),target_str == target_str,0.6509428024291992
|
||
|
2083,"def sequence_list ( self ) : <TAB> ""Returns a list of information about all DB sequences for all models in all apps."" <TAB> from django. apps import apps <TAB> from django. db import models, router <TAB> sequence_list = [ ] <TAB> for app_config in apps. get_app_configs ( ) : <TAB> <TAB> for model in router. get_migratable_models ( app_config, self. connection. alias ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if model. _meta. swapped : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> for f in model. _meta. local_fields : <TAB> <TAB> <TAB> <TAB> if isinstance ( f, models. AutoField ) : <TAB> <TAB> <TAB> <TAB> <TAB> sequence_list. append ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> { ""table"" : model. _meta. db_table, ""column"" : f. column } <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> for f in model. _meta. local_many_to_many : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if f. remote_field. through is None : <TAB> <TAB> <TAB> <TAB> <TAB> sequence_list. append ( { ""table"" : f. m2m_db_table ( ), ""column"" : None } ) <TAB> return sequence_list",False,not model._meta.managed,"hasattr(model, '_meta')",0.6582242250442505
|
||
|
2084,"def _extract_constants_from_irs ( <TAB> irs : List [ Operation ], <TAB> all_cst_used : List [ ConstantValue ], <TAB> all_cst_used_in_binary : Dict [ str, List [ ConstantValue ] ], <TAB> context_explored : Set [ Node ], ) : <TAB> for ir in irs : <TAB> <TAB> if isinstance ( ir, Binary ) : <TAB> <TAB> <TAB> for r in ir. read : <TAB> <TAB> <TAB> <TAB> if isinstance ( r, Constant ) : <TAB> <TAB> <TAB> <TAB> <TAB> all_cst_used_in_binary [ str ( ir. type ) ]. append ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ConstantValue ( str ( r. value ), str ( r. type ) ) <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> if isinstance ( ir, TypeConversion ) : <TAB> <TAB> <TAB> if isinstance ( ir. variable, Constant ) : <TAB> <TAB> <TAB> <TAB> all_cst_used. append ( ConstantValue ( str ( ir. variable. value ), str ( ir. type ) ) ) <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> for r in ir. read : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if isinstance ( ir, Member ) : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if isinstance ( r, Constant ) : <TAB> <TAB> <TAB> <TAB> all_cst_used. append ( ConstantValue ( str ( r. value ), str ( r. type ) ) ) <TAB> <TAB> <TAB> if isinstance ( r, StateVariable ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> if r. node_initialization. irs : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if r. node_initialization in context_explored",False,r.node_initialization,r.node_initialization is not None,0.658049464225769
|
||
|
2085,"def _galaxy_loc_iter ( loc_file, galaxy_dt, need_remap = False ) : <TAB> """"""Iterator returning genome build and references from Galaxy *.loc file."""""" <TAB> if ""column"" in galaxy_dt : <TAB> <TAB> dbkey_i = galaxy_dt [ ""column"" ]. index ( ""dbkey"" ) <TAB> <TAB> path_i = galaxy_dt [ ""column"" ]. index ( ""path"" ) <TAB> else : <TAB> <TAB> dbkey_i = None <TAB> if os. path. exists ( loc_file ) : <TAB> <TAB> with open ( loc_file ) as in_handle : <TAB> <TAB> <TAB> for line in in_handle : <TAB> <TAB> <TAB> <TAB> if line. strip ( ) and not line. startswith ( ""#"" ) : <TAB> <TAB> <TAB> <TAB> <TAB> parts = [ x. strip ( ) for x in line. strip ( ). split ( ""\t"" ) ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if len ( parts ) == 1 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> parts = [ <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> x. strip ( ) for x in line. strip ( ). split ( "" "" ) if x. strip ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if len ( parts ) > 1 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> raise IOError ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""Galaxy location file uses spaces instead of "" <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""tabs to separate fields: %s"" % loc_file <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB",False,parts[0] == 'index',need_remap,0.6545051336288452
|
||
|
2086,"def check_support ( self ) -> SupportStatus : <TAB> GVISOR_SECURE_RUNTIME = ""runsc"" <TAB> if is_linux ( ) : <TAB> <TAB> if not shutil. which ( GVISOR_SECURE_RUNTIME ) : <TAB> <TAB> <TAB> return SupportStatus. err ( <TAB> <TAB> <TAB> <TAB> { UnsupportReason. ENVIRONMENT_NOT_SECURE : self. ENV_ID } <TAB> <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> logger. warning ( <TAB> <TAB> <TAB> <TAB> ""Unable to start GLambda app. Setting "" <TAB> <TAB> <TAB> <TAB> ""`cgroup.cpuset.cpus` does not match `docker."" <TAB> <TAB> <TAB> <TAB> ""cpuset.cpus`. Potential fix: `cat /sys/fs/"" <TAB> <TAB> <TAB> <TAB> ""cgroup/cpuset/cpuset.cpus > /sys/fs/cgroup/"" <TAB> <TAB> <TAB> <TAB> ""cpuset/docker/cpuset.cpus`."" <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> return SupportStatus. err ( <TAB> <TAB> <TAB> <TAB> { UnsupportReason. ENVIRONMENT_MISCONFIGURED : self. ENV_ID } <TAB> <TAB> <TAB> ) <TAB> return super ( ). check_support ( )",False,not GLambdaTaskEnvironment._is_cgroup_cpuset_cfg_correct(),not self.has_docker,0.6538712978363037
|
||
|
2087,"def __init__ ( self, f ) : <TAB> self. _check_type ( f ) <TAB> self. func = can ( f. func ) <TAB> self. args = [ can ( a ) for a in f. args ] <TAB> self. keywords = { k : can ( v ) for k, v in f. keywords. items ( ) } <TAB> self. buffers = [ ] <TAB> self. arg_buffer_counts = [ ] <TAB> self. keyword_buffer_counts = { } <TAB> <TAB> for canned_arg in self. args : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. arg_buffer_counts. append ( 0 ) <TAB> <TAB> <TAB> continue <TAB> <TAB> self. arg_buffer_counts. append ( len ( canned_arg. buffers ) ) <TAB> <TAB> self. buffers. extend ( canned_arg. buffers ) <TAB> <TAB> canned_arg. buffers = [ ] <TAB> for key in sorted ( self. keywords ) : <TAB> <TAB> canned_kwarg = self. keywords [ key ] <TAB> <TAB> if not isinstance ( canned_kwarg, CannedObject ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> self. keyword_buffer_counts [ key ] = len ( canned_kwarg. buffers ) <TAB> <TAB> self. buffers. extend ( canned_kwarg. buffers ) <TAB> <TAB> canned_kwarg. buffers = [ ]",False,"not isinstance(canned_arg, CannedObject)","isinstance(canned_arg, CannedObject)",0.6588249802589417
|
||
|
2088,"def select_from_partition_request ( self, batch_definition_list = None ) : <TAB> if batch_definition_list is None : <TAB> <TAB> return [ ] <TAB> filter_function : Callable <TAB> if self. custom_filter_function : <TAB> <TAB> filter_function = self. custom_filter_function <TAB> else : <TAB> <TAB> filter_function = self. best_effort_partition_matcher ( ) <TAB> selected_batch_definitions = list ( <TAB> <TAB> filter ( <TAB> <TAB> <TAB> lambda batch_definition : filter_function ( <TAB> <TAB> <TAB> <TAB> partition_definition = batch_definition. partition_definition, <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> batch_definition_list, <TAB> <TAB> ) <TAB> ) <TAB> if self. index is None : <TAB> <TAB> selected_batch_definitions = selected_batch_definitions [ : self. limit ] <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> selected_batch_definitions = [ selected_batch_definitions [ self. index ] ] <TAB> <TAB> else : <TAB> <TAB> <TAB> selected_batch_definitions = list ( <TAB> <TAB> <TAB> <TAB> itertools. chain. from_iterable ( [ selected_batch_definitions [ self. index ] ] ) <TAB> <TAB> <TAB> ) <TAB> return selected_batch_definitions",False,"isinstance(self.index, int)",self.limit is None,0.6496145725250244
|
||
|
2089,"def run ( self ) : <TAB> hs = sublime. load_settings ( ""TextPastryHistory.sublime-settings"" ) <TAB> item = hs. get ( ""last_command"", { } ) <TAB> if ( <TAB> <TAB> item <TAB> <TAB> and ""command"" in item <TAB> <TAB> and ""text"" in item <TAB> <TAB> and item [ ""command"" ] <TAB> <TAB> and item [ ""text"" ] <TAB> ) : <TAB> <TAB> text = item. get ( ""text"" ) <TAB> <TAB> separator = item. get ( ""separator"", None ) <TAB> <TAB> command = item. get ( ""command"", None ) <TAB> <TAB> if text and command : <TAB> <TAB> <TAB> sublime. status_message ( ""Running last command"" ) <TAB> <TAB> <TAB> if command == ""insert_nums"" : <TAB> <TAB> <TAB> <TAB> ( start, step, padding ) = map ( str, text. split ( "" "" ) ) <TAB> <TAB> <TAB> <TAB> self. window. active_view ( ). run_command ( <TAB> <TAB> <TAB> <TAB> <TAB> ""text_pastry_range"", <TAB> <TAB> <TAB> <TAB> <TAB> { ""start"" : start, ""step"" : step, ""padding"" : padding }, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> self. window. active_view ( ). run_command ( <TAB> <TAB> <TAB> <TAB> <TAB> command, { ""text"" : text, ""separator"" : separator } <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> pass",False,command == 'text_pastry_insert_text',command == 'delete_nums',0.6481184959411621
|
||
|
2090,"def model ( data ) : <TAB> with pyro. plate ( ""plate_0"", data. shape [ - 1 ] ) : <TAB> <TAB> alpha = ( <TAB> <TAB> <TAB> pyro. sample ( ""alpha"", dist. HalfCauchy ( 1.0 ) ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> else torch. tensor ( [ 1.0, 1.0 ] ) <TAB> <TAB> ) <TAB> <TAB> beta = ( <TAB> <TAB> <TAB> pyro. sample ( ""beta"", dist. HalfCauchy ( 1.0 ) ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> else torch. tensor ( [ 1.0, 1.0 ] ) <TAB> <TAB> ) <TAB> <TAB> beta_binom = BetaBinomialPair ( ) <TAB> <TAB> with pyro. plate ( ""plate_1"", data. shape [ - 2 ] ) : <TAB> <TAB> <TAB> probs = pyro. sample ( ""probs"", beta_binom. latent ( alpha, beta ) ) <TAB> <TAB> <TAB> with pyro. plate ( ""data"", data. shape [ 0 ] ) : <TAB> <TAB> <TAB> <TAB> pyro. sample ( <TAB> <TAB> <TAB> <TAB> <TAB> ""binomial"", <TAB> <TAB> <TAB> <TAB> <TAB> beta_binom. conditional ( probs = probs, total_count = total_count ), <TAB> <TAB> <TAB> <TAB> <TAB> obs = data, <TAB> <TAB> <TAB> <TAB> )",False,hyperpriors,data.shape[1] == 0,0.7024195194244385
|
||
|
2091,"def _get_build_status ( self, job_name, build_number ) : <TAB> try : <TAB> <TAB> build_info = self. server. get_build_info ( job_name, build_number ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return ""building"" <TAB> <TAB> else : <TAB> <TAB> <TAB> return ""built"" <TAB> except jenkins. NotFoundException : <TAB> <TAB> return ""not found""",False,build_info['building'],build_info,0.6538980007171631
|
||
|
2092,"def get_open_shards ( ) : <TAB> <TAB> <TAB> database_hosts = config. get_required ( ""DATABASE_HOSTS"" ) <TAB> open_shards = [ ] <TAB> for host in database_hosts : <TAB> <TAB> open_shards. extend ( <TAB> <TAB> <TAB> shard [ ""ID"" ] <TAB> <TAB> <TAB> for shard in host [ ""SHARDS"" ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> ) <TAB> return open_shards",False,shard['OPEN'] and (not shard.get('DISABLED')),config.get_option('SHOW_SQL_shards'),0.6628351807594299
|
||
|
2093,"def validate_name ( self, type, name ) : <TAB> if type == InterfaceType. BRIDGE : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> 'Bridge interface must start with ""bridge"" followed by an unique number.' <TAB> <TAB> <TAB> ) <TAB> if type == InterfaceType. LINK_AGGREGATION : <TAB> <TAB> if not ( name. startswith ( ""lagg"" ) and name [ 4 : ]. isdigit ( ) ) : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> 'Link aggregation interface must start with ""lagg"" followed by an unique number.' <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if len ( name ) > 5 and name [ 4 ] == ""0"" : <TAB> <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> <TAB> 'Link aggregation interface name cannot start with ""lagg0"".' <TAB> <TAB> <TAB> <TAB> ) <TAB> if type == InterfaceType. VLAN : <TAB> <TAB> if not ( name. startswith ( ""vlan"" ) and name [ 4 : ]. isdigit ( ) ) : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> 'VLAN interface must start with ""vlan"" followed by an unique number.' <TAB> <TAB> <TAB> )",False,not (name.startswith('bridge') and name[6:].isdigit()),name[0] == name[0],0.6521009206771851
|
||
|
2094,"def _process_enum_definition ( self, tok ) : <TAB> fields = [ ] <TAB> for field in tok. fields : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> expression = self. expression_parser. parse ( field. expression ) <TAB> <TAB> else : <TAB> <TAB> <TAB> expression = None <TAB> <TAB> fields. append ( c_ast. CEnumField ( name = field. name. first, value = expression ) ) <TAB> name = tok. enum_name <TAB> if name : <TAB> <TAB> name = ""enum %s"" % tok. enum_name. first <TAB> else : <TAB> <TAB> name = self. _make_anonymous_type ( ""enum"" ) <TAB> return c_ast. CTypeDefinition ( <TAB> <TAB> name = name, <TAB> <TAB> type_definition = c_ast. CEnum ( <TAB> <TAB> <TAB> attributes = tok. attributes, fields = fields, name = name <TAB> <TAB> ), <TAB> )",True,field.expression,field.expression,0.6620014309883118
|
||
|
2095,"def __init__ ( self, uuid = None, cluster_state = None, children = None, ** kwargs ) : <TAB> self. uuid = uuid <TAB> self. cluster_state = cluster_state <TAB> if self. cluster_state is not None : <TAB> <TAB> self. children = WeakSet ( <TAB> <TAB> <TAB> self. cluster_state. tasks. get ( task_id ) <TAB> <TAB> <TAB> for task_id in children or ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> ) <TAB> else : <TAB> <TAB> self. children = WeakSet ( ) <TAB> self. _serializer_handlers = { <TAB> <TAB> ""children"" : self. _serializable_children, <TAB> <TAB> ""root"" : self. _serializable_root, <TAB> <TAB> ""parent"" : self. _serializable_parent, <TAB> } <TAB> if kwargs : <TAB> <TAB> self. __dict__. update ( kwargs )",False,task_id in self.cluster_state.tasks,task_id is None,0.6590691208839417
|
||
|
2096,"def LoadFromFile ( cls ) : <TAB> """"""Loads a service principal from a file."""""" <TAB> with open ( <TAB> <TAB> object_storage_service. FindCredentialFile ( <TAB> <TAB> <TAB> azure_credentials. AZURE_CREDENTIAL_PROFILE_FILE <TAB> <TAB> ), <TAB> <TAB> encoding = ""utf-8-sig"", <TAB> ) as profile_fp, open ( <TAB> <TAB> object_storage_service. FindCredentialFile ( <TAB> <TAB> <TAB> azure_credentials. AZURE_CREDENTIAL_TOKENS_FILE <TAB> <TAB> ) <TAB> ) as tokens_fp : <TAB> <TAB> subscriptions = json. load ( profile_fp ) [ ""subscriptions"" ] <TAB> <TAB> subscription = [ sub for sub in subscriptions if sub [ ""isDefault"" ] ] [ 0 ] <TAB> <TAB> subscription_type = subscription [ ""user"" ] [ ""type"" ] <TAB> <TAB> if subscription_type!= ""servicePrincipal"" : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> logging. info ( <TAB> <TAB> <TAB> <TAB> ""Azure credentials are of type '%s'. "" <TAB> <TAB> <TAB> <TAB> ""Will try to create a new service principal."", <TAB> <TAB> <TAB> <TAB> subscription_type, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> return cls ( ) <TAB> <TAB> <TAB> <TAB> name = subscription [ ""id"" ] <TAB> <TAB> app_id = subscription [ ""user"" ] [ ""name"" ] <TAB> <TAB> for token in json. load ( tokens_fp ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> logging. info ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Azure credentials are of type'servicePrincipal'. "" <TAB> <TAB> <TAB> <TAB> <TAB> ""Will reuse them for benchmarking."" <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB",False,token['servicePrincipalId'] == app_id,token != app_id,0.6688318848609924
|
||
|
2097,"def prepare_data ( accounts, filters, total_row, parent_children_map, company_currency ) : <TAB> data = [ ] <TAB> for d in accounts : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> prepare_opening_closing ( d ) <TAB> <TAB> has_value = False <TAB> <TAB> row = { <TAB> <TAB> <TAB> ""account"" : d. name, <TAB> <TAB> <TAB> ""parent_account"" : d. parent_account, <TAB> <TAB> <TAB> ""indent"" : d. indent, <TAB> <TAB> <TAB> ""from_date"" : filters. from_date, <TAB> <TAB> <TAB> ""to_date"" : filters. to_date, <TAB> <TAB> <TAB> ""currency"" : company_currency, <TAB> <TAB> <TAB> ""account_name"" : ( <TAB> <TAB> <TAB> <TAB> ""{} - {}"". format ( d. account_number, d. account_name ) <TAB> <TAB> <TAB> <TAB> if d. account_number <TAB> <TAB> <TAB> <TAB> else d. account_name <TAB> <TAB> <TAB> ), <TAB> <TAB> } <TAB> <TAB> for key in value_fields : <TAB> <TAB> <TAB> row [ key ] = flt ( d. get ( key, 0.0 ), 3 ) <TAB> <TAB> <TAB> if abs ( row [ key ] ) >= 0.005 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> has_value = True <TAB> <TAB> row [ ""has_value"" ] = has_value <TAB> <TAB> data. append ( row ) <TAB> data. extend ( [ { }, total_row ] ) <TAB> return data",False,parent_children_map.get(d.account),"d.get(parent_children_map, company_currency)",0.6483578681945801
|
||
|
2098,"def modify_bottle_params ( self, output_stride = None ) : <TAB> if output_stride is not None and output_stride % 2!= 0 : <TAB> <TAB> raise Exception ( ""output stride must to be even number"" ) <TAB> if output_stride is None : <TAB> <TAB> return <TAB> else : <TAB> <TAB> stride = 2 <TAB> <TAB> for i, layer_setting in enumerate ( self. bottleneck_params_list ) : <TAB> <TAB> <TAB> t, c, n, s = layer_setting <TAB> <TAB> <TAB> stride = stride * s <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> s = 1 <TAB> <TAB> <TAB> self. bottleneck_params_list [ i ] = ( t, c, n, s )",False,stride > output_stride,stride == 2,0.673632025718689
|
||
|
2099,"def _Determine_Do ( self ) : <TAB> self. applicable = 1 <TAB> configTokens = black. configure. items [ ""configTokens"" ]. Get ( ) <TAB> buildFlavour = black. configure. items [ ""buildFlavour"" ]. Get ( ) <TAB> if buildFlavour == ""full"" : <TAB> <TAB> self. value = False <TAB> else : <TAB> <TAB> self. value = True <TAB> for opt, optarg in self. chosenOptions : <TAB> <TAB> if opt == ""--with-tests"" : <TAB> <TAB> <TAB> if not self. value : <TAB> <TAB> <TAB> <TAB> configTokens. append ( ""tests"" ) <TAB> <TAB> <TAB> self. value = True <TAB> <TAB> elif opt == ""--without-tests"" : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> configTokens. append ( ""notests"" ) <TAB> <TAB> <TAB> self. value = False <TAB> self. determined = 1",False,self.value,not self.value,0.662090539932251
|
||
|
2100,"def test_out_of_bounds ( self ) : <TAB> <TAB> <TAB> <TAB> projection = ccrs. TransverseMercator ( central_longitude = 0 ) <TAB> rings = [ <TAB> <TAB> <TAB> <TAB> ( [ ( 86, 1 ), ( 86, - 1 ), ( 88, - 1 ), ( 88, 1 ) ], - 1 ), <TAB> <TAB> <TAB> <TAB> ( [ ( 86, 1 ), ( 86, - 1 ), ( 130, - 1 ), ( 88, 1 ) ], 1 ), <TAB> <TAB> <TAB> <TAB> ( [ ( 86, 1 ), ( 86, - 1 ), ( 130, - 1 ), ( 130, 1 ) ], 1 ), <TAB> <TAB> <TAB> <TAB> ( [ ( 120, 1 ), ( 120, - 1 ), ( 130, - 1 ), ( 130, 1 ) ], 0 ), <TAB> ] <TAB> <TAB> for coords, expected_n_lines in rings : <TAB> <TAB> linear_ring = sgeom. LinearRing ( coords ) <TAB> <TAB> rings, mlinestr = projection. project_geometry ( linear_ring ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> assert rings <TAB> <TAB> <TAB> assert not mlinestr <TAB> <TAB> else : <TAB> <TAB> <TAB> assert len ( mlinestr ) == expected_n_lines <TAB> <TAB> <TAB> if expected_n_lines == 0 : <TAB> <TAB> <TAB> <TAB> assert mlinestr. is_empty",False,expected_n_lines == -1,len(mlinestr) == 0,0.6579124927520752
|
||
|
2101,"def get_attached_nodes ( self, external_account ) : <TAB> for node in self. get_nodes_with_oauth_grants ( external_account ) : <TAB> <TAB> if node is None : <TAB> <TAB> <TAB> continue <TAB> <TAB> node_settings = node. get_addon ( self. oauth_provider. short_name ) <TAB> <TAB> if node_settings is None : <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> yield node",False,node_settings.external_account == external_account,self._has_attached_nodes(node_settings),0.6480094194412231
|
||
|
2102,"def GetRemote ( self ) : <TAB> pars = { ""method"" : ""list"", ""path"" : self. rpath, ""by"" : ""name"", ""order"" : ""asc"" } <TAB> result = self. byp. _ByPy__get ( const. PcsUrl + ""file"", pars, self. GetRemoteAct ) <TAB> if result == const. ENoError : <TAB> <TAB> self. title ( self. rpath ) <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> err = ( <TAB> <TAB> <TAB> <TAB> ""Can't retrieve Baidu PCS directories!\n"" <TAB> <TAB> <TAB> <TAB> + ""Maybe the network is down?\n"" <TAB> <TAB> <TAB> <TAB> + ""You can still manually input the remote path though"" <TAB> <TAB> <TAB> <TAB> + ""(But, I doubt it will work)"" <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> tkMessageBox. showerror ( GuiTitle, err ) <TAB> <TAB> <TAB> self. Bye ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. rpath = const. get_pcs_path ( """" ) <TAB> <TAB> <TAB> self. GetRemote ( )",False,self.rpath.strip('/') == const.AppPcsPath.strip('/'),result == const.SC_DOWN,0.6502629518508911
|
||
|
2103,"def set_presets ( * args, ** kwargs ) : <TAB> if ""presets"" in kwargs : <TAB> <TAB> presets = kwargs [ ""presets"" ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return kwargs <TAB> <TAB> if not isinstance ( presets, list ) : <TAB> <TAB> <TAB> presets = [ presets ] <TAB> <TAB> preset_kwargs = { } <TAB> <TAB> for preset in presets : <TAB> <TAB> <TAB> if isinstance ( preset, str ) : <TAB> <TAB> <TAB> <TAB> preset_orig = preset <TAB> <TAB> <TAB> <TAB> preset = preset_dict. get ( preset, None ) <TAB> <TAB> <TAB> <TAB> if preset is None : <TAB> <TAB> <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> f""Preset '{preset_orig}' was not found. Valid presets: {list(preset_dict.keys())}"" <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if isinstance ( preset, dict ) : <TAB> <TAB> <TAB> <TAB> for key in preset : <TAB> <TAB> <TAB> <TAB> <TAB> preset_kwargs [ key ] = preset [ key ] <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> raise TypeError ( <TAB> <TAB> <TAB> <TAB> <TAB> f""Preset of type {type(preset)} was given, but only presets of type [dict, str] are valid."" <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> for key in preset_kwargs : <TAB> <TAB> <TAB> if key not in kwargs : <TAB> <TAB> <TAB> <TAB> kwargs [ key ] = preset_kwargs [ key ] <TAB> return args, kwargs",True,presets is None,presets is None,0.6846630573272705
|
||
|
2104,"def _Determine_Do ( self ) : <TAB> if sys. platform. startswith ( ""linux"" ) or sys. platform == ""darwin"" : <TAB> <TAB> self. applicable = 1 <TAB> <TAB> self. value = [ ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> applicable = black. configure. items [ ""mozBin"" ]. Determine ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> d = black. configure. items [ ""mozBin"" ]. Get ( ) <TAB> <TAB> <TAB> if not self. Contains ( d ) : <TAB> <TAB> <TAB> <TAB> self. value. append ( d ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if sys. platform. startswith ( ""linux"" ) : <TAB> <TAB> <TAB> pythonExecutable = black. configure. items [ ""siloedPython"" ]. Get ( ) <TAB> <TAB> <TAB> pythonLibPath = join ( dirname ( dirname ( pythonExecutable ) ), ""lib"" ) <TAB> <TAB> <TAB> if not self. Contains ( pythonLibPath ) : <TAB> <TAB> <TAB> <TAB> self. value. append ( pythonLibPath ) <TAB> else : <TAB> <TAB> self. applicable = 0 <TAB> self. determined = 1",False,applicable,applied,0.687721848487854
|
||
|
2105,"def _consume_field ( <TAB> self, parse_type : bool = True, prefer_type : bool = False ) -> Tuple [ str, str, List [ str ] ] : <TAB> line = next ( self. _line_iter ) <TAB> before, colon, after = self. _partition_field_on_colon ( line ) <TAB> _name, _type, _desc = before, """", after <TAB> if parse_type : <TAB> <TAB> match = _google_typed_arg_regex. match ( before ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> _name = match. group ( 1 ). strip ( ) <TAB> <TAB> <TAB> _type = match. group ( 2 ) <TAB> _name = self. _escape_args_and_kwargs ( _name ) <TAB> if prefer_type and not _type : <TAB> <TAB> _type, _name = _name, _type <TAB> if _type and self. _config. napoleon_preprocess_types : <TAB> <TAB> _type = _convert_type_spec ( _type, self. _config. napoleon_type_aliases or { } ) <TAB> indent = self. _get_indent ( line ) + 1 <TAB> _descs = [ _desc ] + self. _dedent ( self. _consume_indented_block ( indent ) ) <TAB> _descs = self. __class__ ( _descs, self. _config ). lines ( ) <TAB> return _name, _type, _descs",True,match,match,0.6744592189788818
|
||
|
2106,"def run ( self ) : <TAB> """"""Run the import task."""""" <TAB> self. logger. info ( u""import started {0}"", time. asctime ( ) ) <TAB> self. set_config ( config [ ""import"" ] ) <TAB> <TAB> if self. query is None : <TAB> <TAB> stages = [ read_tasks ( self ) ] <TAB> else : <TAB> <TAB> stages = [ query_tasks ( self ) ] <TAB> <TAB> if self. config [ ""pretend"" ] : <TAB> <TAB> stages += [ log_files ( self ) ] <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> stages += [ group_albums ( self ) ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if self. config [ ""autotag"" ] : <TAB> <TAB> <TAB> stages += [ lookup_candidates ( self ), user_query ( self ) ] <TAB> <TAB> else : <TAB> <TAB> <TAB> stages += [ import_asis ( self ) ] <TAB> <TAB> <TAB> <TAB> for stage_func in plugins. early_import_stages ( ) : <TAB> <TAB> <TAB> stages. append ( plugin_stage ( self, stage_func ) ) <TAB> <TAB> for stage_func in plugins. import_stages ( ) : <TAB> <TAB> <TAB> stages. append ( plugin_stage ( self, stage_func ) ) <TAB> <TAB> stages += [ manipulate_files ( self ) ] <TAB> pl = pipeline. Pipeline ( stages ) <TAB> <TAB> plugins. send ( ""import_begin"", session = self ) <TAB> try : <TAB> <TAB> if config [ ""threaded"" ] : <TAB> <TAB> <TAB> pl. run_parallel ( QUEUE_SIZE ) <TAB> <TAB> else : <TAB> <TAB> <TAB> pl. run_sequential ( ) <TAB> except ImportAbort : <TAB> <TAB> <TAB> <TAB> pass",False,self.config['group_albums'] and (not self.config['singletons']),self.config['groupalbums'],0.6511656045913696
|
||
|
2107,"def put_secret ( _, request ) : <TAB> updated_secret = json. loads ( request. body ) <TAB> for filepath, value in updated_secret [ ""data"" ]. items ( ) : <TAB> <TAB> if filepath not in secret [ ""data"" ] : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> write_file ( <TAB> <TAB> <TAB> <TAB> config_dir, <TAB> <TAB> <TAB> <TAB> filepath, <TAB> <TAB> <TAB> <TAB> base64. b64decode ( value. encode ( ""utf-8"" ) ). decode ( ""ascii"" ), <TAB> <TAB> <TAB> ) <TAB> for filepath in secret [ ""data"" ] : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> normalized_path = normalize_path ( filepath ) <TAB> <TAB> <TAB> os. remove ( str ( config_dir. join ( normalized_path ) ) ) <TAB> secret [ ""data"" ] = updated_secret [ ""data"" ] <TAB> return { ""status_code"" : 200, ""content"" : json. dumps ( secret ) }",False,filepath not in updated_secret['data'],path.exists(str(config_dir.join(filepath)),0.6500364542007446
|
||
|
2108,"def remove_organization_member ( org, user_obj ) : <TAB> org_admins = [ u. username for u in __get_org_admin_users ( org ) ] <TAB> if len ( org_admins ) == 1 and user_obj. username in org_admins : <TAB> <TAB> raise DataModelException ( <TAB> <TAB> <TAB> ""Cannot remove user as they are the only organization admin"" <TAB> <TAB> ) <TAB> with db_transaction ( ) : <TAB> <TAB> <TAB> <TAB> permissions = list ( <TAB> <TAB> <TAB> RepositoryPermission. select ( RepositoryPermission. id ) <TAB> <TAB> <TAB>. join ( Repository ) <TAB> <TAB> <TAB>. where ( <TAB> <TAB> <TAB> <TAB> Repository. namespace_user == org, RepositoryPermission. user == user_obj <TAB> <TAB> <TAB> ) <TAB> <TAB> ) <TAB> <TAB> if permissions : <TAB> <TAB> <TAB> RepositoryPermission. delete ( ). where ( <TAB> <TAB> <TAB> <TAB> RepositoryPermission. id << permissions <TAB> <TAB> <TAB> ). execute ( ) <TAB> <TAB> <TAB> <TAB> members = list ( <TAB> <TAB> <TAB> TeamMember. select ( TeamMember. id ) <TAB> <TAB> <TAB>. join ( Team ) <TAB> <TAB> <TAB>. where ( Team. organization == org, TeamMember. user == user_obj ) <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> TeamMember. delete ( ). where ( TeamMember. id << members ). execute ( )",True,members,members,0.6883749961853027
|
||
|
2109,"def run ( ip_list, path, rate ) : <TAB> try : <TAB> <TAB> ip_file = open ( ""target.log"", ""w"" ) <TAB> <TAB> ip_file. write ( ""\n"". join ( ip_list ) ) <TAB> <TAB> ip_file. close ( ) <TAB> <TAB> path = str ( path ). translate ( None, "";|&"" ) <TAB> <TAB> rate = str ( rate ). translate ( None, "";|&"" ) <TAB> <TAB> if not os. path. exists ( path ) : <TAB> <TAB> <TAB> return <TAB> <TAB> os. system ( <TAB> <TAB> <TAB> ""%s -p1-65535 -iL target.log -oL tmp.log --randomize-hosts --rate=%s"" <TAB> <TAB> <TAB> % ( path, rate ) <TAB> <TAB> ) <TAB> <TAB> result_file = open ( ""tmp.log"", ""r"" ) <TAB> <TAB> result_json = result_file. readlines ( ) <TAB> <TAB> result_file. close ( ) <TAB> <TAB> del result_json [ 0 ] <TAB> <TAB> del result_json [ - 1 ] <TAB> <TAB> open_list = { } <TAB> <TAB> for res in result_json : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> ip = res. split ( ) [ 3 ] <TAB> <TAB> <TAB> <TAB> port = res. split ( ) [ 2 ] <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> open_list [ ip ]. append ( port ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> open_list [ ip ] = [ port ] <TAB> <TAB> <TAB> except : <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> os. remove ( ""target.log"" ) <TAB> <TAB> os. remove ( ""tmp.",True,ip in open_list,ip in open_list,0.6653150320053101
|
||
|
2110,"def build_vertices ( self, ulines ) : <TAB> vertex_idx = 0 <TAB> vertices = collections. OrderedDict ( ) <TAB> for line in ulines : <TAB> <TAB> for vt in line : <TAB> <TAB> <TAB> if vt. replacement is not None : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> new_vertex = ( vt. u, vt. v, 0.0 ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> vt. index = vertex_idx <TAB> <TAB> <TAB> vertex_idx += 1 <TAB> <TAB> <TAB> vertices [ new_vertex ] = 1 <TAB> return vertex_idx, list ( vertices. keys ( ) )",False,new_vertex in vertices,new_vertex == -1,0.6830917596817017
|
||
|
2111,"def build_campaign_parameters ( self, params ) : <TAB> campaign = self. tracker. campaign <TAB> if campaign : <TAB> <TAB> params. _utmz = ""%s.%s.%s.%s."" % ( <TAB> <TAB> <TAB> self. _generate_domain_hash ( ), <TAB> <TAB> <TAB> calendar. timegm ( campaign. creation_time. timetuple ( ) ), <TAB> <TAB> <TAB> self. visitor. visit_count, <TAB> <TAB> <TAB> campaign. response_count, <TAB> <TAB> ) <TAB> <TAB> param_map = { <TAB> <TAB> <TAB> ""utmcid"" : campaign. id, <TAB> <TAB> <TAB> ""utmcsr"" : campaign. source, <TAB> <TAB> <TAB> ""utmgclid"" : campaign. g_click_id, <TAB> <TAB> <TAB> ""utmdclid"" : campaign. d_click_id, <TAB> <TAB> <TAB> ""utmccn"" : campaign. name, <TAB> <TAB> <TAB> ""utmcmd"" : campaign. medium, <TAB> <TAB> <TAB> ""utmctr"" : campaign. term, <TAB> <TAB> <TAB> ""utmcct"" : campaign. content, <TAB> <TAB> } <TAB> <TAB> for k, v in param_map. items ( ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> params. _utmz = ""%s%s=%s%s"" % ( <TAB> <TAB> <TAB> <TAB> <TAB> params. _utmz, <TAB> <TAB> <TAB> <TAB> <TAB> k, <TAB> <TAB> <TAB> <TAB> <TAB> v. replace ( ""+"", ""%20"" ). replace ( "" "", ""%20"" ), <TAB> <TAB> <TAB> <TAB> <TAB> Campaign. CAMPAIGN_DELIMITER, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB>",False,v,self.tracker.campaign == 'utmCtl',0.6908220052719116
|
||
|
2112,"def __on_item_activated ( self, event ) : <TAB> if self. __module_view : <TAB> <TAB> module = self. get_event_module ( event ) <TAB> <TAB> self. __module_view. set_selection ( module. module_num ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. input_list_ctrl. deactivate_active_item ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. list_ctrl. deactivate_active_item ( ) <TAB> <TAB> <TAB> for index in range ( self. list_ctrl. GetItemCount ( ) ) : <TAB> <TAB> <TAB> <TAB> if self. list_ctrl. IsSelected ( index ) : <TAB> <TAB> <TAB> <TAB> <TAB> self. list_ctrl. Select ( index, False ) <TAB> self. __controller. enable_module_controls_panel_buttons ( )",False,event.EventObject is self.list_ctrl,self.input_list_ctrl.IsActive(),0.6541434526443481
|
||
|
2113,"def zipTest ( self, f, compression ) : <TAB> <TAB> zipfp = zipfile. ZipFile ( f, ""w"", compression, allowZip64 = True ) <TAB> <TAB> <TAB> filecount = 6 * 1024 ** 3 // len ( self. data ) <TAB> next_time = time. time ( ) + _PRINT_WORKING_MSG_INTERVAL <TAB> for num in range ( filecount ) : <TAB> <TAB> zipfp. writestr ( ""testfn%d"" % num, self. data ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> next_time = time. time ( ) + _PRINT_WORKING_MSG_INTERVAL <TAB> <TAB> <TAB> print >> sys. __stdout__, ( <TAB> <TAB> <TAB> <TAB> "" zipTest still writing %d of %d, be patient..."" % ( num, filecount ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> sys. __stdout__. flush ( ) <TAB> zipfp. close ( ) <TAB> <TAB> zipfp = zipfile. ZipFile ( f, ""r"", compression ) <TAB> for num in range ( filecount ) : <TAB> <TAB> self. assertEqual ( zipfp. read ( ""testfn%d"" % num ), self. data ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> next_time = time. time ( ) + _PRINT_WORKING_MSG_INTERVAL <TAB> <TAB> <TAB> print >> sys. __stdout__, ( <TAB> <TAB> <TAB> <TAB> "" zipTest still reading %d of %d, be patient..."" % ( num, filecount ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> sys. __stdout__. flush ( ) <TAB> zipfp. close ( )",False,next_time <= time.time(),next_time < 0,0.652493953704834
|
||
|
2114,"def err_handler ( out ) : <TAB> if out. status_code == 500 : <TAB> <TAB> print ( out. traceback ) <TAB> else : <TAB> <TAB> print ( out ) <TAB> if out. status_code == 404 and self. _check_refer_redirect ( ) : <TAB> <TAB> return <TAB> <TAB> if self. is_content_request ( ) : <TAB> <TAB> if self. content_error_redirect : <TAB> <TAB> <TAB> err_context = { ""status"" : out. status_code, ""error"" : out. body } <TAB> <TAB> <TAB> response. status = 303 <TAB> <TAB> <TAB> redirect_url = self. content_error_redirect + ""?"" + urlencode ( err_context ) <TAB> <TAB> <TAB> response. set_header ( ""Location"", redirect_url ) <TAB> <TAB> <TAB> return <TAB> <TAB> else : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> return error_view ( out ) <TAB> if isinstance ( out. exception, dict ) : <TAB> <TAB> return json_error ( out. exception ) <TAB> else : <TAB> <TAB> return json_error ( { ""error"" : ""not_found"" } )",False,self._wrong_content_session_redirect(),"isinstance(out.exception, dict)",0.6515780687332153
|
||
|
2115,"def collect ( self ) : <TAB> for nickname in self. squid_hosts. keys ( ) : <TAB> <TAB> squid_host = self. squid_hosts [ nickname ] <TAB> <TAB> fulldata = self. _getData ( squid_host [ ""host"" ], squid_host [ ""port"" ] ) <TAB> <TAB> if fulldata is not None : <TAB> <TAB> <TAB> fulldata = fulldata. splitlines ( ) <TAB> <TAB> <TAB> for data in fulldata : <TAB> <TAB> <TAB> <TAB> matches = self. stat_pattern. match ( data ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> self. publish_counter ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""%s.%s"" % ( nickname, matches. group ( 1 ) ), float ( matches. group ( 2 ) ) <TAB> <TAB> <TAB> <TAB> <TAB> )",False,matches,matches is not None,0.6868793964385986
|
||
|
2116,"def act_and_mul ( in_deltas, hs, activation ) : <TAB> if iscontiguous ( in_deltas. _tensor ) and iscontiguous ( hs. _tensor ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> _in_deltas = ffi. cast ( ""float *"", ffi. from_buffer ( in_deltas. _tensor ) ) <TAB> <TAB> <TAB> _hs = ffi. cast ( ""float *"", ffi. from_buffer ( hs. _tensor ) ) <TAB> <TAB> <TAB> NervanaObject. be. mathlib. cmath_act_and_mul ( <TAB> <TAB> <TAB> <TAB> _in_deltas, _hs, in_deltas. size, activation. xcut <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> return True <TAB> <TAB> else : <TAB> <TAB> <TAB> return False <TAB> else : <TAB> <TAB> return False",False,"isinstance(activation, Rectlinclip) and activation.slope == 0",hs.size > 0,0.6571342945098877
|
||
|
2117,"def _unpack_scales ( scales, vidxs ) : <TAB> scaleData = [ None, None, None ] <TAB> for i in range ( 3 ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> break <TAB> <TAB> scale = scales [ i ] <TAB> <TAB> if not math. isnan ( scale ) : <TAB> <TAB> <TAB> vidx1, vidx2 = vidxs [ i * 2 ], vidxs [ i * 2 + 1 ] <TAB> <TAB> <TAB> scaleData [ i ] = ( int ( vidx1 ), int ( vidx2 ), float ( scale ) ) <TAB> return scaleData",False,"i >= min(len(scales), len(vidxs) // 2)",i == len(scales) - 1,0.655652642250061
|
||
|
2118,"def response_dict ( self ) : <TAB> res = { <TAB> <TAB> ""ETag"" : self. etag, <TAB> <TAB> ""last-modified"" : self. last_modified_RFC1123, <TAB> <TAB> ""content-length"" : str ( self. size ), <TAB> } <TAB> if self. encryption is not None : <TAB> <TAB> res [ ""x-amz-server-side-encryption"" ] = self. encryption <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> res [ ""x-amz-server-side-encryption-aws-kms-key-id"" ] = self. kms_key_id <TAB> if self. bucket_key_enabled is not None : <TAB> <TAB> res [ ""x-amz-server-side-encryption-bucket-key-enabled"" ] = self. bucket_key_enabled <TAB> if self. _storage_class!= ""STANDARD"" : <TAB> <TAB> res [ ""x-amz-storage-class"" ] = self. _storage_class <TAB> if self. _expiry is not None : <TAB> <TAB> rhdr = 'ongoing-request=""false"", expiry-date=""{0}""' <TAB> <TAB> res [ ""x-amz-restore"" ] = rhdr. format ( self. expiry_date ) <TAB> if self. _is_versioned : <TAB> <TAB> res [ ""x-amz-version-id"" ] = str ( self. version_id ) <TAB> if self. website_redirect_location : <TAB> <TAB> res [ ""x-amz-website-redirect-location"" ] = self. website_redirect_location <TAB> return res",False,self.encryption == 'aws:kms' and self.kms_key_id is not None,self.kms_key_id is not None,0.6521943211555481
|
||
|
2119,"def isSegInside ( self, seg ) : <TAB> if len ( self ) == 0 : <TAB> <TAB> return 2 <TAB> nbInter = 0 <TAB> i1 = None <TAB> i2 = None <TAB> for segpath in self : <TAB> <TAB> a, b = segpath. intersect ( seg ) <TAB> <TAB> if a is not None and not eq ( a, i1 ) and not eq ( a, i2 ) : <TAB> <TAB> <TAB> nbInter += 1 <TAB> <TAB> <TAB> i1 = a <TAB> <TAB> if b is not None and not eq ( b, i1 ) and not eq ( b, i2 ) : <TAB> <TAB> <TAB> nbInter += 1 <TAB> <TAB> <TAB> i2 = a <TAB> if nbInter == 0 : <TAB> <TAB> result = 1 if self. isInside ( seg. A ) else - 1 <TAB> if nbInter == 1 : <TAB> <TAB> if self. isOnPath ( seg. A ) : <TAB> <TAB> <TAB> if self. isOnPath ( seg. B ) : <TAB> <TAB> <TAB> <TAB> result = 0 <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> result = 1 if self. isInside ( seg. B ) else - 1 <TAB> <TAB> elif self. isOnPath ( seg. B ) : <TAB> <TAB> <TAB> result = 1 if self. isInside ( seg. A ) else - 1 <TAB> <TAB> else : <TAB> <TAB> <TAB> result = 0 <TAB> if nbInter >= 2 : <TAB> <TAB> if self. hasSeg ( seg ) : <TAB> <TAB> <TAB> result = 0 <TAB> <TAB> else : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> result = 1 if self. isInside ( seg. midPoint ( ) ) else - 1 <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> result = - 1 <TAB> return result",False,self.isOnPath(seg.A) and self.isOnPath(seg.B),self.hasSeg(seg),0.6507209539413452
|
||
|
2120,"def __init__ ( self, * args, ** kwargs ) : <TAB> <TAB> self. _options_values = { ** kwargs } <TAB> <TAB> for name, value in kwargs. items ( ) : <TAB> <TAB> setattr ( self, name, value ) <TAB> position = 0 <TAB> for name, option in self. __options__ : <TAB> <TAB> if not option. positional : <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> maybe_value = getattr ( type ( self ), name ) <TAB> <TAB> if not isoption ( maybe_value ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> if len ( args ) <= position : <TAB> <TAB> <TAB> break <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( ""Already got a value for option {}"". format ( name ) ) <TAB> <TAB> setattr ( self, name, args [ position ] ) <TAB> <TAB> position += 1",False,name in self._options_values,maybe_value is not None and args[position],0.6568104028701782
|
||
|
2121,"def _codegen_impl ( self, state : CodegenState ) -> None : <TAB> for ll in self. leading_lines : <TAB> <TAB> ll. _codegen ( state ) <TAB> state. add_indent_tokens ( ) <TAB> end_node = self. body <TAB> if len ( self. handlers ) > 0 : <TAB> <TAB> end_node = self. handlers [ - 1 ] <TAB> orelse = self. orelse <TAB> end_node = end_node if orelse is None else orelse <TAB> finalbody = self. finalbody <TAB> end_node = end_node if finalbody is None else finalbody <TAB> with state. record_syntactic_position ( self, end_node = end_node ) : <TAB> <TAB> state. add_token ( ""try"" ) <TAB> <TAB> self. whitespace_before_colon. _codegen ( state ) <TAB> <TAB> state. add_token ( "":"" ) <TAB> <TAB> self. body. _codegen ( state ) <TAB> <TAB> for handler in self. handlers : <TAB> <TAB> <TAB> handler. _codegen ( state ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> orelse. _codegen ( state ) <TAB> <TAB> if finalbody is not None : <TAB> <TAB> <TAB> finalbody. _codegen ( state )",True,orelse is not None,orelse is not None,0.6602383852005005
|
||
|
2122,"def _findInTree ( t, n ) : <TAB> ret = [ ] <TAB> if type ( t ) is dict : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> ret. append ( t ) <TAB> <TAB> for k, v in t. items ( ) : <TAB> <TAB> <TAB> ret += _findInTree ( v, n ) <TAB> if type ( t ) is list : <TAB> <TAB> for v in t : <TAB> <TAB> <TAB> ret += _findInTree ( v, n ) <TAB> return ret",False,'_name' in t and t['_name'] == n,t.keys() is not None,0.6632386445999146
|
||
|
2123,"def test_cwl_rnaseq ( self, install_test_files ) : <TAB> with install_cwl_test_files ( ) as work_dir : <TAB> <TAB> with utils. chdir ( os. path. join ( work_dir, ""rnaseq"" ) ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> shutil. rmtree ( ""cromwell_work"" ) <TAB> <TAB> <TAB> subprocess. check_call ( <TAB> <TAB> <TAB> <TAB> [ ""bcbio_vm.py"", ""cwlrun"", ""cromwell"", ""rnaseq-workflow"" ] <TAB> <TAB> <TAB> )",True,os.path.exists('cromwell_work'),os.path.exists('cromwell_work'),0.6478400230407715
|
||
|
2124,"def _discard ( self, node, current_klass ) : <TAB> if isinstance ( node. expr, self. ast. CallFunc ) : <TAB> <TAB> expr = self. _callfunc ( <TAB> <TAB> <TAB> node. expr, <TAB> <TAB> <TAB> current_klass, <TAB> <TAB> <TAB> is_statement = True, <TAB> <TAB> <TAB> optlocal_var = isinstance ( node. expr. node, self. ast. Name ), <TAB> <TAB> ) <TAB> <TAB> if isinstance ( node. expr. node, self. ast. Name ) : <TAB> <TAB> <TAB> name_type, pyname, jsname, depth, is_local = self. lookup ( <TAB> <TAB> <TAB> <TAB> node. expr. node. name <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. w ( expr ) <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> self. w ( self. spacing ( ) + expr + "";"" ) <TAB> elif isinstance ( node. expr, self. ast. Const ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if node. expr. value in [ <TAB> <TAB> <TAB> ""@"" + ""CONSTANT_DECLARATION@"", <TAB> <TAB> <TAB> ""@"" + ""ATTRIB_REMAP_DECLARATION@"", <TAB> <TAB> ] : <TAB> <TAB> <TAB> self. w ( node. expr. value ) <TAB> <TAB> return <TAB> elif isinstance ( node. expr, self. ast. Yield ) : <TAB> <TAB> self. _yield ( node. expr, current_klass ) <TAB> else : <TAB> <TAB> <TAB> <TAB> expr = self. expr ( node. expr, current_klass ) <TAB> <TAB> self. w ( self. spacing ( ) + expr + "";"" )",False,name_type == '__pyjamas__' and jsname in __pyjamas__.native_js_funcs,is_local,0.6506012678146362
|
||
|
2125,"def find_module_pre_py33 ( string, path = None, fullname = None ) : <TAB> try : <TAB> <TAB> module_file, module_path, description = imp. find_module ( string, path ) <TAB> <TAB> module_type = description [ 2 ] <TAB> <TAB> return module_file, module_path, module_type is imp. PKG_DIRECTORY <TAB> except ImportError : <TAB> <TAB> pass <TAB> if path is None : <TAB> <TAB> path = sys. path <TAB> for item in path : <TAB> <TAB> loader = pkgutil. get_importer ( item ) <TAB> <TAB> if loader : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> loader = loader. find_module ( string ) <TAB> <TAB> <TAB> <TAB> if loader : <TAB> <TAB> <TAB> <TAB> <TAB> is_package = loader. is_package ( string ) <TAB> <TAB> <TAB> <TAB> <TAB> is_archive = hasattr ( loader, ""archive"" ) <TAB> <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> module_path = loader. get_filename ( string ) <TAB> <TAB> <TAB> <TAB> <TAB> except AttributeError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> module_path = loader. _get_filename ( string ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> except AttributeError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> module_path = os. path. dirname ( module_path ) <TAB> <TAB> <TAB> <TAB> <TAB> if is_archive :",False,is_package,is_package and module_path,0.657867431640625
|
||
|
2126,"def ql_syscall_fcntl64 ( ql, fcntl_fd, fcntl_cmd, fcntl_arg, * args, ** kw ) : <TAB> F_GETFD = 1 <TAB> F_SETFD = 2 <TAB> F_GETFL = 3 <TAB> F_SETFL = 4 <TAB> if fcntl_cmd == F_GETFL : <TAB> <TAB> regreturn = 2 <TAB> elif fcntl_cmd == F_SETFL : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> ql. os. fd [ fcntl_fd ]. fcntl ( fcntl_cmd, fcntl_arg ) <TAB> <TAB> regreturn = 0 <TAB> elif fcntl_cmd == F_GETFD : <TAB> <TAB> regreturn = 2 <TAB> elif fcntl_cmd == F_SETFD : <TAB> <TAB> regreturn = 0 <TAB> else : <TAB> <TAB> regreturn = 0 <TAB> return regreturn",False,"isinstance(ql.os.fd[fcntl_fd], ql_socket)",ll.os.fd[fcntl_fd] is not None,0.6535757780075073
|
||
|
2127,"def __call__ ( self, form, field ) : <TAB> l = field. data and len ( field. data ) or 0 <TAB> if l < self. min or self. max!= - 1 and l > self. max : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if self. max == - 1 : <TAB> <TAB> <TAB> <TAB> self. message = field. ngettext ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Field must be at least %(min)d character long."", <TAB> <TAB> <TAB> <TAB> <TAB> ""Field must be at least %(min)d characters long."", <TAB> <TAB> <TAB> <TAB> <TAB> self. min, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> elif self. min == - 1 : <TAB> <TAB> <TAB> <TAB> self. message = field. ngettext ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Field cannot be longer than %(max)d character."", <TAB> <TAB> <TAB> <TAB> <TAB> ""Field cannot be longer than %(max)d characters."", <TAB> <TAB> <TAB> <TAB> <TAB> self. max, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. message = field. gettext ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Field must be between %(min)d and %(max)d characters long."" <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> raise ValidationError ( self. message % dict ( min = self. min, max = self. max ) )",False,self.message is None,self.min == 0,0.6602815389633179
|
||
|
2128,"def topic_exists ( self, arn ) : <TAB> response = self. _conn. get_all_topics ( ) <TAB> topics = response [ ""ListTopicsResponse"" ] [ ""ListTopicsResult"" ] [ ""Topics"" ] <TAB> current_topics = [ ] <TAB> if len ( topics ) > 0 : <TAB> <TAB> for topic in topics : <TAB> <TAB> <TAB> topic_arn = topic [ ""TopicArn"" ] <TAB> <TAB> <TAB> current_topics. append ( topic_arn ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return True <TAB> return False",True,arn in current_topics,arn in current_topics,0.6723469495773315
|
||
|
2129,"def refresh ( token = None, fail_silent = False ) : <TAB> """"""Use self or provided JWT token to get a fresher one. If self token, internalize upon refresh."""""" <TAB> using_self_token = token is None <TAB> try : <TAB> <TAB> if PyGraphistry. store_token_creds_in_memory ( ) : <TAB> <TAB> <TAB> logger. debug ( ""JWT refresh via creds"" ) <TAB> <TAB> <TAB> return PyGraphistry. relogin ( ) <TAB> <TAB> logger. debug ( ""JWT refresh via token"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> PyGraphistry. _is_authenticated = False <TAB> <TAB> token = ( <TAB> <TAB> <TAB> ArrowUploader ( <TAB> <TAB> <TAB> <TAB> server_base_path = PyGraphistry. protocol ( ) <TAB> <TAB> <TAB> <TAB> + ""://"" <TAB> <TAB> <TAB> <TAB> + PyGraphistry. server ( ), <TAB> <TAB> <TAB> <TAB> certificate_validation = PyGraphistry. certificate_validation ( ), <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB>. refresh ( PyGraphistry. api_token ( ) if using_self_token else token ) <TAB> <TAB> <TAB>. token <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> PyGraphistry. api_token ( token ) <TAB> <TAB> <TAB> PyGraphistry. _is_authenticated = True <TAB> <TAB> return PyGraphistry. api_token ( ) <TAB> except Exception as e : <TAB> <TAB> if not fail_silent : <TAB> <TAB> <TAB> util. error ( ""Failed to refresh token: %s"" % str ( e ) )",False,using_self_token,token and token != None,0.6603431701660156
|
||
|
2130,"def sort ( self ) : <TAB> sorted_models = [ ] <TAB> concrete_models = set ( ) <TAB> models = list ( self. data ) <TAB> while len ( sorted_models ) < len ( models ) : <TAB> <TAB> found = False <TAB> <TAB> for model in models : <TAB> <TAB> <TAB> if model in sorted_models : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> dependencies = self. dependencies. get ( model. _meta. concrete_model ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> sorted_models. append ( model ) <TAB> <TAB> <TAB> <TAB> concrete_models. add ( model. _meta. concrete_model ) <TAB> <TAB> <TAB> <TAB> found = True <TAB> <TAB> if not found : <TAB> <TAB> <TAB> return <TAB> self. data = SortedDict ( [ ( model, self. data [ model ] ) for model in sorted_models ] )",False,not (dependencies and dependencies.difference(concrete_models)),dependencies in concrete_models,0.6552073359489441
|
||
|
2131,"def set ( self, new, * args, ** kwargs ) : <TAB> """"""Change the contents of the default scale"""""" <TAB> if type ( new ) == str : <TAB> <TAB> self. scale = Scale. get_scale ( new ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. scale. tuning = kwargs [ ""tuning"" ] <TAB> <TAB> self. pentatonic. update ( self. scale. pentatonic ) <TAB> elif isinstance ( new, ( list, Pattern, TimeVar ) ) : <TAB> <TAB> self. scale = ScalePattern ( new, * args, ** kwargs ) <TAB> <TAB> <TAB> <TAB> if self. scale. name is not None and self. scale. name not in Scale. names ( ) : <TAB> <TAB> <TAB> Scale [ self. scale. name ] = self. scale <TAB> <TAB> self. pentatonic. update ( self. scale. pentatonic ) <TAB> else : <TAB> <TAB> print ( ""Warning: {!r} is not a valid scale"". format ( new ) ) <TAB> return self",True,'tuning' in kwargs,'tuning' in kwargs,0.6624324321746826
|
||
|
2132,"def _stop ( self, close_output_streams = False ) : <TAB> if self. is_stopped ( ) : <TAB> <TAB> return <TAB> self. _status = ""stopping"" <TAB> logger. debug ( ""stopping the %s watcher"" % self. name ) <TAB> logger. debug ( <TAB> <TAB> ""gracefully stopping processes [%s] for %ss"" <TAB> <TAB> % ( self. name, self. graceful_timeout ) <TAB> ) <TAB> <TAB> self. call_hook ( ""before_stop"" ) <TAB> yield self. kill_processes ( ) <TAB> self. reap_processes ( ) <TAB> <TAB> if self. stdout_redirector is not None : <TAB> <TAB> self. stdout_redirector. stop ( ) <TAB> <TAB> self. stdout_redirector = None <TAB> if self. stderr_redirector is not None : <TAB> <TAB> self. stderr_redirector. stop ( ) <TAB> <TAB> self. stderr_redirector = None <TAB> if close_output_streams : <TAB> <TAB> if self. stdout_stream and hasattr ( self. stdout_stream [ ""stream"" ], ""close"" ) : <TAB> <TAB> <TAB> self. stdout_stream [ ""stream"" ]. close ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. stderr_stream [ ""stream"" ]. close ( ) <TAB> <TAB> if self. evpub_socket is not None : <TAB> <TAB> self. notify_event ( ""stop"", { ""time"" : time. time ( ) } ) <TAB> self. _status = ""stopped"" <TAB> <TAB> self. call_hook ( ""after_stop"" ) <TAB> logger. info ( ""%s stopped"", self. name )",False,"self.stderr_stream and hasattr(self.stderr_stream['stream'], 'close')","self.stderr_stream and hasattr(self.stderr_stream[0], 'close')",0.6488653421401978
|
||
|
2133,"def done ( result ) : <TAB> reply, result, ct = result <TAB> if result : <TAB> <TAB> data = { <TAB> <TAB> <TAB> ""text/plain"" : result if isinstance ( result, str ) else str ( result ), <TAB> <TAB> } <TAB> <TAB> if isinstance ( result, BinaryCapsule ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> data [ result. content_type ] = result. as_b64 ( ) <TAB> <TAB> self. _publish_execute_result ( parent, data, { }, self. execution_count ) <TAB> super ( SplashKernel, self ). send_execute_reply ( stream, ident, parent, md, reply )",False,"result.content_type in {'image/png', 'image/jpeg'}",result.content_type is not None,0.6495629549026489
|
||
|
2134,"def logic ( ) : <TAB> count = intbv ( 0, min = 0, max = MAXVAL + 1 ) <TAB> while True : <TAB> <TAB> yield clock. posedge, reset. posedge <TAB> <TAB> if reset == 1 : <TAB> <TAB> <TAB> count [ : ] = 0 <TAB> <TAB> else : <TAB> <TAB> <TAB> flag. next = 0 <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> flag. next = 1 <TAB> <TAB> <TAB> <TAB> count [ : ] = 0 <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> count += 1",False,count == MAXVAL,reset == max,0.6796265244483948
|
||
|
2135,"def sources ( ) : <TAB> for d in os. listdir ( base ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if d. endswith ( ""old"" ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> if d == ""indcat"" : <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> yield d",False,not os.path.isdir(base + d),d == 'notcat',0.6456693410873413
|
||
|
2136,"def LogURLsFromStr ( self, RawOutput ) : <TAB> plugin_output = dict ( PLUGIN_OUTPUT ) <TAB> self. timer. start_timer ( ""LogURLsFromStr"" ) <TAB> <TAB> URLList = import_urls ( RawOutput. strip ( ). split ( ""\n"" ) ) <TAB> NumFound = 0 <TAB> VisitURLs = False <TAB> <TAB> if True : <TAB> <TAB> VisitURLs = True <TAB> <TAB> <TAB> <TAB> for Transaction in self. requester. get_transactions ( True, get_urls_to_visit ( ) ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> NumFound += 1 <TAB> TimeStr = self. timer. get_elapsed_time_as_str ( ""LogURLsFromStr"" ) <TAB> logging. info ( ""Spider/URL scraper time=%s"", TimeStr ) <TAB> plugin_output [ ""type"" ] = ""URLsFromStr"" <TAB> plugin_output [ ""output"" ] = { <TAB> <TAB> ""TimeStr"" : TimeStr, <TAB> <TAB> ""VisitURLs"" : VisitURLs, <TAB> <TAB> ""URLList"" : URLList, <TAB> <TAB> ""NumFound"" : NumFound, <TAB> } <TAB> return [ plugin_output ]",False,Transaction is not None and Transaction.found,True,0.662529706954956
|
||
|
2137,"def test_object___format___errors ( self ) : <TAB> errors = [ <TAB> <TAB> ( ""+"", ""Sign not allowed in string format specifier"" ), <TAB> <TAB> ( ""=+"", ""Sign not allowed in string format specifier"" ), <TAB> <TAB> ( ""=10"", ""'=' alignment not allowed in string format specifier"" ), <TAB> <TAB> ( ""10r"", ""Unknown format code 'r' for object of type'str'"" ), <TAB> <TAB> ( ""=+r"", ""Unknown format code 'r' for object of type'str'"" ), <TAB> <TAB> ( ""."", ""Format specifier missing precision"" ), <TAB> <TAB> ( "".a"", ""Format specifier missing precision"" ), <TAB> ] <TAB> <TAB> for char in allChars : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if char == "","" : <TAB> <TAB> <TAB> <TAB> errors. append ( ( ""10"" + char, ""Cannot specify ',' with's'."" ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> errors. append ( <TAB> <TAB> <TAB> <TAB> <TAB> ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""10"" + char, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""Unknown format code '%s' for object of type'str'"" % char, <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> ) <TAB> for errorFmt, errorMsg in errors : <TAB> <TAB> self. assertRaisesMessage ( ValueError, errorMsg, object ( ). __format__, errorFmt ) <TAB> <TAB> self. assertRaisesMessage ( TestException, ""booh"", bad_str ( ). __format__, ""+"" ) <TAB> self. assertRaisesMessage ( TestException, ""booh"", bad_str ( ). __format__, ""=10"" ) <TAB> self. assertRaisesMessage ( TestException, ""booh"", bad_str ( ). __format__, "".""",False,char != 's' and (char < '0' or char > '9'),char >= 0,0.6499617099761963
|
||
|
2138,"def create_image_upload ( ) : <TAB> if request. method == ""POST"" : <TAB> <TAB> image = request. form [ ""image"" ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> image_file = uploaded_file ( file_content = image ) <TAB> <TAB> <TAB> image_url = upload_local ( <TAB> <TAB> <TAB> <TAB> image_file, UPLOAD_PATHS [ ""temp"" ] [ ""image"" ]. format ( uuid = uuid4 ( ) ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> return jsonify ( { ""status"" : ""ok"", ""image_url"" : image_url } ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return jsonify ( { ""status"" : ""no_image"" } )",True,image,image,0.6921366453170776
|
||
|
2139,"def _record_shell ( ex, files, bind_rez = True, print_msg = False ) : <TAB> if bind_rez and package_commands_sourced_first : <TAB> <TAB> ex. source ( context_file ) <TAB> for file_ in files : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> ex. source ( file_ ) <TAB> if bind_rez and not package_commands_sourced_first : <TAB> <TAB> ex. source ( context_file ) <TAB> if envvar : <TAB> <TAB> ex. unsetenv ( envvar ) <TAB> if add_rez and bind_rez : <TAB> <TAB> ex. interpreter. _bind_interactive_rez ( ) <TAB> if print_msg and add_rez and not quiet : <TAB> <TAB> ex. info ( """" ) <TAB> <TAB> ex. info ( ""You are now in a rez-configured environment."" ) <TAB> <TAB> ex. info ( """" ) <TAB> <TAB> if system. is_production_rez_install : <TAB> <TAB> <TAB> ex. command ( ""rezolve context"" )",False,os.path.exists(os.path.expanduser(file_)),os.path.isfile(file_),0.648218035697937
|
||
|
2140,"def convert_file ( input_file_path ) : <TAB> print ( ""Reading gzip file {}."". format ( input_file_path ) ) <TAB> with gzip. open ( input_file_path ) as f : <TAB> <TAB> records = json. load ( f ) <TAB> n = len ( records [ ""passages"" ]. keys ( ) ) <TAB> for i in tqdm. tqdm ( range ( n ), ""Converting"" ) : <TAB> <TAB> newline_dict = { } <TAB> <TAB> index = str ( i ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> newline_dict [ ""answers"" ] = records [ ""answers"" ] [ index ] <TAB> <TAB> <TAB> newline_dict [ ""wellFormedAnswers"" ] = records [ ""wellFormedAnswers"" ] [ index ] <TAB> <TAB> newline_dict [ ""passages"" ] = records [ ""passages"" ] [ index ] <TAB> <TAB> newline_dict [ ""query"" ] = records [ ""query"" ] [ index ] <TAB> <TAB> newline_dict [ ""query_id"" ] = records [ ""query_id"" ] [ index ] <TAB> <TAB> newline_dict [ ""query_type"" ] = records [ ""query_type"" ] [ index ] <TAB> <TAB> yield newline_dict",False,'test' not in input_file_path,index in records,0.6498531103134155
|
||
|
2141,"def _get_tracks_compositors_list ( ) : <TAB> tracks_list = [ ] <TAB> tracks = current_sequence ( ). tracks <TAB> compositors = current_sequence ( ). compositors <TAB> for track_index in range ( 1, len ( tracks ) - 1 ) : <TAB> <TAB> track_compositors = [ ] <TAB> <TAB> for j in range ( 0, len ( compositors ) ) : <TAB> <TAB> <TAB> comp = compositors [ j ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> track_compositors. append ( comp ) <TAB> <TAB> tracks_list. append ( track_compositors ) <TAB> return tracks_list",False,comp.transition.b_track == track_index,comp,0.6489219665527344
|
||
|
2142,"def delete_stream ( transaction, stream_hash, sd_hash, blob_hashes, blob_dir ) : <TAB> transaction. execute ( <TAB> <TAB> ""delete from content_claim where stream_hash=? "", ( stream_hash, ) <TAB> ) <TAB> transaction. execute ( ""delete from file where stream_hash=? "", ( stream_hash, ) ) <TAB> transaction. execute ( ""delete from stream_blob where stream_hash=?"", ( stream_hash, ) ) <TAB> transaction. execute ( ""delete from stream where stream_hash=? "", ( stream_hash, ) ) <TAB> transaction. execute ( ""delete from blob where blob_hash=?"", ( sd_hash, ) ) <TAB> for blob_hash in blob_hashes : <TAB> <TAB> transaction. execute ( ""delete from blob where blob_hash=?"", ( blob_hash, ) ) <TAB> <TAB> file_path = os. path. join ( blob_dir, blob_hash ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> os. unlink ( file_path )",False,os.path.isfile(file_path),os.path.exists(file_path),0.6448550224304199
|
||
|
2143,"def simp_ext ( _, expr ) : <TAB> if expr. op. startswith ( ""zeroExt_"" ) : <TAB> <TAB> arg = expr. args [ 0 ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return arg <TAB> <TAB> return ExprCompose ( arg, ExprInt ( 0, expr. size - arg. size ) ) <TAB> if expr. op. startswith ( ""signExt_"" ) : <TAB> <TAB> arg = expr. args [ 0 ] <TAB> <TAB> add_size = expr. size - arg. size <TAB> <TAB> new_expr = ExprCompose ( <TAB> <TAB> <TAB> arg, <TAB> <TAB> <TAB> ExprCond ( <TAB> <TAB> <TAB> <TAB> arg. msb ( ), ExprInt ( size2mask ( add_size ), add_size ), ExprInt ( 0, add_size ) <TAB> <TAB> <TAB> ), <TAB> <TAB> ) <TAB> <TAB> return new_expr <TAB> return expr",False,expr.size == arg.size,expr.op.startswith('arg'),0.6592988967895508
|
||
|
2144,"def cmp ( self, other ) : <TAB> v_is_ptr = not isinstance ( self, CTypesGenericPrimitive ) <TAB> w_is_ptr = isinstance ( other, CTypesData ) and not isinstance ( <TAB> <TAB> other, CTypesGenericPrimitive <TAB> ) <TAB> if v_is_ptr and w_is_ptr : <TAB> <TAB> return cmpfunc ( self. _convert_to_address ( None ), other. _convert_to_address ( None ) ) <TAB> elif v_is_ptr or w_is_ptr : <TAB> <TAB> return NotImplemented <TAB> else : <TAB> <TAB> if isinstance ( self, CTypesGenericPrimitive ) : <TAB> <TAB> <TAB> self = self. _value <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> other = other. _value <TAB> <TAB> return cmpfunc ( self, other )",False,"isinstance(other, CTypesGenericPrimitive)","isinstance(other, CTypesData)",0.651056170463562
|
||
|
2145,"def _analytic_forecast ( <TAB> self, <TAB> parameters : NDArray, <TAB> resids : NDArray, <TAB> backcast : Union [ float, NDArray ], <TAB> var_bounds : NDArray, <TAB> start : int, <TAB> horizon : int, ) -> VarianceForecast : <TAB> omega, aw, gw, resids2, indicator = self. _common_forecast_components ( <TAB> <TAB> parameters, resids, backcast, horizon <TAB> ) <TAB> m = self. m <TAB> resids2 [ : start ] = np. nan <TAB> aw_rev = aw [ : : - 1 ] <TAB> gw_rev = gw [ : : - 1 ] <TAB> for i in range ( horizon ) : <TAB> <TAB> resids2 [ :, m + i ] = omega + resids2 [ :, i : ( m + i ) ]. dot ( aw_rev ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> resids2_ind = resids2 [ :, i : ( m + i ) ] * indicator [ :, i : ( m + i ) ] <TAB> <TAB> <TAB> resids2 [ :, m + i ] += resids2_ind. dot ( gw_rev ) <TAB> <TAB> <TAB> indicator [ :, m + i ] = 0.5 <TAB> return VarianceForecast ( resids2 [ :, m : ]. copy ( ) )",False,self._asym,indicator is not None,0.6705334186553955
|
||
|
2146,"def write ( self, data ) : <TAB> self. size -= len ( data ) <TAB> passon = None <TAB> if self. size > 0 : <TAB> <TAB> self. data. append ( data ) <TAB> else : <TAB> <TAB> if self. size : <TAB> <TAB> <TAB> data, passon = data [ : self. size ], data [ self. size : ] <TAB> <TAB> else : <TAB> <TAB> <TAB> passon = b"""" <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. data. append ( data ) <TAB> return passon",False,data,self.size > 0 and passon,0.6889404058456421
|
||
|
2147,"def make_attribute ( key : str, value ) -> IAttributeProto : <TAB> attr = AttributeProto ( ) <TAB> attr. name = key <TAB> is_iterable = isinstance ( value, Iterable ) <TAB> bytes_or_false = _to_bytes_or_false ( value ) <TAB> <TAB> <TAB> if isinstance ( value, float ) : <TAB> <TAB> attr. f = value <TAB> <TAB> elif isinstance ( value, numbers. Integral ) : <TAB> <TAB> attr. i = value <TAB> <TAB> elif bytes_or_false : <TAB> <TAB> attr. s = bytes_or_false <TAB> elif isinstance ( value, TensorProto ) : <TAB> <TAB> attr. t. CopyFrom ( value ) <TAB> elif isinstance ( value, GraphProto ) : <TAB> <TAB> attr. g. CopyFrom ( value ) <TAB> <TAB> elif is_iterable : <TAB> <TAB> byte_array = [ _to_bytes_or_false ( v ) for v in value ] <TAB> <TAB> if all ( isinstance ( v, float ) for v in value ) : <TAB> <TAB> <TAB> attr. floats. extend ( value ) <TAB> <TAB> elif all ( isinstance ( v, numbers. Integral ) for v in value ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> attr. ints. extend ( int ( v ) for v in value ) <TAB> <TAB> elif all ( byte_array ) : <TAB> <TAB> <TAB> attr. strings. extend ( byte_array ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> attr. tensors. extend ( value ) <TAB> <TAB> elif all ( isinstance ( v, GraphProto ) for v in value ) : <TAB> <TAB> <TAB> attr. graphs. extend ( value ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""You passed in an iterable attribute but I cannot figure out "" <TAB> <TAB> <TAB> <TAB> ""its applicable type."" <TAB> <TAB> <TAB> ) <TAB>",False,"all((isinstance(v, TensorProto) for v in value))",is_iterable,0.6574083566665649
|
||
|
2148,"def find_package_modules ( self, package, package_dir ) : <TAB> self. check_package ( package, package_dir ) <TAB> module_files = glob. glob ( os. path. join ( glob. escape ( package_dir ), ""*.py"" ) ) <TAB> modules = [ ] <TAB> setup_script = os. path. abspath ( self. distribution. script_name ) <TAB> for f in module_files : <TAB> <TAB> abs_f = os. path. abspath ( f ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> module = os. path. splitext ( os. path. basename ( f ) ) [ 0 ] <TAB> <TAB> <TAB> modules. append ( ( package, module, f ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. debug_print ( ""excluding %s"" % setup_script ) <TAB> return modules",False,abs_f != setup_script,abs_f == setup_script,0.6582242250442505
|
||
|
2149,"def write_track ( outfile, track ) : <TAB> data = bytearray ( ) <TAB> running_status_byte = None <TAB> for msg in fix_end_of_track ( track ) : <TAB> <TAB> if not isinstance ( msg. time, Integral ) : <TAB> <TAB> <TAB> raise ValueError ( ""message time must be int in MIDI file"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( ""realtime messages are not allowed in MIDI files"" ) <TAB> <TAB> data. extend ( encode_variable_int ( msg. time ) ) <TAB> <TAB> if msg. is_meta : <TAB> <TAB> <TAB> data. extend ( msg. bytes ( ) ) <TAB> <TAB> <TAB> running_status_byte = None <TAB> <TAB> elif msg. type == ""sysex"" : <TAB> <TAB> <TAB> data. append ( 0xF0 ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> data. extend ( encode_variable_int ( len ( msg. data ) + 1 ) ) <TAB> <TAB> <TAB> data. extend ( msg. data ) <TAB> <TAB> <TAB> data. append ( 0xF7 ) <TAB> <TAB> <TAB> running_status_byte = None <TAB> <TAB> else : <TAB> <TAB> <TAB> msg_bytes = msg. bytes ( ) <TAB> <TAB> <TAB> status_byte = msg_bytes [ 0 ] <TAB> <TAB> <TAB> if status_byte == running_status_byte : <TAB> <TAB> <TAB> <TAB> data. extend ( msg_bytes [ 1 : ] ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> data. extend ( msg_bytes ) <TAB> <TAB> <TAB> if status_byte < 0xF0 : <TAB> <TAB> <TAB> <TAB> running_status_byte = status_byte <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> running_status_byte = None <TAB> write_chunk ( outfile, b",False,msg.is_realtime,msg.time > 0,0.6588345766067505
|
||
|
2150,"def get_proxy_ip ( identifier ) : <TAB> """"""Get Proxy IP."""""" <TAB> proxy_ip = None <TAB> try : <TAB> <TAB> if not identifier : <TAB> <TAB> <TAB> return proxy_ip <TAB> <TAB> ips = get_network ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return proxy_ip <TAB> <TAB> device_ip = identifier. split ( "":"", 1 ) [ 0 ] <TAB> <TAB> ip_range = device_ip. rsplit ( ""."", 1 ) [ 0 ] <TAB> <TAB> guess_ip = ip_range + "".1"" <TAB> <TAB> if guess_ip in ips : <TAB> <TAB> <TAB> return guess_ip <TAB> <TAB> for ip_addr in ips : <TAB> <TAB> <TAB> to_check = ip_addr. rsplit ( ""."", 1 ) [ 0 ] <TAB> <TAB> <TAB> if to_check == ip_range : <TAB> <TAB> <TAB> <TAB> return ip_addr <TAB> except Exception : <TAB> <TAB> logger. error ( ""Error getting Proxy IP"" ) <TAB> return proxy_ip",False,':' not in identifier or not ips,identifier,0.6739150285720825
|
||
|
2151,"def Children ( self ) : <TAB> """"""Returns a list of all of this object's owned (strong) children."""""" <TAB> children = [ ] <TAB> for property, attributes in self. _schema. iteritems ( ) : <TAB> <TAB> ( is_list, property_type, is_strong ) = attributes [ 0 : 3 ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if not is_list : <TAB> <TAB> <TAB> <TAB> children. append ( self. _properties [ property ] ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> children. extend ( self. _properties [ property ] ) <TAB> return children",False,is_strong and property in self._properties,property in self._properties and is_strong,0.6682225465774536
|
||
|
2152,"def build_paths ( obj ) : <TAB> paths = [ ] <TAB> if obj [ ""type"" ] == ""Polygon"" : <TAB> <TAB> polygons = [ obj [ ""arcs"" ] ] <TAB> else : <TAB> <TAB> polygons = obj [ ""arcs"" ] <TAB> for polygon in polygons : <TAB> <TAB> for ring in polygon : <TAB> <TAB> <TAB> path = [ ] <TAB> <TAB> <TAB> for i, arc in enumerate ( ring ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> if arc >= 0 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> path. extend ( arcs [ arc ] ) <TAB> <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> path. extend ( ( arcs [ ~ arc ] ) [ : : - 1 ] ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> if arc >= 0 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> path. extend ( arcs [ arc ] [ 1 : ] ) <TAB> <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> path. extend ( ( arcs [ ~ arc ] [ : - 1 ] ) [ : : - 1 ] ) <TAB> <TAB> <TAB> if len ( path ) > 2 : <TAB> <TAB> <TAB> <TAB> V = np. zeros ( ( len ( path ), 3 ), dtype = np. float32 ) <TAB> <TAB> <TAB> <TAB> V [ :, : 2 ] = np. array ( path ) <TAB> <TAB> <TAB> <TAB> paths. append ( V ) <TAB> return paths",False,i == 0,i % 2,0.6855310201644897
|
||
|
2153,"def _thd_cleanup_instance ( self ) : <TAB> container_name = self. getContainerName ( ) <TAB> instances = self. client. containers ( all = 1, filters = dict ( name = container_name ) ) <TAB> for instance in instances : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> try : <TAB> <TAB> <TAB> self. client. remove_container ( instance [ ""Id"" ], v = True, force = True ) <TAB> <TAB> except NotFound : <TAB> <TAB> <TAB> pass <TAB> <TAB> except docker. errors. APIError as e : <TAB> <TAB> <TAB> if ""Conflict operation on container"" not in str ( e ) : <TAB> <TAB> <TAB> <TAB> raise",False,''.join(instance['Names']).strip('/') != container_name,'Id' not in instance,0.6511694192886353
|
||
|
2154,def decodeattrs ( attrs ) : <TAB> names = [ ] <TAB> for bit in range ( 16 ) : <TAB> <TAB> mask = 1 << bit <TAB> <TAB> if attrs & mask : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> names. append ( attrnames [ mask ] ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> names. append ( hex ( mask ) ) <TAB> return names,True,attrnames.has_key(mask),attrnames.has_key(mask),0.6512173414230347
|
||
|
2155,"def modify_address ( self, name, address, domain ) : <TAB> if not self. get_entries_by_name ( name, domain ) : <TAB> <TAB> raise exception. NotFound <TAB> infile = open ( self. filename, ""r"" ) <TAB> outfile = tempfile. NamedTemporaryFile ( ""w"", delete = False ) <TAB> for line in infile : <TAB> <TAB> entry = self. parse_line ( line ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> outfile. write ( <TAB> <TAB> <TAB> <TAB> ""%s %s %s\n"" % ( address, self. qualify ( name, domain ), entry [ ""type"" ] ) <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> outfile. write ( line ) <TAB> infile. close ( ) <TAB> outfile. close ( ) <TAB> shutil. move ( outfile. name, self. filename )",False,"entry and entry['name'].lower() == self.qualify(name, domain).lower()",entry,0.64753657579422
|
||
|
2156,"def pixbufrenderer ( self, column, crp, model, it ) : <TAB> tok = model. get_value ( it, 0 ) <TAB> if tok. type == ""class"" : <TAB> <TAB> icon = ""class"" <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> icon = ""method_priv"" <TAB> <TAB> elif tok. visibility == ""protected"" : <TAB> <TAB> <TAB> icon = ""method_prot"" <TAB> <TAB> else : <TAB> <TAB> <TAB> icon = ""method"" <TAB> crp. set_property ( ""pixbuf"", imagelibrary. pixbufs [ icon ] )",True,tok.visibility == 'private',tok.visibility == 'private',0.656152606010437
|
||
|
2157,"def host_selection_algorithm ( self, request_spec, all_hosts, selected_hosts, unique ) : <TAB> size = request_spec [ ""size"" ] <TAB> drive_type = request_spec [ ""drive_type"" ] <TAB> best_host = None <TAB> best_qoscap = None <TAB> best_cap = None <TAB> max_avail = 0 <TAB> for ( host, capabilities ) in all_hosts : <TAB> <TAB> for qosgrp, qos_values in capabilities. iteritems ( ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if size == 0 : <TAB> <TAB> <TAB> <TAB> <TAB> available = qos_values [ ""FullDrive"" ] [ ""NumFreeDrives"" ] <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> available = qos_values [ ""AvailableCapacity"" ] <TAB> <TAB> <TAB> <TAB> if available > max_avail and self. _allowed_to_use_host ( <TAB> <TAB> <TAB> <TAB> <TAB> host, selected_hosts, unique <TAB> <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> <TAB> max_avail = available <TAB> <TAB> <TAB> <TAB> <TAB> best_host = host <TAB> <TAB> <TAB> <TAB> <TAB> best_qoscap = qos_values <TAB> <TAB> <TAB> <TAB> <TAB> best_cap = capabilities <TAB> <TAB> <TAB> <TAB> break <TAB> if best_host : <TAB> <TAB> self. _add_hostcap_to_list ( selected_hosts, best_host, best_cap ) <TAB> <TAB> type_str = ""drives"" if size == 0 else ""bytes"" <TAB> <TAB> LOG. debug ( <TAB> <TAB> <TAB> _ ( <TAB> <TAB> <TAB> <TAB> ""\t MostAvailCap: Best host: %(best_host)s",False,"self._qosgrp_match(drive_type, qos_values)",drive_type == 'host',0.6497954726219177
|
||
|
2158,"def _pick_error ( self, log_interpretation, step_type ) : <TAB> """"""Pick probable cause of failure (only call this if job fails)."""""" <TAB> logs_needed = self. _logs_needed_to_pick_error ( step_type ) <TAB> if self. _read_logs ( ) and not all ( <TAB> <TAB> log_type in log_interpretation for log_type in logs_needed <TAB> ) : <TAB> <TAB> log. info ( ""Scanning logs for probable cause of failure..."" ) <TAB> <TAB> if ""step"" in logs_needed : <TAB> <TAB> <TAB> self. _interpret_step_logs ( log_interpretation, step_type ) <TAB> <TAB> if ""history"" in logs_needed : <TAB> <TAB> <TAB> self. _interpret_history_log ( log_interpretation ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> error_attempt_ids = _pick_error_attempt_ids ( log_interpretation ) <TAB> <TAB> <TAB> self. _interpret_task_logs ( log_interpretation, step_type, error_attempt_ids ) <TAB> return _pick_error ( log_interpretation )",False,'task' in logs_needed,'tasks' in logs_needed,0.65485018491745
|
||
|
2159,"def _post_sub_clone_resize ( self, path ) : <TAB> """"""Try post sub clone resize in a transactional manner."""""" <TAB> st_tm_mv, st_nw_mv, st_del_old = None, None, None <TAB> seg = path. split ( ""/"" ) <TAB> LOG. info ( ""Post clone resize LUN %s"", seg [ - 1 ] ) <TAB> new_lun = ""new-%s"" % ( seg [ - 1 ] ) <TAB> tmp_lun = ""tmp-%s"" % ( seg [ - 1 ] ) <TAB> tmp_path = ""/vol/%s/%s"" % ( seg [ 2 ], tmp_lun ) <TAB> new_path = ""/vol/%s/%s"" % ( seg [ 2 ], new_lun ) <TAB> try : <TAB> <TAB> st_tm_mv = self. zapi_client. move_lun ( path, tmp_path ) <TAB> <TAB> st_nw_mv = self. zapi_client. move_lun ( new_path, path ) <TAB> <TAB> st_del_old = self. zapi_client. destroy_lun ( tmp_path ) <TAB> except Exception as e : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> msg = _ ( ""Failure staging LUN %s to tmp."" ) <TAB> <TAB> <TAB> raise exception. VolumeBackendAPIException ( data = msg % ( seg [ - 1 ] ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if st_nw_mv is None : <TAB> <TAB> <TAB> <TAB> self. zapi_client. move_lun ( tmp_path, path ) <TAB> <TAB> <TAB> <TAB> msg = _ ( ""Failure moving new cloned LUN to %s."" ) <TAB> <TAB> <TAB> <TAB> raise exception. VolumeBackendAPIException ( data = msg % ( seg [ - 1 ] ) ) <TAB> <TAB> <TAB> elif st_del_old is None : <TAB> <TAB> <TAB> <TAB> LOG. error ( ""Failure deleting staged tmp LUN %s.""",False,st_tm_mv is None,e.args[0] == e.args[0],0.6566102504730225
|
||
|
2160,"def parse_qresult ( self ) : <TAB> """"""Parse a HMMER2 query block."""""" <TAB> while self. read_next ( ) : <TAB> <TAB> if not self. line. startswith ( ""Query"" ) : <TAB> <TAB> <TAB> return <TAB> <TAB> _, id_ = self. parse_key_value ( ) <TAB> <TAB> self. qresult = QueryResult ( id = id_ ) <TAB> <TAB> description = None <TAB> <TAB> while self. read_next ( ) and not self. line. startswith ( ""Scores"" ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. qresult. accession = self. parse_key_value ( ) [ 1 ] <TAB> <TAB> <TAB> if self. line. startswith ( ""Description"" ) : <TAB> <TAB> <TAB> <TAB> description = self. parse_key_value ( ) [ 1 ] <TAB> <TAB> hit_placeholders = self. parse_hits ( ) <TAB> <TAB> if len ( hit_placeholders ) > 0 : <TAB> <TAB> <TAB> self. parse_hsps ( hit_placeholders ) <TAB> <TAB> <TAB> self. parse_hsp_alignments ( ) <TAB> <TAB> while not self. line. startswith ( ""Query"" ) : <TAB> <TAB> <TAB> self. read_next ( ) <TAB> <TAB> <TAB> if not self. line : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> self. buf. append ( self. line ) <TAB> <TAB> if description is not None : <TAB> <TAB> <TAB> self. qresult. description = description <TAB> <TAB> yield self. qresult",False,self.line.startswith('Accession'),"self.line.startswith( ""A)",0.6513302326202393
|
||
|
2161,"def test_exist_ok_s_isgid_directory ( self ) : <TAB> path = os. path. join ( support. TESTFN, ""dir1"" ) <TAB> S_ISGID = stat. S_ISGID <TAB> mode = 0o777 <TAB> old_mask = os. umask ( 0o022 ) <TAB> try : <TAB> <TAB> existing_testfn_mode = stat. S_IMODE ( os. lstat ( support. TESTFN ). st_mode ) <TAB> <TAB> try : <TAB> <TAB> <TAB> os. chmod ( support. TESTFN, existing_testfn_mode | S_ISGID ) <TAB> <TAB> except PermissionError : <TAB> <TAB> <TAB> raise unittest. SkipTest ( ""Cannot set S_ISGID for dir."" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise unittest. SkipTest ( ""No support for S_ISGID dir mode."" ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> os. makedirs ( path, mode | S_ISGID ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> os. makedirs ( path, mode, exist_ok = True ) <TAB> <TAB> <TAB> <TAB> os. chmod ( path, stat. S_IMODE ( os. lstat ( path ). st_mode ) & ~ S_ISGID ) <TAB> <TAB> <TAB> <TAB> os. makedirs ( path, mode | S_ISGID, exist_ok = True ) <TAB> finally : <TAB> <TAB> os. umask ( old_mask )",False,os.lstat(support.TESTFN).st_mode & S_ISGID != S_ISGID,S_ISGID is None,0.6544977426528931
|
||
|
2162,"def _perform_check ( self ) : <TAB> if not self. _enabled : <TAB> <TAB> return <TAB> with self. _check_mutex : <TAB> <TAB> self. _logger. debug ( <TAB> <TAB> <TAB> ""Checking against {}:{} if we are online..."". format ( self. _host, self. _port ) <TAB> <TAB> ) <TAB> <TAB> old_value = self. _online <TAB> <TAB> for _ in range ( 3 ) : <TAB> <TAB> <TAB> connection_working = server_reachable ( self. _host, port = self. _port ) <TAB> <TAB> <TAB> if self. _name : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> self. _logger. debug ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""Checking if we can resolve {}..."". format ( self. _name ) <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> resolution_working = len ( resolve_host ( self. _name ) ) > 0 <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> resolution_working = False <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> resolution_working = True <TAB> <TAB> <TAB> if not ( connection_working and resolution_working ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> time. sleep ( 1.0 ) <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> self. _connection_working = connection_working <TAB> <TAB> self. _resolution_working = resolution_working <TAB> <TAB> if old_value!= self. _online : <TAB> <TAB> <TAB> self. _trigger_change ( old_value, self. _online )",False,connection_working,self._connection_working and port and (self._resolution_working is False),0.6717939376831055
|
||
|
2163,"def expected_forward_with_reduce ( self, x_data, t_data, class_weight ) : <TAB> <TAB> loss_expect = 0.0 <TAB> count = 0 <TAB> x = numpy. rollaxis ( x_data, 1, x_data. ndim ). reshape ( ( t_data. size, x_data. shape [ 1 ] ) ) <TAB> t = t_data. ravel ( ) <TAB> for xi, ti in six. moves. zip ( x, t ) : <TAB> <TAB> if ti == - 1 : <TAB> <TAB> <TAB> continue <TAB> <TAB> log_z = numpy. ufunc. reduce ( numpy. logaddexp, xi ) <TAB> <TAB> if class_weight is None : <TAB> <TAB> <TAB> loss_expect -= ( xi - log_z ) [ ti ] <TAB> <TAB> else : <TAB> <TAB> <TAB> loss_expect -= ( xi - log_z ) [ ti ] * class_weight [ ti ] <TAB> <TAB> count += 1 <TAB> if self. normalize : <TAB> <TAB> if count == 0 : <TAB> <TAB> <TAB> loss_expect = 0.0 <TAB> <TAB> else : <TAB> <TAB> <TAB> loss_expect /= count <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> loss_expect = 0.0 <TAB> <TAB> else : <TAB> <TAB> <TAB> loss_expect /= len ( t_data ) <TAB> return numpy. asarray ( loss_expect, dtype = x. dtype )",False,len(t_data) == 0,count == 0,0.6535935401916504
|
||
|
2164,"def _create_3par_vlun ( self, volume, hostname, nsp, lun_id = None ) : <TAB> try : <TAB> <TAB> location = None <TAB> <TAB> auto = True <TAB> <TAB> if lun_id is not None : <TAB> <TAB> <TAB> auto = False <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> location = self. client. createVLUN ( <TAB> <TAB> <TAB> <TAB> volume, hostname = hostname, auto = auto, lun = lun_id <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> port = self. build_portPos ( nsp ) <TAB> <TAB> <TAB> location = self. client. createVLUN ( <TAB> <TAB> <TAB> <TAB> volume, hostname = hostname, auto = auto, portPos = port, lun = lun_id <TAB> <TAB> <TAB> ) <TAB> <TAB> vlun_info = None <TAB> <TAB> if location : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> vlun = location. split ( "","" ) <TAB> <TAB> <TAB> vlun_info = { <TAB> <TAB> <TAB> <TAB> ""volume_name"" : vlun [ 0 ], <TAB> <TAB> <TAB> <TAB> ""lun_id"" : int ( vlun [ 1 ] ), <TAB> <TAB> <TAB> <TAB> ""host_name"" : vlun [ 2 ], <TAB> <TAB> <TAB> } <TAB> <TAB> <TAB> if len ( vlun ) > 3 : <TAB> <TAB> <TAB> <TAB> vlun_info [ ""nsp"" ] = vlun [ 3 ] <TAB> <TAB> return vlun_info <TAB> except hpeexceptions. HTTPBadRequest as e : <TAB> <TAB> if ""must be in the same domain"" in e. get_description ( ) : <TAB> <TAB> <TAB> LOG. error ( e. get_description ( ) ) <TAB> <TAB> <TAB> raise exception. Invalid3PARDomain",False,nsp is None,volume,0.6635576486587524
|
||
|
2165,"def as_dict ( self ) -> Dict [ str, Any ] : <TAB> od : Dict [ str, Any ] = { <TAB> <TAB> ""_errors"" : self. errors, <TAB> <TAB> ""_notices"" : self. notices, <TAB> <TAB> ""_fast_validation_disagreements"" : self. fast_validation_disagreements, <TAB> <TAB> ""_sources"" : { }, <TAB> } <TAB> if self. helm_chart : <TAB> <TAB> od [ ""_helm_chart"" ] = self. helm_chart <TAB> for k, v in self. sources. items ( ) : <TAB> <TAB> sd = dict ( v ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> sd [ ""_errors"" ] = [ x. as_dict ( ) for x in v. _errors ] <TAB> <TAB> od [ ""_sources"" ] [ k ] = sd <TAB> for kind, configs in self. config. items ( ) : <TAB> <TAB> od [ kind ] = { } <TAB> <TAB> for rkey, config in configs. items ( ) : <TAB> <TAB> <TAB> od [ kind ] [ rkey ] = config. as_dict ( ) <TAB> return od",False,'_errors' in v,self._errors,0.667580246925354
|
||
|
2166,"def expire_connections ( now, mux ) : <TAB> remove = [ ] <TAB> for chan, timeout in dnsreqs. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> debug3 ( ""expiring dnsreqs channel=%d\n"" % chan ) <TAB> <TAB> <TAB> remove. append ( chan ) <TAB> <TAB> <TAB> del mux. channels [ chan ] <TAB> for chan in remove : <TAB> <TAB> del dnsreqs [ chan ] <TAB> debug3 ( ""Remaining DNS requests: %d\n"" % len ( dnsreqs ) ) <TAB> remove = [ ] <TAB> for peer, ( chan, timeout ) in udp_by_src. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> debug3 ( ""expiring UDP channel channel=%d peer=%r\n"" % ( chan, peer ) ) <TAB> <TAB> <TAB> mux. send ( chan, ssnet. CMD_UDP_CLOSE, b"""" ) <TAB> <TAB> <TAB> remove. append ( peer ) <TAB> <TAB> <TAB> del mux. channels [ chan ] <TAB> for peer in remove : <TAB> <TAB> del udp_by_src [ peer ] <TAB> debug3 ( ""Remaining UDP channels: %d\n"" % len ( udp_by_src ) )",False,timeout < now,timeout > 0,0.6669130325317383
|
||
|
2167,"def format ( self, record ) : <TAB> """"""Customize the message format based on the log level."""""" <TAB> if isinstance ( self. fmt, dict ) : <TAB> <TAB> self. _fmt = self. fmt [ record. levelname ] <TAB> <TAB> if sys. version_info > ( 3, 2 ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Style must be one of: %s"" % "","". join ( logging. _STYLES. keys ( ) ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> self. _style = logging. _STYLES [ self. style ] [ 0 ] ( self. _fmt ) <TAB> if sys. version_info > ( 2, 7 ) : <TAB> <TAB> message = super ( LevelFormatter, self ). format ( record ) <TAB> else : <TAB> <TAB> message = ColoredFormatter. format ( self, record ) <TAB> return message",True,self.style not in logging._STYLES,self.style not in logging._STYLES,0.6563971042633057
|
||
|
2168,"def remove_from_index ( self, type, tag, id ) : <TAB> tag_to_object = ""tag-{}s"". format ( type ) <TAB> object_to_tag = ""{}-tags"". format ( type ) <TAB> if tag in self. indices [ tag_to_object ] : <TAB> <TAB> if id in self. indices [ tag_to_object ] [ tag ] : <TAB> <TAB> <TAB> self. indices [ tag_to_object ] [ tag ]. remove ( id ) <TAB> <TAB> <TAB> if len ( self. indices [ tag_to_object ] [ tag ] ) == 0 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> del self. indices [ tag_to_object ] [ tag ] <TAB> if id in self. indices [ object_to_tag ] : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. indices [ object_to_tag ] [ id ]. remove ( tag ) <TAB> <TAB> <TAB> if len ( self. indices [ object_to_tag ] [ id ] ) == 0 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> del self. indices [ object_to_tag ] [ id ]",False,tag in self.indices[object_to_tag][id],tag in self.indices[object_to_tag],0.6559015512466431
|
||
|
2169,"def process_request ( self, request ) : <TAB> for exemption in self. exemptions : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return None <TAB> if not request. user. is_authenticated ( ) : <TAB> <TAB> path = urlquote ( request. get_full_path ( ) ) <TAB> <TAB> tup = ( self. login_url, self. redirect_field_name, path ) <TAB> <TAB> return HttpResponseRedirect ( ""%s?%s=%s"" % tup )",True,"re.match(exemption, request.path)","re.match(exemption, request.path)",0.6481633186340332
|
||
|
2170,"def check_apns_certificate ( ss ) : <TAB> mode = ""start"" <TAB> for s in ss. split ( ""\n"" ) : <TAB> <TAB> if mode == ""start"" : <TAB> <TAB> <TAB> if ""BEGIN RSA PRIVATE KEY"" in s or ""BEGIN PRIVATE KEY"" in s : <TAB> <TAB> <TAB> <TAB> mode = ""key"" <TAB> <TAB> elif mode == ""key"" : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> mode = ""end"" <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> elif s. startswith ( ""Proc-Type"" ) and ""ENCRYPTED"" in s : <TAB> <TAB> <TAB> <TAB> raise ImproperlyConfigured ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Encrypted APNS private keys are not supported"" <TAB> <TAB> <TAB> <TAB> ) <TAB> if mode!= ""end"" : <TAB> <TAB> raise ImproperlyConfigured ( ""The APNS certificate doesn't contain a private key"" )",False,'END RSA PRIVATE KEY' in s or 'END PRIVATE KEY' in s,s.startswith('APNS private key'),0.6740132570266724
|
||
|
2171,"def _extract_video_id ( data, lesson_id ) : <TAB> if not data : <TAB> <TAB> return <TAB> groups = try_get ( data, lambda x : x [ ""groups"" ], list ) or [ ] <TAB> if not groups : <TAB> <TAB> return <TAB> for group in groups : <TAB> <TAB> if not isinstance ( group, dict ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> contents = try_get ( data, lambda x : x [ ""contents"" ], list ) or [ ] <TAB> <TAB> for content in contents : <TAB> <TAB> <TAB> if not isinstance ( content, dict ) : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> ordinal = int_or_none ( content. get ( ""ordinal"" ) ) <TAB> <TAB> <TAB> if ordinal!= lesson_id : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> video_id = content. get ( ""identifier"" ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return compat_str ( video_id )",True,video_id,video_id,0.6645613312721252
|
||
|
2172,"def throttle_status ( server = None ) : <TAB> result = AmonStruct ( ) <TAB> result. allow = False <TAB> last_check = server. get ( ""last_check"" ) <TAB> server_check_period = server. get ( ""check_every"", 60 ) <TAB> if last_check : <TAB> <TAB> period_since_last_check = unix_utc_now ( ) - last_check <TAB> <TAB> <TAB> <TAB> period_since_last_check = period_since_last_check + 15 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> result. allow = True <TAB> else : <TAB> <TAB> result. allow = True <TAB> return result",False,period_since_last_check >= server_check_period,period_since_last_check > server_check_period,0.646797776222229
|
||
|
2173,"def parse_body ( f, headers ) : <TAB> """"""Return HTTP body parsed from a file object, given HTTP header dict."""""" <TAB> if headers. get ( ""transfer-encoding"", """" ). lower ( ) == ""chunked"" : <TAB> <TAB> l_ = [ ] <TAB> <TAB> found_end = False <TAB> <TAB> while 1 : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> sz = f. readline ( ). split ( None, 1 ) [ 0 ] <TAB> <TAB> <TAB> except IndexError : <TAB> <TAB> <TAB> <TAB> raise dpkt. UnpackError ( ""missing chunk size"" ) <TAB> <TAB> <TAB> n = int ( sz, 16 ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> found_end = True <TAB> <TAB> <TAB> buf = f. read ( n ) <TAB> <TAB> <TAB> if f. readline ( ). strip ( ) : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> if n and len ( buf ) == n : <TAB> <TAB> <TAB> <TAB> l_. append ( buf ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> if not found_end : <TAB> <TAB> <TAB> raise dpkt. NeedData ( ""premature end of chunked body"" ) <TAB> <TAB> body = b"""". join ( l_ ) <TAB> elif ""content-length"" in headers : <TAB> <TAB> n = int ( headers [ ""content-length"" ] ) <TAB> <TAB> body = f. read ( n ) <TAB> <TAB> if len ( body )!= n : <TAB> <TAB> <TAB> raise dpkt. NeedData ( ""short body (missing %d bytes)"" % ( n - len ( body ) ) ) <TAB> elif ""content-type"" in headers : <TAB>",False,n == 0,n > 0,0.673944354057312
|
||
|
2174,"def search ( self, string, pos = 0, endpos = None ) : <TAB> <TAB> <TAB> <TAB> <TAB> if not endpos is None : <TAB> <TAB> string = string [ : endpos ] <TAB> if pos == 0 : <TAB> <TAB> groups = self. search_code. Exec ( string ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return None <TAB> <TAB> _groups = [ ] <TAB> <TAB> for i in list ( groups ) : <TAB> <TAB> <TAB> if JS ( ""@{{i}} === null"" ) : <TAB> <TAB> <TAB> <TAB> _groups. append ( None ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> _groups. append ( str ( i ) ) <TAB> <TAB> groups = _groups <TAB> elif pos >= len ( string ) : <TAB> <TAB> return None <TAB> else : <TAB> <TAB> <TAB> <TAB> groups = self. search_code. Exec ( string [ pos : ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return None <TAB> <TAB> _groups = [ ] <TAB> <TAB> for i in list ( groups ) : <TAB> <TAB> <TAB> if JS ( ""@{{i}} === null"" ) : <TAB> <TAB> <TAB> <TAB> _groups. append ( None ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> _groups. append ( str ( i ) ) <TAB> <TAB> groups = _groups <TAB> return SRE_Match ( <TAB> <TAB> self, string, pos, endpos, groups [ 2 : ], pos + len ( groups [ 1 ] ), None, None <TAB> )",False,JS('@{{groups}} === null'),groups == [],0.6661504507064819
|
||
|
2175,"def find_rulers ( self ) : <TAB> on_first_line = False <TAB> on_message_body = False <TAB> subject_near_limit = ( <TAB> <TAB> len ( self. view. substr ( self. view. line ( sublime. Region ( 0 ) ) ). rstrip ( ) ) >= 40 <TAB> ) <TAB> for region in self. view. sel ( ) : <TAB> <TAB> first_line = self. view. rowcol ( region. begin ( ) ) [ 0 ] <TAB> <TAB> last_line = self. view. rowcol ( region. end ( ) ) [ 0 ] <TAB> <TAB> if first_line == 0 and subject_near_limit : <TAB> <TAB> <TAB> on_first_line = True <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if first_line in range ( 2, self. first_comment_line ) or last_line in range ( <TAB> <TAB> <TAB> <TAB> 2, self. first_comment_line <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> on_message_body = True <TAB> <TAB> else : <TAB> <TAB> <TAB> if first_line >= 2 or last_line >= 2 : <TAB> <TAB> <TAB> <TAB> on_message_body = True <TAB> new_rulers = [ ] <TAB> if on_first_line : <TAB> <TAB> new_rulers. append ( self. first_line_limit ) <TAB> if on_message_body : <TAB> <TAB> new_rulers. append ( self. body_line_limit ) <TAB> return new_rulers",False,self.first_comment_line,self.first_comment_line and (not on_message_body),0.6497775316238403
|
||
|
2176,"def main ( ) : <TAB> """"""Main processing."""""" <TAB> from optparse import OptionParser <TAB> parser = OptionParser ( usage = ""%%prog [options]\nVersion: %s"" % VERSION ) <TAB> parser. add_option ( <TAB> <TAB> ""-f"", <TAB> <TAB> ""--force"", <TAB> <TAB> action = ""store_true"", <TAB> <TAB> dest = ""force"", <TAB> <TAB> default = False, <TAB> <TAB> help = ( <TAB> <TAB> <TAB> ""Ignore session expiration. "" <TAB> <TAB> <TAB> ""Force expiry based on -x option or auth.settings.expiration."" <TAB> <TAB> ), <TAB> ) <TAB> parser. add_option ( <TAB> <TAB> ""-o"", <TAB> <TAB> ""--once"", <TAB> <TAB> action = ""store_true"", <TAB> <TAB> dest = ""once"", <TAB> <TAB> default = False, <TAB> <TAB> help = ""Delete sessions, then exit."", <TAB> ) <TAB> parser. add_option ( <TAB> <TAB> ""-s"", <TAB> <TAB> ""--sleep"", <TAB> <TAB> dest = ""sleep"", <TAB> <TAB> default = SLEEP_MINUTES * 60, <TAB> <TAB> type = ""int"", <TAB> <TAB> help = ""Number of seconds to sleep between executions. Default 300."", <TAB> ) <TAB> parser. add_option ( <TAB> <TAB> ""-v"", <TAB> <TAB> ""--verbose"", <TAB> <TAB> default = 0, <TAB> <TAB> action = ""count"", <TAB> <TAB> help = ""print verbose output, a second -v increases verbosity"", <TAB> ) <TAB> parser. add_option ( <TAB> <TAB> ""-x"", <TAB> <TAB> ""--expiration"", <TAB> <TAB> dest = ""expiration"", <TAB> <TAB> default = None, <TAB> <TAB> type = ""int"", <TAB> <TAB> help = ""Expiration value for sessions without expiration (in seconds)"", <",False,options.once,default is False,0.669709324836731
|
||
|
2177,"def identifier_to_cached_target ( identifier, hash_func, namespace = None ) : <TAB> if "":"" in identifier : <TAB> <TAB> image_name, version = identifier. rsplit ( "":"", 1 ) <TAB> else : <TAB> <TAB> image_name = identifier <TAB> <TAB> version = None <TAB> if not version or version == ""latest"" : <TAB> <TAB> version = None <TAB> image = None <TAB> prefix = """" <TAB> if namespace is not None : <TAB> <TAB> prefix = ""quay.io/%s/"" % namespace <TAB> if image_name. startswith ( prefix + ""mulled-v1-"" ) : <TAB> <TAB> if hash_func == ""v2"" : <TAB> <TAB> <TAB> return None <TAB> <TAB> hash = image_name <TAB> <TAB> build = None <TAB> <TAB> if version and version. isdigit ( ) : <TAB> <TAB> <TAB> build = version <TAB> <TAB> image = CachedV1MulledImageMultiTarget ( hash, build, identifier ) <TAB> elif image_name. startswith ( prefix + ""mulled-v2-"" ) : <TAB> <TAB> if hash_func == ""v1"" : <TAB> <TAB> <TAB> return None <TAB> <TAB> version_hash = None <TAB> <TAB> build = None <TAB> <TAB> if version and ""-"" in version : <TAB> <TAB> <TAB> version_hash, build = version. rsplit ( ""-"", 1 ) <TAB> <TAB> elif version. isdigit ( ) : <TAB> <TAB> <TAB> version_hash, build = None, version <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> log. debug ( ""Unparsable mulled image tag encountered [%s]"" % version ) <TAB> <TAB> image = CachedV2MulledImageMultiTarget ( <TAB> <TAB> <TAB> image_name, version_hash, build, identifier <TAB> <TAB> ) <TAB> else : <TAB> <TAB> build = None <TAB> <TAB> if version and ""--"" in version : <TAB> <TAB> <TAB> version, build = split_",False,version,version and version_hash,0.6854219436645508
|
||
|
2178,"def test_interestingness_1_1_0 ( global_var ) : <TAB> df = pytest. car_df <TAB> df [ ""Year"" ] = pd. to_datetime ( df [ ""Year"" ], format = ""%Y"" ) <TAB> df. set_intent ( [ lux. Clause ( attribute = ""Horsepower"" ), lux. Clause ( attribute = ""Year"" ) ] ) <TAB> df. _repr_html_ ( ) <TAB> <TAB> assert interestingness ( df. recommendation [ ""Enhance"" ] [ 0 ], df )!= None <TAB> <TAB> assert interestingness ( df. recommendation [ ""Filter"" ] [ 0 ], df )!= None <TAB> rank1 = - 1 <TAB> rank2 = - 1 <TAB> rank3 = - 1 <TAB> for f in range ( 0, len ( df. recommendation [ ""Filter"" ] ) ) : <TAB> <TAB> vis = df. recommendation [ ""Filter"" ] [ f ] <TAB> <TAB> if len ( vis. get_attr_by_attr_name ( ""Cylinders"" ) ) > 0 : <TAB> <TAB> <TAB> if int ( vis. _inferred_intent [ 2 ]. value ) == 6 : <TAB> <TAB> <TAB> <TAB> rank1 = f <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> rank2 = f <TAB> <TAB> if len ( vis. get_attr_by_attr_name ( ""Origin"" ) ) > 0 : <TAB> <TAB> <TAB> if str ( vis. _inferred_intent [ 2 ]. value ) == ""Europe"" : <TAB> <TAB> <TAB> <TAB> rank3 = f <TAB> assert rank1 < rank2 and rank1 < rank3 and rank2 < rank3 <TAB> <TAB> assert interestingness ( df. recommendation [ ""Filter"" ] [ 0 ], df )!= None <TAB> df. clear_intent ( )",False,int(vis._inferred_intent[2].value) == 8,"len( vis.get_attr_by_attr_name( ""Origin"") > 0",0.6497321128845215
|
||
|
2179,"def __init__ ( self, * args, ** kwargs ) : <TAB> assert len ( kwargs ) in ( 0, 1, 2 ), ( <TAB> <TAB> type ( self ). __name__ + ': expected 0 to 2 extra parameters (""ctype"", ""cname"").' <TAB> ) <TAB> ctype = kwargs. pop ( ""ctype"", ""int"" ) <TAB> cname = kwargs. pop ( ""cname"", None ) <TAB> for arg_rank, arg in enumerate ( args ) : <TAB> <TAB> if isinstance ( arg, ( list, tuple ) ) : <TAB> <TAB> <TAB> if len ( arg )!= 2 : <TAB> <TAB> <TAB> <TAB> raise TypeError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""%s: when using a tuple to define a constant, your tuple should contain 2 values: "" <TAB> <TAB> <TAB> <TAB> <TAB> ""constant name followed by constant alias."" % type ( self ). __name__ <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> constant_name, constant_alias = arg <TAB> <TAB> <TAB> if not isinstance ( constant_alias, str ) : <TAB> <TAB> <TAB> <TAB> raise TypeError ( <TAB> <TAB> <TAB> <TAB> <TAB> '%s: constant alias should be a string, got ""%s"".' <TAB> <TAB> <TAB> <TAB> <TAB> % ( type ( self ). __name__, constant_alias ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> constant_value = ( constant_alias, arg_rank ) <TAB> <TAB> else : <TAB> <TAB> <TAB> constant_name = arg <TAB> <TAB> <TAB> constant_value = arg_rank <TAB> <TAB> if not isinstance ( constant_name, str ) : <TAB> <TAB> <TAB> raise TypeError ( <TAB> <TAB> <TAB> <TAB> '%s: constant name should be a string, got ""%s"".' <TAB> <TAB> <TAB> <TAB> % ( type ( self ). __name__, constant_name",False,constant_name in kwargs,self.constant_name is None,0.6623759269714355
|
||
|
2180,"def setup_data ( self, path ) : <TAB> print ( ""loading: "" + path ) <TAB> tree = ET. parse ( path ) <TAB> root = tree. getroot ( ) <TAB> for child in root : <TAB> <TAB> asks_for = child. attrib [ ""asks-for"" ] <TAB> <TAB> answer = child. attrib [ ""most-plausible-alternative"" ] <TAB> <TAB> premise = child [ 0 ]. text <TAB> <TAB> alternative_one = child [ 1 ]. text <TAB> <TAB> alternative_two = child [ 2 ]. text <TAB> <TAB> if asks_for == ""cause"" : <TAB> <TAB> <TAB> premise += "" "" + COPA_CAUSE_SUFFIX <TAB> <TAB> else : <TAB> <TAB> <TAB> premise += "" "" + COPA_RESULT_SUFFIX <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> answer = [ alternative_one ] <TAB> <TAB> else : <TAB> <TAB> <TAB> answer = [ alternative_two ] <TAB> <TAB> answer_options = [ alternative_one, alternative_two ] <TAB> <TAB> yield ( premise, answer, None, answer_options ), True",False,answer == '1',asks_for == 'e',0.6719765067100525
|
||
|
2181,"def run ( self, parent, blocks ) : <TAB> """"""Find, set, and remove footnote definitions."""""" <TAB> block = blocks. pop ( 0 ) <TAB> m = self. RE. search ( block ) <TAB> if m : <TAB> <TAB> id = m. group ( 1 ) <TAB> <TAB> fn_blocks = [ m. group ( 2 ) ] <TAB> <TAB> <TAB> <TAB> therest = block [ m. end ( ) : ]. lstrip ( ""\n"" ) <TAB> <TAB> m2 = self. RE. search ( therest ) <TAB> <TAB> if m2 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> before = therest [ : m2. start ( ) ]. rstrip ( ""\n"" ) <TAB> <TAB> <TAB> fn_blocks [ 0 ] = ""\n"". join ( [ fn_blocks [ 0 ], self. detab ( before ) ] ). lstrip ( ""\n"" ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> blocks. insert ( 0, therest [ m2. start ( ) : ] ) <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> fn_blocks [ 0 ] = ""\n"". join ( [ fn_blocks [ 0 ], self. detab ( therest ) ] ). strip ( ""\n"" ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> fn_blocks. extend ( self. detectTabbed ( blocks ) ) <TAB> <TAB> footnote = ""\n\n"". join ( fn_blocks ) <TAB> <TAB> self. footnotes. setFootnote ( id, footnote. rstrip ( ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> blocks. insert ( 0, block [ : m. start ( ) ]. rstrip ( ""\n"" ) ) <TAB> <TAB> return True <TAB> <TAB> blocks. insert ( 0, block ) <TAB> return False",False,block[:m.start()].strip(),len(block) > 0,0.6504757404327393
|
||
|
2182,"def needs_appliance ( test_item ) : <TAB> import json <TAB> test_item = _mark_test ( ""appliance"", test_item ) <TAB> if os. getenv ( ""TOIL_SKIP_DOCKER"", """" ). lower ( ) == ""true"" : <TAB> <TAB> return unittest. skip ( ""Skipping docker test."" ) ( test_item ) <TAB> if which ( ""docker"" ) : <TAB> <TAB> image = applianceSelf ( ) <TAB> <TAB> try : <TAB> <TAB> <TAB> images = subprocess. check_output ( [ ""docker"", ""inspect"", image ] ). decode ( <TAB> <TAB> <TAB> <TAB> ""utf-8"" <TAB> <TAB> <TAB> ) <TAB> <TAB> except subprocess. CalledProcessError : <TAB> <TAB> <TAB> images = [ ] <TAB> <TAB> else : <TAB> <TAB> <TAB> images = { i [ ""Id"" ] for i in json. loads ( images ) if image in i [ ""RepoTags"" ] } <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return unittest. skip ( <TAB> <TAB> <TAB> <TAB> ""Cannot find appliance image %s. Use'make test' target to "" <TAB> <TAB> <TAB> <TAB> ""automatically build appliance, or just run'make docker' "" <TAB> <TAB> <TAB> <TAB> ""prior to running this test."" % image <TAB> <TAB> <TAB> ) ( test_item ) <TAB> <TAB> elif len ( images ) == 1 : <TAB> <TAB> <TAB> return test_item <TAB> <TAB> else : <TAB> <TAB> <TAB> assert False, ""Expected `docker inspect` to return zero or one image."" <TAB> else : <TAB> <TAB> return unittest. skip ( ""Install Docker to include this test."" ) ( test_item )",True,len(images) == 0,len(images) == 0,0.6541647911071777
|
||
|
2183,"def pytest_runtestloop ( self, session ) : <TAB> self. log ( ""entering main loop"" ) <TAB> torun = [ ] <TAB> while 1 : <TAB> <TAB> try : <TAB> <TAB> <TAB> name, kwargs = self. channel. receive ( ) <TAB> <TAB> except EOFError : <TAB> <TAB> <TAB> return True <TAB> <TAB> self. log ( ""received command"", name, kwargs ) <TAB> <TAB> if name == ""runtests"" : <TAB> <TAB> <TAB> torun. extend ( kwargs [ ""indices"" ] ) <TAB> <TAB> elif name == ""runtests_all"" : <TAB> <TAB> <TAB> torun. extend ( range ( len ( session. items ) ) ) <TAB> <TAB> self. log ( ""items to run:"", torun ) <TAB> <TAB> <TAB> <TAB> while len ( torun ) >= 2 : <TAB> <TAB> <TAB> self. run_one_test ( torun ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if torun : <TAB> <TAB> <TAB> <TAB> self. run_one_test ( torun ) <TAB> <TAB> <TAB> break <TAB> return True",False,name == 'shutdown',session,0.6624027490615845
|
||
|
2184,"def _generate_measurement_ids ( self ) -> Tuple [ Dict [ str, str ], Dict [ str, Optional [ str ] ] ] : <TAB> <TAB> meas_key_id_map = { } <TAB> meas_comments = { } <TAB> meas_i = 0 <TAB> for meas in self. measurements : <TAB> <TAB> key = protocols. measurement_key ( meas ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> meas_id = ""m_{}"". format ( key ) <TAB> <TAB> if self. is_valid_qasm_id ( meas_id ) : <TAB> <TAB> <TAB> meas_comments [ key ] = None <TAB> <TAB> else : <TAB> <TAB> <TAB> meas_id = ""m{}"". format ( meas_i ) <TAB> <TAB> <TAB> meas_i += 1 <TAB> <TAB> <TAB> meas_comments [ key ] = "" "". join ( key. split ( ""\n"" ) ) <TAB> <TAB> meas_key_id_map [ key ] = meas_id <TAB> return meas_key_id_map, meas_comments",True,key in meas_key_id_map,key in meas_key_id_map,0.6538110971450806
|
||
|
2185,"def ns_provides ( self ) : <TAB> ans = [ ] <TAB> <TAB> logTabWidget = self. get_top_splitter ( ). find_child ( QtWidgets. QWidget, ""logTabWidget"" ) <TAB> for n in range ( logTabWidget. count ( ) ) : <TAB> <TAB> text = str ( logTabWidget. tabText ( n ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> if text == ""Log"" : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> ans. append ( ( text, ""_leo_tab:"" + text ) ) <TAB> ans. append ( ( ""Tree"", ""_leo_pane:outlineFrame"" ) ) <TAB> ans. append ( ( ""Body"", ""_leo_pane:bodyFrame"" ) ) <TAB> ans. append ( ( ""Tab pane"", ""_leo_pane:logFrame"" ) ) <TAB> return ans",False,"text in ('Body', 'Tree')","text == ""None'",0.6501554846763611
|
||
|
2186,"def apply_figure ( self, figure ) : <TAB> super ( legend_text_legend, self ). apply_figure ( figure ) <TAB> properties = self. properties. copy ( ) <TAB> with suppress ( KeyError ) : <TAB> <TAB> del properties [ ""margin"" ] <TAB> with suppress ( KeyError ) : <TAB> <TAB> texts = figure. _themeable [ ""legend_text_legend"" ] <TAB> <TAB> for text in texts : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> text = text. _text <TAB> <TAB> <TAB> text. set ( ** properties )",False,"not hasattr(text, '_x')",properties,0.6529051065444946
|
||
|
2187,"def from_doh_simple ( simple, add_qr = False ) : <TAB> message = dns. message. QueryMessage ( ) <TAB> flags = 0 <TAB> for f in dns. flags. Flag : <TAB> <TAB> if simple. get ( f. name, False ) : <TAB> <TAB> <TAB> flags |= f <TAB> if add_qr : <TAB> <TAB> flags |= dns. flags. QR <TAB> message. flags = flags <TAB> message. set_rcode ( simple. get ( ""Status"", 0 ) ) <TAB> for i, sn in enumerate ( dns. message. MessageSection ) : <TAB> <TAB> rr_list = simple. get ( sn. name. title ( ), [ ] ) <TAB> <TAB> for rr in rr_list : <TAB> <TAB> <TAB> rdtype = dns. rdatatype. RdataType ( rr [ ""type"" ] ) <TAB> <TAB> <TAB> rrs = message. find_rrset ( <TAB> <TAB> <TAB> <TAB> i, <TAB> <TAB> <TAB> <TAB> dns. name. from_text ( rr [ ""name"" ] ), <TAB> <TAB> <TAB> <TAB> dns. rdataclass. IN, <TAB> <TAB> <TAB> <TAB> rdtype, <TAB> <TAB> <TAB> <TAB> create = True, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> rrs. add ( <TAB> <TAB> <TAB> <TAB> <TAB> dns. rdata. from_text ( dns. rdataclass. IN, rdtype, rr [ ""data"" ] ), <TAB> <TAB> <TAB> <TAB> <TAB> rr. get ( ""TTL"", 0 ), <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> return message",False,'data' in rr,rrs,0.6665961742401123
|
||
|
2188,"def main ( args = None ) : <TAB> if args is None : <TAB> <TAB> args = sys. argv [ 1 : ] <TAB> import argparse <TAB> parser = ConfigBackedParser ( <TAB> <TAB> ""hg-nbdiffweb"", <TAB> <TAB> description = __doc__, <TAB> <TAB> formatter_class = argparse. RawDescriptionHelpFormatter, <TAB> ) <TAB> nbdifftool. build_arg_parser ( parser ) <TAB> opts = parser. parse_args ( args ) <TAB> <TAB> if not os. path. isfile ( opts. local ) or not os. path. isfile ( opts. remote ) : <TAB> <TAB> local, remote = opts. local, opts. remote <TAB> <TAB> for a, b in diff_directories ( local, remote ) : <TAB> <TAB> <TAB> opts. local, opts. remote = a, b <TAB> <TAB> <TAB> ret = nbdifftool. main_parsed ( opts ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return ret <TAB> <TAB> return ret <TAB> else : <TAB> <TAB> return nbdifftool. main_parsed ( opts )",False,ret != 0,ret is not None,0.6697608232498169
|
||
|
2189,"def version_dict ( self ) : <TAB> <TAB> self. _version_dict = defaultdict ( list ) <TAB> for finder_name, finder in self. __finders. items ( ) : <TAB> <TAB> for version, entry in finder. versions. items ( ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> if entry not in self. _version_dict [ version ] : <TAB> <TAB> <TAB> <TAB> <TAB> self. _version_dict [ version ]. append ( entry ) <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if entry not in self. _version_dict [ version ] and entry. is_python : <TAB> <TAB> <TAB> <TAB> self. _version_dict [ version ]. append ( entry ) <TAB> for p, entry in self. python_executables. items ( ) : <TAB> <TAB> version = entry. as_python <TAB> <TAB> if not version : <TAB> <TAB> <TAB> continue <TAB> <TAB> if not isinstance ( version, tuple ) : <TAB> <TAB> <TAB> version = version. version_tuple <TAB> <TAB> if version and entry not in self. _version_dict [ version ] : <TAB> <TAB> <TAB> self. _version_dict [ version ]. append ( entry ) <TAB> return self. _version_dict",False,finder_name == 'windows',finder_name == version,0.6603221297264099
|
||
|
2190,"def serialize_bytes ( data ) : <TAB> """"""Write bytes by using Telegram guidelines"""""" <TAB> if not isinstance ( data, bytes ) : <TAB> <TAB> if isinstance ( data, str ) : <TAB> <TAB> <TAB> data = data. encode ( ""utf-8"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise TypeError ( ""bytes or str expected, not {}"". format ( type ( data ) ) ) <TAB> r = [ ] <TAB> if len ( data ) < 254 : <TAB> <TAB> padding = ( len ( data ) + 1 ) % 4 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> padding = 4 - padding <TAB> <TAB> r. append ( bytes ( [ len ( data ) ] ) ) <TAB> <TAB> r. append ( data ) <TAB> else : <TAB> <TAB> padding = len ( data ) % 4 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> padding = 4 - padding <TAB> <TAB> r. append ( <TAB> <TAB> <TAB> bytes ( <TAB> <TAB> <TAB> <TAB> [ 254, len ( data ) % 256, ( len ( data ) >> 8 ) % 256, ( len ( data ) >> 16 ) % 256 ] <TAB> <TAB> <TAB> ) <TAB> <TAB> ) <TAB> <TAB> r. append ( data ) <TAB> r. append ( bytes ( padding ) ) <TAB> return b"""". join ( r )",False,padding != 0,padding > 0,0.6864440441131592
|
||
|
2191,"def check_strings ( self ) : <TAB> """"""Check that all strings have been consumed."""""" <TAB> for i, aList in enumerate ( self. string_tokens ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> g. trace ( ""warning: line %s. unused strings"" % i ) <TAB> <TAB> <TAB> for z in aList : <TAB> <TAB> <TAB> <TAB> print ( self. dump_token ( z ) )",False,aList,i % self.debug_interval == 0,0.6724624037742615
|
||
|
2192,"def _serve ( self ) : <TAB> self. _conn = self. manager. request ( REQUEST_DNS_LISTENER, self. domain ) <TAB> conn = MsgPackMessages ( self. _conn ) <TAB> while self. active : <TAB> <TAB> request = conn. recv ( ) <TAB> <TAB> if not request : <TAB> <TAB> <TAB> logger. warning ( ""DNS: Recieved empty request. Shutdown"" ) <TAB> <TAB> <TAB> self. stop ( ) <TAB> <TAB> <TAB> break <TAB> <TAB> now = time. time ( ) <TAB> <TAB> response = self. handler. process ( request ) <TAB> <TAB> if not response : <TAB> <TAB> <TAB> response = [ ] <TAB> <TAB> used = time. time ( ) - now <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> logger. warning ( ""DNS: Slow processing speed (%s)s"", used ) <TAB> <TAB> conn. send ( response )",False,used > 1,used > 0,0.6664760112762451
|
||
|
2193,"def forward ( <TAB> self, <TAB> hidden_states, <TAB> attention_mask = None, <TAB> head_mask = None, <TAB> encoder_hidden_states = None, <TAB> encoder_attention_mask = None, ) : <TAB> all_hidden_states = ( ) <TAB> all_attentions = ( ) <TAB> for i, layer_module in enumerate ( self. layer ) : <TAB> <TAB> if self. 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> encoder_hidden_states, <TAB> <TAB> <TAB> encoder_attention_mask, <TAB> <TAB> ) <TAB> <TAB> hidden_states = layer_outputs [ 0 ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> all_attentions = all_attentions + ( layer_outputs [ 1 ], ) <TAB> <TAB> if self. output_hidden_states : <TAB> <TAB> all_hidden_states = all_hidden_states + ( hidden_states, ) <TAB> outputs = ( hidden_states, ) <TAB> if self. output_hidden_states : <TAB> <TAB> outputs = outputs + ( all_hidden_states, ) <TAB> if<mask> : <TAB> <TAB> outputs = outputs + ( all_attentions, ) <TAB> return outputs",False,self.output_attentions,self.attention_mask,0.6525454521179199
|
||
|
2194,"def _find_remote_inputs ( metadata ) : <TAB> out = [ ] <TAB> for fr_key in metadata. keys ( ) : <TAB> <TAB> if isinstance ( fr_key, ( list, tuple ) ) : <TAB> <TAB> <TAB> frs = fr_key <TAB> <TAB> else : <TAB> <TAB> <TAB> frs = [ fr_key ] <TAB> <TAB> for fr in frs : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> out. append ( fr ) <TAB> return out",False,objectstore.is_remote(fr),not fr in out,0.6518054008483887
|
||
|
2195,"def __get ( self, base_call, key, * args, ** kwargs ) : <TAB> if key == ""title"" and ""title"" not in self and ""organization"" in self : <TAB> <TAB> return base_call ( ""organization"", * args, ** kwargs ) <TAB> <TAB> <TAB> if ( <TAB> <TAB> not self. multisong <TAB> <TAB> and key in ( ""title"", ""artist"" ) <TAB> <TAB> and ""title"" in self <TAB> <TAB> and ""artist"" not in self <TAB> ) : <TAB> <TAB> title = base_call ( ""title"" ). split ( "" - "", 1 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return ( key == ""title"" and title [ - 1 ] ) or title [ 0 ] <TAB> if ( <TAB> <TAB> key in ( ""artist"", TAG_TO_SORT [ ""artist"" ] ) <TAB> <TAB> and not base_call ( key, * args ) <TAB> <TAB> and ""website"" in self <TAB> ) : <TAB> <TAB> return base_call ( ""website"", * args ) <TAB> if key == ""~format"" and ""audio-codec"" in self : <TAB> <TAB> return ""%s (%s)"" % ( self. format, base_call ( ""audio-codec"", * args, ** kwargs ) ) <TAB> return base_call ( key, * args, ** kwargs )",False,len(title) > 1,len(title) > 0,0.6565163731575012
|
||
|
2196,"def manage_comment ( self, webhook_data ) : <TAB> if webhook_data is None : <TAB> <TAB> return { ""message"" : ""Nothing for me"" } <TAB> <TAB> message = re. search ( ""@{} (.*)"". format ( self. robot_name ), webhook_data. text, re. I ) <TAB> response = None <TAB> if message : <TAB> <TAB> command = message. group ( 1 ) <TAB> <TAB> split_text = command. lower ( ). split ( ) <TAB> <TAB> orderstr = split_text. pop ( 0 ) <TAB> <TAB> if orderstr == ""help"" : <TAB> <TAB> <TAB> response = self. help_order ( ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> webhook_data. comment. create_reaction ( ""+1"" ) <TAB> <TAB> <TAB> except GithubException : <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> with exception_to_github ( webhook_data. issue ) : <TAB> <TAB> <TAB> <TAB> response = getattr ( self. handler, orderstr ) ( <TAB> <TAB> <TAB> <TAB> <TAB> webhook_data. issue, * split_text <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> response = ""I didn't understand your command:\n```bash\n{}\n```\nin this context, sorry :(\n"". format ( <TAB> <TAB> <TAB> <TAB> command <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> response += self. help_order ( ) <TAB> <TAB> if response : <TAB> <TAB> <TAB> webhook_data. issue. create_comment ( response ) <TAB> <TAB> <TAB> return { ""message"" : response } <TAB> return { ""message"" : ""Nothing for me or exception"" }",False,orderstr in self.orders(),response,0.6614961624145508
|
||
|
2197,"def _setup_output_metrics ( self, engine : Engine ) -> Dict [ str, Any ] : <TAB> """"""Helper method to setup metrics to log"""""" <TAB> metrics = { } <TAB> if self. metric_names is not None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> metrics = engine. state. metrics <TAB> <TAB> else : <TAB> <TAB> <TAB> for name in self. metric_names : <TAB> <TAB> <TAB> <TAB> if name not in engine. state. metrics : <TAB> <TAB> <TAB> <TAB> <TAB> warnings. warn ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> f""Provided metric name '{name}' is missing "" <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> f""in engine's state metrics: {list(engine.state.metrics.keys())}"" <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> metrics [ name ] = engine. state. metrics [ name ] <TAB> if self. output_transform is not None : <TAB> <TAB> output_dict = self. output_transform ( engine. state. output ) <TAB> <TAB> if not isinstance ( output_dict, dict ) : <TAB> <TAB> <TAB> output_dict = { ""output"" : output_dict } <TAB> <TAB> metrics. update ( { name : value for name, value in output_dict. items ( ) } ) <TAB> return metrics",False,"isinstance(self.metric_names, str) and self.metric_names == 'all'",engine.state.metrics,0.653809666633606
|
||
|
2198,"def _infinite_indices ( self ) : <TAB> np. random. seed ( self. _seed ) <TAB> while True : <TAB> <TAB> avl_pids = copy. deepcopy ( self. pids ) <TAB> <TAB> batch_idxs_dict = { } <TAB> <TAB> batch_indices = [ ] <TAB> <TAB> while len ( avl_pids ) >= self. num_pids_per_batch : <TAB> <TAB> <TAB> selected_pids = np. random. choice ( <TAB> <TAB> <TAB> <TAB> avl_pids, self. num_pids_per_batch, replace = False <TAB> <TAB> <TAB> ). tolist ( ) <TAB> <TAB> <TAB> for pid in selected_pids : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if pid not in batch_idxs_dict : <TAB> <TAB> <TAB> <TAB> <TAB> idxs = copy. deepcopy ( self. pid_index [ pid ] ) <TAB> <TAB> <TAB> <TAB> <TAB> if len ( idxs ) < self. num_instances : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> idxs = np. random. choice ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> idxs, size = self. num_instances, replace = True <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ). tolist ( ) <TAB> <TAB> <TAB> <TAB> <TAB> np. random. shuffle ( idxs ) <TAB> <TAB> <TAB> <TAB> <TAB> batch_idxs_dict [ pid ] = idxs <TAB> <TAB> <TAB> <TAB> avl_idxs = batch_idxs_dict [ pid ] <TAB> <TAB> <TAB> <TAB> for _ in range ( self. num_instances ) : <TAB> <TAB> <TAB> <TAB> <TAB> batch_indices. append ( avl_idxs. pop ( 0 ) ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <",False,len(avl_idxs) < self.num_instances,len(batch_indices) > 0,0.6497932076454163
|
||
|
2199,"def extract_package ( package ) : <TAB> if VERSION >= 3006 : <TAB> <TAB> package_location = os. path. join ( <TAB> <TAB> <TAB> sublime. installed_packages_path ( ), package + "".sublime-package"" <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> package_location = os. path. join ( <TAB> <TAB> <TAB> <TAB> os. path. dirname ( sublime. executable_path ( ) ), <TAB> <TAB> <TAB> <TAB> ""Packages"", <TAB> <TAB> <TAB> <TAB> package + "".sublime-package"", <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> package_location = None <TAB> <TAB> if package_location : <TAB> <TAB> <TAB> with zipfile. ZipFile ( package_location ) as zip_file : <TAB> <TAB> <TAB> <TAB> extract_location = os. path. join ( sublime. packages_path ( ), package ) <TAB> <TAB> <TAB> <TAB> zip_file. extractall ( extract_location )",False,not os.path.exists(package_location),os.path.exists(package_location),0.6460158824920654
|
||
|
2200,"def __delitem__ ( self, key ) : <TAB> ""Deleting tag[key] deletes all 'key' attributes for the tag."" <TAB> for item in self. attrs : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. attrs. remove ( item ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _getAttrMap ( ) <TAB> <TAB> if self. attrMap. has_key ( key ) : <TAB> <TAB> <TAB> del self. attrMap [ key ]",False,item[0] == key,item in self.attrs,0.662900447845459
|
||
|
2201,"def parse_message ( message ) : <TAB> message = gtp. pre_engine ( message ). strip ( ) <TAB> first, rest = ( message. split ( "" "", 1 ) + [ None ] ) [ : 2 ] <TAB> if first. isdigit ( ) : <TAB> <TAB> message_id = int ( first ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> command, arguments = ( rest. split ( "" "", 1 ) + [ None ] ) [ : 2 ] <TAB> <TAB> else : <TAB> <TAB> <TAB> command, arguments = None, None <TAB> else : <TAB> <TAB> message_id = None <TAB> <TAB> command, arguments = first, rest <TAB> command = command. replace ( ""-"", ""_"" ) <TAB> return message_id, command, arguments",False,rest is not None,rest.digit(),0.6679273247718811
|
||
|
2202,"def __exit__ ( self, type, value, traceback ) : <TAB> try : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return self. exception_handler ( type, value, traceback ) <TAB> finally : <TAB> <TAB> final_contexts = _state. contexts <TAB> <TAB> _state. contexts = self. old_contexts <TAB> <TAB> if final_contexts is not self. new_contexts : <TAB> <TAB> <TAB> raise StackContextInconsistentError ( <TAB> <TAB> <TAB> <TAB> ""stack_context inconsistency (may be caused by yield "" <TAB> <TAB> <TAB> <TAB> 'within a ""with StackContext"" block)' <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> self. new_contexts = None",False,type is not None,self.exception_handler is not None,0.6561484336853027
|
||
|
2203,"def test_15_verify_jail_started ( ) : <TAB> global freeze, freeze_msg <TAB> if freeze is True : <TAB> <TAB> pytest. skip ( freeze_msg ) <TAB> freeze = False <TAB> job_status = wait_on_job ( JOB_ID, 20 ) <TAB> if job_status [ ""state"" ] in [ ""TIMEOUT"", ""FAILED"" ] : <TAB> <TAB> freeze = True <TAB> <TAB> freeze_msg = f""Failed to start jail: {JAIL_NAME}"" <TAB> assert job_status [ ""state"" ] == ""SUCCESS"", str ( job_status [ ""results"" ] ) <TAB> for run in range ( 10 ) : <TAB> <TAB> results = GET ( f""/jail/id/{JAIL_NAME}/"" ) <TAB> <TAB> assert results. status_code == 200, results. text <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> break <TAB> <TAB> time. sleep ( 1 ) <TAB> else : <TAB> <TAB> assert results. json ( ) [ ""state"" ] == ""up"", results. text",False,results.json()['state'] == 'up',run == 0,0.6483564972877502
|
||
|
2204,"def _write_assets ( self, asset_type, assets, txn, chunk_size, mapping_data = None ) : <TAB> if asset_type == ""future"" : <TAB> <TAB> tbl = futures_contracts_table <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise TypeError ( ""no mapping data expected for futures"" ) <TAB> elif asset_type == ""equity"" : <TAB> <TAB> tbl = equities_table <TAB> <TAB> if mapping_data is None : <TAB> <TAB> <TAB> raise TypeError ( ""mapping data required for equities"" ) <TAB> <TAB> <TAB> <TAB> self. _write_df_to_table ( <TAB> <TAB> <TAB> equity_symbol_mappings, <TAB> <TAB> <TAB> mapping_data, <TAB> <TAB> <TAB> txn, <TAB> <TAB> <TAB> chunk_size, <TAB> <TAB> <TAB> idx_label = ""sid"", <TAB> <TAB> ) <TAB> else : <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> ""asset_type must be in {'future', 'equity'}, got: %s"" % asset_type, <TAB> <TAB> ) <TAB> self. _write_df_to_table ( tbl, assets, txn, chunk_size ) <TAB> pd. DataFrame ( <TAB> <TAB> { <TAB> <TAB> <TAB> asset_router. c. sid. name : assets. index. values, <TAB> <TAB> <TAB> asset_router. c. asset_type. name : asset_type, <TAB> <TAB> } <TAB> ). to_sql ( <TAB> <TAB> asset_router. name, <TAB> <TAB> txn. connection, <TAB> <TAB> if_exists = ""append"", <TAB> <TAB> index = False, <TAB> <TAB> chunksize = chunk_size, <TAB> )",False,mapping_data is not None,mapping_data is None,0.6581676006317139
|
||
|
2205,"def unfulfilled_items ( self ) : <TAB> unfulfilled_items = 0 <TAB> for order_item in self. items. all ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> aggr = order_item. deliver_item. aggregate ( delivered = Sum ( ""quantity"" ) ) <TAB> <TAB> <TAB> unfulfilled_items += order_item. quantity - ( aggr [ ""delivered"" ] or 0 ) <TAB> return unfulfilled_items",False,not order_item.canceled,order_item.deliver_item,0.6553289890289307
|
||
|
2206,"def _quotesplit ( line ) : <TAB> inquote = None <TAB> inescape = None <TAB> wordstart = 0 <TAB> word = """" <TAB> for i in range ( len ( line ) ) : <TAB> <TAB> c = line [ i ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if inquote == q and c!= q : <TAB> <TAB> <TAB> <TAB> word += ""\\"" <TAB> <TAB> <TAB> word += c <TAB> <TAB> <TAB> inescape = False <TAB> <TAB> elif c == ""\\"" : <TAB> <TAB> <TAB> inescape = True <TAB> <TAB> elif c == inquote : <TAB> <TAB> <TAB> inquote = None <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> yield ( wordstart, word ) <TAB> <TAB> <TAB> word = """" <TAB> <TAB> <TAB> wordstart = i + 1 <TAB> <TAB> elif not inquote and not word and ( c == q or c == qq ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> inquote = c <TAB> <TAB> <TAB> wordstart = i <TAB> <TAB> elif not inquote and c in [ "" "", ""\n"", ""\r"", ""\t"" ] : <TAB> <TAB> <TAB> if word : <TAB> <TAB> <TAB> <TAB> yield ( wordstart, word ) <TAB> <TAB> <TAB> word = """" <TAB> <TAB> <TAB> wordstart = i + 1 <TAB> <TAB> else : <TAB> <TAB> <TAB> word += c <TAB> if word : <TAB> <TAB> yield ( wordstart, word ) <TAB> if inquote or inescape or word : <TAB> <TAB> raise QuoteError ( )",False,inescape,i == 0,0.6868882775306702
|
||
|
2207,"def _modify_config_data ( max_seq_length, num_train_data, num_classes ) : <TAB> <TAB> config_data_exists = os. path. isfile ( ""./config_data.py"" ) <TAB> if config_data_exists : <TAB> <TAB> with open ( ""./config_data.py"", ""r"" ) as file : <TAB> <TAB> <TAB> filedata = file. read ( ) <TAB> <TAB> <TAB> filedata_lines = filedata. split ( ""\n"" ) <TAB> <TAB> <TAB> idx = 0 <TAB> <TAB> <TAB> while True : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> line = filedata_lines [ idx ] <TAB> <TAB> <TAB> <TAB> if ( <TAB> <TAB> <TAB> <TAB> <TAB> line. startswith ( ""num_classes ="" ) <TAB> <TAB> <TAB> <TAB> <TAB> or line. startswith ( ""num_train_data ="" ) <TAB> <TAB> <TAB> <TAB> <TAB> or line. startswith ( ""max_seq_length ="" ) <TAB> <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> <TAB> filedata_lines. pop ( idx ) <TAB> <TAB> <TAB> <TAB> <TAB> idx -= 1 <TAB> <TAB> <TAB> <TAB> idx += 1 <TAB> <TAB> <TAB> if len ( filedata_lines ) > 0 : <TAB> <TAB> <TAB> <TAB> insert_idx = 1 <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> insert_idx = 0 <TAB> <TAB> <TAB> filedata_lines. insert ( <TAB> <TAB> <TAB> <TAB> insert_idx, ""{} = {}"". format ( ""num_train_data"", num_train_data ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> filedata_lines",False,idx >= len(filedata_lines),num_classes > 0,0.6521614789962769
|
||
|
2208,"def new ( obj : bpy. types. Object ) : <TAB> <TAB> <TAB> <TAB> <TAB> assert ( <TAB> <TAB> type ( obj ) is bpy. types. Object and type ( obj. data ) is bpy. types. Mesh <TAB> ), ""obj must be mesh object"" <TAB> <TAB> rfsource = None <TAB> if False : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> rfsource = RFSource. __cache [ obj. data. name ] <TAB> <TAB> <TAB> hashed = hash_object ( obj ) <TAB> <TAB> <TAB> if rfsource. hash!= hashed : <TAB> <TAB> <TAB> <TAB> rfsource = None <TAB> <TAB> if not rfsource : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> RFSource. creating = True <TAB> <TAB> <TAB> rfsource = RFSource ( ) <TAB> <TAB> <TAB> del RFSource. creating <TAB> <TAB> <TAB> rfsource. __setup__ ( obj ) <TAB> <TAB> <TAB> RFSource. __cache [ obj. data. name ] = rfsource <TAB> <TAB> else : <TAB> <TAB> <TAB> rfsource = RFSource. __cache [ obj. data. name ] <TAB> else : <TAB> <TAB> RFSource. creating = True <TAB> <TAB> rfsource = RFSource ( ) <TAB> <TAB> del RFSource. creating <TAB> <TAB> rfsource. __setup__ ( obj ) <TAB> return rfsource",False,obj.data.name in RFSource.__cache,"hasattr(obj, 'data')",0.6579772233963013
|
||
|
2209,"def test_set_classy_state_weight_inflation ( self ) : <TAB> <TAB> <TAB> <TAB> model_2d_config, model_3d_config = self. _get_model_config_weight_inflation ( ) <TAB> model_2d = build_model ( model_2d_config ) <TAB> model_2d_state = model_2d. get_classy_state ( ) <TAB> model_3d = build_model ( model_3d_config ) <TAB> model_3d. set_classy_state ( model_2d_state ) <TAB> model_3d_state = model_3d. get_classy_state ( ) <TAB> for name, weight_2d in model_2d_state [ ""model"" ] [ ""trunk"" ]. items ( ) : <TAB> <TAB> weight_3d = model_3d_state [ ""model"" ] [ ""trunk"" ] [ name ] <TAB> <TAB> if weight_2d. dim ( ) == 5 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. assertEqual ( weight_3d. dim ( ), 5 ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> weight_2d_inflated = ( <TAB> <TAB> <TAB> <TAB> <TAB> weight_2d. repeat ( 1, 1, weight_3d. shape [ 2 ], 1, 1 ) <TAB> <TAB> <TAB> <TAB> <TAB> / weight_3d. shape [ 2 ] <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> self. assertTrue ( torch. equal ( weight_3d, weight_2d_inflated ) )",False,weight_2d.shape[2] == 1 and weight_3d.shape[2] > 1,weight_3d.dim() == 3,0.6482073068618774
|
||
|
2210,"def _hints_to_binary ( pkg ) : <TAB> pkg_type = anchore_engine. utils. ensure_str ( pkg. get ( ""type"", ""binary"" ) ). lower ( ) <TAB> pkg_name = anchore_engine. utils. ensure_str ( pkg. get ( ""name"", """" ) ) <TAB> pkg_version = anchore_engine. utils. ensure_str ( pkg. get ( ""version"", """" ) ) <TAB> pkg_location = anchore_engine. utils. ensure_str ( <TAB> <TAB> pkg. get ( ""location"", ""/virtual/binarypkg/{}-{}"". format ( pkg_name, pkg_version ) ) <TAB> ) <TAB> pkg_license = anchore_engine. utils. ensure_str ( pkg. get ( ""license"", """" ) ) <TAB> pkg_origin = anchore_engine. utils. ensure_str ( pkg. get ( ""origin"", """" ) ) <TAB> pkg_files = pkg. get ( ""files"", [ ] ) <TAB> pkg_metadata = json. dumps ( pkg. get ( ""metadata"", { } ) ) <TAB> if not pkg_name or not pkg_version or not pkg_type : <TAB> <TAB> raise Exception ( <TAB> <TAB> <TAB> ""bad hints record, all hints records must supply at least a name, version and type"" <TAB> <TAB> ) <TAB> for inp in [ pkg_files ] : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise Exception ( <TAB> <TAB> <TAB> <TAB> ""bad hints record ({}), versions, licenses, origins, and files if specified must be list types"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> pkg_name <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> el = { <TAB> <TAB> ""name"" : pkg_name, <TAB> <TAB> ""version"" : pkg_version, <TAB> <TAB> ""origin"" : pkg_origin, <TAB> <TAB> ""license"" : pkg_license, <TAB> <TAB> ""location"" :",False,type(inp) is not list,not inp[0] or inp[1] or (not pkg_type and pkg_origin and pkg_type),0.6540470123291016
|
||
|
2211,"def evaluate ( env, net, device = ""cpu"" ) : <TAB> obs = env. reset ( ) <TAB> reward = 0.0 <TAB> steps = 0 <TAB> while True : <TAB> <TAB> obs_v = ptan. agent. default_states_preprocessor ( [ obs ] ). to ( device ) <TAB> <TAB> action_v = net ( obs_v ) <TAB> <TAB> action = action_v. data. cpu ( ). numpy ( ) [ 0 ] <TAB> <TAB> obs, r, done, _ = env. step ( action ) <TAB> <TAB> reward += r <TAB> <TAB> steps += 1 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> break <TAB> return reward, steps",True,done,done,0.6859234571456909
|
||
|
2212,"def _should_cleanup ( self, config_filename ) : <TAB> """"""Return True if `config_filename` does not exist or if modtime and hash have changes, else return False."""""" <TAB> if not os. path. exists ( config_filename ) : <TAB> <TAB> return True <TAB> new_mtime = os. path. getmtime ( config_filename ) <TAB> tool_hash = self. _hash_by_tool_paths. get ( config_filename ) <TAB> if tool_hash. modtime < new_mtime : <TAB> <TAB> if md5_hash_file ( config_filename )!= tool_hash. hash : <TAB> <TAB> <TAB> return True <TAB> tool = self. _tools_by_path [ config_filename ] <TAB> for macro_path in tool. _macro_paths : <TAB> <TAB> new_mtime = os. path. getmtime ( macro_path ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return True <TAB> return False",False,self._hash_by_tool_paths.get(macro_path).modtime < new_mtime,new_mtime > md5_hash_file(config_filename),0.6468406915664673
|
||
|
2213,"def __gt__ ( self, other ) : <TAB> """"""Return True if self appears after other in outline order."""""" <TAB> stack1, stack2 = self. stack, other. stack <TAB> n1, n2 = len ( stack1 ), len ( stack2 ) <TAB> n = min ( n1, n2 ) <TAB> <TAB> for item1, item2 in zip ( stack1, stack2 ) : <TAB> <TAB> v1, x1 = item1 <TAB> <TAB> v2, x2 = item2 <TAB> <TAB> if x1 > x2 : <TAB> <TAB> <TAB> return True <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> return False <TAB> <TAB> if n1 == n2 : <TAB> <TAB> x1, x2 = self. _childIndex, other. _childIndex <TAB> <TAB> return x1 > x2 <TAB> elif n1 < n2 : <TAB> <TAB> x1 = self. _childIndex <TAB> <TAB> v2, x2 = other. stack [ n ] <TAB> <TAB> return x1 > x2 <TAB> else : <TAB> <TAB> <TAB> <TAB> x1 = other. _childIndex <TAB> <TAB> v2, x2 = self. stack [ n ] <TAB> <TAB> return x2 >= x1",False,x1 < x2,v1 > x2,0.6643438339233398
|
||
|
2214,"def add_nets ( self, * nets ) : <TAB> """"""Add some Net objects to the circuit. Assign a net name if necessary."""""" <TAB> for net in nets : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if net. circuit!= self : <TAB> <TAB> <TAB> if net. is_movable ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> net. circuit -= net <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> net. circuit = self <TAB> <TAB> <TAB> <TAB> net. name = net. name <TAB> <TAB> <TAB> <TAB> net. hierarchy = self. hierarchy <TAB> <TAB> <TAB> <TAB> self. nets. append ( net ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> log_and_raise ( <TAB> <TAB> <TAB> <TAB> <TAB> logger, <TAB> <TAB> <TAB> <TAB> <TAB> ValueError, <TAB> <TAB> <TAB> <TAB> <TAB> ""Can't add unmovable net {} to this circuit."". format ( net. name ), <TAB> <TAB> <TAB> <TAB> )",False,"isinstance(net.circuit, Circuit)","hasattr(self, 'circuit')",0.6605138778686523
|
||
|
2215,"def test_authorize_nocsrf_ratelimiting ( self ) : <TAB> <TAB> form = { <TAB> <TAB> ""client_id"" : ""deadbeef"", <TAB> <TAB> ""redirect_uri"" : ""http://localhost:8000/o2c.html"", <TAB> <TAB> ""scope"" : ""user:admin"", <TAB> } <TAB> <TAB> headers = dict ( authorization = gen_basic_auth ( ""devtable"", ""invalidpassword"" ) ) <TAB> self. postResponse ( <TAB> <TAB> ""web.authorize_application"", <TAB> <TAB> headers = headers, <TAB> <TAB> form = form, <TAB> <TAB> with_csrf = False, <TAB> <TAB> expected_code = 401, <TAB> ) <TAB> counter = 0 <TAB> while True : <TAB> <TAB> r = self. postResponse ( <TAB> <TAB> <TAB> ""web.authorize_application"", <TAB> <TAB> <TAB> headers = headers, <TAB> <TAB> <TAB> form = form, <TAB> <TAB> <TAB> with_csrf = False, <TAB> <TAB> <TAB> expected_code = None, <TAB> <TAB> ) <TAB> <TAB> self. assertNotEqual ( 200, r. status_code ) <TAB> <TAB> counter = counter + 1 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. fail ( ""Exponential backoff did not fire"" ) <TAB> <TAB> if r. status_code == 429 : <TAB> <TAB> <TAB> break",False,counter > 5,counter == 0,0.6693984270095825
|
||
|
2216,"def __call__ ( self, pymodule, node ) : <TAB> pyname = self. _evaluate_node ( pymodule, node ) <TAB> if pyname is None or self. expected is None : <TAB> <TAB> return self. unsure <TAB> if self. _unsure_pyname ( pyname, unbound = self. kind == ""name"" ) : <TAB> <TAB> return True <TAB> if self. kind == ""name"" : <TAB> <TAB> return self. _same_pyname ( self. expected, pyname ) <TAB> else : <TAB> <TAB> pyobject = pyname. get_object ( ) <TAB> <TAB> if self. kind == ""object"" : <TAB> <TAB> <TAB> objects = [ pyobject ] <TAB> <TAB> if self. kind == ""type"" : <TAB> <TAB> <TAB> objects = [ pyobject. get_type ( ) ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> objects = [ pyobject ] <TAB> <TAB> <TAB> objects. extend ( self. _get_super_classes ( pyobject ) ) <TAB> <TAB> <TAB> objects. extend ( self. _get_super_classes ( pyobject. get_type ( ) ) ) <TAB> <TAB> for pyobject in objects : <TAB> <TAB> <TAB> if self. _same_pyobject ( self. expected. get_object ( ), pyobject ) : <TAB> <TAB> <TAB> <TAB> return True <TAB> <TAB> return False",False,self.kind == 'instance',self.kind == 'classed',0.6566417813301086
|
||
|
2217,"def drop ( self ) : <TAB> <TAB> sql = ""if object_id('%s') is not null drop table %s"" % ( self. tname, self. tname ) <TAB> try : <TAB> <TAB> self. execute ( sql ) <TAB> except Exception as e : <TAB> <TAB> self. conn. rollback ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise <TAB> <TAB> <TAB> <TAB> sql = ""drop table if exists %s"" % self. tname <TAB> <TAB> self. execute ( sql )",False,'syntax error' not in str(e),"e.args[0] not in [E.SUCCESS, E.CMD]",0.6630998849868774
|
||
|
2218,"def starts_block ( self, i, lines, new_state, prev_state ) : <TAB> """"""True if the line starts a block."""""" <TAB> if prev_state. context : <TAB> <TAB> return False <TAB> else : <TAB> <TAB> line = lines [ i ] <TAB> <TAB> for pattern in self. pascal_pattern_table : <TAB> <TAB> <TAB> m = pattern. match ( line ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return True <TAB> <TAB> return False",True,m,m,0.6917235255241394
|
||
|
2219,"def __cut ( sentence ) : <TAB> global emit_P <TAB> prob, pos_list = viterbi ( sentence, ""BMES"", start_P, trans_P, emit_P ) <TAB> begin, nexti = 0, 0 <TAB> <TAB> for i, char in enumerate ( sentence ) : <TAB> <TAB> pos = pos_list [ i ] <TAB> <TAB> if pos == ""B"" : <TAB> <TAB> <TAB> begin = i <TAB> <TAB> elif pos == ""E"" : <TAB> <TAB> <TAB> yield sentence [ begin : i + 1 ] <TAB> <TAB> <TAB> nexti = i + 1 <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> yield char <TAB> <TAB> <TAB> nexti = i + 1 <TAB> if nexti < len ( sentence ) : <TAB> <TAB> yield sentence [ nexti : ]",False,pos == 'S',pos == 'F',0.66117262840271
|
||
|
2220,"def grad ( self, inputs, gout ) : <TAB> ( x, ) = inputs <TAB> ( gz, ) = gout <TAB> if x. dtype not in continuous_dtypes : <TAB> <TAB> return [ x. zeros_like ( dtype = theano. config. floatX ) ] <TAB> if self. structured : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> r = gz * theano. sparse. sp_ones_like ( x ) <TAB> <TAB> elif self. axis == 0 : <TAB> <TAB> <TAB> r = col_scale ( theano. sparse. sp_ones_like ( x ), gz ) <TAB> <TAB> elif self. axis == 1 : <TAB> <TAB> <TAB> r = row_scale ( theano. sparse. sp_ones_like ( x ), gz ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise ValueError ( ""Illegal value for self.axis."" ) <TAB> else : <TAB> <TAB> o_format = x. format <TAB> <TAB> x = dense_from_sparse ( x ) <TAB> <TAB> if _is_sparse_variable ( gz ) : <TAB> <TAB> <TAB> gz = dense_from_sparse ( gz ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> r = tensor. second ( x, gz ) <TAB> <TAB> else : <TAB> <TAB> <TAB> ones = tensor. ones_like ( x ) <TAB> <TAB> <TAB> if self. axis == 0 : <TAB> <TAB> <TAB> <TAB> r = tensor. addbroadcast ( gz. dimshuffle ( ""x"", 0 ), 0 ) * ones <TAB> <TAB> <TAB> elif self. axis == 1 : <TAB> <TAB> <TAB> <TAB> r = tensor. addbroadcast ( gz. dimshuffle ( 0, ""x"" ), 1 ) * ones <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> raise ValueError ( ""Illegal value for self.axis."" ) <TAB> <TAB> r = SparseFromDense ( o_format ) ( r",False,self.axis is None,_is_sparse_variable(gz),0.6636162400245667
|
||
|
2221,"def _resolve ( d ) : <TAB> all_keys = frozenset ( d. keys ( ) ) <TAB> result = [ ] <TAB> resolved_keys = set ( ) <TAB> <TAB> while d : <TAB> <TAB> resolved_this_round = set ( ) <TAB> <TAB> for name, links in list ( d. items ( ) ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if not links or links <= resolved_keys : <TAB> <TAB> <TAB> <TAB> result. append ( name ) <TAB> <TAB> <TAB> <TAB> resolved_this_round. add ( name ) <TAB> <TAB> <TAB> <TAB> del d [ name ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> unknown = links - all_keys <TAB> <TAB> <TAB> if len ( unknown ) == 1 : <TAB> <TAB> <TAB> <TAB> raise BlockadeConfigError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""container %s links to unknown container %s"" <TAB> <TAB> <TAB> <TAB> <TAB> % ( name, list ( unknown ) [ 0 ] ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> elif len ( unknown ) > 1 : <TAB> <TAB> <TAB> <TAB> raise BlockadeConfigError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""container %s links to unknown containers %s"" % ( name, unknown ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise BlockadeConfigError ( ""containers have circular links!"" ) <TAB> <TAB> resolved_keys. update ( resolved_this_round ) <TAB> return result",False,not resolved_this_round,self._has_circular_links(unknown),0.6526947021484375
|
||
|
2222,"def getBoundsCenter ( uv_layer ) : <TAB> min_x = getCenter ( uv_layer ) [ 0 ] <TAB> max_x = getCenter ( uv_layer ) [ 0 ] <TAB> min_y = getCenter ( uv_layer ) [ 1 ] <TAB> max_y = getCenter ( uv_layer ) [ 1 ] <TAB> len = 0 <TAB> for uv_verts in uv_layer. data : <TAB> <TAB> if uv_verts. uv [ 0 ] < min_x : <TAB> <TAB> <TAB> min_x = uv_verts. uv [ 0 ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> max_x = uv_verts. uv [ 0 ] <TAB> <TAB> if uv_verts. uv [ 1 ] < min_y : <TAB> <TAB> <TAB> min_y = uv_verts. uv [ 1 ] <TAB> <TAB> if uv_verts. uv [ 1 ] > max_y : <TAB> <TAB> <TAB> max_y = uv_verts. uv [ 1 ] <TAB> center_x = ( max_x - min_x ) / 2 + min_x <TAB> center_y = ( max_y - min_y ) / 2 + min_y <TAB> return ( center_x, center_y )",False,uv_verts.uv[0] > max_x,uv_verts.uv[0] < max_x,0.6599746942520142
|
||
|
2223,"def _populate_map ( self ) : <TAB> try : <TAB> <TAB> with open ( self. filename ) as fh : <TAB> <TAB> <TAB> line_number = 0 <TAB> <TAB> <TAB> for line in fh : <TAB> <TAB> <TAB> <TAB> line_number += 1 <TAB> <TAB> <TAB> <TAB> line = line. rstrip ( ""\r\n"" ) <TAB> <TAB> <TAB> <TAB> if not line. startswith ( self. comment_chars ) : <TAB> <TAB> <TAB> <TAB> <TAB> elems = line. split ( self. delimiter ) <TAB> <TAB> <TAB> <TAB> <TAB> if len ( elems ) <= self. key_column : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> die ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""Location file %s line %d: less than %d columns"" <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> % ( self. filename, line_number, self. key_column + 1 ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> key = elems. pop ( self. key_column ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if self. _map [ key ]!= elems : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> die ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> 'Location file %s line %d: duplicate key ""%s""' <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> % ( self. filename, line_number, key ) <TAB> <TAB> <TAB> <TAB> <TAB",True,key in self._map,key in self._map,0.6664842367172241
|
||
|
2224,def _handle_extension_suppressions ( extensions ) : <TAB> filtered_extensions = [ ] <TAB> for ext in extensions : <TAB> <TAB> should_include = True <TAB> <TAB> for suppression in ext_suppressions : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> should_include = False <TAB> <TAB> if should_include : <TAB> <TAB> <TAB> filtered_extensions. append ( ext ) <TAB> return filtered_extensions,False,should_include and suppression.handle_suppress(ext),suppression not in ['TAB>,0.6457030773162842
|
||
|
2225,"def setup_sampler ( sampler_type, num_iters, batch_size ) : <TAB> if sampler_type is None : <TAB> <TAB> return None, batch_size <TAB> if sampler_type == ""weighted"" : <TAB> <TAB> from torch. utils. data. sampler import WeightedRandomSampler <TAB> <TAB> w = torch. ones ( num_iters * batch_size, dtype = torch. float ) <TAB> <TAB> for i in range ( num_iters ) : <TAB> <TAB> <TAB> w [ batch_size * i : batch_size * ( i + 1 ) ] += i * 1.0 <TAB> <TAB> return ( <TAB> <TAB> <TAB> WeightedRandomSampler ( <TAB> <TAB> <TAB> <TAB> w, num_samples = num_iters * batch_size, replacement = True <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> batch_size, <TAB> <TAB> ) <TAB> if sampler_type == ""distributed"" : <TAB> <TAB> import torch. distributed as dist <TAB> <TAB> from torch. utils. data. distributed import DistributedSampler <TAB> <TAB> num_replicas = 1 <TAB> <TAB> rank = 0 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> num_replicas = dist. get_world_size ( ) <TAB> <TAB> <TAB> rank = dist. get_rank ( ) <TAB> <TAB> dataset = torch. zeros ( num_iters * batch_size ) <TAB> <TAB> return ( <TAB> <TAB> <TAB> DistributedSampler ( dataset, num_replicas = num_replicas, rank = rank ), <TAB> <TAB> <TAB> batch_size // num_replicas, <TAB> <TAB> )",False,dist.is_available() and dist.is_initialized(),dist.is_initialized(),0.6488051414489746
|
||
|
2226,"def _try_increase_batch_size ( self, current_batch_size ) : <TAB> if current_batch_size * 2 <= self. max_batch_size : <TAB> <TAB> current_time = time. time ( ) <TAB> <TAB> latest_batch_size_change_time = self. latest_batch_size_change_time <TAB> <TAB> seconds_since_last_change = ( <TAB> <TAB> <TAB> current_time - latest_batch_size_change_time <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> else 0 <TAB> <TAB> ) <TAB> <TAB> if seconds_since_last_change > BATCH_CHANGE_COOLDOWN_PERIOD_SECONDS : <TAB> <TAB> <TAB> new_batch_size = current_batch_size * 2 <TAB> <TAB> <TAB> self. logger. info ( ""Increasing batch size to {}."". format ( new_batch_size ) ) <TAB> <TAB> <TAB> self. batch_size = new_batch_size <TAB> <TAB> <TAB> self. latest_batch_size_change_time = current_time",False,latest_batch_size_change_time is not None,current_time < self.max_batch_size,0.6491739749908447
|
||
|
2227,"def activate_css ( targetnode ) : <TAB> scriptnodes = list ( targetnode. getElementsByTagName ( ""link"" ) ) <TAB> for LC in range ( len ( scriptnodes ) ) : <TAB> <TAB> sn = scriptnodes [ LC ] <TAB> <TAB> sn. parentNode. removeChild ( sn ) <TAB> <TAB> fileref = DOM. createElement ( ""link"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> fileref. href = sn. href <TAB> <TAB> else : <TAB> <TAB> <TAB> fileref. text = sn. text <TAB> <TAB> fileref. rel = ""stylesheet"" <TAB> <TAB> fileref. type = ""text/css"" <TAB> <TAB> doc ( ). getElementsByTagName ( ""head"" ). item ( 0 ). appendChild ( fileref )",False,"hassattr(sn, 'href')","sys.version_info >= (3, 0)",0.6528770923614502
|
||
|
2228,"def visit_simple_stmt ( self, node : Node ) -> Iterator [ Line ] : <TAB> """"""Visit a statement without nested statements."""""" <TAB> is_suite_like = node. parent and node. parent. type in STATEMENT <TAB> if is_suite_like : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> yield from self. visit_default ( node ) <TAB> <TAB> else : <TAB> <TAB> <TAB> yield from self. line ( + 1 ) <TAB> <TAB> <TAB> yield from self. visit_default ( node ) <TAB> <TAB> <TAB> yield from self. line ( - 1 ) <TAB> else : <TAB> <TAB> if not self. is_pyi or not node. parent or not is_stub_suite ( node. parent ) : <TAB> <TAB> <TAB> yield from self. line ( ) <TAB> <TAB> yield from self. visit_default ( node )",False,self.is_pyi and is_stub_body(node),node.parent,0.651760458946228
|
||
|
2229,"def validate_party_details ( self ) : <TAB> if self. party : <TAB> <TAB> if not frappe. db. exists ( self. party_type, self. party ) : <TAB> <TAB> <TAB> frappe. throw ( _ ( ""Invalid {0}: {1}"" ). format ( self. party_type, self. party ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. validate_account_type ( <TAB> <TAB> <TAB> <TAB> self. party_account, [ erpnext. get_party_account_type ( self. party_type ) ] <TAB> <TAB> <TAB> )",False,"self.party_account and self.party_type in ('Customer', 'Supplier')",self.party_account,0.6509919166564941
|
||
|
2230,"def __call__ ( self, x, uttid = None ) : <TAB> if self. utt2spk is not None : <TAB> <TAB> spk = self. utt2spk [ uttid ] <TAB> else : <TAB> <TAB> spk = uttid <TAB> if not self. reverse : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> x = np. add ( x, self. bias [ spk ] ) <TAB> <TAB> if self. norm_vars : <TAB> <TAB> <TAB> x = np. multiply ( x, self. scale [ spk ] ) <TAB> else : <TAB> <TAB> if self. norm_vars : <TAB> <TAB> <TAB> x = np. divide ( x, self. scale [ spk ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> x = np. subtract ( x, self. bias [ spk ] ) <TAB> return x",False,self.norm_means,self.norm_bias,0.6563746929168701
|
||
|
2231,"def __init__ ( self, operation_def, inputs ) : <TAB> self. _operation_def = operation_def <TAB> self. _inputs = inputs <TAB> if not isinstance ( operation_def, OperationDef ) : <TAB> <TAB> raise TypeError ( <TAB> <TAB> <TAB> ""operation_def must be an OperationDef, got {} of type {}"". format ( <TAB> <TAB> <TAB> <TAB> operation_def, type ( operation_def ) <TAB> <TAB> <TAB> ) <TAB> <TAB> ) <TAB> if not isinstance ( inputs, tuple ) : <TAB> <TAB> raise TypeError ( <TAB> <TAB> <TAB> ""inputs must be a tuple, got {} of type {}"". format ( inputs, type ( inputs ) ) <TAB> <TAB> ) <TAB> for value_node in inputs : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise TypeError ( <TAB> <TAB> <TAB> <TAB> ""Inputs to Operation must be a ValueNode, got {} of type {}"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> value_node, type ( value_node ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> )",True,"not isinstance(value_node, ValueNode)","not isinstance(value_node, ValueNode)",0.6510245203971863
|
||
|
2232,"def instantiate_lambda ( transform, lambda_transforms = None ) : <TAB> if transform. get ( ""__type__"" ) == ""Lambda"" : <TAB> <TAB> name = transform [ ""__name__"" ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""To deserialize a Lambda transform with name {name} you need to pass a dict with this transform "" <TAB> <TAB> <TAB> <TAB> ""as the `lambda_transforms` argument"". format ( name = name ) <TAB> <TAB> <TAB> ) <TAB> <TAB> transform = lambda_transforms. get ( name ) <TAB> <TAB> if transform is None : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""Lambda transform with {name} was not found in `lambda_transforms`"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> name = name <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> return transform <TAB> return None",True,lambda_transforms is None,lambda_transforms is None,0.6757447719573975
|
||
|
2233,"def on_paint ( self, event ) : <TAB> dc = wx. BufferedPaintDC ( self. panel ) <TAB> dc. SetBackground ( wx. Brush ( wx. SystemSettings. GetColour ( wx. SYS_COLOUR_WINDOW ) ) ) <TAB> dc. Clear ( ) <TAB> dc. SetPen ( wx. Pen ( wx. SystemSettings. GetColour ( wx. SYS_COLOUR_GRAYTEXT ) ) ) <TAB> sizer = self. panel. Sizer <TAB> _, panel_width = self. panel. GetClientSize ( ) <TAB> assert isinstance ( sizer, wx. lib. rcsizer. RowColSizer ) <TAB> bottom_choice_name = self. get_choice_control_name ( self. n_items ) <TAB> bottom_choice = self. panel. FindWindowByName ( bottom_choice_name ) <TAB> if bottom_choice is not None : <TAB> <TAB> r = bottom_choice. GetRect ( ) <TAB> <TAB> dc. DrawLine ( r. Left - 2, 1, r. Left - 2, r. Bottom ) <TAB> for i in range ( 1, self. n_items + 1 ) : <TAB> <TAB> choice_name = self. get_choice_control_name ( i ) <TAB> <TAB> choice = self. panel. FindWindowByName ( choice_name ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> r = choice. GetRect ( ) <TAB> <TAB> <TAB> dc. DrawLine ( 1, r. Top - 2, panel_width - 1, r. Top - 2 ) <TAB> event. Skip ( )",True,choice is not None,choice is not None,0.6647061109542847
|
||
|
2234,"def validate_dict ( d ) : <TAB> for n, v in d. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> if n [ 0 : 2 ] == ""t_"" : <TAB> <TAB> <TAB> continue <TAB> <TAB> if n [ 0 : 2 ] == ""p_"" : <TAB> <TAB> <TAB> sys. stderr. write ( ""yacc: Warning. '%s' not defined as a function\n"" % n ) <TAB> <TAB> if 1 and isinstance ( v, types. FunctionType ) and v. func_code. co_argcount == 1 : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> doc = v. __doc__. split ( "" "" ) <TAB> <TAB> <TAB> <TAB> if doc [ 1 ] == "":"" : <TAB> <TAB> <TAB> <TAB> <TAB> sys. stderr. write ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""%s:%d: Warning. Possible grammar rule '%s' defined without p_ prefix.\n"" <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> % ( v. func_code. co_filename, v. func_code. co_firstlineno, n ) <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> <TAB> pass",False,"n[0:2] == 'p_' and type(v) in (types.FunctionType, types.MethodType)",n[0:2] == 'e_',0.6508049964904785
|
||
|
2235,"def client_post_decrypt ( self, buf ) : <TAB> if self. raw_trans : <TAB> <TAB> return buf <TAB> self. recv_buf += buf <TAB> out_buf = b"""" <TAB> while len ( self. recv_buf ) > 2 : <TAB> <TAB> length = struct. unpack ( "">H"", self. recv_buf [ : 2 ] ) [ 0 ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. raw_trans = True <TAB> <TAB> <TAB> self. recv_buf = b"""" <TAB> <TAB> <TAB> raise Exception ( ""client_post_decrypt data error"" ) <TAB> <TAB> if length > len ( self. recv_buf ) : <TAB> <TAB> <TAB> break <TAB> <TAB> if ( <TAB> <TAB> <TAB> struct. pack ( ""<I"", zlib. adler32 ( self. recv_buf [ : length - 4 ] ) & 0xFFFFFFFF ) <TAB> <TAB> <TAB>!= self. recv_buf [ length - 4 : length ] <TAB> <TAB> ) : <TAB> <TAB> <TAB> self. raw_trans = True <TAB> <TAB> <TAB> self. recv_buf = b"""" <TAB> <TAB> <TAB> raise Exception ( ""client_post_decrypt data uncorrect checksum"" ) <TAB> <TAB> pos = common. ord ( self. recv_buf [ 2 ] ) + 2 <TAB> <TAB> out_buf += self. recv_buf [ pos : length - 4 ] <TAB> <TAB> self. recv_buf = self. recv_buf [ length : ] <TAB> if out_buf : <TAB> <TAB> self. decrypt_packet_num += 1 <TAB> return out_buf",False,length >= 8192 or length < 7,length > len(self.recv_buf),0.660135805606842
|
||
|
2236,"def visit_Enum ( self, node ) : <TAB> if not node. values : <TAB> <TAB> return <TAB> generator = c_generator. CGenerator ( ) <TAB> for i, elem in enumerate ( node. values. enumerators ) : <TAB> <TAB> if not elem. value : <TAB> <TAB> <TAB> continue <TAB> <TAB> try : <TAB> <TAB> <TAB> raw_val = generator. visit ( elem. value ) <TAB> <TAB> <TAB> for item in node. values. enumerators : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> raw_val = raw_val. replace ( item. name, item. value. value ) <TAB> <TAB> <TAB> <TAB> except : <TAB> <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> cooked_value = eval ( raw_val ) <TAB> <TAB> <TAB> elem. value = Constant ( type = ""int"", value = str ( cooked_value ) ) <TAB> <TAB> except : <TAB> <TAB> <TAB> pass",False,item.value and item.value.type == 'int',item.name,0.6530643701553345
|
||
|
2237,"def get_palette_for_custom_classes ( self, class_names, palette = None ) : <TAB> if self. label_map is not None : <TAB> <TAB> <TAB> <TAB> palette = [ ] <TAB> <TAB> for old_id, new_id in sorted ( self. label_map. items ( ), key = lambda x : x [ 1 ] ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> palette. append ( self. PALETTE [ old_id ] ) <TAB> <TAB> palette = type ( self. PALETTE ) ( palette ) <TAB> elif palette is None : <TAB> <TAB> if self. PALETTE is None : <TAB> <TAB> <TAB> palette = np. random. randint ( 0, 255, size = ( len ( class_names ), 3 ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> palette = self. PALETTE <TAB> return palette",False,new_id != -1,new_id in class_names,0.6611730456352234
|
||
|
2238,"def save ( self ) : <TAB> updates = self. cinder_obj_get_changes ( ) <TAB> if updates : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> metadata = updates. pop ( ""metadata"", None ) <TAB> <TAB> <TAB> self. metadata = db. backup_metadata_update ( <TAB> <TAB> <TAB> <TAB> self. _context, self. id, metadata, True <TAB> <TAB> <TAB> ) <TAB> <TAB> updates. pop ( ""parent"", None ) <TAB> <TAB> db. backup_update ( self. _context, self. id, updates ) <TAB> self. obj_reset_changes ( )",False,'metadata' in updates,self.metadata,0.6707595586776733
|
||
|
2239,"def export_addresses ( self ) : <TAB> exports = self. _cached_exports_addresses <TAB> if exports is None : <TAB> <TAB> exports = [ ] <TAB> <TAB> for export_spec in getattr ( self, ""export_specs"", tuple ( ) ) : <TAB> <TAB> <TAB> if isinstance ( export_spec, Target ) : <TAB> <TAB> <TAB> <TAB> exports. append ( export_spec. address ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> exports. append ( <TAB> <TAB> <TAB> <TAB> <TAB> Address. parse ( export_spec, relative_to = self. address. spec_path ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> exports = tuple ( exports ) <TAB> <TAB> dep_addresses = { d. address for d in self. dependencies } <TAB> <TAB> invalid_export_specs = [ a. spec for a in exports if a not in dep_addresses ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise TargetDefinitionException ( <TAB> <TAB> <TAB> <TAB> self, <TAB> <TAB> <TAB> <TAB> ""Invalid exports: these exports must also be dependencies\n {}"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> ""\n "". join ( invalid_export_specs ) <TAB> <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> ) <TAB> <TAB> self. _cached_exports_addresses = exports <TAB> return exports",False,len(invalid_export_specs) > 0,invalid_export_specs,0.6557188034057617
|
||
|
2240,"def _set_value ( self, value ) : <TAB> if self. _module is None : <TAB> <TAB> <TAB> <TAB> for module in ( _eui48, _eui64 ) : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> self. _value = module. str_to_int ( value ) <TAB> <TAB> <TAB> <TAB> self. _module = module <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> except AddrFormatError : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _value = int ( value ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _module = module <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> if self. _module is None : <TAB> <TAB> <TAB> raise AddrFormatError ( ""failed to detect EUI version: %r"" % value ) <TAB> else : <TAB> <TAB> <TAB> <TAB> if _is_str ( value ) : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> self. _value = self. _module. str_to_int ( value ) <TAB> <TAB> <TAB> except AddrFormatError : <TAB> <TAB> <TAB> <TAB> raise AddrFormatError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""address %r is not an EUIv%d"" % ( value, self. _module. version ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if 0 <= int ( value ) <= self. _module. max_int : <TAB> <TAB> <TAB> <TAB> self. _value = int ( value ) <TAB",False,0 <= int(value) <= module.max_int,_is_int(value),0.658035159111023
|
||
|
2241,"def main ( argv ) : <TAB> <TAB> out_path = argv [ 1 ] <TAB> <TAB> <TAB> <TAB> mode = zipfile. ZIP_STORED <TAB> z = zipfile. ZipFile ( out_path, ""w"", mode ) <TAB> seen = { } <TAB> for line in sys. stdin : <TAB> <TAB> line = line. strip ( ) <TAB> <TAB> try : <TAB> <TAB> <TAB> full_path, rel_path = line. split ( None, 1 ) <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> raise RuntimeError ( ""Invalid line %r"" % line ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> expected = seen [ rel_path ] <TAB> <TAB> <TAB> if expected!= full_path : <TAB> <TAB> <TAB> <TAB> print >> sys. stderr, ""WARNING: expected %r, got %r"" % ( <TAB> <TAB> <TAB> <TAB> <TAB> expected, <TAB> <TAB> <TAB> <TAB> <TAB> full_path, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> z. write ( full_path, rel_path ) <TAB> <TAB> seen [ rel_path ] = full_path",True,rel_path in seen,rel_path in seen,0.6614975333213806
|
||
|
2242,"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<mask> : <TAB> <TAB> <TAB> break <TAB> <TAB> if fid == 1 : <TAB> <TAB> <TAB> if ftype == TType. STRUCT : <TAB> <TAB> <TAB> <TAB> self. type = Type ( ) <TAB> <TAB> <TAB> <TAB> self. type. 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 ( )",False,ftype == TType.STOP,fid == 0,0.6585721373558044
|
||
|
2243,"def __init__ ( self, options, columns ) : <TAB> super ( TestForeignDataWrapper, self ). __init__ ( options, columns ) <TAB> self. columns = columns <TAB> self. test_type = options. get ( ""test_type"", None ) <TAB> self. test_subtype = options. get ( ""test_subtype"", None ) <TAB> self. tx_hook = options. get ( ""tx_hook"", False ) <TAB> self. _row_id_column = options. get ( ""row_id_column"", list ( self. columns. keys ( ) ) [ 0 ] ) <TAB> log_to_postgres ( str ( sorted ( options. items ( ) ) ) ) <TAB> log_to_postgres ( <TAB> <TAB> str ( sorted ( [ ( key, column. type_name ) for key, column in columns. items ( ) ] ) ) <TAB> ) <TAB> for column in columns. values ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> log_to_postgres ( <TAB> <TAB> <TAB> <TAB> ""Column %s options: %s"" % ( column. column_name, column. options ) <TAB> <TAB> <TAB> ) <TAB> if self. test_type == ""logger"" : <TAB> <TAB> log_to_postgres ( ""An error is about to occur"", WARNING ) <TAB> <TAB> log_to_postgres ( ""An error occured"", ERROR )",False,column.options,self.test_type == 'table',0.6561008095741272
|
||
|
2244,"def filter_command ( self, event = None ) : <TAB> dir, pat = self. get_filter ( ) <TAB> try : <TAB> <TAB> names = os. listdir ( dir ) <TAB> except OSError : <TAB> <TAB> self. master. bell ( ) <TAB> <TAB> return <TAB> self. directory = dir <TAB> self. set_filter ( dir, pat ) <TAB> names. sort ( ) <TAB> subdirs = [ os. pardir ] <TAB> matchingfiles = [ ] <TAB> for name in names : <TAB> <TAB> fullname = os. path. join ( dir, name ) <TAB> <TAB> if os. path. isdir ( fullname ) : <TAB> <TAB> <TAB> subdirs. append ( name ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> matchingfiles. append ( name ) <TAB> self. dirs. delete ( 0, END ) <TAB> for name in subdirs : <TAB> <TAB> self. dirs. insert ( END, name ) <TAB> self. files. delete ( 0, END ) <TAB> for name in matchingfiles : <TAB> <TAB> self. files. insert ( END, name ) <TAB> head, tail = os. path. split ( self. get_selection ( ) ) <TAB> if tail == os. curdir : <TAB> <TAB> tail = """" <TAB> self. set_selection ( tail )",False,"fnmatch.fnmatch(name, pat)",os.path.isfile(name),0.6435481905937195
|
||
|
2245,"def action ( self, line ) : <TAB> if line. strip ( ). startswith ( ""#"" ) and self. state!= ""multiline"" : <TAB> <TAB> if self. state!= ""init"" or self. tags or self. variant!= ""feature"" : <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> <TAB> line = line. strip ( ) [ 1 : ]. strip ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> language = line [ 9 : ]. strip ( ) <TAB> <TAB> <TAB> self. language = language <TAB> <TAB> <TAB> self. keywords = i18n. languages [ language ] <TAB> <TAB> return <TAB> func = getattr ( self, ""action_"" + self. state, None ) <TAB> if func is None : <TAB> <TAB> line = line. strip ( ) <TAB> <TAB> msg = u""Parser in unknown state %s;"" % self. state <TAB> <TAB> raise ParserError ( msg, self. line, self. filename, line ) <TAB> if not func ( line ) : <TAB> <TAB> line = line. strip ( ) <TAB> <TAB> msg = u'\nParser failure in state %s, at line %d: ""%s""\n' % ( <TAB> <TAB> <TAB> self. state, <TAB> <TAB> <TAB> self. line, <TAB> <TAB> <TAB> line, <TAB> <TAB> ) <TAB> <TAB> reason = self. ask_parse_failure_oracle ( line ) <TAB> <TAB> if reason : <TAB> <TAB> <TAB> msg += u""REASON: %s"" % reason <TAB> <TAB> raise ParserError ( msg, None, self. filename )",False,line.lstrip().lower().startswith('language:'),len(line) > 9,0.647869348526001
|
||
|
2246,"def OnMacKeyDown ( self, e ) : <TAB> code = e. GetKeyCode ( ) <TAB> stopPropagation = True <TAB> <TAB> if e. CmdDown ( ) : <TAB> <TAB> if code == wx. _core. WXK_LEFT : <TAB> <TAB> <TAB> self. GotoLine ( self. GetCurrentLine ( ) ) <TAB> <TAB> elif code == wx. _core. WXK_RIGHT : <TAB> <TAB> <TAB> self. GotoPos ( self. GetLineEndPosition ( self. GetCurrentLine ( ) ) ) <TAB> <TAB> elif code == wx. _core. WXK_UP : <TAB> <TAB> <TAB> self. GotoPos ( 0 ) <TAB> <TAB> elif code == wx. _core. WXK_DOWN : <TAB> <TAB> <TAB> self. GotoPos ( self. GetLength ( ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> stopPropagation = False <TAB> <TAB> elif e. GetModifiers ( ) & 0xF0 : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. GotoLine ( self. GetCurrentLine ( ) ) <TAB> <TAB> elif code == 69 : <TAB> <TAB> <TAB> self. GotoPos ( self. GetLineEndPosition ( self. GetCurrentLine ( ) ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> stopPropagation = False <TAB> else : <TAB> <TAB> stopPropagation = False <TAB> <TAB> if stopPropagation : <TAB> <TAB> e. StopPropagation ( ) <TAB> else : <TAB> <TAB> e. Skip ( )",False,code == 65,code == wx._core.WXK_RIGHT,0.6755229234695435
|
||
|
2247,"def _postproc_phase3 ( self ) : <TAB> try : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. end_online ( ) <TAB> <TAB> if self. _user. token and self. engine. stopping_reason : <TAB> <TAB> <TAB> exc_class = self. engine. stopping_reason. __class__. __name__ <TAB> <TAB> <TAB> note = ""%s: %s"" % ( exc_class, str ( self. engine. stopping_reason ) ) <TAB> <TAB> <TAB> self. append_note_to_session ( note ) <TAB> <TAB> <TAB> if self. _master : <TAB> <TAB> <TAB> <TAB> self. append_note_to_master ( note ) <TAB> except KeyboardInterrupt : <TAB> <TAB> raise <TAB> except BaseException as exc : <TAB> <TAB> self. log. debug ( ""Failed to finish online: %s"", traceback. format_exc ( ) ) <TAB> <TAB> self. log. warning ( ""Failed to finish online: %s"", exc )",False,self.send_data,self.engine.is_online,0.6547809839248657
|
||
|
2248,"def _setPupilDetection ( self, pmode ) : <TAB> try : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _eyelink. sendCommand ( ""use_ellipse_fitter = YES"" ) <TAB> <TAB> elif pmode. upper ( ) == ""CENTROID_FIT"" : <TAB> <TAB> <TAB> self. _eyelink. sendCommand ( ""force_ellipse_fitter -1"" ) <TAB> <TAB> <TAB> self. _eyelink. sendCommand ( ""use_ellipse_fitter = NO"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> print2err ( <TAB> <TAB> <TAB> <TAB> ""** EyeLink Warning: _setPupilDetection: Unrecofnized pupil fitting type: "", <TAB> <TAB> <TAB> <TAB> pmode, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> return EyeTrackerConstants. EYETRACKER_ERROR <TAB> <TAB> return EyeTrackerConstants. EYETRACKER_OK <TAB> except Exception : <TAB> <TAB> print2err ( ""EYELINK Error during _setPupilDetection:"" ) <TAB> <TAB> printExceptionDetailsToStdErr ( ) <TAB> <TAB> return EyeTrackerConstants. EYETRACKER_ERROR",False,pmode.upper() == 'ELLIPSE_FIT',pmode.upper() == 'YES',0.6553326845169067
|
||
|
2249,"def runGenerator ( self ) : <TAB> generatorrunner = ""shiboken"" <TAB> for name in ( ""shiboken"", ""generatorrunner"" ) : <TAB> <TAB> if PLAT_WINDOWS : <TAB> <TAB> <TAB> name += "".exe"" <TAB> <TAB> name = os. path. join ( self. PySideBase, ""bin"", name ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> generatorrunner = name <TAB> <TAB> <TAB> break <TAB> args = [ <TAB> <TAB> generatorrunner, <TAB> <TAB> ""--generator-set="" + self. ShibokenGenerator, <TAB> <TAB> ""global.h "", <TAB> <TAB> ""--avoid-protected-hack"", <TAB> <TAB> ""--enable-pyside-extensions"", <TAB> <TAB> ""--include-paths="" + self. AllIncludes, <TAB> <TAB> ""--typesystem-paths="" + self. PySideTypeSystem, <TAB> <TAB> ""--output-directory=."", <TAB> <TAB> ""typesystem_ScintillaEdit.xml"", <TAB> ] <TAB> print ( "" "". join ( args ) ) <TAB> retcode = subprocess. call ( "" "". join ( args ), shell = True, stderr = subprocess. STDOUT ) <TAB> if retcode : <TAB> <TAB> print ( ""Failed in generatorrunner"", retcode ) <TAB> <TAB> sys. exit ( )",False,os.path.exists(name),os.path.isdir(name),0.6492661833763123
|
||
|
2250,"def _align_column_choose_padfn ( strings, alignment, has_invisible ) : <TAB> if alignment == ""right"" : <TAB> <TAB> if not PRESERVE_WHITESPACE : <TAB> <TAB> <TAB> strings = [ s. strip ( ) for s in strings ] <TAB> <TAB> padfn = _padleft <TAB> elif alignment == ""center"" : <TAB> <TAB> if not PRESERVE_WHITESPACE : <TAB> <TAB> <TAB> strings = [ s. strip ( ) for s in strings ] <TAB> <TAB> padfn = _padboth <TAB> elif alignment == ""decimal"" : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> decimals = [ _afterpoint ( _strip_invisible ( s ) ) for s in strings ] <TAB> <TAB> else : <TAB> <TAB> <TAB> decimals = [ _afterpoint ( s ) for s in strings ] <TAB> <TAB> maxdecimals = max ( decimals ) <TAB> <TAB> strings = [ s + ( maxdecimals - decs ) * "" "" for s, decs in zip ( strings, decimals ) ] <TAB> <TAB> padfn = _padleft <TAB> elif not alignment : <TAB> <TAB> padfn = _padnone <TAB> else : <TAB> <TAB> if not PRESERVE_WHITESPACE : <TAB> <TAB> <TAB> strings = [ s. strip ( ) for s in strings ] <TAB> <TAB> padfn = _padright <TAB> return strings, padfn",True,has_invisible,has_invisible,0.663918673992157
|
||
|
2251,"def yview ( self, mode = None, value = None, units = None ) : <TAB> if type ( value ) == str : <TAB> <TAB> value = float ( value ) <TAB> if mode is None : <TAB> <TAB> return self. vsb. get ( ) <TAB> elif mode == ""moveto"" : <TAB> <TAB> frameHeight = self. innerframe. winfo_reqheight ( ) <TAB> <TAB> self. _startY = value * float ( frameHeight ) <TAB> else : <TAB> <TAB> clipperHeight = self. _clipper. winfo_height ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> jump = int ( clipperHeight * self. _jfraction ) <TAB> <TAB> else : <TAB> <TAB> <TAB> jump = clipperHeight <TAB> <TAB> self. _startY = self. _startY + value * jump <TAB> self. reposition ( )",False,units == 'units',clipperHeight > 0,0.6600906252861023
|
||
|
2252,"def iter_fields ( node, *, include_meta = True, exclude_unset = False ) : <TAB> exclude_meta = not include_meta <TAB> for field_name, field in node. _fields. items ( ) : <TAB> <TAB> if exclude_meta and field. meta : <TAB> <TAB> <TAB> continue <TAB> <TAB> field_val = getattr ( node, field_name, _marker ) <TAB> <TAB> if field_val is _marker : <TAB> <TAB> <TAB> continue <TAB> <TAB> if exclude_unset : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> default = field. default ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> default = field. default <TAB> <TAB> <TAB> if field_val == default : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> yield field_name, field_val",False,callable(field.default),field_val == _marker,0.6510690450668335
|
||
|
2253,"def _build_coverage_data ( executed_commands ) : <TAB> coverage_data = { } <TAB> for command in executed_commands : <TAB> <TAB> command_tokens = [ ] <TAB> <TAB> param_tokens = [ ] <TAB> <TAB> is_command = True <TAB> <TAB> for token in command. split ( ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> param_tokens. append ( token ) <TAB> <TAB> <TAB> <TAB> is_command = False <TAB> <TAB> <TAB> elif is_command : <TAB> <TAB> <TAB> <TAB> command_tokens. append ( token ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> command_name = "" "". join ( command_tokens ) <TAB> <TAB> if command_name in coverage_data : <TAB> <TAB> <TAB> coverage_data [ command_name ] = list ( <TAB> <TAB> <TAB> <TAB> set ( coverage_data [ command_name ] ). union ( set ( param_tokens ) ) <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> coverage_data [ command_name ] = param_tokens <TAB> return coverage_data",False,token.startswith('-'),is_command,0.6484431028366089
|
||
|
2254,"def __init__ ( self, name, * sub_params ) : <TAB> self. name = name <TAB> types = self. struct_types = OrderedDict ( ) <TAB> values = self. struct_values = { } <TAB> for sub in sub_params : <TAB> <TAB> if isinstance ( sub, self. __class__ ) : <TAB> <TAB> <TAB> types [ sub. name ] = ""STRUCT"" <TAB> <TAB> <TAB> values [ sub. name ] = sub <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> types [ sub. name ] = ""ARRAY"" <TAB> <TAB> <TAB> values [ sub. name ] = sub <TAB> <TAB> else : <TAB> <TAB> <TAB> types [ sub. name ] = sub. type_ <TAB> <TAB> <TAB> values [ sub. name ] = sub. value",False,"isinstance(sub, ArrayQueryParameter)","isinstance(sub, self.__class__)",0.6559240818023682
|
||
|
2255,"def update ( self, content = None ) : <TAB> if content is not None : <TAB> <TAB> self. content = content <TAB> <TAB> try : <TAB> <TAB> root = ET. fromstring ( self. content ) <TAB> <TAB> self. size = len ( self. content ) <TAB> <TAB> self. last_modified = int ( <TAB> <TAB> <TAB> ( datetime. datetime. now ( ) - datetime. datetime ( 1970, 1, 1 ) ). total_seconds ( ) <TAB> <TAB> ) <TAB> <TAB> self. lexemes_count = len ( root. findall ( ""."" ) ) <TAB> <TAB> for key, value in root. attrib. items ( ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. alphabet = value <TAB> <TAB> <TAB> elif key. endswith ( ""lang"" ) : <TAB> <TAB> <TAB> <TAB> self. language_code = value <TAB> except Exception as err : <TAB> <TAB> raise ValueError ( ""Failure parsing XML: {0}"". format ( err ) )",False,key.endswith('alphabet'),key.endswith('ui_language'),0.651118278503418
|
||
|
2256,"def nextEditable ( self ) : <TAB> """"""Moves focus of the cursor to the next editable window"""""" <TAB> if self. currentEditable is None : <TAB> <TAB> if len ( self. _editableChildren ) : <TAB> <TAB> <TAB> self. _currentEditableRef = self. _editableChildren [ 0 ] <TAB> else : <TAB> <TAB> for ref in weakref. getweakrefs ( self. currentEditable ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> cei = self. _editableChildren. index ( ref ) <TAB> <TAB> <TAB> <TAB> nei = cei + 1 <TAB> <TAB> <TAB> <TAB> if nei >= len ( self. _editableChildren ) : <TAB> <TAB> <TAB> <TAB> <TAB> nei = 0 <TAB> <TAB> <TAB> <TAB> self. _currentEditableRef = self. _editableChildren [ nei ] <TAB> return self. currentEditable",True,ref in self._editableChildren,ref in self._editableChildren,0.6591984033584595
|
||
|
2257,"def buildSearchTrie ( self, choices ) : <TAB> searchtrie = trie. Trie ( ) <TAB> for choice in choices : <TAB> <TAB> for token in self. tokenizeChoice ( choice ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> searchtrie [ token ] = [ ] <TAB> <TAB> <TAB> searchtrie [ token ]. append ( choice ) <TAB> return searchtrie",False,not searchtrie.has_key(token),token not in searchtrie,0.6557948589324951
|
||
|
2258,"def test_upload_guest ( self ) : <TAB> response = requests. post ( <TAB> <TAB> ""/"". join ( [ server_url, ""data"", ""upload"" ] ), json = self. upload_config <TAB> ) <TAB> self. assertTrue ( response. status_code in [ 200, 201 ] ) <TAB> self. assertTrue ( int ( response. json ( ) [ ""retcode"" ] ) == 0 ) <TAB> job_id = response. json ( ) [ ""jobId"" ] <TAB> for i in range ( 60 ) : <TAB> <TAB> response = requests. post ( <TAB> <TAB> <TAB> ""/"". join ( [ server_url, ""job"", ""query"" ] ), json = { ""job_id"" : job_id } <TAB> <TAB> ) <TAB> <TAB> self. assertTrue ( int ( response. json ( ) [ ""retcode"" ] ) == 0 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> break <TAB> <TAB> time. sleep ( 1 ) <TAB> self. assertTrue ( response. json ( ) [ ""data"" ] [ 0 ] [ ""f_status"" ] == JobStatus. SUCCESS ) <TAB> response = test_table_info ( ) <TAB> self. assertTrue ( response. status_code in [ 200, 201 ] ) <TAB> self. assertTrue ( int ( response. json ( ) [ ""retcode"" ] ) == 0 ) <TAB> response = test_table_delete ( ) <TAB> self. assertTrue ( response. status_code in [ 200, 201 ] ) <TAB> self. assertTrue ( int ( response. json ( ) [ ""retcode"" ] ) == 0 )",False,response.json()['data'][0]['f_status'] == JobStatus.SUCCESS,5 < 5,0.6520617008209229
|
||
|
2259,"def _get_pid_port_udp ( self, port ) : <TAB> for item in self. get_extended_udp_table ( ) : <TAB> <TAB> lPort = socket. ntohs ( item. dwLocalPort ) <TAB> <TAB> lAddr = socket. inet_ntoa ( struct. pack ( ""L"", item. dwLocalAddr ) ) <TAB> <TAB> pid = item. dwOwningPid <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return pid <TAB> else : <TAB> <TAB> return None",False,lPort == port,pid and port == pid,0.6643568277359009
|
||
|
2260,"def _process_service_request ( self, pkttype, pktid, packet ) : <TAB> """"""Process a service request"""""" <TAB> <TAB> service = packet. get_string ( ) <TAB> packet. check_end ( ) <TAB> if service == self. _next_service : <TAB> <TAB> self. logger. debug2 ( ""Accepting request for service %s"", service ) <TAB> <TAB> self. _next_service = None <TAB> <TAB> self. send_packet ( MSG_SERVICE_ACCEPT, String ( service ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _auth_in_progress = True <TAB> <TAB> <TAB> self. _send_deferred_packets ( ) <TAB> else : <TAB> <TAB> raise DisconnectError ( <TAB> <TAB> <TAB> DISC_SERVICE_NOT_AVAILABLE, ""Unexpected service request received"" <TAB> <TAB> )",False,self.is_server() and service == _USERAUTH_SERVICE,self._auth_in_progress,0.6530213356018066
|
||
|
2261,"def __init__ ( self, library, binary = None ) : <TAB> self. results = { } <TAB> try : <TAB> <TAB> lib = SIM_LIBRARIES [ library ] <TAB> except KeyError : <TAB> <TAB> raise AngrValueError ( ""No such library %s"" % library ) <TAB> if binary is None : <TAB> <TAB> binary = self. project. loader. main_object <TAB> for func in binary. symbols : <TAB> <TAB> if not func. is_function : <TAB> <TAB> <TAB> continue <TAB> <TAB> if self. project. is_hooked ( func. rebased_addr ) : <TAB> <TAB> <TAB> l. debug ( ""Skipping %s at %#x, already hooked"", func. name, func. rebased_addr ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> proc = lib. get ( func. name, self. project. arch ) <TAB> <TAB> <TAB> self. results [ func. rebased_addr ] = proc <TAB> <TAB> <TAB> if self. project. is_hooked ( func. rebased_addr ) : <TAB> <TAB> <TAB> <TAB> l. debug ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Skipping %s at %#x, already hooked"", func. name, func. rebased_addr <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. project. hook ( func. rebased_addr, proc ) <TAB> <TAB> <TAB> <TAB> l. info ( ""Hooked %s at %#x"", func. name, func. rebased_addr ) <TAB> <TAB> else : <TAB> <TAB> <TAB> l. debug ( ""Failed to hook %s at %#x"", func. name, func. rebased_addr )",False,lib.has_implementation(func.name),self.project.arch != None,0.6505863666534424
|
||
|
2262,"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. lockid = iprot. readI64 ( ) <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. state = iprot. readI32 ( ) <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.I32,fid == 3,0.658821702003479
|
||
|
2263,"def insert ( self, index, item ) : <TAB> if len ( self. lists ) == 1 : <TAB> <TAB> self. lists [ 0 ]. insert ( index, item ) <TAB> <TAB> self. _balance_list ( 0 ) <TAB> else : <TAB> <TAB> list_idx, rel_idx = self. _translate_index ( index ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise IndexError ( ) <TAB> <TAB> self. lists [ list_idx ]. insert ( rel_idx, item ) <TAB> <TAB> self. _balance_list ( list_idx ) <TAB> return",False,list_idx is None,list_idx not in len(self.lists),0.6620573401451111
|
||
|
2264,def output_handles_from_execution_plan ( execution_plan ) : <TAB> output_handles_for_current_run = set ( ) <TAB> for step_level in execution_plan. execution_step_levels ( ) : <TAB> <TAB> for step in step_level : <TAB> <TAB> <TAB> for step_input in step. step_inputs : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> output_handles_for_current_run. update ( step_input. source_handles ) <TAB> return output_handles_for_current_run,True,step_input.source_handles,step_input.source_handles,0.6585800647735596
|
||
|
2265,"def update_metas ( <TAB> self, <TAB> schema = None, <TAB> count = None, <TAB> part_of_data = None, <TAB> description = None, <TAB> partitions = None, <TAB> in_serialized = None, <TAB> ** kwargs ) : <TAB> meta_info = { } <TAB> for k, v in locals ( ). items ( ) : <TAB> <TAB> if k not in [ ""self"", ""kwargs"", ""meta_info"" ] and v is not None : <TAB> <TAB> <TAB> meta_info [ k ] = v <TAB> meta_info. update ( kwargs ) <TAB> meta_info [ ""name"" ] = meta_info. get ( ""name"", self. name ) <TAB> meta_info [ ""namespace"" ] = meta_info. get ( ""namespace"", self. namespace ) <TAB> update_filters = [ ] <TAB> primary_keys = StorageTableMetaModel. _meta. primary_key. field_names <TAB> for p_k in primary_keys : <TAB> <TAB> update_filters. append ( <TAB> <TAB> <TAB> operator. attrgetter ( p_k ) ( StorageTableMetaModel ) <TAB> <TAB> <TAB> == meta_info [ p_k. lstrip ( ""f_"" ) ] <TAB> <TAB> ) <TAB> table_meta = StorageTableMetaModel ( ) <TAB> update_fields = { } <TAB> for k, v in meta_info. items ( ) : <TAB> <TAB> attr_name = ""f_%s"" % k <TAB> <TAB> if hasattr ( StorageTableMetaModel, attr_name ) and attr_name not in primary_keys : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> if len ( v ) < 100 : <TAB> <TAB> <TAB> <TAB> <TAB> tmp = v <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> tmp = v [ : 100 ] <TAB> <TAB> <TAB> <TAB> update_fields [ <TAB> <TAB> <TAB> <TAB>",False,k == 'part_of_data',len(v) > 0,0.6513879895210266
|
||
|
2266,"def use_index ( <TAB> self, term : Union [ str, Index ], * terms : Union [ str, Index ] ) -> ""QueryBuilder"" : <TAB> for t in ( term, * terms ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _use_indexes. append ( t ) <TAB> <TAB> elif isinstance ( t, str ) : <TAB> <TAB> <TAB> self. _use_indexes. append ( Index ( t ) )",True,"isinstance(t, Index)","isinstance(t, Index)",0.6632080674171448
|
||
|
2267,"def generate_self_block ( self, block : PLBlock ) -> Optional [ PLBlock ] : <TAB> if not self. commands : <TAB> <TAB> return None <TAB> self_block = block. add_block ( ) <TAB> prefix_code = self. prefix_code ( ) <TAB> actions = [ ] <TAB> dynamic_actions = [ ] <TAB> for cmd in self. commands : <TAB> <TAB> if isinstance ( cmd, tuple ) and ( cmd [ 1 ] or cmd [ 2 ] ) : <TAB> <TAB> <TAB> action = cmd [ 0 ]. code ( self_block ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> subcommand = f""EXECUTE {ql(prefix_code)} ||'' || {action}"" <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> subcommand = prefix_code + "" "" + action <TAB> <TAB> <TAB> self_block. add_command ( subcommand, conditions = cmd [ 1 ], neg_conditions = cmd [ 2 ] ) <TAB> <TAB> else : <TAB> <TAB> <TAB> action = cmd. code ( self_block ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> subcommand = f""EXECUTE {ql(prefix_code)} ||'' || {action}"" <TAB> <TAB> <TAB> <TAB> dynamic_actions. append ( subcommand ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> actions. append ( action ) <TAB> if actions : <TAB> <TAB> command = prefix_code + "" "" + "", "". join ( actions ) <TAB> <TAB> self_block. add_command ( command ) <TAB> if dynamic_actions : <TAB> <TAB> for action in dynamic_actions : <TAB> <TAB> <TAB> self_block. add_command ( action ) <TAB> extra_block = self_block. add_block ( ) <TAB> for cmd in self. commands : <TAB> <TAB> if isinstance ( cmd, tuple ) and ( cmd [ 1 ] or cmd [ 2 ] ) : <TAB",False,"isinstance(action, PLExpression)",action,0.6632215976715088
|
||
|
2268,"def clean ( self, ignore_ignored = True ) : <TAB> files = [ ] <TAB> commands = [ [ ""mtn"", ""ls"", ""unknown"" ] ] <TAB> if not ignore_ignored : <TAB> <TAB> commands. append ( [ ""mtn"", ""ls"", ""ignored"" ] ) <TAB> for cmd in commands : <TAB> <TAB> stdout = yield self. _dovccmd ( cmd, workdir = self. workdir, collectStdout = True ) <TAB> <TAB> if not stdout : <TAB> <TAB> <TAB> continue <TAB> <TAB> for filename in stdout. strip ( ). split ( ""\n"" ) : <TAB> <TAB> <TAB> filename = self. workdir + ""/"" + str ( filename ) <TAB> <TAB> <TAB> files. append ( filename ) <TAB> if not files : <TAB> <TAB> rc = 0 <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> rc = yield self. removeFiles ( files ) <TAB> <TAB> else : <TAB> <TAB> <TAB> rc = yield self. runRmdir ( files, abandonOnFailure = False ) <TAB> if rc!= 0 : <TAB> <TAB> log. msg ( ""Failed removing files"" ) <TAB> <TAB> raise buildstep. BuildStepFailed ( )",False,"self.workerVersionIsOlderThan('rmdir', '2.14')",self.removeFiles(files),0.6504614949226379
|
||
|
2269,"def _execute ( self, undoinfo ) : <TAB> if undoinfo is None : <TAB> <TAB> return None <TAB> msg, func, args = UndoRedo. _split ( undoinfo ) <TAB> if isinstance ( func, list ) : <TAB> <TAB> redolist = [ ] <TAB> <TAB> while func : <TAB> <TAB> <TAB> redolist. append ( self. _execute ( func. pop ( ) ) ) <TAB> <TAB> if msg : <TAB> <TAB> <TAB> return msg, redolist <TAB> <TAB> else : <TAB> <TAB> <TAB> return redolist <TAB> else : <TAB> <TAB> <TAB> <TAB> redoinfo = func ( * args ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return redoinfo <TAB> <TAB> elif msg : <TAB> <TAB> <TAB> return ( msg, ) + redoinfo <TAB> <TAB> else : <TAB> <TAB> <TAB> return redoinfo",False,"isinstance(redoinfo[0], str)",redoinfo,0.657508909702301
|
||
|
2270,"def __focusDefaultButton ( self ) : <TAB> defaultButton = self. __defaultButton <TAB> if defaultButton == self. DefaultButton. FromUserData : <TAB> <TAB> defaultButton = self. DefaultButton. OK <TAB> <TAB> d = None <TAB> <TAB> with IECore. IgnoredExceptions ( KeyError ) : <TAB> <TAB> <TAB> d = self. __node. getParameterised ( ) [ 0 ]. userData ( ) [ ""UI"" ] [ ""defaultButton"" ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> for v in self. DefaultButton. values ( ) : <TAB> <TAB> <TAB> <TAB> if str ( v ). lower ( ) == d. value. lower ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> defaultButton = v <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> if defaultButton == self. DefaultButton. None_ : <TAB> <TAB> self. _qtWidget ( ). setFocus ( ) <TAB> elif defaultButton == self. DefaultButton. Cancel : <TAB> <TAB> self. __backButton. _qtWidget ( ). setFocus ( ) <TAB> else : <TAB> <TAB> self. __forwardButton. _qtWidget ( ). setFocus ( )",False,d is not None,d,0.6591241359710693
|
||
|
2271,"def sysctlTestAndSet ( name, limit ) : <TAB> ""Helper function to set sysctl limits"" <TAB> <TAB> if ""/"" not in name : <TAB> <TAB> name = ""/proc/sys/"" + name. replace ( ""."", ""/"" ) <TAB> <TAB> with open ( name, ""r"" ) as readFile : <TAB> <TAB> oldLimit = readFile. readline ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if int ( oldLimit ) < limit : <TAB> <TAB> <TAB> <TAB> with open ( name, ""w"" ) as writeFile : <TAB> <TAB> <TAB> <TAB> <TAB> writeFile. write ( ""%d"" % limit ) <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> with open ( name, ""w"" ) as writeFile : <TAB> <TAB> <TAB> <TAB> writeFile. write ( limit )",False,"isinstance(limit, int)",oldLimit,0.6571223735809326
|
||
|
2272,"def add_listen ( self, addr ) : <TAB> ip = addr [ 0 ] <TAB> port = addr [ 1 ] <TAB> if isinstance ( ip, str ) : <TAB> <TAB> ip = ip. encode ( ""ascii"" ) <TAB> if b"":"" in ip : <TAB> <TAB> sock = socket. socket ( socket. AF_INET6, socket. SOCK_STREAM ) <TAB> else : <TAB> <TAB> sock = socket. socket ( socket. AF_INET, socket. SOCK_STREAM ) <TAB> sock. setsockopt ( socket. SOL_SOCKET, socket. SO_REUSEADDR, 1 ) <TAB> sock. setsockopt ( socket. SOL_TCP, socket. TCP_NODELAY, True ) <TAB> addr = tuple ( ( ip, port ) ) <TAB> try : <TAB> <TAB> sock. bind ( addr ) <TAB> except Exception as e : <TAB> <TAB> err_string = ""bind to %s:%d fail:%r"" % ( addr [ 0 ], addr [ 1 ], e ) <TAB> <TAB> self. logger. error ( err_string ) <TAB> <TAB> raise Exception ( err_string ) <TAB> if self. use_https : <TAB> <TAB> import OpenSSL <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> ssl_version = OpenSSL. SSL. TLSv1_2_METHOD <TAB> <TAB> elif hasattr ( OpenSSL. SSL, ""TLSv1_1_METHOD"" ) : <TAB> <TAB> <TAB> ssl_version = OpenSSL. SSL. TLSv1_1_METHOD <TAB> <TAB> elif hasattr ( OpenSSL. SSL, ""TLSv1_METHOD"" ) : <TAB> <TAB> <TAB> ssl_version = OpenSSL. SSL. TLSv1_METHOD <TAB> <TAB> ctx = OpenSSL. SSL. Context ( ssl_version ) <TAB> <TAB> <TAB> <TAB> fpem = self. cert <TAB> <TAB> ctx. use_privatekey_file ( fpem ) <TAB> <TAB> ctx. use_certificate_file ( fpem ) <TAB> <TAB> sock = OpenSSL. SSL. Connection ( ctx, sock ) <TAB> sock. listen ( 200 )",True,"hasattr(OpenSSL.SSL, 'TLSv1_2_METHOD')","hasattr(OpenSSL.SSL, 'TLSv1_2_METHOD')",0.646664023399353
|
||
|
2273,"def set_dir_modes ( self, dirname, mode ) : <TAB> if not self. is_chmod_supported ( ) : <TAB> <TAB> return <TAB> for dirpath, dirnames, fnames in os. walk ( dirname ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> log. info ( ""changing mode of %s to %o"", dirpath, mode ) <TAB> <TAB> if not self. dry_run : <TAB> <TAB> <TAB> os. chmod ( dirpath, mode )",False,os.path.islink(dirpath),"mode in ('w', 'w')",0.647996187210083
|
||
|
2274,def clean_data ( data ) : <TAB> <TAB> <TAB> <TAB> for k in list ( data. keys ( ) ) : <TAB> <TAB> delete_key = False <TAB> <TAB> new_k = collector. cached_mapped_file ( k ) <TAB> <TAB> if not new_k. startswith ( source_path ) : <TAB> <TAB> <TAB> delete_key = True <TAB> <TAB> else : <TAB> <TAB> <TAB> for omit_pattern in omit_patterns : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> delete_key = True <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> if delete_key : <TAB> <TAB> <TAB> del data [ k ] <TAB> <TAB> else : <TAB> <TAB> <TAB> v = data [ k ] <TAB> <TAB> <TAB> del data [ k ] <TAB> <TAB> <TAB> data [ new_k ] = v,False,"fnmatch(new_k, omit_pattern)",new_k.startswith(oml_pattern),0.6461020708084106
|
||
|
2275,"def init_sequence ( self, coll_name, seq_config ) : <TAB> if not isinstance ( seq_config, list ) : <TAB> <TAB> raise Exception ( '""sequence"" config must be a list' ) <TAB> handlers = [ ] <TAB> for entry in seq_config : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise Exception ( '""sequence"" entry must be a dict' ) <TAB> <TAB> name = entry. get ( ""name"", """" ) <TAB> <TAB> handler = self. load_coll ( name, entry ) <TAB> <TAB> handlers. append ( handler ) <TAB> return HandlerSeq ( handlers )",True,"not isinstance(entry, dict)","not isinstance(entry, dict)",0.6548457145690918
|
||
|
2276,"def get_dhcp_opts ( context, network_ref ) : <TAB> """"""Get network's hosts config in dhcp-opts format."""""" <TAB> hosts = [ ] <TAB> ips_ref = db. network_get_associated_fixed_ips ( context, network_ref [ ""id"" ] ) <TAB> if ips_ref : <TAB> <TAB> <TAB> <TAB> instance_set = set ( [ fixed_ip_ref [ ""instance_id"" ] for fixed_ip_ref in ips_ref ] ) <TAB> <TAB> default_gw_network_node = { } <TAB> <TAB> for instance_id in instance_set : <TAB> <TAB> <TAB> vifs = db. virtual_interface_get_by_instance ( context, instance_id ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> default_gw_network_node [ instance_id ] = vifs [ 0 ] [ ""network_id"" ] <TAB> <TAB> for fixed_ip_ref in ips_ref : <TAB> <TAB> <TAB> instance_id = fixed_ip_ref [ ""instance_id"" ] <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> instance_ref = db. instance_get ( context, instance_id ) <TAB> <TAB> <TAB> except exception. InstanceNotFound : <TAB> <TAB> <TAB> <TAB> msg = _ ( ""Instance %(instance_id)s not found"" ) <TAB> <TAB> <TAB> <TAB> LOG. debug ( msg % { ""instance_id"" : instance_id } ) <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if instance_id in default_gw_network_node : <TAB> <TAB> <TAB> <TAB> target_network_id = default_gw_network_node [ instance_id ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if target_network_id!= fixed_ip_ref [ ""network_id"" ] : <TAB> <TAB> <",False,vifs,len(vifs,0.6847608089447021
|
||
|
2277,"def stats ( self, parent ) : <TAB> nvar = parent. exog. shape [ 1 ] <TAB> rv = parent. endog. copy ( ) <TAB> vl = [ ( i, parent. exog [ :, i ] ) for i in range ( nvar ) ] <TAB> z = np. empty ( nvar ) <TAB> past = [ ] <TAB> for i in range ( nvar ) : <TAB> <TAB> dp = np. r_ [ [ np. abs ( np. dot ( rv, x [ 1 ] ) ) for x in vl ] ] <TAB> <TAB> j = np. argmax ( dp ) <TAB> <TAB> z [ vl [ j ] [ 0 ] ] = nvar - i - 1 <TAB> <TAB> x = vl [ j ] [ 1 ] <TAB> <TAB> del vl [ j ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> for v in past : <TAB> <TAB> <TAB> <TAB> x -= np. dot ( x, v ) * v <TAB> <TAB> <TAB> past. append ( x ) <TAB> <TAB> rv -= np. dot ( rv, x ) * x <TAB> z1 = z [ 0 : nvar // 2 ] <TAB> z2 = z [ nvar // 2 : ] <TAB> st = np. where ( z1 > z2, z1, z2 ) * np. sign ( z1 - z2 ) <TAB> return st",False,self.pursuit,past,0.6620579957962036
|
||
|
2278,"def reward ( self ) : <TAB> """"""Returns a tuple of sum of raw and processed rewards."""""" <TAB> raw_rewards, processed_rewards = 0, 0 <TAB> for ts in self. time_steps : <TAB> <TAB> <TAB> <TAB> if ts. raw_reward is not None : <TAB> <TAB> <TAB> raw_rewards += ts. raw_reward <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> processed_rewards += ts. processed_reward <TAB> return raw_rewards, processed_rewards",True,ts.processed_reward is not None,ts.processed_reward is not None,0.6585056185722351
|
||
|
2279,"def do_uninstall ( self, name ) : <TAB> """"""Uninstall a plugin."""""" <TAB> for ( <TAB> <TAB> plugin <TAB> ) in self. site. plugin_manager. getAllPlugins ( ) : <TAB> <TAB> if name == plugin. name : <TAB> <TAB> <TAB> p = plugin. path <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> p = p + os. sep <TAB> <TAB> <TAB> <TAB> p = os. path. abspath ( os. path. join ( p, os. pardir ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> p = os. path. dirname ( p ) <TAB> <TAB> <TAB> LOGGER. warning ( ""About to uninstall plugin: {0}"". format ( name ) ) <TAB> <TAB> <TAB> LOGGER. warning ( ""This will delete {0}"". format ( p ) ) <TAB> <TAB> <TAB> sure = utils. ask_yesno ( ""Are you sure?"" ) <TAB> <TAB> <TAB> if sure : <TAB> <TAB> <TAB> <TAB> LOGGER. warning ( ""Removing {0}"". format ( p ) ) <TAB> <TAB> <TAB> <TAB> shutil. rmtree ( p ) <TAB> <TAB> <TAB> <TAB> return 0 <TAB> <TAB> <TAB> return 1 <TAB> LOGGER. error ( ""Unknown plugin: {0}"". format ( name ) ) <TAB> return 1",False,os.path.isdir(p),p and os.path.exists(p),0.6460264921188354
|
||
|
2280,"def test_positions_on_track ( self ) -> None : <TAB> gpx = mod_gpx. GPX ( ) <TAB> track = mod_gpx. GPXTrack ( ) <TAB> gpx. tracks. append ( track ) <TAB> segment = mod_gpx. GPXTrackSegment ( ) <TAB> track. segments. append ( segment ) <TAB> location_to_find_on_track = None <TAB> for i in range ( 1000 ) : <TAB> <TAB> latitude = 45 + i * 0.001 <TAB> <TAB> longitude = 45 + i * 0.001 <TAB> <TAB> elevation = 100 + i * 2 <TAB> <TAB> point = mod_gpx. GPXTrackPoint ( <TAB> <TAB> <TAB> latitude = latitude, longitude = longitude, elevation = elevation <TAB> <TAB> ) <TAB> <TAB> segment. points. append ( point ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> location_to_find_on_track = mod_gpx. GPXWaypoint ( <TAB> <TAB> <TAB> <TAB> latitude = latitude, longitude = longitude <TAB> <TAB> <TAB> ) <TAB> result = gpx. get_nearest_locations ( location_to_find_on_track ) <TAB> self. assertTrue ( len ( result ) == 1 )",False,i == 500,gpx.get_distance() > 0,0.6912835836410522
|
||
|
2281,"def updateNodeStatistics ( self ) : <TAB> scenario_solutions = [ <TAB> <TAB> ( scenario. _probability, scenario. _x [ self. _name ] ) for scenario in self. _scenarios <TAB> ] <TAB> for variable_id in self. _variable_ids : <TAB> <TAB> stale = False <TAB> <TAB> values = [ ] <TAB> <TAB> avg_value = 0.0 <TAB> <TAB> for probability, var_values in scenario_solutions : <TAB> <TAB> <TAB> val = var_values [ variable_id ] <TAB> <TAB> <TAB> if val is not None : <TAB> <TAB> <TAB> <TAB> avg_value += probability * val <TAB> <TAB> <TAB> <TAB> values. append ( val ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> stale = True <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _minimums [ variable_id ] = None <TAB> <TAB> <TAB> self. _maximums [ variable_id ] = None <TAB> <TAB> <TAB> self. _averages [ variable_id ] = None <TAB> <TAB> else : <TAB> <TAB> <TAB> avg_value /= self. _probability <TAB> <TAB> <TAB> self. _minimums [ variable_id ] = min ( values ) <TAB> <TAB> <TAB> self. _maximums [ variable_id ] = max ( values ) <TAB> <TAB> <TAB> self. _averages [ variable_id ] = avg_value",True,stale,stale,0.7056097984313965
|
||
|
2282,"def __init__ ( self, * args, ** kwargs ) : <TAB> self. shp = None <TAB> self. shx = None <TAB> self. dbf = None <TAB> self. shapeName = ""Not specified"" <TAB> self. _offsets = [ ] <TAB> self. shpLength = None <TAB> self. numRecords = None <TAB> self. fields = [ ] <TAB> self. __dbfHdrLength = 0 <TAB> <TAB> if len ( args ) > 0 : <TAB> <TAB> if type ( args [ 0 ] ) is type ( ""stringTest"" ) : <TAB> <TAB> <TAB> self. load ( args [ 0 ] ) <TAB> <TAB> <TAB> return <TAB> if ""shp"" in kwargs. keys ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. shp = kwargs [ ""shp"" ] <TAB> <TAB> <TAB> if hasattr ( self. shp, ""seek"" ) : <TAB> <TAB> <TAB> <TAB> self. shp. seek ( 0 ) <TAB> <TAB> if ""shx"" in kwargs. keys ( ) : <TAB> <TAB> <TAB> if hasattr ( kwargs [ ""shx"" ], ""read"" ) : <TAB> <TAB> <TAB> <TAB> self. shx = kwargs [ ""shx"" ] <TAB> <TAB> <TAB> <TAB> if hasattr ( self. shx, ""seek"" ) : <TAB> <TAB> <TAB> <TAB> <TAB> self. shx. seek ( 0 ) <TAB> if ""dbf"" in kwargs. keys ( ) : <TAB> <TAB> if hasattr ( kwargs [ ""dbf"" ], ""read"" ) : <TAB> <TAB> <TAB> self. dbf = kwargs [ ""dbf"" ] <TAB> <TAB> <TAB> if hasattr ( self. dbf, ""seek"" ) : <TAB> <TAB> <TAB> <TAB> self. dbf. seek ( 0 ) <TAB> if self. shp or self. dbf : <TAB> <TAB> self. load ( ) <TAB> else : <TAB> <TAB> raise ShapefileException ( <TAB",False,"hasattr(kwargs['shp'], 'read')",'sshp' in kwargs.keys(),0.6562072038650513
|
||
|
2283,"def _load_from_obj ( original_fn, obj, f, * args, ** kwargs ) : <TAB> <TAB> if not PatchPyTorchModelIO. __main_task : <TAB> <TAB> return original_fn ( obj, f, * args, ** kwargs ) <TAB> <TAB> try : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> filename = f <TAB> <TAB> elif hasattr ( f, ""as_posix"" ) : <TAB> <TAB> <TAB> filename = f. as_posix ( ) <TAB> <TAB> elif hasattr ( f, ""name"" ) : <TAB> <TAB> <TAB> filename = f. name <TAB> <TAB> else : <TAB> <TAB> <TAB> filename = None <TAB> except Exception : <TAB> <TAB> filename = None <TAB> <TAB> empty = _Empty ( ) <TAB> <TAB> if False and running_remotely ( ) : <TAB> <TAB> filename = WeightsFileHandler. restore_weights_file ( <TAB> <TAB> <TAB> empty, filename, Framework. pytorch, PatchPyTorchModelIO. __main_task <TAB> <TAB> ) <TAB> <TAB> model = original_fn ( obj, filename or f, * args, ** kwargs ) <TAB> else : <TAB> <TAB> <TAB> <TAB> model = original_fn ( obj, f, * args, ** kwargs ) <TAB> <TAB> WeightsFileHandler. restore_weights_file ( <TAB> <TAB> <TAB> empty, filename, Framework. pytorch, PatchPyTorchModelIO. __main_task <TAB> <TAB> ) <TAB> if empty. trains_in_model : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> model. trains_in_model = empty. trains_in_model <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> pass <TAB> return model",False,"isinstance(f, six.string_types)","hasattr(f, '__load_weights_file')",0.6473408937454224
|
||
|
2284,"def _request_data ( self ) : <TAB> """"""Return a tuple (url, data, headers)."""""" <TAB> method = self. method. upper ( ) <TAB> <TAB> parts = self. _urlparse ( self. action ) <TAB> rest, ( query, frag ) = parts [ : - 2 ], parts [ - 2 : ] <TAB> if method == ""GET"" : <TAB> <TAB> self. enctype = ""application/x-www-form-urlencoded"" <TAB> <TAB> parts = rest + ( urlencode ( self. _pairs ( ) ), None ) <TAB> <TAB> uri = self. _urlunparse ( parts ) <TAB> <TAB> return uri, None, [ ] <TAB> elif method == ""POST"" : <TAB> <TAB> parts = rest + ( query, None ) <TAB> <TAB> uri = self. _urlunparse ( parts ) <TAB> <TAB> if self. enctype == ""application/x-www-form-urlencoded"" : <TAB> <TAB> <TAB> return ( uri, urlencode ( self. _pairs ( ) ), [ ( ""Content-Type"", self. enctype ) ] ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> return ( uri, self. _pairs ( ), [ ( ""Content-Type"", self. enctype ) ] ) <TAB> <TAB> elif self. enctype == ""multipart/form-data"" : <TAB> <TAB> <TAB> data = _cStringIO ( ) <TAB> <TAB> <TAB> http_hdrs = [ ] <TAB> <TAB> <TAB> mw = MimeWriter ( data, http_hdrs ) <TAB> <TAB> <TAB> f = mw. startmultipartbody ( ""form-data"", add_to_http_hdrs = True, prefix = 0 ) <TAB> <TAB> <TAB> for ii, k, v, control_index in self. _pairs_and_controls ( ) : <TAB> <TAB> <TAB> <TAB> self. controls [ control_index ]. _write_mime_data ( mw, k, v ) <TAB> <TAB> <TAB> mw. lastpart ( ) <TAB> <TAB> <",False,self.enctype == 'text/plain',self.enctype == 'application/x-www-form-data',0.6497485637664795
|
||
|
2285,"def _readline_from_keyboard ( self ) : <TAB> c = self. console <TAB> while 1 : <TAB> <TAB> self. _update_line ( ) <TAB> <TAB> event = c. getkeypress ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. next_meta = False <TAB> <TAB> <TAB> control, meta, shift, code = event. keyinfo <TAB> <TAB> <TAB> event. keyinfo = ( control, True, shift, code ) <TAB> <TAB> <TAB> <TAB> if event. keyinfo in self. exit_dispatch : <TAB> <TAB> <TAB> if lineobj. EndOfLine ( self. l_buffer ) == 0 : <TAB> <TAB> <TAB> <TAB> raise EOFError <TAB> <TAB> dispatch_func = self. key_dispatch. get ( event. keyinfo. tuple ( ), self. vi_key ) <TAB> <TAB> log ( ""readline from keyboard:%s->%s"" % ( event. keyinfo. tuple ( ), dispatch_func ) ) <TAB> <TAB> r = None <TAB> <TAB> if dispatch_func : <TAB> <TAB> <TAB> r = dispatch_func ( event ) <TAB> <TAB> <TAB> self. l_buffer. push_undo ( ) <TAB> <TAB> self. previous_func = dispatch_func <TAB> <TAB> if r : <TAB> <TAB> <TAB> self. _update_line ( ) <TAB> <TAB> <TAB> break",True,self.next_meta,self.next_meta,0.6536632776260376
|
||
|
2286,"def format_sql ( sql, params ) : <TAB> rv = [ ] <TAB> if isinstance ( params, dict ) : <TAB> <TAB> <TAB> <TAB> conv = _FormatConverter ( params ) <TAB> <TAB> if params : <TAB> <TAB> <TAB> sql = sql_to_string ( sql ) <TAB> <TAB> <TAB> sql = sql % conv <TAB> <TAB> <TAB> params = conv. params <TAB> <TAB> else : <TAB> <TAB> <TAB> params = ( ) <TAB> for param in params or ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> rv. append ( ""NULL"" ) <TAB> <TAB> param = safe_repr ( param ) <TAB> <TAB> rv. append ( param ) <TAB> return sql, rv",True,param is None,param is None,0.6670687198638916
|
||
|
2287,"def f ( self, info ) : <TAB> for k in keys : <TAB> <TAB> if callable ( k ) : <TAB> <TAB> <TAB> for k2 in list ( info. keys ( ) ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> info. pop ( k2 ) <TAB> <TAB> else : <TAB> <TAB> <TAB> info. pop ( k, None )",False,k(k2),k2,0.6592751741409302
|
||
|
2288,"def kdt_closest_edges ( verts, socket_inputs ) : <TAB> """"""Join verts pairs by defining distance range and number of connections"""""" <TAB> mindist, maxdist, maxNum, skip = socket_inputs <TAB> <TAB> kd = create_kdt ( verts ) <TAB> <TAB> maxNum = max ( maxNum, 1 ) <TAB> skip = max ( skip, 0 ) <TAB> <TAB> edges = set ( ) <TAB> edges_add = edges. add <TAB> max_dist = abs ( maxdist ) <TAB> min_dist = abs ( mindist ) <TAB> for i, vtx in enumerate ( verts ) : <TAB> <TAB> num_edges = 0 <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for edge_idx, ( _, index, dist ) in enumerate ( kd. find_range ( vtx, max_dist ) ) : <TAB> <TAB> <TAB> if skip > 0 : <TAB> <TAB> <TAB> <TAB> if edge_idx < skip : <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if ( dist <= min_dist ) or ( i == index ) : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> edge = tuple ( sorted ( [ i, index ] ) ) <TAB> <TAB> <TAB> if not edge in edges : <TAB> <TAB> <TAB> <TAB> edges_add ( edge ) <TAB> <TAB> <TAB> <TAB> num_edges += 1 <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> break <TAB> return list ( edges )",False,num_edges == maxNum,num_edges >= max_dist,0.6677591800689697
|
||
|
2289,"def _populate_class_variables ( ) : <TAB> lookup = { } <TAB> reverse_lookup = { } <TAB> characters_for_re = [ ] <TAB> for codepoint, name in list ( codepoint2name. items ( ) ) : <TAB> <TAB> character = chr ( codepoint ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> characters_for_re. append ( character ) <TAB> <TAB> <TAB> lookup [ character ] = name <TAB> <TAB> <TAB> <TAB> reverse_lookup [ name ] = character <TAB> re_definition = ""[%s]"" % """". join ( characters_for_re ) <TAB> return lookup, reverse_lookup, re. compile ( re_definition )",False,codepoint != 34,character >= 32,0.6735028028488159
|
||
|
2290,"def main ( ) : <TAB> <TAB> docs = ""Common AST"" <TAB> docs += ""\n"" + ""="" * len ( docs ) + ""\n\n"" <TAB> docs += "".. automodule:: commonast\n\n"" <TAB> docs += "".. autofunction:: commonast.parse\n\n"" <TAB> docs += ""----\n\n"" <TAB> docs += ""The nodes\n---------\n\n"" <TAB> docs += "".. autoclass:: commonast.Node\n :members:\n\n"" <TAB> code = open ( commonast. __file__, ""rb"" ). read ( ). decode ( ) <TAB> status = 0 <TAB> for line in code. splitlines ( ) : <TAB> <TAB> if status == 0 : <TAB> <TAB> <TAB> if line. startswith ( ""## --"" ) : <TAB> <TAB> <TAB> <TAB> status = 1 <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> if line. startswith ( ""## --"" ) : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> elif line. startswith ( ""## "" ) : <TAB> <TAB> <TAB> <TAB> title = line [ 3 : ]. strip ( ) <TAB> <TAB> <TAB> <TAB> docs += ""%s\n%s\n\n"" % ( title, ""-"" * len ( title ) ) <TAB> <TAB> <TAB> elif line. startswith ( ""class "" ) : <TAB> <TAB> <TAB> <TAB> clsname = line [ 6 : ]. split ( ""("" ) [ 0 ] <TAB> <TAB> <TAB> <TAB> docs += "".. autoclass:: %s\n\n"" % ( ""commonast."" + clsname ) <TAB> <TAB> <TAB> <TAB> cls = getattr ( commonast, clsname ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> cls. __doc__ = ""%s()\n%s"" % ( clsname, cls. __doc__ ) <TAB> <TAB> filename = os. path. join ( OUTPUT_DIR, """,False,status == 1,status == 2,0.6859836578369141
|
||
|
2291,"def __init__ ( self, input_chunk ) : <TAB> self. qualifier = None <TAB> self. may_must = None <TAB> self. flag_actions = [ ] <TAB> m = flags_rec_t. _flag_pattern. search ( input_chunk ) <TAB> if m : <TAB> <TAB> flags_input = m. group ( ""flags"" ). strip ( ). split ( ) <TAB> <TAB> qualifiers = m. group ( ""qualifiers"" ). strip ( ). split ( ) <TAB> else : <TAB> <TAB> die ( ""Could not find flags in %s"" % input_chunk ) <TAB> first = qualifiers [ 0 ] <TAB> if first in flags_rec_t. valid_flags_qualifiers : <TAB> <TAB> self. qualifier = first <TAB> <TAB> qualifiers. pop ( 0 ) <TAB> self. may_must = qualifiers [ 0 ] <TAB> if self. may_must not in flags_rec_t. valid_flags_semantics_specifiers : <TAB> <TAB> die ( ""Invalid flags specification: %s"" % input_chunk ) <TAB> self. read_set = flag_set_t ( ) <TAB> self. write_set = flag_set_t ( ) <TAB> self. undefined_set = flag_set_t ( ) <TAB> self. flag_action_index = - 1 <TAB> self. simple_id = - 1 <TAB> for flag_action_str in flags_input : <TAB> <TAB> fa = flag_action_t ( flag_action_str ) <TAB> <TAB> self. flag_actions. append ( fa ) <TAB> <TAB> if fa. flag : <TAB> <TAB> <TAB> if fa. reads_flag ( ) : <TAB> <TAB> <TAB> <TAB> self. read_set. set ( fa. flag ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. write_set. set ( fa. flag ) <TAB> <TAB> <TAB> if fa. makes_flag_undefined ( ) : <TAB> <TAB> <TAB> <TAB> self. undefined_set. set ( fa",False,fa.writes_flag(),fa.makes_flag_out(),0.6603126525878906
|
||
|
2292,"def enable ( self ) : <TAB> log. debug ( ""\n\nEnabling %s"", self. __class__. __name__ ) <TAB> for event in self. events : <TAB> <TAB> if self. __imp == ""core"" : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> component. get ( ""Notifications"" ). register_custom_email_notification ( <TAB> <TAB> <TAB> <TAB> event. __class__. __name__, self. custom_email_message_provider <TAB> <TAB> <TAB> ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> notifications_component = component. get ( ""Notifications"" ) <TAB> <TAB> <TAB> notifications_component. register_custom_popup_notification ( <TAB> <TAB> <TAB> <TAB> event. __class__. __name__, self. custom_popup_message_provider <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> notifications_component. register_custom_blink_notification ( <TAB> <TAB> <TAB> <TAB> event. __class__. __name__, self. custom_blink_message_provider <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> notifications_component. register_custom_sound_notification ( <TAB> <TAB> <TAB> <TAB> event. __class__. __name__, self. custom_sound_message_provider <TAB> <TAB> <TAB> ) <TAB> self. lc. start ( 60, False )",False,self.__imp == 'gtk',self.__imp == 'popup',0.6548651456832886
|
||
|
2293,"def _get_filter ( self, tag, user_id, include_draft, conn ) : <TAB> filters = [ ] <TAB> if tag : <TAB> <TAB> tag = tag. upper ( ) <TAB> <TAB> tag_statement = sqla. select ( [ self. _tag_table. c. id ] ). where ( <TAB> <TAB> <TAB> self. _tag_table. c. text == tag <TAB> <TAB> ) <TAB> <TAB> tag_result = conn. execute ( tag_statement ). fetchone ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> tag_id = tag_result [ 0 ] <TAB> <TAB> <TAB> tag_filter = sqla. and_ ( <TAB> <TAB> <TAB> <TAB> self. _tag_posts_table. c. tag_id == tag_id, <TAB> <TAB> <TAB> <TAB> self. _post_table. c. id == self. _tag_posts_table. c. post_id, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> filters. append ( tag_filter ) <TAB> if user_id : <TAB> <TAB> user_filter = sqla. and_ ( <TAB> <TAB> <TAB> self. _user_posts_table. c. user_id == user_id, <TAB> <TAB> <TAB> self. _post_table. c. id == self. _user_posts_table. c. post_id, <TAB> <TAB> ) <TAB> <TAB> filters. append ( user_filter ) <TAB> draft_filter = ( <TAB> <TAB> self. _post_table. c. draft == 1 <TAB> <TAB> if include_draft <TAB> <TAB> else self. _post_table. c. draft == 0 <TAB> ) <TAB> filters. append ( draft_filter ) <TAB> sql_filter = sqla. and_ ( * filters ) <TAB> return sql_filter",False,tag_result is not None,tag_result,0.6548498868942261
|
||
|
2294,"def generateMapItemNode ( self, node ) : <TAB> try : <TAB> <TAB> self. mappingItem = True <TAB> <TAB> fieldname, value = node <TAB> <TAB> transformed_fieldname = self. fieldNameMapping ( fieldname, value ) <TAB> <TAB> has_wildcard = re. search ( <TAB> <TAB> <TAB> r""((\\(\*|\?|\\))|\*|\?|_|%)"", self. generateNode ( value ) <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return self. mapMulti % ( transformed_fieldname, self. generateNode ( value ) ) <TAB> <TAB> elif ""LENGTH"" in transformed_fieldname : <TAB> <TAB> <TAB> return self. mapLength % ( transformed_fieldname, value ) <TAB> <TAB> elif type ( value ) == list : <TAB> <TAB> <TAB> return self. generateMapItemListNode ( transformed_fieldname, value ) <TAB> <TAB> elif ( <TAB> <TAB> <TAB> self. mapListsSpecialHandling == False <TAB> <TAB> <TAB> and type ( value ) in ( str, int, list ) <TAB> <TAB> <TAB> or self. mapListsSpecialHandling == True <TAB> <TAB> <TAB> and type ( value ) in ( str, int ) <TAB> <TAB> ) : <TAB> <TAB> <TAB> if has_wildcard : <TAB> <TAB> <TAB> <TAB> return self. mapWildcard % ( <TAB> <TAB> <TAB> <TAB> <TAB> transformed_fieldname, <TAB> <TAB> <TAB> <TAB> <TAB> self. generateNode ( value ), <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> return self. mapExpression % ( <TAB> <TAB> <TAB> <TAB> <TAB> transformed_fieldname, <TAB> <TAB> <TAB> <TAB> <TAB> self. generateNode ( value ), <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> elif ""sourcetype",False,"',' in self.generateNode(value) and (not has_wildcard)","""MULTI_TAB > 0",0.6534509658813477
|
||
|
2295,"def depth_first_search ( split_bin_str, n, l, sol = None, cur_sum = 0 ) : <TAB> """"""Partition an integer value of n into l bins each with min 1"""""" <TAB> sol = sol or [ ] <TAB> cur_idx = len ( sol ) <TAB> if cur_idx < l : <TAB> <TAB> m = len ( split_bin_str [ cur_idx ] ) <TAB> <TAB> n_avail = n - cur_sum <TAB> <TAB> for j in range ( 1, min ( m, n_avail - ( l - 1 - cur_idx ) ) + 1 ) : <TAB> <TAB> <TAB> depth_first_search ( split_bin_str, n, l, sol = sol + [ j ], cur_sum = cur_sum + j ) <TAB> elif cur_idx == l : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> partition_list = sol <TAB> <TAB> <TAB> context. coeff += _coeff_monomial_with_partition ( <TAB> <TAB> <TAB> <TAB> split_bin_str, partition_list <TAB> <TAB> <TAB> )",False,cur_sum == n,n - cur_sum > 0,0.669865608215332
|
||
|
2296,"def _get_omega ( self ) : <TAB> if self. _omega is None : <TAB> <TAB> n = self. get_drift_dim ( ) // 2 <TAB> <TAB> omg = sympl. calc_omega ( n ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _omega = Qobj ( omg, dims = self. dyn_dims ) <TAB> <TAB> <TAB> self. _omega_qobj = self. _omega <TAB> <TAB> elif self. oper_dtype == sp. csr_matrix : <TAB> <TAB> <TAB> self. _omega = sp. csr_matrix ( omg ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. _omega = omg <TAB> return self. _omega",False,self.oper_dtype == Qobj,self.oper_dtype == sp.Qobj,0.6642476320266724
|
||
|
2297,"def HeaderPrintMUADetails ( message, mta = None ) : <TAB> """"""Summarize what the message tells us directly about the MUA."""""" <TAB> details = [ ] <TAB> for header in MUA_ID_HEADERS : <TAB> <TAB> value = message. get ( header ) <TAB> <TAB> if value : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> value = "" "". join ( <TAB> <TAB> <TAB> <TAB> [ <TAB> <TAB> <TAB> <TAB> <TAB> v <TAB> <TAB> <TAB> <TAB> <TAB> for v in HP_MUA_ID_SPLIT. split ( value. strip ( ) ) <TAB> <TAB> <TAB> <TAB> <TAB> if not HP_MUA_ID_IGNORE. search ( v ) <TAB> <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> details. extend ( [ header, value. strip ( ) ] ) <TAB> if not details : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> details. extend ( [ ""Guessed"", ""GMail"" ] ) <TAB> <TAB> elif ""x-ms-tnef-correlator"" in message or ""x-ms-has-attach"" in message : <TAB> <TAB> <TAB> details. extend ( [ ""Guessed"", ""Exchange"" ] ) <TAB> <TAB> elif ""@mailpile"" in message. get ( ""message-id"", """" ) : <TAB> <TAB> <TAB> details. extend ( [ ""Guessed"", ""Mailpile"" ] ) <TAB> return details",False,mta and mta[0].startswith('Received by google.com'),'x-ms-mail' in message,0.6513311862945557
|
||
|
2298,"def _renew_registration ( self, serverToRegister, registrationClient, period = DEF_REGINT ) : <TAB> <TAB> try : <TAB> <TAB> with self. _lock : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> self. _register_server ( serverToRegister, registrationClient ) <TAB> except ( BrokenPipeError, OSError ) as e : <TAB> <TAB> self. logger. info ( ""Discovery server registration failure: {:s}"". format ( str ( e ) ) ) <TAB> <TAB> return <TAB> except TimeoutError : <TAB> <TAB> self. logger. info ( ""Discovery server registration timeout: {:s}"". format ( str ( e ) ) ) <TAB> <TAB> if period == 0 : <TAB> <TAB> return <TAB> elif not serverToRegister. iserver. is_running ( ) : <TAB> <TAB> return <TAB> else : <TAB> <TAB> self. _schedule_registration ( serverToRegister, registrationClient, period )",False,registrationClient not in self._registration_clients,serverToRegister.isserver.is_running(),0.658024787902832
|
||
|
2299,"def get_cursor_position ( <TAB> fragment : str = ""[SetCursorPosition]"", ) -> Optional [ Point ] : <TAB> for y, line in enumerate ( fragment_lines ) : <TAB> <TAB> x = 0 <TAB> <TAB> for style_str, text, * _ in line : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return Point ( x = x, y = y ) <TAB> <TAB> <TAB> x += len ( text ) <TAB> return None",False,fragment in style_str,style_str.startswith(text),0.6661649942398071
|
||
|
2300,"def resize ( self, * e ) : <TAB> bold = ( ""helvetica"", - self. _size. get ( ), ""bold"" ) <TAB> helv = ( ""helvetica"", - self. _size. get ( ) ) <TAB> xspace = self. _size. get ( ) <TAB> yspace = self. _size. get ( ) <TAB> for widget in self. _widgets : <TAB> <TAB> widget [ ""node_font"" ] = bold <TAB> <TAB> widget [ ""leaf_font"" ] = helv <TAB> <TAB> widget [ ""xspace"" ] = xspace <TAB> <TAB> widget [ ""yspace"" ] = yspace <TAB> <TAB> if self. _size. get ( ) < 20 : <TAB> <TAB> <TAB> widget [ ""line_width"" ] = 1 <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> widget [ ""line_width"" ] = 2 <TAB> <TAB> else : <TAB> <TAB> <TAB> widget [ ""line_width"" ] = 3 <TAB> self. _layout ( )",False,self._size.get() < 30,self._size.get() < 50,0.6579011082649231
|
||
|
2301,"def get_generators ( self ) : <TAB> """"""Get a dict with all registered generators, indexed by name"""""" <TAB> generators = { } <TAB> for core in self. db. find ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> _generators = core. get_generators ( { } ) <TAB> <TAB> <TAB> if _generators : <TAB> <TAB> <TAB> <TAB> generators [ str ( core. name ) ] = _generators <TAB> return generators",True,"hasattr(core, 'get_generators')","hasattr(core, 'get_generators')",0.660944938659668
|
||
|
2302,"def transition ( self, context, token, value ) : <TAB> if context. type == ""from"" : <TAB> <TAB> if token == ""NAME"" : <TAB> <TAB> <TAB> if context. expect == ""source"" : <TAB> <TAB> <TAB> <TAB> if value == ""import"" and context. level : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> context. expect = ""names"" <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> context. source += value <TAB> <TAB> <TAB> <TAB> <TAB> context. expect = ""."" <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> context. expect = ""names"" <TAB> <TAB> <TAB> elif context. expect == ""names"" : <TAB> <TAB> <TAB> <TAB> context. names. append ( value ) <TAB> <TAB> <TAB> <TAB> context. expect = "","" <TAB> <TAB> elif token == ""OP"" : <TAB> <TAB> <TAB> if value == "","" and context. expect == "","" : <TAB> <TAB> <TAB> <TAB> context. expect = ""names"" <TAB> <TAB> <TAB> elif value == ""."" and context. expect == ""."" : <TAB> <TAB> <TAB> <TAB> context. source += ""."" <TAB> <TAB> <TAB> <TAB> context. expect = ""source"" <TAB> <TAB> <TAB> elif value == ""."" and context. expect == ""source"" : <TAB> <TAB> <TAB> <TAB> context. level += 1 <TAB> elif context. type == ""import"" : <TAB> <TAB> if token == ""NAME"" : <TAB> <TAB> <TAB> if context. expect == ""module"" : <TAB> <TAB> <TAB> <TAB> if context. modules and context. modules [ - 1 ]. endswith ( ""."" ) : <TAB> <TAB> <TAB> <TAB> <TAB> context. modules [ - 1 ] += value <TAB> <TAB> <TAB> <TAB",False,context.expect == '.' and value == 'import',context.expect == 'names',0.6559977531433105
|
||
|
2303,"def _verify_flow_removed ( self, dp, msg ) : <TAB> params = self. _verify [ ""params"" ] <TAB> in_port = self. _verify [ ""in_port"" ] <TAB> timeout = self. _verify [ ""timeout"" ] <TAB> if timeout : <TAB> <TAB> duration_nsec = ( msg. duration_sec * 10 ** 9 ) + msg. duration_nsec <TAB> <TAB> timeout_nsec = timeout * 10 ** 9 <TAB> <TAB> <TAB> <TAB> l = ( timeout - 0.5 ) * 10 ** 9 <TAB> <TAB> h = ( timeout + 1.5 ) * 10 ** 9 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return ""bad duration time. set=%s(nsec), duration=%s(nsec)"" % ( <TAB> <TAB> <TAB> <TAB> timeout_nsec, <TAB> <TAB> <TAB> <TAB> duration_nsec, <TAB> <TAB> <TAB> ) <TAB> for name, val in params. items ( ) : <TAB> <TAB> r_val = getattr ( msg, name ) <TAB> <TAB> if val!= r_val : <TAB> <TAB> <TAB> return ""%s is mismatched. verify=%s, reply=%s"" % ( name, val, r_val ) <TAB> for f in msg. match. fields : <TAB> <TAB> if f. header == ofproto_v1_2. OXM_OF_IN_PORT : <TAB> <TAB> <TAB> if f. value!= in_port : <TAB> <TAB> <TAB> <TAB> return ""in_port is mismatched. verify=%s, reply=%s"" % ( in_port, f. value ) <TAB> return True",False,not l < duration_nsec < h,l > timeout_nsec or h > timeout_nsec,0.6586206555366516
|
||
|
2304,"def display_prompt ( self ) : <TAB> self. caret_x = - 1 <TAB> self. caret_y = - 1 <TAB> self. do_display_prompt ( self. RPROMPT, y_offset = self. PROMPT_OFFSET_V, x_align = ""right"" ) <TAB> self. do_display_prompt ( self. PROMPT, y_offset = self. PROMPT_OFFSET_V ) <TAB> try : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. screen. move ( <TAB> <TAB> <TAB> <TAB> self. caret_y, <TAB> <TAB> <TAB> <TAB> self. caret_x <TAB> <TAB> <TAB> <TAB> + display. screen_len ( self. model. query, 0, self. model. caret ), <TAB> <TAB> <TAB> ) <TAB> except curses. error : <TAB> <TAB> pass",False,self.caret_x >= 0 and self.caret_y >= 0,self.model.caret,0.6545965075492859
|
||
|
2305,"def _update ( model, lun, value ) : <TAB> if isinstance ( model, dict ) : <TAB> <TAB> luns = model. keys ( ) if lun is None else [ lun ] <TAB> <TAB> for lun_item in luns : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise CLIError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""data disk with lun of '{}' doesn't exist"". format ( lun_item ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> model [ lun_item ] [ ""writeAcceleratorEnabled"" ] = value <TAB> else : <TAB> <TAB> if lun is None : <TAB> <TAB> <TAB> disks = [ model. os_disk ] + ( model. data_disks or [ ] ) <TAB> <TAB> elif lun == ""os"" : <TAB> <TAB> <TAB> disks = [ model. os_disk ] <TAB> <TAB> else : <TAB> <TAB> <TAB> disk = next ( ( d for d in model. data_disks if d. lun == lun ), None ) <TAB> <TAB> <TAB> if not disk : <TAB> <TAB> <TAB> <TAB> raise CLIError ( ""data disk with lun of '{}' doesn't exist"". format ( lun ) ) <TAB> <TAB> <TAB> disks = [ disk ] <TAB> <TAB> for disk in disks : <TAB> <TAB> <TAB> disk. write_accelerator_enabled = value",False,lun_item not in model,not model.data_disks,0.6596503853797913
|
||
|
2306,"def device_iter ( ** kwargs ) : <TAB> for dev in backend. enumerate_devices ( ) : <TAB> <TAB> d = Device ( dev, backend ) <TAB> <TAB> tests = ( val == _try_getattr ( d, key ) for key, val in kwargs. items ( ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> yield d",False,_interop._all(tests) and (custom_match is None or custom_match(d)),tests,0.6481562852859497
|
||
|
2307,"def test_time_series_intraday_date_indexing ( self, mock_request ) : <TAB> """"""Test that api call returns a pandas data frame with a date as index"""""" <TAB> ts = TimeSeries ( <TAB> <TAB> key = TestAlphaVantage. _API_KEY_TEST, output_format = ""pandas"", indexing_type = ""date"" <TAB> ) <TAB> url = ""https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&symbol=MSFT&interval=1min&outputsize=full&apikey=test&datatype=json"" <TAB> path_file = self. get_file_from_url ( ""mock_time_series"" ) <TAB> with open ( path_file ) as f : <TAB> <TAB> mock_request. get ( url, text = f. read ( ) ) <TAB> <TAB> data, _ = ts. get_intraday ( ""MSFT"", interval = ""1min"", outputsize = ""full"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> assert isinstance ( data. index [ 0 ], Timestamp ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if sys. version_info [ 0 ] == 3 : <TAB> <TAB> <TAB> <TAB> assert isinstance ( data. index [ 0 ], str ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> assert isinstance ( data. index [ 0 ], basestring )",False,ts.indexing_type == 'date',sys.version_info[0] == 2,0.6527478694915771
|
||
|
2308,"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 fid == 1 : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. sessionHandle = TSessionHandle ( ) <TAB> <TAB> <TAB> <TAB> self. sessionHandle. read ( iprot ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif fid == 2 : <TAB> <TAB> <TAB> if ftype == TType. I32 : <TAB> <TAB> <TAB> <TAB> self. infoType = iprot. readI32 ( ) <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.STRUCT,fid == 2,0.6616673469543457
|
||
|
2309,"def _line_ranges ( statements, lines ) : <TAB> """"""Produce a list of ranges for `format_lines`."""""" <TAB> statements = sorted ( statements ) <TAB> lines = sorted ( lines ) <TAB> pairs = [ ] <TAB> start = None <TAB> lidx = 0 <TAB> for stmt in statements : <TAB> <TAB> if lidx >= len ( lines ) : <TAB> <TAB> <TAB> break <TAB> <TAB> if stmt == lines [ lidx ] : <TAB> <TAB> <TAB> lidx += 1 <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> start = stmt <TAB> <TAB> <TAB> end = stmt <TAB> <TAB> elif start : <TAB> <TAB> <TAB> pairs. append ( ( start, end ) ) <TAB> <TAB> <TAB> start = None <TAB> if start : <TAB> <TAB> pairs. append ( ( start, end ) ) <TAB> return pairs",False,not start,stmt > lines[lidx],0.6763074398040771
|
||
|
2310,"def _build_auth_record ( response ) : <TAB> """"""Build an AuthenticationRecord from the result of an MSAL ClientApplication token request"""""" <TAB> try : <TAB> <TAB> id_token = response [ ""id_token_claims"" ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> client_info = json. loads ( _decode_client_info ( response [ ""client_info"" ] ) ) <TAB> <TAB> <TAB> home_account_id = ""{uid}.{utid}"". format ( ** client_info ) <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> home_account_id = id_token [ ""sub"" ] <TAB> <TAB> <TAB> <TAB> issuer = six. moves. urllib_parse. urlparse ( id_token [ ""iss"" ] ) <TAB> <TAB> <TAB> <TAB> tenant_id = id_token. get ( ""tid"" ) or issuer. path. strip ( ""/"" ) <TAB> <TAB> <TAB> <TAB> username = id_token. get ( ""preferred_username"" ) or id_token [ ""upn"" ] <TAB> <TAB> return AuthenticationRecord ( <TAB> <TAB> <TAB> authority = issuer. netloc, <TAB> <TAB> <TAB> client_id = id_token [ ""aud"" ], <TAB> <TAB> <TAB> home_account_id = home_account_id, <TAB> <TAB> <TAB> tenant_id = tenant_id, <TAB> <TAB> <TAB> username = username, <TAB> <TAB> ) <TAB> except ( KeyError, ValueError ) as ex : <TAB> <TAB> auth_error = ClientAuthenticationError ( <TAB> <TAB> <TAB> message = ""Failed to build AuthenticationRecord from unexpected identity token"" <TAB> <TAB> ) <TAB> <TAB> six. raise_from ( auth_error, ex )",False,'client_info' in response,id_token['client_info'],0.6563567519187927
|
||
|
2311,"def publish ( self, dashboard_id : int ) -> FlaskResponse : <TAB> """"""Gets and toggles published status on dashboards"""""" <TAB> logger. warning ( <TAB> <TAB> ""This API endpoint is deprecated and will be removed in version 1.0.0"" <TAB> ) <TAB> session = db. session ( ) <TAB> Role = ab_models. Role <TAB> dash = session. query ( Dashboard ). filter ( Dashboard. id == dashboard_id ). one_or_none ( ) <TAB> admin_role = session. query ( Role ). filter ( Role. name == ""Admin"" ). one_or_none ( ) <TAB> if request. method == ""GET"" : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return json_success ( json. dumps ( { ""published"" : dash. published } ) ) <TAB> <TAB> return json_error_response ( <TAB> <TAB> <TAB> f""ERROR: cannot find dashboard {dashboard_id}"", status = 404 <TAB> <TAB> ) <TAB> edit_perm = is_owner ( dash, g. user ) or admin_role in get_user_roles ( ) <TAB> if not edit_perm : <TAB> <TAB> return json_error_response ( <TAB> <TAB> <TAB> f'ERROR: ""{g.user.username}"" cannot alter'<TAB> <TAB> <TAB> f'dashboard ""{dash.dashboard_title}""', <TAB> <TAB> <TAB> status = 403, <TAB> <TAB> ) <TAB> dash. published = str ( request. form [ ""published"" ] ). lower ( ) == ""true"" <TAB> session. commit ( ) <TAB> return json_success ( json. dumps ( { ""published"" : dash. published } ) )",False,dash,dash.published,0.682155191898346
|
||
|
2312,"def buildGAPIServiceObject ( api, soft_errors = False ) : <TAB> global extra_args <TAB> auth_as = options. use_admin if options. use_admin else options. email <TAB> scopes = getAPIScope ( api ) <TAB> credentials = getSvcAcctCredentials ( scopes, auth_as ) <TAB> if options. debug : <TAB> <TAB> extra_args [ ""prettyPrint"" ] = True <TAB> if os. path. isfile ( os. path. join ( getProgPath ( ), ""extra-args.txt"" ) ) : <TAB> <TAB> config = configparser. ConfigParser ( ) <TAB> <TAB> config. optionxform = str <TAB> <TAB> config. read ( getGamPath ( ) + ""extra-args.txt"" ) <TAB> <TAB> extra_args. update ( dict ( config. items ( ""extra-args"" ) ) ) <TAB> httpc = _createHttpObj ( ) <TAB> request = google_auth_httplib2. Request ( httpc ) <TAB> credentials. refresh ( request ) <TAB> version = getAPIVer ( api ) <TAB> try : <TAB> <TAB> service = googleapiclient. discovery. build ( <TAB> <TAB> <TAB> api, version, http = httpc, cache_discovery = False <TAB> <TAB> ) <TAB> <TAB> service. _http = google_auth_httplib2. AuthorizedHttp ( credentials, http = httpc ) <TAB> <TAB> return service <TAB> except ( httplib2. ServerNotFoundError, RuntimeError ) as e : <TAB> <TAB> systemErrorExit ( 4, e ) <TAB> except google. auth. exceptions. RefreshError as e : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> e = e. args [ 0 ] <TAB> <TAB> systemErrorExit ( 5, e )",False,"isinstance(e.args, tuple)",e.args,0.6462751626968384
|
||
|
2313,"def create_wallet_source ( wallet : Wallet, include_worth = True ) : <TAB> exchange_name = wallet. exchange. name <TAB> symbol = wallet. instrument. symbol <TAB> with Module ( exchange_name + "":/"" + symbol ) as wallet_ds : <TAB> <TAB> free_balance = Lambda ( ""free"", lambda w : w. balance. size, wallet ) <TAB> <TAB> locked_balance = Lambda ( ""locked"", lambda w : w. locked_balance. size, wallet ) <TAB> <TAB> total_balance = Lambda ( ""total"", lambda w : w. total_balance. size, wallet ) <TAB> <TAB> nodes = [ free_balance, locked_balance, total_balance ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> price = Select ( lambda node : node. name. endswith ( symbol ) ) ( wallet. exchange ) <TAB> <TAB> <TAB> worth = BinOp ( ""worth"", operator. mul ) ( price, total_balance ) <TAB> <TAB> <TAB> nodes += [ worth ] <TAB> return wallet_ds",True,include_worth,include_worth,0.6667280793190002
|
||
|
2314,"def asset ( * paths ) : <TAB> for path in paths : <TAB> <TAB> fspath = www_root + ""/assets/"" + path <TAB> <TAB> etag = """" <TAB> <TAB> try : <TAB> <TAB> <TAB> if env. cache_static : <TAB> <TAB> <TAB> <TAB> etag = asset_etag ( fspath ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> os. stat ( fspath ) <TAB> <TAB> except FileNotFoundError as e : <TAB> <TAB> <TAB> if path == paths [ - 1 ] : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> tell_sentry ( e, { } ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> except Exception as e : <TAB> <TAB> <TAB> tell_sentry ( e, { } ) <TAB> <TAB> return asset_url + path + ( etag and ""?etag="" + etag )",False,not os.path.exists(fspath + '.spt'),e,0.652911901473999
|
||
|
2315,"def apply ( self ) : <TAB> self. maxdepth = self. startnode. details. get ( ""depth"", None ) <TAB> self. startvalue = self. startnode. details. get ( ""start"", 1 ) <TAB> self. prefix = self. startnode. details. get ( ""prefix"", """" ) <TAB> self. suffix = self. startnode. details. get ( ""suffix"", """" ) <TAB> self. startnode. parent. remove ( self. startnode ) <TAB> if self. document. settings. sectnum_xform : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. maxdepth = sys. maxint <TAB> <TAB> self. update_section_numbers ( self. document ) <TAB> else : <TAB> <TAB> self. document. settings. sectnum_depth = self. maxdepth <TAB> <TAB> self. document. settings. sectnum_start = self. startvalue <TAB> <TAB> self. document. settings. sectnum_prefix = self. prefix <TAB> <TAB> self. document. settings. sectnum_suffix = self. suffix",True,self.maxdepth is None,self.maxdepth is None,0.6597217321395874
|
||
|
2316,"def parse ( self, response ) : <TAB> try : <TAB> <TAB> content = response. content. decode ( ""utf-8"", ""ignore"" ) <TAB> <TAB> content = json. loads ( content, strict = False ) <TAB> except : <TAB> <TAB> self. logger. error ( ""Fail to parse the response in json format"" ) <TAB> <TAB> return <TAB> for item in content [ ""data"" ] : <TAB> <TAB> if ""objURL"" in item : <TAB> <TAB> <TAB> img_url = self. _decode_url ( item [ ""objURL"" ] ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> img_url = item [ ""hoverURL"" ] <TAB> <TAB> else : <TAB> <TAB> <TAB> continue <TAB> <TAB> yield dict ( file_url = img_url )",True,'hoverURL' in item,'hoverURL' in item,0.6621360778808594
|
||
|
2317,"def do_rollout ( agent, env, num_steps, render = False ) : <TAB> total_rew = 0 <TAB> ob = env. reset ( ) <TAB> for t in range ( num_steps ) : <TAB> <TAB> a = agent. act ( ob ) <TAB> <TAB> ( ob, reward, done, _info ) = env. step ( a ) <TAB> <TAB> total_rew += reward <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> env. render ( ) <TAB> <TAB> if done : <TAB> <TAB> <TAB> break <TAB> return total_rew, t + 1",False,render and t % 3 == 0,render,0.6644103527069092
|
||
|
2318,"def pickle_to_file ( obj, file_path, gzip = False ) : <TAB> """"""Pickle obj to file_path with gzipping and failure protection."""""" <TAB> <TAB> tmp_file_path = file_path + ""._tmp_"" <TAB> with tf. io. gfile. GFile ( tmp_file_path, ""wb"" ) as f : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> pickle. dump ( obj, f, protocol = pickle. HIGHEST_PROTOCOL ) <TAB> <TAB> else : <TAB> <TAB> <TAB> with gzip_lib. GzipFile ( fileobj = f, compresslevel = 2 ) as gzipf : <TAB> <TAB> <TAB> <TAB> pickle. dump ( obj, gzipf, protocol = pickle. HIGHEST_PROTOCOL ) <TAB> <TAB> tf. io. gfile. rename ( tmp_file_path, file_path, overwrite = True )",False,not gzip,gzip is False,0.6882905960083008
|
||
|
2319,"def _do_load ( self, row ) : <TAB> values = dict ( ( c. name, row [ c ] ) for c in self. columns if c in row ) <TAB> if all ( ( v is None ) for v in values. values ( ) ) : <TAB> <TAB> return None <TAB> rv = self. model ( ) <TAB> for c in self. columns : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> instance_key = self. model. _column_name_map. invert_get ( c. name ) <TAB> <TAB> <TAB> rv. __values__ [ instance_key ] = row [ c ] <TAB> return rv",True,c in row,c in row,0.681359052658081
|
||
|
2320,"def get_django_comment ( text : str, i : int ) -> str : <TAB> end = i + 4 <TAB> unclosed_end = 0 <TAB> while end <= len ( text ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return text [ i : end ] <TAB> <TAB> if not unclosed_end and text [ end ] == ""<"" : <TAB> <TAB> <TAB> unclosed_end = end <TAB> <TAB> end += 1 <TAB> raise TokenizationException ( ""Unclosed comment"", text [ i : unclosed_end ] )",False,text[end - 2:end] == '#}',"text[end] == ""<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.6616141200065613
|
||
|
2321,"def repl ( m, base_path, rel_path = None ) : <TAB> if m. group ( ""comments"" ) : <TAB> <TAB> tag = m. group ( ""comments"" ) <TAB> else : <TAB> <TAB> tag = m. group ( ""open"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> tag += RE_TAG_LINK_ATTR. sub ( <TAB> <TAB> <TAB> <TAB> lambda m2 : repl_absolute ( m2, base_path ), m. group ( ""attr"" ) <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> tag += RE_TAG_LINK_ATTR. sub ( <TAB> <TAB> <TAB> <TAB> lambda m2 : repl_relative ( m2, base_path, rel_path ), m. group ( ""attr"" ) <TAB> <TAB> <TAB> ) <TAB> <TAB> tag += m. group ( ""close"" ) <TAB> return tag",True,rel_path is None,rel_path is None,0.6548975706100464
|
||
|
2322,"def fake_query ( * args ) : <TAB> kwargs = args [ 1 ] <TAB> start_key = kwargs. get ( EXCLUSIVE_START_KEY, None ) <TAB> if start_key : <TAB> <TAB> item_idx = 0 <TAB> <TAB> for query_item in BATCH_GET_ITEMS. get ( RESPONSES ). get ( UserModel. Meta. table_name ) : <TAB> <TAB> <TAB> item_idx += 1 <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> query_items = BATCH_GET_ITEMS. get ( RESPONSES ). get ( UserModel. Meta. table_name ) [ <TAB> <TAB> <TAB> item_idx : item_idx + 1 <TAB> <TAB> ] <TAB> else : <TAB> <TAB> query_items = BATCH_GET_ITEMS. get ( RESPONSES ). get ( UserModel. Meta. table_name ) [ : 1 ] <TAB> data = { <TAB> <TAB> CAMEL_COUNT : len ( query_items ), <TAB> <TAB> ITEMS : query_items, <TAB> <TAB> SCANNED_COUNT : 2 * len ( query_items ), <TAB> <TAB> LAST_EVALUATED_KEY : query_items [ - 1 ] if len ( query_items ) else None, <TAB> } <TAB> return data",False,query_item == start_key,query_item,0.6555781364440918
|
||
|
2323,"def n_weights ( self ) : <TAB> """"""Return the number of weights (parameters) in this network."""""" <TAB> n_weights = 0 <TAB> for i, w in enumerate ( self. all_weights ) : <TAB> <TAB> n = 1 <TAB> <TAB> <TAB> <TAB> for s in w. get_shape ( ) : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> s = int ( s ) <TAB> <TAB> <TAB> except : <TAB> <TAB> <TAB> <TAB> s = 1 <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> n = n * s <TAB> <TAB> n_weights = n_weights + n <TAB> <TAB> return n_weights",True,s,s,0.6920080184936523
|
||
|
2324,"def calculate ( self ) : <TAB> addr_space = utils. load_as ( self. _config ) <TAB> regapi = registryapi. RegistryApi ( self. _config ) <TAB> regapi. reset_current ( ) <TAB> version = ( <TAB> <TAB> addr_space. profile. metadata. get ( ""major"", 0 ), <TAB> <TAB> addr_space. profile. metadata. get ( ""minor"", 0 ), <TAB> ) <TAB> for value, data_raw in regapi. reg_yield_values ( <TAB> <TAB> ""security"", ""Policy\\PolAdtEv"", thetype = ""REG_NONE"" <TAB> ) : <TAB> <TAB> bufferas = addrspace. BufferAddressSpace ( self. _config, data = data_raw ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> ap = obj. Object ( ""AuditPolDataXP"", offset = 0, vm = bufferas ) <TAB> <TAB> elif version <= ( 6, 0 ) : <TAB> <TAB> <TAB> ap = obj. Object ( ""AuditPolDataVista"", offset = 0, vm = bufferas ) <TAB> <TAB> elif version == ( 6, 1 ) : <TAB> <TAB> <TAB> ap = obj. Object ( ""AuditPolData7"", offset = 0, vm = bufferas ) <TAB> <TAB> elif version == ( 6, 2 ) or version == ( 6, 3 ) : <TAB> <TAB> <TAB> ap = obj. Object ( ""AuditPolData8"", offset = 0, vm = bufferas ) <TAB> <TAB> else : <TAB> <TAB> <TAB> ap = obj. Object ( ""AuditPolData10"", offset = 0, vm = bufferas ) <TAB> <TAB> if ap == None : <TAB> <TAB> <TAB> debug. error ( ""No AuditPol data found"" ) <TAB> <TAB> yield data_raw, ap",False,"version <= (5, 1)","version == (6, 0)",0.654232382774353
|
||
|
2325,"def cdn_ip ( address ) : <TAB> if not address : <TAB> <TAB> return False <TAB> try : <TAB> <TAB> _ = addr_to_int ( address ) <TAB> <TAB> for prefix, mask in CDN_RANGES. get ( address. split ( ""."" ) [ 0 ], { } ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return True <TAB> except ( IndexError, ValueError ) : <TAB> <TAB> pass <TAB> return False",False,_ & mask == prefix,mask.find(prefix) >= 0,0.6695114374160767
|
||
|
2326,"def start ( self ) : <TAB> self. on_config_change ( ) <TAB> self. start_config_watch ( ) <TAB> try : <TAB> <TAB> if self. config [ ""MITMf"" ] [ ""DNS"" ] [ ""tcp"" ]. lower ( ) == ""on"" : <TAB> <TAB> <TAB> self. startTCP ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. startUDP ( ) <TAB> except socket. error as e : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> shutdown ( <TAB> <TAB> <TAB> <TAB> ""\n[DNS] Unable to start DNS server on port {}: port already in use"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> self. config [ ""MITMf"" ] [ ""DNS"" ] [ ""port"" ] <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> )",False,'Address already in use' in e,e.args[0] in [TAB > 0,0.6601972579956055
|
||
|
2327,"def find_volume_by_name ( <TAB> volume_name : str, <TAB> not_found_msg : Optional [ str ] = None, <TAB> found_several_msg : Optional [ str ] = None, <TAB> parent = None, ) -> Optional [ str ] : <TAB> from thonny. languages import tr <TAB> <TAB> if not_found_msg is None : <TAB> <TAB> not_found_msg = tr ( <TAB> <TAB> <TAB> ""Could not find disk '%s'. Do you want to locate it yourself?"" <TAB> <TAB> ) <TAB> if found_several_msg is None : <TAB> <TAB> found_several_msg = tr ( <TAB> <TAB> <TAB> ""Found several '%s' disks. Do you want to choose one yourself?"" <TAB> <TAB> ) <TAB> volumes = find_volumes_by_name ( volume_name ) <TAB> if len ( volumes ) == 1 : <TAB> <TAB> return volumes [ 0 ] <TAB> else : <TAB> <TAB> if len ( volumes ) == 0 : <TAB> <TAB> <TAB> msg = not_found_msg % volume_name <TAB> <TAB> else : <TAB> <TAB> <TAB> msg = found_several_msg % volume_name <TAB> <TAB> import tkinter as tk <TAB> <TAB> from tkinter. messagebox import askyesno <TAB> <TAB> from thonny. ui_utils import askdirectory <TAB> <TAB> if askyesno ( tr ( ""Can't find suitable disk"" ), msg, master = parent ) : <TAB> <TAB> <TAB> path = askdirectory ( parent = parent ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return path <TAB> return None",False,path,len(path) > 0,0.6868901252746582
|
||
|
2328,"def __init__ ( self, height = 20, width = 20, density = 0.8, minority_pc = 0.2, homophily = 3 ) : <TAB> """""" """""" <TAB> self. height = height <TAB> self. width = width <TAB> self. density = density <TAB> self. minority_pc = minority_pc <TAB> self. homophily = homophily <TAB> self. schedule = RandomActivation ( self ) <TAB> self. grid = SingleGrid ( height, width, torus = True ) <TAB> self. happy = 0 <TAB> self. datacollector = DataCollector ( <TAB> <TAB> { ""happy"" : ""happy"" }, <TAB> <TAB> <TAB> <TAB> { ""x"" : lambda a : a. pos [ 0 ], ""y"" : lambda a : a. pos [ 1 ] }, <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> for cell in self. grid. coord_iter ( ) : <TAB> <TAB> x = cell [ 1 ] <TAB> <TAB> y = cell [ 2 ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if self. random. random ( ) < self. minority_pc : <TAB> <TAB> <TAB> <TAB> agent_type = 1 <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> agent_type = 0 <TAB> <TAB> <TAB> agent = SchellingAgent ( ( x, y ), self, agent_type ) <TAB> <TAB> <TAB> self. grid. position_agent ( agent, ( x, y ) ) <TAB> <TAB> <TAB> self. schedule. add ( agent ) <TAB> self. running = True <TAB> self. datacollector. collect ( self )",False,self.random.random() < self.density,self.has_agent,0.6485270261764526
|
||
|
2329,"def cache_cable_devices ( apps, schema_editor ) : <TAB> Cable = apps. get_model ( ""dcim"", ""Cable"" ) <TAB> if ""test"" not in sys. argv : <TAB> <TAB> print ( ""\nUpdating cable device terminations..."" ) <TAB> cable_count = Cable. objects. count ( ) <TAB> <TAB> <TAB> for i, cable in enumerate ( Cable. objects. all ( ), start = 1 ) : <TAB> <TAB> if not i % 1000 and ""test"" not in sys. argv : <TAB> <TAB> <TAB> print ( ""[{}/{}]"". format ( i, cable_count ) ) <TAB> <TAB> termination_a_model = apps. get_model ( <TAB> <TAB> <TAB> cable. termination_a_type. app_label, cable. termination_a_type. model <TAB> <TAB> ) <TAB> <TAB> termination_a_device = None <TAB> <TAB> if hasattr ( termination_a_model, ""device"" ) : <TAB> <TAB> <TAB> termination_a = termination_a_model. objects. get ( pk = cable. termination_a_id ) <TAB> <TAB> <TAB> termination_a_device = termination_a. device <TAB> <TAB> termination_b_model = apps. get_model ( <TAB> <TAB> <TAB> cable. termination_b_type. app_label, cable. termination_b_type. model <TAB> <TAB> ) <TAB> <TAB> termination_b_device = None <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> termination_b = termination_b_model. objects. get ( pk = cable. termination_b_id ) <TAB> <TAB> <TAB> termination_b_device = termination_b. device <TAB> <TAB> Cable. objects. filter ( pk = cable. pk ). update ( <TAB> <TAB> <TAB> _termination_a_device = termination_a_device, <TAB> <TAB> <TAB> _termination_b_device = termination_b_device, <TAB",True,"hasattr(termination_b_model, 'device')","hasattr(termination_b_model, 'device')",0.6443324685096741
|
||
|
2330,"def reduce_uri ( self, uri, default_port = True ) : <TAB> """"""Accept authority or URI and extract only the authority and path."""""" <TAB> <TAB> parts = urlparse. urlsplit ( uri ) <TAB> if parts [ 1 ] : <TAB> <TAB> <TAB> <TAB> scheme = parts [ 0 ] <TAB> <TAB> authority = parts [ 1 ] <TAB> <TAB> path = parts [ 2 ] or ""/"" <TAB> else : <TAB> <TAB> <TAB> <TAB> scheme = None <TAB> <TAB> authority = uri <TAB> <TAB> path = ""/"" <TAB> host, port = splitport ( authority ) <TAB> if default_port and port is None and scheme is not None : <TAB> <TAB> dport = { <TAB> <TAB> <TAB> ""http"" : 80, <TAB> <TAB> <TAB> ""https"" : 443, <TAB> <TAB> }. get ( scheme ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> authority = ""%s:%d"" % ( host, dport ) <TAB> return authority, path",False,dport is not None,dport,0.6581437587738037
|
||
|
2331,"def read_config ( args, parser ) : <TAB> """"""Read both user configuration and local configuration."""""" <TAB> config = SafeConfigParser ( ) <TAB> try : <TAB> <TAB> config. read ( args. global_config ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> parent = tail = args. files and os. path. abspath ( <TAB> <TAB> <TAB> <TAB> os. path. commonprefix ( args. files ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> while tail : <TAB> <TAB> <TAB> <TAB> if config. read ( [ os. path. join ( parent, fn ) for fn in PROJECT_CONFIG ] ) : <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> ( parent, tail ) = os. path. split ( parent ) <TAB> <TAB> defaults = { } <TAB> <TAB> option_list = { o. dest : o. type or type ( o. default ) for o in parser. _actions } <TAB> <TAB> for section in [ ""pep8"", ""pycodestyle"", ""flake8"" ] : <TAB> <TAB> <TAB> if not config. has_section ( section ) : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> for norm_opt, k, value in _get_normalize_options ( <TAB> <TAB> <TAB> <TAB> config, section, option_list <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> if args. verbose : <TAB> <TAB> <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""enable config: section={}, key={}, value={}"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> section, k, value <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> defaults [ norm_opt",False,not args.ignore_local_config,args.files,0.6543875932693481
|
||
|
2332,"def find_distribution_modules ( name = __name__, file = __file__ ) : <TAB> current_dist_depth = len ( name. split ( ""."" ) ) - 1 <TAB> current_dist = os. path. join ( <TAB> <TAB> os. path. dirname ( file ), * ( [ os. pardir ] * current_dist_depth ) <TAB> ) <TAB> abs = os. path. abspath ( current_dist ) <TAB> dist_name = os. path. basename ( abs ) <TAB> for dirpath, dirnames, filenames in os. walk ( abs ) : <TAB> <TAB> package = ( dist_name + dirpath [ len ( abs ) : ] ). replace ( ""/"", ""."" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> yield package <TAB> <TAB> <TAB> for filename in filenames : <TAB> <TAB> <TAB> <TAB> if filename. endswith ( "".py"" ) and filename!= ""__init__.py"" : <TAB> <TAB> <TAB> <TAB> <TAB> yield ""."". join ( [ package, filename ] ) [ : - 3 ]",False,'__init__.py' in filenames,len(filenames) > 0,0.6513705253601074
|
||
|
2333,"def main ( docs_dir, outfile ) : <TAB> keys = { } <TAB> for fname in os. listdir ( docs_dir ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> logging. warning ( ""Ignored path: %s"", fname ) <TAB> <TAB> <TAB> continue <TAB> <TAB> keywords = index_file ( os. path. join ( docs_dir, fname ) ) <TAB> <TAB> for kwrd in keywords : <TAB> <TAB> <TAB> if kwrd not in keys : <TAB> <TAB> <TAB> <TAB> keys [ kwrd ] = set ( ) <TAB> <TAB> <TAB> keys [ kwrd ]. add ( fname ) <TAB> with open ( outfile ) as fhr : <TAB> <TAB> items = [ ] <TAB> <TAB> for kwrd in sorted ( keys. keys ( ) ) : <TAB> <TAB> <TAB> pages = "", "". join ( <TAB> <TAB> <TAB> <TAB> [ <TAB> <TAB> <TAB> <TAB> <TAB> ""[%s](%s)"" % ( x. replace ( "".md"", """" ), x. replace ( "".md"", """" ) ) <TAB> <TAB> <TAB> <TAB> <TAB> for x in sorted ( keys [ kwrd ] ) <TAB> <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> items. append ( ""* `%s`: %s"" % ( kwrd, pages ) ) <TAB> <TAB> text = fhr. read ( ) + ""\n"". join ( items ) <TAB> with open ( outfile, ""wt"" ) as fhw : <TAB> <TAB> fhw. write ( text )",False,not fname.endswith('.md') or fname == 'YAMLTutorial.md',not os.path.isfile(fname),0.6517249345779419
|
||
|
2334,"def wrapper ( * args, ** kwargs ) : <TAB> start = time. time ( ) <TAB> try : <TAB> <TAB> return f ( * args, ** kwargs ) <TAB> finally : <TAB> <TAB> timing = ( time. time ( ) - start ) * 1000.0 <TAB> <TAB> func = fqfn ( f ) <TAB> <TAB> lt = logtarget <TAB> <TAB> if expand_logtarget : <TAB> <TAB> <TAB> lt += ""."" + func <TAB> <TAB> logger = logging. getLogger ( lt ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> data = { ""func"" : func, ""timing"" : timing } <TAB> <TAB> <TAB> if incl_func_args : <TAB> <TAB> <TAB> <TAB> data. update ( <TAB> <TAB> <TAB> <TAB> <TAB> func_args = "","". join ( map ( repr, args ) ), <TAB> <TAB> <TAB> <TAB> <TAB> func_kwargs = "","". join ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> map ( lambda x : ""{}={!r}"". format ( x [ 0 ], x [ 1 ] ), kwargs. items ( ) ) <TAB> <TAB> <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> logger. debug ( message. format ( ** data ), extra = data )",False,logger.isEnabledFor(logging.DEBUG),logger is not None,0.6503386497497559
|
||
|
2335,"def serialize_config ( self, session, key, tid, language ) : <TAB> cache_key = gen_cache_key ( key, tid, language ) <TAB> cache_obj = None <TAB> if cache_key not in self. cache : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> cache_obj = db_admin_serialize_node ( session, tid, language ) <TAB> <TAB> elif key == ""notification"" : <TAB> <TAB> <TAB> cache_obj = db_get_notification ( session, tid, language ) <TAB> <TAB> self. cache [ cache_key ] = cache_obj <TAB> return self. cache [ cache_key ]",False,key == 'node',key == 'admin',0.662927508354187
|
||
|
2336,"def parse_search_response ( json_data ) : <TAB> """"""Construct response for any input"""""" <TAB> if json_data is None : <TAB> <TAB> return { ""error"" : ""Error parsing empty search engine response"" } <TAB> try : <TAB> <TAB> return json. loads ( json_data ) <TAB> except json. JSONDecodeError : <TAB> <TAB> logger. exception ( ""Error parsing search engine response"" ) <TAB> <TAB> m = re_pre. search ( json_data ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return { ""error"" : ""Error parsing search engine response"" } <TAB> <TAB> error = web. htmlunquote ( m. group ( 1 ) ) <TAB> <TAB> solr_error = ""org.apache.lucene.queryParser.ParseException: "" <TAB> <TAB> if error. startswith ( solr_error ) : <TAB> <TAB> <TAB> error = error [ len ( solr_error ) : ] <TAB> <TAB> return { ""error"" : error }",True,m is None,m is None,0.6705228090286255
|
||
|
2337,"def _render_xlsx ( self, form_data, output_file = None ) : <TAB> wb = Workbook ( write_only = True ) <TAB> n_sheets = len ( self. sheets ) <TAB> for i_sheet, ( s, l ) in enumerate ( self. sheets ) : <TAB> <TAB> ws = wb. create_sheet ( str ( l ) ) <TAB> <TAB> total = 0 <TAB> <TAB> counter = 0 <TAB> <TAB> for i, line in enumerate ( self. iterate_sheet ( form_data, sheet = s ) ) : <TAB> <TAB> <TAB> if isinstance ( line, self. ProgressSetTotal ) : <TAB> <TAB> <TAB> <TAB> total = line. total <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> ws. append ( <TAB> <TAB> <TAB> <TAB> [ str ( val ) if not isinstance ( val, KNOWN_TYPES ) else val for val in line ] <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> counter += 1 <TAB> <TAB> <TAB> <TAB> if counter % max ( 10, total // 100 ) == 0 : <TAB> <TAB> <TAB> <TAB> <TAB> self. progress_callback ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> counter / total * 100 / n_sheets + 100 / n_sheets * i_sheet <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> if output_file : <TAB> <TAB> wb. save ( output_file ) <TAB> <TAB> return ( <TAB> <TAB> <TAB> self. get_filename ( ) + "".xlsx"", <TAB> <TAB> <TAB> ""application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"", <TAB> <TAB> <TAB> None, <TAB> <TAB> ) <TAB> else : <TAB> <TAB> with tempfile. NamedTemporaryFile ( suffix = "".xlsx"" ) as f : <TAB> <TAB> <TAB> wb. save",True,total,total,0.6983985900878906
|
||
|
2338,"def recvcb_actions ( self, l ) : <TAB> if l. startswith ( ""!!"" ) : <TAB> <TAB> self. do_pause ( None ) <TAB> <TAB> msg = l. split ( "" "", 1 ) <TAB> <TAB> if len ( msg ) > 1 and self. silent is False : <TAB> <TAB> <TAB> self. logError ( msg [ 1 ]. ljust ( 15 ) ) <TAB> <TAB> sys. stdout. write ( self. promptf ( ) ) <TAB> <TAB> sys. stdout. flush ( ) <TAB> <TAB> return True <TAB> elif l. startswith ( ""//"" ) : <TAB> <TAB> command = l. split ( "" "", 1 ) <TAB> <TAB> if len ( command ) > 1 : <TAB> <TAB> <TAB> command = command [ 1 ] <TAB> <TAB> <TAB> self. log ( _ ( ""Received command %s"" ) % command ) <TAB> <TAB> <TAB> command = command. split ( "":"" ) <TAB> <TAB> <TAB> if len ( command ) == 2 and command [ 0 ] == ""action"" : <TAB> <TAB> <TAB> <TAB> command = command [ 1 ] <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> self. do_pause ( None ) <TAB> <TAB> <TAB> <TAB> <TAB> sys. stdout. write ( self. promptf ( ) ) <TAB> <TAB> <TAB> <TAB> <TAB> sys. stdout. flush ( ) <TAB> <TAB> <TAB> <TAB> <TAB> return True <TAB> <TAB> <TAB> <TAB> elif command == ""resume"" : <TAB> <TAB> <TAB> <TAB> <TAB> self. do_resume ( None ) <TAB> <TAB> <TAB> <TAB> <TAB> sys. stdout. write ( self. promptf ( ) ) <TAB> <TAB> <TAB> <TAB> <TAB> sys. stdout. flush ( ) <TAB> <TAB> <TAB> <TAB> <TAB> return True <TAB> <TAB> <TAB> <TAB> elif command ==",True,command == 'pause',command == 'pause',0.6651689410209656
|
||
|
2339,"def __contains__ ( self, item ) : <TAB> if isinstance ( item, Distribution ) : <TAB> <TAB> if item. key!= self. key : <TAB> <TAB> <TAB> return False <TAB> <TAB> if self. index : <TAB> <TAB> <TAB> item = item. parsed_version <TAB> elif isinstance ( item, basestring ) : <TAB> <TAB> item = parse_version ( item ) <TAB> last = None <TAB> for parsed, trans, op, ver in self. index : <TAB> <TAB> action = trans [ cmp ( item, parsed ) ] <TAB> <TAB> if action == ""F"" : <TAB> <TAB> <TAB> return False <TAB> <TAB> elif action == ""T"" : <TAB> <TAB> <TAB> return True <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> last = True <TAB> <TAB> elif action == ""-"" or last is None : <TAB> <TAB> <TAB> last = False <TAB> if last is None : <TAB> <TAB> last = True <TAB> return last",False,action == '+',action == 'o',0.7027027606964111
|
||
|
2340,"def limit_rate ( self, response : Response ) -> Optional [ float ] : <TAB> next_check = None <TAB> retry_after = response. headers. get ( ""Retry-After"" ) <TAB> if retry_after : <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> delay = float ( retry_after ) <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> until = parsedate_to_datetime ( retry_after ) <TAB> <TAB> <TAB> except ( TypeError, ValueError ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> next_check = datetime. timestamp ( until ) <TAB> <TAB> <TAB> <TAB> delay = ( until - datetime. now ( timezone. utc ) ). total_seconds ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> next_check = time. time ( ) + delay <TAB> netloc = urlparse ( response. url ). netloc <TAB> if next_check is None : <TAB> <TAB> max_delay = self. config. linkcheck_rate_limit_timeout <TAB> <TAB> try : <TAB> <TAB> <TAB> rate_limit = self. rate_limits [ netloc ] <TAB> <TAB> except KeyError : <TAB> <TAB> <TAB> delay = DEFAULT_DELAY <TAB> <TAB> else : <TAB> <TAB> <TAB> last_wait_time = rate_limit. delay <TAB> <TAB> <TAB> delay = 2.0 * last_wait_time <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> delay = max_delay <TAB> <TAB> if delay > max_delay : <TAB> <TAB> <TAB> return None <TAB> <TAB> next_check = time. time ( ) + delay <TAB> self. rate",False,delay > max_delay and last_wait_time < max_delay,delay > 0.0,0.653852105140686
|
||
|
2341,"def _get_x_for_y ( self, xValue, x, y ) : <TAB> <TAB> x_value = str ( xValue ) <TAB> for anime in self. xmlMap. findall ( ""anime"" ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return int ( anime. get ( y, 0 ) ) <TAB> <TAB> except ValueError as e : <TAB> <TAB> <TAB> continue <TAB> return 0",False,"anime.get(x, False) == x_value","anime.get(x_value, 0) == x_value",0.6519744396209717
|
||
|
2342,"def metadata ( environ, start_response ) : <TAB> try : <TAB> <TAB> path = args. path <TAB> <TAB> if path is None or len ( path ) == 0 : <TAB> <TAB> <TAB> path = os. path. dirname ( os. path. abspath ( __file__ ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> path += ""/"" <TAB> <TAB> metadata = create_metadata_string ( <TAB> <TAB> <TAB> path + args. config, <TAB> <TAB> <TAB> IDP. config, <TAB> <TAB> <TAB> args. valid, <TAB> <TAB> <TAB> args. cert, <TAB> <TAB> <TAB> args. keyfile, <TAB> <TAB> <TAB> args. id, <TAB> <TAB> <TAB> args. name, <TAB> <TAB> <TAB> args. sign, <TAB> <TAB> ) <TAB> <TAB> start_response ( ""200 OK"", [ ( ""Content-Type"", ""text/xml"" ) ] ) <TAB> <TAB> return metadata <TAB> except Exception as ex : <TAB> <TAB> logger. error ( ""An error occured while creating metadata:"", ex. message ) <TAB> <TAB> return not_found ( environ, start_response )",True,path[-1] != '/',path[-1] != '/',0.6730730533599854
|
||
|
2343,"def set_caller_information ( doc, state ) : <TAB> """"""Called from hooks on creation of Lead or Contact"""""" <TAB> if doc. doctype not in [ ""Lead"", ""Contact"" ] : <TAB> <TAB> return <TAB> numbers = [ doc. get ( ""phone"" ), doc. get ( ""mobile_no"" ) ] <TAB> <TAB> fieldname = doc. doctype. lower ( ) <TAB> <TAB> display_name_field = ""{}_name"". format ( fieldname ) <TAB> <TAB> if doc. doctype == ""Contact"" : <TAB> <TAB> numbers = [ d. phone for d in doc. phone_nos ] <TAB> for number in numbers : <TAB> <TAB> number = strip_number ( number ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> filters = frappe. _dict ( { ""from"" : [ ""like"", ""%{}"". format ( number ) ], fieldname : """" } ) <TAB> <TAB> logs = frappe. get_all ( ""Call Log"", filters = filters ) <TAB> <TAB> for log in logs : <TAB> <TAB> <TAB> frappe. db. set_value ( <TAB> <TAB> <TAB> <TAB> ""Call Log"", <TAB> <TAB> <TAB> <TAB> log. name, <TAB> <TAB> <TAB> <TAB> { fieldname : doc. name, display_name_field : doc. get_title ( ) }, <TAB> <TAB> <TAB> <TAB> update_modified = False, <TAB> <TAB> <TAB> )",False,not number,number is None,0.6707401275634766
|
||
|
2344,"def _roll_random ( n ) : <TAB> """"""returns a random # from 0 to N-1"""""" <TAB> bits = util. bit_length ( n - 1 ) <TAB> byte_count = ( bits + 7 ) // 8 <TAB> hbyte_mask = pow ( 2, bits % 8 ) - 1 <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> while True : <TAB> <TAB> x = os. urandom ( byte_count ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> x = byte_mask ( x [ 0 ], hbyte_mask ) + x [ 1 : ] <TAB> <TAB> num = util. inflate_long ( x, 1 ) <TAB> <TAB> if num < n : <TAB> <TAB> <TAB> break <TAB> return num",False,hbyte_mask > 0,len(x) > 0,0.6614553928375244
|
||
|
2345,"def OutputString ( self, attrs = None ) : <TAB> <TAB> <TAB> result = [ ] <TAB> append = result. append <TAB> <TAB> append ( ""%s=%s"" % ( self. key, self. coded_value ) ) <TAB> <TAB> if attrs is None : <TAB> <TAB> attrs = self. _reserved <TAB> items = sorted ( self. items ( ) ) <TAB> for key, value in items : <TAB> <TAB> if value == """" : <TAB> <TAB> <TAB> continue <TAB> <TAB> if key not in attrs : <TAB> <TAB> <TAB> continue <TAB> <TAB> if key == ""expires"" and isinstance ( value, int ) : <TAB> <TAB> <TAB> append ( ""%s=%s"" % ( self. _reserved [ key ], _getdate ( value ) ) ) <TAB> <TAB> elif key == ""max-age"" and isinstance ( value, int ) : <TAB> <TAB> <TAB> append ( ""%s=%d"" % ( self. _reserved [ key ], value ) ) <TAB> <TAB> elif key == ""secure"" : <TAB> <TAB> <TAB> append ( str ( self. _reserved [ key ] ) ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> append ( str ( self. _reserved [ key ] ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> append ( ""%s=%s"" % ( self. _reserved [ key ], value ) ) <TAB> <TAB> return _semispacejoin ( result )",False,key == 'httponly',key == 'domain',0.657065212726593
|
||
|
2346,"def raffle_notify ( self, func, value, id = None ) : <TAB> await asyncio. sleep ( 0 ) <TAB> if id is None : <TAB> <TAB> list_tasks = [ ] <TAB> <TAB> for i, user in enumerate ( self. _observers ) : <TAB> <TAB> <TAB> if self. check_status ( func, i ) : <TAB> <TAB> <TAB> <TAB> task = asyncio. ensure_future ( user. update ( func, value ) ) <TAB> <TAB> <TAB> <TAB> list_tasks. append ( task ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> await asyncio. wait ( list_tasks, return_when = asyncio. ALL_COMPLETED ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> list_tasks = [ ] <TAB> <TAB> if list_tasks : <TAB> <TAB> <TAB> await asyncio. wait ( list_tasks, return_when = asyncio. ALL_COMPLETED ) <TAB> elif id >= 0 : <TAB> <TAB> user = self. _observers [ id ] <TAB> <TAB> if self. check_status ( func, id ) : <TAB> <TAB> <TAB> asyncio. ensure_future ( user. update ( func, value ) ) <TAB> else : <TAB> <TAB> user = self. _var_super_user <TAB> <TAB> answer = await user. update ( func, value ) <TAB> <TAB> return answer",False,not (i + 1) % 100,list_tasks,0.659375786781311
|
||
|
2347,"def print_po_snippet ( en_loc_old_lists, context ) : <TAB> for m, localized, old in zip ( * en_loc_old_lists ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> if m == localized : <TAB> <TAB> <TAB> localized = old <TAB> <TAB> print ( <TAB> <TAB> <TAB> ""#: {file}:{line}\n"" <TAB> <TAB> <TAB>'msgid ""{context}{en_month}""\n' <TAB> <TAB> <TAB>'msgstr ""{localized_month}""\n'. format ( <TAB> <TAB> <TAB> <TAB> context = context, <TAB> <TAB> <TAB> <TAB> file = filename, <TAB> <TAB> <TAB> <TAB> line = print_po_snippet. line, <TAB> <TAB> <TAB> <TAB> en_month = m, <TAB> <TAB> <TAB> <TAB> localized_month = localized, <TAB> <TAB> <TAB> ) <TAB> <TAB> ) <TAB> <TAB> print_po_snippet. line += 1",False,m == '',m == None,0.6893705129623413
|
||
|
2348,"def topology_change_notify ( self, port_state ) : <TAB> notice = False <TAB> if port_state is PORT_STATE_FORWARD : <TAB> <TAB> for port in self. ports. values ( ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> notice = True <TAB> <TAB> <TAB> <TAB> break <TAB> else : <TAB> <TAB> notice = True <TAB> if notice : <TAB> <TAB> self. send_event ( EventTopologyChange ( self. dp ) ) <TAB> <TAB> if self. is_root_bridge : <TAB> <TAB> <TAB> self. _transmit_tc_bpdu ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. _transmit_tcn_bpdu ( )",False,port.role is DESIGNATED_PORT,port in self.ports,0.6570047736167908
|
||
|
2349,"def _internal_tell_not_asked ( self, candidate : p. Parameter, loss : tp. FloatLoss ) -> None : <TAB> discardable : tp. Optional [ str ] = None <TAB> if len ( self. population ) >= self. llambda : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> uid, worst = max ( self. population. items ( ), key = lambda p : base. _loss ( p [ 1 ] ) ) <TAB> <TAB> <TAB> if loss < base. _loss ( worst ) : <TAB> <TAB> <TAB> <TAB> discardable = uid <TAB> <TAB> else : <TAB> <TAB> <TAB> pareto_uids = { c. uid for c in self. pareto_front ( ) } <TAB> <TAB> <TAB> if candidate. uid in pareto_uids : <TAB> <TAB> <TAB> <TAB> non_pareto_pop = { c. uid for c in self. population. values ( ) } - pareto_uids <TAB> <TAB> <TAB> <TAB> if non_pareto_pop : <TAB> <TAB> <TAB> <TAB> <TAB> nonpareto = { c. uid : c for c in self. population. values ( ) } [ <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> list ( non_pareto_pop ) [ 0 ] <TAB> <TAB> <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> <TAB> <TAB> discardable = nonpareto. heritage [ ""lineage"" ] <TAB> if discardable is not None : <TAB> <TAB> del self. population [ discardable ] <TAB> <TAB> self. _uid_queue. discard ( discardable ) <TAB> if len ( self. population ) < self. llambda : <TAB> <TAB> self. population [ candidate. uid ] = candidate <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _uid_queue. tell ( candidate. uid )",False,self.num_objectives == 1,len(self.population) == 1,0.6569133996963501
|
||
|
2350,"def get_cycle_path ( self, curr_node, goal_node_index ) : <TAB> for dep in curr_node [ ""deps"" ] : <TAB> <TAB> if dep == goal_node_index : <TAB> <TAB> <TAB> return [ curr_node [ ""address"" ] ] <TAB> for dep in curr_node [ ""deps"" ] : <TAB> <TAB> path = self. get_cycle_path ( <TAB> <TAB> <TAB> self. get_by_address ( dep ), goal_node_index <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> path. insert ( 0, curr_node [ ""address"" ] ) <TAB> <TAB> <TAB> return path <TAB> return [ ]",False,len(path) > 0,path,0.655383825302124
|
||
|
2351,"def save_plugin_options ( self ) : <TAB> for name, option_widgets in self. _plugin_option_widgets. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. config [ ""plugins"" ] [ name ] = { } <TAB> <TAB> plugin_config = self. config [ ""plugins"" ] [ <TAB> <TAB> <TAB> name <TAB> <TAB> ] <TAB> <TAB> for option_name, option_widget in option_widgets. items ( ) : <TAB> <TAB> <TAB> plugin_config [ option_name ] = option_widget. option. get_widget_value ( <TAB> <TAB> <TAB> <TAB> option_widget. widget <TAB> <TAB> <TAB> )",False,name not in self.config['plugins'],"name not in self.config[""plugins']",0.6581972241401672
|
||
|
2352,"def __init__ ( self, sources, sinks, effect ) : <TAB> self. effect = OrderedDict ( ) <TAB> <TAB> <TAB> <TAB> for lvalue, rvalue in re. findall ( ""(.*?)=([^=]*)(?:,|$)"", effect ) : <TAB> <TAB> sink = lvalue. strip ( ) <TAB> <TAB> if sink not in sinks : <TAB> <TAB> <TAB> raise SpaParseError ( <TAB> <TAB> <TAB> <TAB> ""Left-hand module '%s' from effect '%s=%s' "" <TAB> <TAB> <TAB> <TAB> ""is not defined."" % ( lvalue, lvalue, rvalue ) <TAB> <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise SpaParseError ( <TAB> <TAB> <TAB> <TAB> ""Left-hand module '%s' from effect '%s=%s' "" <TAB> <TAB> <TAB> <TAB> ""is assigned to multiple times in '%s'."" <TAB> <TAB> <TAB> <TAB> % ( lvalue, lvalue, rvalue, effect ) <TAB> <TAB> <TAB> ) <TAB> <TAB> self. effect [ sink ] = Expression ( sources, rvalue )",False,sink in self.effect,lvalue != lvalue or rvalue != lvalue,0.6681115031242371
|
||
|
2353,"def _upload_file_aws_cli ( local_fname, bucket, keyname, config = None, mditems = None ) : <TAB> """"""Streaming upload via the standard AWS command line interface."""""" <TAB> s3_fname = ""s3://%s/%s"" % ( bucket, keyname ) <TAB> args = [ ""--sse"", ""--expected-size"", str ( os. path. getsize ( local_fname ) ) ] <TAB> if config : <TAB> <TAB> if config. get ( ""region"" ) : <TAB> <TAB> <TAB> args += [ ""--region"", config. get ( ""region"" ) ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> args += [ ""--storage-class"", ""REDUCED_REDUNDANCY"" ] <TAB> cmd = ( <TAB> <TAB> [ os. path. join ( os. path. dirname ( sys. executable ), ""aws"" ), ""s3"", ""cp"" ] <TAB> <TAB> + args <TAB> <TAB> + [ local_fname, s3_fname ] <TAB> ) <TAB> do. run ( cmd, ""Upload to s3: %s %s"" % ( bucket, keyname ) )",False,config.get('reduced_redundancy'),mditems,0.6555967330932617
|
||
|
2354,"def _known_types ( self, config ) : <TAB> msg = ( <TAB> <TAB> ""The config entry %r in section %r is of type %r, "" <TAB> <TAB> ""which does not match the expected type %r."" <TAB> ) <TAB> for section, conf in config. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> for k, v in conf. items ( ) : <TAB> <TAB> <TAB> <TAB> if v is not None : <TAB> <TAB> <TAB> <TAB> <TAB> expected_type = self. known_config_types. get ( k, None ) <TAB> <TAB> <TAB> <TAB> <TAB> vtype = type ( v ) <TAB> <TAB> <TAB> <TAB> <TAB> if expected_type and vtype!= expected_type : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> warnings. warn ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> msg % ( k, section, vtype. __name__, expected_type. __name__ ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> k, v = section, conf <TAB> <TAB> <TAB> if v is not None : <TAB> <TAB> <TAB> <TAB> expected_type = self. known_config_types. get ( k, None ) <TAB> <TAB> <TAB> <TAB> vtype = type ( v ) <TAB> <TAB> <TAB> <TAB> if expected_type and vtype!= expected_type : <TAB> <TAB> <TAB> <TAB> <TAB> warnings. warn ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> msg % ( k, section, vtype. __name__, expected_type. __name__ ) <TAB> <TAB> <TAB> <TAB> <TAB> )",False,"isinstance(conf, dict)",conf is not None,0.6516681909561157
|
||
|
2355,"def set_values ( self, vals ) : <TAB> vals = np. array ( vals ) <TAB> if vals. ndim == 0 : <TAB> <TAB> self. values = np. ones ( self. n_points ) * vals <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""Values should be a scalar or a 1D ndarray of the grid size."" <TAB> <TAB> <TAB> ) <TAB> <TAB> self. values = vals",False,"vals.shape != (self.n_points,)",not np.isscalar(vals),0.6555777192115784
|
||
|
2356,"def test_run_read_write ( self, mock_writer, mock_select, mock_read ) : <TAB> mock_select. side_effect = [ ( [ self. in_fd ], [ ], [ ] ), ( [ self. in_fd ], [ ], [ ] ) ] <TAB> mock_read. side_effect = [ b""A"" * 300, b"""" ] <TAB> <TAB> inc = 0 <TAB> with self. writer. running ( ) : <TAB> <TAB> while self. writer. is_alive ( ) : <TAB> <TAB> <TAB> time. sleep ( 0.01 ) <TAB> <TAB> <TAB> inc += 1 <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise Exception ( ""waited too long."" ) <TAB> self. assertFalse ( self. writer. is_alive ( ) ) <TAB> mock_read. assert_called_with ( - 1, io. DEFAULT_BUFFER_SIZE ) <TAB> self. assertEqual ( mock_read. call_count, 2 ) <TAB> mock_writer. assert_has_calls ( <TAB> <TAB> [ <TAB> <TAB> <TAB> unittest. mock. call ( unittest. mock. ANY, ChunkType. STDIN, b""A"" * 300 ), <TAB> <TAB> <TAB> unittest. mock. call ( unittest. mock. ANY, ChunkType. STDIN_EOF ), <TAB> <TAB> ] <TAB> )",False,inc >= 1000,inc > self.wait_size,0.683684766292572
|
||
|
2357,"def add_msg_info ( self, mid, msg_info, full_threads = False, idxs = None ) : <TAB> <TAB> self [ ""data"" ] [ ""metadata"" ] [ mid ] = self. _metadata ( msg_info ) <TAB> <TAB> thread_mid = parent_mid = msg_info [ MailIndex. MSG_THREAD_MID ] <TAB> if ""/"" in thread_mid : <TAB> <TAB> thread_mid, parent_mid = thread_mid. split ( ""/"" ) <TAB> if thread_mid not in self [ ""data"" ] [ ""threads"" ] : <TAB> <TAB> thread = self. _thread ( thread_mid ) <TAB> <TAB> self [ ""data"" ] [ ""threads"" ] [ thread_mid ] = thread <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> idxs. extend ( <TAB> <TAB> <TAB> <TAB> [ <TAB> <TAB> <TAB> <TAB> <TAB> int ( t, 36 ) <TAB> <TAB> <TAB> <TAB> <TAB> for t, bar, kids in thread <TAB> <TAB> <TAB> <TAB> <TAB> if t not in self [ ""data"" ] [ ""metadata"" ] <TAB> <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> ) <TAB> <TAB> for cid in self. _msg_addresses ( msg_info ) : <TAB> <TAB> if cid not in self [ ""data"" ] [ ""addresses"" ] : <TAB> <TAB> <TAB> self [ ""data"" ] [ ""addresses"" ] [ cid ] = self. _address ( cid = cid ) <TAB> <TAB> if ""tags"" in self. session. config : <TAB> <TAB> for tid in self. _msg_tags ( msg_info ) : <TAB> <TAB> <TAB> if tid not in self [ ""data"" ] [ ""tags"" ] : <TAB> <TAB> <TAB> <TAB> self [ ""data"" ] [ ""tags"" ] [ tid ] = self. _tag ( tid, { ""searched"" : False } )",False,full_threads and idxs,full_threads,0.6638230085372925
|
||
|
2358,"def __init__ ( self, functions = None, type_definitions = None ) : <TAB> if functions is None : <TAB> <TAB> functions = { } <TAB> elif isinstance ( functions, dict ) : <TAB> <TAB> mapped_funcs = { } <TAB> <TAB> for k, v in functions. items ( ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> k = _expr. GlobalVar ( k ) <TAB> <TAB> <TAB> if not isinstance ( k, _expr. GlobalVar ) : <TAB> <TAB> <TAB> <TAB> raise TypeError ( ""Expect functions to be Dict[GlobalVar, Function]"" ) <TAB> <TAB> <TAB> mapped_funcs [ k ] = v <TAB> <TAB> functions = mapped_funcs <TAB> if type_definitions is None : <TAB> <TAB> type_definitions = { } <TAB> elif isinstance ( type_definitions, dict ) : <TAB> <TAB> mapped_type_defs = { } <TAB> <TAB> for k, v in type_definitions. items ( ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> k = _ty. GlobalTypeVar ( k ) <TAB> <TAB> <TAB> if not isinstance ( k, _ty. GlobalTypeVar ) : <TAB> <TAB> <TAB> <TAB> raise TypeError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Expect type_definitions to be Dict[GlobalTypeVar, Type]"" <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> mapped_type_defs [ k ] = v <TAB> <TAB> type_definitions = mapped_type_defs <TAB> self. __init_handle_by_constructor__ ( _ffi_api. IRModule, functions, type_definitions )",False,"isinstance(k, string_types)",k in mapped_type_defs,0.651375412940979
|
||
|
2359,"def _get_dimensions ( cls, json, props ) : <TAB> if json is None : <TAB> <TAB> return <TAB> if ""config"" in json and ""view"" in json [ ""config"" ] : <TAB> <TAB> size_config = json [ ""config"" ] [ ""view"" ] <TAB> else : <TAB> <TAB> size_config = json <TAB> view = { } <TAB> for w in ( ""width"", ""continuousWidth"" ) : <TAB> <TAB> if w in size_config : <TAB> <TAB> <TAB> view [ ""width"" ] = size_config [ w ] <TAB> for h in ( ""height"", ""continuousHeight"" ) : <TAB> <TAB> if h in size_config : <TAB> <TAB> <TAB> view [ ""height"" ] = size_config [ h ] <TAB> for p in ( ""width"", ""height"" ) : <TAB> <TAB> if p not in view or isinstance ( view [ p ], string_types ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> v = view [ p ] <TAB> <TAB> <TAB> props [ p ] = v + 22 if isinstance ( v, int ) else v <TAB> responsive_height = json. get ( ""height"" ) == ""container"" <TAB> responsive_width = json. get ( ""width"" ) == ""container"" <TAB> if responsive_height and responsive_width : <TAB> <TAB> props [ ""sizing_mode"" ] = ""stretch_both"" <TAB> elif responsive_width : <TAB> <TAB> props [ ""sizing_mode"" ] = ""stretch_width"" <TAB> elif responsive_height : <TAB> <TAB> props [ ""sizing_mode"" ] = ""stretch_height""",False,props.get(p) is None or (p in view and props.get(p) < view[p]),p in view,0.651118278503418
|
||
|
2360,"def _check_good_input ( self, X, y = None ) : <TAB> if isinstance ( X, dict ) : <TAB> <TAB> lengths = [ len ( X1 ) for X1 in X. values ( ) ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( ""Not all values of X are of equal length."" ) <TAB> <TAB> x_len = lengths [ 0 ] <TAB> else : <TAB> <TAB> x_len = len ( X ) <TAB> if y is not None : <TAB> <TAB> if len ( y )!= x_len : <TAB> <TAB> <TAB> raise ValueError ( ""X and y are not of equal length."" ) <TAB> if self. regression and y is not None and y. ndim == 1 : <TAB> <TAB> y = y. reshape ( - 1, 1 ) <TAB> return X, y",False,len(set(lengths)) > 1,len(lengths) != len(X),0.6554114818572998
|
||
|
2361,"def _path ( task, opt ) : <TAB> <TAB> build ( opt ) <TAB> suffix = """" <TAB> dt = opt [ ""datatype"" ]. split ( "":"" ) [ 0 ] <TAB> if<mask> : <TAB> <TAB> suffix = ""train"" <TAB> elif dt == ""test"" : <TAB> <TAB> suffix = ""test"" <TAB> elif dt == ""valid"" : <TAB> <TAB> suffix = ""dev"" <TAB> datafile = os. path. join ( <TAB> <TAB> opt [ ""datapath"" ], <TAB> <TAB> ""MovieDialog"", <TAB> <TAB> ""movie_dialog_dataset"", <TAB> <TAB> ""{t}{s}.txt"". format ( t = tasks [ int ( task ) ], s = suffix ), <TAB> ) <TAB> if int ( task ) == 4 : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> candpath = None <TAB> <TAB> else : <TAB> <TAB> <TAB> candpath = datafile. replace ( suffix + "".txt"", ""cand-{dt}.txt"". format ( dt = dt ) ) <TAB> else : <TAB> <TAB> candpath = os. path. join ( <TAB> <TAB> <TAB> opt [ ""datapath"" ], ""MovieDialog"", ""movie_dialog_dataset"", ""entities.txt"" <TAB> <TAB> ) <TAB> return datafile, candpath",True,dt == 'train',dt == 'train',0.6694294214248657
|
||
|
2362,"def test_label_plate_by_row ( ) : <TAB> """"""Label one complete plate"""""" <TAB> nsites = 6 <TAB> nimagesets = 96 * nsites <TAB> workspace, module = make_workspace ( nimagesets ) <TAB> measurements = workspace. measurements <TAB> assert isinstance ( measurements, cellprofiler_core. measurement. Measurements ) <TAB> assert isinstance ( module, cellprofiler. modules. labelimages. LabelImages ) <TAB> module. row_count. value = 8 <TAB> module. column_count. value = 12 <TAB> module. order. value = cellprofiler. modules. labelimages. O_ROW <TAB> module. site_count. value = nsites <TAB> for i in range ( nimagesets ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> measurements. next_image_set ( ) <TAB> <TAB> module. run ( workspace ) <TAB> sites = measurements. get_all_measurements ( ""Image"", M_SITE ) <TAB> rows = measurements. get_all_measurements ( ""Image"", M_ROW ) <TAB> columns = measurements. get_all_measurements ( ""Image"", M_COLUMN ) <TAB> plates = measurements. get_all_measurements ( ""Image"", M_PLATE ) <TAB> wells = measurements. get_all_measurements ( ""Image"", M_WELL ) <TAB> for i in range ( nimagesets ) : <TAB> <TAB> assert sites [ i ] == ( i % 6 ) + 1 <TAB> <TAB> this_row = ""ABCDEFGH"" [ int ( i / 6 / 12 ) ] <TAB> <TAB> this_column = ( int ( i / 6 ) % 12 ) + 1 <TAB> <TAB> assert rows [ i ] == this_row <TAB> <TAB> assert columns [ i ] == this_column <TAB> <TAB> assert wells [ i ] == ""%s%02d"" % ( this_row, this_column ) <TAB> <TAB> assert plates [ i ] == 1",False,i != 0,i % 6 == 0,0.679051399230957
|
||
|
2363,"def use_params ( self, params ) : <TAB> key_prefix = f""tensorflow_{self.id}_"" <TAB> <TAB> state_dict = { } <TAB> for k, v in params. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if cupy is None : <TAB> <TAB> <TAB> <TAB> assert isinstance ( v, numpy. ndarray ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> if isinstance ( v, cupy. core. core. ndarray ) : <TAB> <TAB> <TAB> <TAB> <TAB> v = cupy. asnumpy ( v ) <TAB> <TAB> <TAB> <TAB> assert isinstance ( v, numpy. ndarray ) <TAB> <TAB> <TAB> state_dict [ k. replace ( key_prefix, """" ) ] = v <TAB> if state_dict : <TAB> <TAB> backup = self. _create_state_dict ( ) <TAB> <TAB> self. _load_weights_from_state_dict ( state_dict ) <TAB> <TAB> yield <TAB> <TAB> self. _load_weights_from_state_dict ( backup ) <TAB> else : <TAB> <TAB> yield",False,"hasattr(k, 'startswith') and k.startswith(key_prefix)",k.startswith(key_prefix),0.6483956575393677
|
||
|
2364,"def send_request_to_server ( request ) : <TAB> sock = socket. socket ( socket. AF_INET, socket. SOCK_STREAM ) <TAB> try : <TAB> <TAB> <TAB> <TAB> sock. connect ( ( expand_host, expand_port ) ) <TAB> <TAB> logger. info ( ""sending request"" ) <TAB> <TAB> req_packet = pickle. dumps ( request ) <TAB> <TAB> <TAB> <TAB> sock. sendall ( req_packet ) <TAB> <TAB> <TAB> <TAB> data = b"""" <TAB> <TAB> ctr = 0 <TAB> <TAB> while True : <TAB> <TAB> <TAB> packet = sock. recv ( 134217728 ) <TAB> <TAB> <TAB> logger. info ( ""%s. received: %s"", str ( ctr ), str ( len ( packet ) ) ) <TAB> <TAB> <TAB> ctr += 1 <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> data += packet <TAB> <TAB> <TAB> logger. info ( ""got response, uncompressing"" ) <TAB> <TAB> received = pickle. loads ( data ) <TAB> <TAB> <TAB> <TAB> return received <TAB> except EOFError : <TAB> <TAB> logger. info ( ""No data received"" ) <TAB> finally : <TAB> <TAB> sock. close ( )",False,not packet,ctr > 10,0.676325261592865
|
||
|
2365,"def _update_split ( self, _event, direction ) : <TAB> self. split_count [ direction ] = self. spinbuttons [ direction ]. get_value_as_int ( ) <TAB> if self. even_splits [ direction ] : <TAB> <TAB> self. model [ direction ]. clear ( ) <TAB> <TAB> <TAB> <TAB> count = self. split_count [ direction ] <TAB> <TAB> frac = 100 // count <TAB> <TAB> partition = [ frac ] * ( count - 1 ) <TAB> <TAB> partition. append ( 100 - ( count - 1 ) * frac ) <TAB> <TAB> for i, frac in enumerate ( partition, start = 1 ) : <TAB> <TAB> <TAB> self. model [ direction ]. append ( [ i, frac ] ) <TAB> else : <TAB> <TAB> delta = self. split_count [ direction ] - len ( self. model [ direction ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> idx = len ( self. model [ direction ] ) + 1 <TAB> <TAB> <TAB> for i in range ( delta ) : <TAB> <TAB> <TAB> <TAB> self. model [ direction ]. append ( [ idx + i, 0 ] ) <TAB> <TAB> if delta < 0 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> s = 0 <TAB> <TAB> <TAB> for i in range ( abs ( delta ) ) : <TAB> <TAB> <TAB> <TAB> s += self. model [ direction ] [ - 1 ] [ 1 ] <TAB> <TAB> <TAB> <TAB> del self. model [ direction ] [ - 1 ] <TAB> <TAB> <TAB> self. model [ direction ] [ - 1 ] [ 1 ] += s",True,delta > 0,delta > 0,0.6855176687240601
|
||
|
2366,"def _dump_section ( self, name, values, f ) : <TAB> doc = ""__doc__"" <TAB> if doc in values : <TAB> <TAB> print ( ""# %s"" % values [ doc ], file = f ) <TAB> print ( ""%s("" % name, file = f ) <TAB> for k, v in values. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> doc = k + ""__doc__"" <TAB> <TAB> if doc in values : <TAB> <TAB> <TAB> print ( "" # %s"" % values [ doc ], file = f ) <TAB> <TAB> print ( "" %s = %s,"" % ( k, pprint. pformat ( v, indent = 8 ) ), file = f ) <TAB> print ( "")\n"", file = f )",False,k.endswith('__doc__'),k == '__doc__',0.6502742767333984
|
||
|
2367,"def parse_command ( self, text ) : <TAB> result = None <TAB> builtin_commands = sublime. load_settings ( ""TextPastryCommands.json"" ) <TAB> cmd_shortcuts = global_settings ( ""commands"", [ ] ) <TAB> cmd_shortcuts. extend ( builtin_commands. get ( ""commands"", [ ] ) ) <TAB> for item in cmd_shortcuts : <TAB> <TAB> <TAB> <TAB> if ""parser"" in item : <TAB> <TAB> <TAB> class_ = globals ( ) [ item [ ""parser"" ] ] <TAB> <TAB> <TAB> result = class_ ( text ). parse ( ) <TAB> <TAB> elif ""match"" in item : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> comp = re. compile ( item [ ""match"" ] ) <TAB> <TAB> <TAB> match = comp. match ( text ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> refs = { } <TAB> <TAB> <TAB> <TAB> for ( key, value ) in enumerate ( match. groups ( ) ) : <TAB> <TAB> <TAB> <TAB> <TAB> refs [ ""$"" + str ( key + 1 ) ] = value <TAB> <TAB> <TAB> <TAB> refs [ ""$0"" ] = match. group ( 0 ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> refs [ ""$clipbord"" ] = sublime. get_clipboard ( ) <TAB> <TAB> <TAB> <TAB> result = self. create_command ( item, refs ) <TAB> <TAB> if result : <TAB> <TAB> <TAB> break <TAB> return result",True,match,match,0.6823798418045044
|
||
|
2368,"def __computeTagMaps ( self, unique ) : <TAB> presentTypes = { } <TAB> skipTypes = { } <TAB> defaultType = None <TAB> for namedType in self. __namedTypes : <TAB> <TAB> tagMap = namedType. asn1Object. tagMap <TAB> <TAB> if isinstance ( tagMap, NamedTypes. PostponedError ) : <TAB> <TAB> <TAB> return tagMap <TAB> <TAB> for tagSet in tagMap : <TAB> <TAB> <TAB> if unique and tagSet in presentTypes : <TAB> <TAB> <TAB> <TAB> return NamedTypes. PostponedError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Non-unique tagSet %s of %s at %s"" % ( tagSet, namedType, self ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> presentTypes [ tagSet ] = namedType. asn1Object <TAB> <TAB> skipTypes. update ( tagMap. skipTypes ) <TAB> <TAB> if defaultType is None : <TAB> <TAB> <TAB> defaultType = tagMap. defaultType <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> return NamedTypes. PostponedError ( <TAB> <TAB> <TAB> <TAB> ""Duplicate default ASN.1 type at %s"" % ( self, ) <TAB> <TAB> <TAB> ) <TAB> return tagmap. TagMap ( presentTypes, skipTypes, defaultType )",False,tagMap.defaultType is not None,self.defaultType != tagMap.defaultType,0.6499348282814026
|
||
|
2369,"def write ( self, buffer ) : <TAB> if self. mode == MODE_NUMBER : <TAB> <TAB> for i in xrange ( 0, len ( self. data ), 3 ) : <TAB> <TAB> <TAB> chars = self. data [ i : i + 3 ] <TAB> <TAB> <TAB> bit_length = NUMBER_LENGTH [ len ( chars ) ] <TAB> <TAB> <TAB> buffer. put ( int ( chars ), bit_length ) <TAB> elif self. mode == MODE_ALPHA_NUM : <TAB> <TAB> for i in xrange ( 0, len ( self. data ), 2 ) : <TAB> <TAB> <TAB> chars = self. data [ i : i + 2 ] <TAB> <TAB> <TAB> if len ( chars ) > 1 : <TAB> <TAB> <TAB> <TAB> buffer. put ( ALPHA_NUM. find ( chars [ 0 ] ) * 45 + ALPHA_NUM. find ( chars [ 1 ] ), 11 ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> buffer. put ( ALPHA_NUM. find ( chars ), 6 ) <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> data = self. data <TAB> <TAB> else : <TAB> <TAB> <TAB> data = [ ord ( c ) for c in self. data ] <TAB> <TAB> for c in data : <TAB> <TAB> <TAB> buffer. put ( c, 8 )",False,six.PY3,self.data,0.6646746397018433
|
||
|
2370,"def _process ( self, to_process, batch_size ) : <TAB> for model, history_model in to_process : <TAB> <TAB> if history_model. objects. count ( ) : <TAB> <TAB> <TAB> self. stderr. write ( <TAB> <TAB> <TAB> <TAB> ""{msg} {model}\n"". format ( msg = self. EXISTING_HISTORY_FOUND, model = model ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. stdout. write ( self. START_SAVING_FOR_MODEL. format ( model = model ) ) <TAB> <TAB> self. _bulk_history_create ( model, batch_size ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. stdout. write ( self. DONE_SAVING_FOR_MODEL. format ( model = model ) )",False,self.verbosity >= 1,history_model.objects.count(),0.6581740379333496
|
||
|
2371,"def _extract_subtitles ( src ) : <TAB> subtitles = { } <TAB> for caption in try_get ( src, lambda x : x [ ""captions"" ], list ) or [ ] : <TAB> <TAB> subtitle_url = url_or_none ( caption. get ( ""uri"" ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> lang = caption. get ( ""language"", ""deu"" ) <TAB> <TAB> <TAB> subtitles. setdefault ( lang, [ ] ). append ( <TAB> <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> <TAB> ""url"" : subtitle_url, <TAB> <TAB> <TAB> <TAB> } <TAB> <TAB> <TAB> ) <TAB> return subtitles",False,subtitle_url,subtitles_url,0.6614885926246643
|
||
|
2372,"def generate_tag_1_data ( ids ) : <TAB> if len ( ids )!= SAMPLE_NUM : <TAB> <TAB> raise ValueError ( ""len ids should equal to sample number"" ) <TAB> counter = 0 <TAB> for sample_i in range ( SAMPLE_NUM ) : <TAB> <TAB> one_data = [ ids [ sample_i ] ] <TAB> <TAB> valid_set = [ x for x in range ( TAG_INTERVAL [ 0 ], TAG_INTERVAL [ 1 ] ) ] <TAB> <TAB> features = np. random. choice ( valid_set, FEATURE_NUM, replace = False ) <TAB> <TAB> one_data += [ "":"". join ( [ x, ""1.0"" ] ) for x in features ] <TAB> <TAB> counter += 1 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> print ( ""generate data {}"". format ( counter ) ) <TAB> <TAB> yield one_data",False,counter % 10000 == 0,counter % 10 == 0,0.6736827492713928
|
||
|
2373,"def onZoomFit ( self, * args ) : <TAB> <TAB> <TAB> <TAB> <TAB> if 0 : <TAB> <TAB> for axisIndex in range ( self. dimensions ) : <TAB> <TAB> <TAB> linkButton = self. linkButtons [ axisIndex ] <TAB> <TAB> <TAB> link = linkButton. link <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> logger. debug ( ""sending link messages"" ) <TAB> <TAB> <TAB> <TAB> link. sendRanges ( self. dialog. ranges [ axisIndex ], linkButton ) <TAB> <TAB> <TAB> <TAB> link. sendRangesShow ( <TAB> <TAB> <TAB> <TAB> <TAB> self. dialog. state. ranges_viewport [ axisIndex ], linkButton <TAB> <TAB> <TAB> <TAB> ) <TAB> action = undo. ActionZoom ( <TAB> <TAB> self. dialog. undoManager, <TAB> <TAB> ""zoom to fit"", <TAB> <TAB> self. dialog. set_ranges, <TAB> <TAB> list ( range ( self. dialog. dimensions ) ), <TAB> <TAB> self. dialog. state. ranges_viewport, <TAB> <TAB> self. dialog. state. range_level_show, <TAB> <TAB> list ( range ( self. dialog. dimensions ) ), <TAB> <TAB> ranges_viewport = [ None ] * self. dialog. dimensions, <TAB> <TAB> range_level_show = None, <TAB> ) <TAB> <TAB> <TAB> action. do ( ) <TAB> self. dialog. checkUndoRedo ( ) <TAB> self. dialog. queue_history_change ( ""zoom to fit"" ) <TAB> if 0 : <TAB> <TAB> linked_buttons = [ <TAB> <TAB> <TAB> button for button in self. linkButtons if button. link is not None <TAB> <TAB> ] <TAB> <TAB> links = [ button. link for button in linked_buttons ] <TAB> <TAB> if len ( linked_buttons ) > 0 : <TAB> <TAB> <TAB> logger. debug ( ""sending",False,link,len(link) > 0,0.6946277618408203
|
||
|
2374,"def find ( self, back = False ) : <TAB> flags = 0 <TAB> if back : <TAB> <TAB> flags = QTextDocument. FindBackward <TAB> if self. csBox. isChecked ( ) : <TAB> <TAB> flags = flags | QTextDocument. FindCaseSensitively <TAB> text = self. searchEdit. text ( ) <TAB> if not self. findMain ( text, flags ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> cursor = self. editBoxes [ self. ind ]. textCursor ( ) <TAB> <TAB> <TAB> if back : <TAB> <TAB> <TAB> <TAB> cursor. movePosition ( QTextCursor. End ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> cursor. movePosition ( QTextCursor. Start ) <TAB> <TAB> <TAB> self. editBoxes [ self. ind ]. setTextCursor ( cursor ) <TAB> <TAB> <TAB> self. findMain ( text, flags )",False,text in self.editBoxes[self.ind].toPlainText(),self.ind < len(self.editBoxes),0.6578768491744995
|
||
|
2375,"def _str_index ( self ) : <TAB> idx = self [ ""index"" ] <TAB> out = [ ] <TAB> if len ( idx ) == 0 : <TAB> <TAB> return out <TAB> out += [ "".. index:: %s"" % idx. get ( ""default"", """" ) ] <TAB> for section, references in idx. iteritems ( ) : <TAB> <TAB> if section == ""default"" : <TAB> <TAB> <TAB> continue <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> out += [ "" single: %s"" % ( "", "". join ( references ) ) ] <TAB> <TAB> else : <TAB> <TAB> <TAB> out += [ "" %s: %s"" % ( section, "","". join ( references ) ) ] <TAB> return out",False,section == 'refguide',reference is not None,0.6575438976287842
|
||
|
2376,"def bufferSaveAs ( self ) : <TAB> """"""Save buffer to a new filename."""""" <TAB> if self. bufferHasChanged ( ) and self. buffer. doc. filepath : <TAB> <TAB> cancel = self. bufferSuggestSave ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return cancel <TAB> filedir = """" <TAB> if self. buffer and self. buffer. doc. filedir : <TAB> <TAB> filedir = self. buffer. doc. filedir <TAB> result = editor. saveSingle ( <TAB> <TAB> title = ""Save PySlices File"", <TAB> <TAB> directory = filedir, <TAB> <TAB> wildcard = ""PySlices Files (*.pyslices)|*.pyslices"", <TAB> ) <TAB> if result. path not in [ """", None ] : <TAB> <TAB> if result. path [ - 9 : ]!= "".pyslices"" : <TAB> <TAB> <TAB> result. path += "".pyslices"" <TAB> <TAB> self. buffer. doc = document. Document ( result. path ) <TAB> <TAB> self. buffer. name = self. buffer. doc. filename <TAB> <TAB> self. buffer. modulename = self. buffer. doc. filebase <TAB> <TAB> self. simpleSave ( confirmed = True ) <TAB> <TAB> cancel = False <TAB> else : <TAB> <TAB> cancel = True <TAB> return cancel",True,cancel,cancel,0.7059651613235474
|
||
|
2377,"def update ( self ) : <TAB> for plugin_type in self. PLUGIN_TYPES : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> entrypoint_type = ""plover.%s"" % plugin_type <TAB> <TAB> for entrypoint in pkg_resources. iter_entry_points ( entrypoint_type ) : <TAB> <TAB> <TAB> if ""gui_qt"" in entrypoint. extras and not HAS_GUI_QT : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> self. register_plugin_from_entrypoint ( plugin_type, entrypoint ) <TAB> <TAB> if PLUGINS_PLATFORM is not None : <TAB> <TAB> <TAB> entrypoint_type = ""plover.%s.%s"" % ( PLUGINS_PLATFORM, plugin_type ) <TAB> <TAB> <TAB> for entrypoint in pkg_resources. iter_entry_points ( entrypoint_type ) : <TAB> <TAB> <TAB> <TAB> self. register_plugin_from_entrypoint ( plugin_type, entrypoint )",False,plugin_type.startswith('gui.qt.') and (not HAS_GUI_QT),plugin_type is None,0.6496763229370117
|
||
|
2378,"def _run_response_middleware ( self, request, response, request_name = None ) : <TAB> named_middleware = self. named_response_middleware. get ( request_name, deque ( ) ) <TAB> applicable_middleware = self. response_middleware + named_middleware <TAB> if applicable_middleware : <TAB> <TAB> for middleware in applicable_middleware : <TAB> <TAB> <TAB> _response = middleware ( request, response ) <TAB> <TAB> <TAB> if isawaitable ( _response ) : <TAB> <TAB> <TAB> <TAB> _response = await _response <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> response = _response <TAB> <TAB> <TAB> <TAB> break <TAB> return response",False,_response,isawaitable(response),0.6782186031341553
|
||
|
2379,"def _wait_for_positive ( condition, locators, wait_timeout ) : <TAB> start_time = time. time ( ) <TAB> while True : <TAB> <TAB> locator = None <TAB> <TAB> try : <TAB> <TAB> <TAB> locator = get_locator ( <TAB> <TAB> <TAB> <TAB> locators, ignore_implicit_wait = True, raise_exception = True <TAB> <TAB> <TAB> ) <TAB> <TAB> except NoSuchElementException : <TAB> <TAB> <TAB> pass <TAB> <TAB> if locator : <TAB> <TAB> <TAB> element = None <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> element = WebDriverWait ( _get_driver ( ), wait_timeout ). until ( <TAB> <TAB> <TAB> <TAB> <TAB> _get_until_cond ( condition, locator ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> except TimeoutException : <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> if element : <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> elapsed_time = time. time ( ) - start_time <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise NoSuchElementException ( <TAB> <TAB> <TAB> <TAB> ""Timeout occurred while waiting for '%s' condition"" % condition <TAB> <TAB> <TAB> )",False,elapsed_time > wait_timeout,elapsed_time > 5,0.6553369760513306
|
||
|
2380,"def generate ( self, length = 10000, prefix = False ) : <TAB> replacements2 = { "","" : "","", "" \."" : "".\n"", "" :"" : "":"", "" ;"" : "";"", ""\n\s+"" : ""\n"" } <TAB> keys = list ( self. db. keys ( ) ) <TAB> key = keys [ random. randint ( 0, len ( keys ) - 1 ) ] <TAB> words = key <TAB> words = words. capitalize ( ) <TAB> regex = re. compile ( ""[a-z]+"" ) <TAB> for i in range ( length ) : <TAB> <TAB> okey = key <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> break <TAB> <TAB> db = self. db [ key ] <TAB> <TAB> s = sum ( db. values ( ) ) <TAB> <TAB> i = random. randint ( 0, s - 1 ) <TAB> <TAB> for key, value in db. items ( ) : <TAB> <TAB> <TAB> if i < value : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> i -= value <TAB> <TAB> if okey == ""."" : <TAB> <TAB> <TAB> key1 = key. capitalize ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> key1 = key <TAB> <TAB> if prefix and regex. findall ( key1 ) and random. random ( ) < 0.01 : <TAB> <TAB> <TAB> key1 = '<a href=""%s%s"">%s</a>' % ( prefix, key1, key1 ) <TAB> <TAB> words += "" "" + key1 <TAB> text = words <TAB> for key, value in replacements2. items ( ) : <TAB> <TAB> text = re. sub ( key, value, text ) <TAB> return text + "".\n""",False,not key in self.db,okey == False,0.6579463481903076
|
||
|
2381,"def ConstructDpbService ( self ) : <TAB> """"""Create the dpb_service object and create groups for its vms."""""" <TAB> if self. config. dpb_service is None : <TAB> <TAB> return <TAB> dpb_service_spec = self. config. dpb_service <TAB> dpb_service_cloud = dpb_service_spec. worker_group. cloud <TAB> providers. LoadProvider ( dpb_service_cloud ) <TAB> dpb_service_type = dpb_service_spec. service_type <TAB> dpb_service_class = dpb_service. GetDpbServiceClass ( dpb_service_type ) <TAB> self. dpb_service = dpb_service_class ( dpb_service_spec ) <TAB> <TAB> <TAB> if dpb_service_type == dpb_service. UNMANAGED_DPB_SVC_YARN_CLUSTER : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise Exception ( <TAB> <TAB> <TAB> <TAB> ""Invalid Non cluster vm group {0} when benchmarking "" <TAB> <TAB> <TAB> <TAB> ""unmanaged dpb service"". format ( self. vms_to_boot ) <TAB> <TAB> <TAB> ) <TAB> <TAB> base_vm_spec = dpb_service_spec. worker_group <TAB> <TAB> base_vm_spec. vm_spec. zone = self. dpb_service. dpb_service_zone <TAB> <TAB> worker_group_spec = copy. copy ( base_vm_spec ) <TAB> <TAB> worker_group_spec. vm_count = dpb_service_spec. worker_count <TAB> <TAB> self. vms_to_boot [ ""worker_group"" ] = worker_group_spec <TAB> <TAB> master_group_spec = copy. copy ( base_vm_spec ) <TAB> <TAB> master_group_spec. vm_count = 1 <TAB> <TAB> self. vms_to_boot [ ""master_group"" ] = master_group_spec <TAB> <TAB> logging. info ( str (",False,self.vms_to_boot,dpb_service_type != dpb_service.UNMANAGED_DPB_SVC_YARN_CLUSTER,0.659541130065918
|
||
|
2382,"def _write_inputs ( node ) : <TAB> lines = [ ] <TAB> nodename = node. fullname. replace ( ""."", ""_"" ) <TAB> for key, _ in list ( node. inputs. items ( ) ) : <TAB> <TAB> val = getattr ( node. inputs, key ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if isinstance ( val, ( str, bytes ) ) : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> func = create_function_from_source ( val ) <TAB> <TAB> <TAB> <TAB> except RuntimeError : <TAB> <TAB> <TAB> <TAB> <TAB> lines. append ( ""%s.inputs.%s = '%s'"" % ( nodename, key, val ) ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> funcname = [ <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> name for name in func. __globals__ if name!= ""__builtins__"" <TAB> <TAB> <TAB> <TAB> <TAB> ] [ 0 ] <TAB> <TAB> <TAB> <TAB> <TAB> lines. append ( pickle. loads ( val ) ) <TAB> <TAB> <TAB> <TAB> <TAB> if funcname == nodename : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> lines [ - 1 ] = lines [ - 1 ]. replace ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> "" %s("" % funcname, "" %s_1("" % funcname <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> funcname = ""%s_1"" % funcname <TAB> <TAB> <TAB> <TAB> <TAB> lines. append ( ""from nipype.utils.functions import getsource"" ) <TAB> <TAB> <TAB> <TAB> <TAB> lines. append ( <TAB> <TAB> <TAB> <TAB> <TAB",False,isdefined(val),val,0.6546334624290466
|
||
|
2383,"def test_expect_setecho_off ( self ) : <TAB> """"""This tests that echo may be toggled off."""""" <TAB> p = pexpect. spawn ( ""cat"", echo = True, timeout = 5 ) <TAB> try : <TAB> <TAB> self. _expect_echo_toggle ( p ) <TAB> except IOError : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if hasattr ( unittest, ""SkipTest"" ) : <TAB> <TAB> <TAB> <TAB> raise unittest. SkipTest ( ""Not supported on this platform."" ) <TAB> <TAB> <TAB> return ""skip"" <TAB> <TAB> raise",False,sys.platform.lower().startswith('sunos'),"hasattr(unittest, 'getecho')",0.6518650650978088
|
||
|
2384,"def _compute_substitution_score ( <TAB> aln1_chars, aln2_chars, substitution_matrix, gap_substitution_score, gap_chars ) : <TAB> substitution_score = 0 <TAB> for aln1_char, aln2_char in product ( aln1_chars, aln2_chars ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> substitution_score += gap_substitution_score <TAB> <TAB> else : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> substitution_score += substitution_matrix [ aln1_char ] [ aln2_char ] <TAB> <TAB> <TAB> except KeyError : <TAB> <TAB> <TAB> <TAB> offending_chars = [ <TAB> <TAB> <TAB> <TAB> <TAB> c for c in ( aln1_char, aln2_char ) if c not in substitution_matrix <TAB> <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""One of the sequences contains a character that is "" <TAB> <TAB> <TAB> <TAB> <TAB> ""not contained in the substitution matrix. Are you "" <TAB> <TAB> <TAB> <TAB> <TAB> ""using an appropriate substitution matrix for your "" <TAB> <TAB> <TAB> <TAB> <TAB> ""sequence type (e.g., a nucleotide substitution "" <TAB> <TAB> <TAB> <TAB> <TAB> ""matrix does not make sense for aligning protein "" <TAB> <TAB> <TAB> <TAB> <TAB> ""sequences)? Does your sequence contain invalid "" <TAB> <TAB> <TAB> <TAB> <TAB> ""characters? The offending character(s) is: "" <TAB> <TAB> <TAB> <TAB> <TAB> "" %s."" % "", "". join ( offending_chars ) <TAB> <TAB> <TAB> <TAB> ) <TAB> substitution_score /= len ( aln1_chars ) * len ( aln2_chars ) <TAB> return substitution_score",False,aln1_char in gap_chars or aln2_char in gap_chars,gap_substitution_score,0.6586174964904785
|
||
|
2385,"def merge_lz_operations ( lzops ) : <TAB> """"""Merge consecutive LZ operations into single ops if possible."""""" <TAB> lzops = iter ( lzops ) <TAB> try : <TAB> <TAB> prev = lzops. next ( ) <TAB> <TAB> while True : <TAB> <TAB> <TAB> cur = lzops. next ( ) <TAB> <TAB> <TAB> if isinstance ( cur, LZLiteral ) : <TAB> <TAB> <TAB> <TAB> if isinstance ( prev, LZLiteral ) : <TAB> <TAB> <TAB> <TAB> <TAB> prev. data += cur. data <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> yield prev <TAB> <TAB> <TAB> <TAB> <TAB> prev = cur <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> if isinstance ( prev, LZLiteral ) : <TAB> <TAB> <TAB> <TAB> <TAB> yield prev <TAB> <TAB> <TAB> <TAB> <TAB> prev = cur <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> prev. length += cur. length <TAB> <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> yield prev <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> prev = cur <TAB> except StopIteration : <TAB> <TAB> pass",False,prev.distance == cur.distance,prev is not None,0.6532402038574219
|
||
|
2386,"def get_output_for ( self, input, ** kwargs ) : <TAB> <TAB> out = T. tensordot ( self. W, input, axes = [ [ 1 ], [ 0 ] ] ) <TAB> if self. b is None : <TAB> <TAB> activation = out <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> bias_axes = range ( input. ndim - 1 ) + [ ""x"" ] <TAB> <TAB> else : <TAB> <TAB> <TAB> bias_axes = [ 0 ] + ( [ ""x"" ] * ( input. ndim - 1 ) ) <TAB> <TAB> b_shuffled = self. b. dimshuffle ( bias_axes ) <TAB> <TAB> activation = out + b_shuffled <TAB> return self. nonlinearity ( activation )",False,self.untie_biases,self.bias_axes is None,0.6513996124267578
|
||
|
2387,"def compile ( self, filename, obfuscate = False, raw = False, magic = ""\x00"" * 8 ) : <TAB> body = marshal. dumps ( compile ( self. visit ( self. _source_ast ), filename, ""exec"" ) ) <TAB> if obfuscate : <TAB> <TAB> body_len = len ( body ) <TAB> <TAB> offset = 0 if raw else 8 <TAB> <TAB> output = bytearray ( body_len + 8 ) <TAB> <TAB> for i, x in enumerate ( body ) : <TAB> <TAB> <TAB> output [ i + offset ] = ord ( x ) ^ ( ( 2 ** ( ( 65535 - i ) % 65535 ) ) % 251 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> for i in xrange ( 8 ) : <TAB> <TAB> <TAB> <TAB> output [ i ] = 0 <TAB> <TAB> return output <TAB> el if<mask> : <TAB> <TAB> return body <TAB> else : <TAB> <TAB> return magic + body",True,raw,raw,0.6872165203094482
|
||
|
2388,"def apply ( <TAB> self, <TAB> basket, <TAB> condition, <TAB> offer, <TAB> discount_percent = None, <TAB> max_total_discount = None, <TAB> ** kwargs ) : <TAB> if discount_percent is None : <TAB> <TAB> discount_percent = self. value <TAB> discount_amount_available = max_total_discount <TAB> line_tuples = self. get_applicable_lines ( offer, basket ) <TAB> discount_percent = min ( discount_percent, D ( ""100.0"" ) ) <TAB> discount = D ( ""0.00"" ) <TAB> affected_items = 0 <TAB> max_affected_items = self. _effective_max_affected_items ( ) <TAB> affected_lines = [ ] <TAB> for price, line in line_tuples : <TAB> <TAB> if affected_items >= max_affected_items : <TAB> <TAB> <TAB> break <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> break <TAB> <TAB> quantity_affected = min ( <TAB> <TAB> <TAB> line. quantity_without_offer_discount ( offer ), <TAB> <TAB> <TAB> max_affected_items - affected_items, <TAB> <TAB> ) <TAB> <TAB> if quantity_affected <= 0 : <TAB> <TAB> <TAB> break <TAB> <TAB> line_discount = self. round ( <TAB> <TAB> <TAB> discount_percent / D ( ""100.0"" ) * price * int ( quantity_affected ) <TAB> <TAB> ) <TAB> <TAB> if discount_amount_available is not None : <TAB> <TAB> <TAB> line_discount = min ( line_discount, discount_amount_available ) <TAB> <TAB> <TAB> discount_amount_available -= line_discount <TAB> <TAB> apply_discount ( line, line_discount, quantity_affected, offer ) <TAB> <TAB> affected_lines. append ( ( line, line_discount, quantity_affected ) ) <TAB> <TAB> affected_items += quantity_affected <TAB> <TAB> discount += line_discount <TAB> return BasketDiscount ( discount",False,discount_amount_available == 0,line.has_offer_discount,0.6559979915618896
|
||
|
2389,"def __pow__ ( self, power ) : <TAB> if power == 1 : <TAB> <TAB> return self <TAB> if power == - 1 : <TAB> <TAB> <TAB> <TAB> from cirq. devices import line_qubit <TAB> <TAB> decomposed = protocols. decompose_once_with_qubits ( <TAB> <TAB> <TAB> self, qubits = line_qubit. LineQid. for_gate ( self ), default = None <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return NotImplemented <TAB> <TAB> inverse_decomposed = protocols. inverse ( decomposed, None ) <TAB> <TAB> if inverse_decomposed is None : <TAB> <TAB> <TAB> return NotImplemented <TAB> <TAB> return _InverseCompositeGate ( self ) <TAB> return NotImplemented",True,decomposed is None,decomposed is None,0.6663508415222168
|
||
|
2390,"def detect_object ( <TAB> inference, camera, classes, threshold, out_dir, range_x = [ 0, 1 ], range_y = [ 0, 1 ] ) : <TAB> """"""Detects objects belonging to given classes in camera stream."""""" <TAB> stream = io. BytesIO ( ) <TAB> camera. capture ( stream, format = ""jpeg"" ) <TAB> stream. seek ( 0 ) <TAB> image = Image. open ( stream ) <TAB> <TAB> <TAB> rgb_histogram = np. array ( image. histogram ( ) ). reshape ( ( 3, 256 ) ) <TAB> green_peak = np. argmax ( rgb_histogram [ 1, : ] ) <TAB> if green_peak < 3 : <TAB> <TAB> time. sleep ( 1.0 ) <TAB> <TAB> return False, None, None <TAB> debug_data = [ ] <TAB> detection = False <TAB> max_accumulator = 0.0 <TAB> print ( ""Inferring..."" ) <TAB> for p in crop_parameters ( image, range_x, range_y ) : <TAB> <TAB> im_crop = image. crop ( p ) <TAB> <TAB> accumulator = 0.0 <TAB> <TAB> infer_classes = image_classification. get_classes ( <TAB> <TAB> <TAB> inference. run ( im_crop ), top_k = 5, threshold = 0.05 <TAB> <TAB> ) <TAB> <TAB> corner = [ p [ 0 ], p [ 1 ] ] <TAB> <TAB> print ( corner ) <TAB> <TAB> for idx, ( label, score ) in enumerate ( infer_classes ) : <TAB> <TAB> <TAB> debug_data. append ( ( corner, im_crop. size, idx, label, score ) ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> accumulator += score <TAB> <TAB> if accumulator > max_accumulator : <TAB> <TAB> <TAB> max_accumulator = accumulator <TAB> <TAB> if accumulator >= threshold : <TAB> <TAB> <TAB> detection = True <TAB> <TAB> <TAB> break <TAB> if out_dir : <TAB> <",False,label in classes,debug_data,0.670791745185852
|
||
|
2391,"def _handle ( self, environ ) : <TAB> path = environ [ ""bottle.raw_path"" ] = environ [ ""PATH_INFO"" ] <TAB> if py3k : <TAB> <TAB> try : <TAB> <TAB> <TAB> environ [ ""PATH_INFO"" ] = path. encode ( ""latin1"" ). decode ( ""utf8"" ) <TAB> <TAB> except UnicodeError : <TAB> <TAB> <TAB> return HTTPError ( 400, ""Invalid path string. Expected UTF-8"" ) <TAB> try : <TAB> <TAB> environ [ ""bottle.app"" ] = self <TAB> <TAB> request. bind ( environ ) <TAB> <TAB> response. bind ( ) <TAB> <TAB> try : <TAB> <TAB> <TAB> self. trigger_hook ( ""before_request"" ) <TAB> <TAB> <TAB> route, args = self. router. match ( environ ) <TAB> <TAB> <TAB> environ [ ""route.handle"" ] = route <TAB> <TAB> <TAB> environ [ ""bottle.route"" ] = route <TAB> <TAB> <TAB> environ [ ""route.url_args"" ] = args <TAB> <TAB> <TAB> return route. call ( ** args ) <TAB> <TAB> finally : <TAB> <TAB> <TAB> self. trigger_hook ( ""after_request"" ) <TAB> except HTTPResponse : <TAB> <TAB> return _e ( ) <TAB> except RouteReset : <TAB> <TAB> route. reset ( ) <TAB> <TAB> return self. _handle ( environ ) <TAB> except ( KeyboardInterrupt, SystemExit, MemoryError ) : <TAB> <TAB> raise <TAB> except Exception : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise <TAB> <TAB> stacktrace = format_exc ( ) <TAB> <TAB> environ [ ""wsgi.errors"" ]. write ( stacktrace ) <TAB> <TAB> return HTTPError ( 500, ""Internal Server Error"", _e ( ), stacktrace )",False,not self.catchall,environ['wsgi.errors'] is None,0.659212589263916
|
||
|
2392,"def upload_object_via_stream ( <TAB> self, iterator, container, object_name, callback = None, extra = None, ** kwargs ) : <TAB> import boto3. s3. transfer <TAB> stream = _Stream ( iterator ) <TAB> try : <TAB> <TAB> container. bucket. upload_fileobj ( <TAB> <TAB> <TAB> stream, <TAB> <TAB> <TAB> object_name, <TAB> <TAB> <TAB> Config = boto3. s3. transfer. TransferConfig ( <TAB> <TAB> <TAB> <TAB> use_threads = container. config. multipart, <TAB> <TAB> <TAB> <TAB> max_concurrency = self. _max_multipart_concurrency <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> else 1, <TAB> <TAB> <TAB> <TAB> num_download_attempts = container. config. retries, <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> Callback = callback, <TAB> <TAB> ) <TAB> except Exception as ex : <TAB> <TAB> log. error ( ""Failed uploading: %s"" % ex ) <TAB> <TAB> return False <TAB> return True",False,container.config.multipart,max_concurrency <= 0,0.6499392986297607
|
||
|
2393,"def delete_user ( request ) : <TAB> if not is_admin ( request. user ) : <TAB> <TAB> request. audit = { <TAB> <TAB> <TAB> ""operation"" : ""DELETE_USER"", <TAB> <TAB> <TAB> ""operationText"" : _get_failed_operation_text ( <TAB> <TAB> <TAB> <TAB> request. user. username, ""DELETE_USER"" <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> ""allowed"" : False, <TAB> <TAB> } <TAB> <TAB> raise PopupException ( <TAB> <TAB> <TAB> _ ( ""You must be a superuser to delete users."" ), error_code = 401 <TAB> <TAB> ) <TAB> if request. method!= ""POST"" : <TAB> <TAB> raise PopupException ( _ ( ""A POST request is required."" ) ) <TAB> ids = request. POST. getlist ( ""user_ids"" ) <TAB> global __users_lock <TAB> __users_lock. acquire ( ) <TAB> try : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise PopupException ( _ ( ""You cannot remove yourself."" ), error_code = 401 ) <TAB> <TAB> usernames = list ( <TAB> <TAB> <TAB> User. objects. filter ( id__in = ids ). values_list ( ""username"", flat = True ) <TAB> <TAB> ) <TAB> <TAB> UserProfile. objects. filter ( user__id__in = ids ). delete ( ) <TAB> <TAB> User. objects. filter ( id__in = ids ). delete ( ) <TAB> <TAB> request. audit = { <TAB> <TAB> <TAB> ""operation"" : ""DELETE_USER"", <TAB> <TAB> <TAB> ""operationText"" : ""Deleted User(s): %s"" % "", "". join ( usernames ), <TAB> <TAB> } <TAB> finally : <TAB> <TAB> __users_lock. release ( ) <TAB> is_embeddable = request. GET. get ( <TAB> <TAB> ""is_embeddable"", request. POST",False,str(request.user.id) in ids,ids[0] in self.superuser,0.6517447233200073
|
||
|
2394,"def check_multiple_inheritance ( self, typ : TypeInfo ) -> None : <TAB> """"""Check for multiple inheritance related errors."""""" <TAB> if len ( typ. bases ) <= 1 : <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> mro = typ. mro [ 1 : ] <TAB> for i, base in enumerate ( mro ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> non_overridden_attrs = base. names. keys ( ) - typ. names. keys ( ) <TAB> <TAB> for name in non_overridden_attrs : <TAB> <TAB> <TAB> if is_private ( name ) : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> for base2 in mro [ i + 1 : ] : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> self. check_compatibility ( name, base, base2, typ )",False,name in base2.names and base2 not in base.mro,is_private(name),0.6535847187042236
|
||
|
2395,"def change_args_to_dict ( string ) : <TAB> if string is None : <TAB> <TAB> return None <TAB> ans = [ ] <TAB> strings = string. split ( ""\n"" ) <TAB> ind = 1 <TAB> start = 0 <TAB> while ind <= len ( strings ) : <TAB> <TAB> if ind < len ( strings ) and strings [ ind ]. startswith ( "" "" ) : <TAB> <TAB> <TAB> ind += 1 <TAB> <TAB> else : <TAB> <TAB> <TAB> if start < ind : <TAB> <TAB> <TAB> <TAB> ans. append ( ""\n"". join ( strings [ start : ind ] ) ) <TAB> <TAB> <TAB> start = ind <TAB> <TAB> <TAB> ind += 1 <TAB> d = { } <TAB> for line in ans : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> lines = line. split ( "":"" ) <TAB> <TAB> <TAB> d [ lines [ 0 ] ] = lines [ 1 ]. strip ( ) <TAB> return d",False,':' in line and len(line) > 0,line.startswith(b'<TAB>'),0.6525073051452637
|
||
|
2396,def reader_leaves ( self ) : <TAB> self. mutex. acquire ( ) <TAB> try : <TAB> <TAB> self. active_readers -= 1 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. active_writers += 1 <TAB> <TAB> <TAB> self. waiting_writers -= 1 <TAB> <TAB> <TAB> self. can_write. release ( ) <TAB> finally : <TAB> <TAB> self. mutex. release ( ),False,self.active_readers == 0 and self.waiting_writers != 0,self.waiting_writers > 0,0.6549704074859619
|
||
|
2397,"def number_headings ( toc, maindoc ) : <TAB> mdlines = [ ] <TAB> skip = False <TAB> for line in maindoc. splitlines ( ) : <TAB> <TAB> if line. strip ( ) == ""# Introduction"" : <TAB> <TAB> <TAB> toc. start_numbering = True <TAB> <TAB> <TAB> toc. numbering = [ 0 ] <TAB> <TAB> if line == ""```"" : <TAB> <TAB> <TAB> skip = not skip <TAB> <TAB> if not skip : <TAB> <TAB> <TAB> m = re. match ( r""^(#+) (.*)"", line ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> num = toc. add_entry ( len ( m. group ( 1 ) ), m. group ( 2 ) ) <TAB> <TAB> <TAB> <TAB> line = ""%s %s %s"" % ( m. group ( 1 ), num, m. group ( 2 ) ) <TAB> <TAB> <TAB> line = re. sub ( r""^(https?://\S+)"", r""[\1](\1)"", line ) <TAB> <TAB> mdlines. append ( line ) <TAB> maindoc = ""\n"". join ( mdlines ) <TAB> return maindoc",True,m,m,0.6910536885261536
|
||
|
2398,"def _tune ( <TAB> kmeans_estimator, <TAB> kmeans_train_set, <TAB> tuner = None, <TAB> hyperparameter_ranges = None, <TAB> job_name = None, <TAB> warm_start_config = None, <TAB> wait = True, <TAB> max_jobs = 2, <TAB> max_parallel_jobs = 2, <TAB> early_stopping_type = ""Off"", ) : <TAB> with timeout ( minutes = TUNING_DEFAULT_TIMEOUT_MINUTES ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> tuner = HyperparameterTuner ( <TAB> <TAB> <TAB> <TAB> estimator = kmeans_estimator, <TAB> <TAB> <TAB> <TAB> objective_metric_name = ""test:msd"", <TAB> <TAB> <TAB> <TAB> hyperparameter_ranges = hyperparameter_ranges, <TAB> <TAB> <TAB> <TAB> objective_type = ""Minimize"", <TAB> <TAB> <TAB> <TAB> max_jobs = max_jobs, <TAB> <TAB> <TAB> <TAB> max_parallel_jobs = max_parallel_jobs, <TAB> <TAB> <TAB> <TAB> warm_start_config = warm_start_config, <TAB> <TAB> <TAB> <TAB> early_stopping_type = early_stopping_type, <TAB> <TAB> <TAB> ) <TAB> <TAB> records = kmeans_estimator. record_set ( kmeans_train_set [ 0 ] [ : 100 ] ) <TAB> <TAB> test_record_set = kmeans_estimator. record_set ( <TAB> <TAB> <TAB> kmeans_train_set [ 0 ] [ : 100 ], channel = ""test"" <TAB> <TAB> ) <TAB> <TAB> print ( ""Started hyperparameter tuning job with name: {}"". format ( job_name ) ) <TAB> <TAB> tuner. fit ( [ records, test_record_set ], job_name = job_name, wait = wait ) <TAB> return tuner",False,not tuner,tuner is None,0.6938213109970093
|
||
|
2399,"def writeout ( self, fd, output ) : <TAB> if isinstance ( output, ( str, unicode ) ) : <TAB> <TAB> total = len ( output ) <TAB> <TAB> output = StringIO. StringIO ( output ) <TAB> else : <TAB> <TAB> total = 0 <TAB> try : <TAB> <TAB> while True : <TAB> <TAB> <TAB> self. state = ""read"" <TAB> <TAB> <TAB> line = output. read ( BLOCKSIZE ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> self. state = ""write"" <TAB> <TAB> <TAB> fd. write ( line ) <TAB> <TAB> <TAB> total -= len ( line ) <TAB> <TAB> output. close ( ) <TAB> except : <TAB> <TAB> if not self. partial_write_ok : <TAB> <TAB> <TAB> print ( ""%s: %s bytes left"" % ( self, total ) ) <TAB> <TAB> <TAB> traceback. print_exc ( ) <TAB> finally : <TAB> <TAB> self. state = ""done"" <TAB> <TAB> fd. close ( )",False,line == '',total > 0,0.6722662448883057
|
||
|
2400,"def visit_decorator ( self, o : Decorator ) -> None : <TAB> if not self. use_logical_deps ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. add_dependency ( make_trigger ( o. func. fullname ) ) <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for d in o. decorators : <TAB> <TAB> <TAB> tname = None <TAB> <TAB> <TAB> if isinstance ( d, RefExpr ) and d. fullname is not None : <TAB> <TAB> <TAB> <TAB> tname = d. fullname <TAB> <TAB> <TAB> if ( <TAB> <TAB> <TAB> <TAB> isinstance ( d, CallExpr ) <TAB> <TAB> <TAB> <TAB> and isinstance ( d. callee, RefExpr ) <TAB> <TAB> <TAB> <TAB> and d. callee. fullname is not None <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> tname = d. callee. fullname <TAB> <TAB> <TAB> if tname is not None : <TAB> <TAB> <TAB> <TAB> self. add_dependency ( make_trigger ( tname ), make_trigger ( o. func. fullname ) ) <TAB> super ( ). visit_decorator ( o )",False,not o.func.is_overload and self.scope.current_function_name() is None,o.func.fullname is not None,0.6494070887565613
|
||
|
2401,"def _parse_images ( self, is_train ) : <TAB> image_ids = self. COCO. getImgIds ( ) <TAB> image_ids. sort ( ) <TAB> imgs = copy. deepcopy ( self. COCO. loadImgs ( image_ids ) ) <TAB> for img in imgs : <TAB> <TAB> img [ ""image"" ] = os. path. join ( self. img_dir, img [ ""file_name"" ] ) <TAB> <TAB> assert os. path. exists ( img [ ""image"" ] ), ""image {} not found."". format ( img [ ""image"" ] ) <TAB> <TAB> box_num = cfg. max_box_num <TAB> <TAB> img [ ""gt_boxes"" ] = np. zeros ( ( cfg. max_box_num, 4 ), dtype = np. float32 ) <TAB> <TAB> img [ ""gt_labels"" ] = np. zeros ( ( cfg. max_box_num ), dtype = np. int32 ) <TAB> <TAB> for k in [ ""date_captured"", ""url"", ""license"", ""file_name"" ] : <TAB> <TAB> <TAB> if k in img : <TAB> <TAB> <TAB> <TAB> del img [ k ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _parse_gt_annotations ( img ) <TAB> print ( ""Loaded {0} images from {1}."". format ( len ( imgs ), cfg. dataset ) ) <TAB> return imgs",True,is_train,is_train,0.6663854122161865
|
||
|
2402,"def search ( <TAB> self, search_strings, age = 0, show_id = None, season = None, episode = None, ** kwargs ) : <TAB> results = [ ] <TAB> if not self. login ( ) : <TAB> <TAB> return results <TAB> for mode in search_strings : <TAB> <TAB> sickrage. app. log. debug ( ""Search Mode: %s"" % mode ) <TAB> <TAB> for search_string in search_strings [ mode ] : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> sickrage. app. log. debug ( ""Search string: %s"" % search_string ) <TAB> <TAB> <TAB> <TAB> searchURL = self. urls [ ""search"" ] % ( <TAB> <TAB> <TAB> <TAB> <TAB> quote_plus ( search_string. replace ( ""."", "" "" ) ), <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> searchURL = self. urls [ ""search"" ] % """" <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> data = self. session. get ( searchURL ). text <TAB> <TAB> <TAB> <TAB> results += self. parse ( data, mode ) <TAB> <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> <TAB> sickrage. app. log. debug ( ""No data returned from provider"" ) <TAB> <TAB> <TAB> <TAB> continue <TAB> return results",False,mode != 'RSS',search_string,0.6759482026100159
|
||
|
2403,"def on_cboSearchDirectoryEntry_changed ( self, entry ) : <TAB> text = entry. get_text ( ) <TAB> if text and self. _autoCompleteList!= None : <TAB> <TAB> path = os. path. dirname ( text ) <TAB> <TAB> start = os. path. basename ( text ) <TAB> <TAB> self. _autoCompleteList. clear ( ) <TAB> <TAB> try : <TAB> <TAB> <TAB> files = dircache. listdir ( path ) [ : ] <TAB> <TAB> except OSError : <TAB> <TAB> <TAB> return <TAB> <TAB> dircache. annotate ( path, files ) <TAB> <TAB> for f in files : <TAB> <TAB> <TAB> if f. startswith ( ""."" ) and not ( start. startswith ( ""."" ) ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> if path == ""/"" : <TAB> <TAB> <TAB> <TAB> <TAB> match = path + f <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> match = path + os. sep + f <TAB> <TAB> <TAB> <TAB> self. _autoCompleteList. append ( [ match ] )",False,f.startswith(start) and f.endswith('/'),path == '/',0.6463853120803833
|
||
|
2404,"def should_execute ( file_name : str, file_text : str ) -> Tuple [ str, bool ] : <TAB> if dont_execute_re. search ( file_text ) : <TAB> <TAB> return dont_execute_re. sub ( """", file_text ), False <TAB> m = required_py_re. search ( file_text ) <TAB> if m : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return required_py_re. sub ( """", file_text ), True <TAB> <TAB> else : <TAB> <TAB> <TAB> v = ""."". join ( m. groups ( ) ) <TAB> <TAB> <TAB> print ( f""WARNING: {file_name} requires python {v}, not running"" ) <TAB> <TAB> <TAB> return ( <TAB> <TAB> <TAB> <TAB> required_py_re. sub ( f""# requires python {v}, NOT EXECUTED!"", file_text ), <TAB> <TAB> <TAB> <TAB> False, <TAB> <TAB> <TAB> ) <TAB> else : <TAB> <TAB> return file_text, True",False,sys.version_info >= tuple((int(v) for v in m.groups())),m.groups() is None,0.6552332639694214
|
||
|
2405,"def main ( ) : <TAB> assert sys. version_info [ 0 ] == 3 <TAB> moduleset_versions = get_moduleset_versions ( ) <TAB> pool = ThreadPool ( 20 ) <TAB> pool_iter = pool. imap_unordered ( _fetch_version, moduleset_versions. keys ( ) ) <TAB> arch_versions = { } <TAB> for i, some_versions in enumerate ( pool_iter ) : <TAB> <TAB> arch_versions. update ( some_versions ) <TAB> for name, version in sorted ( moduleset_versions. items ( ) ) : <TAB> <TAB> arch_name = fix_name ( name ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> arch_version, arch_url = arch_versions [ arch_name ] <TAB> <TAB> <TAB> arch_version = arch_version. split ( ""+"", 1 ) [ 0 ] <TAB> <TAB> <TAB> if arch_name == ""readline"" : <TAB> <TAB> <TAB> <TAB> arch_version = ""."". join ( arch_version. split ( ""."" ) [ : 2 ] ) <TAB> <TAB> else : <TAB> <TAB> <TAB> arch_version = ""???"" <TAB> <TAB> <TAB> arch_url = """" <TAB> <TAB> if is_maybe_newer ( arch_version, version ) : <TAB> <TAB> <TAB> print ( ""%-30s %-20s %-20s %s"" % ( name, version, arch_version, arch_url ) )",True,arch_name in arch_versions,arch_name in arch_versions,0.6474865674972534
|
||
|
2406,"def load_template ( self, template_path, template_type ) : <TAB> """"""Load a package info template in Info.plist or PackageInfo format."""""" <TAB> if template_path. endswith ( "".plist"" ) : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> with open ( self. env [ ""template_path"" ], ""rb"" ) as f : <TAB> <TAB> <TAB> <TAB> info = plistlib. load ( f ) <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> raise ProcessorError ( <TAB> <TAB> <TAB> <TAB> f""Malformed Info.plist template {self.env['template_path']}"" <TAB> <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return info <TAB> <TAB> else : <TAB> <TAB> <TAB> return self. convert_bundle_info_to_flat ( info ) <TAB> else : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> info = ElementTree. parse ( template_path ) <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> raise ProcessorError ( <TAB> <TAB> <TAB> <TAB> f""Malformed PackageInfo template {self.env['template_path']}"" <TAB> <TAB> <TAB> ) <TAB> <TAB> if template_type == ""flat"" : <TAB> <TAB> <TAB> return info <TAB> <TAB> else : <TAB> <TAB> <TAB> return self. convert_flat_info_to_bundle ( info )",True,template_type == 'bundle',template_type == 'bundle',0.6578556299209595
|
||
|
2407,"def get_common_timezones ( ) -> Dict [ str, Union [ int, Any ] ] : <TAB> tzdata = { } <TAB> normal = datetime. datetime ( 2009, 9, 1 ) <TAB> for str in pytz. all_timezones : <TAB> <TAB> tz = pytz. timezone ( str ) <TAB> <TAB> timedelta = tz. utcoffset ( normal ) <TAB> <TAB> if not timedelta : <TAB> <TAB> <TAB> continue <TAB> <TAB> offset = timedelta. seconds <TAB> <TAB> tz_name = tz. tzname ( normal ) <TAB> <TAB> tzdata [ tz_name ] = offset <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if tz_name == ""IST"" : <TAB> <TAB> <TAB> tzdata [ tz_name ] = 19800 <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> tzdata [ tz_name ] = - 68400 <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if tz_name == ""CST"" : <TAB> <TAB> <TAB> tzdata [ tz_name ] = - 64800 <TAB> return tzdata",False,tz_name == 'CDT',"tz_name == 'S""",0.6602140665054321
|
||
|
2408,"def do_STOU ( self, line ) : <TAB> """"""Store a file on the server with a unique name."""""" <TAB> try : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. respond ( b""450 Can't STOU while REST request is pending."" ) <TAB> <TAB> <TAB> return <TAB> <TAB> _, _file_name = os. path. split ( tempfile. NamedTemporaryFile ( ). name ) <TAB> <TAB> if line : <TAB> <TAB> <TAB> line = self. ftp_path ( line ) <TAB> <TAB> <TAB> basedir, prefix = os. path. split ( line ) <TAB> <TAB> <TAB> _file_name = ""."" + _file_name <TAB> <TAB> else : <TAB> <TAB> <TAB> basedir = self. working_dir <TAB> <TAB> <TAB> if self. config. stou_suffix : <TAB> <TAB> <TAB> <TAB> _file_name = _file_name + self. config. stou_suffix <TAB> <TAB> <TAB> if self. config. stou_prefix : <TAB> <TAB> <TAB> <TAB> _file_name = self. config. stou_prefix + _file_name <TAB> <TAB> with self. config. vfs. check_access ( path = basedir, user = self. _uid, perms = ""w"" ) : <TAB> <TAB> <TAB> self. respond ( b""150 FILE: %a"" % _file_name ) <TAB> <TAB> <TAB> self. recv_file ( os. path. join ( basedir, _file_name ), 0, cmd = ""STOR"" ) <TAB> except FSOperationNotPermitted : <TAB> <TAB> self. respond ( b""500 Operation not permitted."" )",False,self._restart_position,self.state & 32768,0.6574013829231262
|
||
|
2409,"def _read_passphrase ( self, buf, size, rwflag, userdata ) : <TAB> try : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> result = self. _passphrase ( size, rwflag, userdata ) <TAB> <TAB> else : <TAB> <TAB> <TAB> result = self. _passphrase ( rwflag ) <TAB> <TAB> if not isinstance ( result, bytes ) : <TAB> <TAB> <TAB> raise ValueError ( ""String expected"" ) <TAB> <TAB> if len ( result ) > size : <TAB> <TAB> <TAB> if self. _truncate : <TAB> <TAB> <TAB> <TAB> result = result [ : size ] <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> raise ValueError ( ""passphrase returned by callback is too long"" ) <TAB> <TAB> for i in range ( len ( result ) ) : <TAB> <TAB> <TAB> buf [ i ] = result [ i : i + 1 ] <TAB> <TAB> return len ( result ) <TAB> except Exception as e : <TAB> <TAB> self. _problems. append ( e ) <TAB> <TAB> return 0",False,self._more_args,self._passphrase,0.662316083908081
|
||
|
2410,"def get_children ( self, element_name ) : <TAB> child_spec = self. _check_valid_child ( element_name ) <TAB> if child_spec. repeated : <TAB> <TAB> return _ElementListView ( spec = child_spec, parent = self ) <TAB> else : <TAB> <TAB> for child in self. _children : <TAB> <TAB> <TAB> if child. tag == element_name : <TAB> <TAB> <TAB> <TAB> return child <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return None <TAB> <TAB> else : <TAB> <TAB> <TAB> raise RuntimeError ( <TAB> <TAB> <TAB> <TAB> ""Cannot find the non-repeated child <{}> of <{}>. "" <TAB> <TAB> <TAB> <TAB> ""This should never happen, as we pre-create these in __init__. "" <TAB> <TAB> <TAB> <TAB> ""Please file an bug report. Thank you."". format ( <TAB> <TAB> <TAB> <TAB> <TAB> element_name, self. _spec. name <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> )",False,child_spec.on_demand,child.tag == element_name,0.6486592292785645
|
||
|
2411,"def _get_field_value ( self, test, key, match ) : <TAB> if test. ver == ofproto_v1_0. OFP_VERSION : <TAB> <TAB> members = inspect. getmembers ( match ) <TAB> <TAB> for member in members : <TAB> <TAB> <TAB> if member [ 0 ] == key : <TAB> <TAB> <TAB> <TAB> field_value = member [ 1 ] <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> wildcards = member [ 1 ] <TAB> <TAB> if key == ""nw_src"" : <TAB> <TAB> <TAB> field_value = test. nw_src_to_str ( wildcards, field_value ) <TAB> <TAB> elif key == ""nw_dst"" : <TAB> <TAB> <TAB> field_value = test. nw_dst_to_str ( wildcards, field_value ) <TAB> else : <TAB> <TAB> field_value = match [ key ] <TAB> return field_value",False,member[0] == 'wildcards',member[0] == match[TAB],0.6560980677604675
|
||
|
2412,"def release_dict_file ( ) : <TAB> """"""Try to gather release information manually when other methods fail"""""" <TAB> data = { } <TAB> try : <TAB> <TAB> if os. path. exists ( ""/etc/lsb-release"" ) : <TAB> <TAB> <TAB> data = { } <TAB> <TAB> <TAB> with open ( ""/etc/lsb-release"" ) as f : <TAB> <TAB> <TAB> <TAB> for line in f : <TAB> <TAB> <TAB> <TAB> <TAB> key, value = line. split ( ""="", 1 ) <TAB> <TAB> <TAB> <TAB> <TAB> data [ key ] = value. strip ( ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> data = { } <TAB> <TAB> <TAB> with open ( ""/etc/redhat-release"" ) as f : <TAB> <TAB> <TAB> <TAB> distro = f. readline ( ). strip ( ) <TAB> <TAB> <TAB> import re <TAB> <TAB> <TAB> match = re. match ( r""(.*) release (.*) \((.*)\)"", distro ) <TAB> <TAB> <TAB> if match : <TAB> <TAB> <TAB> <TAB> data [ ""DISTRIB_ID"" ] = match. group ( 1 ) <TAB> <TAB> <TAB> <TAB> data [ ""DISTRIB_RELEASE"" ] = match. group ( 2 ) <TAB> <TAB> elif os. path. exists ( ""/etc/SuSE-release"" ) : <TAB> <TAB> <TAB> data = { } <TAB> <TAB> <TAB> data [ ""DISTRIB_ID"" ] = ""SUSE LINUX"" <TAB> <TAB> <TAB> with open ( ""/etc/SuSE-release"" ) as f : <TAB> <TAB> <TAB> <TAB> for line in f : <TAB> <TAB> <TAB> <TAB> <TAB> if line. startswith ( ""VERSION = "" ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> data [ ""DISTRIB_RELEASE"" ] = line [ 10 : ]. rstrip ( ) <TAB>",False,os.path.exists('/etc/redhat-release'),"os.path.exists(/etc/redhat-release"")",0.6474566459655762
|
||
|
2413,"def delete ( self, option ) : <TAB> """"""Deletes media. ""last"", ""all"" or an integer are accepted values for option"""""" <TAB> if self. whichCam ( ) == constants. Camera. Interface. GPControl : <TAB> <TAB> <TAB> <TAB> if isinstance ( option, int ) : <TAB> <TAB> <TAB> for _ in range ( option ) : <TAB> <TAB> <TAB> <TAB> return self. gpControlCommand ( ""storage/delete/"" + ""last"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return self. gpControlCommand ( ""storage/delete/"" + option ) <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> for _ in range ( option ) : <TAB> <TAB> <TAB> <TAB> return self. sendCamera ( ""DL"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if option == ""last"" : <TAB> <TAB> <TAB> <TAB> return self. sendCamera ( ""DL"" ) <TAB> <TAB> <TAB> if option == ""all"" : <TAB> <TAB> <TAB> <TAB> return self. sendCamera ( ""DA"" )",False,"isinstance(option, int) == True",type(option) == int,0.6565436124801636
|
||
|
2414,"def _get_daily_spot_value ( self, asset, column, dt ) : <TAB> reader = self. _get_pricing_reader ( ""daily"" ) <TAB> if column == ""last_traded"" : <TAB> <TAB> last_traded_dt = reader. get_last_traded_dt ( asset, dt ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return pd. NaT <TAB> <TAB> else : <TAB> <TAB> <TAB> return last_traded_dt <TAB> elif column in OHLCV_FIELDS : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> return reader. get_value ( asset, dt, column ) <TAB> <TAB> except NoDataOnDate : <TAB> <TAB> <TAB> return np. nan <TAB> elif column == ""price"" : <TAB> <TAB> found_dt = dt <TAB> <TAB> while True : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> value = reader. get_value ( asset, found_dt, ""close"" ) <TAB> <TAB> <TAB> <TAB> if not isnull ( value ) : <TAB> <TAB> <TAB> <TAB> <TAB> if dt == found_dt : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return value <TAB> <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return self. get_adjusted_value ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> asset, column, found_dt, dt, ""minute"", spot_value = value <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> found_dt -= self. trading_calendar. day <TAB> <TAB> <TAB> except NoDataOnDate :",False,isnull(last_traded_dt),last_traded_dt is not None,0.6548629403114319
|
||
|
2415,"def get_conditions ( filters ) : <TAB> conditions = { ""docstatus"" : ( ""="", 1 ) } <TAB> if filters. get ( ""from_date"" ) and filters. get ( ""to_date"" ) : <TAB> <TAB> conditions [ ""result_date"" ] = ( <TAB> <TAB> <TAB> ""between"", <TAB> <TAB> <TAB> ( filters. get ( ""from_date"" ), filters. get ( ""to_date"" ) ), <TAB> <TAB> ) <TAB> <TAB> filters. pop ( ""from_date"" ) <TAB> <TAB> filters. pop ( ""to_date"" ) <TAB> for key, value in filters. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> conditions [ key ] = value <TAB> return conditions",False,filters.get(key),value,0.6526401042938232
|
||
|
2416,"def gen_code ( self, phase = ""test"" ) : <TAB> self. phase = phase <TAB> self. add_body ( 0, self. header_code ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for layer in self. IR_graph. topological_sort : <TAB> <TAB> current_node = self. IR_graph. get_node ( layer ) <TAB> <TAB> node_type = current_node. type <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> func = getattr ( self, ""emit_"" + node_type ) <TAB> <TAB> <TAB> func ( current_node ) <TAB> <TAB> else : <TAB> <TAB> <TAB> print ( ""CaffeEmitter has not supported operator [%s]."" % ( node_type ) ) <TAB> <TAB> <TAB> self. emit_UNKNOWN ( current_node ) <TAB> self. add_body ( 0, """" ) <TAB> self. add_body ( 0, self. end_code ) <TAB> return self. body_code",False,"hasattr(self, 'emit_' + node_type)",node_type != 'const',0.6518499255180359
|
||
|
2417,"def fit ( self ) : <TAB> print ( ""Start training..."" ) <TAB> train_acc = 0.0 <TAB> for i in range ( self. max_epoch ) : <TAB> <TAB> train_loss, train_acc = self. _train_step ( ) <TAB> <TAB> if self. device!= ""cpu"" : <TAB> <TAB> <TAB> torch. cuda. empty_cache ( ) <TAB> <TAB> print ( f""#epoch {i} : train_loss: {train_loss}, train_acc: {train_acc}"" ) <TAB> if not self. output_model_file == """" : <TAB> <TAB> if not os. path. exists ( ""./saved"" ) : <TAB> <TAB> <TAB> os. mkdir ( ""./saved"" ) <TAB> <TAB> if isinstance ( self. model, GNNPred ) : <TAB> <TAB> <TAB> model = self. model. gnn <TAB> <TAB> else : <TAB> <TAB> <TAB> model = self. model <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> torch. save ( model. state_dict ( ), self. output_model_file + ""_ft.pth"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> torch. save ( model. state_dict ( ), self. output_model_file + "".pth"" ) <TAB> return dict ( Acc = train_acc. item ( ) )",False,self.finetune,self.model.model_type == 'NHWC',0.6575861573219299
|
||
|
2418,"def annotation_specific ( self, mode, annotation_type, chapter, cursor_position ) : <TAB> try : <TAB> <TAB> chapter_annotations = self. pw. annotation_dict [ chapter ] <TAB> except KeyError : <TAB> <TAB> return False <TAB> for i in chapter_annotations : <TAB> <TAB> if annotation_type == ""text"" : <TAB> <TAB> <TAB> cursor_start = i [ ""cursor"" ] [ 0 ] <TAB> <TAB> <TAB> cursor_end = i [ ""cursor"" ] [ 1 ] <TAB> <TAB> <TAB> if cursor_start <= cursor_position <= cursor_end : <TAB> <TAB> <TAB> <TAB> if mode == ""check"" : <TAB> <TAB> <TAB> <TAB> <TAB> return True <TAB> <TAB> <TAB> <TAB> if mode == ""delete"" : <TAB> <TAB> <TAB> <TAB> <TAB> self. pw. annotation_dict [ chapter ]. remove ( i ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> note = i [ ""note"" ] <TAB> <TAB> <TAB> <TAB> <TAB> self. pw. parent. annotationNoteDock. set_annotation ( i ) <TAB> <TAB> <TAB> <TAB> <TAB> self. pw. parent. annotationNoteEdit. setText ( note ) <TAB> <TAB> <TAB> <TAB> <TAB> self. pw. parent. annotationNoteDock. show ( ) <TAB> <TAB> if mode == ""check"" : <TAB> <TAB> return False <TAB> if mode == ""delete"" : <TAB> <TAB> scroll_position = self. pw. verticalScrollBar ( ). value ( ) <TAB> <TAB> self. clear_annotations ( ) <TAB> <TAB> self. load_annotations ( chapter ) <TAB> <TAB> self. pw. verticalScrollBar ( ). setValue ( scroll_position )",False,mode == 'note','note' in i,0.6607382297515869
|
||
|
2419,"def _parse_vhosts ( details ) : <TAB> for service_alias, attr in details. iteritems ( ) : <TAB> <TAB> virtual_host_str = attr [ ""virtual_host_str"" ] = attr [ ""virtual_host"" ] <TAB> <TAB> parsed_virtual_host = [ ] <TAB> <TAB> if virtual_host_str : <TAB> <TAB> <TAB> for h in [ h. strip ( ) for h in virtual_host_str. strip ( ). split ( "","" ) ] : <TAB> <TAB> <TAB> <TAB> pr = urlparse. urlparse ( h ) <TAB> <TAB> <TAB> <TAB> if not pr. netloc : <TAB> <TAB> <TAB> <TAB> <TAB> pr = urlparse. urlparse ( ""http://%s"" % h ) <TAB> <TAB> <TAB> <TAB> port = ""443"" if pr. scheme. lower ( ) in [ ""https"", ""wss"" ] else ""80"" <TAB> <TAB> <TAB> <TAB> host = pr. netloc <TAB> <TAB> <TAB> <TAB> if "":"" in pr. netloc : <TAB> <TAB> <TAB> <TAB> <TAB> host_port = pr. netloc. split ( "":"" ) <TAB> <TAB> <TAB> <TAB> <TAB> host = host_port [ 0 ] <TAB> <TAB> <TAB> <TAB> <TAB> port = host_port [ 1 ] <TAB> <TAB> <TAB> <TAB> parsed_virtual_host. append ( <TAB> <TAB> <TAB> <TAB> <TAB> { ""scheme"" : pr. scheme, ""host"" : host, ""port"" : port, ""path"" : pr. path } <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> details [ service_alias ] [ ""virtual_host"" ] = parsed_virtual_host <TAB> vhosts = [ ] <TAB> for service_alias, attr in details. iteritems ( ) : <TAB> <TAB> virtual_hosts = attr [ ""virtual_host"" ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> for v in virtual_hosts : <TAB>",True,virtual_hosts,virtual_hosts,0.666537880897522
|
||
|
2420,"def func ( x, y ) : <TAB> try : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> z = x + 2 * math. sin ( y ) <TAB> <TAB> <TAB> return z ** 2 <TAB> <TAB> elif x == y : <TAB> <TAB> <TAB> return 4 <TAB> <TAB> else : <TAB> <TAB> <TAB> return 2 ** 3 <TAB> except ValueError : <TAB> <TAB> foo = 0 <TAB> <TAB> for i in range ( 4 ) : <TAB> <TAB> <TAB> foo += i <TAB> <TAB> return foo <TAB> except TypeError : <TAB> <TAB> return 42 <TAB> else : <TAB> <TAB> return 33 <TAB> finally : <TAB> <TAB> print ( ""finished"" )",False,x > y,"isinstance(x, float) and isinstance(y, int)",0.6868847608566284
|
||
|
2421,"def get_string_width ( self, s ) : <TAB> ""Get width of a string in the current font"" <TAB> s = self. normalize_text ( s ) <TAB> cw = self. current_font [ ""cw"" ] <TAB> w = 0 <TAB> l = len ( s ) <TAB> if self. unifontsubset : <TAB> <TAB> for char in s : <TAB> <TAB> <TAB> char = ord ( char ) <TAB> <TAB> <TAB> if len ( cw ) > char : <TAB> <TAB> <TAB> <TAB> w += cw [ char ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> w += self. current_font [ ""desc"" ] [ ""MissingWidth"" ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> w += 500 <TAB> else : <TAB> <TAB> for i in range ( 0, l ) : <TAB> <TAB> <TAB> w += cw. get ( s [ i ], 0 ) <TAB> if self. font_stretching!= 100 : <TAB> <TAB> w = w * self. font_stretching / 100.0 <TAB> return w * self. font_size / 1000.0",False,self.current_font['desc']['MissingWidth'],l > 0,0.6554661989212036
|
||
|
2422,"def editSize ( self, rpcObjects = None ) : <TAB> subs = self. _getSelected ( rpcObjects ) <TAB> if subs : <TAB> <TAB> current = max ( [ sub. data. size for sub in subs ] ) <TAB> <TAB> title = ""Edit Subscription Size"" <TAB> <TAB> body = ( <TAB> <TAB> <TAB> ""Please enter the new subscription size value:\nThis "" <TAB> <TAB> <TAB> ""should only be changed by administrators.\nPlease "" <TAB> <TAB> <TAB> ""contact the resource department."" <TAB> <TAB> ) <TAB> <TAB> minSize = 0 <TAB> <TAB> decimalPlaces = 0 <TAB> <TAB> ( value, choice ) = QtWidgets. QInputDialog. getDouble ( <TAB> <TAB> <TAB> self. _caller, <TAB> <TAB> <TAB> title, <TAB> <TAB> <TAB> body, <TAB> <TAB> <TAB> current / 100.0, <TAB> <TAB> <TAB> minSize, <TAB> <TAB> <TAB> cuegui. Constants. QT_MAX_INT, <TAB> <TAB> <TAB> decimalPlaces, <TAB> <TAB> ) <TAB> <TAB> if choice : <TAB> <TAB> <TAB> msg = QtWidgets. QMessageBox ( ) <TAB> <TAB> <TAB> msg. setText ( <TAB> <TAB> <TAB> <TAB> ""You are about to modify a number that can affect a show's billing. Are you "" <TAB> <TAB> <TAB> <TAB> ""sure you want to do this?"" <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> msg. setStandardButtons ( QtWidgets. QMessageBox. Yes | QtWidgets. QMessageBox. No ) <TAB> <TAB> <TAB> msg. setDefaultButton ( QtWidgets. QMessageBox. No ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> for sub in subs : <TAB> <TAB> <TAB> <TAB> self. cuebotCall ( <TAB> <TAB> <TAB> <TAB> <TAB> sub. setSize",False,msg.exec_() == QtWidgets.QMessageBox.No,self.clanDialog,0.6532444357872009
|
||
|
2423,"def init_environment ( installdir ) : <TAB> <TAB> env_config_file = os. path. join ( installdir, ""environ.ini"" ) <TAB> if os. path. exists ( env_config_file ) : <TAB> <TAB> import configparser <TAB> <TAB> env_config = configparser. ConfigParser ( <TAB> <TAB> <TAB> allow_no_value = True, interpolation = configparser. ExtendedInterpolation ( ) <TAB> <TAB> ) <TAB> <TAB> env_config. optionxform = lambda option : option <TAB> <TAB> env_config [ ""DEFAULT"" ]. update ( <TAB> <TAB> <TAB> ( k, v. replace ( ""$"", ""$$"" ) ) for k, v in os. environ. items ( ) <TAB> <TAB> ) <TAB> <TAB> env_config. read ( env_config_file ) <TAB> <TAB> for k, v in env_config [ ""Environment"" ]. items ( ) : <TAB> <TAB> <TAB> os. environ [ k ] = _parse_environment_param ( v, installdir ) <TAB> <TAB> data_dir = os. path. normpath ( os. path. join ( installdir, ""share"" ) ) <TAB> if os. path. exists ( data_dir ) : <TAB> <TAB> dirs = os. environ. get ( ""XDG_DATA_DIRS"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> os. environ [ ""XDG_DATA_DIRS"" ] = dirs + os. pathsep + data_dir <TAB> <TAB> else : <TAB> <TAB> <TAB> os. environ [ ""XDG_DATA_DIRS"" ] = data_dir",True,dirs,dirs,0.6916582584381104
|
||
|
2424,"def new_func ( self, * args, ** kwargs ) : <TAB> obj = self. obj_ref ( ) <TAB> attr = self. attr <TAB> if obj is not None : <TAB> <TAB> args = tuple ( TrackedValue. make ( obj, attr, arg ) for arg in args ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> kwargs = { <TAB> <TAB> <TAB> <TAB> key : TrackedValue. make ( obj, attr, value ) <TAB> <TAB> <TAB> <TAB> for key, value in iteritems ( kwargs ) <TAB> <TAB> <TAB> } <TAB> result = func ( self, * args, ** kwargs ) <TAB> self. _changed_ ( ) <TAB> return result",False,kwargs,len(kwargs),0.6956216096878052
|
||
|
2425,"def _run_somatic ( paired, ref_file, assoc_files, region, out_file, work_dir ) : <TAB> if not utils. file_exists ( out_file ) : <TAB> <TAB> with file_transaction ( paired. tumor_data, work_dir ) as tx_work_dir : <TAB> <TAB> <TAB> workflow_file = _configure_somatic ( <TAB> <TAB> <TAB> <TAB> paired, ref_file, region, out_file, tx_work_dir <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> has_variants = True <TAB> <TAB> <TAB> <TAB> _run_workflow ( paired. tumor_data, workflow_file, tx_work_dir ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> has_variants = False <TAB> <TAB> <TAB> <TAB> vcfutils. write_empty_vcf ( <TAB> <TAB> <TAB> <TAB> <TAB> out_file, <TAB> <TAB> <TAB> <TAB> <TAB> paired. tumor_data [ ""config"" ], <TAB> <TAB> <TAB> <TAB> <TAB> [ <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> dd. get_sample_name ( d ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for d in [ paired. tumor_data, paired. normal_data ] <TAB> <TAB> <TAB> <TAB> <TAB> ], <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> if has_variants : <TAB> <TAB> <TAB> var_dir = os. path. join ( work_dir, ""results"", ""variants"" ) <TAB> <TAB> <TAB> vcfutils. combine_variant_files ( <TAB> <TAB> <TAB> <TAB> [ <TAB> <TAB> <TAB> <TAB> <TAB> _postprocess_somatic ( os. path. join ( var_dir, f ), paired ) <TAB> <TAB>",False,workflow_file,paired.has_sample_name,0.6739505529403687
|
||
|
2426,"def _invoke_async_task ( invocation, planner ) : <TAB> job_id = ""%016x"" % random. randint ( 0, 2 ** 64 ) <TAB> context = invocation. connection. spawn_isolated_child ( ) <TAB> _propagate_deps ( invocation, planner, context ) <TAB> with mitogen. core. Receiver ( context. router ) as started_recv : <TAB> <TAB> call_recv = context. call_async ( <TAB> <TAB> <TAB> ansible_mitogen. target. run_module_async, <TAB> <TAB> <TAB> job_id = job_id, <TAB> <TAB> <TAB> timeout_secs = invocation. timeout_secs, <TAB> <TAB> <TAB> started_sender = started_recv. to_sender ( ), <TAB> <TAB> <TAB> kwargs = planner. get_kwargs ( ), <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for msg in mitogen. select. Select ( [ started_recv, call_recv ] ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> raise msg. unpickle ( ) <TAB> <TAB> <TAB> break <TAB> <TAB> return { <TAB> <TAB> <TAB> ""stdout"" : json. dumps ( <TAB> <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""changed"" : True, <TAB> <TAB> <TAB> <TAB> <TAB> ""started"" : 1, <TAB> <TAB> <TAB> <TAB> <TAB> ""finished"" : 0, <TAB> <TAB> <TAB> <TAB> <TAB> ""ansible_job_id"" : job_id, <TAB> <TAB> <TAB> <TAB> } <TAB> <TAB> <TAB> ) <TAB> <TAB> }",False,msg.receiver is call_recv,"hasattr(msg, 'unpickle')",0.6591400504112244
|
||
|
2427,"def onMESSAGE ( self, hwnd, msg, wp, lp ) : <TAB> if msg == fw. WND_WM_NOTIFY : <TAB> <TAB> if wp == fw. WND_NM_MSGREFLECT : <TAB> <TAB> <TAB> msgr = fw. WND_MSGREFLECT. from_address ( lp ) <TAB> <TAB> <TAB> msgr. fReturn = self. _base_fMsgReflect <TAB> <TAB> <TAB> if msgr. msg == self. Msg. WM_HSCROLL : <TAB> <TAB> <TAB> <TAB> return self. _base_HandleScroll ( hwnd, msgr. msg, msgr. wParam, msgr. lParam ) <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> return self. _base_HandleScroll ( hwnd, msgr. msg, msgr. wParam, msgr. lParam ) <TAB> <TAB> return 0 <TAB> elif msg == self. Msg. WM_DESTROY : <TAB> <TAB> self. onMSG ( hwnd, ""destroy"", 0, 0 )",False,msgr.msg == self.Msg.WM_VSCROLL,msgr.msg == self.Msg.WM_SCROLL,0.6620676517486572
|
||
|
2428,"def __getitem__ ( self, index ) : <TAB> img = Image. open ( self. images [ index ] ). convert ( ""RGB"" ) <TAB> if self. mode == ""test"" : <TAB> <TAB> img = self. _img_transform ( img ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> img = self. transform ( img ) <TAB> <TAB> return img, os. path. basename ( self. images [ index ] ) <TAB> mask = Image. open ( self. masks [ index ] ) <TAB> <TAB> if self. mode == ""train"" : <TAB> <TAB> img, mask = self. _sync_transform ( img, mask ) <TAB> elif self. mode == ""val"" : <TAB> <TAB> img, mask = self. _val_sync_transform ( img, mask ) <TAB> else : <TAB> <TAB> assert self. mode == ""testval"" <TAB> <TAB> img, mask = self. _img_transform ( img ), self. _mask_transform ( mask ) <TAB> <TAB> if<mask> : <TAB> <TAB> img = self. transform ( img ) <TAB> return img, mask",False,self.transform is not None,self.mode == 'extract',0.651931881904602
|
||
|
2429,"def _v2_common ( self, cfg ) : <TAB> LOG. debug ( ""v2_common: handling config:\n%s"", cfg ) <TAB> if ""nameservers"" in cfg : <TAB> <TAB> search = cfg. get ( ""nameservers"" ). get ( ""search"", [ ] ) <TAB> <TAB> dns = cfg. get ( ""nameservers"" ). get ( ""addresses"", [ ] ) <TAB> <TAB> name_cmd = { ""type"" : ""nameserver"" } <TAB> <TAB> if len ( search ) > 0 : <TAB> <TAB> <TAB> name_cmd. update ( { ""search"" : search } ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> name_cmd. update ( { ""addresses"" : dns } ) <TAB> <TAB> LOG. debug ( ""v2(nameserver) -> v1(nameserver):\n%s"", name_cmd ) <TAB> <TAB> self. handle_nameserver ( name_cmd )",True,len(dns) > 0,len(dns) > 0,0.655834436416626
|
||
|
2430,"def parse_key_equal_value ( text ) : <TAB> """"""Parse a string of the form 'key1=value1 key2=value2'"""""" <TAB> <TAB> text = text. strip ( ) <TAB> if not text : <TAB> <TAB> return { } <TAB> last_space_pos = text. rfind ( "" "" ) <TAB> <TAB> if not text. startswith ( ""--"" ) and isidentifier ( text [ last_space_pos + 1 : ] ) : <TAB> <TAB> key = text [ last_space_pos + 1 : ] <TAB> <TAB> value = None <TAB> <TAB> result = { key : value } <TAB> <TAB> if last_space_pos > 0 : <TAB> <TAB> <TAB> result. update ( parse_key_equal_value ( text [ : last_space_pos ] ) ) <TAB> <TAB> return result <TAB> <TAB> equal_sign_pos = None <TAB> while True : <TAB> <TAB> equal_sign_pos = text. rfind ( ""="", None, equal_sign_pos ) <TAB> <TAB> if equal_sign_pos < 0 : <TAB> <TAB> <TAB> return incorrectly_encoded_metadata ( text ) <TAB> <TAB> <TAB> <TAB> prev_whitespace = text [ : equal_sign_pos ]. rstrip ( ). rfind ( "" "" ) <TAB> <TAB> key = text [ prev_whitespace + 1 : equal_sign_pos ]. strip ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> try : <TAB> <TAB> <TAB> value = relax_json_loads ( text [ equal_sign_pos + 1 : ] ) <TAB> <TAB> except ( ValueError, SyntaxError ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> metadata = ( <TAB> <TAB> <TAB> parse_key_equal_value ( text [ : prev_whitespace ] ) if prev_whitespace > 0 else { } <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> metadata [ key ] = value <TAB",False,"not isidentifier(key.replace('.', ''))",equal_sign_pos < 0,0.6539162397384644
|
||
|
2431,"def generate ( self, dest, vars ) : <TAB> util. ensure_dir ( dest ) <TAB> for relpath, src, template in self. _file_templates : <TAB> <TAB> file_dest = os. path. join ( dest, relpath ) <TAB> <TAB> util. ensure_dir ( os. path. dirname ( file_dest ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> shutil. copyfile ( src, file_dest ) <TAB> <TAB> else : <TAB> <TAB> <TAB> _render_template ( template, vars, file_dest )",False,template is None,os.path.isfile(src),0.659921407699585
|
||
|
2432,"def parse_resources ( resources_args, fallback = None ) : <TAB> """"""Parse resources from args."""""" <TAB> resources = dict ( ) <TAB> if resources_args is not None : <TAB> <TAB> valid = re. compile ( r""[a-zA-Z_]\w*$"" ) <TAB> <TAB> for res in resources_args : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> res, val = res. split ( ""="" ) <TAB> <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> <TAB> raise ValueError ( ""Resources have to be defined as name=value pairs."" ) <TAB> <TAB> <TAB> if not valid. match ( res ) : <TAB> <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Resource definition must start with a valid identifier."" <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> val = int ( val ) <TAB> <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> val = fallback ( val ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""Resource definiton must contain an integer after the identifier."" <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if res == ""_cores"" : <TAB> <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Resource _cores is already defined internally. Use a different name."" <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> resources [ res ] = val <TAB> return resources",False,fallback is not None,fallback,0.6737782955169678
|
||
|
2433,"def _read_value ( self, item ) : <TAB> item = _normalize_path ( item ) <TAB> if item in self. _store : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> del self. _store [ item ] <TAB> <TAB> <TAB> raise KeyError ( item ) <TAB> <TAB> return PathResult ( item, value = self. _store [ item ] ) <TAB> elif item in self. _children : <TAB> <TAB> return PathResult ( item, dir = True ) <TAB> else : <TAB> <TAB> raise KeyError ( item )",False,item in self._expire_time and self._expire_time[item] < datetime.now(),self._children[item],0.6545792818069458
|
||
|
2434,"def splitwords ( str, minlength ) : <TAB> words = [ ] <TAB> i = 0 <TAB> n = len ( str ) <TAB> while i < n : <TAB> <TAB> while i < n and str [ i ] in "" \t\n"" : <TAB> <TAB> <TAB> i = i + 1 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> break <TAB> <TAB> start = i <TAB> <TAB> i = findwordend ( str, i, n ) <TAB> <TAB> words. append ( str [ start : i ] ) <TAB> while len ( words ) < minlength : <TAB> <TAB> words. append ( """" ) <TAB> return words",False,i >= n,i == n,0.689909815788269
|
||
|
2435,"def _strided_slice_shape_func_input_shape ( data_shape, begin, end, strides, slice_mode ) : <TAB> ndim = data_shape. shape [ 0 ] <TAB> out = output_tensor ( ( ndim, ), ""int64"" ) <TAB> for i in const_range ( ndim ) : <TAB> <TAB> cbegin = int64 ( 0 ) <TAB> <TAB> cend = int64 ( data_shape [ i ] ) <TAB> <TAB> cstride = int64 ( 1 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> cstride = int64 ( strides [ i ] ) <TAB> <TAB> if len ( begin ) > i : <TAB> <TAB> <TAB> cbegin = int64 ( begin [ i ] ) <TAB> <TAB> <TAB> if cbegin < 0 : <TAB> <TAB> <TAB> <TAB> cbegin += int64 ( data_shape [ i ] ) <TAB> <TAB> if len ( end ) <= i : <TAB> <TAB> <TAB> cend = int64 ( data_shape [ i ] ) <TAB> <TAB> elif slice_mode!= 0 : <TAB> <TAB> <TAB> cstride = int64 ( 1 ) <TAB> <TAB> <TAB> if end [ i ] < 0 : <TAB> <TAB> <TAB> <TAB> cend = int64 ( data_shape [ i ] ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> cend = cbegin + int64 ( end [ i ] ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if end [ i ] > data_shape [ i ] : <TAB> <TAB> <TAB> <TAB> cend = int64 ( data_shape [ i ] ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> cend = int64 ( end [ i ] ) <TAB> <TAB> <TAB> <TAB> if cend < 0 : <TAB> <TAB> <TAB> <TAB> <TAB> cend += int64 ( data_shape [ i ] ) <TAB> <TAB",False,len(strides) > i,stride != None,0.6640341281890869
|
||
|
2436,"def remove_dot_segments ( path ) : <TAB> r = [ ] <TAB> while path : <TAB> <TAB> <TAB> <TAB> if path. startswith ( ""../"" ) : <TAB> <TAB> <TAB> path = path [ 3 : ] <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> path = path [ 2 : ] <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> if path. startswith ( ""/./"" ) : <TAB> <TAB> <TAB> path = path [ 2 : ] <TAB> <TAB> <TAB> continue <TAB> <TAB> if path == ""/."" : <TAB> <TAB> <TAB> path = ""/"" <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> if path. startswith ( ""/../"" ) : <TAB> <TAB> <TAB> path = path [ 3 : ] <TAB> <TAB> <TAB> if r : <TAB> <TAB> <TAB> <TAB> r. pop ( ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if path == ""/.."" : <TAB> <TAB> <TAB> path = ""/"" <TAB> <TAB> <TAB> if r : <TAB> <TAB> <TAB> <TAB> r. pop ( ) <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> if path == ""."" : <TAB> <TAB> <TAB> path = path [ 1 : ] <TAB> <TAB> <TAB> continue <TAB> <TAB> if path == "".."" : <TAB> <TAB> <TAB> path = path [ 2 : ] <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> start = 0 <TAB> <TAB> if path. startswith ( ""/"" ) : <TAB> <TAB> <TAB> start = 1 <TAB> <TAB> ii = path. find ( ""/"", start ) <TAB> <TAB> if ii < 0 : <TAB> <TAB> <TAB> ii = None <TAB> <TAB> r. append ( path [ : ii ] ) <TAB> <TAB>",False,path.startswith('./'),"path.startswith(../"")",0.6520379185676575
|
||
|
2437,"def PyJsHoisted__interopRequireWildcard_ ( obj, this, arguments, var = var ) : <TAB> var = Scope ( { u""this"" : this, u""obj"" : obj, u""arguments"" : arguments }, var ) <TAB> var. registers ( [ u""obj"", u""key"", u""newObj"" ] ) <TAB> if var. get ( u""obj"" ) and var. get ( u""obj"" ). get ( u""__esModule"" ) : <TAB> <TAB> return var. get ( u""obj"" ) <TAB> else : <TAB> <TAB> PyJs_Object_842_ = Js ( { } ) <TAB> <TAB> var. put ( u""newObj"", PyJs_Object_842_ ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> for PyJsTemp in var. get ( u""obj"" ) : <TAB> <TAB> <TAB> <TAB> var. put ( u""key"", PyJsTemp ) <TAB> <TAB> <TAB> <TAB> if ( <TAB> <TAB> <TAB> <TAB> <TAB> var. get ( u""Object"" ) <TAB> <TAB> <TAB> <TAB> <TAB>. get ( u""prototype"" ) <TAB> <TAB> <TAB> <TAB> <TAB>. get ( u""hasOwnProperty"" ) <TAB> <TAB> <TAB> <TAB> <TAB>. callprop ( u""call"", var. get ( u""obj"" ), var. get ( u""key"" ) ) <TAB> <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> <TAB> var. get ( u""newObj"" ). put ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> var. get ( u""key"" ), var. get ( u""obj"" ). get ( var. get ( u""key"" ) ) <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> var. get ( u""newObj"" ). put ( u""default"", var. get ( u""obj"" ) ) <",False,var.get(u'obj') != var.get(u'null'),PYJsHoisted__.has_wildcard_(),0.6511889696121216
|
||
|
2438,"def _validate_options ( self ) : <TAB> for option in self. options : <TAB> <TAB> <TAB> <TAB> if not type ( self. options [ option ] ) in [ bool, int ] : <TAB> <TAB> <TAB> if self. options. required [ option ] is True and not self. options [ option ] : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> option = ""password"". upper ( ) <TAB> <TAB> <TAB> <TAB> raise FrameworkException ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Value required for the '%s' option."" % ( option. upper ( ) ) <TAB> <TAB> <TAB> <TAB> ) <TAB> return",False,option == Constants.PASSWORD_CLEAR,self.options.required[option] is False,0.662002682685852
|
||
|
2439,"def iterscan ( self, string, idx = 0, context = None ) : <TAB> """"""Yield match, end_idx for each match"""""" <TAB> match = self. scanner. scanner ( string, idx ). match <TAB> actions = self. actions <TAB> lastend = idx <TAB> end = len ( string ) <TAB> while True : <TAB> <TAB> m = match ( ) <TAB> <TAB> if m is None : <TAB> <TAB> <TAB> break <TAB> <TAB> matchbegin, matchend = m. span ( ) <TAB> <TAB> if lastend == matchend : <TAB> <TAB> <TAB> break <TAB> <TAB> action = actions [ m. lastindex ] <TAB> <TAB> if action is not None : <TAB> <TAB> <TAB> rval, next_pos = action ( m, context ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> matchend = next_pos <TAB> <TAB> <TAB> <TAB> match = self. scanner. scanner ( string, matchend ). match <TAB> <TAB> <TAB> yield rval, matchend <TAB> <TAB> lastend = matchend",False,next_pos is not None and next_pos != matchend,next_pos is not None,0.6482467651367188
|
||
|
2440,"def from_darknet ( self ) : <TAB> """"""To convert the darknet symbol to relay functions."""""" <TAB> for i in range ( self. _net. n ) : <TAB> <TAB> layer = self. _net. layers [ i ] <TAB> <TAB> need_skip, sym = self. _preproc_layer ( layer, i ) <TAB> <TAB> if need_skip : <TAB> <TAB> <TAB> continue <TAB> <TAB> processed, sym = self. _handle_darknet_rnn_layers ( i, sym ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> attr = self. _get_darknet_attrs ( layer, i ) <TAB> <TAB> op_name = self. _get_opname ( layer ) <TAB> <TAB> prefix = _get_params_prefix ( op_name, i ) <TAB> <TAB> params = self. _get_darknet_params ( self. _net. layers [ i ], prefix ) <TAB> <TAB> sym = _darknet_convert_symbol ( op_name, _as_list ( sym ), params, attr, prefix ) <TAB> <TAB> if params : <TAB> <TAB> <TAB> self. _tvmparams. update ( params ) <TAB> <TAB> self. _sym_array [ i ] = sym <TAB> <TAB> self. _make_outlist ( sym, prefix, layer, i ) <TAB> outputs = _as_list ( sym ) + self. _outs <TAB> outputs = outputs [ 0 ] if len ( outputs ) == 1 else _expr. Tuple ( outputs ) <TAB> sym = _function. Function ( analysis. free_vars ( outputs ), outputs ) <TAB> return IRModule. from_expr ( sym ), self. _tvmparams",True,processed,processed,0.7120829820632935
|
||
|
2441,"def load_weights_from_unsupervised ( self, unsupervised_model ) : <TAB> update_state_dict = copy. deepcopy ( self. network. state_dict ( ) ) <TAB> for param, weights in unsupervised_model. network. state_dict ( ). items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> new_param = ""tabnet."" + param <TAB> <TAB> else : <TAB> <TAB> <TAB> new_param = param <TAB> <TAB> if self. network. state_dict ( ). get ( new_param ) is not None : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> update_state_dict [ new_param ] = weights <TAB> self. network. load_state_dict ( update_state_dict )",False,param.startswith('encoder'),"isinstance(param, str)",0.6528903245925903
|
||
|
2442,"def is_key_allowed_v1 ( <TAB> self, <TAB> api_resource : str, <TAB> api_operation : str, <TAB> api_name : str, <TAB> extra_data : Optional [ Dict [ str, Any ] ] = None, ) -> bool : <TAB> """"""Checks if a key is allowed with v1 permissions"""""" <TAB> allowed = self. permissions_document [ ""default_allow"" ] <TAB> <TAB> try : <TAB> <TAB> validation_function = ENDPOINT_MAP [ api_name ] <TAB> except Exception : <TAB> <TAB> <TAB> <TAB> _log. exception ( f""Error api_name {api_name} is wrong. This should never happen!"" ) <TAB> <TAB> raise RuntimeError ( f""'{api_name}' is not a valid know api_name"" ) <TAB> <TAB> group_allow = _process_api_resource ( <TAB> <TAB> self. permissions_document [ ""permissions"" ], api_operation <TAB> ) <TAB> if group_allow is not None : <TAB> <TAB> allowed = group_allow <TAB> <TAB> api_resource_permissions = self. permissions_document [ ""permissions"" ]. get ( <TAB> <TAB> api_resource <TAB> ) <TAB> if api_resource_permissions : <TAB> <TAB> group_allow = _process_api_resource ( api_resource_permissions, api_operation ) <TAB> <TAB> if group_allow is not None : <TAB> <TAB> <TAB> allowed = group_allow <TAB> <TAB> <TAB> <TAB> api_name_permissions = api_resource_permissions. get ( api_name ) <TAB> <TAB> if api_name_permissions : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> endpoint_allow = validation_function ( api_name_permissions, extra_data ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> allowed = endpoint_allow <TAB> return allowed",True,endpoint_allow is not None,endpoint_allow is not None,0.6556025743484497
|
||
|
2443,"def _serialize ( self, value, attr, obj ) : <TAB> usages = value. _usages <TAB> usage_list = { } <TAB> for usage in usages : <TAB> <TAB> if usage == x509. oid. ExtendedKeyUsageOID. CLIENT_AUTH : <TAB> <TAB> <TAB> usage_list [ ""useClientAuthentication"" ] = True <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> usage_list [ ""useServerAuthentication"" ] = True <TAB> <TAB> elif usage == x509. oid. ExtendedKeyUsageOID. CODE_SIGNING : <TAB> <TAB> <TAB> usage_list [ ""useCodeSigning"" ] = True <TAB> <TAB> elif usage == x509. oid. ExtendedKeyUsageOID. EMAIL_PROTECTION : <TAB> <TAB> <TAB> usage_list [ ""useEmailProtection"" ] = True <TAB> <TAB> elif usage == x509. oid. ExtendedKeyUsageOID. TIME_STAMPING : <TAB> <TAB> <TAB> usage_list [ ""useTimestamping"" ] = True <TAB> <TAB> elif usage == x509. oid. ExtendedKeyUsageOID. OCSP_SIGNING : <TAB> <TAB> <TAB> usage_list [ ""useOCSPSigning"" ] = True <TAB> <TAB> elif usage. dotted_string == ""1.3.6.1.5.5.7.3.14"" : <TAB> <TAB> <TAB> usage_list [ ""useEapOverLAN"" ] = True <TAB> <TAB> elif usage. dotted_string == ""1.3.6.1.5.5.7.3.13"" : <TAB> <TAB> <TAB> usage_list [ ""useEapOverPPP"" ] = True <TAB> <TAB> elif usage. dotted_string == ""1.3.6.1.4.1.311.20.2.2"" : <TAB> <TAB> <TAB> usage_list [ ""useSmartCardLogon"" ] = True <TAB> <TAB> else : <TAB> <TAB> <TAB> current_app. logger. warning ( <TAB> <TAB> <TAB> <TAB> ""Unable to serialize ExtendedKeyUsage with",True,usage == x509.oid.ExtendedKeyUsageOID.SERVER_AUTH,usage == x509.oid.ExtendedKeyUsageOID.SERVER_AUTH,0.6573565602302551
|
||
|
2444,"def realizeElementExpressions ( innerElement ) : <TAB> elementHasBeenRealized = False <TAB> for exp in innerElement. expressions : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> before, during, after = exp. realize ( innerElement ) <TAB> <TAB> elementHasBeenRealized = True <TAB> <TAB> for n in before : <TAB> <TAB> <TAB> newStream. append ( n ) <TAB> <TAB> if during is not None : <TAB> <TAB> <TAB> newStream. append ( during ) <TAB> <TAB> for n in after : <TAB> <TAB> <TAB> newStream. append ( n ) <TAB> if elementHasBeenRealized is False : <TAB> <TAB> newStream. append ( innerElement )",False,"not hasattr(exp, 'realize')","isinstance(exp, EnerElement)",0.6537826061248779
|
||
|
2445,"def parse_extra_frontend_settings ( envvars ) : <TAB> settings_dict = { } <TAB> if isinstance ( envvars, os. _Environ ) or isinstance ( envvars, dict ) : <TAB> <TAB> frontend_settings_pattern = re. compile ( r""^EXTRA_FRONTEND_SETTINGS_(\d{1,5})$"" ) <TAB> <TAB> frontend_settings_file_pattern = re. compile ( <TAB> <TAB> <TAB> r""^EXTRA_FRONTEND_SETTINGS_FILE_(\d{1,5})$"" <TAB> <TAB> ) <TAB> <TAB> for k, v in envvars. iteritems ( ) : <TAB> <TAB> <TAB> settings = [ ] <TAB> <TAB> <TAB> match = frontend_settings_pattern. match ( k ) <TAB> <TAB> <TAB> file_match = frontend_settings_file_pattern. match ( k ) <TAB> <TAB> <TAB> if match : <TAB> <TAB> <TAB> <TAB> port = match. group ( 1 ) <TAB> <TAB> <TAB> <TAB> settings. extend ( <TAB> <TAB> <TAB> <TAB> <TAB> [ <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> x. strip ( ). replace ( ""\,"", "","" ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for x in re. split ( r""(?<!\\),"", v. strip ( ) ) <TAB> <TAB> <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> elif file_match : <TAB> <TAB> <TAB> <TAB> port = file_match. group ( 1 ) <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> with open ( v ) as file : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for line in file : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> settings. append ( line. strip ( ) ) <TAB> <TAB> <TAB",False,len(settings) > 0,settings_dict,0.6594579219818115
|
||
|
2446,"def __call__ ( self, message ) : <TAB> with self. _lock : <TAB> <TAB> self. _pending_ack += 1 <TAB> <TAB> self. max_pending_ack = max ( self. max_pending_ack, self. _pending_ack ) <TAB> <TAB> self. seen_message_ids. append ( int ( message. attributes [ ""seq_num"" ] ) ) <TAB> time. sleep ( self. _processing_time ) <TAB> with self. _lock : <TAB> <TAB> self. _pending_ack -= 1 <TAB> <TAB> message. ack ( ) <TAB> <TAB> self. completed_calls += 1 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if not self. done_future. done ( ) : <TAB> <TAB> <TAB> <TAB> self. done_future. set_result ( None )",False,self.completed_calls >= self._resolve_at_msg_count,self.done_future is None,0.6495327949523926
|
||
|
2447,"def parametrize ( self, *, x, conditions ) : <TAB> log_epsilon = tf_util. constant ( value = np. log ( util. epsilon ), dtype = ""float"" ) <TAB> shape = ( - 1, ) + self. action_spec. shape <TAB> <TAB> mean = self. mean. apply ( x = x ) <TAB> if<mask> : <TAB> <TAB> mean = tf. reshape ( tensor = mean, shape = shape ) <TAB> <TAB> if self. global_stddev : <TAB> <TAB> multiples = ( tf. shape ( input = x ) [ 0 ], ) + tuple ( <TAB> <TAB> <TAB> 1 for _ in range ( self. action_spec. rank ) <TAB> <TAB> ) <TAB> <TAB> log_stddev = tf. tile ( input = self. log_stddev, multiples = multiples ) <TAB> else : <TAB> <TAB> log_stddev = self. log_stddev. apply ( x = x ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> log_stddev = tf. reshape ( tensor = log_stddev, shape = shape ) <TAB> <TAB> if ( <TAB> <TAB> self. action_spec. min_value is not None <TAB> <TAB> and self. action_spec. max_value is not None <TAB> ) : <TAB> <TAB> log_stddev += tf_util. constant ( value = np. log ( 0.1 ), dtype = ""float"" ) <TAB> <TAB> log_stddev = tf. clip_by_value ( <TAB> <TAB> t = log_stddev, clip_value_min = log_epsilon, clip_value_max = - log_epsilon <TAB> ) <TAB> <TAB> stddev = tf. math. exp ( x = log_stddev ) <TAB> return TensorDict ( mean = mean, stddev = stddev, log_stddev = log_stddev )",False,len(self.input_spec.shape) == 1,conditions,0.6470438838005066
|
||
|
2448,"def get ( self ) : <TAB> name = request. args. get ( ""filename"" ) <TAB> if name is not None : <TAB> <TAB> opts = dict ( ) <TAB> <TAB> opts [ ""type"" ] = ""episode"" <TAB> <TAB> result = guessit ( name, options = opts ) <TAB> <TAB> res = dict ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> res [ ""episode"" ] = result [ ""episode"" ] <TAB> <TAB> else : <TAB> <TAB> <TAB> res [ ""episode"" ] = 0 <TAB> <TAB> if ""season"" in result : <TAB> <TAB> <TAB> res [ ""season"" ] = result [ ""season"" ] <TAB> <TAB> else : <TAB> <TAB> <TAB> res [ ""season"" ] = 0 <TAB> <TAB> if ""subtitle_language"" in result : <TAB> <TAB> <TAB> res [ ""subtitle_language"" ] = str ( result [ ""subtitle_language"" ] ) <TAB> <TAB> return jsonify ( data = res ) <TAB> else : <TAB> <TAB> return """", 400",True,'episode' in result,'episode' in result,0.6783090233802795
|
||
|
2449,"def set_message_type_visibility ( self, message_type : MessageType ) : <TAB> try : <TAB> <TAB> rows = { <TAB> <TAB> <TAB> i <TAB> <TAB> <TAB> for i, msg in enumerate ( self. proto_analyzer. messages ) <TAB> <TAB> <TAB> if msg. message_type == message_type <TAB> <TAB> } <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. ui. tblViewProtocol. show_rows ( rows ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. ui. tblViewProtocol. hide_rows ( rows ) <TAB> except Exception as e : <TAB> <TAB> logger. exception ( e )",False,message_type.show,self.ui.is_show_rows,0.6577572226524353
|
||
|
2450,"def __setLoadCmd ( self ) : <TAB> base = self. __rawLoadCmd <TAB> for _ in range ( self. __machHeader. ncmds ) : <TAB> <TAB> command = LOAD_COMMAND. from_buffer_copy ( base ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> segment = SEGMENT_COMMAND. from_buffer_copy ( base ) <TAB> <TAB> <TAB> self. __setSections ( segment, base [ 56 : ], 32 ) <TAB> <TAB> elif command. cmd == MACHOFlags. LC_SEGMENT_64 : <TAB> <TAB> <TAB> segment = SEGMENT_COMMAND64. from_buffer_copy ( base ) <TAB> <TAB> <TAB> self. __setSections ( segment, base [ 72 : ], 64 ) <TAB> <TAB> base = base [ command. cmdsize : ]",False,command.cmd == MACHOFlags.LC_SEGMENT,command.cmd == MACHOFlags.LC_SEGMENT_ADDRESS,0.6592795848846436
|
||
|
2451,"def test_node_label_pull_scenarios ( graph ) : <TAB> label_sets = [ set ( ), { ""Foo"" }, { ""Foo"", ""Bar"" }, { ""Spam"" } ] <TAB> for old_labels in label_sets : <TAB> <TAB> for new_labels in label_sets : <TAB> <TAB> <TAB> node = Node ( * old_labels ) <TAB> <TAB> <TAB> graph. create ( node ) <TAB> <TAB> <TAB> node_id = node. identity <TAB> <TAB> <TAB> assert set ( node. labels ) == old_labels <TAB> <TAB> <TAB> if old_labels : <TAB> <TAB> <TAB> <TAB> remove_clause = ""REMOVE a:%s"" % "":"". join ( old_labels ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> remove_clause = """" <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> set_clause = ""SET a:%s"" % "":"". join ( new_labels ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> set_clause = """" <TAB> <TAB> <TAB> if remove_clause or set_clause : <TAB> <TAB> <TAB> <TAB> graph. run ( <TAB> <TAB> <TAB> <TAB> <TAB> ""MATCH (a) WHERE id(a)=$x %s %s"" % ( remove_clause, set_clause ), <TAB> <TAB> <TAB> <TAB> <TAB> x = node_id, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> graph. pull ( node ) <TAB> <TAB> <TAB> <TAB> assert ( <TAB> <TAB> <TAB> <TAB> <TAB> set ( node. labels ) == new_labels <TAB> <TAB> <TAB> <TAB> ), ""Failed to pull new labels %r over old labels %r"" % ( <TAB> <TAB> <TAB> <TAB> <TAB> new_labels, <",True,new_labels,new_labels,0.6749863624572754
|
||
|
2452,"def process_request ( self, request ) : <TAB> force_host = settings. SSL_FORCE_HOST <TAB> response = None <TAB> if force_host and request. get_host ( ). split ( "":"" ) [ 0 ]!= force_host : <TAB> <TAB> url = ""http://%s%s"" % ( force_host, request. get_full_path ( ) ) <TAB> <TAB> response = HttpResponsePermanentRedirect ( url ) <TAB> elif settings. SSL_ENABLED and not settings. DEV_SERVER : <TAB> <TAB> url = ""%s%s"" % ( request. get_host ( ), request. get_full_path ( ) ) <TAB> <TAB> path = request. path <TAB> <TAB> if settings. USE_I18N and path [ 1 : 3 ] in self. languages ( ) : <TAB> <TAB> <TAB> path = path [ 3 : ] <TAB> <TAB> if path. startswith ( settings. SSL_FORCE_URL_PREFIXES ) : <TAB> <TAB> <TAB> if not request. is_secure ( ) : <TAB> <TAB> <TAB> <TAB> response = HttpResponseRedirect ( ""https://%s"" % url ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> response = HttpResponseRedirect ( ""http://%s"" % url ) <TAB> if response and request. method == ""POST"" : <TAB> <TAB> if resolve ( request. get_full_path ( ) ). url_name == ""fb_do_upload"" : <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> return <TAB> <TAB> <TAB> <TAB> response. status_code = 307 <TAB> return response",False,request.is_secure() and settings.SSL_FORCED_PREFIXES_ONLY,request.method == 'GET',0.6512200832366943
|
||
|
2453,"def print_tools ( self, buf = sys. stdout ) : <TAB> data = self. get_tools ( ) <TAB> if not data : <TAB> <TAB> return <TAB> _pr = Printer ( buf ) <TAB> conflicts = set ( self. get_conflicting_tools ( ). keys ( ) ) <TAB> rows = [ [ ""TOOL"", ""PACKAGE"", """" ], [ ""----"", ""-------"", """" ] ] <TAB> colors = [ None, None ] <TAB> for _, ( variant, tools ) in sorted ( data. items ( ) ) : <TAB> <TAB> pkg_str = variant. qualified_package_name <TAB> <TAB> for tool in sorted ( tools ) : <TAB> <TAB> <TAB> col = None <TAB> <TAB> <TAB> row = [ tool, pkg_str, """" ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> col = critical <TAB> <TAB> <TAB> <TAB> row [ - 1 ] = ""(in conflict)"" <TAB> <TAB> <TAB> rows. append ( row ) <TAB> <TAB> <TAB> colors. append ( col ) <TAB> for col, line in zip ( colors, columnise ( rows ) ) : <TAB> <TAB> _pr ( line, col )",False,tool in conflicts,conflicting,0.675499439239502
|
||
|
2454,"def process_all ( self, lines, times = 1 ) : <TAB> gap = False <TAB> for _ in range ( times ) : <TAB> <TAB> for line in lines : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. write ( """" ) <TAB> <TAB> <TAB> self. process ( line ) <TAB> <TAB> <TAB> if not is_command ( line ) : <TAB> <TAB> <TAB> <TAB> gap = True <TAB> return 0",True,gap,gap,0.6850862503051758
|
||
|
2455,"def test_load_with_missing ( self ) : <TAB> with open ( ""state"", ""w"" ) as state_file : <TAB> <TAB> print ( ""!GlobalState"", file = state_file ) <TAB> <TAB> print ( ""assets: "", file = state_file ) <TAB> <TAB> if self. build_packages : <TAB> <TAB> <TAB> print ( "" build-packages: {}"". format ( self. build_packages ), file = state_file ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> print ( "" build-snaps: {}"". format ( self. build_snaps ), file = state_file ) <TAB> <TAB> if self. required_grade : <TAB> <TAB> <TAB> print ( "" required-grade: {}"". format ( self. required_grade ), file = state_file ) <TAB> global_state = GlobalState. load ( filepath = ""state"" ) <TAB> self. assertThat ( global_state. get_build_packages ( ), Equals ( self. build_packages ) ) <TAB> self. assertThat ( global_state. get_build_snaps ( ), Equals ( self. build_snaps ) ) <TAB> self. assertThat ( global_state. get_required_grade ( ), Equals ( self. required_grade ) )",True,self.build_snaps,self.build_snaps,0.656694769859314
|
||
|
2456,"def test_len ( self ) : <TAB> eq = self. assertEqual <TAB> eq ( base64MIME. base64_len ( ""hello"" ), len ( base64MIME. encode ( ""hello"", eol = """" ) ) ) <TAB> for size in range ( 15 ) : <TAB> <TAB> if size == 0 : <TAB> <TAB> <TAB> bsize = 0 <TAB> <TAB> elif size <= 3 : <TAB> <TAB> <TAB> bsize = 4 <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> bsize = 8 <TAB> <TAB> elif size <= 9 : <TAB> <TAB> <TAB> bsize = 12 <TAB> <TAB> elif size <= 12 : <TAB> <TAB> <TAB> bsize = 16 <TAB> <TAB> else : <TAB> <TAB> <TAB> bsize = 20 <TAB> <TAB> eq ( base64MIME. base64_len ( ""x"" * size ), bsize )",False,size <= 6,size <= 8,0.6720942854881287
|
||
|
2457,"def wrapped ( * args, ** kwargs ) : <TAB> count = 0 <TAB> while True : <TAB> <TAB> try : <TAB> <TAB> <TAB> return func ( * args, ** kwargs ) <TAB> <TAB> except ( HTTPException, HTTPError, socket. error, socket. timeout ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise <TAB> <TAB> <TAB> logger. info ( ""Throttling API requests..."" ) <TAB> <TAB> <TAB> time. sleep ( 2 ** count * 0.5 ) <TAB> <TAB> <TAB> count += 1",False,count >= 10,count > 5,0.6895406246185303
|
||
|
2458,"def __define_authform_utils ( self ) : <TAB> settings = { <TAB> <TAB> ""form_registration_rw"" : { ""writable"" : [ ], ""readable"" : [ ] }, <TAB> <TAB> ""form_profile_rw"" : { ""writable"" : [ ], ""readable"" : [ ] }, <TAB> } <TAB> for config_dict in settings. keys ( ) : <TAB> <TAB> rw_data = self. __base_visibility ( ) <TAB> <TAB> rw_data. update ( ** self. fields_rw ) <TAB> <TAB> rw_data. update ( ** getattr ( self, config_dict ) ) <TAB> <TAB> for key, value in rw_data. items ( ) : <TAB> <TAB> <TAB> if isinstance ( value, ( tuple, list ) ) : <TAB> <TAB> <TAB> <TAB> readable, writable = value <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> readable = writable = value <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> settings [ config_dict ] [ ""readable"" ]. append ( key ) <TAB> <TAB> <TAB> if writable : <TAB> <TAB> <TAB> <TAB> settings [ config_dict ] [ ""writable"" ]. append ( key ) <TAB> setattr ( <TAB> <TAB> self, <TAB> <TAB> ""_merged_form_rw_"", <TAB> <TAB> { <TAB> <TAB> <TAB> ""registration"" : settings [ ""form_registration_rw"" ], <TAB> <TAB> <TAB> ""profile"" : settings [ ""form_profile_rw"" ], <TAB> <TAB> }, <TAB> )",True,readable,readable,0.7143868207931519
|
||
|
2459,"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. STRING : <TAB> <TAB> <TAB> <TAB> self. dbName = iprot. readString ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif fid == 2 : <TAB> <TAB> <TAB> if ftype == TType. STRING : <TAB> <TAB> <TAB> <TAB> self. tblName = 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. expr = iprot. readString ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif fid == 4 : <TAB> <TAB> <TAB> if ftype == TType. STRING : <TAB> <TAB> <TAB> <TAB> self. defaultPartitionName = iprot. readString ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> i",False,ftype == TType.I16,fid == 2,0.6591702699661255
|
||
|
2460,"def hadoop_fs_rmr ( stdout, stderr, environ, * args ) : <TAB> yarn = mock_hadoop_uses_yarn ( environ ) <TAB> if<mask> : <TAB> <TAB> print ( ""rmr: DEPRECATED: Please use 'rm -r' instead."", file = stderr ) <TAB> if args and args [ 0 ] == ""-skipTrash"" : <TAB> <TAB> path_args = args [ 1 : ] <TAB> else : <TAB> <TAB> path_args = args <TAB> if not path_args : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> print ( ""-rmr: Not enough arguments: expected 1 but got 0"", file = stderr ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> print ( ""Usage: hadoop fs [generic options] -rmr"" "" <src>..."", file = stderr ) <TAB> <TAB> else : <TAB> <TAB> <TAB> print ( ""Usage: java FsShell [-rmr [-skipTrash] <src>]"", file = stderr ) <TAB> <TAB> return - 1 <TAB> return _hadoop_fs_rm ( <TAB> <TAB> ""rmr"", stdout, stderr, environ, path_args = path_args, recursive = True, force = False <TAB> )",False,yarn,len(args) != 1,0.6881247758865356
|
||
|
2461,"def _parse_plugins_key ( cls, key ) : <TAB> if not key : <TAB> <TAB> return None, None <TAB> plugins = key. split ( ""+"" ) <TAB> result = [ ] <TAB> <TAB> for plugin_key in plugins : <TAB> <TAB> <TAB> <TAB> plugin_name, plugin_module = cls. _parse_plugin_key ( plugin_key ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> result. append ( ( plugin_name, plugin_module ) ) <TAB> <TAB> result. append ( cls. _parse_plugin_key ( key. replace ( ""+"", ""-"" ) ) ) <TAB> return result",False,not plugin_name or not plugin_module,plugin_name is None,0.6530880928039551
|
||
|
2462,"def canvas_size ( self ) : <TAB> """"""Return the width and height for this sprite canvas"""""" <TAB> width = height = 0 <TAB> for image in self. images : <TAB> <TAB> x = image. x + image. absolute_width <TAB> <TAB> y = image. y + image. absolute_height <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> width = x <TAB> <TAB> if height < y : <TAB> <TAB> <TAB> height = y <TAB> return round_up ( width ), round_up ( height )",True,width < x,width < x,0.679709792137146
|
||
|
2463,"def _get_season_search_strings ( self, show, season = None ) : <TAB> if not show : <TAB> <TAB> return [ { } ] <TAB> to_return = [ ] <TAB> <TAB> name_exceptions = scene_exceptions. get_scene_exceptions ( show. tvdbid ) + [ show. name ] <TAB> for cur_exception in name_exceptions : <TAB> <TAB> cur_params = { } <TAB> <TAB> <TAB> <TAB> if show. tvrid : <TAB> <TAB> <TAB> cur_params [ ""rid"" ] = show. tvrid <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> cur_params [ ""q"" ] = helpers. sanitizeSceneName ( cur_exception ) <TAB> <TAB> if season!= None : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> cur_params [ ""season"" ] = season. split ( ""-"" ) [ 0 ] <TAB> <TAB> <TAB> <TAB> if ""q"" in cur_params : <TAB> <TAB> <TAB> <TAB> <TAB> cur_params [ ""q"" ] += ""."" + season. replace ( ""-"", ""."" ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> cur_params [ ""q"" ] = season. replace ( ""-"", ""."" ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> cur_params [ ""season"" ] = season <TAB> <TAB> <TAB> <TAB> if not ( ""rid"" in cur_params and to_return ) : <TAB> <TAB> <TAB> to_return. append ( cur_params ) <TAB> return to_return",False,show.air_by_date,season != None,0.6524279117584229
|
||
|
2464,"def ensure_connection ( engine ) : <TAB> remaining_attempts = FLAGS. sql_max_retries <TAB> while True : <TAB> <TAB> try : <TAB> <TAB> <TAB> engine. connect ( ) <TAB> <TAB> <TAB> return <TAB> <TAB> except sqlalchemy. exc. OperationalError : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise <TAB> <TAB> <TAB> LOG. warning ( <TAB> <TAB> <TAB> <TAB> _ ( <TAB> <TAB> <TAB> <TAB> <TAB> ""SQL connection failed (%(connstring)s). "" <TAB> <TAB> <TAB> <TAB> <TAB> ""%(attempts)d attempts left."" <TAB> <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> <TAB> { ""connstring"" : FLAGS. sql_connection, ""attempts"" : remaining_attempts }, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> time. sleep ( FLAGS. sql_retry_interval ) <TAB> <TAB> <TAB> remaining_attempts -= 1",False,remaining_attempts == 0,remaining_attempts <= 0,0.6710488200187683
|
||
|
2465,"def _download ( dset ) : <TAB> for url in dset. urls : <TAB> <TAB> file = os. path. basename ( urlparse ( url ). path ) <TAB> <TAB> out_path = os. path. join ( DATA_DIR, file ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> print ( ""Downloading - {}."". format ( url ) ) <TAB> <TAB> <TAB> urlretrieve ( url, out_path ) <TAB> <TAB> <TAB> print ( ""Download complete."" )",True,not os.path.exists(out_path),not os.path.exists(out_path),0.646681547164917
|
||
|
2466,"def init_author_file ( self ) : <TAB> self. author_map = { } <TAB> if self. ui. config ( ""git"", ""authors"" ) : <TAB> <TAB> f = open ( self. repo. wjoin ( self. ui. config ( ""git"", ""authors"" ) ) ) <TAB> <TAB> try : <TAB> <TAB> <TAB> for line in f : <TAB> <TAB> <TAB> <TAB> line = line. strip ( ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> from_, to = RE_AUTHOR_FILE. split ( line, 2 ) <TAB> <TAB> <TAB> <TAB> self. author_map [ from_ ] = to <TAB> <TAB> finally : <TAB> <TAB> <TAB> f. close ( )",False,not line or line.startswith('#'),not line,0.6481633186340332
|
||
|
2467,"def get_indexes ( self, cursor, table_name ) : <TAB> cursor. execute ( <TAB> <TAB> ""SHOW INDEX FROM {0}"" """". format ( self. connection. ops. quote_name ( table_name ) ) <TAB> ) <TAB> <TAB> <TAB> <TAB> rows = list ( cursor. fetchall ( ) ) <TAB> multicol_indexes = set ( ) <TAB> for row in rows : <TAB> <TAB> if row [ 3 ] > 1 : <TAB> <TAB> <TAB> multicol_indexes. add ( row [ 2 ] ) <TAB> indexes = { } <TAB> for row in rows : <TAB> <TAB> if row [ 2 ] in multicol_indexes : <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> indexes [ row [ 4 ] ] = { ""primary_key"" : False, ""unique"" : False } <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if row [ 2 ] == ""PRIMARY"" : <TAB> <TAB> <TAB> indexes [ row [ 4 ] ] [ ""primary_key"" ] = True <TAB> <TAB> if not row [ 1 ] : <TAB> <TAB> <TAB> indexes [ row [ 4 ] ] [ ""unique"" ] = True <TAB> return indexes",True,row[4] not in indexes,row[4] not in indexes,0.6560623049736023
|
||
|
2468,"def when ( self, matches, context ) : <TAB> to_remove = [ ] <TAB> to_ignore = set ( ) <TAB> remove = False <TAB> for filepart in matches. markers. named ( ""path"" ) : <TAB> <TAB> year = matches. range ( <TAB> <TAB> <TAB> filepart. start, filepart. end, predicate = lambda m : m. name == ""year"", index = 0 <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> remove = True <TAB> <TAB> <TAB> next_match = matches. range ( <TAB> <TAB> <TAB> <TAB> year. end, filepart. end, predicate = lambda m : m. private, index = 0 <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if ( <TAB> <TAB> <TAB> <TAB> next_match <TAB> <TAB> <TAB> <TAB> and not matches. holes ( <TAB> <TAB> <TAB> <TAB> <TAB> year. end, next_match. start, predicate = lambda m : m. raw. strip ( seps ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> and not matches. at_match ( <TAB> <TAB> <TAB> <TAB> <TAB> next_match, predicate = lambda m : m. name == ""year"" <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> to_ignore. add ( next_match. initiator ) <TAB> <TAB> <TAB> to_ignore. update ( <TAB> <TAB> <TAB> <TAB> matches. range ( <TAB> <TAB> <TAB> <TAB> <TAB> filepart. start, <TAB> <TAB> <TAB> <TAB> <TAB> filepart. end, <TAB> <TAB> <TAB> <TAB> <TAB> predicate = lambda m : len ( m. children. named ( ""episode"" ) ) > 1, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <",False,year,remove,0.7028327584266663
|
||
|
2469,"def send_push ( <TAB> self, api_key, title, body, url = None, destination = None, destination_type = None ) : <TAB> push_type = ""link"" if url else ""note"" <TAB> notification = { ""type"" : push_type, ""title"" : title, ""body"" : body } <TAB> if url : <TAB> <TAB> notification [ ""url"" ] = url <TAB> if destination : <TAB> <TAB> notification [ destination_type ] = destination <TAB> <TAB> headers = { <TAB> <TAB> ""Authorization"" : b""Basic "" + base64. b64encode ( api_key. encode ( ""ascii"" ) ), <TAB> <TAB> ""Content-Type"" : ""application/json"", <TAB> <TAB> ""Accept"" : ""application/json"", <TAB> <TAB> ""User-Agent"" : ""Flexget"", <TAB> } <TAB> try : <TAB> <TAB> response = requests. post ( PUSHBULLET_URL, headers = headers, json = notification ) <TAB> except RequestException as e : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if e. response. status_code == 429 : <TAB> <TAB> <TAB> <TAB> reset_time = datetime. datetime. fromtimestamp ( <TAB> <TAB> <TAB> <TAB> <TAB> int ( e. response. headers [ ""X-Ratelimit-Reset"" ] ) <TAB> <TAB> <TAB> <TAB> ). strftime ( ""%Y-%m-%d %H:%M:%S"" ) <TAB> <TAB> <TAB> <TAB> message = ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Monthly Pushbullet database operations limit reached. Next reset: %s"" <TAB> <TAB> <TAB> <TAB> <TAB> % reset_time <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> message = e. response. json ( ) [ ""error"" ] [ ""message"" ] <TAB> <TAB> else : <TAB> <TAB> <TAB> message = str ( e",False,e.response is not None,e.response_code != 200,0.6556862592697144
|
||
|
2470,"def ParseFile ( <TAB> self, <TAB> knowledge_base : rdf_client. KnowledgeBase, <TAB> pathspec : rdf_paths. PathSpec, <TAB> filedesc : IO [ bytes ], ) -> Iterator [ rdf_webhistory. BrowserHistoryItem ] : <TAB> del knowledge_base <TAB> <TAB> chrome = ChromeParser ( ) <TAB> path = pathspec. CollapsePath ( ) <TAB> for timestamp, entry_type, url, data1, _, _ in chrome. Parse ( path, filedesc ) : <TAB> <TAB> if entry_type == ""CHROME_DOWNLOAD"" : <TAB> <TAB> <TAB> yield rdf_webhistory. BrowserHistoryItem ( <TAB> <TAB> <TAB> <TAB> url = url, <TAB> <TAB> <TAB> <TAB> domain = urlparse. urlparse ( url ). netloc, <TAB> <TAB> <TAB> <TAB> access_time = timestamp, <TAB> <TAB> <TAB> <TAB> program_name = ""Chrome"", <TAB> <TAB> <TAB> <TAB> source_path = pathspec. CollapsePath ( ), <TAB> <TAB> <TAB> <TAB> download_path = data1, <TAB> <TAB> <TAB> ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> yield rdf_webhistory. BrowserHistoryItem ( <TAB> <TAB> <TAB> <TAB> url = url, <TAB> <TAB> <TAB> <TAB> domain = urlparse. urlparse ( url ). netloc, <TAB> <TAB> <TAB> <TAB> access_time = timestamp, <TAB> <TAB> <TAB> <TAB> program_name = ""Chrome"", <TAB> <TAB> <TAB> <TAB> source_path = pathspec. CollapsePath ( ), <TAB> <TAB> <TAB> <TAB> title = data1, <TAB> <TAB> <TAB> )",False,entry_type == 'CHROME_VISIT',"entry_type == ""CHROME_READ_URL'",0.6542778015136719
|
||
|
2471,"def test_read_value ( self, replicator_fn, cross_replica ) : <TAB> replicator = replicator_fn ( ) <TAB> if replicator is None : <TAB> <TAB> self. skipTest ( ""No replicator supplied."" ) <TAB> with replicator. scope ( ) : <TAB> <TAB> v = tf. Variable ( 0.0 ) <TAB> if cross_replica : <TAB> <TAB> values = [ v. read_value ( ) ] <TAB> else : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> read_value_fn = tf. function ( v. read_value ) <TAB> <TAB> else : <TAB> <TAB> <TAB> read_value_fn = v. read_value <TAB> <TAB> values = replicator. run ( read_value_fn ) <TAB> <TAB> values = replicator. experimental_local_results ( values ) <TAB> for component in v. _values : <TAB> <TAB> for value in values : <TAB> <TAB> <TAB> self. assertAllEqual ( component. read_value ( ), value )",False,"isinstance(replicator, snt_replicator.TpuReplicator)",tf.function is not None,0.6506149768829346
|
||
|
2472,"def runas ( <TAB> args = sys. argv, <TAB> executable = sys. executable, <TAB> cwd = None, <TAB> nShow = 1, <TAB> waitClose = True, <TAB> waitTimeout = - 1, ) : <TAB> if not 0 <= nShow <= 10 : <TAB> <TAB> nShow = 1 <TAB> err = None <TAB> try : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> args = subprocess. list2cmdline ( args ) <TAB> <TAB> pExecInfo = ShellExecuteInfo ( ) <TAB> <TAB> pExecInfo. cbSize = ctypes. sizeof ( pExecInfo ) <TAB> <TAB> pExecInfo. fMask |= SEE_MASK_NOCLOSEPROCESS <TAB> <TAB> pExecInfo. lpVerb = b""open"" if is_admin ( ) else b""runas"" <TAB> <TAB> pExecInfo. lpFile = encode_for_locale ( executable ) <TAB> <TAB> pExecInfo. lpParameters = encode_for_locale ( args ) <TAB> <TAB> pExecInfo. lpDirectory = encode_for_locale ( cwd ) <TAB> <TAB> pExecInfo. nShow = nShow <TAB> <TAB> if ShellExecuteEx ( pExecInfo ) : <TAB> <TAB> <TAB> if waitClose : <TAB> <TAB> <TAB> <TAB> WaitForSingleObject ( pExecInfo. hProcess, waitTimeout ) <TAB> <TAB> <TAB> <TAB> return True <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> return pExecInfo. hProcess <TAB> <TAB> else : <TAB> <TAB> <TAB> err = SE_ERR_CODES. get ( pExecInfo. hInstApp, ""unknown"" ) <TAB> except Exception as e : <TAB> <TAB> err = e <TAB> if err : <TAB> <TAB> print ( ( ""runas failed! error: %r"" % err ) )",False,"args is not None and (not isinstance(args, str))",subprocess,0.653452455997467
|
||
|
2473,"def __init__ ( self, num_spherical, num_radial, cutoff = 5.0, envelope_exponent = 5 ) : <TAB> super ( SphericalBasisLayer, self ). __init__ ( ) <TAB> assert num_radial <= 64 <TAB> self. num_spherical = num_spherical <TAB> self. num_radial = num_radial <TAB> self. cutoff = cutoff <TAB> self. envelope = Envelope ( envelope_exponent ) <TAB> bessel_forms = bessel_basis ( num_spherical, num_radial ) <TAB> sph_harm_forms = real_sph_harm ( num_spherical ) <TAB> self. sph_funcs = [ ] <TAB> self. bessel_funcs = [ ] <TAB> x, theta = sym. symbols ( ""x theta"" ) <TAB> modules = { ""sin"" : torch. sin, ""cos"" : torch. cos } <TAB> for i in range ( num_spherical ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> sph1 = sym. lambdify ( [ theta ], sph_harm_forms [ i ] [ 0 ], modules ) ( 0 ) <TAB> <TAB> <TAB> self. sph_funcs. append ( lambda x : torch. zeros_like ( x ) + sph1 ) <TAB> <TAB> else : <TAB> <TAB> <TAB> sph = sym. lambdify ( [ theta ], sph_harm_forms [ i ] [ 0 ], modules ) <TAB> <TAB> <TAB> self. sph_funcs. append ( sph ) <TAB> <TAB> for j in range ( num_radial ) : <TAB> <TAB> <TAB> bessel = sym. lambdify ( [ x ], bessel_forms [ i ] [ j ], modules ) <TAB> <TAB> <TAB> self. bessel_funcs. append ( bessel )",False,i == 0,num_radial == 64,0.677891731262207
|
||
|
2474,"def builder ( ) : <TAB> try : <TAB> <TAB> res = self. _svnwithrev ( ""ls"", ""-v"" ) <TAB> except process. cmdexec. Error : <TAB> <TAB> e = sys. exc_info ( ) [ 1 ] <TAB> <TAB> if e. err. find ( ""non-existent in that revision"" )!= - 1 : <TAB> <TAB> <TAB> raise py. error. ENOENT ( self, e. err ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> raise py. error. ENOENT ( self, e. err ) <TAB> <TAB> elif e. err. find ( ""File not found"" )!= - 1 : <TAB> <TAB> <TAB> raise py. error. ENOENT ( self, e. err ) <TAB> <TAB> elif e. err. find ( ""not part of a repository"" )!= - 1 : <TAB> <TAB> <TAB> raise py. error. ENOENT ( self, e. err ) <TAB> <TAB> elif e. err. find ( ""Unable to open"" )!= - 1 : <TAB> <TAB> <TAB> raise py. error. ENOENT ( self, e. err ) <TAB> <TAB> elif e. err. lower ( ). find ( ""method not allowed"" )!= - 1 : <TAB> <TAB> <TAB> raise py. error. EACCES ( self, e. err ) <TAB> <TAB> raise py. error. Error ( e. err ) <TAB> lines = res. split ( ""\n"" ) <TAB> nameinfo_seq = [ ] <TAB> for lsline in lines : <TAB> <TAB> if lsline : <TAB> <TAB> <TAB> info = InfoSvnCommand ( lsline ) <TAB> <TAB> <TAB> if info. _name!= ""."" : <TAB> <TAB> <TAB> <TAB> nameinfo_seq. append ( ( info. _name, info ) ) <TAB> nameinfo_seq. sort ( ) <TAB> return nameinfo_seq",False,e.err.find('E200009:') != -1,e.err.find('File found') != -1,0.6513532400131226
|
||
|
2475,"def star_op ( self ) : <TAB> """"""Put a '*' op, with special cases for *args."""""" <TAB> val = ""*"" <TAB> if self. paren_level : <TAB> <TAB> i = len ( self. code_list ) - 1 <TAB> <TAB> if self. code_list [ i ]. kind == ""blank"" : <TAB> <TAB> <TAB> i -= 1 <TAB> <TAB> token = self. code_list [ i ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. op_no_blanks ( val ) <TAB> <TAB> elif token. value == "","" : <TAB> <TAB> <TAB> self. blank ( ) <TAB> <TAB> <TAB> self. add_token ( ""op-no-blanks"", val ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. op ( val ) <TAB> else : <TAB> <TAB> self. op ( val )",False,token.kind == 'lt',token.kind == 'no-blanks',0.6594384908676147
|
||
|
2476,"def test_values_extended ( self ) : <TAB> entries = grp. getgrall ( ) <TAB> if len ( entries ) > 1000 : <TAB> <TAB> self. skipTest ( ""huge group file, extended test skipped"" ) <TAB> for e in entries : <TAB> <TAB> e2 = grp. getgrgid ( e. gr_gid ) <TAB> <TAB> self. check_value ( e2 ) <TAB> <TAB> self. assertEqual ( e2. gr_gid, e. gr_gid ) <TAB> <TAB> name = e. gr_name <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> e2 = grp. getgrnam ( name ) <TAB> <TAB> self. check_value ( e2 ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. assertEqual ( e2. gr_name. lower ( ), name. lower ( ) )",False,name.startswith('+') or name.startswith('-'),name is None,0.644282877445221
|
||
|
2477,"def _presolve ( self, * args, ** kwds ) : <TAB> if not isinstance ( args [ 0 ], six. string_types ) : <TAB> <TAB> self. _instance = args [ 0 ] <TAB> <TAB> xfrm = TransformationFactory ( ""mpec.nl"" ) <TAB> <TAB> xfrm. apply_to ( self. _instance ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _instance = None <TAB> <TAB> else : <TAB> <TAB> <TAB> args = ( self. _instance, ) <TAB> else : <TAB> <TAB> self. _instance = None <TAB> <TAB> SystemCallSolver. _presolve ( self, * args, ** kwds )",False,len(self._instance._transformation_data['mpec.nl'].compl_cuids) == 0,len(args) == 0,0.6532272100448608
|
||
|
2478,"def update_or_create_direct_relations ( self, attrs, relations ) : <TAB> for field_name, ( field, field_source ) in relations. items ( ) : <TAB> <TAB> obj = None <TAB> <TAB> data = self. get_initial ( ) [ field_name ] <TAB> <TAB> model_class = field. Meta. model <TAB> <TAB> pk = self. _get_related_pk ( data, model_class ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> obj = model_class. objects. filter ( <TAB> <TAB> <TAB> <TAB> pk = pk, <TAB> <TAB> <TAB> ). first ( ) <TAB> <TAB> serializer = self. _get_serializer_for_field ( <TAB> <TAB> <TAB> field, <TAB> <TAB> <TAB> instance = obj, <TAB> <TAB> <TAB> data = data, <TAB> <TAB> ) <TAB> <TAB> try : <TAB> <TAB> <TAB> serializer. is_valid ( raise_exception = True ) <TAB> <TAB> <TAB> attrs [ field_source ] = serializer. save ( ** self. _get_save_kwargs ( field_name ) ) <TAB> <TAB> except ValidationError as exc : <TAB> <TAB> <TAB> raise ValidationError ( { field_name : exc. detail } )",True,pk,pk,0.7025264501571655
|
||
|
2479,"def _get_subtype ( dtype : torch. dtype, format : str, encoding : str, bits_per_sample : int ) : <TAB> if format == ""wav"" : <TAB> <TAB> return _get_subtype_for_wav ( dtype, encoding, bits_per_sample ) <TAB> if format == ""flac"" : <TAB> <TAB> if encoding : <TAB> <TAB> <TAB> raise ValueError ( ""flac does not support encoding."" ) <TAB> <TAB> if not bits_per_sample : <TAB> <TAB> <TAB> return ""PCM_24"" <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( ""flac does not support bits_per_sample > 24."" ) <TAB> <TAB> return ""PCM_S8"" if bits_per_sample == 8 else f""PCM_{bits_per_sample}"" <TAB> if format in ( ""ogg"", ""vorbis"" ) : <TAB> <TAB> if encoding or bits_per_sample : <TAB> <TAB> <TAB> raise ValueError ( ""ogg/vorbis does not support encoding/bits_per_sample."" ) <TAB> <TAB> return ""VORBIS"" <TAB> if format == ""sph"" : <TAB> <TAB> return _get_subtype_for_sphere ( encoding, bits_per_sample ) <TAB> if format in ( ""nis"", ""nist"" ) : <TAB> <TAB> return ""PCM_16"" <TAB> raise ValueError ( f""Unsupported format: {format}"" )",False,bits_per_sample > 24,not bits_per_sample,0.6492035388946533
|
||
|
2480,"def _parse_preamble ( self ) : <TAB> """"""Parse metadata about query (PRIVATE)."""""" <TAB> meta = { } <TAB> while self. line : <TAB> <TAB> regx = re. search ( _RE_QUERY, self. line ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. query_id = regx. group ( 1 ) <TAB> <TAB> if self. line. startswith ( ""Match_columns"" ) : <TAB> <TAB> <TAB> self. seq_len = int ( self. line. strip ( ). split ( ) [ 1 ] ) <TAB> <TAB> self. line = self. handle. readline ( ). strip ( ) <TAB> return meta",True,regx,regx,0.6682659387588501
|
||
|
2481,"def test_non_uniform_probabilities_over_elements ( self ) : <TAB> param = iap. Choice ( [ 0, 1 ], p = [ 0.25, 0.75 ] ) <TAB> samples = param. draw_samples ( ( 10000, ) ) <TAB> unique, counts = np. unique ( samples, return_counts = True ) <TAB> assert len ( unique ) == 2 <TAB> for val, count in zip ( unique, counts ) : <TAB> <TAB> if val == 0 : <TAB> <TAB> <TAB> assert 2500 - 500 < count < 2500 + 500 <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> assert 7500 - 500 < count < 7500 + 500 <TAB> <TAB> else : <TAB> <TAB> <TAB> assert False",True,val == 1,val == 1,0.673570990562439
|
||
|
2482,"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<mask> : <TAB> <TAB> <TAB> if ftype == TType. LIST : <TAB> <TAB> <TAB> <TAB> self. partitions = [ ] <TAB> <TAB> <TAB> <TAB> ( _etype367, _size364 ) = iprot. readListBegin ( ) <TAB> <TAB> <TAB> <TAB> for _i368 in xrange ( _size364 ) : <TAB> <TAB> <TAB> <TAB> <TAB> _elem369 = Partition ( ) <TAB> <TAB> <TAB> <TAB> <TAB> _elem369. read ( iprot ) <TAB> <TAB> <TAB> <TAB> <TAB> self. partitions. append ( _elem369 ) <TAB> <TAB> <TAB> <TAB> iprot. readListEnd ( ) <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,fid == 1,fid == TType.PUSH,0.6745845079421997
|
||
|
2483,"def onMessage ( self, message, metadata ) : <TAB> <TAB> <TAB> if ""details"" in message : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if ""http_user_agent"" in message [ ""details"" ] : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> message = None <TAB> <TAB> <TAB> <TAB> return message <TAB> return ( message, metadata )",False,message['details']['http_user_agent'] == 'ELB-HealthChecker/1.0',message['http_user_agent'] != message['details'],0.6523468494415283
|
||
|
2484,"def _blob_name_from_object_path ( cls, name, container_name ) : <TAB> scheme = urlparse ( name ). scheme <TAB> if scheme : <TAB> <TAB> if scheme!= cls. scheme : <TAB> <TAB> <TAB> raise StorageError ( <TAB> <TAB> <TAB> <TAB> ""When using a URL, only the `{}` scheme is supported for Azure storage: {}"", <TAB> <TAB> <TAB> <TAB> cls. scheme, <TAB> <TAB> <TAB> <TAB> name, <TAB> <TAB> <TAB> ) <TAB> <TAB> f = furl ( name ) <TAB> <TAB> if not f. path. segments : <TAB> <TAB> <TAB> raise StorageError ( <TAB> <TAB> <TAB> <TAB> ""Missing container name in URL {}"", <TAB> <TAB> <TAB> <TAB> name, <TAB> <TAB> <TAB> ) <TAB> <TAB> parsed_container_name = f. path. segments [ 0 ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise StorageError ( <TAB> <TAB> <TAB> <TAB> ""Container name mismatch (expected {}, found {}) in {}"", <TAB> <TAB> <TAB> <TAB> container_name, <TAB> <TAB> <TAB> <TAB> parsed_container_name, <TAB> <TAB> <TAB> <TAB> name, <TAB> <TAB> <TAB> ) <TAB> <TAB> if len ( f. path. segments ) == 1 : <TAB> <TAB> <TAB> raise StorageError ( <TAB> <TAB> <TAB> <TAB> ""No path found following container name {} in {}"", <TAB> <TAB> <TAB> <TAB> container_name, <TAB> <TAB> <TAB> <TAB> name, <TAB> <TAB> <TAB> ) <TAB> <TAB> return f. path. segments [ 0 ], os. path. join ( * f. path. segments [ 1 : ] ) <TAB> return name",True,parsed_container_name != container_name,parsed_container_name != container_name,0.6523797512054443
|
||
|
2485,"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 fid == 0 : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. success = TCancelOperationResp ( ) <TAB> <TAB> <TAB> <TAB> self. success. 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 ( )",False,ftype == TType.STRUCT,self.success is not None,0.6601253747940063
|
||
|
2486,"def get_quarantine_count ( self ) : <TAB> """"""get obj/container/account quarantine counts"""""" <TAB> qcounts = { ""objects"" : 0, ""containers"" : 0, ""accounts"" : 0 } <TAB> qdir = ""quarantined"" <TAB> for device in os. listdir ( self. devices ) : <TAB> <TAB> for qtype in qcounts : <TAB> <TAB> <TAB> qtgt = os. path. join ( self. devices, device, qdir, qtype ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> linkcount = os. lstat ( qtgt ). st_nlink <TAB> <TAB> <TAB> <TAB> if linkcount > 2 : <TAB> <TAB> <TAB> <TAB> <TAB> qcounts [ qtype ] += linkcount - 2 <TAB> return qcounts",False,os.path.exists(qtgt),qtgt and os.lstat(qtgt),0.6544297933578491
|
||
|
2487,"def test_attributes_bad_port ( self ) : <TAB> """"""Check handling of invalid ports."""""" <TAB> for bytes in ( False, True ) : <TAB> <TAB> for parse in ( urllib. parse. urlsplit, urllib. parse. urlparse ) : <TAB> <TAB> <TAB> for port in ( ""foo"", ""1.5"", ""-1"", ""0x10"" ) : <TAB> <TAB> <TAB> <TAB> with self. subTest ( bytes = bytes, parse = parse, port = port ) : <TAB> <TAB> <TAB> <TAB> <TAB> netloc = ""www.example.net:"" + port <TAB> <TAB> <TAB> <TAB> <TAB> url = ""http://"" + netloc <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> netloc = netloc. encode ( ""ascii"" ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> url = url. encode ( ""ascii"" ) <TAB> <TAB> <TAB> <TAB> <TAB> p = parse ( url ) <TAB> <TAB> <TAB> <TAB> <TAB> self. assertEqual ( p. netloc, netloc ) <TAB> <TAB> <TAB> <TAB> <TAB> with self. assertRaises ( ValueError ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> p. port",False,bytes,url is not None,0.6866328120231628
|
||
|
2488,"def get_file_sources ( ) : <TAB> global _file_sources <TAB> if _file_sources is None : <TAB> <TAB> from galaxy. files import ConfiguredFileSources <TAB> <TAB> file_sources = None <TAB> <TAB> if os. path. exists ( ""file_sources.json"" ) : <TAB> <TAB> <TAB> file_sources_as_dict = None <TAB> <TAB> <TAB> with open ( ""file_sources.json"", ""r"" ) as f : <TAB> <TAB> <TAB> <TAB> file_sources_as_dict = json. load ( f ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> file_sources = ConfiguredFileSources. from_dict ( file_sources_as_dict ) <TAB> <TAB> if file_sources is None : <TAB> <TAB> <TAB> ConfiguredFileSources. from_dict ( [ ] ) <TAB> <TAB> _file_sources = file_sources <TAB> return _file_sources",False,file_sources_as_dict is not None,file_sources_as_dict,0.6550328135490417
|
||
|
2489,"def search ( a, b, desired ) : <TAB> if a == b : <TAB> <TAB> return a <TAB> if abs ( b - a ) < 0.005 : <TAB> <TAB> ca = count ( a ) <TAB> <TAB> cb = count ( b ) <TAB> <TAB> dista = abs ( desired - ca ) <TAB> <TAB> distb = abs ( desired - cb ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return a <TAB> <TAB> else : <TAB> <TAB> <TAB> return b <TAB> m = ( a + b ) / 2.0 <TAB> cm = count ( m ) <TAB> if desired < cm : <TAB> <TAB> return search ( m, b, desired ) <TAB> else : <TAB> <TAB> return search ( a, m, desired )",False,dista < distb,dista == distb,0.6647661924362183
|
||
|
2490,"def _handleLogError ( self, msg, data, marker, pattern ) : <TAB> print ( """" ) <TAB> print ( "" ERROR: %s"" % msg ) <TAB> if not self. interactive : <TAB> <TAB> raise self. failureException ( msg ) <TAB> p = "" Show: "" ""[L]og [M]arker [P]attern; "" ""[I]gnore, [R]aise, or sys.e[X]it >> "" <TAB> sys. stdout. write ( p + "" "" ) <TAB> <TAB> sys. stdout. flush ( ) <TAB> while True : <TAB> <TAB> i = getchar ( ). upper ( ) <TAB> <TAB> if i not in ""MPLIRX"" : <TAB> <TAB> <TAB> continue <TAB> <TAB> print ( i. upper ( ) ) <TAB> <TAB> if i == ""L"" : <TAB> <TAB> <TAB> for x, line in enumerate ( data ) : <TAB> <TAB> <TAB> <TAB> if ( x + 1 ) % self. console_height == 0 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> sys. stdout. write ( ""<-- More -->\r "" ) <TAB> <TAB> <TAB> <TAB> <TAB> m = getchar ( ). lower ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> sys. stdout. write ( "" \r "" ) <TAB> <TAB> <TAB> <TAB> <TAB> if m == ""q"" : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> print ( line. rstrip ( ) ) <TAB> <TAB> elif i == ""M"" : <TAB> <TAB> <TAB> print ( repr ( marker or self. lastmarker ) ) <TAB> <TAB> elif i == ""P"" : <TAB> <TAB> <TAB> print ( repr ( pattern ) ) <TAB> <TAB> elif i == ""I"" : <TAB> <TAB",False,i == 'X',self.console_height > 0,0.6602107882499695
|
||
|
2491,"def consume_buf ( ) : <TAB> ty = state [ ""ty"" ] - 1 <TAB> for i in xrange ( state [ ""buf"" ]. shape [ 1 ] // N ) : <TAB> <TAB> tx = x // N + i <TAB> <TAB> src = state [ ""buf"" ] [ :, i * N : ( i + 1 ) * N, : ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> with self. tile_request ( tx, ty, readonly = False ) as dst : <TAB> <TAB> <TAB> <TAB> mypaintlib. tile_convert_rgba8_to_rgba16 ( src, dst, self. EOTF ) <TAB> if state [ ""progress"" ] : <TAB> <TAB> try : <TAB> <TAB> <TAB> state [ ""progress"" ]. completed ( ty - ty0 ) <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> logger. exception ( ""Progress.completed() failed"" ) <TAB> <TAB> <TAB> state [ ""progress"" ] = None",False,"src[:, :, 3].any()",state['tile'],0.6509518623352051
|
||
|
2492,"def using_user_docutils_conf ( confdir : str ) -> Generator [ None, None, None ] : <TAB> """"""Let docutils know the location of ``docutils.conf`` for Sphinx."""""" <TAB> try : <TAB> <TAB> docutilsconfig = os. environ. get ( ""DOCUTILSCONFIG"", None ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> os. environ [ ""DOCUTILSCONFIG"" ] = path. join ( <TAB> <TAB> <TAB> <TAB> path. abspath ( confdir ), ""docutils.conf"" <TAB> <TAB> <TAB> ) <TAB> <TAB> yield <TAB> finally : <TAB> <TAB> if docutilsconfig is None : <TAB> <TAB> <TAB> os. environ. pop ( ""DOCUTILSCONFIG"", None ) <TAB> <TAB> else : <TAB> <TAB> <TAB> os. environ [ ""DOCUTILSCONFIG"" ] = docutilsconfig",False,confdir,path is not None,0.6801047921180725
|
||
|
2493,"def evaluate_batch_e2e ( args, rag_model, questions ) : <TAB> with torch. no_grad ( ) : <TAB> <TAB> inputs_dict = rag_model. retriever. question_encoder_tokenizer. batch_encode_plus ( <TAB> <TAB> <TAB> questions, return_tensors = ""pt"", padding = True, truncation = True <TAB> <TAB> ) <TAB> <TAB> input_ids = inputs_dict. input_ids. to ( args. device ) <TAB> <TAB> attention_mask = inputs_dict. attention_mask. to ( args. device ) <TAB> <TAB> outputs = rag_model. generate ( <TAB> <TAB> <TAB> input_ids, <TAB> <TAB> <TAB> attention_mask = attention_mask, <TAB> <TAB> <TAB> num_beams = args. num_beams, <TAB> <TAB> <TAB> min_length = args. min_length, <TAB> <TAB> <TAB> max_length = args. max_length, <TAB> <TAB> <TAB> early_stopping = False, <TAB> <TAB> <TAB> num_return_sequences = 1, <TAB> <TAB> <TAB> bad_words_ids = [ <TAB> <TAB> <TAB> <TAB> [ 0, 0 ] <TAB> <TAB> <TAB> ], <TAB> <TAB> ) <TAB> <TAB> answers = rag_model. retriever. generator_tokenizer. batch_decode ( <TAB> <TAB> <TAB> outputs, skip_special_tokens = True <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> for q, a in zip ( questions, answers ) : <TAB> <TAB> <TAB> <TAB> logger. info ( ""Q: {} - A: {}"". format ( q, a ) ) <TAB> <TAB> return answers",False,args.print_predictions,len(answers) > 0,0.6567527055740356
|
||
|
2494,"def compute_timer_precision ( timer ) : <TAB> precision = None <TAB> points = 0 <TAB> timeout = timeout_timer ( ) + 1.0 <TAB> previous = timer ( ) <TAB> while timeout_timer ( ) < timeout or points < 5 : <TAB> <TAB> for _ in XRANGE ( 10 ) : <TAB> <TAB> <TAB> t1 = timer ( ) <TAB> <TAB> <TAB> t2 = timer ( ) <TAB> <TAB> <TAB> dt = t2 - t1 <TAB> <TAB> <TAB> if 0 < dt : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> else : <TAB> <TAB> <TAB> dt = t2 - previous <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> if precision is not None : <TAB> <TAB> <TAB> precision = min ( precision, dt ) <TAB> <TAB> else : <TAB> <TAB> <TAB> precision = dt <TAB> <TAB> points += 1 <TAB> <TAB> previous = timer ( ) <TAB> return precision",False,dt <= 0.0,0 < dt,0.672704815864563
|
||
|
2495,"def forward_pass ( self, buffers, training_pass = True ) : <TAB> <TAB> _h = self. handler <TAB> W, R, bias, timing = buffers. parameters <TAB> inputs = buffers. inputs. default <TAB> outputs = buffers. outputs. default <TAB> Ha = buffers. internals. Ha <TAB> flat_inputs = flatten_time_and_features ( inputs ) <TAB> flat_H = flatten_time ( Ha [ : - 1 ] ) <TAB> _h. dot_mm ( flat_inputs, W, flat_H, transb = True ) <TAB> _h. add_mv ( flat_H, bias. reshape ( ( 1, self. size ) ), flat_H ) <TAB> tmp = _h. zeros ( timing. shape ) <TAB> cond = _h. zeros ( outputs [ 0 ]. shape ) <TAB> for t in range ( inputs. shape [ 0 ] ) : <TAB> <TAB> _h. dot_add_mm ( outputs [ t - 1 ], R, Ha [ t ], transb = True ) <TAB> <TAB> _h. act_func [ self. activation ] ( Ha [ t ], outputs [ t ] ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> _h. fill ( tmp, t ) <TAB> <TAB> <TAB> _h. modulo_tt ( tmp, timing, tmp ) <TAB> <TAB> <TAB> _h. broadcast_t ( tmp. reshape ( ( 1, tmp. shape [ 0 ] ) ), 0, cond ) <TAB> <TAB> <TAB> _h. copy_to_if ( outputs [ t - 1 ], outputs [ t ], cond )",False,t > 0,training_pass,0.6696994304656982
|
||
|
2496,"def _is_static_shape ( self, shape ) : <TAB> if shape is None or not isinstance ( shape, list ) : <TAB> <TAB> return False <TAB> for dim_value in shape : <TAB> <TAB> if not isinstance ( dim_value, int ) : <TAB> <TAB> <TAB> return False <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise Exception ( ""Negative dimension is illegal: %d"" % dim_value ) <TAB> return True",False,dim_value < 0,dim_value <= 0,0.663841962814331
|
||
|
2497,"def _update_balancer ( self, params ) : <TAB> try : <TAB> <TAB> return self. connection. request ( <TAB> <TAB> <TAB> ""/api/grid/loadbalancer/edit"", method = ""POST"", params = params <TAB> <TAB> ) <TAB> except Exception as e : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise LibcloudLBImmutableError ( ""Balancer is immutable"", GoGridLBDriver ) <TAB> <TAB> raise LibcloudError ( value = ""Exception: %s"" % str ( e ), driver = self )",False,'Update already pending' in str(e),self.is_mutable,0.6577302813529968
|
||
|
2498,"def read_raw_data ( <TAB> self, <TAB> filename, <TAB> ordered = False, <TAB> lower_case = True, <TAB> delimiter = None, <TAB> add_eos = True, <TAB> add_double_eos = False, ) : <TAB> assert os. path. exists ( filename ), ""%s is not exist. "" % filename <TAB> data = [ ] <TAB> with open ( filename, ""r"", encoding = ""utf-8"" ) as f : <TAB> <TAB> for line in f : <TAB> <TAB> <TAB> tokens = LMDataset. tokenize ( <TAB> <TAB> <TAB> <TAB> line = line, delimiter = delimiter, lower_case = lower_case <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> tokens = ( <TAB> <TAB> <TAB> <TAB> <TAB> [ self. vocab. _identifiers_to_tokens [ ""bos_token"" ] ] <TAB> <TAB> <TAB> <TAB> <TAB> + tokens <TAB> <TAB> <TAB> <TAB> <TAB> + [ self. vocab. _identifiers_to_tokens [ ""bos_token"" ] ] <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> elif add_eos : <TAB> <TAB> <TAB> <TAB> tokens = tokens + [ self. vocab. _identifiers_to_tokens [ ""eos_token"" ] ] <TAB> <TAB> <TAB> data. append ( np. asarray ( self. get_indices ( tokens ) ). astype ( ""int64"" ) ) <TAB> if ordered : <TAB> <TAB> data = np. concatenate ( data ) <TAB> return data",True,add_double_eos,add_double_eos,0.6560062766075134
|
||
|
2499,"def _EvalCondition ( self, cond, spid ) : <TAB> <TAB> b = False <TAB> UP_cond = cond <TAB> with tagswitch ( cond ) as case : <TAB> <TAB> if case ( condition_e. Shell ) : <TAB> <TAB> <TAB> cond = cast ( condition__Shell, UP_cond ) <TAB> <TAB> <TAB> self. _StrictErrExitList ( cond. commands ) <TAB> <TAB> <TAB> with state. ctx_ErrExit ( self. mutable_opts, False, spid ) : <TAB> <TAB> <TAB> <TAB> cond_status = self. _ExecuteList ( cond. commands ) <TAB> <TAB> <TAB> b = cond_status == 0 <TAB> <TAB> elif case ( condition_e. Oil ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> cond = cast ( condition__Oil, UP_cond ) <TAB> <TAB> <TAB> <TAB> obj = self. expr_ev. EvalExpr ( cond. e ) <TAB> <TAB> <TAB> <TAB> b = bool ( obj ) <TAB> return b",False,mylib.PYTHON,case case case,0.6687970161437988
|
||
|
2500,"def sina_download ( url, info_only = False, ** kwargs ) : <TAB> """"""Downloads Sina videos by URL."""""" <TAB> if ""news.sina.com.cn/zxt"" in url : <TAB> <TAB> sina_zxt ( url, info_only = info_only, ** kwargs ) <TAB> <TAB> return <TAB> vid = match1 ( url, r""vid=(\d+)"" ) <TAB> if vid is None : <TAB> <TAB> video_page = get_content ( url ) <TAB> <TAB> vid = hd_vid = match1 ( video_page, r""hd_vid\s*:\s*\'([^\']+)\'"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> vids = match1 ( video_page, r""[^\w]vid\s*:\s*\'([^\']+)\'"" ). split ( ""|"" ) <TAB> <TAB> <TAB> vid = vids [ - 1 ] <TAB> if vid is None : <TAB> <TAB> vid = match1 ( video_page, r'vid:""?(\d+)""?' ) <TAB> if vid : <TAB> <TAB> <TAB> <TAB> sina_download_by_vid ( vid, info_only = info_only, ** kwargs ) <TAB> else : <TAB> <TAB> vkey = match1 ( video_page, r'vkey\s*:\s*""([^""]+)""' ) <TAB> <TAB> if vkey is None : <TAB> <TAB> <TAB> vid = match1 ( url, r""#(\d+)"" ) <TAB> <TAB> <TAB> sina_download_by_vid ( vid, info_only = info_only, ** kwargs ) <TAB> <TAB> <TAB> return <TAB> <TAB> title = match1 ( video_page, r'title\s*:\s*""([^""]+)""' ) <TAB> <TAB> sina_download_by_vkey ( vkey, title = title, info_only = info_only, ** kwargs )",False,hd_vid == '0',vid == 0,0.6591084003448486
|
||
|
2501,"def set_merge_cells ( self, mergecells ) : <TAB> if not mergecells : <TAB> <TAB> return <TAB> if not self. filedata : <TAB> <TAB> self. filedata = self. filehandle. read ( ) <TAB> data = str ( self. filedata ) <TAB> <TAB> start = data. find ( ""<worksheet"" ) <TAB> if start < 0 : <TAB> <TAB> return <TAB> end = data. find ( "">"", start ) <TAB> worksheet = data [ start : end + 1 ] <TAB> <TAB> start = data. find ( ""<mergeCells"" ) <TAB> if start < 0 : <TAB> <TAB> <TAB> <TAB> return <TAB> end = data. find ( ""</mergeCells>"" ) <TAB> data = data [ start : end + 13 ] <TAB> <TAB> doc = minidom. parseString ( worksheet + data + ""</worksheet>"" ). firstChild <TAB> if doc. namespaceURI : <TAB> <TAB> mergeCells = doc. getElementsByTagNameNS ( doc. namespaceURI, ""mergeCell"" ) <TAB> else : <TAB> <TAB> mergeCells = doc. getElementsByTagName ( ""mergeCell"" ) <TAB> for mergeCell in mergeCells : <TAB> <TAB> attrs = mergeCell. _attrs <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> rangeStr = attrs [ ""ref"" ]. value <TAB> <TAB> <TAB> rng = rangeStr. split ( "":"" ) <TAB> <TAB> <TAB> if len ( rng ) > 1 : <TAB> <TAB> <TAB> <TAB> for cell in self. _range ( rangeStr ) : <TAB> <TAB> <TAB> <TAB> <TAB> self. mergeCells [ cell ] = { } <TAB> <TAB> <TAB> <TAB> <TAB> self. mergeCells [ cell ] [ ""copyFrom"" ] = rng [ 0 ]",False,'ref' in attrs.keys(),attrs,0.6532999277114868
|
||
|
2502,"def parseFunctionDeclaration ( self, node, identifierIsOptional = None ) : <TAB> d = null <TAB> params = [ ] <TAB> defaults = [ ] <TAB> message = None <TAB> firstRestricted = None <TAB> self. expectKeyword ( ""function"" ) <TAB> if identifierIsOptional or not self. match ( ""("" ) : <TAB> <TAB> token = self. lookahead <TAB> <TAB> d = self. parseVariableIdentifier ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if isRestrictedWord ( token [ ""value"" ] ) : <TAB> <TAB> <TAB> <TAB> self. tolerateUnexpectedToken ( token, Messages. StrictFunctionName ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if isRestrictedWord ( token [ ""value"" ] ) : <TAB> <TAB> <TAB> <TAB> firstRestricted = token <TAB> <TAB> <TAB> <TAB> message = Messages. StrictFunctionName <TAB> <TAB> <TAB> elif isStrictModeReservedWord ( token [ ""value"" ] ) : <TAB> <TAB> <TAB> <TAB> firstRestricted = token <TAB> <TAB> <TAB> <TAB> message = Messages. StrictReservedWord <TAB> tmp = self. parseParams ( firstRestricted ) <TAB> params = tmp [ ""params"" ] <TAB> defaults = tmp [ ""defaults"" ] <TAB> stricted = tmp. get ( ""stricted"" ) <TAB> firstRestricted = tmp [ ""firstRestricted"" ] <TAB> if tmp. get ( ""message"" ) : <TAB> <TAB> message = tmp [ ""message"" ] <TAB> previousStrict = self. strict <TAB> body = self. parseFunctionSourceElements ( ) <TAB> if self. strict and firstRestricted : <TAB> <TAB> self. throwUnexpectedToken ( firstRestricted, message ) <TAB> if self. strict and stricted : <TAB> <TAB> self. tolerateUnexpectedToken ( stricted, message ) <TAB> self. strict = previousStrict <TAB> return node. finishFunctionDeclaration ( d, params, defaults, body )",False,self.strict,d == None,0.6624323129653931
|
||
|
2503,"def _parse_service_catalog_auth_v3 ( self, service_catalog ) : <TAB> entries = [ ] <TAB> for item in service_catalog : <TAB> <TAB> service_type = item [ ""type"" ] <TAB> <TAB> service_name = item. get ( ""name"", None ) <TAB> <TAB> entry_endpoints = [ ] <TAB> <TAB> for endpoint in item [ ""endpoints"" ] : <TAB> <TAB> <TAB> region = endpoint. get ( ""region"", None ) <TAB> <TAB> <TAB> url = endpoint [ ""url"" ] <TAB> <TAB> <TAB> endpoint_type = endpoint [ ""interface"" ] <TAB> <TAB> <TAB> if endpoint_type == ""internal"" : <TAB> <TAB> <TAB> <TAB> endpoint_type = OpenStackIdentityEndpointType. INTERNAL <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> endpoint_type = OpenStackIdentityEndpointType. EXTERNAL <TAB> <TAB> <TAB> elif endpoint_type == ""admin"" : <TAB> <TAB> <TAB> <TAB> endpoint_type = OpenStackIdentityEndpointType. ADMIN <TAB> <TAB> <TAB> entry_endpoint = OpenStackServiceCatalogEntryEndpoint ( <TAB> <TAB> <TAB> <TAB> region = region, url = url, endpoint_type = endpoint_type <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> entry_endpoints. append ( entry_endpoint ) <TAB> <TAB> entry = OpenStackServiceCatalogEntry ( <TAB> <TAB> <TAB> service_type = service_type, <TAB> <TAB> <TAB> service_name = service_name, <TAB> <TAB> <TAB> endpoints = entry_endpoints, <TAB> <TAB> ) <TAB> <TAB> entries. append ( entry ) <TAB> return entries",False,endpoint_type == 'public',endpoint_type == 'external',0.6567357778549194
|
||
|
2504,"def run ( self, bar_dict ) : <TAB> conf = self. _env. config. base <TAB> for event in self. _env. event_source. events ( <TAB> <TAB> conf. start_date, conf. end_date, conf. frequency <TAB> ) : <TAB> <TAB> if event. event_type == EVENT. TICK : <TAB> <TAB> <TAB> if self. _ensure_before_trading ( event ) : <TAB> <TAB> <TAB> <TAB> self. _split_and_publish ( event ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> if self. _ensure_before_trading ( event ) : <TAB> <TAB> <TAB> <TAB> bar_dict. update_dt ( event. calendar_dt ) <TAB> <TAB> <TAB> <TAB> event. bar_dict = bar_dict <TAB> <TAB> <TAB> <TAB> self. _split_and_publish ( event ) <TAB> <TAB> elif event. event_type == EVENT. OPEN_AUCTION : <TAB> <TAB> <TAB> if self. _ensure_before_trading ( event ) : <TAB> <TAB> <TAB> <TAB> bar_dict. update_dt ( event. calendar_dt ) <TAB> <TAB> <TAB> <TAB> event. bar_dict = bar_dict <TAB> <TAB> <TAB> <TAB> self. _split_and_publish ( event ) <TAB> <TAB> elif event. event_type == EVENT. BEFORE_TRADING : <TAB> <TAB> <TAB> self. _ensure_before_trading ( event ) <TAB> <TAB> elif event. event_type == EVENT. AFTER_TRADING : <TAB> <TAB> <TAB> self. _split_and_publish ( event ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. _env. event_bus. publish_event ( event ) <TAB> <TAB> self. _split_and_publish ( Event ( EVENT. SETTLEMENT ) )",False,event.event_type == EVENT.BAR,event.event_type == EVENT.SPACE,0.6555917263031006
|
||
|
2505,"def _pipe_relay ( stopped, fd, name, cb, tee, output_writer ) : <TAB> while True : <TAB> <TAB> try : <TAB> <TAB> <TAB> data = os. read ( fd, 4096 ) <TAB> <TAB> except OSError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> if len ( data ) == 0 : <TAB> <TAB> <TAB> break <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if data. endswith ( _LAST_WRITE_TOKEN. encode ( ) ) : <TAB> <TAB> <TAB> <TAB> logger. info ( ""relay done saw last write: %s"", name ) <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> if tee : <TAB> <TAB> <TAB> os. write ( tee, data ) <TAB> <TAB> if output_writer : <TAB> <TAB> <TAB> output_writer. write ( data ) <TAB> <TAB> if cb : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> cb ( name, data ) <TAB> <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> <TAB> logger. exception ( ""problem in pipe relay"" ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> cb = None <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> logger. info ( ""relay done done: %s"", name )",False,stopped.isSet(),stopped,0.6573858261108398
|
||
|
2506,"def _get_sources ( self ) : <TAB> servers = self. config [ ""servers"" ] <TAB> url = """" <TAB> for i in servers : <TAB> <TAB> params = { <TAB> <TAB> <TAB> ""s"" : i, <TAB> <TAB> <TAB> ""episode_id"" : self. url. split ( ""id="" ) [ - 1 ], <TAB> <TAB> } <TAB> <TAB> api = helpers. post ( <TAB> <TAB> <TAB> self. _episode_list_url, params = params, referer = self. url <TAB> <TAB> ). json ( ) <TAB> <TAB> if api. get ( ""status"", False ) : <TAB> <TAB> <TAB><mask> : <TAB> <TAB> <TAB> url = re. search ( iframe_regex, api [ ""value"" ] ). group ( 1 ) <TAB> <TAB> <TAB> if url. startswith ( ""//"" ) : <TAB> <TAB> <TAB> <TAB> url = ""https:"" + url <TAB> <TAB> <TAB> if url. endswith ( ""mp4upload.com/embed-.html"" ) or url. endswith ( <TAB> <TAB> <TAB> <TAB> ""yourupload.com/embed/"" <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> url = """" <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> break <TAB> extractor = ""streamx"" <TAB> extractor_urls = { <TAB> <TAB> ""mp4upload.com"" : ""mp4upload"", <TAB> <TAB> ""yourupload.com"" : ""yourupload"", <TAB> } <TAB> for i in extractor_urls : <TAB> <TAB> if i in url : <TAB> <TAB> <TAB> extractor = extractor_urls [ i ] <TAB> return [ ( extractor, url ) ]",False,"iframe_regex = '<iframe src=""([^""]*?)""'",iframe_regex is not None,0.6590650081634521
|
||
|
2507,"def _resize_masks ( self, results ) : <TAB> """"""Resize masks with ``results['scale']``"""""" <TAB> for key in results. get ( ""mask_fields"", [ ] ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> if self. keep_ratio : <TAB> <TAB> <TAB> results [ key ] = results [ key ]. rescale ( results [ ""scale"" ] ) <TAB> <TAB> else : <TAB> <TAB> <TAB> results [ key ] = results [ key ]. resize ( results [ ""img_shape"" ] [ : 2 ] )",False,results[key] is None,key not in results,0.6575219631195068
|
||
|
2508,"def onCompletion ( self, text ) : <TAB> res = [ ] <TAB> for l in text. split ( ""\n"" ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> l = l. split ( "":"" ) <TAB> <TAB> if len ( l )!= 2 : <TAB> <TAB> <TAB> continue <TAB> <TAB> res. append ( [ l [ 0 ]. strip ( ), l [ 1 ]. strip ( ) ] ) <TAB> self. panel. setChapters ( res )",True,not l,not l,0.672437310218811
|
||
|
2509,"def get_mech_config ( limit = None ) : <TAB> logger. info ( ""Getting Mech config..."" ) <TAB> if limit and not isinstance ( limit, ( list, tuple ) ) : <TAB> <TAB> limit = [ limit ] <TAB> <TAB> with progress_spinner ( { ""mech ls"" } ) as progress : <TAB> <TAB> output = local. shell ( <TAB> <TAB> <TAB> ""mech ls"", <TAB> <TAB> <TAB> splitlines = True, <TAB> <TAB> ) <TAB> <TAB> progress ( ""mech ls"" ) <TAB> targets = [ ] <TAB> for line in output : <TAB> <TAB> address = """" <TAB> <TAB> data = line. split ( ) <TAB> <TAB> target = data [ 0 ] <TAB> <TAB> if len ( data ) == 5 : <TAB> <TAB> <TAB> address = data [ 1 ] <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> if address!= """" and address [ 0 ]. isdigit ( ) : <TAB> <TAB> <TAB> targets. append ( target ) <TAB> threads = [ ] <TAB> config_queue = Queue ( ) <TAB> with progress_spinner ( targets ) as progress : <TAB> <TAB> for target in targets : <TAB> <TAB> <TAB> thread = Thread ( <TAB> <TAB> <TAB> <TAB> target = _get_mech_ssh_config, <TAB> <TAB> <TAB> <TAB> args = ( config_queue, progress, target ), <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> threads. append ( thread ) <TAB> <TAB> <TAB> thread. start ( ) <TAB> for thread in threads : <TAB> <TAB> thread. join ( ) <TAB> queue_items = list ( config_queue. queue ) <TAB> lines = [ ] <TAB> for output in queue_items : <TAB> <TAB> lines. extend ( output ) <TAB> return lines",False,limit is not None and target not in limit,address == None,0.6587840914726257
|
||
|
2510,"def _get_python_wrapper_content ( self, job_class, args ) : <TAB> job = job_class ( [ ""-r"", ""hadoop"" ] + list ( args ) ) <TAB> job. sandbox ( ) <TAB> with job. make_runner ( ) as runner : <TAB> <TAB> runner. _create_setup_wrapper_scripts ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> with open ( runner. _spark_python_wrapper_path ) as f : <TAB> <TAB> <TAB> <TAB> return f. read ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return None",False,runner._spark_python_wrapper_path,self.python_python_wrapper_path is not None,0.6545815467834473
|
||
|
2511,"def manage_user_outputs_with_mapping ( mapping, reference_mapping, user_layers ) : <TAB> if mapping is not None and reference_mapping is not None : <TAB> <TAB> layers_map = map_layers ( mapping, reference_mapping ) <TAB> else : <TAB> <TAB> layers_map = { layer : layer for layer in user_layers } <TAB> for layer in user_layers : <TAB> <TAB> if layer not in layers_map : <TAB> <TAB> <TAB> if mapping is not None and reference_mapping is not None : <TAB> <TAB> <TAB> <TAB> log. warning ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Can not map layer {} from --model/-m to any layer from --reference_model/-ref_m"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> layer <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> log. warning ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Can not find layer {} in --reference_model/-ref_m model"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> layer <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> ) <TAB> for layer in layers_map : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> del layers_map [ layer ] <TAB> return layers_map",False,layer not in user_layers,layer in layers_map,0.657917320728302
|
||
|
2512,"def set ( self, obj, ** kwargs ) : <TAB> """"""Check for missing event functions and substitute these with"""""" <TAB> """"""the ignore method"""""" <TAB> ignore = getattr ( self, ""ignore"" ) <TAB> for k, v in kwargs. iteritems ( ) : <TAB> <TAB> setattr ( self, k, getattr ( obj, v ) ) <TAB> <TAB> if k in self. combinations : <TAB> <TAB> <TAB> for k1 in self. combinations [ k ] : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> setattr ( self, k1, ignore )",False,"not hasattr(self, k1)",k1 in self.combining,0.6515053510665894
|
||
|
2513,"def is_dead ( self ) : <TAB> monkey_is_dead = False <TAB> if self. dead : <TAB> <TAB> monkey_is_dead = True <TAB> else : <TAB> <TAB> try : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> monkey_is_dead = True <TAB> <TAB> except ( DoesNotExist, AttributeError ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> monkey_is_dead = True <TAB> return monkey_is_dead",False,MonkeyTtl.objects(id=self.ttl_ref.id).count() == 0,self.get_data(),0.6618226766586304
|
||
|
2514,"def set_date ( self, year, month, day ) : <TAB> try : <TAB> <TAB> date ( year, month, day ) <TAB> except Exception as e : <TAB> <TAB> if str ( e ) == ""day is out of range for month"" : <TAB> <TAB> <TAB> raise self. SetDateError ( <TAB> <TAB> <TAB> <TAB> "" Day %s day is out of range for month %s"" % ( day, month ) <TAB> <TAB> <TAB> ) <TAB> <TAB> elif str ( e ) == ""month must be in 1..12"" : <TAB> <TAB> <TAB> raise self. SetDateError ( ""Month must be between 1 and 12, got %s"" % month ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> raise self. SetDateError ( <TAB> <TAB> <TAB> <TAB> ""Year must be between %s and %s, got %s"" <TAB> <TAB> <TAB> <TAB> % ( datetime. MINYEAR, datetime. MAXYEAR, year ) <TAB> <TAB> <TAB> ) <TAB> else : <TAB> <TAB> self. sel_year = year <TAB> <TAB> self. sel_month = month <TAB> <TAB> self. sel_day = day <TAB> <TAB> self. month = self. sel_month <TAB> <TAB> self. year = self. sel_year <TAB> <TAB> self. day = self. sel_day <TAB> <TAB> self. update_cal_matrix ( self. sel_year, self. sel_month ) <TAB> <TAB> self. set_month_day ( self. sel_day ) <TAB> <TAB> self. selector. update ( )",False,str(e) == 'year is out of range',str(e) == 'year must be in 1..12',0.6623948216438293
|
||
|
2515,"def create_docker_client ( ) : <TAB> try : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> print ( ""using environment to create docker client"" ) <TAB> <TAB> <TAB> c = docker. from_env ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> c = docker. DockerClient ( <TAB> <TAB> <TAB> <TAB> base_url = ""unix://var/run/docker.sock"", version = ""auto"" <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> c. run = run ( c ) <TAB> <TAB> return c <TAB> except DockerException as e : <TAB> <TAB> print ( ""Unable to connect to a docker socket"" ) <TAB> <TAB> raise pytest. UsageError ( <TAB> <TAB> <TAB> ""Could not connect to a running docker socket: %s"" % str ( e ) <TAB> <TAB> )",False,use_environ(),not HAS_docker,0.6602483987808228
|
||
|
2516,"def visitIf ( self, node, scope ) : <TAB> for test, body in node. tests : <TAB> <TAB> if isinstance ( test, ast. Const ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> if not test. value : <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> self. visit ( test, scope ) <TAB> <TAB> self. visit ( body, scope ) <TAB> if node. else_ : <TAB> <TAB> self. visit ( node. else_, scope )",False,type(test.value) in self._const_types,body is not None,0.6497872471809387
|
||
|
2517,"def __exit__ ( self, * exc_info ) : <TAB> super ( WarningsChecker, self ). __exit__ ( * exc_info ) <TAB> <TAB> if all ( a is None for a in exc_info ) : <TAB> <TAB> if self. expected_warning is not None : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> __tracebackhide__ = True <TAB> <TAB> <TAB> <TAB> pytest. fail ( ""DID NOT WARN"" )",False,not any((r.category in self.expected_warning for r in self)),self.__tracebackhide__ is False,0.6558982133865356
|
||
|
2518,"def test_arguments_regex ( self ) : <TAB> argument_matches = ( <TAB> <TAB> ( ""pip=1.1"", ( ""pip"", ""1.1"" ) ), <TAB> <TAB> ( ""pip==1.1"", None ), <TAB> <TAB> ( ""pip=1.2=1"", ( ""pip"", ""1.2=1"" ) ), <TAB> ) <TAB> for argument, match in argument_matches : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. assertIsNone ( salt. utils. args. KWARG_REGEX. match ( argument ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. assertEqual ( <TAB> <TAB> <TAB> <TAB> salt. utils. args. KWARG_REGEX. match ( argument ). groups ( ), match <TAB> <TAB> <TAB> )",True,match is None,match is None,0.6565696001052856
|
||
|
2519,"def normalize ( d : Dict [ Any, Any ] ) -> Dict [ str, Any ] : <TAB> first_exception = None <TAB> for normalizer in normalizers : <TAB> <TAB> try : <TAB> <TAB> <TAB> normalized = normalizer ( d ) <TAB> <TAB> except KeyError as e : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> first_exception = e <TAB> <TAB> else : <TAB> <TAB> <TAB> return normalized <TAB> assert first_exception is not None <TAB> raise first_exception",False,not first_exception,first_exception is None,0.6661331653594971
|
||
|
2520,"def _fatal_error ( self, exc, message = ""Fatal error on pipe transport"" ) : <TAB> if isinstance ( exc, ( BrokenPipeError, ConnectionResetError ) ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> logger. debug ( ""%r: %s"", self, message, exc_info = True ) <TAB> else : <TAB> <TAB> self. _loop. call_exception_handler ( <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> ""message"" : message, <TAB> <TAB> <TAB> <TAB> ""exception"" : exc, <TAB> <TAB> <TAB> <TAB> ""transport"" : self, <TAB> <TAB> <TAB> <TAB> ""protocol"" : self. _protocol, <TAB> <TAB> <TAB> } <TAB> <TAB> ) <TAB> self. _force_close ( exc )",True,self._loop.get_debug(),self._loop.get_debug(),0.6518343091011047
|
||
|
2521,"def __getattr__ ( self, name ) : <TAB> <TAB> if name in SPINNER_ATTRS : <TAB> <TAB> from. spinners import Spinners <TAB> <TAB> sp = getattr ( Spinners, name ) <TAB> <TAB> self. spinner = sp <TAB> <TAB> elif name in COLOR_ATTRS : <TAB> <TAB> attr_type = COLOR_MAP [ name ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. attrs = [ name ] <TAB> <TAB> if attr_type in ( ""color"", ""on_color"" ) : <TAB> <TAB> <TAB> setattr ( self, attr_type, name ) <TAB> <TAB> elif name in ( ""left"", ""right"" ) : <TAB> <TAB> self. side = name <TAB> <TAB> else : <TAB> <TAB> raise AttributeError ( <TAB> <TAB> <TAB> ""'{0}' object has no attribute: '{1}'"". format ( self. __class__. __name__, name ) <TAB> <TAB> ) <TAB> return self",False,attr_type == 'attrs',"attr_type in (None, 'object', 'type')",0.6599444150924683
|
||
|
2522,"def _cmd_rmrcconsistgrp ( self, ** kwargs ) : <TAB> if ""obj"" not in kwargs : <TAB> <TAB> return self. _errors [ ""CMMVC5701E"" ] <TAB> rccg_name = kwargs [ ""obj"" ]. strip ( ""'\"""" ) <TAB> force = True if ""force"" in kwargs else False <TAB> try : <TAB> <TAB> rccg = self. _rcconsistgrp_list [ rccg_name ] <TAB> except KeyError : <TAB> <TAB> return self. _errors [ ""CMMVC5804E"" ] <TAB> function = ""delete_force"" if force else ""delete"" <TAB> self. _rccg_state_transition ( function, rccg ) <TAB> if rccg [ ""state"" ] == ""end"" : <TAB> <TAB> for rcrel_info in self. _rcrelationship_list. values ( ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> rcrel_info [ ""consistency_group_name"" ] = """" <TAB> <TAB> <TAB> <TAB> rcrel_info [ ""consistency_group_id"" ] = """" <TAB> <TAB> del self. _rcconsistgrp_list [ rccg_name ] <TAB> return ( """", """" )",False,rcrel_info['consistency_group_name'] == rccg['name'],rcrel_info[rccg_name] == 'consistency_group_id',0.6476861238479614
|
||
|
2523,"def _read_header_lines ( fp ) : <TAB> """"""Read lines with headers until the start of body"""""" <TAB> lines = deque ( ) <TAB> for line in fp : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if not _RE_HEADER. match ( line ) : <TAB> <TAB> <TAB> fp. seek ( fp. tell ( ) - len ( line ) ) <TAB> <TAB> <TAB> break <TAB> <TAB> lines. append ( line ) <TAB> return lines",False,is_empty(line),line.startswith(line),0.647891640663147
|
||
|
2524,"def create_accumulator ( self ) -> tf_metric_accumulators. TFCompilableMetricsAccumulator : <TAB> configs = zip ( self. _metric_configs, self. _loss_configs ) <TAB> padding_options = None <TAB> if self. _eval_config is not None : <TAB> <TAB> model_spec = model_util. get_model_spec ( self. _eval_config, self. _model_name ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> padding_options = model_spec. padding_options <TAB> return tf_metric_accumulators. TFCompilableMetricsAccumulator ( <TAB> <TAB> padding_options, <TAB> <TAB> [ len ( m ) + len ( l ) for m, l in configs ], <TAB> <TAB> desired_batch_size = self. _desired_batch_size, <TAB> )",False,model_spec is not None and model_spec.HasField('padding_options'),model_spec is not None,0.6490122079849243
|
||
|
2525,"def local_recursive_function ( list_opt, out, optimized_vars, depth ) : <TAB> if not getattr ( out, ""owner"", None ) : <TAB> <TAB> return [ out ], optimized_vars <TAB> node = out. owner <TAB> if hasattr ( node, ""fgraph"" ) : <TAB> <TAB> return node. outputs, optimized_vars <TAB> for idx, inp in enumerate ( node. inputs ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> nw_in = optimized_vars [ inp ] <TAB> <TAB> else : <TAB> <TAB> <TAB> if inp. owner : <TAB> <TAB> <TAB> <TAB> outs, optimized_vars = local_recursive_function ( <TAB> <TAB> <TAB> <TAB> <TAB> list_opt, inp, optimized_vars, depth + 1 <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> for k, v in zip ( inp. owner. outputs, outs ) : <TAB> <TAB> <TAB> <TAB> <TAB> optimized_vars [ k ] = v <TAB> <TAB> <TAB> <TAB> nw_in = outs [ inp. owner. outputs. index ( inp ) ] <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> nw_in = inp <TAB> <TAB> <TAB> <TAB> optimized_vars [ inp ] = inp <TAB> <TAB> node. inputs [ idx ] = nw_in <TAB> results = node. outputs <TAB> for opt in list_opt : <TAB> <TAB> ret = opt. transform ( node ) <TAB> <TAB> if ret is not False and ret is not None : <TAB> <TAB> <TAB> assert len ( ret ) == len ( node. outputs ), opt <TAB> <TAB> <TAB> for k, v in zip ( node. outputs, ret ) : <TAB> <TAB> <TAB> <TAB> optimized_vars [ k ] = v <TAB> <TAB> <TAB> results = ret <TAB> <TAB> <TAB> if ret [ 0 ]. owner : <TAB> <TAB>",True,inp in optimized_vars,inp in optimized_vars,0.6667083501815796
|
||
|
2526,"def _alter_begin ( <TAB> self, <TAB> schema : s_schema. Schema, <TAB> context : sd. CommandContext, ) -> s_schema. Schema : <TAB> schema = super ( ). _alter_begin ( schema, context ) <TAB> scls = self. scls <TAB> if not context. canonical : <TAB> <TAB> props = self. enumerate_attributes ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if context. enable_recursion : <TAB> <TAB> <TAB> <TAB> self. _propagate_field_alter ( schema, context, scls, props ) <TAB> <TAB> <TAB> bases = scls. get_bases ( schema ). objects ( schema ) <TAB> <TAB> <TAB> self. inherit_fields ( schema, context, bases, fields = props ) <TAB> return schema",False,props,len(props) > 0,0.6828353404998779
|
||
|
2527,"def double_click ( self, obj, event ) : <TAB> """"""the user wants to edit the selected person or family"""""" <TAB> if event. type == Gdk. EventType. _2BUTTON_PRESS and event. button == 1 : <TAB> <TAB> ( model, node ) = self. selection. get_selected ( ) <TAB> <TAB> if not node : <TAB> <TAB> <TAB> return <TAB> <TAB> sort_path = self. sort_model. get_path ( node ) <TAB> <TAB> filt_path = self. sort_model. convert_path_to_child_path ( sort_path ) <TAB> <TAB> real_path = self. filt_model. convert_path_to_child_path ( filt_path ) <TAB> <TAB> row = self. real_model [ real_path ] <TAB> <TAB> the_type = row [ VerifyResults. OBJ_TYPE_COL ] <TAB> <TAB> handle = row [ VerifyResults. OBJ_HANDLE_COL ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> person = self. dbstate. db. get_person_from_handle ( handle ) <TAB> <TAB> <TAB> <TAB> EditPerson ( self. dbstate, self. uistate, self. track, person ) <TAB> <TAB> <TAB> except WindowActiveError : <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> elif the_type == ""Family"" : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> family = self. dbstate. db. get_family_from_handle ( handle ) <TAB> <TAB> <TAB> <TAB> EditFamily ( self. dbstate, self. uistate, self. track, family ) <TAB> <TAB> <TAB> except WindowActiveError : <TAB> <TAB> <TAB> <TAB> pass",True,the_type == 'Person',the_type == 'Person',0.6530232429504395
|
||
|
2528,"def __init__ ( <TAB> self, <TAB> data, <TAB> batch_size : int, <TAB> num_steps : int = 1, <TAB> sample_coverage : int = 0, <TAB> save_dir : Optional [ str ] = None, <TAB> log : bool = True, <TAB> ** kwargs ) : <TAB> assert data. edge_index is not None <TAB> assert ""node_norm"" not in data <TAB> assert ""edge_norm"" not in data <TAB> self. num_steps = num_steps <TAB> self. __batch_size__ = batch_size <TAB> self. sample_coverage = sample_coverage <TAB> self. log = log <TAB> self. N = N = data. num_nodes <TAB> self. E = data. num_edges <TAB> self. adj = SparseTensor ( <TAB> <TAB> row = data. edge_index [ 0 ], <TAB> <TAB> col = data. edge_index [ 1 ], <TAB> <TAB> value = torch. arange ( self. E, device = data. edge_index. device ), <TAB> <TAB> sparse_sizes = ( N, N ), <TAB> ) <TAB> self. data = copy. copy ( data ) <TAB> self. data. edge_index = None <TAB> super ( GraphSAINTSampler, self ). __init__ ( <TAB> <TAB> self, batch_size = 1, collate_fn = self. __collate__, ** kwargs <TAB> ) <TAB> if self. sample_coverage > 0 : <TAB> <TAB> path = osp. join ( save_dir or """", self. __filename__ ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. node_norm, self. edge_norm = torch. load ( path ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. node_norm, self. edge_norm = self. __compute_norm__ ( ) <TAB> <TAB> <TAB> if save_dir is not None : <TAB> <TAB> <TAB> <TAB> torch. save ( ( self. node_norm, self. edge_norm ), path )",False,save_dir is not None and osp.exists(path),path is not None,0.6469844579696655
|
||
|
2529,"def _getListNextPackagesReadyToBuild ( ) : <TAB> for pkg in Scheduler. listOfPackagesToBuild : <TAB> <TAB> if pkg in Scheduler. listOfPackagesCurrentlyBuilding : <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> Scheduler. listOfPackagesNextToBuild. put ( ( - Scheduler. _getPriority ( pkg ), pkg ) ) <TAB> <TAB> <TAB> Scheduler. logger. debug ( ""Adding "" + pkg + "" to the schedule list"" )",False,constants.rpmCheck or Scheduler._checkNextPackageIsReadyToBuild(pkg),pkg in Scheduler.listOfPackagesNextToBuild,0.6507382392883301
|
||
|
2530,"def _create_object ( self, obj_body ) : <TAB> props = obj_body [ SYMBOL_PROPERTIES ] <TAB> for prop_name, prop_value in props. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> func_name = list ( prop_value. keys ( ) ) [ 0 ] <TAB> <TAB> <TAB> if func_name. startswith ( ""_"" ) : <TAB> <TAB> <TAB> <TAB> func = getattr ( self, func_name ) <TAB> <TAB> <TAB> <TAB> props [ prop_name ] = func ( prop_value [ func_name ] ) <TAB> if SYMBOL_TYPE in obj_body and obj_body [ SYMBOL_TYPE ] in self. fake_func_mapping : <TAB> <TAB> return self. fake_func_mapping [ obj_body [ SYMBOL_TYPE ] ] ( ** props ) <TAB> else : <TAB> <TAB> return props",False,"isinstance(prop_value, dict) and prop_value","hasattr(self, func_name)",0.6489107012748718
|
||
|
2531,"def test_compile_success ( ) : <TAB> with compilation ( <TAB> <TAB> valid_paths = [ ""a.py"", ""c/c.py"" ], <TAB> <TAB> invalid_paths = [ ""b.py"", ""d/d.py"" ], <TAB> <TAB> compile_paths = [ ""a.py"", ""c/c.py"" ], <TAB> ) as ( root, compiled_relpaths ) : <TAB> <TAB> assert 2 == len ( compiled_relpaths ) <TAB> <TAB> results = { } <TAB> <TAB> for compiled in compiled_relpaths : <TAB> <TAB> <TAB> compiled_abspath = os. path. join ( root, compiled ) <TAB> <TAB> <TAB> with open ( compiled_abspath, ""rb"" ) as fp : <TAB> <TAB> <TAB> <TAB> fp. read ( 4 ) <TAB> <TAB> <TAB> <TAB> if sys. version_info [ : 2 ] >= ( 3, 7 ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> fp. read ( 4 ) <TAB> <TAB> <TAB> <TAB> fp. read ( 4 ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> fp. read ( 4 ) <TAB> <TAB> <TAB> <TAB> code = marshal. load ( fp ) <TAB> <TAB> <TAB> local_symbols = { } <TAB> <TAB> <TAB> exec ( code, { }, local_symbols ) <TAB> <TAB> <TAB> results [ compiled ] = local_symbols <TAB> <TAB> assert { ""basename"" : ""a.py"" } == results. pop ( ""a.pyc"" ) <TAB> <TAB> assert { ""basename"" : ""c.py"" } == results. pop ( ""c/c.pyc"" ) <TAB> <TAB> assert 0 == len ( results )",False,compatibility.PY3,"sys.version_info[2] >= (3, 6)",0.6651102304458618
|
||
|
2532,"def __setitem__ ( self, key, value ) : <TAB> _type = type ( key ) <TAB> if _type is str : <TAB> <TAB> value = np. array ( value, dtype = bool, ndmin = 1 ) <TAB> <TAB> k_params = self. k_params <TAB> <TAB> self. k_parameters [ key ] = value. size + np. sum ( value ) * ( self. k_regimes - 1 ) <TAB> <TAB> self. k_params += self. k_parameters [ key ] <TAB> <TAB> self. switching [ key ] = value <TAB> <TAB> self. slices_purpose [ key ] = np. s_ [ k_params : self. k_params ] <TAB> <TAB> for j in range ( self. k_regimes ) : <TAB> <TAB> <TAB> self. relative_index_regime_purpose [ j ] [ key ] = [ ] <TAB> <TAB> <TAB> self. index_regime_purpose [ j ] [ key ] = [ ] <TAB> <TAB> offset = 0 <TAB> <TAB> for i in range ( value. size ) : <TAB> <TAB> <TAB> switching = value [ i ] <TAB> <TAB> <TAB> for j in range ( self. k_regimes ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> self. relative_index_regime_purpose [ j ] [ key ]. append ( offset ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> self. relative_index_regime_purpose [ j ] [ key ]. append ( offset + j ) <TAB> <TAB> <TAB> offset += 1 if not switching else self. k_regimes <TAB> <TAB> for j in range ( self. k_regimes ) : <TAB> <TAB> <TAB> offset = 0 <TAB> <TAB> <TAB> indices = [ ] <TAB> <TAB> <TAB> for k,",False,not switching,switching,0.6803080439567566
|
||
|
2533,"def verts_of_loop ( edge_loop ) : <TAB> verts = [ ] <TAB> for e0, e1 in iter_pairs ( edge_loop, False ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> v0 = e0. shared_vert ( e1 ) <TAB> <TAB> <TAB> verts += [ e0. other_vert ( v0 ), v0 ] <TAB> <TAB> verts += [ e1. other_vert ( verts [ - 1 ] ) ] <TAB> if len ( verts ) > 1 and verts [ 0 ] == verts [ - 1 ] : <TAB> <TAB> return verts [ : - 1 ] <TAB> return verts",False,not verts,e0 and e1,0.6796014308929443
|
||
|
2534,"def init ( self, name, dataList ) : <TAB> """"""aList is a list of tuples (commandName,bi)."""""" <TAB> c, d, modeName = self. c, self. d, self. name <TAB> for name, bi in dataList : <TAB> <TAB> if not name : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. entryCommands. append ( bi ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> bi. pane = modeName <TAB> <TAB> <TAB> aList = d. get ( name, [ ] ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> key2, aList2 = c. config. getShortcut ( name ) <TAB> <TAB> <TAB> aList3 = [ z for z in aList2 if z. pane!= modeName ] <TAB> <TAB> <TAB> if aList3 : <TAB> <TAB> <TAB> <TAB> aList. extend ( aList3 ) <TAB> <TAB> <TAB> aList. append ( bi ) <TAB> <TAB> <TAB> d [ name ] = aList",False,bi is not None,name,0.6651281118392944
|
||
|
2535,"def download_cell ( cell_id ) : <TAB> worksheet = app. config [ ""worksheet"" ] <TAB> data = cStringIO. StringIO ( ) <TAB> with zipfile. ZipFile ( data, mode = ""w"", compression = zipfile. ZIP_DEFLATED ) as out_fd : <TAB> <TAB> path = ""%s/"" % cell_id <TAB> <TAB> stored_files = set ( ) <TAB> <TAB> for filename in worksheet. ListFiles ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> stored_files. add ( filename ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if filename. startswith ( path ) : <TAB> <TAB> <TAB> <TAB> with worksheet. Open ( filename ) as in_fd : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> out_fd. writestr ( filename [ len ( path ) : ], in_fd. read ( 100000000 ) ) <TAB> return ( <TAB> <TAB> data. getvalue ( ), <TAB> <TAB> 200, <TAB> <TAB> { <TAB> <TAB> <TAB> ""content-type"" : ""binary/octet-stream"", <TAB> <TAB> <TAB> ""content-disposition"" : 'attachment; filename=""%s.zip""' <TAB> <TAB> <TAB> % ( request. args. get ( ""filename"", ""unknown"" ) ), <TAB> <TAB> }, <TAB> )",False,filename in stored_files,filename.startswith(path),0.6554923057556152
|
||
|
2536,"def run ( ) : <TAB> if len ( completions ) > completions_per_page : <TAB> <TAB> <TAB> <TAB> message = ""Display all {} possibilities? (y on n) "". format ( len ( completions ) ) <TAB> <TAB> confirm = yield create_confirm_application ( message ) <TAB> <TAB> if confirm : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for page in range ( page_count ) : <TAB> <TAB> <TAB> <TAB> display ( page ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> show_more = yield _create_more_application ( ) <TAB> <TAB> <TAB> <TAB> <TAB> if not show_more : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> else : <TAB> <TAB> <TAB> cli. output. write ( ""\n"" ) <TAB> <TAB> <TAB> cli. output. flush ( ) <TAB> else : <TAB> <TAB> <TAB> <TAB> display ( 0 )",False,page != page_count - 1,not confirm,0.667433500289917
|
||
|
2537,"def register_helper ( register, base_url, body ) : <TAB> if not isinstance ( base_url, str ) : <TAB> <TAB> register ( base_url, body ) <TAB> <TAB> return <TAB> base_url = base_url. rstrip ( ""/"" ) <TAB> if isinstance ( body, str ) : <TAB> <TAB> register ( base_url, body ) <TAB> elif isinstance ( body, list ) : <TAB> <TAB> register ( base_url, ""\n"". join ( body ) + ""\n"" ) <TAB> <TAB> register ( base_url + ""/"", ""\n"". join ( body ) + ""\n"" ) <TAB> elif isinstance ( body, dict ) : <TAB> <TAB> vals = [ ] <TAB> <TAB> for k, v in body. items ( ) : <TAB> <TAB> <TAB> if k == ""public-keys"" : <TAB> <TAB> <TAB> <TAB> _register_ssh_keys ( register, base_url + ""/public-keys/"", v ) <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> suffix = k. rstrip ( ""/"" ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> suffix += ""/"" <TAB> <TAB> <TAB> vals. append ( suffix ) <TAB> <TAB> <TAB> url = base_url + ""/"" + suffix <TAB> <TAB> <TAB> register_helper ( register, url, v ) <TAB> <TAB> register ( base_url, ""\n"". join ( vals ) + ""\n"" ) <TAB> <TAB> register ( base_url + ""/"", ""\n"". join ( vals ) + ""\n"" ) <TAB> elif body is None : <TAB> <TAB> register ( base_url, ""not found"", status = 404 )",False,"not isinstance(v, (str, list))",suffix,0.6500570774078369
|
||
|
2538,"def _check_repo_status ( self, repo_dir, expected_status ) : <TAB> """"""Check the worktree status of a repository"""""" <TAB> result = runCmd ( ""git status. --porcelain"", cwd = repo_dir ) <TAB> for line in result. output. splitlines ( ) : <TAB> <TAB> for ind, ( f_status, fn_re ) in enumerate ( expected_status ) : <TAB> <TAB> <TAB> if re. match ( fn_re, line [ 3 : ] ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> self. fail ( ""Unexpected status in line: %s"" % line ) <TAB> <TAB> <TAB> <TAB> expected_status. pop ( ind ) <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> else : <TAB> <TAB> <TAB> self. fail ( ""Unexpected modified file in line: %s"" % line ) <TAB> if expected_status : <TAB> <TAB> self. fail ( ""Missing file changes: %s"" % expected_status )",False,f_status != line[:2],ind not in expected_status,0.6548702716827393
|
||
|
2539,"def CalculateChecksum ( data ) : <TAB> <TAB> if isinstance ( data, bytearray ) : <TAB> <TAB> total = sum ( data ) <TAB> elif isinstance ( data, bytes ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> total = sum ( map ( ord, data ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> total = sum ( data ) <TAB> else : <TAB> <TAB> <TAB> <TAB> total = sum ( map ( ord, data ) ) <TAB> return total & 0xFFFFFFFF",False,"data and isinstance(data[0], bytes)","hasattr(data, 'TAB')",0.6555616855621338
|
||
|
2540,"def load_schemas ( ref = None, included_files = [ ] ) : <TAB> """"""Loads ECS and custom schemas. They are returned deeply nested and merged."""""" <TAB> <TAB> if ref : <TAB> <TAB> schema_files_raw = load_schemas_from_git ( ref ) <TAB> else : <TAB> <TAB> schema_files_raw = load_schema_files ( ecs_helpers. ecs_files ( ) ) <TAB> fields = deep_nesting_representation ( schema_files_raw ) <TAB> <TAB> if included_files and len ( included_files ) > 0 : <TAB> <TAB> print ( ""Loading user defined schemas: {0}"". format ( included_files ) ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> exp_schema_files_raw = load_schemas_from_git ( <TAB> <TAB> <TAB> <TAB> ref, target_dir = EXPERIMENTAL_SCHEMA_DIR <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> exp_fields = deep_nesting_representation ( exp_schema_files_raw ) <TAB> <TAB> <TAB> fields = merge_fields ( fields, exp_fields ) <TAB> <TAB> <TAB> included_files. remove ( EXPERIMENTAL_SCHEMA_DIR ) <TAB> <TAB> <TAB> <TAB> custom_files = ecs_helpers. get_glob_files ( included_files, ecs_helpers. YAML_EXT ) <TAB> <TAB> custom_fields = deep_nesting_representation ( load_schema_files ( custom_files ) ) <TAB> <TAB> fields = merge_fields ( fields, custom_fields ) <TAB> return fields",False,ref and EXPERIMENTAL_SCHEMA_DIR in included_files,experIMENTAL_SCHEMA_DIR,0.6472787857055664
|
||
|
2541,"def _perform_vex_expr_Load ( self, addr_bundle, ty, end, condition = None, ** kwargs ) : <TAB> addr, addr_deps = addr_bundle <TAB> if<mask> : : <TAB> <TAB> condition, condition_deps = condition <TAB> else : <TAB> <TAB> condition_deps = None <TAB> result = super ( ). _perform_vex_expr_Load ( <TAB> <TAB> addr, ty, end, condition = condition, ** kwargs <TAB> ) <TAB> if o. TRACK_MEMORY_ACTIONS in self. state. options : <TAB> <TAB> addr_ao = SimActionObject ( addr, deps = addr_deps, state = self. state ) <TAB> <TAB> condition_ao = ( <TAB> <TAB> <TAB> SimActionObject ( condition, deps = condition_deps, state = self. state ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> else None <TAB> <TAB> ) <TAB> <TAB> r = SimActionData ( <TAB> <TAB> <TAB> self. state, <TAB> <TAB> <TAB> self. state. memory. id, <TAB> <TAB> <TAB> SimActionData. READ, <TAB> <TAB> <TAB> addr = addr_ao, <TAB> <TAB> <TAB> size = pyvex. get_type_size ( ty ), <TAB> <TAB> <TAB> data = result, <TAB> <TAB> <TAB> condition = condition_ao, <TAB> <TAB> ) <TAB> <TAB> self. state. history. add_action ( r ) <TAB> <TAB> a = frozenset ( ( r, ) ) <TAB> else : <TAB> <TAB> a = frozenset ( ) <TAB> return result, a",False,condition is not None,o.TRACK_MEMORY_ACTIONS in self.state.options,0.66037917137146
|
||
|
2542,"def OnGraphOptionChanged ( self, event ) : <TAB> event. Skip ( ) <TAB> layout = getattr ( event, ""refreshColumns"", False ) or getattr ( <TAB> <TAB> event, ""refreshColumns"", False <TAB> ) <TAB> if layout : <TAB> <TAB> self. ctrlPanel. Freeze ( ) <TAB> <TAB> if getattr ( event, ""refreshAxeLabels"", False ) : <TAB> <TAB> <TAB> self. ctrlPanel. refreshAxeLabels ( restoreSelection = True ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. ctrlPanel. refreshColumns ( ) <TAB> <TAB> self. Layout ( ) <TAB> <TAB> self. ctrlPanel. Thaw ( ) <TAB> self. clearCache ( reason = GraphCacheCleanupReason. optionChanged ) <TAB> self. draw ( )",False,"getattr(event, 'refreshColumns', False)",layout,0.6571841239929199
|
||
|
2543,"def _get_run_link ( self, tracking_uri, run_id ) : <TAB> <TAB> <TAB> if is_databricks_default_tracking_uri ( tracking_uri ) and ( <TAB> <TAB> is_in_databricks_notebook ( ) or is_in_databricks_job ( ) <TAB> ) : <TAB> <TAB> <TAB> <TAB> workspace_host, workspace_id = get_workspace_info_from_dbutils ( ) <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> workspace_host, workspace_id = get_workspace_info_from_databricks_secrets ( <TAB> <TAB> <TAB> tracking_uri <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> ""No workspace ID specified; if your Databricks workspaces share the same"" <TAB> <TAB> <TAB> <TAB> "" host URL, you may want to specify the workspace ID (along with the host"" <TAB> <TAB> <TAB> <TAB> "" information in the secret manager) for run lineage tracking. For more"" <TAB> <TAB> <TAB> <TAB> "" details on how to specify this information in the secret manager,"" <TAB> <TAB> <TAB> <TAB> "" please refer to the model registry documentation."" <TAB> <TAB> <TAB> ) <TAB> <TAB> experiment_id = self. get_run ( run_id ). info. experiment_id <TAB> if workspace_host and run_id and experiment_id : <TAB> <TAB> return construct_run_url ( workspace_host, experiment_id, run_id, workspace_id )",True,not workspace_id,not workspace_id,0.6586687564849854
|
||
|
2544,"def __impl__ ( func ) : <TAB> if op_type is None : <TAB> <TAB> op_type_name = func. __name__ <TAB> else : <TAB> <TAB> op_type_name = op_type <TAB> op_proto = OpProtoHolder. instance ( ). get_op_proto ( op_type_name ) <TAB> tmpl = string. Template ( func. __doc__ ) <TAB> comment_lines = op_proto. comment. split ( ""\n"" ) <TAB> comment = """" <TAB> for line in comment_lines : <TAB> <TAB> line = line. strip ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> comment += escape_math ( line ) <TAB> <TAB> <TAB> comment += "" "" <TAB> <TAB> elif len ( comment )!= 0 : <TAB> <TAB> <TAB> comment += ""\n \n "" <TAB> args = { ""comment"" : trim_ending_dot ( comment ) } <TAB> for each_input in op_proto. inputs : <TAB> <TAB> input_name = _convert_ ( each_input. name ) <TAB> <TAB> args [ ""{0}_comment"". format ( input_name ) ] = trim_ending_dot ( each_input. comment ) <TAB> <TAB> args [ ""{0}_type"". format ( input_name ) ] = ""Variable"" <TAB> for each_attr in op_proto. attrs : <TAB> <TAB> input_name = _convert_ ( each_attr. name ) <TAB> <TAB> args [ ""{0}_comment"". format ( input_name ) ] = trim_ending_dot ( each_attr. comment ) <TAB> <TAB> args [ ""{0}_type"". format ( input_name ) ] = _type_to_str_ ( each_attr. type ) <TAB> for each_opt in op_proto. outputs : <TAB> <TAB> output_name = _convert_ ( each_opt. name ) <TAB> <TAB> args [ ""{0}_comment"". format ( output_name ) ] = trim_ending_dot ( each_opt. comment ) <TAB> <TAB> args [ ""{0",False,len(line) != 0,len(line) > 0,0.6571491360664368
|
||
|
2545,"def _inner ( src ) : <TAB> for match in C_INCLUDE_RE. finditer ( src ) : <TAB> <TAB> included = match. group ( 1 ) <TAB> <TAB> found = False <TAB> <TAB> for ipath in include_path : <TAB> <TAB> <TAB> included_file_name = realpath ( join ( ipath, included ) ) <TAB> <TAB> <TAB> if included_file_name not in result : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> src_file = open ( included_file_name, ""rt"" ) <TAB> <TAB> <TAB> <TAB> except IOError : <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> included_src = src_file. read ( ) <TAB> <TAB> <TAB> <TAB> finally : <TAB> <TAB> <TAB> <TAB> <TAB> src_file. close ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> result [ included_file_name ] = None <TAB> <TAB> <TAB> <TAB> checksum = new_hash ( ) <TAB> <TAB> <TAB> <TAB> update_checksum ( checksum, included_src ) <TAB> <TAB> <TAB> <TAB> _inner ( included_src ) <TAB> <TAB> <TAB> <TAB> result [ included_file_name ] = ( <TAB> <TAB> <TAB> <TAB> <TAB> os. stat ( included_file_name ). st_mtime, <TAB> <TAB> <TAB> <TAB> <TAB> checksum. hexdigest ( ), <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> found = True <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> pass",True,not found,not found,0.6693658828735352
|
||
|
2546,"def monitor_filter ( self ) : <TAB> """"""Return filtered service objects list"""""" <TAB> services = self. client. services. list ( filters = { ""label"" : ""com.ouroboros.enable"" } ) <TAB> monitored_services = [ ] <TAB> for service in services : <TAB> <TAB> ouro_label = service. attrs [ ""Spec"" ] [ ""Labels"" ]. get ( ""com.ouroboros.enable"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> monitored_services. append ( service ) <TAB> self. data_manager. monitored_containers [ self. socket ] = len ( monitored_services ) <TAB> self. data_manager. set ( self. socket ) <TAB> return monitored_services",False,"not self.config.label_enable or ouro_label.lower() in ['true', 'yes']",ouro_label != self.socket,0.6489477157592773
|
||
|
2547,"def handle_label ( self, path, ** options ) : <TAB> verbosity = int ( options. get ( ""verbosity"", 1 ) ) <TAB> result = finders. find ( path, all = options [ ""all"" ] ) <TAB> path = smart_unicode ( path ) <TAB> if result : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> result = [ result ] <TAB> <TAB> output = u""\n "". join ( <TAB> <TAB> <TAB> ( smart_unicode ( os. path. realpath ( path ) ) for path in result ) <TAB> <TAB> ) <TAB> <TAB> self. stdout. write ( smart_str ( u""Found '%s' here:\n %s\n"" % ( path, output ) ) ) <TAB> else : <TAB> <TAB> if verbosity >= 1 : <TAB> <TAB> <TAB> self. stderr. write ( smart_str ( ""No matching file found for '%s'.\n"" % path ) )",False,"not isinstance(result, (list, tuple))",verbosity > 2,0.6486179232597351
|
||
|
2548,"def __listingColumns ( self ) : <TAB> columns = [ ] <TAB> for name in self. __getColumns ( ) : <TAB> <TAB> definition = column ( name ) <TAB> <TAB> if not definition : <TAB> <TAB> <TAB> IECore. msg ( <TAB> <TAB> <TAB> <TAB> IECore. Msg. Level. Error, <TAB> <TAB> <TAB> <TAB> ""GafferImageUI.CatalogueUI"", <TAB> <TAB> <TAB> <TAB> ""No column registered with name '%s'"" % name, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> c = GafferUI. PathListingWidget. IconColumn ( definition. title ( ), """", name ) <TAB> <TAB> else : <TAB> <TAB> <TAB> c = GafferUI. PathListingWidget. StandardColumn ( definition. title ( ), name ) <TAB> <TAB> columns. append ( c ) <TAB> return columns",False,"isinstance(definition, IconColumn)",self.__isGafferImageUI,0.6526787281036377
|
||
|
2549,"def get_reference_as_per_payment_terms ( <TAB> payment_schedule, dt, dn, doc, grand_total, outstanding_amount ) : <TAB> references = [ ] <TAB> for payment_term in payment_schedule : <TAB> <TAB> payment_term_outstanding = flt ( <TAB> <TAB> <TAB> payment_term. payment_amount - payment_term. paid_amount, <TAB> <TAB> <TAB> payment_term. precision ( ""payment_amount"" ), <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> references. append ( <TAB> <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> <TAB> ""reference_doctype"" : dt, <TAB> <TAB> <TAB> <TAB> <TAB> ""reference_name"" : dn, <TAB> <TAB> <TAB> <TAB> <TAB> ""bill_no"" : doc. get ( ""bill_no"" ), <TAB> <TAB> <TAB> <TAB> <TAB> ""due_date"" : doc. get ( ""due_date"" ), <TAB> <TAB> <TAB> <TAB> <TAB> ""total_amount"" : grand_total, <TAB> <TAB> <TAB> <TAB> <TAB> ""outstanding_amount"" : outstanding_amount, <TAB> <TAB> <TAB> <TAB> <TAB> ""payment_term"" : payment_term. payment_term, <TAB> <TAB> <TAB> <TAB> <TAB> ""allocated_amount"" : payment_term_outstanding, <TAB> <TAB> <TAB> <TAB> } <TAB> <TAB> <TAB> ) <TAB> return references",False,payment_term_outstanding,refused,0.6702572107315063
|
||
|
2550,"def process_query ( self, query ) : <TAB> raw_filters = { } <TAB> <TAB> for key in request. args : <TAB> <TAB> orig_key = key <TAB> <TAB> if key. startswith ( ""-"" ) : <TAB> <TAB> <TAB> negated = True <TAB> <TAB> <TAB> key = key [ 1 : ] <TAB> <TAB> else : <TAB> <TAB> <TAB> negated = False <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> expr, op = key. rsplit ( ""__"", 1 ) <TAB> <TAB> <TAB> if op not in DJANGO_MAP : <TAB> <TAB> <TAB> <TAB> expr = key <TAB> <TAB> <TAB> <TAB> op = ""eq"" <TAB> <TAB> else : <TAB> <TAB> <TAB> expr = key <TAB> <TAB> <TAB> op = ""eq"" <TAB> <TAB> raw_filters. setdefault ( expr, [ ] ) <TAB> <TAB> raw_filters [ expr ]. append ( ( op, request. args. getlist ( orig_key ), negated ) ) <TAB> <TAB> <TAB> <TAB> queue = [ ( self. _field_tree, """" ) ] <TAB> while queue : <TAB> <TAB> node, prefix = queue. pop ( 0 ) <TAB> <TAB> for field in node. fields : <TAB> <TAB> <TAB> filter_expr = ""%s%s"" % ( prefix, field. name ) <TAB> <TAB> <TAB> if filter_expr in raw_filters : <TAB> <TAB> <TAB> <TAB> for op, arg_list, negated in raw_filters [ filter_expr ] : <TAB> <TAB> <TAB> <TAB> <TAB> clean_args = self. clean_arg_list ( arg_list ) <TAB> <TAB> <TAB> <TAB> <TAB> query = self. apply_filter ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> query, filter_expr, op, clean_args, negated <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <",False,'__' in key,negated,0.6873005628585815
|
||
|
2551,"def _set_multiple_targets ( ) : <TAB> <TAB> if conf. url : <TAB> <TAB> targets = set ( ) <TAB> <TAB> for url in conf. url : <TAB> <TAB> <TAB> parsed = parse_target ( url ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> targets. add ( parsed ) <TAB> <TAB> if not targets : <TAB> <TAB> <TAB> err_msg = ""incorrect target url or ip format!"" <TAB> <TAB> <TAB> logger. error ( err_msg ) <TAB> <TAB> for target in targets : <TAB> <TAB> <TAB> kb. targets. add ( target ) <TAB> if conf. url_file : <TAB> <TAB> for line in get_file_items ( conf. url_file, lowercase = False, unique = True ) : <TAB> <TAB> <TAB> kb. targets. add ( line ) <TAB> if conf. dork : <TAB> <TAB> <TAB> <TAB> if ( <TAB> <TAB> <TAB> ""target_from_shodan"" not in conf. plugins <TAB> <TAB> <TAB> and ""target_from_fofa"" not in conf. plugins <TAB> <TAB> ) : <TAB> <TAB> <TAB> conf. plugins. append ( ""target_from_zoomeye"" ) <TAB> if conf. dork_zoomeye : <TAB> <TAB> conf. plugins. append ( ""target_from_zoomeye"" ) <TAB> if conf. dork_shodan : <TAB> <TAB> conf. plugins. append ( ""target_from_shodan"" ) <TAB> if conf. dork_censys : <TAB> <TAB> conf. plugins. append ( ""target_from_censys"" ) <TAB> if conf. dork_fofa : <TAB> <TAB> conf. plugins. append ( ""target_from_fofa"" )",True,parsed,parsed,0.6915911436080933
|
||
|
2552,"def setup ( self, gen ) : <TAB> Node. setup ( self, gen ) <TAB> for c in self. children : <TAB> <TAB> c. setup ( gen ) <TAB> if not self. accepts_epsilon : <TAB> <TAB> <TAB> <TAB> for c in self. children : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> else : <TAB> <TAB> <TAB> self. accepts_epsilon = 1 <TAB> <TAB> <TAB> gen. changed ( )",False,not c.accepts_epsilon,c.accepts_epsilon,0.6554921865463257
|
||
|
2553,"def process_cache_response ( self, view_instance, view_method, request, args, kwargs ) : <TAB> key = self. calculate_key ( <TAB> <TAB> view_instance = view_instance, <TAB> <TAB> view_method = view_method, <TAB> <TAB> request = request, <TAB> <TAB> args = args, <TAB> <TAB> kwargs = kwargs, <TAB> ) <TAB> timeout = self. calculate_timeout ( view_instance = view_instance ) <TAB> response_triple = self. cache. get ( key ) <TAB> if not response_triple : <TAB> <TAB> <TAB> <TAB> response = view_method ( view_instance, request, * args, ** kwargs ) <TAB> <TAB> response = view_instance. finalize_response ( request, response, * args, ** kwargs ) <TAB> <TAB> response. render ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> response_triple = ( <TAB> <TAB> <TAB> <TAB> response. rendered_content, <TAB> <TAB> <TAB> <TAB> response. status_code, <TAB> <TAB> <TAB> <TAB> response. _headers. copy ( ), <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> self. cache. set ( key, response_triple, timeout ) <TAB> else : <TAB> <TAB> <TAB> <TAB> content, status, headers = response_triple <TAB> <TAB> response = HttpResponse ( content = content, status = status ) <TAB> <TAB> for k, v in headers. values ( ) : <TAB> <TAB> <TAB> response [ k ] = v <TAB> if not hasattr ( response, ""_closable_objects"" ) : <TAB> <TAB> response. _closable_objects = [ ] <TAB> return response",False,not response.status_code >= 400 or self.cache_errors,response_triple,0.6516073942184448
|
||
|
2554,"def async_recv ( self ) : <TAB> poll = select. poll ( ) <TAB> poll. register ( self. _sock, select. POLLIN | select. POLLPRI ) <TAB> poll. register ( self. _ctrl_read, select. POLLIN | select. POLLPRI ) <TAB> sockfd = self. _sock. fileno ( ) <TAB> while True : <TAB> <TAB> events = poll. poll ( ) <TAB> <TAB> for ( fd, event ) in events : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> data = bytearray ( 64000 ) <TAB> <TAB> <TAB> <TAB> <TAB> self. _sock. recv_into ( data, 64000 ) <TAB> <TAB> <TAB> <TAB> <TAB> self. buffer_queue. put_nowait ( data ) <TAB> <TAB> <TAB> <TAB> except Exception as e : <TAB> <TAB> <TAB> <TAB> <TAB> self. buffer_queue. put ( e ) <TAB> <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> return",True,fd == sockfd,fd == sockfd,0.6701676845550537
|
||
|
2555,"def getDOMImplementation ( features = None ) : <TAB> if features : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> features = domreg. _parse_feature_string ( features ) <TAB> <TAB> for f, v in features : <TAB> <TAB> <TAB> if not Document. implementation. hasFeature ( f, v ) : <TAB> <TAB> <TAB> <TAB> return None <TAB> return Document. implementation",False,"isinstance(features, str)",Document.implementation == None,0.6567810773849487
|
||
|
2556,"def _represent_changes ( self, changes, field ) : <TAB> if ""default"" in changes and changes [ ""default"" ] [ 1 ] is not None : <TAB> <TAB> ftype = changes [ ""default"" ] [ 2 ] or field. type <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> ftype = changes [ ""type"" ] [ 1 ] <TAB> <TAB> changes [ ""default"" ] [ 1 ] = self. adapter. represent ( changes [ ""default"" ] [ 1 ], ftype ) <TAB> if<mask> : <TAB> <TAB> changes. pop ( ""length"", None ) <TAB> <TAB> coltype = changes [ ""type"" ] [ 1 ] <TAB> <TAB> if coltype. startswith ( ""reference"" ) : <TAB> <TAB> <TAB> raise NotImplementedError ( <TAB> <TAB> <TAB> <TAB> ""Type change on reference fields is not supported."" <TAB> <TAB> <TAB> ) <TAB> <TAB> elif coltype. startswith ( ""decimal"" ) : <TAB> <TAB> <TAB> precision, scale = map ( int, coltype [ 8 : - 1 ]. split ( "","" ) ) <TAB> <TAB> <TAB> csql = self. adapter. types [ coltype [ : 7 ] ] % dict ( <TAB> <TAB> <TAB> <TAB> precision = precision, scale = scale <TAB> <TAB> <TAB> ) <TAB> <TAB> elif coltype. startswith ( ""geo"" ) : <TAB> <TAB> <TAB> csql = self. _gen_geo ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> csql = self. adapter. types [ coltype ] % { <TAB> <TAB> <TAB> <TAB> ""length"" : changes [ ""type"" ] [ 2 ] or field. length <TAB> <TAB> <TAB> } <TAB> <TAB> changes [ ""type"" ] [ 1 ] = csql <TAB> elif ""length"" in changes : <TAB> <TAB> change = changes. pop ( ""length"" ) <TAB> <TAB> ftype = change [ 2 ] or field. type <TAB> <TAB> changes [ ""type"" ] = [ None, self",True,'type' in changes,'type' in changes,0.6660585403442383
|
||
|
2557,"def get_symbol_type ( self, sym_name, nm_type = """", module = ""kernel"" ) : <TAB> symtable = self. sys_map <TAB> ret = None <TAB> <TAB> if module in symtable : <TAB> <TAB> mod = symtable [ module ] <TAB> <TAB> <TAB> <TAB> if sym_name in mod : <TAB> <TAB> <TAB> sym_list = mod [ sym_name ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if len ( sym_list ) > 1 : <TAB> <TAB> <TAB> <TAB> if nm_type == """" : <TAB> <TAB> <TAB> <TAB> <TAB> debug. debug ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""Requested symbol {0:s} in module {1:s} has multiple definitions and no type given\n"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> sym_name, module <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> return None <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> for ( addr, stype ) in sym_list : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ret = addr <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> <TAB> if ret == None : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> debug. error ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""Requested symbol {0:s} in module {1:s} could not be found\n"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> <",False,stype == nm_type,nm_type == '',0.6772770285606384
|
||
|
2558,"def _get_startup_packages ( lib_path : Path, packages ) -> Set [ str ] : <TAB> names = set ( ) <TAB> for path in lib_path. iterdir ( ) : <TAB> <TAB> name = path. name <TAB> <TAB> if name == ""__pycache__"" : <TAB> <TAB> <TAB> continue <TAB> <TAB> if name. endswith ( "".py"" ) : <TAB> <TAB> <TAB> names. add ( name. split ( ""."" ) [ 0 ] ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> names. add ( name ) <TAB> if packages : <TAB> <TAB> packages = { package. lower ( ). replace ( ""-"", ""_"" ) for package in packages } <TAB> <TAB> if len ( names & packages ) == len ( packages ) : <TAB> <TAB> <TAB> return packages <TAB> return names",False,path.is_dir() and '.' not in name,name,0.6567971706390381
|
||
|
2559,def swap_actions ( actions ) : <TAB> for mutexgroup in mutex_groups : <TAB> <TAB> mutex_actions = mutexgroup. _group_actions <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> targetindex = actions. index ( mutexgroup. _group_actions [ 0 ] ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> actions [ targetindex ] = mutexgroup <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> actions = [ action for action in actions if action not in mutex_actions ] <TAB> return actions,False,"contains_actions(mutex_actions, actions)",mutexgroup._group_actions and actions.size() > 0,0.6560034155845642
|
||
|
2560,"def flush ( self ) : <TAB> try : <TAB> <TAB> with salt. utils. files. fopen ( self. name, ""wb"" ) as outfile : <TAB> <TAB> <TAB> ini_gen = self. gen_ini ( ) <TAB> <TAB> <TAB> next ( ini_gen ) <TAB> <TAB> <TAB> ini_gen_list = list ( ini_gen ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> ini_gen_list [ 0 ] = ini_gen_list [ 0 ]. lstrip ( os. linesep ) <TAB> <TAB> <TAB> outfile. writelines ( salt. utils. data. encode ( ini_gen_list ) ) <TAB> except ( OSError, IOError ) as exc : <TAB> <TAB> raise CommandExecutionError ( <TAB> <TAB> <TAB> ""Unable to write file '{0}'. "" ""Exception: {1}"". format ( self. name, exc ) <TAB> <TAB> )",False,ini_gen_list,len(ini_gen_list) > 0,0.6612122654914856
|
||
|
2561,"def _describe_tracks ( <TAB> self, <TAB> video_path, <TAB> general_track, <TAB> video_tracks, <TAB> audio_tracks, <TAB> subtitle_tracks, <TAB> context, ) : <TAB> logger. debug ( ""Handling general track"" ) <TAB> props = self. _describe_track ( general_track, ""general"", context ) <TAB> if ""path"" not in props : <TAB> <TAB> props [ ""path"" ] = video_path <TAB> if ""container"" not in props : <TAB> <TAB> props [ ""container"" ] = os. path. splitext ( video_path ) [ 1 ] [ 1 : ] <TAB> if ""size"" not in props and os. path. isfile ( video_path ) : <TAB> <TAB> props [ ""size"" ] = size_property. handle ( os. path. getsize ( video_path ), context ) <TAB> for track_type, tracks, in ( <TAB> <TAB> ( ""video"", video_tracks ), <TAB> <TAB> ( ""audio"", audio_tracks ), <TAB> <TAB> ( ""subtitle"", subtitle_tracks ), <TAB> ) : <TAB> <TAB> results = [ ] <TAB> <TAB> for track in tracks or [ ] : <TAB> <TAB> <TAB> logger. debug ( ""Handling %s track"", track_type ) <TAB> <TAB> <TAB> t = self. _validate_track ( <TAB> <TAB> <TAB> <TAB> track_type, self. _describe_track ( track, track_type, context ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if t : <TAB> <TAB> <TAB> <TAB> results. append ( t ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> props [ track_type ] = results <TAB> return props",True,results,results,0.6834471225738525
|
||
|
2562,"def _add_content ( linesep, lines = None, include_marker_start = True, end_line = None ) : <TAB> if lines is None : <TAB> <TAB> lines = [ ] <TAB> <TAB> include_marker_start = True <TAB> if end_line is None : <TAB> <TAB> end_line = marker_end <TAB> end_line = end_line. rstrip ( ""\r\n"" ) + linesep <TAB> if include_marker_start : <TAB> <TAB> lines. append ( marker_start + linesep ) <TAB> if split_content : <TAB> <TAB> for index, content_line in enumerate ( split_content, 1 ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> lines. append ( content_line + linesep ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if append_newline : <TAB> <TAB> <TAB> <TAB> <TAB> lines. append ( content_line + linesep ) <TAB> <TAB> <TAB> <TAB> <TAB> lines. append ( end_line ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> lines. append ( content_line + end_line ) <TAB> else : <TAB> <TAB> lines. append ( end_line ) <TAB> return lines",False,index != line_count,index == len(split_content) - 1,0.6572616100311279
|
||
|
2563,"def getDocumentHandler ( self, publicId = None, systemId = None, namespace = None ) : <TAB> try : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if publicId or systemId : <TAB> <TAB> <TAB> <TAB> log. debug ( <TAB> <TAB> <TAB> <TAB> <TAB> ""getDocumentHandler: using all three, %s %s %s"", <TAB> <TAB> <TAB> <TAB> <TAB> publicId, <TAB> <TAB> <TAB> <TAB> <TAB> systemId, <TAB> <TAB> <TAB> <TAB> <TAB> namespace, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> return self. handlers [ ( publicId, systemId, namespace ) ] <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> log. debug ( ""getDocumentHandler: namespace only, %s"", namespace ) <TAB> <TAB> <TAB> <TAB> return self. handlers [ namespace ] <TAB> <TAB> else : <TAB> <TAB> <TAB> log. debug ( ""getDocumentHandler: ids only, %s, %s"", publicId, systemId ) <TAB> <TAB> <TAB> return self. handlers [ ( publicId, systemId ) ] <TAB> except KeyError : <TAB> <TAB> log. debug ( <TAB> <TAB> <TAB> ""getDocumentHandler: Failed, retrying with %s, %s, %s..."", <TAB> <TAB> <TAB> publicId, <TAB> <TAB> <TAB> systemId, <TAB> <TAB> <TAB> namespace, <TAB> <TAB> ) <TAB> <TAB> dataset = self. resolver. getDataset ( publicId, systemId, namespace ) <TAB> <TAB> if not dataset : <TAB> <TAB> <TAB> handler = EmptyDatasetHandler ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> handler = DataSetHandler ( namespace, dataset ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. handlers [ namespace ] = handler <TAB> <TAB> <TAB>",False,namespace,namespace not in self.handlers,0.7176885604858398
|
||
|
2564,"def _handle_Conversion ( self, expr ) : <TAB> simop = vex_operations [ expr. op ] <TAB> arg_0 = self. _expr ( expr. args [ 0 ] ) <TAB> bits = int ( simop. op_attrs [ ""to_size"" ] ) <TAB> data = set ( ) <TAB> <TAB> for a in arg_0 : <TAB> <TAB> if type ( a ) is Undefined : <TAB> <TAB> <TAB> pass <TAB> <TAB> elif isinstance ( a, int ) : <TAB> <TAB> <TAB> mask = 2 ** bits - 1 <TAB> <TAB> <TAB> a &= mask <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> if type ( a. value ) is Register : <TAB> <TAB> <TAB> <TAB> a. value. size = bits // 8 <TAB> <TAB> <TAB> elif type ( a. value ) is SpOffset : <TAB> <TAB> <TAB> <TAB> a. value. bits = bits <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> l. warning ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Unsupported type Parameter->%s for conversion."", <TAB> <TAB> <TAB> <TAB> <TAB> type ( a. value ). __name__, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> l. warning ( ""Unsupported type %s for conversion."", type ( a ). __name__ ) <TAB> <TAB> data. add ( a ) <TAB> return DataSet ( data, expr. result_size ( self. tyenv ) )",False,type(a) is Parameter,"isinstance(a, Data)",0.6593149900436401
|
||
|
2565,"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 ftype == TType. LIST : <TAB> <TAB> <TAB> <TAB> self. success = [ ] <TAB> <TAB> <TAB> <TAB> ( _etype734, _size731 ) = iprot. readListBegin ( ) <TAB> <TAB> <TAB> <TAB> for _i735 in xrange ( _size731 ) : <TAB> <TAB> <TAB> <TAB> <TAB> _elem736 = PartitionSpec ( ) <TAB> <TAB> <TAB> <TAB> <TAB> _elem736. read ( iprot ) <TAB> <TAB> <TAB> <TAB> <TAB> self. success. append ( _elem736 ) <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 = NoSuchObjectException ( ) <TAB> <TAB> <TAB> <TAB> self. o1. read ( iprot ) <TAB> <TAB> <TAB> else : <TAB> <",True,fid == 2,fid == 2,0.6792460083961487
|
||
|
2566,"def test_array_interface ( self, data ) : <TAB> result = np. array ( data ) <TAB> np. testing. assert_array_equal ( result [ 0 ], data [ 0 ] ) <TAB> result = np. array ( data, dtype = object ) <TAB> expected = np. array ( list ( data ), dtype = object ) <TAB> for a1, a2 in zip ( result, expected ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> assert np. isnan ( a1 ) and np. isnan ( a2 ) <TAB> <TAB> else : <TAB> <TAB> <TAB> tm. assert_numpy_array_equal ( a2, a1 )",False,np.isscalar(a1),a1 == a2,0.6502156257629395
|
||
|
2567,"def _load_db ( self ) : <TAB> try : <TAB> <TAB> with open ( self. db ) as db : <TAB> <TAB> <TAB> content = db. read ( 8 ) <TAB> <TAB> <TAB> db. seek ( 0 ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> data = StringIO ( ) <TAB> <TAB> <TAB> <TAB> if self. encryptor : <TAB> <TAB> <TAB> <TAB> <TAB> self. encryptor. decrypt ( db, data ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> raise EncryptionError ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""Encrpyted credential storage: {}"". format ( self. db ) <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> return json. loads ( data. getvalue ( ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> return json. load ( db ) <TAB> except : <TAB> <TAB> return { ""creds"" : [ ] }",False,content == 'Salted__',len(content) > 0,0.6817852258682251
|
||
|
2568,"def _libc_clock_info ( use_info ) : <TAB> if<mask> : <TAB> <TAB> info = { <TAB> <TAB> <TAB> ""implementation"" : ""clock()"", <TAB> <TAB> <TAB> ""resolution"" : 1.0, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""monotonic"" : True, <TAB> <TAB> <TAB> ""adjustable"" : False, <TAB> <TAB> } <TAB> <TAB> if os. name!= ""nt"" : <TAB> <TAB> <TAB> info [ ""monotonic"" ] = True <TAB> else : <TAB> <TAB> info = None <TAB> if has_libc_clock : <TAB> <TAB> value = _libc_clock ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> info [ ""implementation"" ] = ""clock()"" <TAB> else : <TAB> <TAB> value = python_time. clock ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> info [ ""implementation"" ] = ""time.clock()"" <TAB> return ( value, info )",True,use_info,use_info,0.6628698110580444
|
||
|
2569,"def _api_call ( self, params = None, results_per_page = 300, offset = 0 ) : <TAB> response = { } <TAB> json_rpc = { <TAB> <TAB> ""jsonrpc"" : ""2.0"", <TAB> <TAB> ""method"" : ""getTorrents"", <TAB> <TAB> ""params"" : [ self. api_key, params or { }, results_per_page, offset ], <TAB> <TAB> ""id"" : uuid. uuid4 ( ). hex, <TAB> } <TAB> try : <TAB> <TAB> response = self. session. post ( <TAB> <TAB> <TAB> self. urls [ ""api"" ], <TAB> <TAB> <TAB> json = json_rpc, <TAB> <TAB> <TAB> headers = { ""Content-Type"" : ""application/json-rpc"" }, <TAB> <TAB> ). json ( ) <TAB> <TAB> if ""error"" in response : <TAB> <TAB> <TAB> error = response [ ""error"" ] <TAB> <TAB> <TAB> message = error [ ""message"" ] <TAB> <TAB> <TAB> code = error [ ""code"" ] <TAB> <TAB> <TAB> if code == - 32001 : <TAB> <TAB> <TAB> <TAB> sickrage. app. log. warning ( ""Incorrect authentication credentials."" ) <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> sickrage. app. log. warning ( <TAB> <TAB> <TAB> <TAB> <TAB> ""You have exceeded the limit of 150 calls per hour."" <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> elif code in ( 500, 502, 521, 524 ) : <TAB> <TAB> <TAB> <TAB> sickrage. app. log. warning ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Provider is currently unavailable. Error: {} {}"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> code, message <TAB> <TAB> <TAB> <TAB> <TAB",False,code == -32002,code == -64,0.6698071956634521
|
||
|
2570,"def filter_mtime ( oldest_time, newest_time, root, dirs, files, pth ) : <TAB> fnames = [ ] <TAB> for f in files : <TAB> <TAB> st_mtime = os. stat ( os. path. join ( root, f ) ). st_mtime <TAB> <TAB> if newest_time > st_mtime > oldest_time : <TAB> <TAB> <TAB> fnames. append ( f ) <TAB> dnames = [ ] <TAB> for d in dirs : <TAB> <TAB> st_mtime = os. stat ( os. path. join ( root, d ) ). st_mtime <TAB> <TAB> if newest_time > st_mtime > oldest_time : <TAB> <TAB> <TAB> dnames. append ( d ) <TAB> if not fnames and not dnames : <TAB> <TAB> st_mtime = os. stat ( root ). st_mtime <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return None, None, None <TAB> return root, dnames, fnames",False,not newest_time > st_mtime > oldest_time,st_mtime != pth.st_mtime,0.6480205059051514
|
||
|
2571,"def parse_target ( address ) : <TAB> target = None <TAB> if ( <TAB> <TAB> is_domain_format ( address ) <TAB> <TAB> or is_url_format ( address ) <TAB> <TAB> or is_ip_address_with_port_format ( address ) <TAB> ) : <TAB> <TAB> target = address <TAB> elif is_ipv6_url_format ( address ) : <TAB> <TAB> conf. ipv6 = True <TAB> <TAB> target = address <TAB> elif is_ip_address_format ( address ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> ip = ip_address ( address ) <TAB> <TAB> <TAB> target = ip. exploded <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> pass <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> conf. ipv6 = True <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> ip = ip_address ( address ) <TAB> <TAB> <TAB> <TAB> target = ip. exploded <TAB> <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> network = ip_network ( address, strict = False ) <TAB> <TAB> <TAB> <TAB> <TAB> for host in network. hosts ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> target = host. exploded <TAB> <TAB> <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> <TAB> <TAB> pass <TAB> return target",False,is_ipv6_address_format(address),is_ipv6_url_format(address),0.6476520299911499
|
||
|
2572,"def from_funcitem ( stub : nodes. FuncItem ) -> ""Signature[nodes.Argument]"" : <TAB> stub_sig = Signature ( ) <TAB> for stub_arg in stub. arguments : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> stub_sig. pos. append ( stub_arg ) <TAB> <TAB> elif stub_arg. kind in ( nodes. ARG_NAMED, nodes. ARG_NAMED_OPT ) : <TAB> <TAB> <TAB> stub_sig. kwonly [ stub_arg. variable. name ] = stub_arg <TAB> <TAB> elif stub_arg. kind == nodes. ARG_STAR : <TAB> <TAB> <TAB> stub_sig. varpos = stub_arg <TAB> <TAB> elif stub_arg. kind == nodes. ARG_STAR2 : <TAB> <TAB> <TAB> stub_sig. varkw = stub_arg <TAB> <TAB> else : <TAB> <TAB> <TAB> raise AssertionError <TAB> return stub_sig",False,"stub_arg.kind in (nodes.ARG_POS, nodes.ARG_OPT)",stub_arg.kind == nodes.ARG_START,0.6566026210784912
|
||
|
2573,"def edit ( request, provider_id = None, credentials_id = None ) : <TAB> provider_data = cloud_credentials_model. get_by_id ( credentials_id ) <TAB> all_for_provider = cloud_credentials_model. get_all_for_provider ( <TAB> <TAB> provider_id = provider_id <TAB> ) <TAB> provider_form = PROVIDERS_FORMS. get ( provider_id, False ) <TAB> if not provider_form : <TAB> <TAB> return redirect ( reverse ( ""cloudservers"" ) ) <TAB> if request. method == ""POST"" : <TAB> <TAB> form = provider_form ( request. POST ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> data = form. cleaned_data <TAB> <TAB> <TAB> cloud_credentials_model. update ( <TAB> <TAB> <TAB> <TAB> data = data, id = credentials_id, provider_id = provider_id <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> sync_credentials ( credentials = provider_data ) <TAB> <TAB> <TAB> redirect_url = reverse ( <TAB> <TAB> <TAB> <TAB> ""cloudservers_edit"", <TAB> <TAB> <TAB> <TAB> kwargs = { ""provider_id"" : provider_id, ""credentials_id"" : credentials_id }, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> messages. add_message ( <TAB> <TAB> <TAB> <TAB> request, <TAB> <TAB> <TAB> <TAB> messages. INFO, <TAB> <TAB> <TAB> <TAB> ""{0} credentials updated & Servers synced"". format ( provider_id. title ( ) ), <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> return redirect ( redirect_url ) <TAB> else : <TAB> <TAB> form = provider_form ( provider_data = provider_data ) <TAB> return render_to_response ( <TAB> <TAB> ""cloudservers/view.html"", <TAB> <TAB> { <TAB> <TAB> <TAB> ""form""",True,form.is_valid(),form.is_valid(),0.6494518518447876
|
||
|
2574,"def xview ( self, mode = None, value = None, units = None ) : <TAB> if type ( value ) == str : <TAB> <TAB> value = float ( value ) <TAB> if mode is None : <TAB> <TAB> return self. hsb. get ( ) <TAB> elif mode == ""moveto"" : <TAB> <TAB> frameWidth = self. innerframe. winfo_reqwidth ( ) <TAB> <TAB> self. _startX = value * float ( frameWidth ) <TAB> else : <TAB> <TAB> clipperWidth = self. _clipper. winfo_width ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> jump = int ( clipperWidth * self. _jfraction ) <TAB> <TAB> else : <TAB> <TAB> <TAB> jump = clipperWidth <TAB> <TAB> self. _startX = self. _startX + value * jump <TAB> self. reposition ( )",False,units == 'units',self._jfraction is not None,0.6587004661560059
|
||
|
2575,"def r_main_suffix ( self ) : <TAB> <TAB> <TAB> v_1 = self. limit - self. cursor <TAB> <TAB> if self. cursor < self. I_p1 : <TAB> <TAB> return False <TAB> self. cursor = self. I_p1 <TAB> v_2 = self. limit_backward <TAB> self. limit_backward = self. cursor <TAB> self. cursor = self. limit - v_1 <TAB> <TAB> <TAB> self. ket = self. cursor <TAB> <TAB> among_var = self. find_among_b ( SwedishStemmer. a_0, 37 ) <TAB> if among_var == 0 : <TAB> <TAB> self. limit_backward = v_2 <TAB> <TAB> return False <TAB> <TAB> self. bra = self. cursor <TAB> self. limit_backward = v_2 <TAB> if among_var == 0 : <TAB> <TAB> return False <TAB> elif among_var == 1 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return False <TAB> elif among_var == 2 : <TAB> <TAB> <TAB> <TAB> if not self. in_grouping_b ( SwedishStemmer. g_s_ending, 98, 121 ) : <TAB> <TAB> <TAB> return False <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return False <TAB> return True",False,not self.slice_del(),"not self.in_grouping_b(SwedishStemmer.g_s_ending, 98, 121)",0.6546493768692017
|
||
|
2576,"def make_HTTPS_handler ( params, ** kwargs ) : <TAB> opts_no_check_certificate = params. get ( ""nocheckcertificate"", False ) <TAB> if hasattr ( ssl, ""create_default_context"" ) : <TAB> <TAB> context = ssl. create_default_context ( ssl. Purpose. SERVER_AUTH ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> context. check_hostname = False <TAB> <TAB> <TAB> context. verify_mode = ssl. CERT_NONE <TAB> <TAB> try : <TAB> <TAB> <TAB> return YoutubeDLHTTPSHandler ( params, context = context, ** kwargs ) <TAB> <TAB> except TypeError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> pass <TAB> if sys. version_info < ( 3, 2 ) : <TAB> <TAB> return YoutubeDLHTTPSHandler ( params, ** kwargs ) <TAB> else : <TAB> <TAB> context = ssl. SSLContext ( ssl. PROTOCOL_TLSv1 ) <TAB> <TAB> context. verify_mode = ( <TAB> <TAB> <TAB> ssl. CERT_NONE if opts_no_check_certificate else ssl. CERT_REQUIRED <TAB> <TAB> ) <TAB> <TAB> context. set_default_verify_paths ( ) <TAB> <TAB> return YoutubeDLHTTPSHandler ( params, context = context, ** kwargs )",True,opts_no_check_certificate,opts_no_check_certificate,0.6506801843643188
|
||
|
2577,"def __setitem__ ( self, key, value ) : <TAB> """"""Register item with priorty 5 less than lowest existing priority."""""" <TAB> if isinstance ( key, str ) : <TAB> <TAB> warnings. warn ( <TAB> <TAB> <TAB> ""Using setitem to register a processor or pattern is deprecated. "" <TAB> <TAB> <TAB> ""Use the `register` method instead."", <TAB> <TAB> <TAB> DeprecationWarning, <TAB> <TAB> <TAB> stacklevel = 2, <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _data [ key ] = value <TAB> <TAB> <TAB> return <TAB> <TAB> if len ( self ) == 0 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> priority = 50 <TAB> <TAB> else : <TAB> <TAB> <TAB> self. _sort ( ) <TAB> <TAB> <TAB> priority = self. _priority [ - 1 ]. priority - 5 <TAB> <TAB> self. register ( value, key, priority ) <TAB> else : <TAB> <TAB> raise TypeError",False,key in self,key in self._data,0.6785482168197632
|
||
|
2578,"def write_to_datastore ( self ) : <TAB> """"""Writes all image batches to the datastore."""""" <TAB> client = self. _datastore_client <TAB> with client. no_transact_batch ( ) as client_batch : <TAB> <TAB> for batch_id, batch_data in iteritems ( self. _data ) : <TAB> <TAB> <TAB> batch_key = client. key ( self. _entity_kind_batches, batch_id ) <TAB> <TAB> <TAB> batch_entity = client. entity ( batch_key ) <TAB> <TAB> <TAB> for k, v in iteritems ( batch_data ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> batch_entity [ k ] = v <TAB> <TAB> <TAB> client_batch. put ( batch_entity ) <TAB> <TAB> <TAB> self. _write_single_batch_images_internal ( batch_id, client_batch )",False,k != 'images',k in self._entity_kind_batches,0.663470983505249
|
||
|
2579,def generate ( ) : <TAB> if<mask> : <TAB> <TAB> decoder = zlib. decompressobj ( 16 + zlib. MAX_WBITS ) <TAB> while True : <TAB> <TAB> chunk = self. raw. read ( chunk_size ) <TAB> <TAB> if not chunk : <TAB> <TAB> <TAB> break <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> chunk = decoder. decompress ( chunk ) <TAB> <TAB> yield chunk,False,self._gzipped,chunk_size > 0,0.6692260503768921
|
||
|
2580,"def check ( self ) : <TAB> tcp_client = self. tcp_create ( ) <TAB> if tcp_client. connect ( ) : <TAB> <TAB> tcp_client. send ( b""ABCDE"" ) <TAB> <TAB> response = tcp_client. recv ( 5 ) <TAB> <TAB> tcp_client. close ( ) <TAB> <TAB> if response : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. endianness = "">"" <TAB> <TAB> <TAB> elif response. startswith ( b""ScMM"" ) : <TAB> <TAB> <TAB> <TAB> self. endianness = ""<"" <TAB> <TAB> <TAB> return True <TAB> return False",False,response.startswith(b'MMcS'),b'ScMM_1x' not in response,0.6525817513465881
|
||
|
2581,"def collect ( self ) : <TAB> for task in self. filter_processes ( ) : <TAB> <TAB> if not task. mm : <TAB> <TAB> <TAB> continue <TAB> <TAB> yield dict ( divider = ""Proc %s (%s)"" % ( task. name, task. pid ) ) <TAB> <TAB> for vma in task. mm. mmap. walk_list ( ""vm_next"" ) : <TAB> <TAB> <TAB> if vma. vm_file : <TAB> <TAB> <TAB> <TAB> inode = vma. vm_file. dentry. d_inode <TAB> <TAB> <TAB> <TAB> major, minor = inode. i_sb. major, inode. i_sb. minor <TAB> <TAB> <TAB> <TAB> ino = inode. i_ino <TAB> <TAB> <TAB> <TAB> pgoff = vma. vm_pgoff << 12 <TAB> <TAB> <TAB> <TAB> fname = task. get_path ( vma. vm_file ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> ( major, minor, ino, pgoff ) = [ 0 ] * 4 <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> fname = ""[heap]"" <TAB> <TAB> <TAB> <TAB> elif ( <TAB> <TAB> <TAB> <TAB> <TAB> vma. vm_start <= task. mm. start_stack <TAB> <TAB> <TAB> <TAB> <TAB> and vma. vm_end >= task. mm. start_stack <TAB> <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> <TAB> fname = ""[stack]"" <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> fname = """" <TAB> <TAB> <TAB> yield dict ( <TAB> <TAB> <TAB> <TAB> task = task, <TAB> <TAB> <TAB> <TAB> start = vma. vm_start, <TAB",False,vma.vm_start <= task.mm.start_brk and vma.vm_end >= task.mm.brk,pgoff,0.6551790237426758
|
||
|
2582,"def get_field_type ( self, connection, table_name, row ) : <TAB> field_type, field_params, field_notes = super ( Command, self ). get_field_type ( <TAB> <TAB> connection, table_name, row <TAB> ) <TAB> if field_type == ""GeometryField"" : <TAB> <TAB> geo_col = row [ 0 ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> field_type, geo_params = connection. introspection. get_geometry_type ( <TAB> <TAB> <TAB> table_name, geo_col <TAB> <TAB> ) <TAB> <TAB> field_params. update ( geo_params ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. gis_tables [ table_name ]. append ( geo_col ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. gis_tables [ table_name ] = [ geo_col ] <TAB> return field_type, field_params, field_notes",True,table_name in self.gis_tables,table_name in self.gis_tables,0.6529151797294617
|
||
|
2583,"def add ( meta_list, info_list = None ) : <TAB> if not info_list : <TAB> <TAB> info_list = meta_list <TAB> if not isinstance ( meta_list, ( list, tuple ) ) : <TAB> <TAB> meta_list = ( meta_list, ) <TAB> if not isinstance ( info_list, ( list, tuple ) ) : <TAB> <TAB> info_list = ( info_list, ) <TAB> for info_f in info_list : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> for meta_f in meta_list : <TAB> <TAB> <TAB> <TAB> metadata [ meta_f ] = info [ info_f ] <TAB> <TAB> <TAB> break",False,info.get(info_f) is not None,info[info_f],0.6488300561904907
|
||
|
2584,"def _source_encode ( source, saltenv ) : <TAB> try : <TAB> <TAB> source_url = _urlparse ( source ) <TAB> except TypeError : <TAB> <TAB> return """", { }, ( ""Invalid format for source parameter"" ) <TAB> protos = ( ""salt"", ""http"", ""https"", ""ftp"", ""swift"", ""s3"", ""file"" ) <TAB> log. trace ( ""parsed source looks like: %s"", source_url ) <TAB> if not source_url. scheme or source_url. scheme == ""file"" : <TAB> <TAB> <TAB> <TAB> filename = os. path. abspath ( source_url. path ) <TAB> <TAB> sname = os. path. basename ( filename ) <TAB> <TAB> log. debug ( ""Source is a regular local file: %s"", source_url. path ) <TAB> <TAB> if _is_dns_subdomain ( sname ) and _is_valid_secret_file ( filename ) : <TAB> <TAB> <TAB> return sname, _file_encode ( filename ) <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> filename = __salt__ [ ""cp.cache_file"" ] ( source, saltenv ) <TAB> <TAB> <TAB> if not filename : <TAB> <TAB> <TAB> <TAB> log. warning ( ""Source file: %s can not be retrieved"", source ) <TAB> <TAB> <TAB> <TAB> return """", """" <TAB> <TAB> <TAB> return os. path. basename ( filename ), _file_encode ( filename ) <TAB> return """", """"",False,source_url.scheme in protos,'cp.cache_file' in __salt__,0.6528134346008301
|
||
|
2585,"def html_visit_displaymath ( self : HTMLTranslator, node : nodes. math_block ) -> None : <TAB> self. body. append ( self. starttag ( node, ""div"", CLASS = ""math notranslate nohighlight"" ) ) <TAB> if node [ ""nowrap"" ] : <TAB> <TAB> self. body. append ( self. encode ( node. astext ( ) ) ) <TAB> <TAB> self. body. append ( ""</div>"" ) <TAB> <TAB> raise nodes. SkipNode <TAB> <TAB> if node [ ""number"" ] : <TAB> <TAB> number = get_node_equation_number ( self, node ) <TAB> <TAB> self. body. append ( '<span class=""eqno"">(%s)' % number ) <TAB> <TAB> self. add_permalink_ref ( node, _ ( ""Permalink to this equation"" ) ) <TAB> <TAB> self. body. append ( ""</span>"" ) <TAB> self. body. append ( self. builder. config. mathjax_display [ 0 ] ) <TAB> parts = [ prt for prt in node. astext ( ). split ( ""\n\n"" ) if prt. strip ( ) ] <TAB> if len ( parts ) > 1 : <TAB> <TAB> self. body. append ( r"" \begin{align}\begin{aligned}"" ) <TAB> for i, part in enumerate ( parts ) : <TAB> <TAB> part = self. encode ( part ) <TAB> <TAB> if r""\\"" in part : <TAB> <TAB> <TAB> self. body. append ( r""\begin{split}"" + part + r""\end{split}"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. body. append ( part ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. body. append ( r""\\"" ) <TAB> if len ( parts ) > 1 : <TAB> <TAB> self. body. append ( r""\end{aligned}\end{align} "" ) <TAB> self. body. append ( self. builder. config. mathjax_display [ 1 ] ) <TAB> self. body. append ( ""</div>\n"" ) <TAB",False,i < len(parts) - 1,'\\\\' in part,0.6528726816177368
|
||
|
2586,"def __contains__ ( self, val ) : <TAB> <TAB> <TAB> <TAB> pos = 0 <TAB> if self. _result_cache is not None : <TAB> <TAB> if val in self. _result_cache : <TAB> <TAB> <TAB> return True <TAB> <TAB> elif self. _iter is None : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return False <TAB> <TAB> <TAB> <TAB> pos = len ( self. _result_cache ) <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> it = iter ( self ) <TAB> <TAB> while True : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _fill_cache ( num = 1 ) <TAB> <TAB> if self. _iter is None : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return False <TAB> <TAB> if self. _result_cache [ pos ] == val : <TAB> <TAB> <TAB> return True <TAB> <TAB> pos += 1",False,len(self._result_cache) <= pos,pos >= len(self._result_cache),0.6558579206466675
|
||
|
2587,"def forwards ( self, orm ) : <TAB> ""Write your forwards methods here."" <TAB> <TAB> for affecteduser in orm [ ""sentry.AffectedUserByGroup"" ]. objects. filter ( <TAB> <TAB> ident__isnull = False <TAB> ) : <TAB> <TAB> if affecteduser. ident. startswith ( ""email:"" ) : <TAB> <TAB> <TAB> email = affecteduser. ident. split ( ""email:"", 1 ) [ - 1 ] <TAB> <TAB> else : <TAB> <TAB> <TAB> email = None <TAB> <TAB> tuser, created = orm [ ""sentry.TrackedUser"" ]. objects. get_or_create ( <TAB> <TAB> <TAB> project = affecteduser. project, <TAB> <TAB> <TAB> ident = affecteduser. ident, <TAB> <TAB> <TAB> defaults = { <TAB> <TAB> <TAB> <TAB> ""last_seen"" : affecteduser. last_seen, <TAB> <TAB> <TAB> <TAB> ""first_seen"" : affecteduser. first_seen, <TAB> <TAB> <TAB> <TAB> ""num_events"" : affecteduser. times_seen, <TAB> <TAB> <TAB> <TAB> ""email"" : email, <TAB> <TAB> <TAB> }, <TAB> <TAB> ) <TAB> <TAB> if not created : <TAB> <TAB> <TAB> kwargs = { <TAB> <TAB> <TAB> <TAB> ""num_events"" : F ( ""num_events"" ) + affecteduser. times_seen, <TAB> <TAB> <TAB> } <TAB> <TAB> <TAB> if affecteduser. last_seen > tuser. last_seen : <TAB> <TAB> <TAB> <TAB> kwargs [ ""last_seen"" ] = affecteduser. last_seen <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> kwargs [ ""first_seen"" ] = affecteduser. first_seen <TAB> <TAB> <TAB> orm [ ""sentry.TrackedUser"" ]. objects. filter ( id = tuser. id ). update ( ** kwargs ) <TAB",False,affecteduser.first_seen > tuser.first_seen,affecteduser.first_seen != tuser.id,0.6510517597198486
|
||
|
2588,"def readAtOffset ( self, offset, size, shortok = False ) : <TAB> ret = b"""" <TAB> self. fd. seek ( offset ) <TAB> while len ( ret )!= size : <TAB> <TAB> rlen = size - len ( ret ) <TAB> <TAB> x = self. fd. read ( rlen ) <TAB> <TAB> if x == b"""" : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return None <TAB> <TAB> <TAB> return ret <TAB> <TAB> ret += x <TAB> return ret",False,not shortok,shortok,0.685297966003418
|
||
|
2589,"def _download_data ( self ) : <TAB> _, archive_hash = self. _archive_file <TAB> for name, checksum in self. _checksums. items ( ) : <TAB> <TAB> name = name. split ( ""/"" ) <TAB> <TAB> path = os. path. join ( self. root, * name ) <TAB> <TAB> if not os. path. exists ( path ) or not check_sha1 ( path, checksum ) : <TAB> <TAB> <TAB> if self. _namespace is not None : <TAB> <TAB> <TAB> <TAB> url = _get_repo_file_url ( self. _namespace, self. _archive_file [ 0 ] ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> url = self. _url <TAB> <TAB> <TAB> downloaded_file_path = download ( <TAB> <TAB> <TAB> <TAB> url, path = self. root, sha1_hash = archive_hash, verify_ssl = self. _verify_ssl <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if downloaded_file_path. lower ( ). endswith ( ""zip"" ) : <TAB> <TAB> <TAB> <TAB> with zipfile. ZipFile ( downloaded_file_path, ""r"" ) as zf : <TAB> <TAB> <TAB> <TAB> <TAB> zf. extractall ( path = self. root ) <TAB> <TAB> <TAB> elif downloaded_file_path. lower ( ). endswith ( ""tar.gz"" ) : <TAB> <TAB> <TAB> <TAB> with tarfile. open ( downloaded_file_path, ""r"" ) as tf : <TAB> <TAB> <TAB> <TAB> <TAB> tf. extractall ( path = self. root ) <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> err = ""Failed retrieving {clsname}."". format ( <TAB> <TAB> <TAB> <TAB> <TAB> clsname = self. __class__. __name__ <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <",False,len(self._checksums) > 1,clsname is not None,0.652108371257782
|
||
|
2590,"def _find_activity_task_from_token ( self, task_token ) : <TAB> activity_task = None <TAB> for domain in self. domains : <TAB> <TAB> for wfe in domain. workflow_executions : <TAB> <TAB> <TAB> for task in wfe. activity_tasks : <TAB> <TAB> <TAB> <TAB> if task. task_token == task_token : <TAB> <TAB> <TAB> <TAB> <TAB> activity_task = task <TAB> <TAB> if not activity_task : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> raise SWFValidationException ( ""Invalid token"" ) <TAB> <TAB> wfe = activity_task. workflow_execution <TAB> if not wfe. open : <TAB> <TAB> raise SWFUnknownResourceFault ( <TAB> <TAB> <TAB> ""execution"", <TAB> <TAB> <TAB> ""WorkflowExecution=[workflowId={0}, runId={1}]"". format ( <TAB> <TAB> <TAB> <TAB> wfe. workflow_id, wfe. run_id <TAB> <TAB> <TAB> ), <TAB> <TAB> ) <TAB> <TAB> if activity_task. state!= ""STARTED"" : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise SWFUnknownResourceFault ( <TAB> <TAB> <TAB> <TAB> ""activity, scheduledEventId = {0}"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> activity_task. scheduled_event_id <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""This shouldn't happen: you have to PollForActivityTask to get a token, "" <TAB> <TAB> <TAB> <TAB> ""which changes ActivityTask status to 'STARTED' ; then it can only change "" <TAB> <TAB> <TAB> <TAB> ""to 'COMPLETED'. If you didn't hack moto/swf internals, this is probably "" <TAB> <",False,activity_task.state == 'COMPLETED',not wfe.open,0.658137321472168
|
||
|
2591,"def get_resource_public_actions ( resource_class ) : <TAB> resource_class_members = inspect. getmembers ( resource_class ) <TAB> resource_methods = { } <TAB> for name, member in resource_class_members : <TAB> <TAB> if not name. startswith ( ""_"" ) : <TAB> <TAB> <TAB> if not name [ 0 ]. isupper ( ) : <TAB> <TAB> <TAB> <TAB> if not name. startswith ( ""wait_until"" ) : <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> resource_methods [ name ] = member <TAB> return resource_methods",False,is_resource_action(member),member.startswith(wait_until),0.6521165370941162
|
||
|
2592,"def numpy_data_from_bmesh ( bm, out_np, face_data = None ) : <TAB> if out_np [ 0 ] : <TAB> <TAB> verts = np. array ( [ v. co [ : ] for v in bm. verts ] ) <TAB> else : <TAB> <TAB> verts = [ v. co [ : ] for v in bm. verts ] <TAB> if out_np [ 1 ] : <TAB> <TAB> edges = np. array ( [ [ e. verts [ 0 ]. index, e. verts [ 1 ]. index ] for e in bm. edges ] ) <TAB> else : <TAB> <TAB> edges = [ [ e. verts [ 0 ]. index, e. verts [ 1 ]. index ] for e in bm. edges ] <TAB> if out_np [ 2 ] : <TAB> <TAB> faces = np. array ( [ [ i. index for i in p. verts ] for p in bm. faces ] ) <TAB> else : <TAB> <TAB> faces = [ [ i. index for i in p. verts ] for p in bm. faces ] <TAB> if face_data : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> face_data_out = np. array ( face_data_from_bmesh_faces ( bm, face_data ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> face_data_out = face_data_from_bmesh_faces ( bm, face_data ) <TAB> <TAB> <TAB> return verts, edges, faces, face_data_out <TAB> else : <TAB> <TAB> return verts, edges, faces, [ ]",False,out_np[3],out_np[2],0.6536121368408203
|
||
|
2593,"def visualize_dnn ( dnn ) : <TAB> layer_num = len ( dnn. params ) / 2 <TAB> for i in xrange ( layer_num ) : <TAB> <TAB> fig_name = ""Activation weights W"" + str ( i ) <TAB> <TAB> fig_title = ""Activation weights of W"" + str ( i ) <TAB> <TAB> xlabel = ""Neuron index of hidden layer "" + str ( i ) <TAB> <TAB> ylabel = ""Neuron index of hidden layer "" + str ( i + 1 ) <TAB> <TAB> if i == 0 : <TAB> <TAB> <TAB> xlabel = ""Input feature index"" <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> ylabel = ""Output feature index"" <TAB> <TAB> logger. create_plot ( fig_name, SingleWeightMatrixPlot ) <TAB> <TAB> plotlogger. add_plot_point ( <TAB> <TAB> <TAB> fig_name, fig_name, dnn. params [ i * 2 ]. get_value ( borrow = True ). T <TAB> <TAB> ) <TAB> <TAB> plotlogger. save_plot ( fig_name, title = fig_name, xlabel = xlabel, ylabel = ylabel )",False,i == layer_num - 1,i == 1,0.6654807329177856
|
||
|
2594,"def apply_constants_config ( <TAB> spec_globals : Dict [ str, Any ], warn_if_unknown : bool = False ) -> None : <TAB> global config <TAB> for k, v in config. items ( ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> spec_globals [ k ] = spec_globals [ k ]. __class__ ( v ) <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if warn_if_unknown : <TAB> <TAB> <TAB> <TAB> print ( f""WARNING: unknown config key: '{k}' with value: '{v}'"" )",True,k in spec_globals,k in spec_globals,0.6681599617004395
|
||
|
2595,"def detect_layers ( layer_directories, no_auto ) : <TAB> layers = [ ] <TAB> for directory in layer_directories : <TAB> <TAB> directory = os. path. realpath ( directory ) <TAB> <TAB> if directory [ - 1 ] == ""/"" : <TAB> <TAB> <TAB> directory = directory [ 0 : - 1 ] <TAB> <TAB> if no_auto : <TAB> <TAB> <TAB> conf_dir = os. path. join ( directory, ""conf"" ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> layer = _detect_layer ( directory ) <TAB> <TAB> <TAB> <TAB> if layer : <TAB> <TAB> <TAB> <TAB> <TAB> layers. append ( layer ) <TAB> <TAB> else : <TAB> <TAB> <TAB> for root, dirs, files in os. walk ( directory ) : <TAB> <TAB> <TAB> <TAB> dir_name = os. path. basename ( root ) <TAB> <TAB> <TAB> <TAB> conf_dir = os. path. join ( root, ""conf"" ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> layer = _detect_layer ( root ) <TAB> <TAB> <TAB> <TAB> <TAB> if layer : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> layers. append ( layer ) <TAB> return layers",True,os.path.isdir(conf_dir),os.path.isdir(conf_dir),0.6444283723831177
|
||
|
2596,"def write_config ( config : configparser. ConfigParser = None ) -> None : <TAB> if not config : <TAB> <TAB> config = configparser. ConfigParser ( ) <TAB> need_write = False <TAB> for section_name, section in CONFIG_SCHEMA. items ( ) : <TAB> <TAB> if section_name not in config : <TAB> <TAB> <TAB> config [ section_name ] = { } <TAB> <TAB> for option_name, option_schema in section. items ( ) : <TAB> <TAB> <TAB> if option_schema. get ( ""migrated"" ) : <TAB> <TAB> <TAB> <TAB> need_write = True <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if option_name not in config [ section_name ] : <TAB> <TAB> <TAB> <TAB> config [ section_name ] [ option_name ] = option_schema [ ""default"" ] <TAB> <TAB> <TAB> <TAB> need_write = True <TAB> if need_write : <TAB> <TAB> if not os. path. exists ( CONFIG_ROOT ) : <TAB> <TAB> <TAB> os. makedirs ( CONFIG_ROOT ) <TAB> <TAB> with open ( CONFIG_PATH, ""w"" ) as configfile : <TAB> <TAB> <TAB> config. write ( configfile )",False,option_schema.get('deprecated'),section_name not in config,0.6487365961074829
|
||
|
2597,"def _poll ( self ) : <TAB> self. _sleep = min ( 20, self. _sleep + 2 ) <TAB> if len ( self. pending ) == 0 : <TAB> <TAB> return <TAB> for name, spec in self. pending. items ( ) : <TAB> <TAB> delta = time. time ( ) - spec [ ""received_at"" ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise error. TimeoutError ( <TAB> <TAB> <TAB> <TAB> ""Waited {}s for {} to get an IP, which exceeds start_timeout of {}"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> delta, name, self. start_timeout <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> names = list ( self. pending. keys ( ) ) <TAB> <TAB> <TAB> <TAB> allocation = self. with_retries ( <TAB> <TAB> self. _requestor. allocation_refresh, self. client_id, names = names <TAB> ) <TAB> assert len ( allocation [ ""env_n"" ] ) <= len ( <TAB> <TAB> names <TAB> ), ""Received more envs than requested: allocation={} names={}"". format ( <TAB> <TAB> allocation, names <TAB> ) <TAB> <TAB> result = set ( env [ ""name"" ] for env in allocation [ ""env_n"" ] ) <TAB> dropped = [ p for p in self. pending. keys ( ) if p not in result ] <TAB> if len ( dropped ) > 0 : <TAB> <TAB> logger. info ( <TAB> <TAB> <TAB> ""Pending remote envs %s were not returned by the allocator (only %s were returned). Assuming the missing ones have gone down and requesting replacements."", <TAB> <TAB> <TAB> dropped, <TAB> <TAB> <TAB> list ( result ), <TAB> <TAB> ) <TAB> <TAB> for d in dropped : <TAB> <TAB> <TAB> spec = self. pending. pop ( d ) <TAB> <TAB> <TAB> self. _allocate ( [ spec [ ""handle"" ] ], False, spec",True,delta > self.start_timeout,delta > self.start_timeout,0.6581231355667114
|
||
|
2598,"def __init__ ( <TAB> self, <TAB> config, <TAB> auth_portal, <TAB> RouterPB = None, <TAB> SMPPClientManagerPB = None, <TAB> interceptorpb_client = None, ) : <TAB> self. config = config <TAB> <TAB> <TAB> self. bound_connections = { } <TAB> self. _auth_portal = auth_portal <TAB> self. RouterPB = RouterPB <TAB> self. SMPPClientManagerPB = SMPPClientManagerPB <TAB> self. interceptorpb_client = interceptorpb_client <TAB> <TAB> self. stats = SMPPServerStatsCollector ( ). get ( cid = self. config. id ) <TAB> self. stats. set ( ""created_at"", datetime. now ( ) ) <TAB> <TAB> self. log = logging. getLogger ( LOG_CATEGORY_SERVER_BASE + "".%s"" % config. id ) <TAB> if len ( self. log. handlers )!= 1 : <TAB> <TAB> self. log. setLevel ( config. log_level ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> handler = logging. StreamHandler ( sys. stdout ) <TAB> <TAB> else : <TAB> <TAB> <TAB> handler = TimedRotatingFileHandler ( <TAB> <TAB> <TAB> <TAB> filename = self. config. log_file, when = self. config. log_rotate <TAB> <TAB> <TAB> ) <TAB> <TAB> formatter = logging. Formatter ( config. log_format, config. log_date_format ) <TAB> <TAB> handler. setFormatter ( formatter ) <TAB> <TAB> self. log. addHandler ( handler ) <TAB> <TAB> self. log. propagate = False <TAB> self. msgHandler = self. submit_sm_event_interceptor",False,'stdout' in self.config.log_file,self.log_rotate is None,0.6595252156257629
|
||
|
2599,"def toString ( self ) -> str : <TAB> l = [ ] <TAB> w = l. append <TAB> w ( ""sip:"" ) <TAB> if self. username!= None : <TAB> <TAB> w ( self. username ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> w ( "":%s"" % self. password ) <TAB> <TAB> w ( ""@"" ) <TAB> w ( self. host ) <TAB> if self. port!= None : <TAB> <TAB> w ( "":%d"" % self. port ) <TAB> if self. usertype!= None : <TAB> <TAB> w ( "";user=%s"" % self. usertype ) <TAB> for n in ( ""transport"", ""ttl"", ""maddr"", ""method"", ""tag"" ) : <TAB> <TAB> v = getattr ( self, n ) <TAB> <TAB> if v!= None : <TAB> <TAB> <TAB> w ( "";{}={}"". format ( n, v ) ) <TAB> for v in self. other : <TAB> <TAB> w ( "";%s"" % v ) <TAB> if self. headers : <TAB> <TAB> w ( ""?"" ) <TAB> <TAB> w ( <TAB> <TAB> <TAB> ""&"". join ( <TAB> <TAB> <TAB> <TAB> [ <TAB> <TAB> <TAB> <TAB> <TAB> ( ""{}={}"". format ( specialCases. get ( h ) or dashCapitalize ( h ), v ) ) <TAB> <TAB> <TAB> <TAB> <TAB> for ( h, v ) in self. headers. items ( ) <TAB> <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> ) <TAB> <TAB> ) <TAB> return """". join ( l )",True,self.password != None,self.password != None,0.6616320610046387
|
||
|
2600,"def get_object_from_name ( self, name, check_symlinks = True ) : <TAB> if not name : <TAB> <TAB> return None <TAB> name = name. rstrip ( ""\\"" ) <TAB> for a, o in self. objects. items ( ) : <TAB> <TAB> if not o. name : <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return o <TAB> if check_symlinks : <TAB> <TAB> m = [ sl [ 1 ] for sl in self. symlinks if name. lower ( ) == sl [ 0 ]. lower ( ) ] <TAB> <TAB> if m : <TAB> <TAB> <TAB> name = m [ 0 ] <TAB> <TAB> return self. get_object_from_name ( name, False )",False,o.name.lower() == name.lower(),a.check_symlink,0.6519632339477539
|
||
|
2601,def refresh ( self ) : <TAB> if self. _obj : <TAB> <TAB> base = self. _db. get_media_from_handle ( self. _obj. get_reference_handle ( ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _title = base. get_description ( ) <TAB> <TAB> <TAB> self. _value = base. get_path ( ),True,base,base,0.7030476927757263
|
||
|
2602,"def flow_stream_stats ( ips, flow_stream, period ) : <TAB> period_counters = { } <TAB> stats = Counter ( ) <TAB> for flow_records in flow_stream : <TAB> <TAB> for record in flow_records : <TAB> <TAB> <TAB> stats [ ""Flows"" ] += 1 <TAB> <TAB> <TAB> stats [ ""Bytes"" ] += record. bytes <TAB> <TAB> <TAB> pk = record. start - record. start % period <TAB> <TAB> <TAB> pc = period_counters. get ( pk ) <TAB> <TAB> <TAB> if pc is None : <TAB> <TAB> <TAB> <TAB> period_counters [ pk ] = pc = { ""inbytes"" : Counter ( ), ""outbytes"" : Counter ( ) } <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> stats [ ""Rejects"" ] += 1 <TAB> <TAB> <TAB> if record. dstaddr in ips : <TAB> <TAB> <TAB> <TAB> pc [ ""inbytes"" ] [ record. srcaddr ] += record. bytes <TAB> <TAB> <TAB> elif record. srcaddr in ips : <TAB> <TAB> <TAB> <TAB> pc [ ""outbytes"" ] [ record. dstaddr ] += record. bytes <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> raise ValueError ( """" ) <TAB> log. info ( <TAB> <TAB> ""flows:%d bytes:%s rejects:%s"", <TAB> <TAB> stats [ ""Flows"" ], <TAB> <TAB> human_size ( stats [ ""Bytes"" ] ), <TAB> <TAB> stats [ ""Rejects"" ], <TAB> ) <TAB> return period_counters",False,record.action == REJECT,pc.get_rank() > 0,0.6600205898284912
|
||
|
2603,"def update_pp_binding ( <TAB> tenantid, ppid, newtenantid = None, newportid = None, newdefault = None ) : <TAB> """"""Updates port profile binding"""""" <TAB> LOG. debug ( ""update_pp_binding() called"" ) <TAB> session = db. get_session ( ) <TAB> try : <TAB> <TAB> binding = ( <TAB> <TAB> <TAB> session. query ( l2network_models. PortProfileBinding ) <TAB> <TAB> <TAB>. filter_by ( portprofile_id = ppid ) <TAB> <TAB> <TAB>. one ( ) <TAB> <TAB> ) <TAB> <TAB> if newtenantid : <TAB> <TAB> <TAB> binding [ ""tenant_id"" ] = newtenantid <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> binding [ ""port_id"" ] = newportid <TAB> <TAB> if newdefault : <TAB> <TAB> <TAB> binding [ ""default"" ] = newdefault <TAB> <TAB> session. merge ( binding ) <TAB> <TAB> session. flush ( ) <TAB> <TAB> return binding <TAB> except exc. NoResultFound : <TAB> <TAB> raise c_exc. PortProfileNotFound ( tenant_id = tenantid, portprofile_id = ppid )",True,newportid,newportid,0.6855206489562988
|
||
|
2604,"def doc ( self ) : <TAB> lines = [ ] <TAB> for line in striphtml ( self. data [ ""desc"" ], tags = [ ""pre"" ] ). splitlines ( ) : <TAB> <TAB> line = re. sub ( ""\s+"", "" "", line ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> if re. match ( ""function \([^)]*\) { *}"", line ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> lines. append ( line ) <TAB> return ""\n"". join ( textwrap. wrap ( ""\n"". join ( lines ), width = 72 ) )",True,not line,not line,0.6631966829299927
|
||
|
2605,"def __init__ ( <TAB> self, <TAB> manifest_path, <TAB> sample_rate, <TAB> max_sample_size = None, <TAB> min_sample_size = None, <TAB> shuffle = True, <TAB> min_length = 0, <TAB> pad = False, <TAB> normalize = False, ) : <TAB> super ( ). __init__ ( <TAB> <TAB> sample_rate = sample_rate, <TAB> <TAB> max_sample_size = max_sample_size, <TAB> <TAB> min_sample_size = min_sample_size, <TAB> <TAB> shuffle = shuffle, <TAB> <TAB> min_length = min_length, <TAB> <TAB> pad = pad, <TAB> <TAB> normalize = normalize, <TAB> ) <TAB> self. fnames = [ ] <TAB> skipped = 0 <TAB> with open ( manifest_path, ""r"" ) as f : <TAB> <TAB> self. root_dir = f. readline ( ). strip ( ) <TAB> <TAB> for line in f : <TAB> <TAB> <TAB> items = line. strip ( ). split ( ""\t"" ) <TAB> <TAB> <TAB> assert len ( items ) == 2, line <TAB> <TAB> <TAB> sz = int ( items [ 1 ] ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> skipped += 1 <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> self. fnames. append ( items [ 0 ] ) <TAB> <TAB> <TAB> self. sizes. append ( sz ) <TAB> logger. info ( f""loaded {len(self.fnames)}, skipped {skipped} samples"" )",False,min_length is not None and sz < min_length,sz == 0,0.6565159559249878
|
||
|
2606,"def __init__ ( self, event, event_info, fields = [ ] ) : <TAB> _wmi_object. __init__ ( self, event, fields = fields ) <TAB> _set ( self, ""event_type"", None ) <TAB> _set ( self, ""timestamp"", None ) <TAB> _set ( self, ""previous"", None ) <TAB> if event_info : <TAB> <TAB> event_type = self. event_type_re. match ( event_info. Path_. Class ). group ( 1 ). lower ( ) <TAB> <TAB> _set ( self, ""event_type"", event_type ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> _set ( self, ""timestamp"", from_1601 ( event_info. TIME_CREATED ) ) <TAB> <TAB> if hasattr ( event_info, ""PreviousInstance"" ) : <TAB> <TAB> <TAB> _set ( self, ""previous"", event_info. PreviousInstance )",True,"hasattr(event_info, 'TIME_CREATED')","hasattr(event_info, 'TIME_CREATED')",0.6506666541099548
|
||
|
2607,"def doForward ( users ) : <TAB> enable = getBoolean ( sys. argv [ 4 ], ""gam <users> forward"" ) <TAB> body = { ""enabled"" : enable } <TAB> i = 5 <TAB> while i < len ( sys. argv ) : <TAB> <TAB> myarg = sys. argv [ i ]. lower ( ) <TAB> <TAB> if myarg in EMAILSETTINGS_FORWARD_POP_ACTION_CHOICES_MAP : <TAB> <TAB> <TAB> body [ ""disposition"" ] = EMAILSETTINGS_FORWARD_POP_ACTION_CHOICES_MAP [ myarg ] <TAB> <TAB> <TAB> i += 1 <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> i += 1 <TAB> <TAB> elif myarg. find ( ""@"" )!= - 1 : <TAB> <TAB> <TAB> body [ ""emailAddress"" ] = sys. argv [ i ] <TAB> <TAB> <TAB> i += 1 <TAB> <TAB> else : <TAB> <TAB> <TAB> controlflow. invalid_argument_exit ( myarg, ""gam <users> forward"" ) <TAB> if enable and ( not body. get ( ""disposition"" ) or not body. get ( ""emailAddress"" ) ) : <TAB> <TAB> controlflow. system_error_exit ( <TAB> <TAB> <TAB> 2, <TAB> <TAB> <TAB> 'you must specify an action and a forwarding address for ""gam <users> forward', <TAB> <TAB> ) <TAB> i = 0 <TAB> count = len ( users ) <TAB> for user in users : <TAB> <TAB> i += 1 <TAB> <TAB> user, gmail = buildGmailGAPIObject ( user ) <TAB> <TAB> if not gmail : <TAB> <TAB> <TAB> continue <TAB> <TAB> if enable : <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> f'User: {user}, Forward Enabled: {enable}, Forwarding Address: {body[""emailAddress""]}, Action: {body[""disposition""]}{currentCount(i, count)}' <TAB> <TAB> <TAB>",False,myarg == 'confirm',myarg.find(@@),0.6625698804855347
|
||
|
2608,"def _threaded_request_tracker ( self, builder ) : <TAB> while True : <TAB> <TAB> event_type = self. _read_q. get ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return <TAB> <TAB> payload = { ""body"" : b"""" } <TAB> <TAB> request_id = builder. build_record ( event_type, payload, """" ) <TAB> <TAB> self. _write_q. put_nowait ( request_id )",False,event_type is False,event_type == 'read',0.6583157777786255
|
||
|
2609,"def __getitem__ ( self, index ) : <TAB> while True : <TAB> <TAB> try : <TAB> <TAB> <TAB> file = self. files [ self. index ] <TAB> <TAB> <TAB> self. index = self. index + 1 <TAB> <TAB> except IndexError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. directory = self. stack. pop ( ) <TAB> <TAB> <TAB> if os. path. isdir ( self. directory ) : <TAB> <TAB> <TAB> <TAB> self. files = os. listdir ( self. directory ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. files = [ ] <TAB> <TAB> <TAB> self. index = 0 <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> fullname = os. path. join ( self. directory, file ) <TAB> <TAB> <TAB> if os. path. isdir ( fullname ) and not os. path. islink ( fullname ) : <TAB> <TAB> <TAB> <TAB> self. stack. append ( fullname ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return fullname",False,"fnmatch.fnmatch(file, self.pattern)",len(self.stack) == self.maxlen,0.6445600986480713
|
||
|
2610,"def register_middleware ( self, middleware_instance ) : <TAB> registered_count = 0 <TAB> self. _middlewares. append ( middleware_instance ) <TAB> for hook in self. _hooks. keys ( ) : <TAB> <TAB> functor = getattr ( middleware_instance, hook, None ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> functor = middleware_instance. get ( hook, None ) <TAB> <TAB> <TAB> except AttributeError : <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> if functor is not None : <TAB> <TAB> <TAB> self. _hooks [ hook ]. append ( functor ) <TAB> <TAB> <TAB> registered_count += 1 <TAB> return registered_count",True,functor is None,functor is None,0.6707620620727539
|
||
|
2611,"def plugin_on_song_ended ( self, song, skipped ) : <TAB> if song is not None : <TAB> <TAB> rating = song ( ""~#rating"" ) <TAB> <TAB> invrating = 1.0 - rating <TAB> <TAB> delta = min ( rating, invrating ) / 2.0 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> rating -= delta <TAB> <TAB> else : <TAB> <TAB> <TAB> rating += delta <TAB> <TAB> song [ ""~#rating"" ] = rating",True,skipped,skipped,0.6970874071121216
|
||
|
2612,"def _setup_importer ( self ) : <TAB> importer = self. config. get ( ""importer"" ) <TAB> if importer : <TAB> <TAB> importer. _install_handler ( self. router ) <TAB> <TAB> importer. _context = self. parent <TAB> else : <TAB> <TAB> core_src_fd = self. config. get ( ""core_src_fd"", 101 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> fp = os. fdopen ( core_src_fd, ""rb"", 1 ) <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> core_src = fp. read ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> core_src = b ( ""\n"" ). join ( core_src. splitlines ( ) [ : - 1 ] ) <TAB> <TAB> <TAB> finally : <TAB> <TAB> <TAB> <TAB> fp. close ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> core_src = None <TAB> <TAB> importer = Importer ( <TAB> <TAB> <TAB> self. router, <TAB> <TAB> <TAB> self. parent, <TAB> <TAB> <TAB> core_src, <TAB> <TAB> <TAB> self. config. get ( ""whitelist"", ( ) ), <TAB> <TAB> <TAB> self. config. get ( ""blacklist"", ( ) ), <TAB> <TAB> ) <TAB> self. importer = importer <TAB> self. router. importer = importer <TAB> sys. meta_path. insert ( 0, self. importer )",True,core_src_fd,core_src_fd,0.6634727120399475
|
||
|
2613,"def _resolve_baseami ( self ) : <TAB> log. info ( ""Resolving base AMI"" ) <TAB> context = self. _config. context <TAB> cloud_config = self. _config. plugins [ self. full_name ] <TAB> try : <TAB> <TAB> ami_id = context. ami. get ( <TAB> <TAB> <TAB> ""base_ami_name"", cloud_config. get ( ""base_ami_name"", None ) <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> ami_id = context. ami. get ( <TAB> <TAB> <TAB> <TAB> ""base_ami_id"", cloud_config. get ( ""base_ami_id"", None ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise RuntimeError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Must configure or provide either a base ami name or id"" <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> context. ami [ ""ami_id"" ] = ami_id <TAB> <TAB> <TAB> <TAB> log. info ( ""looking up base AMI with ID {0}"". format ( ami_id ) ) <TAB> <TAB> <TAB> <TAB> baseami = self. _connection. get_all_images ( image_ids = [ ami_id ] ) [ 0 ] <TAB> <TAB> else : <TAB> <TAB> <TAB> log. info ( ""looking up base AMI with name {0}"". format ( ami_id ) ) <TAB> <TAB> <TAB> baseami = self. _connection. get_all_images ( filters = { ""name"" : ami_id } ) [ 0 ] <TAB> except IndexError : <TAB> <TAB> raise RuntimeError ( <TAB> <TAB> <TAB> ""Could not locate base AMI with identifier: {0}"". format ( ami_id ) <TAB> <",False,ami_id is None,not ami_id,0.6613317131996155
|
||
|
2614,"def _tokenize ( self, string, munge = False ) : <TAB> if munge : <TAB> <TAB> for ts in self. RE_MUNGE_TOKENSPACERS : <TAB> <TAB> <TAB> string = re. sub ( ts, ""\\1 \\2"", string ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> for ts in self. RE_MUNGE_TOKENSTRIPPERS : <TAB> <TAB> <TAB> <TAB> string = re. sub ( ts, """", string ) <TAB> return re. findall ( self. RE_TOKENIZER, string )",False,munge == 3,munge,0.7060970067977905
|
||
|
2615,"def get_scene_exceptions_by_season ( self, season = - 1 ) : <TAB> scene_exceptions = [ ] <TAB> for scene_exception in self. scene_exceptions : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> scene_name, scene_season = scene_exception. split ( ""|"" ) <TAB> <TAB> if season == scene_season : <TAB> <TAB> <TAB> scene_exceptions. append ( scene_name ) <TAB> return scene_exceptions",False,not len(scene_exception) == 2,scene_exception == '',0.651654839515686
|
||
|
2616,"def getElement ( self, aboutUri, namespace, name ) : <TAB> for desc in self. rdfRoot. getElementsByTagNameNS ( RDF_NAMESPACE, ""Description"" ) : <TAB> <TAB> if desc. getAttributeNS ( RDF_NAMESPACE, ""about"" ) == aboutUri : <TAB> <TAB> <TAB> attr = desc. getAttributeNodeNS ( namespace, name ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> yield attr <TAB> <TAB> <TAB> for element in desc. getElementsByTagNameNS ( namespace, name ) : <TAB> <TAB> <TAB> <TAB> yield element",False,attr != None,attr,0.6779091358184814
|
||
|
2617,"def save ( self, commit = True ) : <TAB> account = super ( AccountFormGeneral, self ). save ( commit = False ) <TAB> if self. user == account and not self. cleaned_data [ ""is_active"" ] : <TAB> <TAB> raise lib_exceptions. PermDeniedException ( <TAB> <TAB> <TAB> _ ( ""You can't disable your own account"" ) <TAB> <TAB> ) <TAB> if not account. pk : <TAB> <TAB> account. language = settings. LANGUAGE_CODE <TAB> if commit : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> account. set_password ( self. cleaned_data [ ""password2"" ] ) <TAB> <TAB> account. save ( ) <TAB> <TAB> account. role = self. cleaned_data [ ""role"" ] <TAB> <TAB> if hasattr ( account, ""mailbox"" ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> models. Alias. objects. filter ( address = account. email, internal = False ). update ( <TAB> <TAB> <TAB> <TAB> enabled = account. is_active <TAB> <TAB> <TAB> ) <TAB> return account",False,"self.cleaned_data.get('password2', '') != ''",self.cleaned_data['password2'],0.6529395580291748
|
||
|
2618,def refresh ( self ) : <TAB> if self. _handle : <TAB> <TAB> source = self. _db. get_repository_from_handle ( self. _handle ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _title = str ( source. get_type ( ) ) <TAB> <TAB> <TAB> self. _value = source. get_name ( ),True,source,source,0.693641185760498
|
||
|
2619,"def save_weight ( name, node, level ) : <TAB> weights [ name ] = dict ( ) <TAB> current_layer = weights [ name ] <TAB> for p in params : <TAB> <TAB> if hasattr ( node, p ) : <TAB> <TAB> <TAB> func = getattr ( node, p ) <TAB> <TAB> <TAB> arr = np. array ( func ) <TAB> <TAB> <TAB> if arr. ndim >= 1 : <TAB> <TAB> <TAB> <TAB> current_layer [ p ] = arr <TAB> <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> <TAB> "" "" * level <TAB> <TAB> <TAB> <TAB> <TAB> + ""{}.{} shape {} {}"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> name, p, current_layer [ p ]. shape, current_layer [ p ]. dtype <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> ) <TAB> for p in recursive : <TAB> <TAB> if hasattr ( node, p ) : <TAB> <TAB> <TAB> func = getattr ( node, p ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> for idx, subnode in enumerate ( func ) : <TAB> <TAB> <TAB> <TAB> <TAB> new_name = name + "":{}:{}"". format ( p, idx ) <TAB> <TAB> <TAB> <TAB> <TAB> save_weight ( new_name, subnode, level + 1 )",False,func != None,func is not None,0.675049901008606
|
||
|
2620,"def expression_set ( <TAB> expr : irast. Expr, <TAB> path_id : Optional [ irast. PathId ] = None, <TAB> *, <TAB> type_override : Optional [ s_types. Type ] = None, <TAB> ctx : context. ContextLevel, ) -> irast. Set : <TAB> if isinstance ( expr, irast. Set ) : <TAB> <TAB> raise errors. InternalServerError ( f""{expr!r} is already a Set"" ) <TAB> if type_override is not None : <TAB> <TAB> stype = type_override <TAB> else : <TAB> <TAB> stype = inference. infer_type ( expr, ctx. env ) <TAB> if<mask> : <TAB> <TAB> path_id = getattr ( expr, ""path_id"", None ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> path_id = pathctx. get_expression_path_id ( stype, ctx = ctx ) <TAB> return new_set ( <TAB> <TAB> path_id = path_id, stype = stype, expr = expr, context = expr. context, ctx = ctx <TAB> )",True,path_id is None,path_id is None,0.6556904315948486
|
||
|
2621,"def list_stuff ( self, upto = 10, start_after = - 1 ) : <TAB> for i in range ( upto ) : <TAB> <TAB> if i <= start_after : <TAB> <TAB> <TAB> continue <TAB> <TAB> if i == 2 and self. count < 1 : <TAB> <TAB> <TAB> self. count += 1 <TAB> <TAB> <TAB> raise TemporaryProblem <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. count += 1 <TAB> <TAB> <TAB> raise TemporaryProblem <TAB> <TAB> yield i",False,i == 7 and self.count < 4,i == 3 and self.count < 1,0.656586766242981
|
||
|
2622,"def ingest ( self, co, classname = None, code_objects = { }, show_asm = None ) : <TAB> tokens, customize = Scanner3. ingest ( self, co, classname, code_objects, show_asm ) <TAB> not_pypy36 = not ( self. version == 3.6 and self. is_pypy ) <TAB> for t in tokens : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if not_pypy36 and t. op == self. opc. CALL_FUNCTION_EX and t. attr & 1 : <TAB> <TAB> <TAB> t. kind = ""CALL_FUNCTION_EX_KW"" <TAB> <TAB> <TAB> pass <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> t. kind = ""BUILD_STRING_%s"" % t. attr <TAB> <TAB> elif t. op == self. opc. CALL_FUNCTION_KW : <TAB> <TAB> <TAB> t. kind = ""CALL_FUNCTION_KW_%s"" % t. attr <TAB> <TAB> elif t. op == self. opc. FORMAT_VALUE : <TAB> <TAB> <TAB> if t. attr & 0x4 : <TAB> <TAB> <TAB> <TAB> t. kind = ""FORMAT_VALUE_ATTR"" <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> elif not_pypy36 and t. op == self. opc. BUILD_MAP_UNPACK_WITH_CALL : <TAB> <TAB> <TAB> t. kind = ""BUILD_MAP_UNPACK_WITH_CALL_%d"" % t. attr <TAB> <TAB> elif not_pypy36 and t. op == self. opc. BUILD_TUPLE_UNPACK_WITH_CALL : <TAB> <TAB> <TAB> t. kind = ""BUILD_TUPLE_UNPACK_WITH_CALL_%d"" % t. attr <TAB> <TAB> pass <TAB> return tokens, customize",True,t.op == self.opc.BUILD_STRING,t.op == self.opc.BUILD_STRING,0.6650586128234863
|
||
|
2623,"def post ( self, * args, ** kwargs ) : <TAB> self. object = confirmation = self. get_object ( ) <TAB> self. user = self. request. user <TAB> confirmed = confirmation. confirm ( ) is not None <TAB> if confirmed : <TAB> <TAB> self. after_confirmation ( confirmation ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. user = self. login_user ( confirmation. email_address. user ) <TAB> <TAB> redirect_url = self. get_redirect_url ( ) <TAB> <TAB> if not redirect_url : <TAB> <TAB> <TAB> ctx = self. get_context_data ( ) <TAB> <TAB> <TAB> return self. render_to_response ( ctx ) <TAB> <TAB> if self. messages. get ( ""email_confirmed"" ) : <TAB> <TAB> <TAB> messages. add_message ( <TAB> <TAB> <TAB> <TAB> self. request, <TAB> <TAB> <TAB> <TAB> self. messages [ ""email_confirmed"" ] [ ""level"" ], <TAB> <TAB> <TAB> <TAB> self. messages [ ""email_confirmed"" ] [ ""text"" ]. format ( <TAB> <TAB> <TAB> <TAB> <TAB> ** { ""email"" : confirmation. email_address. email } <TAB> <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> ) <TAB> else : <TAB> <TAB> redirect_url = self. get_redirect_url ( ) <TAB> <TAB> messages. add_message ( <TAB> <TAB> <TAB> self. request, <TAB> <TAB> <TAB> self. messages [ ""email_confirmation_expired"" ] [ ""level"" ], <TAB> <TAB> <TAB> self. messages [ ""email_confirmation_expired"" ] [ ""text"" ]. format ( <TAB> <TAB> <TAB> <TAB> ** { ""email"" : confirmation. email_address. email } <TAB> <TAB> <TAB> ), <TAB> <TAB> ) <TAB> return redirect ( redirect_url )",False,settings.ACCOUNT_EMAIL_CONFIRMATION_AUTO_LOGIN,self.user is None,0.6533658504486084
|
||
|
2624,"def func_wrapper ( self, * args, ** kwds ) : <TAB> self. home ( ) <TAB> history_name = f. __name__ + datetime. datetime. now ( ). strftime ( ""%Y%m%d%H%M%s"" ) <TAB> self. history_panel_create_new_with_name ( history_name ) <TAB> try : <TAB> <TAB> f ( self, * args, ** kwds ) <TAB> finally : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> current_history_id = self. current_history_id ( ) <TAB> <TAB> <TAB> <TAB> self. dataset_populator. cancel_history_jobs ( current_history_id ) <TAB> <TAB> <TAB> <TAB> self. api_delete ( ""histories/%s"" % current_history_id ) <TAB> <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Faild to cleanup managed history, selenium connection corrupted somehow?"" <TAB> <TAB> <TAB> <TAB> )",False,'GALAXY_TEST_NO_CLEANUP' not in os.environ,self.dataset_populator is not None,0.6518641710281372
|
||
|
2625,"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. value = 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.value is None,0.6590157747268677
|
||
|
2626,"def notify_global_event ( <TAB> event, sender_user, node, timestamp, recipients, template = None, context = None ) : <TAB> event_type = utils. find_subscription_type ( event ) <TAB> sent_users = [ ] <TAB> if not context : <TAB> <TAB> context = { } <TAB> for recipient in recipients : <TAB> <TAB> subscriptions = get_user_subscriptions ( recipient, event_type ) <TAB> <TAB> context [ ""is_creator"" ] = recipient == node. creator <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> context [ ""has_psyarxiv_chronos_text"" ] = ( <TAB> <TAB> <TAB> <TAB> node. has_permission ( recipient, ADMIN ) <TAB> <TAB> <TAB> <TAB> and ""psyarxiv"" in node. provider. name. lower ( ) <TAB> <TAB> <TAB> ) <TAB> <TAB> for notification_type in subscriptions : <TAB> <TAB> <TAB> if ( <TAB> <TAB> <TAB> <TAB> notification_type!= ""none"" <TAB> <TAB> <TAB> <TAB> and subscriptions [ notification_type ] <TAB> <TAB> <TAB> <TAB> and recipient. _id in subscriptions [ notification_type ] <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> store_emails ( <TAB> <TAB> <TAB> <TAB> <TAB> [ recipient. _id ], <TAB> <TAB> <TAB> <TAB> <TAB> notification_type, <TAB> <TAB> <TAB> <TAB> <TAB> event, <TAB> <TAB> <TAB> <TAB> <TAB> sender_user, <TAB> <TAB> <TAB> <TAB> <TAB> node, <TAB> <TAB> <TAB> <TAB> <TAB> timestamp, <TAB> <TAB> <TAB> <TAB> <TAB> template = template, <TAB> <TAB> <TAB> <TAB> <TAB> ** context <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> sent_users.",False,node.provider,template,0.6600046157836914
|
||
|
2627,"def _worker ( index, env_fn, pipe, parent_pipe, shared_memory, error_queue ) : <TAB> assert shared_memory is None <TAB> env = env_fn ( ) <TAB> parent_pipe. close ( ) <TAB> try : <TAB> <TAB> while True : <TAB> <TAB> <TAB> command, data = pipe. recv ( ) <TAB> <TAB> <TAB> if command == ""reset"" : <TAB> <TAB> <TAB> <TAB> observation = env. reset ( ) <TAB> <TAB> <TAB> <TAB> pipe. send ( ( observation, True ) ) <TAB> <TAB> <TAB> elif command == ""step"" : <TAB> <TAB> <TAB> <TAB> observation, reward, done, info = env. step ( data ) <TAB> <TAB> <TAB> <TAB> if done : <TAB> <TAB> <TAB> <TAB> <TAB> observation = env. reset ( ) <TAB> <TAB> <TAB> <TAB> pipe. send ( ( ( observation, reward, done, info ), True ) ) <TAB> <TAB> <TAB> elif command == ""seed"" : <TAB> <TAB> <TAB> <TAB> env. seed ( data ) <TAB> <TAB> <TAB> <TAB> pipe. send ( ( None, True ) ) <TAB> <TAB> <TAB> elif command == ""close"" : <TAB> <TAB> <TAB> <TAB> pipe. send ( ( None, True ) ) <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> pipe. send ( ( data == env. observation_space, True ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> raise RuntimeError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Received unknown command `{0}`. Must "" <TAB> <TAB> <TAB> <TAB> <TAB> ""be one of {`reset`, `step`, `seed`, `close`, "" <TAB> <TAB> <TAB> <TAB> <TAB> ""`_check_observation_space`}."". format (",False,command == '_check_observation_space',command == 'observation_space',0.656582236289978
|
||
|
2628,"def sla_add ( request, response_format = ""html"" ) : <TAB> ""ServiceLevelAgreement add"" <TAB> if not request. user. profile. is_admin ( ""treeio.services"" ) : <TAB> <TAB> return user_denied ( <TAB> <TAB> <TAB> request, <TAB> <TAB> <TAB> message = ""You don't have administrator access to the Service Support module"", <TAB> <TAB> ) <TAB> if request. POST : <TAB> <TAB> if ""cancel"" not in request. POST : <TAB> <TAB> <TAB> sla = ServiceLevelAgreement ( ) <TAB> <TAB> <TAB> form = ServiceLevelAgreementForm ( <TAB> <TAB> <TAB> <TAB> request. user. profile, request. POST, instance = sla <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> sla = form. save ( ) <TAB> <TAB> <TAB> <TAB> sla. set_user_from_request ( request ) <TAB> <TAB> <TAB> <TAB> return HttpResponseRedirect ( reverse ( ""services_sla_view"", args = [ sla. id ] ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return HttpResponseRedirect ( reverse ( ""services"" ) ) <TAB> else : <TAB> <TAB> form = ServiceLevelAgreementForm ( request. user. profile ) <TAB> context = _get_default_context ( request ) <TAB> context. update ( { ""form"" : form } ) <TAB> return render_to_response ( <TAB> <TAB> ""services/sla_add"", <TAB> <TAB> context, <TAB> <TAB> context_instance = RequestContext ( request ), <TAB> <TAB> response_format = response_format, <TAB> )",True,form.is_valid(),form.is_valid(),0.6508152484893799
|
||
|
2629,"def on_file_save ( self, event ) : <TAB> with wx. FileDialog ( <TAB> <TAB> self, <TAB> <TAB> ""Save figure"", <TAB> <TAB> wildcard = ""PDF file (*.pdf)|*.pdf|PNG image (*.png)|*.png"", <TAB> <TAB> style = wx. FD_SAVE | wx. FD_OVERWRITE_PROMPT, <TAB> ) as dlg : <TAB> <TAB> if dlg. ShowModal ( ) == wx. ID_OK : <TAB> <TAB> <TAB> path = dlg. GetPath ( ) <TAB> <TAB> <TAB> if dlg. FilterIndex == 1 : <TAB> <TAB> <TAB> <TAB> file_format = ""png"" <TAB> <TAB> <TAB> elif dlg. FilterIndex == 0 : <TAB> <TAB> <TAB> <TAB> file_format = ""pdf"" <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> file_format = ""tif"" <TAB> <TAB> <TAB> elif dlg. FilterIndex == 3 : <TAB> <TAB> <TAB> <TAB> file_format = ""jpg"" <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> file_format = ""pdf"" <TAB> <TAB> <TAB> if ""."" not in os. path. split ( path ) [ 1 ] : <TAB> <TAB> <TAB> <TAB> path += ""."" + file_format <TAB> <TAB> <TAB> self. figure. savefig ( path, format = file_format )",True,dlg.FilterIndex == 2,dlg.FilterIndex == 2,0.6593809723854065
|
||
|
2630,"def getStateString ( self, state = None ) : <TAB> if state is None : <TAB> <TAB> state = self. _state <TAB> if state == self. STATE_NONE : <TAB> <TAB> return ""Offline"" <TAB> elif state == self. STATE_OPEN_SERIAL : <TAB> <TAB> return ""Opening serial connection"" <TAB> elif state == self. STATE_DETECT_SERIAL : <TAB> <TAB> return ""Detecting serial connection"" <TAB> elif state == self. STATE_CONNECTING : <TAB> <TAB> return ""Connecting"" <TAB> elif state == self. STATE_OPERATIONAL : <TAB> <TAB> return ""Operational"" <TAB> elif state == self. STATE_STARTING : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return ""Starting print from SD"" <TAB> <TAB> elif self. isStreaming ( ) : <TAB> <TAB> <TAB> return ""Starting to send file to SD"" <TAB> <TAB> else : <TAB> <TAB> <TAB> return ""Starting"" <TAB> elif state == self. STATE_PRINTING : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return ""Printing from SD"" <TAB> <TAB> elif self. isStreaming ( ) : <TAB> <TAB> <TAB> return ""Sending file to SD"" <TAB> <TAB> else : <TAB> <TAB> <TAB> return ""Printing"" <TAB> elif state == self. STATE_CANCELLING : <TAB> <TAB> return ""Cancelling"" <TAB> elif state == self. STATE_PAUSING : <TAB> <TAB> return ""Pausing"" <TAB> elif state == self. STATE_PAUSED : <TAB> <TAB> return ""Paused"" <TAB> elif state == self. STATE_RESUMING : <TAB> <TAB> return ""Resuming"" <TAB> elif state == self. STATE_FINISHING : <TAB> <TAB> return ""Finishing"" <TAB> elif state == self. STATE_CLOSED : <TAB> <TAB> return ""Offline"" <TAB> elif state == self. STATE_ERROR : <TAB> <TAB> return ""Error: {}"". format (",False,self.isSdFileSelected(),self.isStreaming(),0.6604294180870056
|
||
|
2631,"def clean_asset ( self ) : <TAB> model = self. cleaned_data. get ( ""model"" ) <TAB> asset = self. cleaned_data. get ( ""asset"" ) <TAB> <TAB> <TAB> if not model : <TAB> <TAB> return asset <TAB> if model and model. type not in ASSET_NOT_REQUIRED : <TAB> <TAB> if not asset : <TAB> <TAB> <TAB> msg = ""Asset is required for this kind of device."" <TAB> <TAB> <TAB> raise forms. ValidationError ( msg ) <TAB> if ""ralph_assets"" in settings. INSTALLED_APPS : <TAB> <TAB> from ralph_assets. api_ralph import is_asset_assigned <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise forms. ValidationError ( <TAB> <TAB> <TAB> <TAB> ""This asset is already linked to some other device. "" <TAB> <TAB> <TAB> <TAB> ""To resolve this conflict, please click the link above."" <TAB> <TAB> <TAB> ) <TAB> return asset",False,asset and is_asset_assigned(asset_id=asset.id),is_asset_assigned(asset),0.6504762172698975
|
||
|
2632,"def make_test_suite ( self, all, marked ) : <TAB> """"""Return the test suite or None."""""" <TAB> c, tm = self. c, self <TAB> suite = unittest. makeSuite ( unittest. TestCase ) <TAB> aList = tm. findAllUnitTestNodes ( all, marked ) <TAB> setup_script = None <TAB> found = False <TAB> for p in aList : <TAB> <TAB> if tm. isTestSetupNode ( p ) : <TAB> <TAB> <TAB> setup_script = p. b <TAB> <TAB> <TAB> test = None <TAB> <TAB> elif tm. isTestNode ( p ) : <TAB> <TAB> <TAB> test = tm. makeTestCase ( p, setup_script ) <TAB> <TAB> elif tm. isSuiteNode ( p ) : <TAB> <TAB> <TAB> test = tm. makeTestSuite ( p, setup_script ) <TAB> <TAB> elif tm. isTestClassNode ( p ) : <TAB> <TAB> <TAB> test = tm. makeTestClass ( p ) <TAB> <TAB> else : <TAB> <TAB> <TAB> test = None <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> suite. addTest ( test ) <TAB> <TAB> <TAB> found = True <TAB> if not found : <TAB> <TAB> <TAB> <TAB> test = tm. makeTestCase ( c. p, setup_script ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> suite. addTest ( test ) <TAB> <TAB> <TAB> found = True <TAB> return suite if found else None",False,test,not test,0.6846701502799988
|
||
|
2633,"def test_write ( self ) : <TAB> with gzip. GzipFile ( self. filename, ""wb"" ) as f : <TAB> <TAB> f. write ( data1 * 50 ) <TAB> <TAB> <TAB> <TAB> f. flush ( ) <TAB> <TAB> f. fileno ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> os. fsync ( f. fileno ( ) ) <TAB> <TAB> f. close ( ) <TAB> <TAB> f. close ( )",False,"hasattr(os, 'fsync')",os.stat(f.fileno()).st_size() == 0,0.6512020826339722
|
||
|
2634,"def _gen_az_wrapper ( self, genaz_regex, count_regex ) : <TAB> if genaz_regex. search ( self. param_value ) : <TAB> <TAB> numazs = int ( self. regxfind ( count_regex, self. param_value ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _regex_replace_param_value ( genaz_regex, self. get_available_azs ( numazs ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> LOG. info ( ""$[taskcat_genaz_(!)]"" ) <TAB> <TAB> <TAB> LOG. info ( ""Number of az's not specified!"" ) <TAB> <TAB> <TAB> LOG. info ( "" - (Defaulting to 1 az)"" ) <TAB> <TAB> <TAB> self. _regex_replace_param_value ( genaz_regex, self. get_available_azs ( 1 ) )",False,numazs,numazs > 0,0.6724315881729126
|
||
|
2635,"def update_clearance_date ( self ) : <TAB> clearance_date_updated = False <TAB> for d in self. get ( ""payment_entries"" ) : <TAB> <TAB> if d. clearance_date : <TAB> <TAB> <TAB> if not d. payment_document : <TAB> <TAB> <TAB> <TAB> frappe. throw ( <TAB> <TAB> <TAB> <TAB> <TAB> _ ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""Row #{0}: Payment document is required to complete the transaction"" <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if d. cheque_date and getdate ( d. clearance_date ) < getdate ( d. cheque_date ) : <TAB> <TAB> <TAB> <TAB> frappe. throw ( <TAB> <TAB> <TAB> <TAB> <TAB> _ ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""Row #{0}: Clearance date {1} cannot be before Cheque Date {2}"" <TAB> <TAB> <TAB> <TAB> <TAB> ). format ( d. idx, d. clearance_date, d. cheque_date ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> if d. clearance_date or self. include_reconciled_entries : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> d. clearance_date = None <TAB> <TAB> <TAB> payment_entry = frappe. get_doc ( d. payment_document, d. payment_entry ) <TAB> <TAB> <TAB> payment_entry. db_set ( ""clearance_date"", d. clearance_date ) <TAB> <TAB> <TAB> clearance_date_updated = True <TAB> if clearance_date_updated : <TAB> <TAB> self. get_payment_entries ( ) <TAB> <TAB> msgprint ( _ ( ""Clearance Date updated"" ) )",False,not d.clearance_date,d.payment_document,0.659864068031311
|
||
|
2636,"def adjust_inputs ( self, context ) : <TAB> mode = self. type_selected_mode <TAB> inputs = self. inputs <TAB> socket_ops = self. soket_opt <TAB> if mode == ""Int"" : <TAB> <TAB> if inputs [ 2 ]. prop_name [ - 1 ] == ""f"" : <TAB> <TAB> <TAB> inputs [ 2 ]. prop_name = ""low_i"" <TAB> <TAB> <TAB> inputs [ 3 ]. prop_name = ""high_i"" <TAB> <TAB> inputs [ ""Weights"" ]. hide_safe = not self. weighted <TAB> <TAB> for i in range ( 0, 3 ) : <TAB> <TAB> <TAB> inputs [ socket_ops [ i ] [ 0 ] ]. hide_safe = True <TAB> elif mode == ""Float"" : <TAB> <TAB> dsm = self. distribute_mode <TAB> <TAB> func = self. func_dict [ dsm ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> inputs [ 2 ]. prop_name = ""low_f"" <TAB> <TAB> <TAB> inputs [ 3 ]. prop_name = ""high_f"" <TAB> <TAB> inputs [ ""Weights"" ]. hide_safe = True <TAB> <TAB> for i in range ( 1, 4 ) : <TAB> <TAB> <TAB> inputs [ socket_ops [ i - 1 ] [ 0 ] ]. hide_safe = i not in func [ 2 ] <TAB> updateNode ( self, context )",False,inputs[2].prop_name[-1] == 'i',inputs[2].prop_name[-1] == 'f',0.6524931788444519
|
||
|
2637,"def monitor_removed ( self, parent, monitor ) : <TAB> for row in self. liststore : <TAB> <TAB> titer = row. iter <TAB> <TAB> ( val, ) = self. liststore. get ( titer, 0 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. liststore. set ( <TAB> <TAB> <TAB> <TAB> titer, <TAB> <TAB> <TAB> <TAB> 1, <TAB> <TAB> <TAB> <TAB> self. get_caption ( monitor. device [ ""Alias"" ], monitor. device [ ""Address"" ] ), <TAB> <TAB> <TAB> <TAB> 2, <TAB> <TAB> <TAB> <TAB> _ ( ""Not Connected"" ), <TAB> <TAB> <TAB> <TAB> 3, <TAB> <TAB> <TAB> <TAB> None, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> return",False,val == monitor.device['Address'],val,0.6529565453529358
|
||
|
2638,"def get_attr_by_data_model ( self, dmodel, exclude_record = False ) : <TAB> if exclude_record : <TAB> <TAB> return list ( <TAB> <TAB> <TAB> filter ( <TAB> <TAB> <TAB> <TAB> lambda x : x. data_model == dmodel and x. value == """" <TAB> <TAB> <TAB> <TAB> if x. attribute!= ""Record"" and hasattr ( x, ""data_model"" ) <TAB> <TAB> <TAB> <TAB> else False, <TAB> <TAB> <TAB> <TAB> self. _inferred_intent, <TAB> <TAB> <TAB> ) <TAB> <TAB> ) <TAB> else : <TAB> <TAB> return list ( <TAB> <TAB> <TAB> filter ( <TAB> <TAB> <TAB> <TAB> lambda x : x. data_model == dmodel and x. value == """" <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> else False, <TAB> <TAB> <TAB> <TAB> self. _inferred_intent, <TAB> <TAB> <TAB> ) <TAB> <TAB> )",False,"hasattr(x, 'data_model')",x.attribute != 'Record',0.6502106189727783
|
||
|
2639,"def _prune_tasks ( self ) : <TAB> assistant_ids = { w. id for w in self. _state. get_assistants ( ) } <TAB> remove_tasks = [ ] <TAB> for task in self. _state. get_active_tasks ( ) : <TAB> <TAB> self. _state. fail_dead_worker_task ( task, self. _config, assistant_ids ) <TAB> <TAB> self. _state. update_status ( task, self. _config ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> logger. info ( ""Removing task %r"", task. id ) <TAB> <TAB> <TAB> remove_tasks. append ( task. id ) <TAB> self. _state. inactivate_tasks ( remove_tasks )",False,self._state.may_prune(task),task.id in self._tasks,0.6544284820556641
|
||
|
2640,"def dnd_end ( self, target, event ) : <TAB> gui. trace ( ""<<DRAGGABLE_WIDGET.dnd_end>> %s target=%s"", self. Name, target ) <TAB> <TAB> if self. Canvas is None : <TAB> <TAB> gui. trace ( ""<<DRAGGABLE_WIDGET.dnd_end>> dropped with Canvas (None)"" ) <TAB> <TAB> if DraggableWidget. discardDragged : <TAB> <TAB> <TAB> gui. trace ( ""<<DRAGGABLE_WIDGET.dnd_end>> DISCARDING under order"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if self. OriginalCanvas is not None : <TAB> <TAB> <TAB> <TAB> gui. trace ( ""<<DRAGGABLE_WIDGET.dnd_end>> RESTORING"" ) <TAB> <TAB> <TAB> <TAB> self. restoreOldData ( ) <TAB> <TAB> <TAB> <TAB> self. Canvas. dnd_enter ( self, event ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> gui. trace ( ""<<DRAGGABLE_WIDGET.dnd_end>> DISCARDING as nowhere to go"" ) <TAB> <TAB> else : <TAB> <TAB> gui. trace ( <TAB> <TAB> <TAB> ""<<DRAGGABLE_WIDGET.dnd_end>> dropped with Canvas(%s) Target=%s"", <TAB> <TAB> <TAB> self. Canvas, <TAB> <TAB> <TAB> self. dropTarget, <TAB> <TAB> ) <TAB> <TAB> if not self. dropTarget : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. Label. bind ( ""<ButtonPress>"", self. press ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. Label. bind ( ""<ButtonPress>"", self. press ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <",False,"self.dropTarget.keepWidget(self.Title, self.Name)",not self.dropTarget,0.6550115346908569
|
||
|
2641,"def handle_code ( code, vk_packet = True ) : <TAB> """"""Handle a key or sequence of keys in braces"""""" <TAB> code_keys = [ ] <TAB> <TAB> if code in CODES : <TAB> <TAB> code_keys. append ( KeyAction ( CODES [ code ] ) ) <TAB> <TAB> elif len ( code ) == 1 : <TAB> <TAB> code_keys. append ( KeyAction ( code ) ) <TAB> <TAB> elif "" "" in code : <TAB> <TAB> to_repeat, count = code. rsplit ( None, 1 ) <TAB> <TAB> if to_repeat == ""PAUSE"" : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> pause_time = float ( count ) <TAB> <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> <TAB> raise KeySequenceError ( ""invalid pause time {}"". format ( count ) ) <TAB> <TAB> <TAB> code_keys. append ( PauseAction ( pause_time ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> count = int ( count ) <TAB> <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> <TAB> raise KeySequenceError ( ""invalid repetition count {}"". format ( count ) ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> code_keys. extend ( [ KeyAction ( CODES [ to_repeat ] ) ] * count ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> to_repeat = parse_keys ( to_repeat ) <TAB> <TAB> <TAB> <TAB> if isinstance ( to_repeat, list ) : <TAB> <TAB> <TAB> <TAB> <TAB> keys = to_repeat * count <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> keys = [ to_repeat",False,to_repeat in CODES,to_repeat != None,0.6647645235061646
|
||
|
2642,"def populate_resource_parameters ( self, tool_source ) : <TAB> root = getattr ( tool_source, ""root"", None ) <TAB> if ( <TAB> <TAB> root is not None <TAB> <TAB> and hasattr ( self. app, ""job_config"" ) <TAB> <TAB> and hasattr ( self. app. job_config, ""get_tool_resource_xml"" ) <TAB> ) : <TAB> <TAB> resource_xml = self. app. job_config. get_tool_resource_xml ( <TAB> <TAB> <TAB> root. get ( ""id"" ), self. tool_type <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> inputs = root. find ( ""inputs"" ) <TAB> <TAB> <TAB> if inputs is None : <TAB> <TAB> <TAB> <TAB> inputs = parse_xml_string ( ""<inputs/>"" ) <TAB> <TAB> <TAB> <TAB> root. append ( inputs ) <TAB> <TAB> <TAB> inputs. append ( resource_xml )",False,resource_xml is not None,root is not None,0.6599102020263672
|
||
|
2643,"def validate_max_discount ( self ) : <TAB> if self. rate_or_discount == ""Discount Percentage"" and self. get ( ""items"" ) : <TAB> <TAB> for d in self. items : <TAB> <TAB> <TAB> max_discount = frappe. get_cached_value ( ""Item"", d. item_code, ""max_discount"" ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> throw ( <TAB> <TAB> <TAB> <TAB> <TAB> _ ( ""Max discount allowed for item: {0} is {1}%"" ). format ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. item_code, max_discount <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> )",False,max_discount and flt(self.discount_percentage) > flt(max_discount),max_discount is not None and max_discount < TAB > 0,0.6499215364456177
|
||
|
2644,"def check_converter_received_device_arg ( self, received_device_arg, device_arg ) : <TAB> new_style = self. converter_style in ( ""decorator"", ""class"" ) <TAB> <TAB> if device_arg is None : <TAB> <TAB> assert received_device_arg is None <TAB> <TAB> return <TAB> <TAB> is_cpu = False <TAB> cuda_device_id = None <TAB> if isinstance ( device_arg, int ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> is_cpu = True <TAB> <TAB> else : <TAB> <TAB> <TAB> cuda_device_id = device_arg <TAB> elif isinstance ( device_arg, _cpu. CpuDevice ) : <TAB> <TAB> is_cpu = True <TAB> elif isinstance ( device_arg, cuda. GpuDevice ) : <TAB> <TAB> cuda_device_id = device_arg. device. id <TAB> else : <TAB> <TAB> assert False <TAB> <TAB> if is_cpu : <TAB> <TAB> if new_style : <TAB> <TAB> <TAB> assert received_device_arg == _cpu. CpuDevice ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> assert received_device_arg == - 1 <TAB> elif cuda_device_id is not None : <TAB> <TAB> if new_style : <TAB> <TAB> <TAB> assert received_device_arg == cuda. GpuDevice. from_device_id ( cuda_device_id ) <TAB> <TAB> else : <TAB> <TAB> <TAB> assert isinstance ( received_device_arg, int ) <TAB> <TAB> <TAB> assert received_device_arg == cuda_device_id <TAB> else : <TAB> <TAB> assert new_style <TAB> <TAB> assert received_device_arg is device_arg",False,device_arg < 0,is_cpu,0.6620326638221741
|
||
|
2645,"def _best_latent ( self ) : <TAB> if self. latent is None : <TAB> <TAB> self. latent = self. gan. session. run ( self. gan. latent. sample ) <TAB> fitness = self. gan. session. run ( self. fitness, { self. gan. latent. sample : self. latent } ) <TAB> zs = self. latent <TAB> sort_zs = None <TAB> last_fitness = 10000 <TAB> count = 0 <TAB> while True : <TAB> <TAB> d = self. gan. session. run ( [ self. fitness, self. gan. latent. sample ] ) <TAB> <TAB> _f = d [ 0 ] <TAB> <TAB> _z = d [ 1 ] <TAB> <TAB> fitness = np. reshape ( fitness, np. shape ( _f ) ) <TAB> <TAB> fitness = np. concatenate ( [ fitness, _f ], axis = 0 ) <TAB> <TAB> zs = np. reshape ( zs, np. shape ( _z ) ) <TAB> <TAB> zs = np. concatenate ( [ zs, _z ], axis = 0 ) <TAB> <TAB> sort = np. argsort ( fitness. flatten ( ) ) [ : self. gan. batch_size ( ) ] <TAB> <TAB> zs = zs [ sort ] <TAB> <TAB> fitness = fitness. flatten ( ) [ sort ] <TAB> <TAB> if fitness. flatten ( ) [ - 1 ] < last_fitness : <TAB> <TAB> <TAB> last_fitness = fitness [ - 1 ] <TAB> <TAB> <TAB> count = 0 <TAB> <TAB> else : <TAB> <TAB> <TAB> count += 1 <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> sort_zs = np. reshape ( zs, np. shape ( _z ) ) <TAB> <TAB> <TAB> <TAB> break <TAB> return sort_zs",False,count > self.config.heuristic,count > last_fitness,0.6530178189277649
|
||
|
2646,"def __get_attribute__ ( self, attr ) : <TAB> """"""Look for default attributes for this node"""""" <TAB> attr_val = self. obj_dict [ ""attributes"" ]. get ( attr, None ) <TAB> if attr_val is None : <TAB> <TAB> <TAB> <TAB> default_node_name = self. obj_dict [ ""type"" ] <TAB> <TAB> <TAB> <TAB> if default_node_name in ( ""subgraph"", ""digraph"", ""cluster"" ) : <TAB> <TAB> <TAB> default_node_name = ""graph"" <TAB> <TAB> g = self. get_parent_graph ( ) <TAB> <TAB> if g is not None : <TAB> <TAB> <TAB> defaults = g. get_node ( default_node_name ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return None <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if not isinstance ( defaults, ( list, tuple ) ) : <TAB> <TAB> <TAB> defaults = [ defaults ] <TAB> <TAB> for default in defaults : <TAB> <TAB> <TAB> attr_val = default. obj_dict [ ""attributes"" ]. get ( attr, None ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return attr_val <TAB> else : <TAB> <TAB> return attr_val <TAB> return None",False,attr_val,attr_val is None,0.6663174629211426
|
||
|
2647,"def validate_or_policy ( namespace ) : <TAB> error_elements = [ ] <TAB> if namespace. properties is None : <TAB> <TAB> error_msg = ( <TAB> <TAB> <TAB> ""Please provide --policy in JSON format or the following arguments: "" <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> error_elements. append ( ""--source-account"" ) <TAB> <TAB> <TAB> <TAB> if namespace. destination_account is None : <TAB> <TAB> <TAB> namespace. destination_account = namespace. account_name <TAB> <TAB> if error_elements : <TAB> <TAB> <TAB> error_msg += "", "". join ( error_elements ) <TAB> <TAB> <TAB> error_msg += "" to initialize Object Replication Policy for storage account."" <TAB> <TAB> <TAB> raise ValueError ( error_msg ) <TAB> else : <TAB> <TAB> if os. path. exists ( namespace. properties ) : <TAB> <TAB> <TAB> or_policy = get_file_json ( namespace. properties ) <TAB> <TAB> else : <TAB> <TAB> <TAB> or_policy = shell_safe_json_parse ( namespace. properties ) <TAB> <TAB> try : <TAB> <TAB> <TAB> namespace. source_account = or_policy [ ""sourceAccount"" ] <TAB> <TAB> except KeyError : <TAB> <TAB> <TAB> namespace. source_account = or_policy [ ""source_account"" ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> error_elements. append ( ""source_account"" ) <TAB> <TAB> try : <TAB> <TAB> <TAB> namespace. destination_account = or_policy [ ""destinationAccount"" ] <TAB> <TAB> except KeyError : <TAB> <TAB> <TAB> namespace. destination_account = or_policy [ ""destination_account"" ] <TAB> <TAB> if ""rules"" not in or_policy. keys ( ) or not or_policy [ ""rules"" ] : <TAB> <TAB> <TAB> error_elements. append ( ""rules"" ) <TAB> <TAB> error",False,namespace.source_account is None,error_elements,0.6595767736434937
|
||
|
2648,"def __handle_blamechunk_content__ ( self, content ) : <TAB> author = None <TAB> ( comments, self. is_inside_comment ) = comment. handle_comment_block ( <TAB> <TAB> self. is_inside_comment, self. extension, content <TAB> ) <TAB> if self. blamechunk_is_prior and interval. get_since ( ) : <TAB> <TAB> return <TAB> try : <TAB> <TAB> author = self. changes. get_latest_author_by_email ( self. blamechunk_email ) <TAB> except KeyError : <TAB> <TAB> return <TAB> if ( <TAB> <TAB> not filtering. set_filtered ( author, ""author"" ) <TAB> <TAB> and not filtering. set_filtered ( self. blamechunk_email, ""email"" ) <TAB> <TAB> and not filtering. set_filtered ( self. blamechunk_revision, ""revision"" ) <TAB> ) : <TAB> <TAB> __blame_lock__. acquire ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. blames [ ( author, self. filename ) ] = BlameEntry ( ) <TAB> <TAB> self. blames [ ( author, self. filename ) ]. comments += comments <TAB> <TAB> self. blames [ ( author, self. filename ) ]. rows += 1 <TAB> <TAB> if ( self. blamechunk_time - self. changes. first_commit_date ). days > 0 : <TAB> <TAB> <TAB> self. blames [ ( author, self. filename ) ]. skew += ( <TAB> <TAB> <TAB> <TAB> self. changes. last_commit_date - self. blamechunk_time <TAB> <TAB> <TAB> ). days / ( 7.0 if self. useweeks else AVG_DAYS_PER_MONTH ) <TAB> <TAB> __blame_lock__. release ( )",False,"self.blames.get((author, self.filename), None) == None",self.blamechunk_time is None,0.6585873365402222
|
||
|
2649,"def normalized_version_match ( rawsemver, rawpkgver, language = ""python"" ) : <TAB> versionmatch = False <TAB> vranges = re. split ( r"" *\|\| *"", rawsemver ) <TAB> <TAB> inrange = False <TAB> for vrange in vranges : <TAB> <TAB> vrange = vrange. strip ( ) <TAB> <TAB> if vrange in [ ""*"", ""all"" ] : <TAB> <TAB> <TAB> inrange = True <TAB> <TAB> <TAB> break <TAB> <TAB> tokre = re. compile ( r""[!|<|>|=|~|^]+\s*[^\s]+"" ) <TAB> <TAB> rangechecks = tokre. findall ( vrange ) <TAB> <TAB> <TAB> <TAB> violation = False <TAB> <TAB> if not rangechecks : <TAB> <TAB> <TAB> raise Exception ( ""invalid range detected - {}"". format ( vrange ) ) <TAB> <TAB> for rangecheck in rangechecks : <TAB> <TAB> <TAB> rangecheck = re. sub ( r""\s+"", """", rangecheck ) <TAB> <TAB> <TAB> patt = re. match ( ""([!|<|>|=|~|^]+)(.*)"", rangecheck ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> op, verraw = ( patt. group ( 1 ), patt. group ( 2 ) ) <TAB> <TAB> <TAB> <TAB> inrange = language_compare ( rawpkgver, op, verraw, language = language ) <TAB> <TAB> <TAB> <TAB> if not inrange : <TAB> <TAB> <TAB> <TAB> <TAB> violation = True <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> if not violation : <TAB> <TAB> <TAB> inrange = True <TAB> <TAB> <TAB> break <TAB> if inrange : <TAB> <TAB> versionmatch = True <TAB> return versionmatch",True,patt,patt,0.6876529455184937
|
||
|
2650,"def cleanup_from_JSON_dict_filename ( cls, filename ) : <TAB> try : <TAB> <TAB> with open ( filename ) as fh : <TAB> <TAB> <TAB> for value in json. load ( fh ). values ( ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> value = cls. from_JSON ( value ) <TAB> <TAB> <TAB> <TAB> if isinstance ( value, cls ) and os. path. exists ( value. file_name ) : <TAB> <TAB> <TAB> <TAB> <TAB> log. debug ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""Cleaning up abandoned MetadataTempFile file: %s"", <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> value. file_name, <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> os. unlink ( value. file_name ) <TAB> except Exception as e : <TAB> <TAB> log. debug ( <TAB> <TAB> <TAB> ""Failed to cleanup MetadataTempFile temp files from %s: %s"", <TAB> <TAB> <TAB> filename, <TAB> <TAB> <TAB> unicodify ( e ), <TAB> <TAB> )",False,cls.is_JSONified_value(value),"isinstance(value, dict)",0.6504443883895874
|
||
|
2651,"def ticket_edit ( request, ticket_id, response_format = ""html"" ) : <TAB> ""Ticket edit"" <TAB> context = _get_default_context ( request ) <TAB> agent = context [ ""agent"" ] <TAB> ticket = get_object_or_404 ( Ticket, pk = ticket_id ) <TAB> if not request. user. profile. has_permission ( ticket, mode = ""w"" ) : <TAB> <TAB> return user_denied ( request, message = ""You don't have access to this Ticket"" ) <TAB> if request. POST : <TAB> <TAB> if ""cancel"" not in request. POST : <TAB> <TAB> <TAB> form = TicketForm ( <TAB> <TAB> <TAB> <TAB> request. user. profile, None, agent, request. POST, instance = ticket <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> ticket = form. save ( ) <TAB> <TAB> <TAB> <TAB> return HttpResponseRedirect ( <TAB> <TAB> <TAB> <TAB> <TAB> reverse ( ""services_ticket_view"", args = [ ticket. id ] ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return HttpResponseRedirect ( <TAB> <TAB> <TAB> <TAB> reverse ( ""services_ticket_view"", args = [ ticket. id ] ) <TAB> <TAB> <TAB> ) <TAB> else : <TAB> <TAB> form = TicketForm ( request. user. profile, None, agent, instance = ticket ) <TAB> context. update ( { ""form"" : form, ""ticket"" : ticket } ) <TAB> return render_to_response ( <TAB> <TAB> ""services/ticket_edit"", <TAB> <TAB> context, <TAB> <TAB> context_instance = RequestContext ( request ), <TAB> <TAB> response_format = response_format, <TAB> )",True,form.is_valid(),form.is_valid(),0.6491214036941528
|
||
|
2652,"def _validated_matches ( self, rules : yara. Rules ) -> [ ] : <TAB> try : <TAB> <TAB> return rules. match ( self. filepath ) <TAB> except yara. Error as e : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> _, code = str ( e ). split ( "":"" ) <TAB> <TAB> <TAB> if int ( code. strip ( ) ) == 30 : <TAB> <TAB> <TAB> <TAB> message = f""Too many matches for {self.filename}"" <TAB> <TAB> <TAB> <TAB> self. result. append ( { ""match"" : message } ) <TAB> <TAB> <TAB> <TAB> logger. warning ( message ) <TAB> <TAB> <TAB> <TAB> return [ ] <TAB> <TAB> raise e",False,'internal error' in str(e),e.args[0] in [e.args[1],0.6560137271881104
|
||
|
2653,"def to_nurbs ( self, curves ) : <TAB> result = [ ] <TAB> for i, c in enumerate ( curves ) : <TAB> <TAB> nurbs = SvNurbsCurve. to_nurbs ( c ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise Exception ( f""Curve #{i} - {c} - can not be converted to NURBS!"" ) <TAB> <TAB> result. append ( nurbs ) <TAB> return result",False,nurbs is None,not nurbs,0.6711665391921997
|
||
|
2654,"def ajax_compat_update ( request, addon_id, addon, version_id ) : <TAB> if not addon. accepts_compatible_apps ( ) : <TAB> <TAB> raise http. Http404 ( ) <TAB> version = get_object_or_404 ( addon. versions. all ( ), pk = version_id ) <TAB> compat_form = forms. CompatFormSet ( <TAB> <TAB> request. POST or None, <TAB> <TAB> queryset = version. apps. all ( ). select_related ( ""min"", ""max"" ), <TAB> <TAB> form_kwargs = { ""version"" : version }, <TAB> ) <TAB> if request. method == ""POST"" and compat_form. is_valid ( ) : <TAB> <TAB> for compat in compat_form. save ( commit = False ) : <TAB> <TAB> <TAB> compat. version = version <TAB> <TAB> <TAB> compat. save ( ) <TAB> <TAB> for compat in compat_form. deleted_objects : <TAB> <TAB> <TAB> compat. delete ( ) <TAB> <TAB> for form in compat_form. forms : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> _log_max_version_change ( addon, version, form. instance ) <TAB> return render ( <TAB> <TAB> request, <TAB> <TAB> ""devhub/addons/ajax_compat_update.html"", <TAB> <TAB> dict ( addon = addon, version = version, compat_form = compat_form ), <TAB> )",False,"isinstance(form, forms.CompatForm) and 'max' in form.changed_data",form.is_valid(),0.6470600962638855
|
||
|
2655,"def get_doc_object ( obj, what = None ) : <TAB> if what is None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> what = ""class"" <TAB> <TAB> elif inspect. ismodule ( obj ) : <TAB> <TAB> <TAB> what = ""module"" <TAB> <TAB> elif callable ( obj ) : <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 ) <TAB> elif what in ( ""function"", ""method"" ) : <TAB> <TAB> return SphinxFunctionDoc ( obj, """" ) <TAB> else : <TAB> <TAB> return SphinxDocString ( pydoc. getdoc ( obj ) )",False,inspect.isclass(obj),"isinstance(obj, basestring)",0.6557371616363525
|
||
|
2656,"def check_context_processors ( output ) : <TAB> with output. section ( ""Context processors"" ) as section : <TAB> <TAB> processors = list ( <TAB> <TAB> <TAB> chain ( <TAB> <TAB> <TAB> <TAB> * [ <TAB> <TAB> <TAB> <TAB> <TAB> template [ ""OPTIONS"" ]. get ( ""context_processors"", [ ] ) <TAB> <TAB> <TAB> <TAB> <TAB> for template in settings. TEMPLATES <TAB> <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> ) <TAB> <TAB> ) <TAB> <TAB> required_processors = ( ""cms.context_processors.cms_settings"", ) <TAB> <TAB> for processor in required_processors : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> section. error ( <TAB> <TAB> <TAB> <TAB> <TAB> ""%s context processor must be in TEMPLATES option context_processors"" <TAB> <TAB> <TAB> <TAB> <TAB> % processor <TAB> <TAB> <TAB> <TAB> )",False,processor not in processors,processor not in section.context_processors,0.6849406361579895
|
||
|
2657,"def to_string ( self, indent : int ) -> str : <TAB> res = [ Symbol. debug_indent_string * indent ] <TAB> if not self. parent : <TAB> <TAB> res. append ( ""::"" ) <TAB> else : <TAB> <TAB> if self. templateParams : <TAB> <TAB> <TAB> res. append ( str ( self. templateParams ) ) <TAB> <TAB> <TAB> res. append ( ""\n"" ) <TAB> <TAB> <TAB> res. append ( Symbol. debug_indent_string * indent ) <TAB> <TAB> if self. identOrOp : <TAB> <TAB> <TAB> res. append ( str ( self. identOrOp ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> res. append ( str ( self. declaration ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> res. append ( str ( self. templateArgs ) ) <TAB> <TAB> if self. declaration : <TAB> <TAB> <TAB> res. append ( "": "" ) <TAB> <TAB> <TAB> if self. isRedeclaration : <TAB> <TAB> <TAB> <TAB> res. append ( ""!!duplicate!! "" ) <TAB> <TAB> <TAB> res. append ( str ( self. declaration ) ) <TAB> if self. docname : <TAB> <TAB> res. append ( ""\t("" ) <TAB> <TAB> res. append ( self. docname ) <TAB> <TAB> res. append ( "")"" ) <TAB> res. append ( ""\n"" ) <TAB> return """". join ( res )",True,self.templateArgs,self.templateArgs,0.672903299331665
|
||
|
2658,"def log ( args, kwargs ) : <TAB> """"""Log to a file."""""" <TAB> logfile = os. path. join ( args. logdir, ""log.tsv"" ) <TAB> if ""log_created"" not in globals ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> logging. error ( ""Logfile %s already exists."", logfile ) <TAB> <TAB> <TAB> sys. exit ( 1 ) <TAB> <TAB> global log_created <TAB> <TAB> log_created = sorted ( kwargs. keys ( ) ) <TAB> <TAB> header = ""\t"". join ( ( str ( k ) for k in log_created ) ) + ""\n"" <TAB> <TAB> with open ( logfile, ""w"" ) as f : <TAB> <TAB> <TAB> f. write ( header ) <TAB> <TAB> assert log_created == sorted ( kwargs. keys ( ) ) <TAB> with open ( logfile, ""a"" ) as f : <TAB> <TAB> f. write ( ""\t"". join ( ( str ( kwargs [ k ] ) for k in log_created ) ) + ""\n"" )",True,os.path.exists(logfile),os.path.exists(logfile),0.6494218111038208
|
||
|
2659,"def ShowTooltip ( self ) : <TAB> """"""Shows the tooltip on the tab."""""" <TAB> wnd = self. GetPointedToTab ( ) <TAB> if wnd!= self. _tooltip_wnd : <TAB> <TAB> self. RestartTooltipTimer ( wnd ) <TAB> else : <TAB> <TAB> idx = self. GetIdxFromWindow ( wnd ) <TAB> <TAB> if idx >= 0 and idx < len ( self. _pages ) : <TAB> <TAB> <TAB> page = self. _pages [ idx ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> pos = self. ClientToScreen ( page. rect. GetPosition ( ) ) <TAB> <TAB> <TAB> <TAB> rect = wx. Rect ( pos, page. rect. GetSize ( ) ) <TAB> <TAB> <TAB> <TAB> tooltip = wx. TipWindow ( self, page. tooltip ) <TAB> <TAB> <TAB> <TAB> tooltip. SetBoundingRect ( rect ) <TAB> <TAB> else : <TAB> <TAB> <TAB> pos = self. ScreenToClient ( wx. GetMousePosition ( ) ) <TAB> <TAB> <TAB> button = self. ButtonHitTest ( pos. x, pos. y ) <TAB> <TAB> <TAB> if button : <TAB> <TAB> <TAB> <TAB> pos = self. ClientToScreen ( button. rect. GetPosition ( ) ) <TAB> <TAB> <TAB> <TAB> rect = wx. Rect ( pos, button. rect. GetSize ( ) ) <TAB> <TAB> <TAB> <TAB> tooltip = wx. TipWindow ( self, button. name ) <TAB> <TAB> <TAB> <TAB> tooltip. SetBoundingRect ( rect )",False,page.tooltip,page,0.679940938949585
|
||
|
2660,"def upgrade ( ) : <TAB> <TAB> conn = op. get_bind ( ) <TAB> session = orm. Session ( bind = conn ) <TAB> results = conn. execute ( ""select * from dispatch_user"" ). fetchall ( ) <TAB> op. drop_table ( ""dispatch_user"" ) <TAB> op. create_table ( <TAB> <TAB> ""dispatch_user"", <TAB> <TAB> sa. Column ( ""id"", sa. Integer ( ), nullable = False ), <TAB> <TAB> sa. Column ( ""email"", sa. String ( ), nullable = False ), <TAB> <TAB> sa. Column ( ""password"", sa. Binary ( ), nullable = False ), <TAB> <TAB> sa. Column ( ""role"", sa. String ( ), nullable = False ), <TAB> <TAB> sa. Column ( ""created_at"", sa. DateTime ( ), nullable = True ), <TAB> <TAB> sa. Column ( ""updated_at"", sa. DateTime ( ), nullable = True ), <TAB> <TAB> sa. PrimaryKeyConstraint ( ""id"" ), <TAB> ) <TAB> for r in results : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> session. add ( DispatchUser ( email = r [ 0 ], password = r [ 1 ], role = r [ 4 ] ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> session. add ( DispatchUser ( email = r [ 0 ], password = r [ 1 ] ) ) <TAB> session. commit ( )",False,len(r) == 5,nullable,0.6537355184555054
|
||
|
2661,"def queue_view ( request, queue_id, response_format = ""html"" ) : <TAB> ""Queue view"" <TAB> queue = get_object_or_404 ( TicketQueue, pk = queue_id ) <TAB> if not request. user. profile. has_permission ( queue ) : <TAB> <TAB> return user_denied ( request, message = ""You don't have access to this Queue"" ) <TAB> query = Q ( queue = queue ) <TAB> if request. GET : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> query = query & _get_filter_query ( request. GET ) <TAB> <TAB> else : <TAB> <TAB> <TAB> query = query & Q ( status__hidden = False ) & _get_filter_query ( request. GET ) <TAB> else : <TAB> <TAB> query = query & Q ( status__hidden = False ) <TAB> tickets = Object. filter_by_request ( request, Ticket. objects. filter ( query ) ) <TAB> filters = FilterForm ( request. user. profile, ""queue"", request. GET ) <TAB> subqueues = Object. filter_by_request ( <TAB> <TAB> request, TicketQueue. objects. filter ( parent = queue ) <TAB> ) <TAB> context = _get_default_context ( request ) <TAB> context. update ( <TAB> <TAB> { ""queue"" : queue, ""subqueues"" : subqueues, ""filters"" : filters, ""tickets"" : tickets } <TAB> ) <TAB> return render_to_response ( <TAB> <TAB> ""services/queue_view"", <TAB> <TAB> context, <TAB> <TAB> context_instance = RequestContext ( request ), <TAB> <TAB> response_format = response_format, <TAB> )",False,'status' in request.GET and request.GET['status'],settings.DEBUG,0.6543593406677246
|
||
|
2662,"def autoload ( self ) : <TAB> if self. _app. config. THEME == ""auto"" : <TAB> <TAB> if sys. platform == ""darwin"" : <TAB> <TAB> <TAB> if get_osx_theme ( ) == 1 : <TAB> <TAB> <TAB> <TAB> theme = DARK <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> theme = LIGHT <TAB> <TAB> else : <TAB> <TAB> <TAB> theme = self. guess_system_theme ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> theme = MacOSDark <TAB> else : <TAB> <TAB> theme = self. _app. config. THEME <TAB> self. load_theme ( theme )",False,theme == Dark,theme == 'MacOSDark',0.6781291365623474
|
||
|
2663,"def _parse_description ( self, text : str ) : <TAB> result = dict ( links = [ ], versions = [ ] ) <TAB> for line in text. splitlines ( ) : <TAB> <TAB> clean = REX_TAG. sub ( """", line. strip ( ) ) <TAB> <TAB> if clean. startswith ( ""Severity:"" ) : <TAB> <TAB> <TAB> result [ ""severity"" ] = clean. split ( ) [ 1 ] <TAB> <TAB> <TAB> continue <TAB> <TAB> if clean. startswith ( ""Affects:"" ) : <TAB> <TAB> <TAB> result [ ""name"" ] = clean. split ( ) [ 1 ] <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> result [ ""versions"" ] = self. _get_versions ( clean ) <TAB> <TAB> result [ ""links"" ]. extend ( REX_LINK. findall ( line ) ) <TAB> return result",False,' or higher' in clean,clean,0.6638774871826172
|
||
|
2664,"def _make_gz ( args ) : <TAB> try : <TAB> <TAB> columns, from_file, to_file, sep = args <TAB> <TAB> if os. path. exists ( to_file ) : <TAB> <TAB> <TAB> return <TAB> <TAB> with open ( from_file, ""rb"" ) as fin, gzip. open ( to_file, ""wb"" ) as fout : <TAB> <TAB> <TAB> log. debug ( ""making gz %s => %s"" % ( from_file, to_file ) ) <TAB> <TAB> <TAB> for i, line in enumerate ( fin ) : <TAB> <TAB> <TAB> <TAB> line = line. strip ( b""\n"" ). split ( sep ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> log. error ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""columns not match at %s, got %d, expect %d"" <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> % ( from_file, len ( line ), len ( columns ) ) <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> features = { } <TAB> <TAB> <TAB> <TAB> for l, c in zip ( line, columns ) : <TAB> <TAB> <TAB> <TAB> <TAB> features [ c. name ] = c. raw_to_proto ( l ) <TAB> <TAB> <TAB> <TAB> example = example_pb2. Example ( <TAB> <TAB> <TAB> <TAB> <TAB> features = feature_pb2. Features ( feature = features ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> serialized = example. SerializeToString ( ) <TAB> <TAB> <TAB> <TAB> l = len ( serialized ) <TAB> <",True,len(line) != len(columns),len(line) != len(columns),0.6542791128158569
|
||
|
2665,"def iterator ( self ) : <TAB> self. _epoch += 1 <TAB> self. _pos = 0 <TAB> files = copy. deepcopy ( self. file_list ) <TAB> if self. shuffle : <TAB> <TAB> random. shuffle ( files ) <TAB> files = files [ : self. num_samples ] <TAB> self. num_samples = len ( files ) <TAB> for f in files : <TAB> <TAB> records = f [ 1 ] <TAB> <TAB> im_info = copy. deepcopy ( records [ 0 ] ) <TAB> <TAB> label_info = copy. deepcopy ( records [ 1 ] ) <TAB> <TAB> im_info [ ""epoch"" ] = self. _epoch <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> mix_idx = random. randint ( 1, self. num_samples - 1 ) <TAB> <TAB> <TAB> mix_pos = ( mix_idx + self. _pos ) % self. num_samples <TAB> <TAB> else : <TAB> <TAB> <TAB> mix_pos = 0 <TAB> <TAB> im_info [ ""mixup"" ] = [ <TAB> <TAB> <TAB> files [ mix_pos ] [ 0 ], <TAB> <TAB> <TAB> copy. deepcopy ( files [ mix_pos ] [ 1 ] [ 0 ] ), <TAB> <TAB> <TAB> copy. deepcopy ( files [ mix_pos ] [ 1 ] [ 1 ] ), <TAB> <TAB> ] <TAB> <TAB> self. _pos += 1 <TAB> <TAB> sample = [ f [ 0 ], im_info, label_info ] <TAB> <TAB> yield sample",False,self.num_samples > 1,self.num_samples > 0,0.6548209190368652
|
||
|
2666,"def listen_for_order_book_diffs ( <TAB> self, ev_loop : asyncio. BaseEventLoop, output : asyncio. Queue ) : <TAB> while True : <TAB> <TAB> try : <TAB> <TAB> <TAB> trading_pairs : List [ str ] = self. _trading_pairs <TAB> <TAB> <TAB> async with websockets. connect ( WS_URL ) as ws : <TAB> <TAB> <TAB> <TAB> ws : websockets. WebSocketClientProtocol = ws <TAB> <TAB> <TAB> <TAB> for trading_pair in trading_pairs : <TAB> <TAB> <TAB> <TAB> <TAB> request : Dict [ str, str ] = { <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""type"" : ""SUBSCRIBE"", <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""topic"" : ""BOOK"", <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""market"" : trading_pair, <TAB> <TAB> <TAB> <TAB> <TAB> } <TAB> <TAB> <TAB> <TAB> <TAB> await ws. send ( ujson. dumps ( request ) ) <TAB> <TAB> <TAB> <TAB> async for raw_msg in self. _inner_messages ( ws ) : <TAB> <TAB> <TAB> <TAB> <TAB> msg = ujson. loads ( raw_msg ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> diff_msg : RadarRelayOrderBookMessage = ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> RadarRelayOrderBook. diff_message_from_exchange ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> msg, time. time ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB",False,'action' in msg,self.has_diff_message,0.6705566048622131
|
||
|
2667,"def create ( self ) : <TAB> """"""Create a backup in /tmp"""""" <TAB> if not is_safe_to_remove ( self. repository. content. path. local ) : <TAB> <TAB> return <TAB> if os. path. exists ( self. backup_path ) : <TAB> <TAB> shutil. rmtree ( self. backup_path ) <TAB> <TAB> while os. path. exists ( self. backup_path ) : <TAB> <TAB> <TAB> sleep ( 0.1 ) <TAB> os. makedirs ( self. backup_path, exist_ok = True ) <TAB> for filename in os. listdir ( self. repository. content. path. local ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> source_file_name = f""{self.repository.content.path.local}/{filename}"" <TAB> <TAB> <TAB> target_file_name = f""{self.backup_path}/{filename}"" <TAB> <TAB> <TAB> shutil. copyfile ( source_file_name, target_file_name )",False,filename.endswith('.yaml'),filename,0.6462347507476807
|
||
|
2668,"def wait ( self, timeout = None ) : <TAB> if self. returncode is None : <TAB> <TAB> if timeout is not None : <TAB> <TAB> <TAB> from multiprocessing. connection import wait <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return None <TAB> <TAB> <TAB> <TAB> return self. poll ( os. WNOHANG if timeout == 0.0 else 0 ) <TAB> return self. returncode",False,"not wait([self.sentinel], timeout)",wait.is_set(),0.6539663076400757
|
||
|
2669,"def has_hash_of ( self, destpath, code, package_level ) : <TAB> """"""Determine if a file has the hash of the code."""""" <TAB> if destpath is not None and os. path. isfile ( destpath ) : <TAB> <TAB> with univ_open ( destpath, ""r"" ) as opened : <TAB> <TAB> <TAB> compiled = readfile ( opened ) <TAB> <TAB> hashash = gethash ( compiled ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return True <TAB> return False",False,"hashash is not None and hashash == self.comp.genhash(code, package_level)",hashash == code,0.6459992527961731
|
||
|
2670,"def create ( self, defn, check, allow_reboot, allow_recreate ) : <TAB> self. no_subscription_id_change ( defn ) <TAB> self. no_location_change ( defn ) <TAB> self. no_property_change ( defn, ""resource_group"" ) <TAB> self. copy_mgmt_credentials ( defn ) <TAB> self. gateway_name = defn. gateway_name <TAB> self. resource_group = defn. resource_group <TAB> if check : <TAB> <TAB> gateway = self. get_settled_resource ( ) <TAB> <TAB> if not gateway : <TAB> <TAB> <TAB> self. warn_missing_resource ( ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> self. warn_if_failed ( gateway ) <TAB> <TAB> <TAB> self. handle_changed_property ( <TAB> <TAB> <TAB> <TAB> ""location"", normalize_location ( gateway. location ), can_fix = False <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> self. handle_changed_property ( ""tags"", gateway. tags ) <TAB> <TAB> <TAB> self. handle_changed_property ( <TAB> <TAB> <TAB> <TAB> ""address_space"", <TAB> <TAB> <TAB> <TAB> gateway. local_network_site_address_space <TAB> <TAB> <TAB> <TAB> and gateway. local_network_site_address_space. address_prefixes, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> self. handle_changed_property ( ""ip_address"", gateway. gateway_ip_address ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. warn_not_supposed_to_exist ( ) <TAB> <TAB> <TAB> self. confirm_destroy ( ) <TAB> if self. state!= self. UP : <TAB> <TAB> if self. get_settled_resource ( ) : <TAB> <TAB> <TAB> raise Exception ( <TAB> <TAB> <TAB> <TAB> ""tr",False,self.state == self.UP,gateway.has_failed,0.6611250638961792
|
||
|
2671,"def __init__ ( self, data, prefix = ""picard"", suffix = """" ) : <TAB> self. _filename = None <TAB> _datafile_mutex. lock ( ) <TAB> try : <TAB> <TAB> m = md5 ( ) <TAB> <TAB> m. update ( data ) <TAB> <TAB> self. _hash = m. hexdigest ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> ( fd, self. _filename ) = tempfile. mkstemp ( prefix = prefix, suffix = suffix ) <TAB> <TAB> <TAB> QObject. tagger. register_cleanup ( self. delete_file ) <TAB> <TAB> <TAB> with os. fdopen ( fd, ""wb"" ) as imagefile : <TAB> <TAB> <TAB> <TAB> imagefile. write ( data ) <TAB> <TAB> <TAB> _datafiles [ self. _hash ] = self. _filename <TAB> <TAB> <TAB> log. debug ( ""Saving image data %s to %r"" % ( self. _hash, self. _filename ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. _filename = _datafiles [ self. _hash ] <TAB> finally : <TAB> <TAB> _datafile_mutex. unlock ( )",False,self._hash not in _datafiles,not self._filename,0.656760036945343
|
||
|
2672,"def _NewSearchResults ( self, response, cursor ) : <TAB> """"""Returns a SearchResults populated from a search_service response pb."""""" <TAB> results = [ ] <TAB> for result_pb in response. result_list ( ) : <TAB> <TAB> per_result_cursor = None <TAB> <TAB> if result_pb. has_cursor ( ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> per_result_cursor = Cursor ( <TAB> <TAB> <TAB> <TAB> <TAB> web_safe_string = _ToWebSafeString ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> cursor. per_result, _DecodeUTF8 ( result_pb. cursor ( ) ) <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> results. append ( <TAB> <TAB> <TAB> self. _NewScoredDocumentFromPb ( <TAB> <TAB> <TAB> <TAB> result_pb. document ( ), <TAB> <TAB> <TAB> <TAB> result_pb. score_list ( ), <TAB> <TAB> <TAB> <TAB> result_pb. expression_list ( ), <TAB> <TAB> <TAB> <TAB> per_result_cursor, <TAB> <TAB> <TAB> ) <TAB> <TAB> ) <TAB> results_cursor = None <TAB> if response. has_cursor ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> results_cursor = Cursor ( <TAB> <TAB> <TAB> <TAB> web_safe_string = _ToWebSafeString ( <TAB> <TAB> <TAB> <TAB> <TAB> cursor. per_result, _DecodeUTF8 ( response. cursor ( ) ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> return SearchResults ( <TAB> <TAB> results = results, number_found = response. matched_count ( ), cursor = results_cursor <TAB> )",False,"isinstance(cursor, Cursor)",cursor is None,0.6577832698822021
|
||
|
2673,"def generate ( self ) : <TAB> inpath = self. keypath. get ( ) <TAB> self. status [ ""text"" ] = ""Getting key..."" <TAB> try : <TAB> <TAB> keys = get_serials ( inpath ) <TAB> <TAB> keycount = 0 <TAB> <TAB> for key in keys : <TAB> <TAB> <TAB> while True : <TAB> <TAB> <TAB> <TAB> keycount += 1 <TAB> <TAB> <TAB> <TAB> outfile = os. path. join ( progpath, ""kindlekey{0:d}.k4a"". format ( keycount ) ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> with open ( outfile, ""w"" ) as keyfileout : <TAB> <TAB> <TAB> <TAB> keyfileout. write ( key ) <TAB> <TAB> <TAB> success = True <TAB> <TAB> <TAB> tkinter. messagebox. showinfo ( <TAB> <TAB> <TAB> <TAB> progname, ""Key successfully retrieved to {0}"". format ( outfile ) <TAB> <TAB> <TAB> ) <TAB> except Exception as e : <TAB> <TAB> self. status [ ""text"" ] = ""Error: {0}"". format ( e. args [ 0 ] ) <TAB> <TAB> return <TAB> self. status [ ""text"" ] = ""Select backup.ab file""",False,not os.path.exists(outfile),not outfile,0.6474169492721558
|
||
|
2674,"def get_eval_matcher ( self ) : <TAB> if isinstance ( self. data [ ""match"" ], str ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> values = [ ""explicitDeny"", ""implicitDeny"" ] <TAB> <TAB> else : <TAB> <TAB> <TAB> values = [ ""allowed"" ] <TAB> <TAB> vf = ValueFilter ( <TAB> <TAB> <TAB> { ""type"" : ""value"", ""key"" : ""EvalDecision"", ""value"" : values, ""op"" : ""in"" } <TAB> <TAB> ) <TAB> else : <TAB> <TAB> vf = ValueFilter ( self. data [ ""match"" ] ) <TAB> vf. annotate = False <TAB> return vf",False,self.data['match'] == 'denied',self.data['match'] is None or self.data['match'] is None or self.data['match'][0] == 'explicitDeny',0.6551796197891235
|
||
|
2675,"def wrapper ( evaluator, obj, arguments ) : <TAB> debug. dbg ( ""builtin start %s"" % obj, color = ""MAGENTA"" ) <TAB> try : <TAB> <TAB> lst = list ( arguments. eval_argument_clinic ( clinic_args ) ) <TAB> except ValueError : <TAB> <TAB> return set ( ) <TAB> else : <TAB> <TAB> kwargs = { } <TAB> <TAB> if want_context : <TAB> <TAB> <TAB> kwargs [ ""context"" ] = arguments. context <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> kwargs [ ""obj"" ] = obj <TAB> <TAB> if want_arguments : <TAB> <TAB> <TAB> kwargs [ ""arguments"" ] = arguments <TAB> <TAB> return func ( evaluator, * lst, ** kwargs ) <TAB> finally : <TAB> <TAB> debug. dbg ( ""builtin end"", color = ""MAGENTA"" )",True,want_obj,want_obj,0.6667706370353699
|
||
|
2676,"def _column_keys ( self ) : <TAB> """"""Get a dictionary of all columns and their case mapping."""""" <TAB> if not self. exists : <TAB> <TAB> return { } <TAB> with self. db. lock : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> table = self. table <TAB> <TAB> <TAB> self. _columns = { } <TAB> <TAB> <TAB> for column in table. columns : <TAB> <TAB> <TAB> <TAB> name = normalize_column_name ( column. name ) <TAB> <TAB> <TAB> <TAB> key = normalize_column_key ( name ) <TAB> <TAB> <TAB> <TAB> if key in self. _columns : <TAB> <TAB> <TAB> <TAB> <TAB> log. warning ( ""Duplicate column: %s"", name ) <TAB> <TAB> <TAB> <TAB> self. _columns [ key ] = name <TAB> <TAB> return self. _columns",False,self._columns is None,self.has_column,0.6667230129241943
|
||
|
2677,"def handle_starttag ( self, tag, attrs ) : <TAB> if tag. lower ( ) == ""script"" : <TAB> <TAB> _type = ""js_script"" <TAB> <TAB> src = None <TAB> <TAB> for key, value in attrs : <TAB> <TAB> <TAB> if key == ""type"" and value in ( ""text/python"", ""text/python3"" ) : <TAB> <TAB> <TAB> <TAB> _type = ""py_script"" <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> src = value <TAB> <TAB> if _type == ""py_script"" and src : <TAB> <TAB> <TAB> _type = ""py_script_with_src"" <TAB> <TAB> <TAB> path = os. path. join ( self. dirname, src ) <TAB> <TAB> <TAB> with open ( path, encoding = ""utf-8"" ) as fobj : <TAB> <TAB> <TAB> <TAB> self. scripts. append ( fobj. read ( ) ) <TAB> <TAB> self. tag_stack. append ( _type )",True,key == 'src',key == 'src',0.6624555587768555
|
||
|
2678,"def _refresh_watermarked_events ( self ) : <TAB> self. _watermarked_events. clear ( ) <TAB> timestamps = [ x. timestamp for x in self. _conversation. events ] <TAB> for user_id in self. _conversation. watermarks : <TAB> <TAB> user = self. _conversation. get_user ( user_id ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> timestamp = self. _conversation. watermarks [ user_id ] <TAB> <TAB> if timestamp < timestamps [ 0 ] : <TAB> <TAB> <TAB> continue <TAB> <TAB> event_idx = ConversationEventListWalker. _find_watermark_event ( <TAB> <TAB> <TAB> timestamps, timestamp <TAB> <TAB> ) <TAB> <TAB> if event_idx >= 0 : <TAB> <TAB> <TAB> event_pos = self. _conversation. events [ event_idx ]. id_ <TAB> <TAB> <TAB> if event_pos not in self. _watermarked_events : <TAB> <TAB> <TAB> <TAB> self. _watermarked_events [ event_pos ] = set ( ) <TAB> <TAB> <TAB> self. _watermarked_events [ event_pos ]. add ( user )",False,user.is_self,len(self._conversation.watermarks) == 0,0.6557863354682922
|
||
|
2679,"def startFileTransfer ( <TAB> self, path, localFilename, remoteFilename, special = False, tags = None ) : <TAB> if not self. isOperational ( ) or self. isBusy ( ) : <TAB> <TAB> self. _logger. info ( ""Printer is not operational or busy"" ) <TAB> <TAB> return <TAB> if tags is None : <TAB> <TAB> tags = set ( ) <TAB> with self. _jobLock : <TAB> <TAB> self. resetLineNumbers ( tags = { ""trigger:comm.start_file_transfer"" } ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _currentFile = SpecialStreamingGcodeFileInformation ( <TAB> <TAB> <TAB> <TAB> path, localFilename, remoteFilename <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. _currentFile = StreamingGcodeFileInformation ( <TAB> <TAB> <TAB> <TAB> path, localFilename, remoteFilename <TAB> <TAB> <TAB> ) <TAB> <TAB> self. _currentFile. start ( ) <TAB> <TAB> self. sendCommand ( <TAB> <TAB> <TAB> ""M28 %s"" % remoteFilename, <TAB> <TAB> <TAB> tags = tags <TAB> <TAB> <TAB> | { <TAB> <TAB> <TAB> <TAB> ""trigger:comm.start_file_transfer"", <TAB> <TAB> <TAB> }, <TAB> <TAB> ) <TAB> <TAB> self. _callback. on_comm_file_transfer_started ( <TAB> <TAB> <TAB> localFilename, <TAB> <TAB> <TAB> remoteFilename, <TAB> <TAB> <TAB> self. _currentFile. getFilesize ( ), <TAB> <TAB> <TAB> user = self. _currentFile. getUser ( ), <TAB> <TAB> )",True,special,special,0.6733992695808411
|
||
|
2680,"def __parse_tag ( self, tag, count ) : <TAB> """"""Raises IOError and APEBadItemError"""""" <TAB> fileobj = BytesIO ( tag ) <TAB> for i in range ( count ) : <TAB> <TAB> tag_data = fileobj. read ( 8 ) <TAB> <TAB> <TAB> <TAB> if not tag_data : <TAB> <TAB> <TAB> break <TAB> <TAB> if len ( tag_data )!= 8 : <TAB> <TAB> <TAB> raise error <TAB> <TAB> size = cdata. uint32_le ( tag_data [ : 4 ] ) <TAB> <TAB> flags = cdata. uint32_le ( tag_data [ 4 : 8 ] ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> kind = ( flags & 6 ) >> 1 <TAB> <TAB> if kind == 3 : <TAB> <TAB> <TAB> raise APEBadItemError ( ""value type must be 0, 1, or 2"" ) <TAB> <TAB> key = value = fileobj. read ( 1 ) <TAB> <TAB> if not key : <TAB> <TAB> <TAB> raise APEBadItemError <TAB> <TAB> while key [ - 1 : ]!= b""\x00"" and value : <TAB> <TAB> <TAB> value = fileobj. read ( 1 ) <TAB> <TAB> <TAB> if not value : <TAB> <TAB> <TAB> <TAB> raise APEBadItemError <TAB> <TAB> <TAB> key += value <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> key = key [ : - 1 ] <TAB> <TAB> try : <TAB> <TAB> <TAB> key = key. decode ( ""ascii"" ) <TAB> <TAB> except UnicodeError as err : <TAB> <TAB> <TAB> reraise ( APEBadItemError, err, sys. exc_info ( ) [ 2 ] ) <TAB> <TAB> value = fileobj. read ( size ) <TAB> <TAB> if len ( value )!= size : <TAB> <TAB> <TAB> raise APEBadItemError <TAB> <TAB> value = _get_value_type (",False,key[-1:] == b'\x00',kind == 2,0.657939076423645
|
||
|
2681,"def _prunetraceback ( self, excinfo ) : <TAB> if hasattr ( self, ""_obj"" ) and not self. config. option. fulltrace : <TAB> <TAB> code = _pytest. _code. Code ( get_real_func ( self. obj ) ) <TAB> <TAB> path, firstlineno = code. path, code. firstlineno <TAB> <TAB> traceback = excinfo. traceback <TAB> <TAB> ntraceback = traceback. cut ( path = path, firstlineno = firstlineno ) <TAB> <TAB> if ntraceback == traceback : <TAB> <TAB> <TAB> ntraceback = ntraceback. cut ( path = path ) <TAB> <TAB> <TAB> if ntraceback == traceback : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ntraceback = ntraceback. filter ( filter_traceback ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> ntraceback = traceback <TAB> <TAB> excinfo. traceback = ntraceback. filter ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if self. config. option. tbstyle == ""auto"" : <TAB> <TAB> <TAB> if len ( excinfo. traceback ) > 2 : <TAB> <TAB> <TAB> <TAB> for entry in excinfo. traceback [ 1 : - 1 ] : <TAB> <TAB> <TAB> <TAB> <TAB> entry. set_repr_style ( ""short"" )",False,not ntraceback,ntraceback == traceback,0.689589262008667
|
||
|
2682,"def fix_datetime_fields ( data : TableData, table : TableName ) -> None : <TAB> for item in data [ table ] : <TAB> <TAB> for field_name in DATE_FIELDS [ table ] : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> item [ field_name ] = datetime. datetime. fromtimestamp ( <TAB> <TAB> <TAB> <TAB> <TAB> item [ field_name ], tz = datetime. timezone. utc <TAB> <TAB> <TAB> <TAB> )",False,item[field_name] is not None,field_name not in item,0.6560338735580444
|
||
|
2683,"def search ( <TAB> self, query : List [ str ], unknown_elem_positions : List [ Tuple [ int, str ] ] ) -> List [ Dict [ str, str ] ] : <TAB> query = list ( map ( lambda elem : """" if elem. startswith ( ""?"" ) else elem, query ) ) <TAB> subj, rel, obj = query <TAB> if self. file_format == ""hdt"" : <TAB> <TAB> triplets, c = self. document. search_triples ( subj, rel, obj ) <TAB> <TAB> if rel == self. description_rel : <TAB> <TAB> <TAB> triplets = [ <TAB> <TAB> <TAB> <TAB> triplet for triplet in triplets if triplet [ 2 ]. endswith ( self. lang ) <TAB> <TAB> <TAB> ] <TAB> <TAB> combs = [ <TAB> <TAB> <TAB> { elem : triplet [ pos ] for pos, elem in unknown_elem_positions } <TAB> <TAB> <TAB> for triplet in triplets <TAB> <TAB> ] <TAB> else : <TAB> <TAB> if subj : <TAB> <TAB> <TAB> subj, triplets = self. find_triplets ( subj, ""forw"" ) <TAB> <TAB> <TAB> triplets = [ <TAB> <TAB> <TAB> <TAB> [ subj, triplet [ 0 ], obj ] for triplet in triplets for obj in triplet [ 1 : ] <TAB> <TAB> <TAB> ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> obj, triplets = self. find_triplets ( obj, ""backw"" ) <TAB> <TAB> <TAB> triplets = [ <TAB> <TAB> <TAB> <TAB> [ subj, triplet [ 0 ], obj ] for triplet in triplets for subj in triplet [ 1 : ] <TAB> <TAB> <TAB> ] <TAB> <TAB> if rel : <TAB> <TAB> <TAB> if rel == self. description_rel : <TAB> <TAB> <TAB> <TAB> triplets = [ triplet for triplet in triplets if triplet [ 1 ] == """,True,obj,obj,0.6905737519264221
|
||
|
2684,"def post ( self, request ) : <TAB> logger = logging. getLogger ( ""netbox.auth.login"" ) <TAB> form = LoginForm ( request, data = request. POST ) <TAB> if form. is_valid ( ) : <TAB> <TAB> logger. debug ( ""Login form validation was successful"" ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> logger. warning ( <TAB> <TAB> <TAB> <TAB> ""Maintenance mode enabled: disabling update of most recent login time"" <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> user_logged_in. disconnect ( <TAB> <TAB> <TAB> <TAB> update_last_login, dispatch_uid = ""update_last_login"" <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> auth_login ( request, form. get_user ( ) ) <TAB> <TAB> logger. info ( f""User {request.user} successfully authenticated"" ) <TAB> <TAB> messages. info ( request, ""Logged in as {}."". format ( request. user ) ) <TAB> <TAB> return self. redirect_to_next ( request, logger ) <TAB> else : <TAB> <TAB> logger. debug ( ""Login form validation failed"" ) <TAB> return render ( <TAB> <TAB> request, <TAB> <TAB> self. template_name, <TAB> <TAB> { <TAB> <TAB> <TAB> ""form"" : form, <TAB> <TAB> }, <TAB> )",False,settings.MAINTENANCE_MODE,self.update_last_login is None,0.6554818153381348
|
||
|
2685,"def build_pass_managers ( ** kws ) : <TAB> mod = kws. get ( ""mod"" ) <TAB> if not mod : <TAB> <TAB> raise NameError ( ""module must be provided"" ) <TAB> pm = llvm. create_module_pass_manager ( ) <TAB> if kws. get ( ""fpm"", True ) : <TAB> <TAB> assert isinstance ( mod, llvm. ModuleRef ) <TAB> <TAB> fpm = llvm. create_function_pass_manager ( mod ) <TAB> else : <TAB> <TAB> fpm = None <TAB> with llvm. create_pass_manager_builder ( ) as pmb : <TAB> <TAB> pmb. opt_level = opt = kws. get ( ""opt"", 2 ) <TAB> <TAB> pmb. loop_vectorize = kws. get ( ""loop_vectorize"", False ) <TAB> <TAB> pmb. slp_vectorize = kws. get ( ""slp_vectorize"", False ) <TAB> <TAB> pmb. inlining_threshold = _inlining_threshold ( optlevel = opt ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> tli = llvm. create_target_library_info ( mod. triple ) <TAB> <TAB> <TAB> if kws. get ( ""nobuiltins"", False ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> tli. disable_all ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for k in kws. get ( ""disable_builtins"", ( ) ) : <TAB> <TAB> <TAB> <TAB> <TAB> libf = tli. get_libfunc ( k ) <TAB> <TAB> <TAB> <TAB> <TAB> tli. set_unavailable ( libf ) <TAB> <TAB> <TAB> tli. add_pass ( pm ) <TAB> <TAB> <TAB> if fpm is not None : <TAB> <TAB> <TAB> <",False,mod,mod.triple,0.6927608847618103
|
||
|
2686,"def can_be_installed ( self ) -> bool : <TAB> if self. data. homeassistant is not None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if not version_left_higher_then_right ( <TAB> <TAB> <TAB> <TAB> self. hacs. system. ha_version, self. data. homeassistant <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> return False <TAB> return True",False,self.data.releases,self.hacs.system.is_available(),0.6604485511779785
|
||
|
2687,"def create ( self, attrs ) : <TAB> args = { } <TAB> for field_tuple in self. _THRIFT_CLASS. thrift_spec : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> _, thrift_type, arg_name, _, default = field_tuple <TAB> <TAB> f_name = arg_name <TAB> <TAB> if arg_name in self. _THRIFT_RENAMED_FIELDS : <TAB> <TAB> <TAB> f_name = self. _THRIFT_RENAMED_FIELDS [ arg_name ] <TAB> <TAB> serializer = self. fields [ f_name ] <TAB> <TAB> if f_name not in attrs : <TAB> <TAB> <TAB> args [ arg_name ] = default <TAB> <TAB> <TAB> continue <TAB> <TAB> if thrift_type == TType. STRUCT : <TAB> <TAB> <TAB> args [ arg_name ] = serializer. create ( attrs [ f_name ] ) <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> args [ arg_name ] = attrs [ f_name ] <TAB> return self. _THRIFT_CLASS ( ** args )",False,not field_tuple,field_tuple[0] == TType.NONE,0.6612769961357117
|
||
|
2688,"def test_outputs ( self ) : <TAB> for add_texture in ( True, False ) : <TAB> <TAB> meshes = TestSamplePoints. init_meshes ( <TAB> <TAB> <TAB> device = torch. device ( ""cuda:0"" ), add_texture = add_texture <TAB> <TAB> ) <TAB> <TAB> out1 = sample_points_from_meshes ( meshes, num_samples = 100 ) <TAB> <TAB> self. assertTrue ( torch. is_tensor ( out1 ) ) <TAB> <TAB> out2 = sample_points_from_meshes ( meshes, num_samples = 100, return_normals = True ) <TAB> <TAB> self. assertTrue ( isinstance ( out2, tuple ) and len ( out2 ) == 2 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> out3 = sample_points_from_meshes ( <TAB> <TAB> <TAB> <TAB> meshes, num_samples = 100, return_textures = True <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> self. assertTrue ( isinstance ( out3, tuple ) and len ( out3 ) == 2 ) <TAB> <TAB> <TAB> out4 = sample_points_from_meshes ( <TAB> <TAB> <TAB> <TAB> meshes, num_samples = 100, return_normals = True, return_textures = True <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> self. assertTrue ( isinstance ( out4, tuple ) and len ( out4 ) == 3 ) <TAB> <TAB> else : <TAB> <TAB> <TAB> with self. assertRaisesRegex ( ValueError, ""Meshes do not contain textures."" ) : <TAB> <TAB> <TAB> <TAB> sample_points_from_meshes ( meshes, num_samples = 100, return_textures = True ) <TAB> <TAB> <TAB> with self. assertRaisesRegex ( ValueError, ""Meshes do not contain textures."" ) : <TAB> <TAB> <TAB> <TAB> sample_points_from_meshes ( <TAB>",False,add_texture,"isinstance(out1, tuple)",0.6565780639648438
|
||
|
2689,"def load_modules ( <TAB> to_load, load, attr, modules_dict, excluded_aliases, loading_message = None ) : <TAB> if loading_message : <TAB> <TAB> print ( loading_message ) <TAB> for name in to_load : <TAB> <TAB> module = load ( name ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> cls = getattr ( module, attr ) <TAB> <TAB> if hasattr ( cls, ""initialize"" ) and not cls. initialize ( ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> if hasattr ( module, ""aliases"" ) : <TAB> <TAB> <TAB> for alias in module. aliases ( ) : <TAB> <TAB> <TAB> <TAB> if alias not in excluded_aliases : <TAB> <TAB> <TAB> <TAB> <TAB> modules_dict [ alias ] = module <TAB> <TAB> else : <TAB> <TAB> <TAB> modules_dict [ name ] = module <TAB> if loading_message : <TAB> <TAB> print ( )",False,"module is None or not hasattr(module, attr)",attr not in modules_dict,0.6484876871109009
|
||
|
2690,"def render_full ( self, target, ** options ) : <TAB> column_headers = [ ] <TAB> row_headers = [ ] <TAB> for row_header in target. row_headers or ( ) : <TAB> <TAB> row_headers. append ( text. Cell ( row_header, align = ""r"", padding = 1 ) ) <TAB> <TAB> if row_headers : <TAB> <TAB> column_headers. append ( text. Cell ( target. caption or ""-"", padding = 1 ) ) <TAB> for column_header in target. column_headers : <TAB> <TAB> column_headers. append ( text. Cell ( column_header, align = ""c"", padding = 1 ) ) <TAB> rows = [ text. JoinedCell ( * column_headers, tablesep = """" ) ] <TAB> for idx, row in enumerate ( target. rows ) : <TAB> <TAB> cells = [ ] <TAB> <TAB> if row_headers : <TAB> <TAB> <TAB> cells. append ( row_headers [ idx ] ) <TAB> <TAB> for cell in row : <TAB> <TAB> <TAB> fg = cell. get ( ""fg"" ) <TAB> <TAB> <TAB> bg = cell. get ( ""bg"" ) <TAB> <TAB> <TAB> heat = cell. get ( ""heat"" ) <TAB> <TAB> <TAB> if heat and not bg : <TAB> <TAB> <TAB> <TAB> bg = colors. HeatToRGB ( heat, greyscale = target. greyscale ) <TAB> <TAB> <TAB> bg = colors. RGBToXTerm ( * bg ) if bg else None <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> fg = colors. XTermTextForBackground ( bg ) <TAB> <TAB> <TAB> cells. append ( <TAB> <TAB> <TAB> <TAB> text. Cell ( <TAB> <TAB> <TAB> <TAB> <TAB> value = utils. SmartUnicode ( cell. get ( ""value"", ""-"" ) ), <TAB> <TAB> <TAB> <TAB> <TAB> highlights = [ dict ( bg = bg, fg = fg",False,bg and (not fg),bg,0.6612266302108765
|
||
|
2691,"def mat_reciprocal ( self, dim ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> rng = np. random. RandomState ( seed = utt. fetch_seed ( ) ) <TAB> a, b = matrices ( ""ab"" ) <TAB> ab = a * b <TAB> <TAB> diff = ab - as_tensor_variable ( np. ones ( ( dim, dim ), dtype = config. floatX ) ) <TAB> <TAB> ssdiff = sum ( ( diff ** 2.0 ) ) <TAB> g_b = grad ( ssdiff, b ) <TAB> <TAB> <TAB> fn = inplace_func ( [ a, b ], [ ssdiff, g_b ] ) <TAB> <TAB> x = rng. rand ( dim, dim ) + 0.1 <TAB> w = rng. rand ( dim, dim ) <TAB> x = np. asarray ( x, dtype = config. floatX ) <TAB> w = np. asarray ( w, dtype = config. floatX ) <TAB> for i in xrange ( 100 ) : <TAB> <TAB> ssd, gw = fn ( x, w ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> ssd0 = ssd <TAB> <TAB> w -= 0.4 * gw <TAB> return ssd0, ssd",False,i == 0,gw > 0,0.6716749668121338
|
||
|
2692,"def remove ( self, items ) : <TAB> """"""Remove messages from lease management."""""" <TAB> with self. _add_remove_lock : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for item in items : <TAB> <TAB> <TAB> if self. _leased_messages. pop ( item. ack_id, None ) is not None : <TAB> <TAB> <TAB> <TAB> self. _bytes -= item. byte_size <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> _LOGGER. debug ( ""Item %s was not managed."", item. ack_id ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> _LOGGER. debug ( ""Bytes was unexpectedly negative: %d"", self. _bytes ) <TAB> <TAB> <TAB> self. _bytes = 0",True,self._bytes < 0,self._bytes < 0,0.6634814739227295
|
||
|
2693,"def __update_iam_permissions ( <TAB> s3_info, bucket_name, iam_entity, allowed_iam_entity, policy_info ) : <TAB> if bucket_name!= ""*"" and bucket_name in s3_info [ ""buckets"" ] : <TAB> <TAB> bucket = s3_info [ ""buckets"" ] [ bucket_name ] <TAB> <TAB> manage_dictionary ( bucket, iam_entity, { } ) <TAB> <TAB> manage_dictionary ( bucket, iam_entity + ""_count"", 0 ) <TAB> <TAB> if not allowed_iam_entity in bucket [ iam_entity ] : <TAB> <TAB> <TAB> bucket [ iam_entity ] [ allowed_iam_entity ] = { } <TAB> <TAB> <TAB> bucket [ iam_entity + ""_count"" ] = bucket [ iam_entity + ""_count"" ] + 1 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> manage_dictionary ( <TAB> <TAB> <TAB> <TAB> bucket [ iam_entity ] [ allowed_iam_entity ], ""inline_policies"", { } <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> bucket [ iam_entity ] [ allowed_iam_entity ] [ ""inline_policies"" ]. update ( <TAB> <TAB> <TAB> <TAB> policy_info [ ""inline_policies"" ] <TAB> <TAB> <TAB> ) <TAB> <TAB> if ""policies"" in policy_info : <TAB> <TAB> <TAB> manage_dictionary ( bucket [ iam_entity ] [ allowed_iam_entity ], ""policies"", { } ) <TAB> <TAB> <TAB> bucket [ iam_entity ] [ allowed_iam_entity ] [ ""policies"" ]. update ( <TAB> <TAB> <TAB> <TAB> policy_info [ ""policies"" ] <TAB> <TAB> <TAB> ) <TAB> elif bucket_name == ""*"" : <TAB> <TAB> for bucket in s3_info [ ""buckets"" ] : <TAB> <TAB> <TAB> __update_iam_permissions ( <TAB> <TAB> <TAB> <TAB> s3_info, bucket, iam_entity, allowed_iam",False,'inline_policies' in policy_info,allowed_iam_entity in bucket,0.65384840965271
|
||
|
2694,"def dict_to_XML ( tag, dictionary, ** kwargs ) : <TAB> """"""Return XML element converting dicts recursively."""""" <TAB> elem = Element ( tag, ** kwargs ) <TAB> for key, val in dictionary. items ( ) : <TAB> <TAB> if tag == ""layers"" : <TAB> <TAB> <TAB> child = dict_to_XML ( ""layer"", val, name = key ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> child = dict_to_XML ( key, val ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if tag == ""config"" : <TAB> <TAB> <TAB> <TAB> child = Element ( ""variable"", name = key ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> child = Element ( key ) <TAB> <TAB> <TAB> child. text = str ( val ) <TAB> <TAB> elem. append ( child ) <TAB> return elem",False,"isinstance(val, MutableMapping)",tag == 'tag',0.6502958536148071
|
||
|
2695,"def __init__ ( self, date, cfg ) : <TAB> self. config = cfg <TAB> self. profileID = cfg. currentProfile ( ) <TAB> self. isRoot = False <TAB> if isinstance ( date, datetime. datetime ) : <TAB> <TAB> self. sid = ""-"". join ( <TAB> <TAB> <TAB> ( date. strftime ( ""%Y%m%d-%H%M%S"" ), self. config. tag ( self. profileID ) ) <TAB> <TAB> ) <TAB> <TAB> self. date = date <TAB> elif isinstance ( date, datetime. date ) : <TAB> <TAB> self. sid = ""-"". join ( <TAB> <TAB> <TAB> ( date. strftime ( ""%Y%m%d-000000"" ), self. config. tag ( self. profileID ) ) <TAB> <TAB> ) <TAB> <TAB> self. date = datetime. datetime. combine ( date, datetime. datetime. min. time ( ) ) <TAB> elif isinstance ( date, str ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. sid = date <TAB> <TAB> <TAB> self. date = datetime. datetime ( * self. split ( ) ) <TAB> <TAB> elif date == ""last_snapshot"" : <TAB> <TAB> <TAB> raise LastSnapshotSymlink ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""'date' must be in snapshot ID format (e.g 20151218-173512-123)"" <TAB> <TAB> <TAB> ) <TAB> else : <TAB> <TAB> raise TypeError ( <TAB> <TAB> <TAB> ""'date' must be an instance of str, datetime.date or datetime.datetime"" <TAB> <TAB> )",False,self.__cValidSID.match(date),"isinstance(date, datetime.date)",0.6496450901031494
|
||
|
2696,"def __aexit__ ( <TAB> self, exc_type : type, exc_value : BaseException, tb : TracebackType ) -> None : <TAB> if exc_type is not None : <TAB> <TAB> await self. close ( ) <TAB> await self. _task <TAB> while not self. _receive_queue. empty ( ) : <TAB> <TAB> data = await self. _receive_queue. get ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. response_data. extend ( data ) <TAB> <TAB> elif not isinstance ( data, HTTPDisconnect ) : <TAB> <TAB> <TAB> raise data",False,"isinstance(data, bytes)","isinstance(data, HTTPResponse)",0.6515741944313049
|
||
|
2697,"def graph_merge_softmax_with_crossentropy_softmax ( node ) : <TAB> if node. op == softmax_with_bias : <TAB> <TAB> x, b = node. inputs <TAB> <TAB> for x_client in x. clients : <TAB> <TAB> <TAB> if x_client [ 0 ]. op == crossentropy_softmax_argmax_1hot_with_bias : <TAB> <TAB> <TAB> <TAB> big_client = x_client [ 0 ] <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> xx, bb, ll = big_client. inputs <TAB> <TAB> <TAB> <TAB> <TAB> mergeable_client = big_client. op ( x, b, ll ) <TAB> <TAB> <TAB> <TAB> <TAB> copy_stack_trace ( node. outputs [ 0 ], mergeable_client [ 1 ] ) <TAB> <TAB> <TAB> <TAB> <TAB> return [ mergeable_client [ 1 ] ]",False,big_client in [b_client[0] for b_client in b.clients],big_client.op != x,0.6534655094146729
|
||
|
2698,"def check_result ( result, func, arguments ) : <TAB> if check_warning ( result ) and ( result. value!= ReturnCode. WARN_NODATA ) : <TAB> <TAB> log. warning ( UcanWarning ( result, func, arguments ) ) <TAB> elif check_error ( result ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise UcanCmdError ( result, func, arguments ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise UcanError ( result, func, arguments ) <TAB> return result",False,check_error_cmd(result),result.value != ReturnCode.ERROR_NO_RESULT,0.6549124717712402
|
||
|
2699,"def _parse_pylint_informational ( messages ) : <TAB> ignore_files = set ( ) <TAB> ignore_messages = defaultdict ( lambda : defaultdict ( list ) ) <TAB> for message in messages : <TAB> <TAB> if message. source == ""pylint"" : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> match = _PYLINT_SUPPRESSED_MESSAGE. match ( message. message ) <TAB> <TAB> <TAB> <TAB> suppressed_code = match. group ( 1 ) <TAB> <TAB> <TAB> <TAB> line_dict = ignore_messages [ message. location. path ] <TAB> <TAB> <TAB> <TAB> line_dict [ message. location. line ]. append ( suppressed_code ) <TAB> <TAB> <TAB> elif message. code == ""file-ignored"" : <TAB> <TAB> <TAB> <TAB> ignore_files. add ( message. location. path ) <TAB> return ignore_files, ignore_messages",False,message.code == 'suppressed-message',message.code == 'debug',0.6511337757110596
|
||
|
2700,"def remove_packages ( self, ref, package_ids ) : <TAB> """"""Remove any packages specified by package_ids"""""" <TAB> self. check_credentials ( ) <TAB> payload = { ""package_ids"" : package_ids } <TAB> url = self. router. remove_packages ( ref ) <TAB> ret = self. _post_json ( url, payload ) <TAB> if not package_ids and ret. status_code == 404 : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return namedtuple ( ""_"", [ ""status_code"", ""content"" ] ) ( 200, b"""" ) <TAB> <TAB> except Exception as e : <TAB> <TAB> <TAB> logger. warning ( <TAB> <TAB> <TAB> <TAB> ""Unexpected error searching {} packages"" <TAB> <TAB> <TAB> <TAB> "" in remote {}: {}"". format ( ref, self. remote_url, e ) <TAB> <TAB> <TAB> ) <TAB> return ret",False,"not self.search_packages(ref, query=None)",ret.status_code == 502,0.6501806974411011
|
||
|
2701,"def mouse_down ( self, ips, x, y, btn, ** key ) : <TAB> lim = 5.0 / key [ ""canvas"" ]. get_scale ( ) <TAB> if btn == 1 or btn == 3 : <TAB> <TAB> if ips. roi!= None : <TAB> <TAB> <TAB> self. curobj = ips. roi. pick ( x, y, lim ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return <TAB> <TAB> if ips. roi == None : <TAB> <TAB> <TAB> msk = floodfill ( <TAB> <TAB> <TAB> <TAB> ips. img, x, y, self. para [ ""tor"" ], self. para [ ""con"" ] == ""8-connect"" <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> conts = find_contours ( msk, 0, ""high"" ) <TAB> <TAB> <TAB> ips. roi = shape2roi ( polygonize ( conts, btn == 3 ) ) <TAB> <TAB> elif hasattr ( ips. roi, ""topolygon"" ) : <TAB> <TAB> <TAB> shp = roi2shape ( ips. roi. topolygon ( ) ) <TAB> <TAB> <TAB> oper = """" <TAB> <TAB> <TAB> if key [ ""shift"" ] : <TAB> <TAB> <TAB> <TAB> oper = ""+"" <TAB> <TAB> <TAB> elif key [ ""ctrl"" ] : <TAB> <TAB> <TAB> <TAB> oper = ""-"" <TAB> <TAB> <TAB> elif self. curobj : <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> ips. roi = None <TAB> <TAB> <TAB> msk = floodfill ( <TAB> <TAB> <TAB> <TAB> ips. img, x, y, self. para [ ""tor"" ], self. para [ ""con"" ] == ""8-connect"" <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> conts = find_contours (",False,"not self.curobj in (None, True)",self.curobj,0.6529407501220703
|
||
|
2702,"def __call__ ( self, data : Data ) : <TAB> if not self. _add_to_x : <TAB> <TAB> return data <TAB> feat = getattr ( data, self. _feat_name, None ) <TAB> if feat is None : <TAB> <TAB> if self. _strict : <TAB> <TAB> <TAB> raise Exception ( <TAB> <TAB> <TAB> <TAB> ""Data should contain the attribute {}"". format ( self. _feat_name ) <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return data <TAB> else : <TAB> <TAB> if self. _input_nc_feat : <TAB> <TAB> <TAB> feat_dim = 1 if feat. dim ( ) == 1 else feat. shape [ - 1 ] <TAB> <TAB> <TAB> if self. _input_nc_feat!= feat_dim and self. _strict : <TAB> <TAB> <TAB> <TAB> raise Exception ( <TAB> <TAB> <TAB> <TAB> <TAB> ""The shape of feat: {} doesn t match {}"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> feat. shape, self. _input_nc_feat <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> x = getattr ( data, ""x"", None ) <TAB> <TAB> if x is None : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise Exception ( ""We expected to have an attribute x"" ) <TAB> <TAB> <TAB> if feat. dim ( ) == 1 : <TAB> <TAB> <TAB> <TAB> feat = feat. unsqueeze ( - 1 ) <TAB> <TAB> <TAB> data. x = feat <TAB> <TAB> else : <TAB> <TAB> <TAB> if x. shape [ 0 ] == feat. shape [ 0 ] : <TAB> <TAB> <TAB> <TAB> if x. dim ( ) == 1 : <TAB> <TAB> <TAB> <TAB> <",False,self._strict and data.pos.shape[0] != feat.shape[0],x is None,0.6534580588340759
|
||
|
2703,"def publish ( self, channel, nick, msg ) : <TAB> if channel not in self. channels : <TAB> <TAB> print ( ""IGNORED UNKNOWN CHANNEL %s"" % channel ) <TAB> <TAB> return <TAB> for ( n, c ) in self. channels [ channel ] [ : ] : <TAB> <TAB> try : <TAB> <TAB> <TAB> c. message ( nick, msg ) <TAB> <TAB> except Pyro4. errors. ConnectionClosedError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. channels [ channel ]. remove ( ( n, c ) ) <TAB> <TAB> <TAB> <TAB> print ( ""Removed dead listener %s %s"" % ( n, c ) )",False,"(n, c) in self.channels[channel]",n >= 0 and c in self.channels[channel],0.6491459608078003
|
||
|
2704,"def _get_cluster_status ( self ) : <TAB> try : <TAB> <TAB> return ( <TAB> <TAB> <TAB> self. dataproc_client. projects ( ) <TAB> <TAB> <TAB>. regions ( ) <TAB> <TAB> <TAB>. clusters ( ) <TAB> <TAB> <TAB>. get ( <TAB> <TAB> <TAB> <TAB> projectId = self. gcloud_project_id, <TAB> <TAB> <TAB> <TAB> region = self. dataproc_region, <TAB> <TAB> <TAB> <TAB> clusterName = self. dataproc_cluster_name, <TAB> <TAB> <TAB> <TAB> fields = ""status"", <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB>. execute ( ) <TAB> <TAB> ) <TAB> except HttpError as e : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return None <TAB> <TAB> else : <TAB> <TAB> <TAB> raise e",False,e.resp.status == 404,e.args[0] in _NoSuchClusterError.__args,0.6577361822128296
|
||
|
2705,"def _parse_src_file ( self ) : <TAB> lines = self. open ( self. _fileids [ 0 ] ). read ( ). splitlines ( ) <TAB> lines = filter ( ( lambda x : not re. search ( r""^\s*#"", x ) ), lines ) <TAB> for i, line in enumerate ( lines ) : <TAB> <TAB> fields = [ field. strip ( ) for field in re. split ( r""\t+"", line ) ] <TAB> <TAB> try : <TAB> <TAB> <TAB> pos, offset, pos_score, neg_score, synset_terms, gloss = fields <TAB> <TAB> except : <TAB> <TAB> <TAB> raise ValueError ( ""Line %s formatted incorrectly: %s\n"" % ( i, line ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> offset = int ( offset ) <TAB> <TAB> <TAB> self. _db [ ( pos, offset ) ] = ( float ( pos_score ), float ( neg_score ) )",False,pos and offset,gloss,0.668982982635498
|
||
|
2706,"def get_drive ( self, root_path = """", volume_guid_path = """" ) : <TAB> for drive in self. drives : <TAB> <TAB> if root_path : <TAB> <TAB> <TAB> config_root_path = drive. get ( ""root_path"" ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return drive <TAB> <TAB> elif volume_guid_path : <TAB> <TAB> <TAB> config_volume_guid_path = drive. get ( ""volume_guid_path"" ) <TAB> <TAB> <TAB> if config_volume_guid_path and config_volume_guid_path == volume_guid_path : <TAB> <TAB> <TAB> <TAB> return drive",False,config_root_path and root_path == config_root_path,config_root_path and config_root_path == drive,0.6443790197372437
|
||
|
2707,"def traverse ( tree ) : <TAB> """"""Generator dropping comment nodes"""""" <TAB> for entry in tree : <TAB> <TAB> <TAB> <TAB> spaceless = [ e for e in entry if not nginxparser. spacey ( e ) ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> key = spaceless [ 0 ] <TAB> <TAB> <TAB> values = spaceless [ 1 ] if len ( spaceless ) > 1 else None <TAB> <TAB> else : <TAB> <TAB> <TAB> key = values = """" <TAB> <TAB> if isinstance ( key, list ) : <TAB> <TAB> <TAB> new = copy. deepcopy ( entry ) <TAB> <TAB> <TAB> new [ 1 ] = filter_comments ( values ) <TAB> <TAB> <TAB> yield new <TAB> <TAB> else : <TAB> <TAB> <TAB> if key!= ""#"" and spaceless : <TAB> <TAB> <TAB> <TAB> yield spaceless",True,spaceless,spaceless,0.6895411014556885
|
||
|
2708,def __bootstrap ( self ) : <TAB> try : <TAB> <TAB> self. _set_ident ( ) <TAB> <TAB> self. _Thread__started. set ( ) <TAB> <TAB> threading. _active_limbo_lock. acquire ( ) <TAB> <TAB> threading. _active [ self. _Thread__ident ] = self <TAB> <TAB> del threading. _limbo [ self ] <TAB> <TAB> threading. _active_limbo_lock. release ( ) <TAB> <TAB> if threading. _trace_hook : <TAB> <TAB> <TAB> sys. settrace ( threading. _trace_hook ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> sys. setprofile ( threading. _profile_hook ) <TAB> <TAB> try : <TAB> <TAB> <TAB> self. run ( ) <TAB> <TAB> finally : <TAB> <TAB> <TAB> self. _Thread__exc_clear ( ) <TAB> finally : <TAB> <TAB> with threading. _active_limbo_lock : <TAB> <TAB> <TAB> self. _Thread__stop ( ) <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> del threading. _active [ threading. _get_ident ( ) ] <TAB> <TAB> <TAB> except : <TAB> <TAB> <TAB> <TAB> pass,True,threading._profile_hook,threading._profile_hook,0.6569888591766357
|
||
|
2709,"def main ( client ) : <TAB> <TAB> creative_service = client. GetService ( ""CreativeService"", version = ""v202008"" ) <TAB> <TAB> statement = ( <TAB> <TAB> ad_manager. StatementBuilder ( version = ""v202008"" ) <TAB> <TAB>. Where ( ""creativeType = :creativeType"" ) <TAB> <TAB>. WithBindVariable ( ""creativeType"", ""ImageCreative"" ) <TAB> ) <TAB> <TAB> <TAB> while True : <TAB> <TAB> response = creative_service. getCreativesByStatement ( statement. ToStatement ( ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> for creative in response [ ""results"" ] : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> <TAB> 'Creative with ID ""%d"" and name ""%s"" was found.\n' <TAB> <TAB> <TAB> <TAB> <TAB> % ( creative [ ""id"" ], creative [ ""name"" ] ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> statement. offset += statement. limit <TAB> <TAB> else : <TAB> <TAB> <TAB> break <TAB> print ( ""\nNumber of results found: %s"" % response [ ""totalResultSetSize"" ] )",False,'results' in response and len(response['results']),response[0] != None,0.6585992574691772
|
||
|
2710,"def __repr__ ( self ) : <TAB> if self. info is not None : <TAB> <TAB> out = repr ( self. info ) <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> out = ""(%s(%r))"" % ( self. expr. op, self. args [ 0 ] ) <TAB> <TAB> else : <TAB> <TAB> <TAB> out = ""(%s)"" % self. expr. op. join ( repr ( arg ) for arg in self. args ) <TAB> return out",True,len(self.args) == 1,len(self.args) == 1,0.6569452285766602
|
||
|
2711,"def __call__ ( self, frame : FrameType, event : str, arg : Any ) -> ""CallTracer"" : <TAB> code = frame. f_code <TAB> if ( <TAB> <TAB> event not in SUPPORTED_EVENTS <TAB> <TAB> or code. co_name == ""trace_types"" <TAB> <TAB> or self. should_trace <TAB> <TAB> and not self. should_trace ( code ) <TAB> ) : <TAB> <TAB> return self <TAB> try : <TAB> <TAB> if event == EVENT_CALL : <TAB> <TAB> <TAB> self. handle_call ( frame ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> self. handle_return ( frame, arg ) <TAB> <TAB> else : <TAB> <TAB> <TAB> logger. error ( ""Cannot handle event %s"", event ) <TAB> except Exception : <TAB> <TAB> logger. exception ( ""Failed collecting trace"" ) <TAB> return self",True,event == EVENT_RETURN,event == EVENT_RETURN,0.6851500272750854
|
||
|
2712,"def _find_caller ( args ) : <TAB> """"""Somewhat hacky method of finding the __file__ based on the line executed."""""" <TAB> re_line = re. compile ( r""[^;\s|&<>]+\s+"" + r""\s+"". join ( args ) ) <TAB> curr = inspect. currentframe ( ) <TAB> for _, fname, lineno, _, lines, _ in getouterframes ( curr, context = 1 ) [ 3 : ] : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return fname <TAB> <TAB> elif ( <TAB> <TAB> <TAB> lineno == 1 and re_line. search ( linecache. getline ( fname, lineno ) ) is not None <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return fname <TAB> else : <TAB> <TAB> msg = ( <TAB> <TAB> <TAB> ""xonsh: warning: __file__ name could not be found. You may be "" <TAB> <TAB> <TAB> ""trying to trace interactively. Please pass in the file names "" <TAB> <TAB> <TAB> ""you want to trace explicitly."" <TAB> <TAB> ) <TAB> <TAB> print ( msg, file = sys. stderr )",False,lines is not None and re_line.search(lines[0]) is not None,fname is None,0.648374080657959
|
||
|
2713,"def filter_module ( mod, type_req = None, subclass_req = None ) : <TAB> for name in dir ( mod ) : <TAB> <TAB> val = getattr ( mod, name ) <TAB> <TAB> if type_req is not None and not isinstance ( val, type_req ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> yield name, val",False,"subclass_req is not None and (not issubclass(val, subclass_req))","subclass_req and val and (not issubclass(val, subclass_req))",0.6528202295303345
|
||
|
2714,"def _get_vdisk_create_params ( opts, is_dr_pool, add_copies = False ) : <TAB> easytier = ""on"" if opts [ ""easytier"" ] else ""off"" <TAB> if opts [ ""rsize"" ] == - 1 : <TAB> <TAB> params = [ ] <TAB> <TAB> if opts [ ""nofmtdisk"" ] : <TAB> <TAB> <TAB> params. append ( ""-nofmtdisk"" ) <TAB> else : <TAB> <TAB> if is_dr_pool : <TAB> <TAB> <TAB> params = [ ""-rsize"", ""%s%%"" % str ( opts [ ""rsize"" ] ), ""-autoexpand"" ] <TAB> <TAB> <TAB> if opts [ ""compression"" ] : <TAB> <TAB> <TAB> <TAB> params. append ( ""-compressed"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> params = [ <TAB> <TAB> <TAB> <TAB> ""-rsize"", <TAB> <TAB> <TAB> <TAB> ""%s%%"" % str ( opts [ ""rsize"" ] ), <TAB> <TAB> <TAB> <TAB> ""-autoexpand"", <TAB> <TAB> <TAB> <TAB> ""-warning"", <TAB> <TAB> <TAB> <TAB> ""%s%%"" % str ( opts [ ""warning"" ] ), <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> params. remove ( ""-autoexpand"" ) <TAB> <TAB> <TAB> if opts [ ""compression"" ] : <TAB> <TAB> <TAB> <TAB> params. append ( ""-compressed"" ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> params. extend ( [ ""-grainsize"", str ( opts [ ""grainsize"" ] ) ] ) <TAB> if add_copies and opts [ ""mirror_pool"" ] : <TAB> <TAB> params. extend ( [ ""-copies"", ""2"" ] ) <TAB> if not is_dr_pool : <TAB",False,not opts['autoexpand'],is_dr_pool and is_autoexpand,0.6668483018875122
|
||
|
2715,"def cnvkit_background ( <TAB> background_cnns, out_file, items, target_bed = None, antitarget_bed = None ) : <TAB> """"""Calculate background reference, handling flat case with no normal sample."""""" <TAB> if not utils. file_exists ( out_file ) : <TAB> <TAB> with file_transaction ( items [ 0 ], out_file ) as tx_out_file : <TAB> <TAB> <TAB> cmd = [ <TAB> <TAB> <TAB> <TAB> _get_cmd ( ), <TAB> <TAB> <TAB> <TAB> ""reference"", <TAB> <TAB> <TAB> <TAB> ""-f"", <TAB> <TAB> <TAB> <TAB> dd. get_ref_file ( items [ 0 ] ), <TAB> <TAB> <TAB> <TAB> ""-o"", <TAB> <TAB> <TAB> <TAB> tx_out_file, <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> gender = _get_batch_gender ( items ) <TAB> <TAB> <TAB> if gender : <TAB> <TAB> <TAB> <TAB> cmd += [ ""--sample-sex"", gender ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> assert ( <TAB> <TAB> <TAB> <TAB> <TAB> target_bed and antitarget_bed <TAB> <TAB> <TAB> <TAB> ), ""Missing CNNs and target BEDs for flat background"" <TAB> <TAB> <TAB> <TAB> cmd += [ ""-t"", target_bed, ""-a"", antitarget_bed ] <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> cmd += background_cnns <TAB> <TAB> <TAB> do. run ( _prep_cmd ( cmd, tx_out_file ), ""CNVkit background"" ) <TAB> return out_file",False,len(background_cnns) == 0,target_bed and antitarget_bed,0.6582752466201782
|
||
|
2716,"def _generate_certs ( <TAB> self, ) : <TAB> if certs_files_exist ( ) : <TAB> <TAB> self. app. log ( f""Gateway SSL certification files exist in {cert_path()}."" ) <TAB> <TAB> self. app. log ( <TAB> <TAB> <TAB> ""To create new certification files, please first manually delete those files."" <TAB> <TAB> ) <TAB> <TAB> return <TAB> self. app. clear_input ( ) <TAB> self. placeholder_mode = True <TAB> self. app. hide_input = True <TAB> while True : <TAB> <TAB> pass_phase = await self. app. prompt ( <TAB> <TAB> <TAB> prompt = ""Enter pass phase to generate Gateway SSL certifications >>> "", <TAB> <TAB> <TAB> is_password = True, <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> break <TAB> <TAB> self. app. log ( ""Error: Invalid pass phase"" ) <TAB> create_self_sign_certs ( pass_phase ) <TAB> self. _notify ( f""Gateway SSL certification files are created in {cert_path()}."" ) <TAB> self. placeholder_mode = False <TAB> self. app. hide_input = False <TAB> self. app. change_prompt ( prompt = "">>> "" )",False,pass_phase is not None and len(pass_phase) > 0,not pass_phase,0.6452759504318237
|
||
|
2717,"def has_object_permission ( self, request, view, obj ) : <TAB> if isinstance ( obj, OsfStorageFolder ) : <TAB> <TAB> obj = obj. target <TAB> assert_resource_type ( obj, self. acceptable_models ) <TAB> auth = get_user_auth ( request ) <TAB> if request. method in permissions. SAFE_METHODS : <TAB> <TAB> if auth. user is None : <TAB> <TAB> <TAB> return obj. verified_publishable <TAB> <TAB> else : <TAB> <TAB> <TAB> user_has_permissions = ( <TAB> <TAB> <TAB> <TAB> obj. verified_publishable <TAB> <TAB> <TAB> <TAB> or ( <TAB> <TAB> <TAB> <TAB> <TAB> obj. is_public <TAB> <TAB> <TAB> <TAB> <TAB> and auth. user. has_perm ( ""view_submissions"", obj. provider ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> or obj. has_permission ( auth. user, osf_permissions. ADMIN ) <TAB> <TAB> <TAB> <TAB> or ( <TAB> <TAB> <TAB> <TAB> <TAB> obj. is_contributor ( auth. user ) <TAB> <TAB> <TAB> <TAB> <TAB> and obj. machine_state!= DefaultStates. INITIAL. value <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> return user_has_permissions <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise exceptions. PermissionDenied ( <TAB> <TAB> <TAB> <TAB> detail = ""User must be an admin to make these preprint edits."" <TAB> <TAB> <TAB> ) <TAB> <TAB> return True",False,"not obj.has_permission(auth.user, osf_permissions.ADMIN)","self.has_admin(obj, request.user)",0.6502338647842407
|
||
|
2718,"def UpdateControls ( self ) : <TAB> clockStyle = self. clock. GetClockStyle ( ) <TAB> hourStyle, minuteStyle = self. clock. GetTickStyle ( ) <TAB> [ g1, g2, g3 ] = self. groups <TAB> for label in dir ( styles ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> item = self. GetItemByLabel ( label, g2 ) <TAB> <TAB> <TAB> value = bool ( getattr ( styles, label ) & hourStyle ) <TAB> <TAB> <TAB> self. SetItemValue ( item, value ) <TAB> <TAB> <TAB> item = self. GetItemByLabel ( label, g3 ) <TAB> <TAB> <TAB> value = bool ( getattr ( styles, label ) & minuteStyle ) <TAB> <TAB> <TAB> self. SetItemValue ( item, value ) <TAB> <TAB> elif not ( <TAB> <TAB> <TAB> label. startswith ( ""DEFAULT_"" ) <TAB> <TAB> <TAB> or label. startswith ( ""_"" ) <TAB> <TAB> <TAB> or label in [ ""HOUR"", ""MINUTE"", ""SECOND"", ""ALL"" ] <TAB> <TAB> ) : <TAB> <TAB> <TAB> item = self. GetItemByLabel ( label, g1 ) <TAB> <TAB> <TAB> value = bool ( getattr ( styles, label ) & clockStyle ) <TAB> <TAB> <TAB> self. SetItemValue ( item, value )",False,label.startswith('TICKS_'),"label in [None, 'DEFAULT', 'TAB>",0.6568251252174377
|
||
|
2719,"def process_input_line ( self, line, store_history = True ) : <TAB> """"""process the input, capturing stdout"""""" <TAB> stdout = sys. stdout <TAB> splitter = self. IP. input_splitter <TAB> try : <TAB> <TAB> sys. stdout = self. cout <TAB> <TAB> splitter. push ( line ) <TAB> <TAB> more = splitter. push_accepts_more ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> source_raw = splitter. source_raw_reset ( ) [ 1 ] <TAB> <TAB> <TAB> except : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> source_raw = splitter. raw_reset ( ) <TAB> <TAB> <TAB> self. IP. run_cell ( source_raw, store_history = store_history ) <TAB> finally : <TAB> <TAB> sys. stdout = stdout",False,not more,more,0.6725689172744751
|
||
|
2720,"def _load_from_file_system ( grammar, path, p_time ) : <TAB> cache_path = _get_hashed_path ( grammar, path ) <TAB> try : <TAB> <TAB> try : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return None <TAB> <TAB> except OSError as e : <TAB> <TAB> <TAB> if e. errno == errno. ENOENT : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> raise FileNotFoundError <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> raise <TAB> <TAB> with open ( cache_path, ""rb"" ) as f : <TAB> <TAB> <TAB> gc. disable ( ) <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> module_cache_item = pickle. load ( f ) <TAB> <TAB> <TAB> finally : <TAB> <TAB> <TAB> <TAB> gc. enable ( ) <TAB> except FileNotFoundError : <TAB> <TAB> return None <TAB> else : <TAB> <TAB> parser_cache [ path ] = module_cache_item <TAB> <TAB> debug. dbg ( ""pickle loaded: %s"", path ) <TAB> <TAB> return module_cache_item. node",False,p_time > os.path.getmtime(cache_path),os.path.exists(path),0.6481732130050659
|
||
|
2721,"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<mask> : <TAB> <TAB> <TAB> break <TAB> <TAB> if fid == 1 : <TAB> <TAB> <TAB> if ftype == TType. STRING : <TAB> <TAB> <TAB> <TAB> self. cfName = iprot. readString ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif fid == 2 : <TAB> <TAB> <TAB> if ftype == TType. STRING : <TAB> <TAB> <TAB> <TAB> self. start_token = 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. end_token = iprot. readString ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif fid == 4 : <TAB> <TAB> <TAB> if ftype == TType. I32 : <TAB> <TAB> <TAB> <TAB> self. keys_per_split = iprot. readI32 ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB>",False,ftype == TType.STOP,fid == 0,0.6626762747764587
|
||
|
2722,"def __repr__ ( self ) : <TAB> tmp = ""%s(%r,%r,%r) %r\n"" % ( <TAB> <TAB> self. __class__. __name__, <TAB> <TAB> self. restag, <TAB> <TAB> self. rescode, <TAB> <TAB> self. resstr, <TAB> <TAB> self. attrs, <TAB> ) <TAB> m = 0 <TAB> for line in self. datalines : <TAB> <TAB> for k, v in line. items ( ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> m = len ( k ) <TAB> for line in self. datalines : <TAB> <TAB> tmp += "" Line:\n"" <TAB> <TAB> for k, v in line. items ( ) : <TAB> <TAB> <TAB> tmp += "" %s:%s %s\n"" % ( k, ( m - len ( k ) ) * "" "", v ) <TAB> return tmp",False,len(k) > m,k == k,0.6655681133270264
|
||
|
2723,def filtered ( gen ) : <TAB> for example in gen : <TAB> <TAB> example_len = length_fn ( example ) <TAB> <TAB> <TAB> <TAB> if max_length is not None : <TAB> <TAB> <TAB> if example_len > max_length : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if example_len < min_length : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> yield example,True,min_length is not None,min_length is not None,0.6567391157150269
|
||
|
2724,"def get_unfiltered_action_space ( <TAB> self, output_action_space : BoxActionSpace ) -> DiscreteActionSpace : <TAB> if isinstance ( self. num_bins_per_dimension, int ) : <TAB> <TAB> self. num_bins_per_dimension = ( <TAB> <TAB> <TAB> np. ones ( output_action_space. shape ) * self. num_bins_per_dimension <TAB> <TAB> ) <TAB> bins = [ ] <TAB> for i in range ( len ( output_action_space. low ) ) : <TAB> <TAB> dim_bins = np. linspace ( <TAB> <TAB> <TAB> output_action_space. low [ i ], <TAB> <TAB> <TAB> output_action_space. high [ i ], <TAB> <TAB> <TAB> self. num_bins_per_dimension [ i ], <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> dim_bins = dim_bins. astype ( int ) <TAB> <TAB> bins. append ( dim_bins ) <TAB> self. target_actions = [ list ( action ) for action in list ( product ( * bins ) ) ] <TAB> return super ( ). get_unfiltered_action_space ( output_action_space )",False,self.force_int_bins,dim_bins,0.6635154485702515
|
||
|
2725,"def prepare_command_list ( <TAB> ctx : commands. Context, command_list : Iterable [ Tuple [ str, dict ] ] ) -> List [ Tuple [ str, str ] ] : <TAB> results = [ ] <TAB> for command, body in command_list : <TAB> <TAB> responses = body [ ""response"" ] <TAB> <TAB> if isinstance ( responses, list ) : <TAB> <TAB> <TAB> result = "", "". join ( responses ) <TAB> <TAB> elif isinstance ( responses, str ) : <TAB> <TAB> <TAB> result = responses <TAB> <TAB> else : <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> result = result [ : 49 ] + ""..."" <TAB> <TAB> <TAB> <TAB> result = result. replace ( ""\n"", "" "" ) <TAB> <TAB> <TAB> <TAB> result = escape ( result, formatting = True, mass_mentions = True ) <TAB> <TAB> results. append ( ( f""{ctx.clean_prefix}{command}"", result ) ) <TAB> return results",False,len(result) > 52,len(result) > 49,0.6559702157974243
|
||
|
2726,"def symlink ( self, target_path, path ) : <TAB> path = self. _realpath ( path ) <TAB> if ( len ( target_path ) > 0 ) and ( target_path [ 0 ] == ""/"" ) : <TAB> <TAB> <TAB> <TAB> target_path = os. path. join ( self. ROOT, target_path [ 1 : ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> target_path = target_path [ 1 : ] <TAB> else : <TAB> <TAB> <TAB> <TAB> abspath = os. path. join ( os. path. dirname ( path ), target_path ) <TAB> <TAB> if abspath [ : len ( self. ROOT ) ]!= self. ROOT : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> target_path = ""<error>"" <TAB> try : <TAB> <TAB> os. symlink ( target_path, path ) <TAB> except OSError as e : <TAB> <TAB> return SFTPServer. convert_errno ( e. errno ) <TAB> return SFTP_OK",False,target_path[:2] == '//',len(target_path) > 0,0.6546930074691772
|
||
|
2727,"def predict ( self, X ) : <TAB> predictions = self. get_all_predictions ( X ) <TAB> <TAB> if X. shape [ 0 ] == 1 : <TAB> <TAB> <TAB> <TAB> predicted_vals = predictions. values ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return np. median ( predicted_vals ) <TAB> <TAB> elif ( <TAB> <TAB> <TAB> self. ensemble_method == ""average"" <TAB> <TAB> <TAB> or self. ensemble_method == ""mean"" <TAB> <TAB> <TAB> or self. ensemble_method == ""avg"" <TAB> <TAB> ) : <TAB> <TAB> <TAB> return np. average ( predicted_vals ) <TAB> <TAB> elif self. ensemble_method == ""max"" : <TAB> <TAB> <TAB> return np. max ( predicted_vals ) <TAB> <TAB> elif self. ensemble_method == ""min"" : <TAB> <TAB> <TAB> return np. min ( predicted_vals ) <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return predictions. apply ( np. median, axis = 1 ). values <TAB> <TAB> elif ( <TAB> <TAB> <TAB> self. ensemble_method == ""average"" <TAB> <TAB> <TAB> or self. ensemble_method == ""mean"" <TAB> <TAB> <TAB> or self. ensemble_method == ""avg"" <TAB> <TAB> ) : <TAB> <TAB> <TAB> return predictions. apply ( np. average, axis = 1 ). values <TAB> <TAB> elif self. ensemble_method == ""max"" : <TAB> <TAB> <TAB> return predictions. apply ( np. max, axis = 1 ). values <TAB> <TAB> elif self. ensemble_method == ""min"" : <TAB> <TAB> <TAB> return predictions. apply ( np. min, axis = 1 ). values",True,self.ensemble_method == 'median',self.ensemble_method == 'median',0.6615849733352661
|
||
|
2728,"def textToString ( self, element ) : <TAB> buffer = [ ] <TAB> for node in element. childNodes : <TAB> <TAB> if node. nodeType == xml. dom. Node. TEXT_NODE : <TAB> <TAB> <TAB> buffer. append ( node. nodeValue ) <TAB> <TAB> elif node. nodeType == xml. dom. Node. ELEMENT_NODE : <TAB> <TAB> <TAB> tag = node. tagName <TAB> <TAB> <TAB> if tag in ( ""draw:text-box"", ""draw:frame"" ) : <TAB> <TAB> <TAB> <TAB> buffer. append ( self. textToString ( node ) ) <TAB> <TAB> <TAB> elif tag in ( ""text:p"", ""text:h"" ) : <TAB> <TAB> <TAB> <TAB> text = self. paragraphToString ( node ) <TAB> <TAB> <TAB> <TAB> if text : <TAB> <TAB> <TAB> <TAB> <TAB> buffer. append ( text ) <TAB> <TAB> <TAB> elif tag == ""text:list"" : <TAB> <TAB> <TAB> <TAB> buffer. append ( self. listToString ( node ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> method = self. elements. get ( tag ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> buffer. append ( method ( node ) ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> buffer. append ( "" {"" + tag + ""} "" ) <TAB> return """". join ( buffer )",True,method,method,0.6950024366378784
|
||
|
2729,"def dump_types ( self, manager : FineGrainedBuildManager ) -> List [ str ] : <TAB> a = [ ] <TAB> <TAB> <TAB> for module_id in sorted ( manager. manager. modules ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> all_types = manager. manager. all_types <TAB> <TAB> <TAB> <TAB> tree = manager. graph [ module_id ]. tree <TAB> <TAB> assert tree is not None <TAB> <TAB> type_map = { <TAB> <TAB> <TAB> node : all_types [ node ] <TAB> <TAB> <TAB> for node in get_subexpressions ( tree ) <TAB> <TAB> <TAB> if node in all_types <TAB> <TAB> } <TAB> <TAB> if type_map : <TAB> <TAB> <TAB> a. append ( ""## {}"". format ( module_id ) ) <TAB> <TAB> <TAB> for expr in sorted ( <TAB> <TAB> <TAB> <TAB> type_map, <TAB> <TAB> <TAB> <TAB> key = lambda n : ( n. line, short_type ( n ), str ( n ) + str ( type_map [ n ] ) ), <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> typ = type_map [ expr ] <TAB> <TAB> <TAB> <TAB> a. append ( <TAB> <TAB> <TAB> <TAB> <TAB> ""{}:{}: {}"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> short_type ( expr ), expr. line, self. format_type ( typ ) <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> ) <TAB> return a",False,not is_dumped_module(module_id),module_id not in manager.graph,0.6487562656402588
|
||
|
2730,"def FetchFn ( bigger_than_3_only = None, less_than_7_only = None, even_only = None ) : <TAB> result = [ ] <TAB> for i in range ( 10 ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> if bigger_than_3_only and i <= 3 : <TAB> <TAB> <TAB> continue <TAB> <TAB> if less_than_7_only and i >= 7 : <TAB> <TAB> <TAB> continue <TAB> <TAB> if even_only and i % 2!= 0 : <TAB> <TAB> <TAB> continue <TAB> <TAB> result. append ( i ) <TAB> return result",False,bigger_than_3_only and less_than_7_only and (i == 4),not even_only,0.6522044539451599
|
||
|
2731,"def process ( self ) : <TAB> if not any ( socket. is_linked for socket in self. outputs ) : <TAB> <TAB> return <TAB> solids_in = self. inputs [ 0 ]. sv_get ( ) <TAB> radius_start_s = self. inputs [ 1 ]. sv_get ( ) [ 0 ] <TAB> radius_end_s = self. inputs [ 2 ]. sv_get ( ) [ 0 ] <TAB> mask_s = self. inputs [ 3 ]. sv_get ( default = [ [ 1 ] ] ) <TAB> solids = [ ] <TAB> for solid, r_s, r_e, mask in zip ( <TAB> <TAB> * mlr ( [ solids_in, radius_start_s, radius_end_s, mask_s ] ) <TAB> ) : <TAB> <TAB> selected_edges = [ ] <TAB> <TAB> fullList ( mask, len ( solid. Edges ) ) <TAB> <TAB> for edge, m in zip ( solid. Edges, mask ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> selected_edges. append ( edge ) <TAB> <TAB> if selected_edges : <TAB> <TAB> <TAB> solid_o = solid. makeFillet ( r_s, r_e, selected_edges ) <TAB> <TAB> else : <TAB> <TAB> <TAB> solid_o = solid <TAB> <TAB> solids. append ( solid_o ) <TAB> self. outputs [ ""Solid"" ]. sv_set ( solids )",True,m,m,0.6858646869659424
|
||
|
2732,"def key_release_cb ( self, win, tdw, event ) : <TAB> if self. in_drag : <TAB> <TAB> if event. keyval == self. _start_keyval : <TAB> <TAB> <TAB> self. _stop_drag ( ) <TAB> <TAB> <TAB> self. _start_keyval = None <TAB> <TAB> return True <TAB> if self. SPRING_LOADED : <TAB> <TAB> if event. is_modifier and self. in_drag : <TAB> <TAB> <TAB> return False <TAB> <TAB> if self. initial_modifiers : <TAB> <TAB> <TAB> modifiers = self. current_modifiers ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> if self is self. doc. modes. top : <TAB> <TAB> <TAB> <TAB> <TAB> self. doc. modes. pop ( ) <TAB> <TAB> <TAB> <TAB> return True <TAB> <TAB> return super ( DragMode, self ). key_release_cb ( win, tdw, event )",False,modifiers & self.initial_modifiers == 0,modifiers.get_value(),0.6582457423210144
|
||
|
2733,"def _build_metaindex ( self, dbtable, index_name ) : <TAB> model = dbtable. _model_ <TAB> dbindex = model. _indexes_ [ index_name ] <TAB> kw = { } <TAB> with self. db. _adapter. index_expander ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> kw [ ""where"" ] = str ( dbindex [ ""where"" ] ) <TAB> <TAB> rv = MetaIndex ( <TAB> <TAB> <TAB> model. tablename, <TAB> <TAB> <TAB> index_name, <TAB> <TAB> <TAB> [ field for field in dbindex [ ""fields"" ] ], <TAB> <TAB> <TAB> [ str ( expr ) for expr in dbindex [ ""expressions"" ] ], <TAB> <TAB> <TAB> dbindex [ ""unique"" ], <TAB> <TAB> <TAB> ** kw <TAB> <TAB> ) <TAB> return rv",False,'where' in dbindex,dbindex['where'] is not None,0.6713399887084961
|
||
|
2734,"def block_users ( self, user_ids ) : <TAB> broken_items = [ ] <TAB> self. logger. info ( ""Going to block %d users."" % len ( user_ids ) ) <TAB> for user_id in tqdm ( user_ids ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. error_delay ( ) <TAB> <TAB> <TAB> broken_items = user_ids [ user_ids. index ( user_id ) : ] <TAB> <TAB> <TAB> break <TAB> self. logger. info ( ""DONE: Total blocked %d users."" % self. total [ ""blocks"" ] ) <TAB> return broken_items",False,not self.block(user_id),self.total[user_id] > 0,0.6460548639297485
|
||
|
2735,"def has_invalid_cce ( yaml_file, product_yaml = None ) : <TAB> rule = yaml. open_and_macro_expand ( yaml_file, product_yaml ) <TAB> if ""identifiers"" in rule and rule [ ""identifiers"" ] is not None : <TAB> <TAB> for i_type, i_value in rule [ ""identifiers"" ]. items ( ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> if not checks. is_cce_value_valid ( ""CCE-"" + str ( i_value ) ) : <TAB> <TAB> <TAB> <TAB> <TAB> return True <TAB> return False",False,i_type[0:3] == 'cce',i_type == 'cce',0.651930570602417
|
||
|
2736,"def __import__ ( name, globals = None, locals = None, fromlist = ( ), level = 0 ) : <TAB> module = orig___import__ ( name, globals, locals, fromlist, level ) <TAB> if fromlist and module. __name__ in modules : <TAB> <TAB> if ""*"" in fromlist : <TAB> <TAB> <TAB> fromlist = list ( fromlist ) <TAB> <TAB> <TAB> fromlist. remove ( ""*"" ) <TAB> <TAB> <TAB> fromlist. extend ( getattr ( module, ""__all__"", [ ] ) ) <TAB> <TAB> for x in fromlist : <TAB> <TAB> <TAB> if isinstance ( getattr ( module, x, None ), types. ModuleType ) : <TAB> <TAB> <TAB> <TAB> from_name = ""{}.{}"". format ( module. __name__, x ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> importlib. import_module ( from_name ) <TAB> return module",False,from_name in modules,from_name,0.6553236842155457
|
||
|
2737,"def check_friendly_cross_account ( self, item ) : <TAB> accounts = { <TAB> <TAB> lp. get ( ""UserId"", lp. get ( ""Group"" ) ) <TAB> <TAB> for lp in item. config. get ( ""LaunchPermissions"", [ ] ) <TAB> } <TAB> for account in accounts : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> if account in self. FRIENDLY : <TAB> <TAB> <TAB> entity = Entity ( <TAB> <TAB> <TAB> <TAB> category = ""account"", <TAB> <TAB> <TAB> <TAB> value = account, <TAB> <TAB> <TAB> <TAB> account_name = self. FRIENDLY [ account ], <TAB> <TAB> <TAB> <TAB> account_identifier = account, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> self. record_friendly_access ( item, entity, actions = [ ""LaunchPermissions"" ] )",False,account == 'all',account == '00000000',0.6625968217849731
|
||
|
2738,"def add_user_command ( ctx, username, password, groups, permissions, is_admin ) : <TAB> """"""Add a new user."""""" <TAB> if not groups : <TAB> <TAB> groups = [ ] <TAB> if is_admin : <TAB> <TAB> groups. append ( ctx. obj. group_manager. admin_group ) <TAB> try : <TAB> <TAB> ctx. obj. user_manager. add_user ( <TAB> <TAB> <TAB> username, password, groups = groups, permissions = permissions, active = True <TAB> <TAB> ) <TAB> <TAB> user = ctx. obj. user_manager. find_user ( username ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> click. echo ( ""User created:"" ) <TAB> <TAB> <TAB> click. echo ( ""\t{}"". format ( _user_to_line ( user. as_dict ( ) ) ) ) <TAB> except UserAlreadyExists : <TAB> <TAB> click. echo ( <TAB> <TAB> <TAB> ""A user with the name {} does already exist!"". format ( username ), err = True <TAB> <TAB> )",True,user,user,0.6796194314956665
|
||
|
2739,"def retry_http_digest_auth ( self, req, auth ) : <TAB> token, challenge = auth. split ( "" "", 1 ) <TAB> chal = parse_keqv_list ( parse_http_list ( challenge ) ) <TAB> auth = self. get_authorization ( req, chal ) <TAB> if auth : <TAB> <TAB> auth_val = ""Digest %s"" % auth <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return None <TAB> <TAB> req. add_unredirected_header ( self. auth_header, auth_val ) <TAB> <TAB> resp = self. parent. open ( req ) <TAB> <TAB> return resp",False,"req.headers.get(self.auth_header, None) == auth_val",self.auth_header and auth_val not in self.auth_header,0.6478418111801147
|
||
|
2740,"def save_cover_from_filestorage ( filepath, saved_filename, img ) : <TAB> if hasattr ( img, ""metadata"" ) : <TAB> <TAB> img. save ( filename = os. path. join ( filepath, saved_filename ) ) <TAB> <TAB> img. close ( ) <TAB> else : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> os. makedirs ( filepath ) <TAB> <TAB> <TAB> except OSError : <TAB> <TAB> <TAB> <TAB> log. error ( u""Failed to create path for cover"" ) <TAB> <TAB> <TAB> <TAB> return False, _ ( u""Failed to create path for cover"" ) <TAB> <TAB> try : <TAB> <TAB> <TAB> img. save ( os. path. join ( filepath, saved_filename ) ) <TAB> <TAB> except ( IOError, OSError ) : <TAB> <TAB> <TAB> log. error ( u""Cover-file is not a valid image file, or could not be stored"" ) <TAB> <TAB> <TAB> return False, _ ( <TAB> <TAB> <TAB> <TAB> u""Cover-file is not a valid image file, or could not be stored"" <TAB> <TAB> <TAB> ) <TAB> return True, None",True,not os.path.exists(filepath),not os.path.exists(filepath),0.6480621695518494
|
||
|
2741,"def check_enums_ATLAS_ISAEXT ( lines ) : <TAB> for i, isaext in enumerate ( ATLAS_ISAEXT ) : <TAB> <TAB> got = lines. pop ( 0 ). strip ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> expect = ""none: 1"" <TAB> <TAB> else : <TAB> <TAB> <TAB> expect = ""{0}: {1}"". format ( isaext, 1 << i ) <TAB> <TAB> if got!= expect : <TAB> <TAB> <TAB> raise RuntimeError ( <TAB> <TAB> <TAB> <TAB> ""ATLAS_ISAEXT mismatch at position "" <TAB> <TAB> <TAB> <TAB> + str ( i ) <TAB> <TAB> <TAB> <TAB> + "": got >>"" <TAB> <TAB> <TAB> <TAB> + got <TAB> <TAB> <TAB> <TAB> + ""<<, expected >>"" <TAB> <TAB> <TAB> <TAB> + expect <TAB> <TAB> <TAB> <TAB> + ""<<"" <TAB> <TAB> <TAB> )",False,i == 0,isaext == 0,0.6774026155471802
|
||
|
2742,"def do_acquire_read_lock ( self, wait = True ) : <TAB> self. condition. acquire ( ) <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> while self. current_sync_operation is not None : <TAB> <TAB> <TAB> <TAB> self. condition. wait ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if self. current_sync_operation is not None : <TAB> <TAB> <TAB> <TAB> return False <TAB> <TAB> self. asynch += 1 <TAB> finally : <TAB> <TAB> self. condition. release ( ) <TAB> if not wait : <TAB> <TAB> return True",True,wait,wait,0.7024734020233154
|
||
|
2743,"def _diff_dict ( self, old, new ) : <TAB> diff = { } <TAB> removed = [ ] <TAB> added = [ ] <TAB> for key, value in old. items ( ) : <TAB> <TAB> if key not in new : <TAB> <TAB> <TAB> removed. append ( key ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> removed. append ( key ) <TAB> <TAB> <TAB> added. append ( key ) <TAB> for key, value in new. items ( ) : <TAB> <TAB> if key not in old : <TAB> <TAB> <TAB> added. append ( key ) <TAB> if removed : <TAB> <TAB> diff [ ""removed"" ] = sorted ( removed ) <TAB> if added : <TAB> <TAB> diff [ ""added"" ] = sorted ( added ) <TAB> return diff",False,old[key] != new[key],not added,0.6584181785583496
|
||
|
2744,"def to_json_schema ( self, parent = None ) : <TAB> schema = { } <TAB> if not parent : <TAB> <TAB> schema [ ""title"" ] = self. title <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> schema [ ""description"" ] = self. description <TAB> <TAB> if self. has_default : <TAB> <TAB> <TAB> schema [ ""default"" ] = self. default <TAB> <TAB> schema [ ""_required_"" ] = self. required <TAB> if self. null : <TAB> <TAB> schema [ ""type"" ] = [ ""string"", ""null"" ] <TAB> else : <TAB> <TAB> schema [ ""type"" ] = ""string"" <TAB> if self. enum is not None : <TAB> <TAB> schema [ ""enum"" ] = self. enum <TAB> return schema",True,self.description,self.description,0.6759694814682007
|
||
|
2745,"def load_streams ( self ) : <TAB> streams = [ ] <TAB> for raw_stream in await self. config. streams ( ) : <TAB> <TAB> _class = getattr ( _streamtypes, raw_stream [ ""type"" ], None ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> raw_msg_cache = raw_stream [ ""messages"" ] <TAB> <TAB> raw_stream [ ""_messages_cache"" ] = [ ] <TAB> <TAB> for raw_msg in raw_msg_cache : <TAB> <TAB> <TAB> chn = self. bot. get_channel ( raw_msg [ ""channel"" ] ) <TAB> <TAB> <TAB> if chn is not None : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> msg = await chn. fetch_message ( raw_msg [ ""message"" ] ) <TAB> <TAB> <TAB> <TAB> except discord. HTTPException : <TAB> <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> raw_stream [ ""_messages_cache"" ]. append ( msg ) <TAB> <TAB> token = await self. bot. get_shared_api_tokens ( _class. token_name ) <TAB> <TAB> if token : <TAB> <TAB> <TAB> if _class. __name__ == ""TwitchStream"" : <TAB> <TAB> <TAB> <TAB> raw_stream [ ""token"" ] = token. get ( ""client_id"" ) <TAB> <TAB> <TAB> <TAB> raw_stream [ ""bearer"" ] = self. ttv_bearer_cache. get ( ""access_token"", None ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> if _class. __name__ == ""YoutubeStream"" : <TAB> <TAB> <TAB> <TAB> <TAB> raw_stream [ ""config"" ] = self. config <TAB> <TAB> <TAB",False,not _class,_class is None,0.6664639711380005
|
||
|
2746,"def save_servers ( self ) : <TAB> l = [ ] <TAB> for s in self. servers : <TAB> <TAB> host = s. host ( ) <TAB> <TAB> if not host : <TAB> <TAB> <TAB> continue <TAB> <TAB> nets = [ ] <TAB> <TAB> for n in s. nets ( ) : <TAB> <TAB> <TAB> subnet = n. subnet ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> nets. append ( ( subnet, n. width ( ) ) ) <TAB> <TAB> d = dict ( <TAB> <TAB> <TAB> host = s. host ( ), <TAB> <TAB> <TAB> nets = nets, <TAB> <TAB> <TAB> autoNets = s. autoNets ( ), <TAB> <TAB> <TAB> autoHosts = s. autoHosts ( ), <TAB> <TAB> <TAB> useDns = s. useDns ( ), <TAB> <TAB> <TAB> latencyControl = s. latencyControl ( ), <TAB> <TAB> ) <TAB> <TAB> l. append ( d ) <TAB> my. Defaults ( ). setObject_forKey_ ( l, ""servers"" ) <TAB> self. fill_menu ( )",False,not subnet,subnet,0.6889684200286865
|
||
|
2747,"def parse_data_type ( self, index, ** kwargs ) : <TAB> """"""Parse a type to an other type"""""" <TAB> if not index. isValid ( ) : <TAB> <TAB> return False <TAB> try : <TAB> <TAB> if kwargs [ ""atype"" ] == ""date"" : <TAB> <TAB> <TAB> self. _data [ index. row ( ) ] [ index. column ( ) ] = datestr_to_datetime ( <TAB> <TAB> <TAB> <TAB> self. _data [ index. row ( ) ] [ index. column ( ) ], kwargs [ ""dayfirst"" ] <TAB> <TAB> <TAB> ). date ( ) <TAB> <TAB> elif kwargs [ ""atype"" ] == ""perc"" : <TAB> <TAB> <TAB> _tmp = self. _data [ index. row ( ) ] [ index. column ( ) ]. replace ( ""%"", """" ) <TAB> <TAB> <TAB> self. _data [ index. row ( ) ] [ index. column ( ) ] = eval ( _tmp ) / 100.0 <TAB> <TAB> elif kwargs [ ""atype"" ] == ""account"" : <TAB> <TAB> <TAB> _tmp = self. _data [ index. row ( ) ] [ index. column ( ) ]. replace ( "","", """" ) <TAB> <TAB> <TAB> self. _data [ index. row ( ) ] [ index. column ( ) ] = eval ( _tmp ) <TAB> <TAB> elif kwargs [ ""atype"" ] == ""unicode"" : <TAB> <TAB> <TAB> self. _data [ index. row ( ) ] [ index. column ( ) ] = to_text_string ( <TAB> <TAB> <TAB> <TAB> self. _data [ index. row ( ) ] [ index. column ( ) ] <TAB> <TAB> <TAB> ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> self. _data [ index. row ( ) ] [ index. column ( ) ] = int ( <TAB> <TAB> <TAB> <TAB> self. _data [ index. row ( ) ] [ index. column ( ) ] <TAB> <TAB> <TAB> ) <TAB",True,kwargs['atype'] == 'int',kwargs['atype'] == 'int',0.6612300276756287
|
||
|
2748,"def step ( self, action ) : <TAB> """"""Repeat action, sum reward, and max over last observations."""""" <TAB> total_reward = 0.0 <TAB> done = None <TAB> for i in range ( self. _skip ) : <TAB> <TAB> obs, reward, done, info = self. env. step ( action ) <TAB> <TAB> if i == self. _skip - 2 : <TAB> <TAB> <TAB> self. _obs_buffer [ 0 ] = obs <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _obs_buffer [ 1 ] = obs <TAB> <TAB> total_reward += reward <TAB> <TAB> if done : <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> max_frame = self. _obs_buffer. max ( axis = 0 ) <TAB> return max_frame, total_reward, done, info",True,i == self._skip - 1,i == self._skip - 1,0.6616599559783936
|
||
|
2749,"def DeleteKey ( key, sub_key ) : <TAB> log. debug ( ""DeleteKey: %s, %s"", key. path, sub_key ) <TAB> if key. path. startswith ( ""HKLM"" ) and not elevated : <TAB> <TAB> log. debug ( <TAB> <TAB> <TAB> ""DeleteKey: access denied deleting %s::%s (have %s)"", <TAB> <TAB> <TAB> key. path, <TAB> <TAB> <TAB> sub_key, <TAB> <TAB> <TAB> access_str ( key. access ), <TAB> <TAB> ) <TAB> <TAB> raise WindowsError ( 5, ""ERROR_ACCESS_DENIED"" ) <TAB> path = ""\\"". join ( map ( lambda x : x. strip ( ""\\"" ), [ key. path, sub_key, """" ] ) ) <TAB> path_lower = path. lower ( ) <TAB> for k, v in data. items ( ) : <TAB> <TAB> if not k. lower ( ). startswith ( path_lower ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> if k. lower ( ) == path_lower : <TAB> <TAB> <TAB> path = k <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> log. warn ( ""DeleteKey: path %s has subkeys or values %s = %r"", path, k, v ) <TAB> <TAB> raise WindowsError ( 4, ""ERROR_TOO_MANY_OPEN_FILES"" ) <TAB> parent = path. rsplit ( ""\\"", 2 ) [ 0 ] + ""\\"" <TAB> if not parent in data : <TAB> <TAB> <TAB> <TAB> log. debug ( ""DeleteKey: deleted %s, adding parent %s"", path, parent ) <TAB> <TAB> data [ parent ] = None <TAB> else : <TAB> <TAB> log. debug ( ""DeleteKey: deleted %s"", path ) <TAB> del data [ path ]",False,v is None,path in data,0.6651968955993652
|
||
|
2750,"def _walk_dir ( dir, ddir = None, maxlevels = 10, quiet = 0 ) : <TAB> if quiet < 2 and isinstance ( dir, os. PathLike ) : <TAB> <TAB> dir = os. fspath ( dir ) <TAB> if not quiet : <TAB> <TAB> print ( ""Listing {!r}..."". format ( dir ) ) <TAB> try : <TAB> <TAB> names = os. listdir ( dir ) <TAB> except OSError : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> print ( ""Can't list {!r}"". format ( dir ) ) <TAB> <TAB> names = [ ] <TAB> names. sort ( ) <TAB> for name in names : <TAB> <TAB> if name == ""__pycache__"" : <TAB> <TAB> <TAB> continue <TAB> <TAB> fullname = os. path. join ( dir, name ) <TAB> <TAB> if ddir is not None : <TAB> <TAB> <TAB> dfile = os. path. join ( ddir, name ) <TAB> <TAB> else : <TAB> <TAB> <TAB> dfile = None <TAB> <TAB> if not os. path. isdir ( fullname ) : <TAB> <TAB> <TAB> yield fullname, ddir <TAB> <TAB> elif ( <TAB> <TAB> <TAB> maxlevels > 0 <TAB> <TAB> <TAB> and name!= os. curdir <TAB> <TAB> <TAB> and name!= os. pardir <TAB> <TAB> <TAB> and os. path. isdir ( fullname ) <TAB> <TAB> <TAB> and not os. path. islink ( fullname ) <TAB> <TAB> ) : <TAB> <TAB> <TAB> yield from _walk_dir ( <TAB> <TAB> <TAB> <TAB> fullname, ddir = dfile, maxlevels = maxlevels - 1, quiet = quiet <TAB> <TAB> <TAB> )",False,quiet < 2,not names,0.6807381510734558
|
||
|
2751,"def build_titles ( title ) : <TAB> warnings. warn ( <TAB> <TAB> ""Deprecated, use openlibrary.catalog.merge.merge_marc.build_titles() instead."", <TAB> <TAB> DeprecationWarning, <TAB> ) <TAB> normalized_title = normalize ( title ). lower ( ) <TAB> titles = [ title, normalized_title ] <TAB> if title. find ( "" & "" )!= - 1 : <TAB> <TAB> t = title. replace ( "" & "", "" and "" ) <TAB> <TAB> titles. append ( t ) <TAB> <TAB> titles. append ( normalize ( t ) ) <TAB> t2 = [ ] <TAB> for t in titles : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> t2. append ( t [ 4 : ] ) <TAB> <TAB> elif t. lower ( ). startswith ( ""a "" ) : <TAB> <TAB> <TAB> t2. append ( t [ 2 : ] ) <TAB> titles += t2 <TAB> if re_amazon_title_paren. match ( title ) : <TAB> <TAB> t2 = [ ] <TAB> <TAB> for t in titles : <TAB> <TAB> <TAB> m = re_amazon_title_paren. match ( t ) <TAB> <TAB> <TAB> if m : <TAB> <TAB> <TAB> <TAB> t2. append ( m. group ( 1 ) ) <TAB> <TAB> <TAB> <TAB> t2. append ( normalize ( m. group ( 1 ) ) ) <TAB> <TAB> titles += t2 <TAB> return { <TAB> <TAB> ""full_title"" : title, <TAB> <TAB> ""normalized_title"" : normalized_title, <TAB> <TAB> ""titles"" : titles, <TAB> <TAB> ""short_title"" : normalized_title [ : 25 ], <TAB> }",False,t.lower().startswith('the '),t.lower().startswith('a'),0.6473172307014465
|
||
|
2752,"def _validate_parameter_range ( self, value_hp, parameter_range ) : <TAB> """"""Placeholder docstring"""""" <TAB> for ( <TAB> <TAB> parameter_range_key, <TAB> <TAB> parameter_range_value, <TAB> ) in parameter_range. __dict__. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> if isinstance ( parameter_range_value, list ) : <TAB> <TAB> <TAB> for categorical_value in parameter_range_value : <TAB> <TAB> <TAB> <TAB> value_hp. validate ( categorical_value ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> value_hp. validate ( parameter_range_value )",False,parameter_range_key == 'scaling_type',parameter_range_key is None,0.6524428129196167
|
||
|
2753,"def once_a_day ( <TAB> midnight_dt, current_data = self. current_data, data_portal = self. data_portal ) : <TAB> <TAB> for capital_change in algo. calculate_capital_changes ( <TAB> <TAB> midnight_dt, emission_rate = emission_rate, is_interday = True <TAB> ) : <TAB> <TAB> yield capital_change <TAB> <TAB> self. simulation_dt = midnight_dt <TAB> algo. on_dt_changed ( midnight_dt ) <TAB> metrics_tracker. handle_market_open ( <TAB> <TAB> midnight_dt, <TAB> <TAB> algo. data_portal, <TAB> ) <TAB> <TAB> assets_we_care_about = viewkeys ( metrics_tracker. positions ) | viewkeys ( <TAB> <TAB> algo. blotter. open_orders <TAB> ) <TAB> if assets_we_care_about : <TAB> <TAB> splits = data_portal. get_splits ( assets_we_care_about, midnight_dt ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> algo. blotter. process_splits ( splits ) <TAB> <TAB> <TAB> metrics_tracker. handle_splits ( splits )",True,splits,splits,0.6793467402458191
|
||
|
2754,"def read ( self, n ) : <TAB> if self. current_frame : <TAB> <TAB> data = self. current_frame. read ( n ) <TAB> <TAB> if not data and n!= 0 : <TAB> <TAB> <TAB> self. current_frame = None <TAB> <TAB> <TAB> return self. file_read ( n ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise UnpicklingError ( ""pickle exhausted before end of frame"" ) <TAB> <TAB> return data <TAB> else : <TAB> <TAB> return self. file_read ( n )",False,len(data) < n,n == 0,0.6625741124153137
|
||
|
2755,"def _trackA ( self, tracks ) : <TAB> try : <TAB> <TAB> track, start, end = self. featureA <TAB> <TAB> assert track in tracks <TAB> <TAB> return track <TAB> except TypeError : <TAB> <TAB> for track in tracks : <TAB> <TAB> <TAB> for feature_set in track. get_sets ( ) : <TAB> <TAB> <TAB> <TAB> if hasattr ( feature_set, ""features"" ) : <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return track <TAB> <TAB> return None",False,self.featureA in feature_set.features.values(),"hasattr(feature_set, 'features')",0.6484836339950562
|
||
|
2756,"def monad ( self ) : <TAB> if not self. cls_bl_idname : <TAB> <TAB> return None <TAB> for monad in bpy. data. node_groups : <TAB> <TAB> if hasattr ( monad, ""cls_bl_idname"" ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return monad <TAB> return None",False,monad.cls_bl_idname == self.cls_bl_idname,"hasattr(monad, 'name')",0.6534332633018494
|
||
|
2757,"def get_upstream_statuses_events ( self, upstream : Set ) -> Dict [ str, V1Statuses ] : <TAB> statuses_by_refs = { u : [ ] for u in upstream } <TAB> events = self. events or [ ] <TAB> for e in events : <TAB> <TAB> entity_ref = contexts_refs. get_entity_ref ( e. ref ) <TAB> <TAB> if not entity_ref : <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> for kind in e. kinds : <TAB> <TAB> <TAB> status = V1EventKind. events_statuses_mapping. get ( kind ) <TAB> <TAB> <TAB> if status : <TAB> <TAB> <TAB> <TAB> statuses_by_refs [ entity_ref ]. append ( status ) <TAB> return statuses_by_refs",False,entity_ref not in statuses_by_refs,e.kinds not in V1EventKind.events_statuses_mapping,0.6517710089683533
|
||
|
2758,"def fetch_count ( dbset ) : <TAB> <TAB> <TAB> if cache_count is None or isinstance ( cache_count, tuple ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> c = ""count(*) AS count_all"" <TAB> <TAB> <TAB> nrows = db. executesql ( <TAB> <TAB> <TAB> <TAB> ""select count(*) from (%s) _tmp;"" <TAB> <TAB> <TAB> <TAB> % dbset. _select ( <TAB> <TAB> <TAB> <TAB> <TAB> c, left = left, cacheable = True, groupby = groupby, cache = cache_count <TAB> <TAB> <TAB> <TAB> ) [ : - 1 ] <TAB> <TAB> <TAB> ) [ 0 ] [ 0 ] <TAB> <TAB> elif left : <TAB> <TAB> <TAB> c = ""count(*)"" <TAB> <TAB> <TAB> nrows = dbset. select ( <TAB> <TAB> <TAB> <TAB> c, left = left, cacheable = True, cache = cache_count <TAB> <TAB> <TAB> ). first ( ) [ c ] <TAB> <TAB> elif dbset. _db. _adapter. dbengine == ""google:datastore"" : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> nrows = dbset. db. _adapter. count ( dbset. query, limit = 1000 ) <TAB> <TAB> else : <TAB> <TAB> <TAB> nrows = dbset. count ( cache = cache_count ) <TAB> elif isinstance ( cache_count, integer_types ) : <TAB> <TAB> nrows = cache_count <TAB> elif callable ( cache_count ) : <TAB> <TAB> nrows = cache_count ( dbset, request. vars ) <TAB> else : <TAB> <TAB> nrows = 0 <TAB> return nrows",False,groupby,left,0.6700143814086914
|
||
|
2759,"def _getRSSData ( self ) : <TAB> RSS_data = None <TAB> xml_element_tree = None <TAB> for url in [ <TAB> <TAB> self. provider. url + ""rss/?sec=tv-x264&fr=false"", <TAB> <TAB> self. provider. url + ""rss/?sec=tv-dvd&fr=false"", <TAB> ] : <TAB> <TAB> logger. log ( u""Womble's Index cache update URL: "" + url, logger. DEBUG ) <TAB> <TAB> data = self. provider. getURL ( url ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> parsedXML = helpers. parse_xml ( data ) <TAB> <TAB> <TAB> if parsedXML : <TAB> <TAB> <TAB> <TAB> if xml_element_tree is None : <TAB> <TAB> <TAB> <TAB> <TAB> xml_element_tree = parsedXML <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> items = parsedXML. findall ( "".//item"" ) <TAB> <TAB> <TAB> <TAB> <TAB> if items : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for item in items : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> xml_element_tree. append ( item ) <TAB> if xml_element_tree is not None : <TAB> <TAB> RSS_data = etree. tostring ( xml_element_tree ) <TAB> return RSS_data",True,data,data,0.6830787658691406
|
||
|
2760,"def nested_html_table ( rows ) : <TAB> <TAB> <TAB> <TAB> <TAB> html = [ ] <TAB> html. append ( '<table border=""0"" cellspacing=""0"" cellpadding=""0"">' ) <TAB> for row in rows : <TAB> <TAB> if isinstance ( row, List ) : <TAB> <TAB> <TAB> if len ( row ) > 0 and any ( row ) : <TAB> <TAB> <TAB> <TAB> html. append ( "" <tr><td>"" ) <TAB> <TAB> <TAB> <TAB> html. append ( <TAB> <TAB> <TAB> <TAB> <TAB>' <table border=""0"" cellspacing=""0"" cellpadding=""3"" cellborder=""1""><tr>' <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> for cell in row : <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> html. append ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> f' <td balign=""left"">{cell}</td>'. replace ( ""><tdX"", """" ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> html. append ( "" </tr></table>"" ) <TAB> <TAB> <TAB> <TAB> html. append ( "" </td></tr>"" ) <TAB> <TAB> elif row is not None : <TAB> <TAB> <TAB> html. append ( "" <tr><td>"" ) <TAB> <TAB> <TAB> html. append ( f"" {row}"" ) <TAB> <TAB> <TAB> html. append ( "" </td></tr>"" ) <TAB> html. append ( ""</table>"" ) <TAB> return html",False,cell is not None,len(row) > 0,0.6660335063934326
|
||
|
2761,"def __init__ ( self, fileobj ) : <TAB> stream_id = fileobj. read ( 4 ) <TAB> if len ( stream_id )!= 4 or not stream_id == b""tBaK"" : <TAB> <TAB> raise TAKHeaderError ( ""not a TAK file"" ) <TAB> bitreader = _LSBBitReader ( fileobj ) <TAB> while True : <TAB> <TAB> type = TAKMetadata ( bitreader. bits ( 7 ) ) <TAB> <TAB> bitreader. skip ( 1 ) <TAB> <TAB> size = struct. unpack ( ""<I"", bitreader. bytes ( 3 ) + b""\0"" ) [ 0 ] <TAB> <TAB> data_size = size - CRC_SIZE <TAB> <TAB> pos = fileobj. tell ( ) <TAB> <TAB> if type == TAKMetadata. END : <TAB> <TAB> <TAB> break <TAB> <TAB> elif type == TAKMetadata. STREAM_INFO : <TAB> <TAB> <TAB> self. _parse_stream_info ( bitreader, size ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> self. _parse_encoder_info ( bitreader, data_size ) <TAB> <TAB> assert bitreader. is_aligned ( ) <TAB> <TAB> fileobj. seek ( pos + size ) <TAB> if self. sample_rate > 0 : <TAB> <TAB> self. length = self. number_of_samples / float ( self. sample_rate )",False,type == TAKMetadata.ENCODER_INFO,type == TAKMetadata.encoder_INFO,0.6610809564590454
|
||
|
2762,"def LinkFunc ( target, source, env ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> src = source [ 0 ]. abspath <TAB> dest = target [ 0 ]. abspath <TAB> dir, file = os. path. split ( dest ) <TAB> if dir and not target [ 0 ]. fs. isdir ( dir ) : <TAB> <TAB> os. makedirs ( dir ) <TAB> if not Link_Funcs : <TAB> <TAB> <TAB> <TAB> set_duplicate ( ""hard-soft-copy"" ) <TAB> fs = source [ 0 ]. fs <TAB> <TAB> for func in Link_Funcs : <TAB> <TAB> try : <TAB> <TAB> <TAB> func ( fs, src, dest ) <TAB> <TAB> <TAB> break <TAB> <TAB> except ( IOError, OSError ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> raise <TAB> return 0",False,func == Link_Funcs[-1],env.get('fail_if_macos'),0.6576271653175354
|
||
|
2763,"def adjust_threshold ( gain_df, threshold ) : <TAB> if gain_df. shape [ 0 ] == 0 : <TAB> <TAB> raise BaseException ( ""ran out of features to prune!"" ) <TAB> banned_df = gain_df. loc [ gain_df >= threshold ]. index <TAB> banned_features = list ( banned_df ) <TAB> if len ( banned_features ) == 0 : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise BaseException ( ""threshold already max!"" ) <TAB> <TAB> elif threshold > 0.000001 : <TAB> <TAB> <TAB> threshold_new = threshold / 2 <TAB> <TAB> elif threshold > 0 : <TAB> <TAB> <TAB> threshold_new = 0 <TAB> <TAB> elif threshold == 0 : <TAB> <TAB> <TAB> threshold_new = - 0.00000001 <TAB> <TAB> elif ( threshold < 0 ) and ( threshold > - 0.0001 ) : <TAB> <TAB> <TAB> threshold_new = threshold * 2 <TAB> <TAB> else : <TAB> <TAB> <TAB> threshold_new = gain_df. max ( ) <TAB> <TAB> logger. log ( 10, ""Adjusting threshold to %s"" % threshold_new ) <TAB> <TAB> return FeaturePruner. adjust_threshold ( gain_df = gain_df, threshold = threshold_new ) <TAB> else : <TAB> <TAB> return threshold",False,threshold < -100000000,threshold in banned_features,0.6722052097320557
|
||
|
2764,"def scan_eop ( self ) : <TAB> for i in range ( len ( self. bits ) - 19 ) : <TAB> <TAB> k = ( <TAB> <TAB> <TAB> self. get_sym ( i, rec = False ), <TAB> <TAB> <TAB> self. get_sym ( i + 5, rec = False ), <TAB> <TAB> <TAB> self. get_sym ( i + 10, rec = False ), <TAB> <TAB> <TAB> self. get_sym ( i + 15, rec = False ), <TAB> <TAB> ) <TAB> <TAB> sym = START_OF_PACKETS. get ( k, None ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> sym = self. find_corrupted_sop ( k ) <TAB> <TAB> <TAB> <TAB> if sym : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. putx ( 0, i, [ 1, [ ""Preamble"", ""..."" ] ] ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. rec_sym ( i, k [ 0 ] ) <TAB> <TAB> <TAB> self. rec_sym ( i + 5, k [ 1 ] ) <TAB> <TAB> <TAB> self. rec_sym ( i + 10, k [ 2 ] ) <TAB> <TAB> <TAB> self. rec_sym ( i + 15, k [ 3 ] ) <TAB> <TAB> <TAB> if sym == ""Hard Reset"" : <TAB> <TAB> <TAB> <TAB> self. text += ""HRST"" <TAB> <TAB> <TAB> <TAB> return - 1 <TAB> <TAB> <TAB> elif sym == ""Cable Reset"" : <TAB> <TAB> <TAB> <TAB> self. text += ""CRST"" <TAB> <TAB> <TAB> <TAB> return - 1 <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. putx ( i, i + 20, [ 2, [ sym, ""S"" ] ] ) <TAB> <TAB> <TAB",False,not sym,sym is None,0.6738256216049194
|
||
|
2765,"def _handle_songs ( self, songs, playlist = None ) : <TAB> <TAB> if self. com_index : <TAB> <TAB> com = self. get_data ( self. com_index ) <TAB> <TAB> if len ( songs ) > com. warn_threshold : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> print_d ( ""User decided not to run on %d songs"" % len ( songs ) ) <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> print_d ( ""Running %s on %d song(s)"" % ( com, len ( songs ) ) ) <TAB> <TAB> try : <TAB> <TAB> <TAB> com. run ( songs, playlist and playlist. name ) <TAB> <TAB> except Exception as err : <TAB> <TAB> <TAB> print_e ( <TAB> <TAB> <TAB> <TAB> ""Couldn't run command %s: %s %s at:"" <TAB> <TAB> <TAB> <TAB> % ( <TAB> <TAB> <TAB> <TAB> <TAB> com. name, <TAB> <TAB> <TAB> <TAB> <TAB> type ( err ), <TAB> <TAB> <TAB> <TAB> <TAB> err, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> print_exc ( ) <TAB> <TAB> <TAB> ErrorMessage ( <TAB> <TAB> <TAB> <TAB> self. plugin_window, <TAB> <TAB> <TAB> <TAB> _ ( ""Unable to run custom command %s"" ) % util. escape ( self. com_index ), <TAB> <TAB> <TAB> <TAB> util. escape ( str ( err ) ), <TAB> <TAB> <TAB> ). run ( )",False,"not confirm_multi_song_invoke(self, com.name, len(songs))",self.com_index and playlist is None,0.6499416828155518
|
||
|
2766,"def update_jupyter ( self, s, keywords ) : <TAB> """"""Update @jupyter node in the vr pane."""""" <TAB> pc = self <TAB> c = pc. c <TAB> if pc. must_change_widget ( QtWebKitWidgets. QWebView ) : <TAB> <TAB> w = QtWebKitWidgets. QWebView ( ) <TAB> <TAB> n = c. config. getInt ( ""qweb-view-font-size"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> settings = w. settings ( ) <TAB> <TAB> <TAB> settings. setFontSize ( settings. DefaultFontSize, n ) <TAB> <TAB> pc. embed_widget ( w ) <TAB> <TAB> assert w == pc. w <TAB> else : <TAB> <TAB> w = pc. w <TAB> s = self. get_jupyter_source ( c ) <TAB> if isQt5 : <TAB> <TAB> w. hide ( ) <TAB> w. setHtml ( s ) <TAB> w. show ( ) <TAB> c. bodyWantsFocusNow ( )",False,n,n > 0,0.7014975547790527
|
||
|
2767,"def addButtons ( <TAB> self, names, funcs, row = None, column = 0, colspan = 0, rowspan = 0, fill = False ) : <TAB> """"""adds a 1D/2D list of buttons"""""" <TAB> if not isinstance ( names, list ) : <TAB> <TAB> raise Exception ( ""Invalid button: "" + names + "". It must be a list of buttons."" ) <TAB> singleFunc = self. _checkFunc ( names, funcs ) <TAB> frame = self. _makeWidgetBox ( ) ( self. getContainer ( ) ) <TAB> if not self. ttk : <TAB> <TAB> frame. config ( background = self. _getContainerBg ( ) ) <TAB> <TAB> if not isinstance ( names [ 0 ], list ) : <TAB> <TAB> names = [ names ] <TAB> <TAB> <TAB> <TAB> if funcs is not None : <TAB> <TAB> <TAB> funcs = [ funcs ] <TAB> sticky = None <TAB> if fill : <TAB> <TAB> sticky = E + W <TAB> for bRow in range ( len ( names ) ) : <TAB> <TAB> for i in range ( len ( names [ bRow ] ) ) : <TAB> <TAB> <TAB> t = names [ bRow ] [ i ] <TAB> <TAB> <TAB> if funcs is None : <TAB> <TAB> <TAB> <TAB> tempFunc = None <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> tempFunc = funcs [ bRow ] [ i ] <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> tempFunc = singleFunc <TAB> <TAB> <TAB> but = self. _buildButton ( t, tempFunc, frame ) <TAB> <TAB> <TAB> but. grid ( row = bRow, column = i, sticky = sticky ) <TAB> <TAB> <TAB> Grid. columnconfigure ( frame, i, weight = 1 ) <TAB> <TAB> <TAB> Grid. rowconfigure ( frame, bRow, weight = 1 ) <TAB> <TAB> <TAB> frame. theWidgets. append ( but ) <TAB> self. _positionWidget (",False,singleFunc is None,"isinstance(funcs[bRow], list)",0.664440393447876
|
||
|
2768,"def kwargs ( self ) : <TAB> kwargs = { } <TAB> kwargs_started = False <TAB> for param_name, param in self. _signature. parameters. items ( ) : <TAB> <TAB> if not kwargs_started : <TAB> <TAB> <TAB> if param. kind in ( _VAR_KEYWORD, _KEYWORD_ONLY ) or param. _partial_kwarg : <TAB> <TAB> <TAB> <TAB> kwargs_started = True <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> kwargs_started = True <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> if not kwargs_started : <TAB> <TAB> <TAB> continue <TAB> <TAB> try : <TAB> <TAB> <TAB> arg = self. arguments [ param_name ] <TAB> <TAB> except KeyError : <TAB> <TAB> <TAB> pass <TAB> <TAB> else : <TAB> <TAB> <TAB> if param. kind == _VAR_KEYWORD : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> kwargs. update ( arg ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> kwargs [ param_name ] = arg <TAB> return kwargs",False,param_name not in self.arguments,param_name == _TAB_ONLY,0.6635857820510864
|
||
|
2769,"def dump_constants ( header ) : <TAB> output = StringIO. StringIO ( ) <TAB> output. write ( header ) <TAB> for attribute in dir ( FSEvents ) : <TAB> <TAB> value = getattr ( FSEvents, attribute ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> output. write ( "" %s = %s\n"" % ( attribute, hex ( value ) ) ) <TAB> content = output. getvalue ( ) <TAB> output. close ( ) <TAB> return content",False,"attribute.startswith('k') and isinstance(value, int)",value,0.650115966796875
|
||
|
2770,def _increment_bracket_num ( self ) : <TAB> self. _current_bracket -= 1 <TAB> if self. _current_bracket < 0 : <TAB> <TAB> self. _current_bracket = self. _get_num_brackets ( ) - 1 <TAB> <TAB> self. _current_iteration += 1 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _current_bracket = 0,False,self._current_iteration > self.hyperband_iterations,self._current_bracket == self._get_num_brackets() - 1,0.6543223857879639
|
||
|
2771,"def pop ( self ) : <TAB> """"""Pop a nonterminal. (Internal)"""""" <TAB> popdfa, popstate, popnode = self. stack. pop ( ) <TAB> newnode = self. convert ( self. grammar, popnode ) <TAB> if newnode is not None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> dfa, state, node = self. stack [ - 1 ] <TAB> <TAB> <TAB> node. children. append ( newnode ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. rootnode = newnode",False,self.stack,len(self.stack) > 1,0.6616175174713135
|
||
|
2772,"def reduce_large ( self, f, init ) : <TAB> for x in range ( self. _cnt ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return rt. deref ( init ) <TAB> <TAB> init = f. invoke ( [ init, rt. wrap ( ord ( self. _buffer [ x ] ) ) ] ) <TAB> return init",False,rt.reduced_QMARK_(init),x == len(self._buffer) - 1,0.6566939353942871
|
||
|
2773,"def _name ( <TAB> self, <TAB> v, <TAB> current_klass, <TAB> return_none_for_module = False, <TAB> optlocal_var = False, ) : <TAB> if not hasattr ( v, ""name"" ) : <TAB> <TAB> name = v. attrname <TAB> else : <TAB> <TAB> name = v. name <TAB> name_type, pyname, jsname, depth, is_local = self. lookup ( name ) <TAB> if name_type is None : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return self. scopeName ( name, depth, is_local ) <TAB> <TAB> return '(typeof %s == ""undefined""?%s:%s)' % ( <TAB> <TAB> <TAB> name, <TAB> <TAB> <TAB> self. scopeName ( name, depth, is_local ), <TAB> <TAB> <TAB> name, <TAB> <TAB> ) <TAB> return jsname",False,not optlocal_var,depth > 0 and is_local,0.654523491859436
|
||
|
2774,"def getFingerprint ( self ) : <TAB> value = """" <TAB> wsOsFp = Format. getOs ( ""web server"", kb. headersFp ) <TAB> if wsOsFp and not hasattr ( conf, ""api"" ) : <TAB> <TAB> value += ""%s\n"" % wsOsFp <TAB> if kb. data. banner : <TAB> <TAB> dbmsOsFp = Format. getOs ( ""back-end DBMS"", kb. bannerFp ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> value += ""%s\n"" % dbmsOsFp <TAB> value += ""back-end DBMS: "" <TAB> actVer = Format. getDbms ( ) <TAB> if not conf. extensiveFp : <TAB> <TAB> value += actVer <TAB> <TAB> return value <TAB> comVer = self. _commentCheck ( ) <TAB> blank = "" "" * 15 <TAB> value += ""active fingerprint: %s"" % actVer <TAB> if comVer : <TAB> <TAB> comVer = Format. getDbms ( [ comVer ] ) <TAB> <TAB> value += ""\n%scomment injection fingerprint: %s"" % ( blank, comVer ) <TAB> if kb. bannerFp : <TAB> <TAB> banVer = kb. bannerFp [ ""dbmsVersion"" ] if ""dbmsVersion"" in kb. bannerFp else None <TAB> <TAB> if banVer and re. search ( ""-log$"", kb. data. banner ) : <TAB> <TAB> <TAB> banVer += "", logging enabled"" <TAB> <TAB> banVer = Format. getDbms ( [ banVer ] if banVer else None ) <TAB> <TAB> value += ""\n%sbanner parsing fingerprint: %s"" % ( blank, banVer ) <TAB> htmlErrorFp = Format. getErrorParsedDBMSes ( ) <TAB> if htmlErrorFp : <TAB> <TAB> value += ""\n%shtml error message fingerprint: %s"" % ( blank, htmlErrorFp ) <TAB> return value",False,"dbmsOsFp and (not hasattr(conf, 'api'))",dbmsOsFp,0.6557803153991699
|
||
|
2775,"def get_filename ( self, prompt ) : <TAB> okay = False <TAB> val = """" <TAB> while not okay : <TAB> <TAB> val = raw_input ( ""%s: %s"" % ( prompt, val ) ) <TAB> <TAB> val = os. path. expanduser ( val ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> okay = True <TAB> <TAB> elif os. path. isdir ( val ) : <TAB> <TAB> <TAB> path = val <TAB> <TAB> <TAB> val = self. choose_from_list ( os. listdir ( path ) ) <TAB> <TAB> <TAB> if val : <TAB> <TAB> <TAB> <TAB> val = os. path. join ( path, val ) <TAB> <TAB> <TAB> <TAB> okay = True <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> val = """" <TAB> <TAB> else : <TAB> <TAB> <TAB> print ( ""Invalid value: %s"" % val ) <TAB> <TAB> <TAB> val = """" <TAB> return val",False,os.path.isfile(val),val,0.6499718427658081
|
||
|
2776,"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. txn_high_water_mark = iprot. readI64 ( ) <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. open_txns = [ ] <TAB> <TAB> <TAB> <TAB> ( _etype381, _size378 ) = iprot. readListBegin ( ) <TAB> <TAB> <TAB> <TAB> for _i382 in xrange ( _size378 ) : <TAB> <TAB> <TAB> <TAB> <TAB> _elem383 = TxnInfo ( ) <TAB> <TAB> <TAB> <TAB> <TAB> _elem383. read ( iprot ) <TAB> <TAB> <TAB> <TAB> <TAB> self. open_txns. append ( _elem383 ) <TAB> <TAB> <TAB> <TAB> iprot. readListEnd ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip",False,ftype == TType.LIST,self.open_txns is None,0.6645516753196716
|
||
|
2777,"def _read_filter ( self, data ) : <TAB> if data : <TAB> <TAB> if self. expected_inner_sha256 : <TAB> <TAB> <TAB> self. inner_sha. update ( data ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. inner_md5. update ( data ) <TAB> return data",False,self.expected_inner_md5sum,self.expected_inner_md5,0.6514483690261841
|
||
|
2778,"def generate_certificate ( self ) : <TAB> LOG. debug ( ""Generating certificate for communication with fabric..."" ) <TAB> if self. certificate is not None : <TAB> <TAB> LOG. debug ( ""Certificate already generated."" ) <TAB> <TAB> return <TAB> with cd ( self. tmpdir ) : <TAB> <TAB> subp. subp ( <TAB> <TAB> <TAB> [ <TAB> <TAB> <TAB> <TAB> ""openssl"", <TAB> <TAB> <TAB> <TAB> ""req"", <TAB> <TAB> <TAB> <TAB> ""-x509"", <TAB> <TAB> <TAB> <TAB> ""-nodes"", <TAB> <TAB> <TAB> <TAB> ""-subj"", <TAB> <TAB> <TAB> <TAB> ""/CN=LinuxTransport"", <TAB> <TAB> <TAB> <TAB> ""-days"", <TAB> <TAB> <TAB> <TAB> ""32768"", <TAB> <TAB> <TAB> <TAB> ""-newkey"", <TAB> <TAB> <TAB> <TAB> ""rsa:2048"", <TAB> <TAB> <TAB> <TAB> ""-keyout"", <TAB> <TAB> <TAB> <TAB> self. certificate_names [ ""private_key"" ], <TAB> <TAB> <TAB> <TAB> ""-out"", <TAB> <TAB> <TAB> <TAB> self. certificate_names [ ""certificate"" ], <TAB> <TAB> <TAB> ] <TAB> <TAB> ) <TAB> <TAB> certificate = """" <TAB> <TAB> for line in open ( self. certificate_names [ ""certificate"" ] ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> certificate += line. rstrip ( ) <TAB> <TAB> self. certificate = certificate <TAB> LOG. debug ( ""New certificate generated."" )",False,'CERTIFICATE' not in line,line,0.6641044020652771
|
||
|
2779,"def GeneratePageMetatadata ( self, task ) : <TAB> address_space = self. session. GetParameter ( ""default_address_space"" ) <TAB> for vma in task. mm. mmap. walk_list ( ""vm_next"" ) : <TAB> <TAB> start = vma. vm_start <TAB> <TAB> end = vma. vm_end <TAB> <TAB> <TAB> <TAB> if end < self. plugin_args. start : <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> if start > self. plugin_args. end : <TAB> <TAB> <TAB> break <TAB> <TAB> for vaddr in utils. xrange ( start, end, 0x1000 ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> yield vaddr, self. _CreateMetadata ( address_space. describe_vtop ( vaddr ) )",False,self.plugin_args.start <= vaddr <= self.plugin_args.end,vaddr,0.651207685470581
|
||
|
2780,"def write ( self, filename = None, trusted = False ) : <TAB> if not filename and not self. filename : <TAB> <TAB> raise ParsingError ( ""File not found"", """" ) <TAB> if filename : <TAB> <TAB> self. filename = filename <TAB> else : <TAB> <TAB> filename = self. filename <TAB> if os. path. dirname ( filename ) and not os. path. isdir ( os. path. dirname ( filename ) ) : <TAB> <TAB> os. makedirs ( os. path. dirname ( filename ) ) <TAB> with io. open ( filename, ""w"", encoding = ""utf-8"" ) as fp : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if trusted : <TAB> <TAB> <TAB> fp. write ( u ( ""#!/usr/bin/env xdg-open\n"" ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> fp. write ( u ( ""[%s]\n"" ) % self. defaultGroup ) <TAB> <TAB> <TAB> for ( key, value ) in self. content [ self. defaultGroup ]. items ( ) : <TAB> <TAB> <TAB> <TAB> fp. write ( u ( ""%s=%s\n"" ) % ( key, value ) ) <TAB> <TAB> <TAB> fp. write ( u ( ""\n"" ) ) <TAB> <TAB> for ( name, group ) in self. content. items ( ) : <TAB> <TAB> <TAB> if name!= self. defaultGroup : <TAB> <TAB> <TAB> <TAB> fp. write ( u ( ""[%s]\n"" ) % name ) <TAB> <TAB> <TAB> <TAB> for ( key, value ) in group. items ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> fp. write ( u ( ""%s=%s\n"" ) % ( key, value ) ) <TAB> <TAB> <TAB> <TAB> fp. write ( u ( ""\n"" ) ) <TAB> <TAB> if trusted : <TAB> <TAB> oldmode = os. stat ( filename ). st",False,self.defaultGroup,self.defaultGroup != None,0.6554144620895386
|
||
|
2781,"def release ( self ) : <TAB> tid = _thread. get_ident ( ) <TAB> with self. lock : <TAB> <TAB> if self. owner!= tid : <TAB> <TAB> <TAB> raise RuntimeError ( ""cannot release un-acquired lock"" ) <TAB> <TAB> assert self. count > 0 <TAB> <TAB> self. count -= 1 <TAB> <TAB> if self. count == 0 : <TAB> <TAB> <TAB> self. owner = None <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. waiters -= 1 <TAB> <TAB> <TAB> <TAB> self. wakeup. release ( )",False,self.waiters,self.waiting,0.6649203896522522
|
||
|
2782,"def _execute_file ( self, cmd, executor_class ) : <TAB> self. _check_update_tty_mode ( cmd ) <TAB> if len ( cmd. args ) >= 1 : <TAB> <TAB> sys. argv = cmd. args <TAB> <TAB> filename = cmd. args [ 0 ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> full_filename = filename <TAB> <TAB> else : <TAB> <TAB> <TAB> full_filename = os. path. abspath ( filename ) <TAB> <TAB> if full_filename == ""-c"" : <TAB> <TAB> <TAB> source = cmd. source <TAB> <TAB> else : <TAB> <TAB> <TAB> with tokenize. open ( full_filename ) as fp : <TAB> <TAB> <TAB> <TAB> source = fp. read ( ) <TAB> <TAB> for preproc in self. _source_preprocessors : <TAB> <TAB> <TAB> source = preproc ( source, cmd ) <TAB> <TAB> result_attributes = self. _execute_source ( <TAB> <TAB> <TAB> source, full_filename, ""exec"", executor_class, cmd, self. _ast_postprocessors <TAB> <TAB> ) <TAB> <TAB> result_attributes [ ""filename"" ] = full_filename <TAB> <TAB> return ToplevelResponse ( command_name = cmd. name, ** result_attributes ) <TAB> else : <TAB> <TAB> raise UserError ( ""Command '%s' takes at least one argument"" % cmd. name )",False,filename == '-c' or os.path.isabs(filename),"isinstance(filename, basestring)",0.649771511554718
|
||
|
2783,"def check_status ( self ) : <TAB> cache = caches [ self. backend ] <TAB> try : <TAB> <TAB> cache. set ( ""djangohealtcheck_test"", ""itworks"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ServiceUnavailable ( ""Cache key does not match"" ) <TAB> except CacheKeyWarning as e : <TAB> <TAB> self. add_error ( ServiceReturnedUnexpectedResult ( ""Cache key warning"" ), e ) <TAB> except ValueError as e : <TAB> <TAB> self. add_error ( ServiceReturnedUnexpectedResult ( ""ValueError"" ), e ) <TAB> except ConnectionError as e : <TAB> <TAB> self. add_error ( ServiceReturnedUnexpectedResult ( ""Connection Error"" ), e )",False,not cache.get('djangohealtcheck_test') == 'itworks',cache.get(self.backend) is None,0.6523085832595825
|
||
|
2784,"def apply ( self ) : <TAB> for compound in self. document. traverse ( nodes. compound ) : <TAB> <TAB> first_child = 1 <TAB> <TAB> for child in compound : <TAB> <TAB> <TAB> if first_child : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> first_child = 0 <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> child [ ""classes"" ]. append ( ""continued"" ) <TAB> <TAB> <TAB> <TAB> compound. replace_self ( compound [ : ] )",False,"not isinstance(child, nodes.Invisible)",child['classes'],0.6475175619125366
|
||
|
2785,"def apply_search ( self, search_term ) : <TAB> """"""Creates a query based on the model's search_allowed_fields"""""" <TAB> if not hasattr ( self. queryset. model, ""search_allowed_fields"" ) : <TAB> <TAB> raise Exception ( <TAB> <TAB> <TAB> ""Search fields aren't defined in the model %s"" % self. queryset. model <TAB> <TAB> ) <TAB> search_queries = None <TAB> for st in search_term. split ( "" "" ) : <TAB> <TAB> queries = None <TAB> <TAB> for field in self. queryset. model. search_allowed_fields : <TAB> <TAB> <TAB> query = Q ( ** { field + ""__icontains"" : st } ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> queries |= query <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> queries = query <TAB> <TAB> if search_queries : <TAB> <TAB> <TAB> search_queries &= queries <TAB> <TAB> else : <TAB> <TAB> <TAB> search_queries = queries <TAB> self. queryset = self. queryset. filter ( search_queries )",False,queries,query,0.720841646194458
|
||
|
2786,"def authenticate ( self, username = None, password = None ) : <TAB> username = force_username_case ( username ) <TAB> request = None <TAB> user = super ( AllowFirstUserDjangoBackend, self ). authenticate ( <TAB> <TAB> request, username = username, password = password <TAB> ) <TAB> if user is not None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> user = rewrite_user ( user ) <TAB> <TAB> <TAB> return user <TAB> <TAB> return user <TAB> if self. is_first_login_ever ( ) : <TAB> <TAB> user = find_or_create_user ( username, password ) <TAB> <TAB> user = rewrite_user ( user ) <TAB> <TAB> userprofile = get_profile ( user ) <TAB> <TAB> userprofile. first_login = False <TAB> <TAB> userprofile. save ( ) <TAB> <TAB> ensure_has_a_group ( user ) <TAB> <TAB> return user <TAB> return None",False,user.is_active,self.is_authenticated_user(user),0.6540259122848511
|
||
|
2787,"def compute_acq ( <TAB> self, x : np. ndarray, model : Optional [ SurrogateModel ] = None ) -> np. ndarray : <TAB> if model is None : <TAB> <TAB> model = self. model <TAB> predictions_list = model. predict_nd ( model. convert_np_to_nd ( x ) ) <TAB> fvals_list = [ ] <TAB> for mean, std in predictions_list : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> current_best = model. convert_np_to_nd ( model. current_best ( ) ). reshape ( ( 1, - 1 ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> current_best = None <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> do_avg = mean. ndim == 2 and mean. shape [ 1 ] > 1 <TAB> <TAB> if do_avg : <TAB> <TAB> <TAB> assert ( <TAB> <TAB> <TAB> <TAB> mean. shape [ 1 ] == current_best. size <TAB> <TAB> <TAB> ), ""mean.shape[1] = {}, current_best.size = {} (must be the same)"". format ( <TAB> <TAB> <TAB> <TAB> mean. shape [ 1 ], current_best. size <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> std = std. reshape ( ( - 1, 1 ) ) <TAB> <TAB> fvals = self. _compute_head ( mean, std, current_best ) <TAB> <TAB> if do_avg : <TAB> <TAB> <TAB> fvals = mx. nd. mean ( fvals, axis = 1 ) <TAB> <TAB> fvals_list. append ( fvals. asnumpy ( ). astype ( x. dtype, copy = False ) ) <TAB> return np. mean ( fvals_list, axis = 0 )",False,self._head_needs_current_best(),model is not None,0.6518842577934265
|
||
|
2788,"def test_get_output_for ( self, dummy_input_layer, extra_kwargs ) : <TAB> from lasagne. layers. dense import NINLayer <TAB> nonlinearity = Mock ( ) <TAB> layer = NINLayer ( <TAB> <TAB> dummy_input_layer, num_units = 6, nonlinearity = nonlinearity, ** extra_kwargs <TAB> ) <TAB> input = theano. shared ( np. random. uniform ( - 1, 1, ( 2, 3, 4, 5 ) ) ) <TAB> result = layer. get_output_for ( input ) <TAB> assert result is nonlinearity. return_value <TAB> nonlinearity_arg = nonlinearity. call_args [ 0 ] [ 0 ] <TAB> X = input. get_value ( ) <TAB> X = np. rollaxis ( X, 1 ). T <TAB> X = np. dot ( X, layer. W. get_value ( ) ) <TAB> if layer. b is not None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> X += layer. b. get_value ( ) [ :, np. newaxis ]. T <TAB> <TAB> else : <TAB> <TAB> <TAB> X += layer. b. get_value ( ) <TAB> X = np. rollaxis ( X. T, 0, 2 ) <TAB> assert np. allclose ( nonlinearity_arg. eval ( ), X )",False,layer.untie_biases,dummy_input_layer.num_units == 3,0.6486664414405823
|
||
|
2789,"def _animateImage ( self, title, firstTime = False ) : <TAB> if not self. alive : <TAB> <TAB> return <TAB> try : <TAB> <TAB> lab = self. widgetManager. get ( WIDGET_NAMES. Image, title ) <TAB> except ItemLookupError : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> self. widgetManager. remove ( WIDGET_NAMES. AnimationID, title ) <TAB> <TAB> except : <TAB> <TAB> <TAB> pass <TAB> <TAB> return <TAB> if not lab. image. animating : <TAB> <TAB> self. widgetManager. remove ( WIDGET_NAMES. AnimationID, title ) <TAB> <TAB> return <TAB> if firstTime and lab. image. alreadyAnimated : <TAB> <TAB> return <TAB> lab. image. alreadyAnimated = True <TAB> try : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> pic = lab. image. pics [ lab. image. anim_pos ] <TAB> <TAB> else : <TAB> <TAB> <TAB> pic = PhotoImage ( <TAB> <TAB> <TAB> <TAB> file = lab. image. path, format = ""gif - {0}"". format ( lab. image. anim_pos ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> lab. image. pics. append ( pic ) <TAB> <TAB> lab. image. anim_pos += 1 <TAB> <TAB> lab. config ( image = pic ) <TAB> <TAB> anim_id = self. topLevel. after ( <TAB> <TAB> <TAB> int ( lab. image. anim_speed ), self. _animateImage, title <TAB> <TAB> ) <TAB> <TAB> self. widgetManager. update ( WIDGET_NAMES. AnimationID, title, anim_id ) <TAB> except IndexError : <TAB> <TAB> <TAB> <TAB> lab. image. anim_pos = 0 <TAB> <TAB> lab. image. cached = True <TAB> <TAB> self. _animateImage ( title ) <TAB>",False,lab.image.cached,lab.image.animating,0.6595226526260376
|
||
|
2790,"def parse_special_directives ( setup_entry, package_dir = None ) : <TAB> <TAB> rv = setup_entry <TAB> if not package_dir : <TAB> <TAB> package_dir = os. getcwd ( ) <TAB> if setup_entry. startswith ( ""file:"" ) : <TAB> <TAB> _, path = setup_entry. split ( ""file:"" ) <TAB> <TAB> path = path. strip ( ) <TAB> <TAB> if os. path. exists ( path ) : <TAB> <TAB> <TAB> rv = read_source ( path ) <TAB> elif setup_entry. startswith ( ""attr:"" ) : <TAB> <TAB> _, resource = setup_entry. split ( ""attr:"" ) <TAB> <TAB> resource = resource. strip ( ) <TAB> <TAB> with temp_path ( ) : <TAB> <TAB> <TAB> sys. path. insert ( 0, package_dir ) <TAB> <TAB> <TAB> if ""."" in resource : <TAB> <TAB> <TAB> <TAB> resource, _, attribute = resource. rpartition ( ""."" ) <TAB> <TAB> <TAB> package, _, path = resource. partition ( ""."" ) <TAB> <TAB> <TAB> base_path = os. path. join ( package_dir, package ) <TAB> <TAB> <TAB> if path : <TAB> <TAB> <TAB> <TAB> path = os. path. join ( base_path, os. path. join ( * path. split ( ""."" ) ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> path = base_path <TAB> <TAB> <TAB> if not os. path. exists ( path ) and os. path. exists ( ""{0}.py"". format ( path ) ) : <TAB> <TAB> <TAB> <TAB> path = ""{0}.py"". format ( path ) <TAB> <TAB> <TAB> elif os. path. isdir ( path ) : <TAB> <TAB> <TAB> <TAB> path = os. path. join ( path, ""__init__.py"" ) <TAB> <TAB> <TAB> rv = ast_parse_attribute_from_file (",False,"not isinstance(rv, six.string_types)",rv,0.6429933309555054
|
||
|
2791,"def _get_exclude_file ( self, read_write ) : <TAB> if not os. path. exists ( self. _exclude_file_path ) and read_write. startswith ( ""r"" ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> os. makedirs ( self. _settings_directory ) <TAB> <TAB> return open ( self. _exclude_file_path, ""w+"" ) <TAB> if os. path. isdir ( self. _exclude_file_path ) : <TAB> <TAB> raise NameError ( '""%s"" is a directory, not file' % self. _exclude_file_path ) <TAB> try : <TAB> <TAB> return open ( self. _exclude_file_path, read_write ) <TAB> except IOError as e : <TAB> <TAB> raise e",False,not os.path.isdir(self._settings_directory),not os.path.exists(self._exclude_file_path),0.6465321779251099
|
||
|
2792,"def __getitem__ ( self, index ) : <TAB> if isinstance ( index, ( int, np. integer ) ) : <TAB> <TAB> if self. restrict_array is None : <TAB> <TAB> <TAB> glob_index = index <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> glob_index = self. restrict_array [ index ] <TAB> <TAB> if glob_index not in self. rows : <TAB> <TAB> <TAB> self. rows [ glob_index ] = self. get_row ( glob_index ) <TAB> <TAB> row = self. rows [ glob_index ] <TAB> <TAB> if self. restrict_array is None : <TAB> <TAB> <TAB> return row <TAB> <TAB> else : <TAB> <TAB> <TAB> return row [ self. restrict_array ] <TAB> else : <TAB> <TAB> if self. restrict_array is None : <TAB> <TAB> <TAB> glob_index_0, glob_index_1 = index <TAB> <TAB> else : <TAB> <TAB> <TAB> glob_index_0 = self. restrict_array [ index [ 0 ] ] <TAB> <TAB> <TAB> glob_index_1 = self. restrict_array [ index [ 1 ] ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. rows [ glob_index_0 ] = self. get_row ( glob_index_0 ) <TAB> <TAB> return self. rows [ glob_index_0 ] [ glob_index_1 ]",True,glob_index_0 not in self.rows,glob_index_0 not in self.rows,0.6602480411529541
|
||
|
2793,"def filter_index ( self, index, name, value ) : <TAB> operations = { <TAB> <TAB> ""~"" : lambda i, value : isinstance ( i. value, six. string_types ) <TAB> <TAB> and i. value. startswith ( web. rstrips ( value, ""*"" ) ), <TAB> <TAB> ""<"" : lambda i, value : i. value < value, <TAB> <TAB> "">"" : lambda i, value : i. value > value, <TAB> <TAB> ""!"" : lambda i, value : i. value!= value, <TAB> <TAB> ""="" : lambda i, value : i. value == value, <TAB> } <TAB> pattern = "".*([%s])$"" % """". join ( operations ) <TAB> rx = web. re_compile ( pattern ) <TAB> m = rx. match ( name ) <TAB> if m : <TAB> <TAB> op = m. group ( 1 ) <TAB> <TAB> name = name [ : - 1 ] <TAB> else : <TAB> <TAB> op = ""="" <TAB> f = operations [ op ] <TAB> if name == ""isbn_"" : <TAB> <TAB> names = [ ""isbn_10"", ""isbn_13"" ] <TAB> else : <TAB> <TAB> names = [ name ] <TAB> if isinstance ( value, list ) : <TAB> <TAB> for n in names : <TAB> <TAB> <TAB> for i in index : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> yield i. key <TAB> else : <TAB> <TAB> for n in names : <TAB> <TAB> <TAB> for i in index : <TAB> <TAB> <TAB> <TAB> if i. name == n and f ( i, value ) : <TAB> <TAB> <TAB> <TAB> <TAB> yield i. key",False,"i.name == n and any((f(i, v) for v in value))","i.name == n and f(i, value)",0.6521011590957642
|
||
|
2794,"def construct_mapping ( loader, node, deep = False ) : <TAB> loader. flatten_mapping ( node ) <TAB> mapping = OrderedDict ( ) <TAB> merged_duplicate = { } <TAB> for key_node, value_node in node. value : <TAB> <TAB> key = loader. construct_object ( key_node, deep = deep ) <TAB> <TAB> value = loader. construct_object ( value_node, deep = deep ) <TAB> <TAB> if key in mapping : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise ConstructorError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""while constructing a mapping"", <TAB> <TAB> <TAB> <TAB> <TAB> node. start_mark, <TAB> <TAB> <TAB> <TAB> <TAB> ""found duplicated key (%s)"" % key, <TAB> <TAB> <TAB> <TAB> <TAB> key_node. start_mark, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> log. debug ( ""Merging values for duplicate key '%s' into a list"", key ) <TAB> <TAB> <TAB> if merged_duplicate. get ( key ) : <TAB> <TAB> <TAB> <TAB> mapping [ key ]. append ( value ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> mapping [ key ] = [ mapping [ key ], value ] <TAB> <TAB> <TAB> <TAB> merged_duplicate [ key ] = True <TAB> <TAB> else : <TAB> <TAB> <TAB> mapping [ key ] = value <TAB> return mapping",False,not merge_duplicate_keys,not merged_duplicate[key],0.6561044454574585
|
||
|
2795,"def get_tweets ( twitter, screen_name, max_id = None ) : <TAB> kwargs = dict ( count = 3200, screen_name = screen_name ) <TAB> if max_id : <TAB> <TAB> kwargs [ ""max_id"" ] = max_id <TAB> n_tweets = 0 <TAB> tweets = twitter. statuses. user_timeline ( ** kwargs ) <TAB> for tweet in tweets : <TAB> <TAB> if tweet [ ""id"" ] == max_id : <TAB> <TAB> <TAB> continue <TAB> <TAB> print ( <TAB> <TAB> <TAB> ""%s %s\nDate: %s"" <TAB> <TAB> <TAB> % ( tweet [ ""user"" ] [ ""screen_name"" ], tweet [ ""id"" ], tweet [ ""created_at"" ] ) <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> print ( ""In-Reply-To: %s"" % tweet [ ""in_reply_to_status_id"" ] ) <TAB> <TAB> print ( ) <TAB> <TAB> for line in tweet [ ""text"" ]. splitlines ( ) : <TAB> <TAB> <TAB> printNicely ( "" "" + line + ""\n"" ) <TAB> <TAB> print ( ) <TAB> <TAB> print ( ) <TAB> <TAB> max_id = tweet [ ""id"" ] <TAB> <TAB> n_tweets += 1 <TAB> return n_tweets, max_id",False,tweet.get('in_reply_to_status_id'),tweets['in_reply_to_status_id'],0.6500918865203857
|
||
|
2796,"def step ( self, metric, auxiliary_metric = None ) : <TAB> <TAB> current = float ( metric ) <TAB> epoch = self. last_epoch + 1 <TAB> self. last_epoch = epoch <TAB> is_better = False <TAB> if self. mode == ""min"" : <TAB> <TAB> if current < self. best : <TAB> <TAB> <TAB> is_better = True <TAB> if self. mode == ""max"" : <TAB> <TAB> if current > self. best : <TAB> <TAB> <TAB> is_better = True <TAB> if current == self. best and auxiliary_metric : <TAB> <TAB> current_aux = float ( auxiliary_metric ) <TAB> <TAB> if self. aux_mode == ""min"" : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> is_better = True <TAB> <TAB> if self. aux_mode == ""max"" : <TAB> <TAB> <TAB> if current_aux > self. best_aux : <TAB> <TAB> <TAB> <TAB> is_better = True <TAB> if is_better : <TAB> <TAB> self. best = current <TAB> <TAB> if auxiliary_metric : <TAB> <TAB> <TAB> self. best_aux = auxiliary_metric <TAB> <TAB> self. num_bad_epochs = 0 <TAB> else : <TAB> <TAB> self. num_bad_epochs += 1 <TAB> if self. in_cooldown : <TAB> <TAB> self. cooldown_counter -= 1 <TAB> <TAB> self. num_bad_epochs = 0 <TAB> if self. num_bad_epochs > self. effective_patience : <TAB> <TAB> self. _reduce_lr ( epoch ) <TAB> <TAB> self. cooldown_counter = self. cooldown <TAB> <TAB> self. num_bad_epochs = 0 <TAB> <TAB> self. effective_patience = self. default_patience <TAB> self. _last_lr = [ group [ ""lr"" ] for group in self. optimizer. param_",False,current_aux < self.best_aux,current_aux > auxiliary_metric,0.6572489738464355
|
||
|
2797,"def do_begin ( self, byte ) : <TAB> if byte. isspace ( ) : <TAB> <TAB> return <TAB> if byte!= ""<"" : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _leadingBodyData = byte <TAB> <TAB> <TAB> return ""bodydata"" <TAB> <TAB> self. _parseError ( ""First char of document [{!r}] wasn't <"". format ( byte ) ) <TAB> return ""tagstart""",False,self.beExtremelyLenient,"byte == ""<TAB> <TAB > or byte == ""<TAB> or (byte == "">"")",0.6560404896736145
|
||
|
2798,"def merge ( self, img, back, M, O, mode, shape, win, lookup ) : <TAB> if img. ndim == 2 : <TAB> <TAB> rstarr = np. zeros ( shape, dtype = img. dtype ) <TAB> <TAB> my_transform ( img, M, offset = O, output = rstarr, k = 1, clip = False ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> rstarr = np. abs ( rstarr ) <TAB> <TAB> rstarr = lookup ( rstarr ) <TAB> if img. ndim == 3 : <TAB> <TAB> rstarr = np. zeros ( ( win [ 3 ], win [ 2 ], 3 ), dtype = img. dtype ) <TAB> <TAB> for i in range ( 3 ) : <TAB> <TAB> <TAB> my_transform ( <TAB> <TAB> <TAB> <TAB> img [ :, :, i ], M, offset = O, output = rstarr [ :, :, i ], k = 1, clip = False <TAB> <TAB> <TAB> ) <TAB> if not back is None : <TAB> <TAB> for i in range ( 3 ) : <TAB> <TAB> <TAB> my_transform ( <TAB> <TAB> <TAB> <TAB> back [ :, :, i ] if back. ndim == 3 else back, <TAB> <TAB> <TAB> <TAB> M, <TAB> <TAB> <TAB> <TAB> offset = O, <TAB> <TAB> <TAB> <TAB> output = rstarr [ :, :, i ], <TAB> <TAB> <TAB> <TAB> k = mode [ 0 ], <TAB> <TAB> <TAB> <TAB> clip = mode [ 1 ] == ""Clip"", <TAB> <TAB> <TAB> ) <TAB> return rstarr",False,rstarr.dtype == np.complex128,lookup is not None,0.6585299968719482
|
||
|
2799,"def tags ( ) : <TAB> """"""Return a dictionary of all tags in the form {hash: [tag_names,...]}."""""" <TAB> tags = { } <TAB> for ( n, c ) in list_refs ( ) : <TAB> <TAB> if n. startswith ( ""refs/tags/"" ) : <TAB> <TAB> <TAB> name = n [ 10 : ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> tags [ c ] = [ ] <TAB> <TAB> <TAB> tags [ c ]. append ( name ) <TAB> return tags",False,not c in tags,c not in tags,0.6735615134239197
|
||
|
2800,"def run ( ) : <TAB> sem = asyncio. Semaphore ( threads ) <TAB> futures = [ ] <TAB> for task in task_list : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> futures. append ( <TAB> <TAB> <TAB> <TAB> asyncio. ensure_future ( <TAB> <TAB> <TAB> <TAB> <TAB> bound_fetch_sync ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> sem, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> task. get ( ""fn"" ), <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> task. get ( ""args"", ( ) ), <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> task. get ( ""kwargs"", { } ), <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> futures. append ( <TAB> <TAB> <TAB> <TAB> asyncio. ensure_future ( <TAB> <TAB> <TAB> <TAB> <TAB> bound_fetch ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> sem, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> task. get ( ""fn"" ), <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> task. get ( ""args"", ( ) ), <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> task. get ( ""kwargs"", { } ), <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> responses = asyncio. gather ( * futures ) <TAB> return await responses",False,sync,task == 'TAB > <TAB > 0,0.6873525381088257
|
||
|
2801,"def show_top_status ( self ) : <TAB> """"""Show top status row."""""" <TAB> self. header_win. erase ( ) <TAB> size = self. get_size ( ) <TAB> display = self. app. config [ ""display"" ] <TAB> head_parts = [ ] <TAB> if display [ ""show_app_name"" ] : <TAB> <TAB> name_str = ""Suplemon Editor v{0} -"". format ( self. app. version ) <TAB> <TAB> if self. app. config [ ""app"" ] [ ""use_unicode_symbols"" ] : <TAB> <TAB> <TAB> logo = ""\U0001f34b"" <TAB> <TAB> <TAB> name_str = "" {0} {1}"". format ( logo, name_str ) <TAB> <TAB> head_parts. append ( name_str ) <TAB> <TAB> module_keys = sorted ( self. app. modules. modules. keys ( ) ) <TAB> for name in module_keys : <TAB> <TAB> module = self. app. modules. modules [ name ] <TAB> <TAB> if module. options [ ""status"" ] == ""top"" : <TAB> <TAB> <TAB> status = module. get_status ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> head_parts. append ( status ) <TAB> if display [ ""show_file_list"" ] : <TAB> <TAB> head_parts. append ( self. file_list_str ( ) ) <TAB> head = "" "". join ( head_parts ) <TAB> head = head + ( "" "" * ( size [ 0 ] - wcswidth ( head ) - 1 ) ) <TAB> head_width = wcswidth ( head ) <TAB> if head_width > size [ 0 ] : <TAB> <TAB> head = head [ : size [ 0 ] - head_width ] <TAB> try : <TAB> <TAB> if self. app. config [ ""display"" ] [ ""invert_status_bars"" ] : <TAB> <TAB> <TAB> self. header_win. addstr ( 0, 0, head, curses. color_pair ( 0",True,status,status,0.687002956867218
|
||
|
2802,"def _norm_ident ( self, ident ) : <TAB> <TAB> if ident is None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise TypeError ( ""no ident specified"" ) <TAB> <TAB> ident = self. default_ident <TAB> <TAB> assert ident is not None, ""class must define default_ident"" <TAB> <TAB> if isinstance ( ident, bytes ) : <TAB> <TAB> ident = ident. decode ( ""ascii"" ) <TAB> <TAB> iv = self. ident_values <TAB> if ident in iv : <TAB> <TAB> return ident <TAB> <TAB> ia = self. ident_aliases <TAB> if ia : <TAB> <TAB> try : <TAB> <TAB> <TAB> value = ia [ ident ] <TAB> <TAB> except KeyError : <TAB> <TAB> <TAB> pass <TAB> <TAB> else : <TAB> <TAB> <TAB> if value in iv : <TAB> <TAB> <TAB> <TAB> return value <TAB> <TAB> raise ValueError ( ""invalid ident: %r"" % ( ident, ) )",False,not self.use_defaults,self.default_ident is None,0.6577395796775818
|
||
|
2803,"def undefined_symbols ( self ) : <TAB> result = [ ] <TAB> for p in self. Productions : <TAB> <TAB> if not p : <TAB> <TAB> <TAB> continue <TAB> <TAB> for s in p. prod : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> result. append ( ( s, p ) ) <TAB> return result",False,not s in self.Prodnames and (not s in self.Terminals) and (s != 'error'),s not in result,0.6574870347976685
|
||
|
2804,"def log_print ( self, destination, path, timestamp, print_time, success, printer_profile ) : <TAB> try : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _storage ( destination ). add_history ( <TAB> <TAB> <TAB> <TAB> path, <TAB> <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> <TAB> ""timestamp"" : timestamp, <TAB> <TAB> <TAB> <TAB> <TAB> ""printTime"" : print_time, <TAB> <TAB> <TAB> <TAB> <TAB> ""success"" : success, <TAB> <TAB> <TAB> <TAB> <TAB> ""printerProfile"" : printer_profile, <TAB> <TAB> <TAB> <TAB> }, <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. _storage ( destination ). add_history ( <TAB> <TAB> <TAB> <TAB> path, <TAB> <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> <TAB> ""timestamp"" : timestamp, <TAB> <TAB> <TAB> <TAB> <TAB> ""success"" : success, <TAB> <TAB> <TAB> <TAB> <TAB> ""printerProfile"" : printer_profile, <TAB> <TAB> <TAB> <TAB> }, <TAB> <TAB> <TAB> ) <TAB> <TAB> eventManager ( ). fire ( <TAB> <TAB> <TAB> Events. METADATA_STATISTICS_UPDATED, { ""storage"" : destination, ""path"" : path } <TAB> <TAB> ) <TAB> except NoSuchStorage : <TAB> <TAB> <TAB> <TAB> pass",False,success,self._storage is not None,0.690306544303894
|
||
|
2805,"def _is_stale ( cli_ctx, cache_obj ) : <TAB> cache_ttl = None <TAB> try : <TAB> <TAB> cache_ttl = cli_ctx. config. get ( ""core"", ""cache_ttl"" ) <TAB> except Exception as ex : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> cls_str = str ( ex. __class__ ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> cli_ctx. config. set_value ( ""core"", ""cache_ttl"", DEFAULT_CACHE_TTL ) <TAB> <TAB> <TAB> cache_ttl = DEFAULT_CACHE_TTL <TAB> <TAB> else : <TAB> <TAB> <TAB> raise ex <TAB> time_now = datetime. datetime. now ( ) <TAB> time_cache = datetime. datetime. strptime ( <TAB> <TAB> cache_obj. last_saved, ""%Y-%m-%d %H:%M:%S.%f"" <TAB> ) <TAB> return time_now - time_cache > datetime. timedelta ( minutes = int ( cache_ttl ) )",False,'NoOptionError' in cls_str or 'NoSectionError' in cls_str,cls_str == 'cache',0.6499749422073364
|
||
|
2806,"def submit ( <TAB> self, metric_name, metric_type, metric_value, metric_tags = None, options = None ) : <TAB> valid_types = [ ""COUNTER"", ""GAUGE"", ""TIMER"" ] <TAB> tags = [ ] <TAB> if metric_type. upper ( ) not in valid_types : <TAB> <TAB> raise Exception ( <TAB> <TAB> <TAB> ""Invalid Metric Type for Statsd, '{metric}' choose from: {options}"". format ( <TAB> <TAB> <TAB> <TAB> metric = metric_type, options = "","". join ( valid_types ) <TAB> <TAB> <TAB> ) <TAB> <TAB> ) <TAB> if metric_tags : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise Exception ( <TAB> <TAB> <TAB> <TAB> ""Invalid Metric Tags for Statsd: Tags must be in dict format"" <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> tags = map ( lambda e : ""{0}:{1}"". format ( * e ), metric_tags. items ( ) ) <TAB> if metric_type. upper ( ) == ""COUNTER"" : <TAB> <TAB> self. statsd. increment ( metric_name, metric_value, tags ) <TAB> elif metric_type. upper ( ) == ""GAUGE"" : <TAB> <TAB> self. statsd. gauge ( metric_name, metric_value, tags ) <TAB> elif metric_type. upper ( ) == ""TIMER"" : <TAB> <TAB> self. statsd. timing ( metric_name, metric_value, tags ) <TAB> return",False,"not isinstance(metric_tags, dict)",options and options != None,0.6506185531616211
|
||
|
2807,"def tearDown ( self ) : <TAB> if not self. is_playback ( ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. sms. delete_hosted_service ( self. hosted_service_name ) <TAB> <TAB> except : <TAB> <TAB> <TAB> pass <TAB> <TAB> try : <TAB> <TAB> <TAB> if self. storage_account_name is not None : <TAB> <TAB> <TAB> <TAB> self. sms. delete_storage_account ( self. storage_account_name ) <TAB> <TAB> except : <TAB> <TAB> <TAB> pass <TAB> <TAB> try : <TAB> <TAB> <TAB> self. sms. delete_affinity_group ( self. affinity_group_name ) <TAB> <TAB> except : <TAB> <TAB> <TAB> pass <TAB> return super ( LegacyMgmtAffinityGroupTest, self ). tearDown ( )",True,self.hosted_service_name is not None,self.hosted_service_name is not None,0.6520122289657593
|
||
|
2808,"def extend_processing ( <TAB> self, item, seconds_from_now, minimum_extension = MINIMUM_EXTENSION, updated_data = None ) : <TAB> with self. _transaction_factory ( db ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> queue_item = self. _item_by_id_for_update ( item. id ) <TAB> <TAB> <TAB> new_expiration = datetime. utcnow ( ) + timedelta ( seconds = seconds_from_now ) <TAB> <TAB> <TAB> has_change = False <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if new_expiration - queue_item. processing_expires > minimum_extension : <TAB> <TAB> <TAB> <TAB> queue_item. processing_expires = new_expiration <TAB> <TAB> <TAB> <TAB> has_change = True <TAB> <TAB> <TAB> if updated_data is not None and queue_item. body!= updated_data : <TAB> <TAB> <TAB> <TAB> queue_item. body = updated_data <TAB> <TAB> <TAB> <TAB> has_change = True <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> queue_item. save ( ) <TAB> <TAB> <TAB> return has_change <TAB> <TAB> except QueueItem. DoesNotExist : <TAB> <TAB> <TAB> return False",False,has_change,queue_item.has(),0.670048713684082
|
||
|
2809,"def render_summary ( self ) : <TAB> output = [ <TAB> <TAB> ""Check Information"", <TAB> <TAB> ""================="", <TAB> ] <TAB> label_width = max ( [ len ( label [ 1 ] ) for label in self. summary_labels ] ) <TAB> for summary_label in self. summary_labels : <TAB> <TAB> key = summary_label [ 0 ] <TAB> <TAB> if key in self. summary : <TAB> <TAB> <TAB> label = summary_label [ 1 ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> value = summary_label [ 2 ] ( self. summary [ key ] ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> value = self. summary [ key ] <TAB> <TAB> <TAB> output. append ( <TAB> <TAB> <TAB> <TAB> "" %s: %s"" <TAB> <TAB> <TAB> <TAB> % ( <TAB> <TAB> <TAB> <TAB> <TAB> label. rjust ( label_width ), <TAB> <TAB> <TAB> <TAB> <TAB> value, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> return ""\n"". join ( output )",False,len(summary_label) > 2,len(self.summary) == 3,0.6569138765335083
|
||
|
2810,"def generate ( cfg ) : <TAB> logger = logging. getLogger ( __name__ ) <TAB> chart_spec_path = cfg. opts ( ""generator"", ""chart.spec.path"", mandatory = False ) <TAB> if cfg. opts ( ""generator"", ""chart.type"" ) == ""time-series"" : <TAB> <TAB> chart_type = TimeSeriesCharts <TAB> else : <TAB> <TAB> chart_type = BarCharts <TAB> console. info ( ""Loading track data..."", flush = True ) <TAB> race_configs = load_race_configs ( cfg, chart_type, chart_spec_path ) <TAB> env = cfg. opts ( ""system"", ""env.name"" ) <TAB> structures = [ ] <TAB> console. info ( ""Generating charts..."", flush = True ) <TAB> if chart_spec_path : <TAB> <TAB> if chart_type == BarCharts : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> structures = gen_charts_per_track ( <TAB> <TAB> <TAB> <TAB> race_configs, chart_type, env, logger = logger <TAB> <TAB> <TAB> ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> structures = gen_charts_from_track_combinations ( <TAB> <TAB> <TAB> <TAB> race_configs, chart_type, env, logger <TAB> <TAB> <TAB> ) <TAB> else : <TAB> <TAB> <TAB> <TAB> structures = gen_charts_per_track ( race_configs, chart_type, env, logger = logger ) <TAB> output_path = cfg. opts ( ""generator"", ""output.path"" ) <TAB> if output_path : <TAB> <TAB> with open ( io. normalize_path ( output_path ), mode = ""wt"", encoding = ""utf-8"" ) as f : <TAB> <TAB> <TAB> print ( json. dumps ( structures, indent = 4 ), file = f ) <TAB> else : <TAB> <TAB> print ( json. dumps ( structures, indent = 4 ) )",False,chart_type == TimeSeriesCharts,chart_type == TimeSeries,0.6679071187973022
|
||
|
2811,"def _do_waitpid ( self, expected_pid ) : <TAB> assert expected_pid > 0 <TAB> try : <TAB> <TAB> pid, status = os. waitpid ( expected_pid, os. WNOHANG ) <TAB> except ChildProcessError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> pid = expected_pid <TAB> <TAB> returncode = 255 <TAB> <TAB> logger. warning ( ""Unknown child process pid %d, will report returncode 255"", pid ) <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> returncode = self. _compute_returncode ( status ) <TAB> <TAB> if self. _loop. get_debug ( ) : <TAB> <TAB> <TAB> logger. debug ( <TAB> <TAB> <TAB> <TAB> ""process %s exited with returncode %s"", expected_pid, returncode <TAB> <TAB> <TAB> ) <TAB> try : <TAB> <TAB> callback, args = self. _callbacks. pop ( pid ) <TAB> except KeyError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if self. _loop. get_debug ( ) : <TAB> <TAB> <TAB> logger. warning ( <TAB> <TAB> <TAB> <TAB> ""Child watcher got an unexpected pid: %r"", pid, exc_info = True <TAB> <TAB> <TAB> ) <TAB> else : <TAB> <TAB> callback ( pid, returncode, * args )",False,pid == 0,returncode > 0,0.6800199747085571
|
||
|
2812,"def new_thread ( request, document_slug ) : <TAB> """"""Start a new thread."""""" <TAB> doc = get_document ( document_slug, request ) <TAB> if request. method == ""GET"" : <TAB> <TAB> form = NewThreadForm ( ) <TAB> <TAB> return render ( <TAB> <TAB> <TAB> request, ""kbforums/new_thread.html"", { ""form"" : form, ""document"" : doc } <TAB> <TAB> ) <TAB> form = NewThreadForm ( request. POST ) <TAB> post_preview = None <TAB> if form. is_valid ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> thread = Thread ( creator = request. user, title = form. cleaned_data [ ""title"" ] ) <TAB> <TAB> <TAB> post_preview = Post ( <TAB> <TAB> <TAB> <TAB> thread = thread, <TAB> <TAB> <TAB> <TAB> creator = request. user, <TAB> <TAB> <TAB> <TAB> content = form. cleaned_data [ ""content"" ], <TAB> <TAB> <TAB> ) <TAB> <TAB> elif not _is_ratelimited ( request ) : <TAB> <TAB> <TAB> thread = doc. thread_set. create ( <TAB> <TAB> <TAB> <TAB> creator = request. user, title = form. cleaned_data [ ""title"" ] <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> thread. save ( ) <TAB> <TAB> <TAB> statsd. incr ( ""kbforums.thread"" ) <TAB> <TAB> <TAB> post = thread. new_post ( <TAB> <TAB> <TAB> <TAB> creator = request. user, content = form. cleaned_data [ ""content"" ] <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> post. save ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> NewThreadEvent ( post ). fire ( exclude = post. creator ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if Setting. get",False,'preview' in request.POST,'title' in form.cleaned_data,0.6592017412185669
|
||
|
2813,"def _validate_collections_param ( collections ) : <TAB> if collections is None : <TAB> <TAB> return <TAB> if not isinstance ( collections, list ) : <TAB> <TAB> raise ValueError ( ""`collections` parameter must be a list or `null`."" ) <TAB> collection_names = set ( ) <TAB> for i, collection in enumerate ( collections ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> if isinstance ( collection, ( str, bytes ) ) : <TAB> <TAB> <TAB> <TAB> collection_name = collection <TAB> <TAB> <TAB> elif isinstance ( collection, list ) : <TAB> <TAB> <TAB> <TAB> e = ValueError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Expected list of format "" <TAB> <TAB> <TAB> <TAB> <TAB> '[""config_name"", ""storage_a_name"", ""storage_b_name""]'. format ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> len ( collection ) <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> if len ( collection )!= 3 : <TAB> <TAB> <TAB> <TAB> <TAB> raise e <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> raise e <TAB> <TAB> <TAB> <TAB> for x in collection [ 1 : ] : <TAB> <TAB> <TAB> <TAB> <TAB> if x is not None and not isinstance ( x, ( str, bytes ) ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> raise e <TAB> <TAB> <TAB> <TAB> collection_name = collection [ 0 ] <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> raise ValueError ( ""Expected string or list of three strings."" ) <TAB> <TAB> <TAB> if collection_name in collection_names : <TAB> <TAB> <TAB> <TAB> raise ValueError ( ""Duplicate value."" )",False,"not isinstance(collection[0], (str, bytes))",i == 0,0.6544097661972046
|
||
|
2814,"def get_functions ( self, prefix = ""apply"", is_pymodule = False ) : <TAB> from mathics. core. parser import parse_builtin_rule <TAB> unavailable_function = self. _get_unavailable_function ( ) <TAB> for name in dir ( self ) : <TAB> <TAB> if name. startswith ( prefix ) : <TAB> <TAB> <TAB> function = getattr ( self, name ) <TAB> <TAB> <TAB> pattern = function. __doc__ <TAB> <TAB> <TAB> if pattern is None : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> m = re. match ( r""([\w,]+)\:\s*(.*)"", pattern ) <TAB> <TAB> <TAB> if m is not None : <TAB> <TAB> <TAB> <TAB> attrs = m. group ( 1 ). split ( "","" ) <TAB> <TAB> <TAB> <TAB> pattern = m. group ( 2 ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> attrs = [ ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> name = self. get_name ( ) <TAB> <TAB> <TAB> pattern = pattern % { ""name"" : name } <TAB> <TAB> <TAB> definition_class = ( <TAB> <TAB> <TAB> <TAB> PyMathicsDefinitions ( ) if is_pymodule else SystemDefinitions ( ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> pattern = parse_builtin_rule ( pattern, definition_class ) <TAB> <TAB> <TAB> if unavailable_function : <TAB> <TAB> <TAB> <TAB> function = unavailable_function <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> yield ( attrs, pattern ), function <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> yield ( pattern, function )",True,attrs,attrs,0.7127394080162048
|
||
|
2815,"def search ( self, query ) : <TAB> <TAB> if not query : <TAB> <TAB> logger. debug ( ""Empty search query"" ) <TAB> <TAB> return [ ] <TAB> logger. debug ( 'Searching TuneIn for ""%s""' % query ) <TAB> args = ""&query="" + query <TAB> search_results = self. _tunein ( ""Search.ashx"", args ) <TAB> results = [ ] <TAB> for item in self. _flatten ( search_results ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _stations [ item [ ""guide_id"" ] ] = item <TAB> <TAB> <TAB> results. append ( item ) <TAB> return results",False,"item.get('type', '') == 'audio'",item['guide_id'] not in self._stations,0.6497741937637329
|
||
|
2816,"def __init__ ( <TAB> self, fixed : MQTTFixedHeader = None, variable_header : PacketIdVariableHeader = None ) : <TAB> if fixed is None : <TAB> <TAB> header = MQTTFixedHeader ( PUBREL, 0x02 ) <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise HBMQTTException ( <TAB> <TAB> <TAB> <TAB> ""Invalid fixed packet type %s for PubrelPacket init"" % fixed. packet_type <TAB> <TAB> <TAB> ) <TAB> <TAB> header = fixed <TAB> super ( ). __init__ ( header ) <TAB> self. variable_header = variable_header <TAB> self. payload = None",False,fixed.packet_type is not PUBREL,not fixed.packet_type,0.6651115417480469
|
||
|
2817,"def replaceChild ( self, newChild, oldChild ) : <TAB> if log. ThugOpts. features_logging : <TAB> <TAB> log. ThugLogging. Features. increase_replacechild_count ( ) <TAB> <TAB> <TAB> if self. is_readonly ( self ) : <TAB> <TAB> raise DOMException ( DOMException. NO_MODIFICATION_ALLOWED_ERR ) <TAB> parent = getattr ( newChild, ""parentNode"", None ) <TAB> if parent : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise DOMException ( DOMException. NO_MODIFICATION_ALLOWED_ERR ) <TAB> if not newChild or not oldChild : <TAB> <TAB> raise DOMException ( DOMException. HIERARCHY_REQUEST_ERR ) <TAB> if not isinstance ( newChild, Node ) or not isinstance ( oldChild, Node ) : <TAB> <TAB> raise DOMException ( DOMException. HIERARCHY_REQUEST_ERR ) <TAB> index = self. findChild ( oldChild ) <TAB> if index < 0 : <TAB> <TAB> raise DOMException ( DOMException. NOT_FOUND_ERR ) <TAB> if self. is_text ( newChild ) : <TAB> <TAB> self. tag. contents [ index ]. replace_with ( <TAB> <TAB> <TAB> newChild. data. output_ready ( formatter = lambda x : x ) <TAB> <TAB> ) <TAB> <TAB> return oldChild <TAB> if newChild. nodeType in ( Node. COMMENT_NODE, ) : <TAB> <TAB> self. tag. contents [ index ]. replace_with ( newChild. data ) <TAB> <TAB> return oldChild <TAB> if newChild. nodeType in ( Node. DOCUMENT_FRAGMENT_NODE, ) : <TAB> <TAB> node = None <TAB> <TAB> for p in newChild. tag. find_all_next ( ) : <TAB> <TAB> <TAB> if node is None : <TAB> <TAB> <TAB> <TAB> self. tag. contents [ index ]. replace_with ( p ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> node. append ( p ) <TAB> <TAB>",False,self.is_readonly(parent),parent.is_empty(),0.6521426439285278
|
||
|
2818,"def recvNotification ( self, node ) : <TAB> if node [ ""type"" ] == ""contacts"" : <TAB> <TAB> if node. getChild ( ""remove"" ) : <TAB> <TAB> <TAB> self. toUpper ( <TAB> <TAB> <TAB> <TAB> RemoveContactNotificationProtocolEntity. fromProtocolTreeNode ( node ) <TAB> <TAB> <TAB> ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> self. toUpper ( <TAB> <TAB> <TAB> <TAB> AddContactNotificationProtocolEntity. fromProtocolTreeNode ( node ) <TAB> <TAB> <TAB> ) <TAB> <TAB> elif node. getChild ( ""update"" ) : <TAB> <TAB> <TAB> self. toUpper ( <TAB> <TAB> <TAB> <TAB> UpdateContactNotificationProtocolEntity. fromProtocolTreeNode ( node ) <TAB> <TAB> <TAB> ) <TAB> <TAB> elif node. getChild ( ""sync"" ) : <TAB> <TAB> <TAB> self. toUpper ( <TAB> <TAB> <TAB> <TAB> ContactsSyncNotificationProtocolEntity. fromProtocolTreeNode ( node ) <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. raiseErrorForNode ( node )",True,node.getChild('add'),node.getChild('add'),0.6587312817573547
|
||
|
2819,"def parse_input_file ( text_file : Path, ann_file : Path ) -> InternalBioNerDataset : <TAB> documents = { } <TAB> entities_per_document = { } <TAB> document_abstract_length = { } <TAB> with open ( str ( text_file ), ""r"", encoding = ""utf8"" ) as text_reader : <TAB> <TAB> for line in text_reader : <TAB> <TAB> <TAB> if not line : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> document_id, title, abstract = line. split ( ""\t"" ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> documents [ document_id ] = abstract + "" "" + title <TAB> <TAB> <TAB> document_abstract_length [ document_id ] = len ( abstract ) + 1 <TAB> <TAB> <TAB> entities_per_document [ document_id ] = [ ] <TAB> with open ( str ( ann_file ), ""r"", encoding = ""utf8"" ) as ann_reader : <TAB> <TAB> for line in ann_reader : <TAB> <TAB> <TAB> if not line : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> columns = line. split ( ""\t"" ) <TAB> <TAB> <TAB> document_id = columns [ 0 ] <TAB> <TAB> <TAB> start, end = int ( columns [ 2 ] ), int ( columns [ 3 ] ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> start = start + document_abstract_length [ document_id ] <TAB> <TAB> <TAB> <TAB> end = end + document_abstract_length [ document_id ] <TAB> <TAB> <TAB> entities_per_document [ document_id ]. append ( <TAB> <TAB> <TAB> <TAB> Entity ( ( start, end ), columns [ 5 ]. strip ( ) ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> document_text = documents [ document_id ] <TAB> <TAB>",False,columns[1] == 'T',document_id in entities_per_document,0.657524049282074
|
||
|
2820,"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<mask> : <TAB> <TAB> <TAB> break <TAB> <TAB> if fid == 1 : <TAB> <TAB> <TAB> if ftype == TType. STRUCT : <TAB> <TAB> <TAB> <TAB> self. request = TResetTableReq ( ) <TAB> <TAB> <TAB> <TAB> self. request. 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 ( )",False,ftype == TType.STOP,fid == 0,0.6586672067642212
|
||
|
2821,"def _marshalData ( self ) : <TAB> if self. _cache == None : <TAB> <TAB> d = self. _data <TAB> <TAB> s = """" <TAB> <TAB> s = time. strftime ( ""%H:%M:%S"", ( 0, 0, 0 ) + d + ( 0, 0, - 1 ) ) <TAB> <TAB> f = d [ 2 ] - int ( d [ 2 ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> s += ( ""%g"" % f ) [ 1 : ] <TAB> <TAB> s += ""Z"" <TAB> <TAB> self. _cache = s <TAB> return self. _cache",False,f != 0,f > 0,0.6770527362823486
|
||
|
2822,"def _tag_is_equal ( self, tag1, tag2 ) : <TAB> if not hasattr ( tag1, ""name"" ) or not hasattr ( tag2, ""name"" ) : <TAB> <TAB> return False <TAB> if tag1. name!= tag2. name : <TAB> <TAB> return False <TAB> if len ( tag1. attributes )!= len ( tag2. attributes ) : <TAB> <TAB> return False <TAB> if tag1. attributes!= tag2. attributes : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for i in range ( len ( tag1. attributes ) ) : <TAB> <TAB> <TAB> attr, value = tag1. attributes [ i ] <TAB> <TAB> <TAB> other_attr, other_value = tag2. attributes [ i ] <TAB> <TAB> <TAB> if value is None : <TAB> <TAB> <TAB> <TAB> value = attr <TAB> <TAB> <TAB> if other_value is None : <TAB> <TAB> <TAB> <TAB> other_value = other_attr <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return False <TAB> return True",False,attr != other_attr or value != other_value,value != other_value,0.6463806629180908
|
||
|
2823,"def settings_edit ( request, response_format = ""html"" ) : <TAB> ""Settings"" <TAB> if request. POST : <TAB> <TAB> if ""cancel"" not in request. POST : <TAB> <TAB> <TAB> form = SettingsForm ( request. user. profile, request. POST ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> form. save ( ) <TAB> <TAB> <TAB> <TAB> return HttpResponseRedirect ( reverse ( ""infrastructure_settings_view"" ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return HttpResponseRedirect ( reverse ( ""infrastructure_settings_view"" ) ) <TAB> else : <TAB> <TAB> form = SettingsForm ( request. user. profile ) <TAB> context = _get_default_context ( request ) <TAB> context. update ( { ""form"" : form } ) <TAB> return render_to_response ( <TAB> <TAB> ""infrastructure/settings_edit"", <TAB> <TAB> context, <TAB> <TAB> context_instance = RequestContext ( request ), <TAB> <TAB> response_format = response_format, <TAB> )",True,form.is_valid(),form.is_valid(),0.6509213447570801
|
||
|
2824,"def get_success_url ( self ) : <TAB> """"""Continue to the flow index or redirect according `?back` parameter."""""" <TAB> if ""back"" in self. request. GET : <TAB> <TAB> back_url = self. request. GET [ ""back"" ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> back_url = ""/"" <TAB> <TAB> return back_url <TAB> return reverse ( self. success_url )",False,"not is_safe_url(url=back_url, allowed_hosts={self.request.get_host()})",not back_url,0.6510293483734131
|
||
|
2825,"def add_source ( self, source, name = None ) : <TAB> """"""Adds a new data source to an existing provider."""""" <TAB> if self. randomize : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""Cannot add a non-shuffleable source to an "" <TAB> <TAB> <TAB> <TAB> ""already shuffled provider."" <TAB> <TAB> <TAB> ) <TAB> super ( ). add_source ( source, name = name ) <TAB> if self. randomize is True : <TAB> <TAB> self. _shuffle_len = self. entries",False,not source.can_shuffle(),source is None,0.6536566019058228
|
||
|
2826,"def convert_to_strings ( self, out, seq_len ) : <TAB> results = [ ] <TAB> for b, batch in enumerate ( out ) : <TAB> <TAB> utterances = [ ] <TAB> <TAB> for p, utt in enumerate ( batch ) : <TAB> <TAB> <TAB> size = seq_len [ b ] [ p ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> transcript = """". join ( <TAB> <TAB> <TAB> <TAB> <TAB> map ( lambda x : self. int_to_char [ x. item ( ) ], utt [ 0 : size ] ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> transcript = """" <TAB> <TAB> <TAB> utterances. append ( transcript ) <TAB> <TAB> results. append ( utterances ) <TAB> return results",False,size > 0,utt[0:size] > 0,0.6688524484634399
|
||
|
2827,"def prepare_request ( next_link = None ) : <TAB> <TAB> header_parameters = { } <TAB> header_parameters [ ""Accept"" ] = self. _serialize. header ( ""accept"", accept, ""str"" ) <TAB> if not next_link : <TAB> <TAB> <TAB> <TAB> url = self. list_at_scope. metadata [ ""url"" ] <TAB> <TAB> path_format_arguments = { <TAB> <TAB> <TAB> ""scope"" : self. _serialize. url ( ""scope"", scope, ""str"", skip_quote = True ), <TAB> <TAB> } <TAB> <TAB> url = self. _client. format_url ( url, ** path_format_arguments ) <TAB> <TAB> <TAB> <TAB> query_parameters = { } <TAB> <TAB> query_parameters [ ""api-version"" ] = self. _serialize. query ( <TAB> <TAB> <TAB> ""api_version"", api_version, ""str"" <TAB> <TAB> ) <TAB> <TAB> if recommendation_type is not None : <TAB> <TAB> <TAB> query_parameters [ ""recommendationType"" ] = self. _serialize. query ( <TAB> <TAB> <TAB> <TAB> ""recommendation_type"", recommendation_type, ""str"" <TAB> <TAB> <TAB> ) <TAB> <TAB> if device_id is not None : <TAB> <TAB> <TAB> query_parameters [ ""deviceId"" ] = self. _serialize. query ( <TAB> <TAB> <TAB> <TAB> ""device_id"", device_id, ""str"" <TAB> <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> query_parameters [ ""$limit"" ] = self. _serialize. query ( ""limit"", limit, ""int"" ) <TAB> <TAB> if skip_token is not None : <TAB> <TAB> <TAB> query_parameters [ ""$skipToken"" ] = self. _serialize. query ( <TAB> <TAB> <TAB> <TAB> ""skip_token"", skip_token, ""str"" <TAB>",True,limit is not None,limit is not None,0.6713051795959473
|
||
|
2828,"def compress ( self, data_list ) : <TAB> warn_untested ( ) <TAB> if data_list : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> error = self. error_messages [ ""invalid_year"" ] <TAB> <TAB> <TAB> raise forms. ValidationError ( error ) <TAB> <TAB> if data_list [ 0 ] in forms. fields. EMPTY_VALUES : <TAB> <TAB> <TAB> error = self. error_messages [ ""invalid_month"" ] <TAB> <TAB> <TAB> raise forms. ValidationError ( error ) <TAB> <TAB> year = int ( data_list [ 1 ] ) <TAB> <TAB> month = int ( data_list [ 0 ] ) <TAB> <TAB> <TAB> <TAB> day = monthrange ( year, month ) [ 1 ] <TAB> <TAB> return date ( year, month, day ) <TAB> return None",False,data_list[1] in forms.fields.EMPTY_VALUES,data_list[1] in self.fields.EMPTY_VALUES,0.6598309278488159
|
||
|
2829,"def spaces_after ( token, prev, next, min = - 1, max = - 1, min_desc = None, max_desc = None ) : <TAB> if next is not None and token. end_mark. line == next. start_mark. line : <TAB> <TAB> spaces = next. start_mark. pointer - token. end_mark. pointer <TAB> <TAB> if max!= - 1 and spaces > max : <TAB> <TAB> <TAB> return LintProblem ( <TAB> <TAB> <TAB> <TAB> token. start_mark. line + 1, next. start_mark. column, max_desc <TAB> <TAB> <TAB> ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> return LintProblem ( <TAB> <TAB> <TAB> <TAB> token. start_mark. line + 1, next. start_mark. column + 1, min_desc <TAB> <TAB> <TAB> )",True,min != -1 and spaces < min,min != -1 and spaces < min,0.6566714644432068
|
||
|
2830,"def remaining_length ( packet ) : <TAB> l = min ( 5, len ( packet ) ) <TAB> all_bytes = struct. unpack ( ""!"" + ""B"" * l, packet [ : l ] ) <TAB> mult = 1 <TAB> rl = 0 <TAB> for i in range ( 1, l - 1 ) : <TAB> <TAB> byte = all_bytes [ i ] <TAB> <TAB> rl += ( byte & 127 ) * mult <TAB> <TAB> mult *= 128 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> packet = packet [ i + 1 : ] <TAB> <TAB> <TAB> break <TAB> return ( packet, rl )",False,byte & 128 == 0,rl > 255,0.6782653331756592
|
||
|
2831,"def select_drm ( self, has_drm ) : <TAB> self. clearSelection ( ) <TAB> current_selection_mode = self. selectionMode ( ) <TAB> self. setSelectionMode ( QAbstractItemView. MultiSelection ) <TAB> for row in range ( self. rowCount ( ) ) : <TAB> <TAB> <TAB> <TAB> if convert_qvariant ( self. item ( row, 0 ). data ( Qt. UserRole ) ) == 1 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if has_drm : <TAB> <TAB> <TAB> <TAB> self. selectRow ( row ) <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. selectRow ( row ) <TAB> self. setSelectionMode ( current_selection_mode )",False,not has_drm,has_drm,0.6564825773239136
|
||
|
2832,"def createFields ( self ) : <TAB> if self. root. isEMF ( ) : <TAB> <TAB> yield Enum ( UInt32 ( self, ""function"" ), EMF_META_NAME ) <TAB> <TAB> yield UInt32 ( self, ""size"" ) <TAB> <TAB> try : <TAB> <TAB> <TAB> parser = EMF_META [ self [ ""function"" ]. value ] [ 2 ] <TAB> <TAB> except KeyError : <TAB> <TAB> <TAB> parser = None <TAB> else : <TAB> <TAB> yield UInt32 ( self, ""size"" ) <TAB> <TAB> yield Enum ( UInt16 ( self, ""function"" ), META_NAME ) <TAB> <TAB> try : <TAB> <TAB> <TAB> parser = META [ self [ ""function"" ]. value ] [ 2 ] <TAB> <TAB> except KeyError : <TAB> <TAB> <TAB> parser = None <TAB> if parser : <TAB> <TAB> for field in parser ( self ) : <TAB> <TAB> <TAB> yield field <TAB> else : <TAB> <TAB> size = ( self. size - self. current_size ) // 8 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> yield RawBytes ( self, ""data"", size )",True,size,size,0.6882491707801819
|
||
|
2833,"def result ( ) : <TAB> <TAB> R, V = rays, virtual_rays <TAB> if V is not None : <TAB> <TAB> if normalize : <TAB> <TAB> <TAB> V = normalize_rays ( V, lattice ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> R = PointCollection ( V, lattice ) <TAB> <TAB> <TAB> V = PointCollection ( V, lattice ) <TAB> <TAB> <TAB> d = lattice. dimension ( ) <TAB> <TAB> <TAB> if len ( V )!= d - R. dim ( ) or ( R + V ). dim ( )!= d : <TAB> <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""virtual rays must be linearly "" <TAB> <TAB> <TAB> <TAB> <TAB> ""independent and with other rays span the ambient space."" <TAB> <TAB> <TAB> <TAB> ) <TAB> return RationalPolyhedralFan ( cones, R, lattice, is_complete, V )",False,check,point_collection is not None,0.6937557458877563
|
||
|
2834,"def to_child ( cls, key = None, process = None ) : <TAB> if process is not None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> 'Invalid value provided for ""process"" parameter, expected a dictionary' <TAB> <TAB> <TAB> ) <TAB> <TAB> if cls. __process__ : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> result = { } <TAB> <TAB> <TAB> result. update ( deepcopy ( cls. __process__ ) ) <TAB> <TAB> <TAB> result. update ( process ) <TAB> <TAB> <TAB> process = result <TAB> class Child ( cls ) : <TAB> <TAB> __key__ = key <TAB> <TAB> __process__ = process <TAB> <TAB> __root__ = False <TAB> Child. __name__ = cls. __name__ <TAB> return Child",False,type(process) is not dict,"key is None or not isinstance(key, dict)",0.6588755249977112
|
||
|
2835,"def _rule_args_to_dict ( self, context, kwargs ) : <TAB> rules = [ ] <TAB> if not ""groups"" in kwargs and not ""ip_ranges"" in kwargs : <TAB> <TAB> rule = self. _rule_dict_last_step ( context, ** kwargs ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> rules. append ( rule ) <TAB> <TAB> return rules <TAB> if ""ip_ranges"" in kwargs : <TAB> <TAB> rules = self. _cidr_args_split ( kwargs ) <TAB> else : <TAB> <TAB> rules = [ kwargs ] <TAB> finalset = [ ] <TAB> for rule in rules : <TAB> <TAB> if ""groups"" in rule : <TAB> <TAB> <TAB> groups_values = self. _groups_args_split ( rule ) <TAB> <TAB> <TAB> for groups_value in groups_values : <TAB> <TAB> <TAB> <TAB> final = self. _rule_dict_last_step ( context, ** groups_value ) <TAB> <TAB> <TAB> <TAB> finalset. append ( final ) <TAB> <TAB> else : <TAB> <TAB> <TAB> final = self. _rule_dict_last_step ( context, ** rule ) <TAB> <TAB> <TAB> finalset. append ( final ) <TAB> return finalset",False,rule,rule in self.rules,0.6950066685676575
|
||
|
2836,"def named_url_format ( self ) : <TAB> named_url_components = [ ] <TAB> stack = [ self ] <TAB> current_fk_name = """" <TAB> while stack : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> named_url_component = NAMED_URL_RES_INNER_DILIMITER. join ( <TAB> <TAB> <TAB> <TAB> [ ""<%s>"" % ( current_fk_name + field ) for field in stack [ - 1 ]. fields ] <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> named_url_components. append ( named_url_component ) <TAB> <TAB> if stack [ - 1 ]. counter >= len ( stack [ - 1 ]. adj_list ) : <TAB> <TAB> <TAB> stack [ - 1 ]. counter = 0 <TAB> <TAB> <TAB> stack. pop ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> to_append = stack [ - 1 ]. adj_list [ stack [ - 1 ]. counter ] [ NEXT_NODE ] <TAB> <TAB> <TAB> current_fk_name = ""%s."" % ( stack [ - 1 ]. adj_list [ stack [ - 1 ]. counter ] [ FK_NAME ], ) <TAB> <TAB> <TAB> stack [ - 1 ]. counter += 1 <TAB> <TAB> <TAB> stack. append ( to_append ) <TAB> return NAMED_URL_RES_DILIMITER. join ( named_url_components )",False,stack[-1].counter == 0,stack[-1].fields,0.6580348610877991
|
||
|
2837,"def update_metrics ( <TAB> return_dict : Dict [ str, Any ], batch : Batch, metrics : ""OrderedDict[str, Metric]"" ) -> None : <TAB> for metric_name, metric in metrics. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> pred_val = return_dict [ metric. pred_name ] <TAB> <TAB> <TAB> except KeyError : <TAB> <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> <TAB> f""Return dictionary from model does not contain "" <TAB> <TAB> <TAB> <TAB> <TAB> f""'{metric.pred_name}' entry, which was required for "" <TAB> <TAB> <TAB> <TAB> <TAB> f""metric '{metric_name}'"" <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if isinstance ( pred_val, torch. Tensor ) : <TAB> <TAB> <TAB> <TAB> pred_val = pred_val. tolist ( ) <TAB> <TAB> <TAB> pred_val = to_list ( pred_val ) <TAB> <TAB> else : <TAB> <TAB> <TAB> pred_val = None <TAB> <TAB> if metric. label_name is not None : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> label_val = batch [ metric. label_name ] <TAB> <TAB> <TAB> except KeyError : <TAB> <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> <TAB> f""Data batch does not contain '{metric.label_name}' "" <TAB> <TAB> <TAB> <TAB> <TAB> f""entry, which was required for metric '{metric_name}'"" <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if isinstance ( label_val, torch. Tensor ) : <TAB> <TAB> <TAB> <TAB> label_val = label_val. tolist ( ) <TAB> <TAB> <TAB> label_",True,metric.pred_name is not None,metric.pred_name is not None,0.6649856567382812
|
||
|
2838,"def __Prefix_Step2a ( self, token ) : <TAB> for prefix in self. __prefix_step2a : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> token = token [ len ( prefix ) : ] <TAB> <TAB> <TAB> self. prefix_step2a_success = True <TAB> <TAB> <TAB> break <TAB> return token",False,token.startswith(prefix) and len(token) > 5,token.startswith(prefix),0.6454793810844421
|
||
|
2839,"def document_lines ( document ) : <TAB> if not document : <TAB> <TAB> return None <TAB> <TAB> STR = document. get_property ( ""text"" ) <TAB> lines = STR. split ( ""\n"" ) <TAB> ans = [ ] <TAB> for i, each in enumerate ( lines ) : <TAB> <TAB> x = struct ( ) <TAB> <TAB> x. i = i <TAB> <TAB> x. len = len ( each ) <TAB> <TAB> x. indent = indent ( each ) <TAB> <TAB> x. raw = each <TAB> <TAB> x. section = match_RE_list ( x. raw, SectionREs ) <TAB> <TAB> x. subsection = None <TAB> <TAB> x. search_match = False <TAB> <TAB> if not x. section : <TAB> <TAB> <TAB> x. subsection = match_RE_list ( x. raw, SubsectionREs ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> match = Split_Off_Indent_Pattern. match ( x. raw ) <TAB> <TAB> <TAB> x. indentSTR = None <TAB> <TAB> <TAB> x. justextSTR = None <TAB> <TAB> <TAB> if match : <TAB> <TAB> <TAB> <TAB> groups = match. groups ( ) <TAB> <TAB> <TAB> <TAB> if len ( groups ) == 2 : <TAB> <TAB> <TAB> <TAB> <TAB> x. indentSTR, x. justextSTR = groups <TAB> <TAB> ans. append ( x ) <TAB> return ans",False,x.section or x.subsection,not x.subsection,0.6522911787033081
|
||
|
2840,"def parse_error ( self ) : <TAB> if self. status == httplib. UNAUTHORIZED : <TAB> <TAB> raise InvalidCredsError ( self. body ) <TAB> elif self. status == httplib. FORBIDDEN : <TAB> <TAB> raise InvalidCredsError ( self. body ) <TAB> body = self. parse_body ( ) <TAB> if self. status == httplib. BAD_REQUEST : <TAB> <TAB> for response_code in BAD_CODE_XML_ELEMENTS : <TAB> <TAB> <TAB> code = findtext ( body, response_code [ 0 ], response_code [ 1 ] ) <TAB> <TAB> <TAB> if code is not None : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> for message in BAD_MESSAGE_XML_ELEMENTS : <TAB> <TAB> <TAB> message = findtext ( body, message [ 0 ], message [ 1 ] ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> raise DimensionDataAPIException ( <TAB> <TAB> <TAB> code = code, msg = message, driver = self. connection. driver <TAB> <TAB> ) <TAB> if self. status is not httplib. OK : <TAB> <TAB> raise DimensionDataAPIException ( <TAB> <TAB> <TAB> code = self. status, msg = body, driver = self. connection. driver <TAB> <TAB> ) <TAB> return self. body",False,message is not None,code is not None,0.6616147756576538
|
||
|
2841,"def set_invoice_details ( self, row ) : <TAB> invoice_details = self. invoice_details. get ( row. voucher_no, { } ) <TAB> if row. due_date : <TAB> <TAB> invoice_details. pop ( ""due_date"", None ) <TAB> row. update ( invoice_details ) <TAB> if row. voucher_type == ""Sales Invoice"" : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. set_delivery_notes ( row ) <TAB> <TAB> if self. filters. show_sales_person and row. sales_team : <TAB> <TAB> <TAB> row. sales_person = "", "". join ( row. sales_team ) <TAB> <TAB> <TAB> del row [ ""sales_team"" ]",False,self.filters.show_delivery_notes,self.delivery_notes,0.6514642238616943
|
||
|
2842,"def restify ( cls : Optional [ ""Type"" ] ) -> str : <TAB> """"""Convert python class to a reST reference."""""" <TAB> from sphinx. util import inspect <TAB> if cls is None or cls is NoneType : <TAB> <TAB> return "":obj:`None`"" <TAB> elif cls is Ellipsis : <TAB> <TAB> return ""..."" <TAB> elif cls is Struct : <TAB> <TAB> <TAB> <TAB> return "":class:`struct.Struct`"" <TAB> elif inspect. isNewType ( cls ) : <TAB> <TAB> return "":class:`%s`"" % cls. __name__ <TAB> elif types_Union and isinstance ( cls, types_Union ) : <TAB> <TAB> if len ( cls. __args__ ) > 1 and None in cls. __args__ : <TAB> <TAB> <TAB> args = "" | "". join ( restify ( a ) for a in cls. __args__ if a ) <TAB> <TAB> <TAB> return ""Optional[%s]"" % args <TAB> <TAB> else : <TAB> <TAB> <TAB> return "" | "". join ( restify ( a ) for a in cls. __args__ ) <TAB> elif cls. __module__ in ( ""__builtin__"", ""builtins"" ) : <TAB> <TAB> return "":class:`%s`"" % cls. __name__ <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return _restify_py37 ( cls ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return _restify_py36 ( cls )",False,"sys.version_info >= (3, 7)",cls.__module__ == '__py37__',0.6517812013626099
|
||
|
2843,"def migrate_old_actions ( apps, schema_editor ) : <TAB> from orgs. utils import set_to_root_org <TAB> set_to_root_org ( ) <TAB> perm_model = apps. get_model ( ""perms"", ""AssetPermission"" ) <TAB> db_alias = schema_editor. connection. alias <TAB> perms = perm_model. objects. using ( db_alias ). all ( ) <TAB> actions_map = { <TAB> <TAB> ""all"" : 0b11111111, <TAB> <TAB> ""connect"" : 0b00000001, <TAB> <TAB> ""upload_file"" : 0b00000010, <TAB> <TAB> ""download_file"" : 0b00000100, <TAB> } <TAB> for perm in perms : <TAB> <TAB> actions = perm. actions. all ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> new_actions = [ actions_map. get ( action. name, 0b11111111 ) for action in actions ] <TAB> <TAB> new_action = reduce ( lambda x, y : x | y, new_actions ) <TAB> <TAB> perm. action = new_action <TAB> <TAB> perm. save ( )",False,not actions,len(actions) < TAB > 0,0.6817644238471985
|
||
|
2844,"def parse_implements_interfaces ( parser ) : <TAB> types = [ ] <TAB> if parser. token. value == ""implements"" : <TAB> <TAB> advance ( parser ) <TAB> <TAB> while True : <TAB> <TAB> <TAB> types. append ( parse_named_type ( parser ) ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> break <TAB> return types",False,"not peek(parser, TokenKind.NAME)",len(types) == 0,0.6568517684936523
|
||
|
2845,"def reduce_arguments ( self, args ) : <TAB> assert isinstance ( args, nodes. Arguments ) <TAB> if args. incorrect_order ( ) : <TAB> <TAB> raise InvalidArguments ( <TAB> <TAB> <TAB> ""All keyword arguments must be after positional arguments."" <TAB> <TAB> ) <TAB> reduced_pos = [ self. reduce_single ( arg ) for arg in args. arguments ] <TAB> reduced_kw = { } <TAB> for key in args. kwargs. keys ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise InvalidArguments ( ""Keyword argument name is not a string."" ) <TAB> <TAB> a = args. kwargs [ key ] <TAB> <TAB> reduced_kw [ key ] = self. reduce_single ( a ) <TAB> return ( reduced_pos, reduced_kw )",False,"not isinstance(key, str)","not isinstance(args.kwargs[key], nodes.StringTypes)",0.6522532105445862
|
||
|
2846,"def run ( self ) : <TAB> """"""Run the worker thread."""""" <TAB> <TAB> <TAB> try : <TAB> <TAB> url = _docsURL % ReplaceCapitals ( self. selectedClass ) <TAB> <TAB> with urllib. request. urlopen ( url ) as fid : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> originalText = fid. read ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> originalText = fid. read ( ). decode ( ""utf-8"" ) <TAB> <TAB> text = RemoveHTMLTags ( originalText ). split ( ""\n"" ) <TAB> <TAB> data = FindWindowStyles ( text, originalText, self. selectedClass ) <TAB> <TAB> if not self. keepRunning : <TAB> <TAB> <TAB> return <TAB> <TAB> wx. CallAfter ( self. notifyWindow. LoadDocumentation, data ) <TAB> except ( IOError, urllib. error. HTTPError ) : <TAB> <TAB> <TAB> <TAB> t, v = sys. exc_info ( ) [ : 2 ] <TAB> <TAB> message = traceback. format_exception_only ( t, v ) <TAB> <TAB> wx. CallAfter ( self. notifyWindow. StopDownload, message ) <TAB> except : <TAB> <TAB> <TAB> <TAB> t, v = sys. exc_info ( ) [ : 2 ] <TAB> <TAB> message = traceback. format_exception_only ( t, v ) <TAB> <TAB> wx. CallAfter ( self. notifyWindow. StopDownload, message )",False,six.PY2,fid.has_key('read'),0.6619912385940552
|
||
|
2847,"def _add_trials ( self, name, spec ) : <TAB> """"""Add trial by invoking TrialRunner."""""" <TAB> resource = { } <TAB> resource [ ""trials"" ] = [ ] <TAB> trial_generator = BasicVariantGenerator ( ) <TAB> trial_generator. add_configurations ( { name : spec } ) <TAB> while not trial_generator. is_finished ( ) : <TAB> <TAB> trial = trial_generator. next_trial ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> break <TAB> <TAB> runner. add_trial ( trial ) <TAB> <TAB> resource [ ""trials"" ]. append ( self. _trial_info ( trial ) ) <TAB> return resource",False,not trial,trial is None,0.6981533169746399
|
||
|
2848,"def _pick_format ( self, database_path, source ) : <TAB> collection_path = os. path. join ( database_path, source ) <TAB> <TAB> names = os. listdir ( collection_path ) <TAB> available = [ ] <TAB> for filename in names : <TAB> <TAB> if not filename. startswith ( ""index."" ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> path = os. path. join ( collection_path, filename ) <TAB> <TAB> name, ext = os. path. splitext ( filename ) <TAB> <TAB> <TAB> <TAB> if ext == ""mpack"" : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> <TAB> modified_date = os. path. getmtime ( path ) <TAB> <TAB> <TAB> <TAB> filename = os. path. basename ( path ) <TAB> <TAB> extension = filename. split ( ""."", 1 ) [ 1 ] <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> available. append ( ( modified_date, filename, extension ) ) <TAB> if len ( available ) < 1 : <TAB> <TAB> raise Exception ( ""No supported index available in %r"" % collection_path ) <TAB> <TAB> available. sort ( key = lambda i : i [ 0 ] ) <TAB> <TAB> _, filename, extension = available [ - 1 ] <TAB> <TAB> for _, fmt in self. plugins. list_ordered ( ""format"" ) : <TAB> <TAB> if fmt. __extension__ == extension : <TAB> <TAB> <TAB> return fmt ( ) <TAB> return None",False,self.formats is not None and extension not in self.formats,modified_date is None,0.6492943167686462
|
||
|
2849,"def on_modified_async ( self, view ) : <TAB> syntax = view. settings ( ). get ( ""syntax"" ) <TAB> if syntax and ""Markdown"" in syntax : <TAB> <TAB> text = view. substr ( sublime. Region ( 0, view. size ( ) ) ) <TAB> <TAB> it = re. finditer ( r""^(#{1,6}(?!#))|^(-{3,}|={3,})"", text, re. M ) <TAB> <TAB> title = """" <TAB> <TAB> title_begin = None <TAB> <TAB> for m in it : <TAB> <TAB> <TAB> if "".front-matter"" in view. scope_name ( m. start ( ) ) : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> title_end = m. start ( ) - 1 <TAB> <TAB> <TAB> <TAB> title_begin = text. rfind ( ""\n"", 0, title_end ) + 1 <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> title_begin = m. end ( ) <TAB> <TAB> <TAB> <TAB> title_end = ( <TAB> <TAB> <TAB> <TAB> <TAB> re. search ( ""("" + m. group ( ) + "")?(\n|$)"", text [ title_begin : ] ). start ( ) <TAB> <TAB> <TAB> <TAB> <TAB> + title_begin <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> title_begin = m. start ( ) + 1 <TAB> <TAB> <TAB> if ""markup.raw.block.markdown"" not in view. scope_name ( title_begin ). split ( <TAB> <TAB> <TAB> <TAB> "" "" <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> if len ( title ) == 0 and title_begin is not None : <TAB> <TAB> <TAB> title = text [ title_begin : title_",False,"re.match('^(-{3,}|={3,})$', m.group())",len(text) > 0,0.6528462767601013
|
||
|
2850,"def callback ( ) : <TAB> try : <TAB> <TAB> descriptions, command = extract_neighbors ( line ) <TAB> <TAB> peers = match_neighbors ( reactor. peers, descriptions ) <TAB> <TAB> if not peers : <TAB> <TAB> <TAB> self. log_failure ( ""no neighbor matching the command : %s"" % command ) <TAB> <TAB> <TAB> reactor. processes. answer_error ( service ) <TAB> <TAB> <TAB> yield True <TAB> <TAB> <TAB> return <TAB> <TAB> changes = self. api_flow ( command ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. log_failure ( ""command could not parse flow in : %s"" % command ) <TAB> <TAB> <TAB> reactor. processes. answer_error ( service ) <TAB> <TAB> <TAB> yield True <TAB> <TAB> <TAB> return <TAB> <TAB> for change in changes : <TAB> <TAB> <TAB> change. nlri. action = OUT. WITHDRAW <TAB> <TAB> <TAB> if reactor. configuration. inject_change ( peers, change ) : <TAB> <TAB> <TAB> <TAB> self. log_message ( <TAB> <TAB> <TAB> <TAB> <TAB> ""flow removed from %s : %s"" <TAB> <TAB> <TAB> <TAB> <TAB> % ( "", "". join ( peers ) if peers else ""all peers"", change. extensive ( ) ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. log_failure ( <TAB> <TAB> <TAB> <TAB> <TAB> ""flow not found on %s : %s"" <TAB> <TAB> <TAB> <TAB> <TAB> % ( "", "". join ( peers ) if peers else ""all peers"", change. extensive ( ) ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> yield False <TAB> <TAB> reactor. processes. answer_done ( service ) <TAB> except ValueError : <TAB> <",True,not changes,not changes,0.6736672520637512
|
||
|
2851,"def takewhile_set ( tokens ) : <TAB> open_braces = 0 <TAB> previous_token = None <TAB> while True : <TAB> <TAB> try : <TAB> <TAB> <TAB> token = tokens. popleft ( ) <TAB> <TAB> except IndexError : <TAB> <TAB> <TAB> break <TAB> <TAB> if token == "", "" : <TAB> <TAB> <TAB> previous_token = token <TAB> <TAB> <TAB> continue <TAB> <TAB> if not token. strip ( ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> if token in keywords : <TAB> <TAB> <TAB> tokens. appendleft ( token ) <TAB> <TAB> <TAB> if previous_token is not None : <TAB> <TAB> <TAB> <TAB> tokens. appendleft ( previous_token ) <TAB> <TAB> <TAB> break <TAB> <TAB> if previous_token is not None : <TAB> <TAB> <TAB> yield previous_token <TAB> <TAB> <TAB> previous_token = None <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> open_braces += 1 <TAB> <TAB> elif token == ""}"" : <TAB> <TAB> <TAB> open_braces -= 1 <TAB> <TAB> yield token <TAB> <TAB> if open_braces == 0 : <TAB> <TAB> <TAB> break",False,token == '{',"token == ""\\",0.6769976019859314
|
||
|
2852,"def __on_change_button_clicked ( self, widget = None ) : <TAB> """"""compute all primary objects and toggle the 'Change' attribute"""""" <TAB> self. change_status = not self. change_status <TAB> for prim_obj, tmp in self. xobjects : <TAB> <TAB> obj_change = self. top. get_object ( ""%s_change"" % prim_obj ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> self. change_entries [ prim_obj ]. set_val ( self. change_status ) <TAB> <TAB> obj_change. set_active ( self. change_status )",False,not obj_change.get_sensitive(),obj_change.get_active(),0.6518914699554443
|
||
|
2853,"def __init__ ( self, layers, name : Optional [ str ] = None ) : <TAB> """"""Initializes the module."""""" <TAB> super ( ). __init__ ( layers, name = name ) <TAB> self. __input_signature = None <TAB> self. _num_unrollable = 0 <TAB> <TAB> <TAB> <TAB> <TAB> for layer in self. _layers : <TAB> <TAB> if hasattr ( layer, ""unroll"" ) : <TAB> <TAB> <TAB> self. _num_unrollable += 1 <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> self. _num_unrollable += 1 <TAB> <TAB> <TAB> layer. unroll = functools. partial ( snt. dynamic_unroll, layer ) <TAB> <TAB> <TAB> logging. warning ( <TAB> <TAB> <TAB> <TAB> ""Acme DeepRNN detected a Sonnet RNNCore. "" <TAB> <TAB> <TAB> <TAB> ""This will be dynamically unrolled. Please implement unroll() "" <TAB> <TAB> <TAB> <TAB> ""to suppress this warning."" <TAB> <TAB> <TAB> )",False,"isinstance(layer, snt.RNNCore)","hasattr(layer, 'unroll')",0.6599419116973877
|
||
|
2854,"def get_mapping_exception_message ( mappings : List [ Tuple [ Text, Text ] ] ) : <TAB> """"""Return a message given a list of duplicates."""""" <TAB> message = """" <TAB> for name, action_name in mappings : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> message += ""\n"" <TAB> <TAB> message += ( <TAB> <TAB> <TAB> ""Intent '{}' is set to trigger action '{}', which is "" <TAB> <TAB> <TAB> ""not defined in the domain."". format ( name, action_name ) <TAB> <TAB> ) <TAB> return message",False,message,action_name in message,0.6979032754898071
|
||
|
2855,"def add_if_unique ( self, issuer, use, keys ) : <TAB> if use in self. issuer_keys [ issuer ] and self. issuer_keys [ issuer ] [ use ] : <TAB> <TAB> for typ, key in keys : <TAB> <TAB> <TAB> flag = 1 <TAB> <TAB> <TAB> for _typ, _key in self. issuer_keys [ issuer ] [ use ] : <TAB> <TAB> <TAB> <TAB> if _typ == typ and key is _key : <TAB> <TAB> <TAB> <TAB> <TAB> flag = 0 <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. issuer_keys [ issuer ] [ use ]. append ( ( typ, key ) ) <TAB> else : <TAB> <TAB> self. issuer_keys [ issuer ] [ use ] = keys",True,flag,flag,0.6819233298301697
|
||
|
2856,"def process_operation_event ( <TAB> events_path : str, <TAB> event_kind : str, <TAB> event_name : str, <TAB> orient : str = V1Events. ORIENT_CSV, ) -> Optional [ Dict ] : <TAB> if not events_path or not os. path. exists ( events_path ) : <TAB> <TAB> return None <TAB> async with aiofiles. open ( events_path, mode = ""r"" ) as f : <TAB> <TAB> contents = await f. read ( ) <TAB> <TAB> if contents : <TAB> <TAB> <TAB> if orient == V1Events. ORIENT_CSV : <TAB> <TAB> <TAB> <TAB> return { ""name"" : event_name, ""kind"" : event_kind, ""data"" : contents } <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> df = V1Events. read ( <TAB> <TAB> <TAB> <TAB> <TAB> kind = event_kind, name = event_name, data = contents, parse_dates = False <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> return { ""name"" : event_name, ""kind"" : event_kind, ""data"" : df. to_dict ( ) } <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> raise HTTPException ( <TAB> <TAB> <TAB> <TAB> <TAB> detail = ""received an unrecognisable orient value {}."". format ( orient ), <TAB> <TAB> <TAB> <TAB> <TAB> status_code = status. HTTP_400_BAD_REQUEST, <TAB> <TAB> <TAB> <TAB> ) <TAB> return None",False,orient == V1Events.ORIENT_DICT,orient == V1Events.NONE_CSV,0.6602900624275208
|
||
|
2857,"def draw_buttons_3dpanel ( self, layout, in_menu = None ) : <TAB> if not in_menu : <TAB> <TAB> menu = layout. row ( align = True ). operator ( <TAB> <TAB> <TAB> ""node.popup_3d_menu"", text = f'Show: ""{self.label or self.name}""' <TAB> <TAB> ) <TAB> <TAB> menu. tree_name = self. id_data. name <TAB> <TAB> menu. node_name = self. name <TAB> else : <TAB> <TAB> layout. label ( text = self. label or self. name ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> colum_list = layout. column ( align = True ) <TAB> <TAB> <TAB> for i in range ( self. v_int ) : <TAB> <TAB> <TAB> <TAB> row = colum_list. row ( align = True ) <TAB> <TAB> <TAB> <TAB> for j in range ( 3 ) : <TAB> <TAB> <TAB> <TAB> <TAB> row. prop ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""vector_list"", <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> index = i * 3 + j, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> text = ""XYZ"" [ j ] + ( self. label if self. label else self. name ), <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> colum_list = layout. column ( align = True ) <TAB> <TAB> <TAB> for i in range ( self. int_ ) : <TAB> <TAB> <TAB> <TAB> row = colum_list. row ( align = True ) <TAB> <TAB> <TAB> <TAB> row. prop ( <TAB> <TAB> <TAB> <TAB> <TAB> self, <TAB> <TAB> <TAB> <",False,self.mode == 'vector',self.v_int > 0,0.6560391187667847
|
||
|
2858,"def run_rom ( args ) : <TAB> rom, frame_limit = args <TAB> pyboy = PyBoy ( rom, window_type = ""dummy"" ) <TAB> pyboy. set_emulation_speed ( 0 ) <TAB> serial_output = """" <TAB> t = time. time ( ) <TAB> result = None <TAB> frame_count = 0 <TAB> while not pyboy. tick ( ) : <TAB> <TAB> b = pyboy. _serial ( ) <TAB> <TAB> if b!= """" : <TAB> <TAB> <TAB> serial_output += b <TAB> <TAB> <TAB> t = time. time ( ) <TAB> <TAB> if ""Passed"" in serial_output : <TAB> <TAB> <TAB> result = ""Passed"" <TAB> <TAB> <TAB> break <TAB> <TAB> elif ""Failed"" in serial_output : <TAB> <TAB> <TAB> result = serial_output <TAB> <TAB> <TAB> break <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> result = ""Timeout:\n"" + serial_output <TAB> <TAB> <TAB> break <TAB> <TAB> elif frame_count == frame_limit : <TAB> <TAB> <TAB> result = ""Frame limit reached:\n"" + serial_output <TAB> <TAB> <TAB> break <TAB> <TAB> frame_count += 1 <TAB> pyboy. stop ( save = False ) <TAB> return result",False,frame_limit == -1 and time.time() - t > timeout,result is None,0.6573423147201538
|
||
|
2859,"def TryMerge ( self, d ) : <TAB> while d. avail ( ) > 0 : <TAB> <TAB> tt = d. getVarInt32 ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. add_version ( d. getPrefixedString ( ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if tt == 0 : <TAB> <TAB> <TAB> raise ProtocolBuffer. ProtocolBufferDecodeError <TAB> <TAB> d. skipData ( tt )",False,tt == 10,tt == 1,0.6975479125976562
|
||
|
2860,"def train ( config, args ) : <TAB> gan = setup_gan ( config, inputs, args ) <TAB> test_batches = [ ] <TAB> for i in range ( args. steps ) : <TAB> <TAB> gan. step ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> correct_prediction = 0 <TAB> <TAB> <TAB> total = 0 <TAB> <TAB> <TAB> for ( x, y ) in gan. inputs. testdata ( ) : <TAB> <TAB> <TAB> <TAB> prediction = gan. generator ( x ) <TAB> <TAB> <TAB> <TAB> correct_prediction += ( <TAB> <TAB> <TAB> <TAB> <TAB> torch. argmax ( prediction, 1 ) == torch. argmax ( y, 1 ) <TAB> <TAB> <TAB> <TAB> ). sum ( ) <TAB> <TAB> <TAB> <TAB> total += y. shape [ 0 ] <TAB> <TAB> <TAB> accuracy = ( float ( correct_prediction ) / total ) * 100 <TAB> <TAB> <TAB> print ( ""accuracy: "", accuracy ) <TAB> return sum_metrics",False,i % args.sample_every == 0 and i > 0,args.steps == 1,0.654068648815155
|
||
|
2861,"def apply ( self, node, code, required ) : <TAB> yield ""try:"" <TAB> yield from self. iterIndented ( code ) <TAB> yield "" pass"" <TAB> yield ""except {}:"". format ( self. exceptionString ) <TAB> outputVariables = node. getOutputSocketVariables ( ) <TAB> for i, s in enumerate ( node. outputs ) : <TAB> <TAB> if s. identifier in required : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> yield f"" {outputVariables[s.identifier]} = {s.getDefaultValueCode()}"" <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> yield f"" {outputVariables[s.identifier]} = self.outputs[{i}].getDefaultValue()"" <TAB> yield "" pass""",False,"hasattr(s, 'getDefaultValueCode')",i == 0,0.6518462896347046
|
||
|
2862,"def create_volume ( self, volume ) : <TAB> """"""Create a volume."""""" <TAB> try : <TAB> <TAB> cmd = [ ""volume"", ""create"", volume [ ""name"" ], ""%sG"" % ( volume [ ""size"" ] ) ] <TAB> <TAB> if self. configuration. eqlx_pool!= ""default"" : <TAB> <TAB> <TAB> cmd. append ( ""pool"" ) <TAB> <TAB> <TAB> cmd. append ( self. configuration. eqlx_pool ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> cmd. append ( ""thin-provision"" ) <TAB> <TAB> out = self. _eql_execute ( * cmd ) <TAB> <TAB> self. add_multihost_access ( volume ) <TAB> <TAB> return self. _get_volume_data ( out ) <TAB> except Exception : <TAB> <TAB> with excutils. save_and_reraise_exception ( ) : <TAB> <TAB> <TAB> LOG. error ( 'Failed to create volume ""%s"".', volume [ ""name"" ] )",False,self.configuration.san_thin_provision,self.configuration.eqlx_provision != 'default',0.6500492095947266
|
||
|
2863,"def start_listening ( self, bot ) : <TAB> loop = asyncio. get_event_loop ( ) <TAB> itemNo = - 1 <TAB> threads = [ ] <TAB> if isinstance ( self. configuration, list ) : <TAB> <TAB> for listener in self. configuration : <TAB> <TAB> <TAB> itemNo += 1 <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> certfile = listener [ ""certfile"" ] <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> logger. warning ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""config.{}[{}].certfile must be configured"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. configkey, itemNo <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> name = listener [ ""name"" ] <TAB> <TAB> <TAB> <TAB> port = listener [ ""port"" ] <TAB> <TAB> <TAB> except KeyError as e : <TAB> <TAB> <TAB> <TAB> logger. warning ( <TAB> <TAB> <TAB> <TAB> <TAB> ""config.{}[{}] missing keyword"". format ( self. configkey, itemNo ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> aiohttp_start ( <TAB> <TAB> <TAB> <TAB> bot, <TAB> <TAB> <TAB> <TAB> name, <TAB> <TAB> <TAB> <TAB> port, <TAB> <TAB> <TAB> <TAB> certfile, <TAB> <TAB> <TAB> <TAB> self. RequestHandler, <TAB> <TAB> <TAB> <TAB> ""webbridge."" + self. configkey, <TAB> <TAB> <TAB> ) <",False,not certfile,not self.has_section and (not self.has_section),0.6758914589881897
|
||
|
2864,"def upload ( self, token, filename, name, finishCallback = None, endpoint = None ) : <TAB> _, ext = os. path. splitext ( filename ) <TAB> if ext == "".csv"" : <TAB> <TAB> tmpdir = tempfile. mkdtemp ( ) <TAB> <TAB> self. _log ( ""Temporary dir {} created"". format ( tmpdir ) ) <TAB> <TAB> try : <TAB> <TAB> <TAB> self. _log ( ""Prepare csv data"" ) <TAB> <TAB> <TAB> csv_data, data_files = self. createCsvData ( filename ) <TAB> <TAB> <TAB> self. _log ( ""Prepare tar file"" ) <TAB> <TAB> <TAB> tarfile = self. createTemporaryTar ( name, csv_data, data_files, tmpdir ) <TAB> <TAB> <TAB> self. _log ( ""Upload"" ) <TAB> <TAB> <TAB> res = self. uploadFile ( endpoint, token, tarfile, name ) <TAB> <TAB> finally : <TAB> <TAB> <TAB> shutil. rmtree ( tmpdir, ignore_errors = True ) <TAB> <TAB> <TAB> self. _log ( ""Temporary dir removed"" ) <TAB> <TAB> if res : <TAB> <TAB> <TAB> self. _log ( ""Finished"" ) <TAB> elif ext == "".tar"" : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _log ( ""Finished"" ) <TAB> else : <TAB> <TAB> self. _log ( ""filename with extension {} is not supported."". format ( ext ) ) <TAB> <TAB> if finishCallback is not None : <TAB> <TAB> <TAB> finishCallback ( False ) <TAB> <TAB> return <TAB> if finishCallback is not None : <TAB> <TAB> finishCallback ( True )",False,"self.uploadFile(endpoint, token, filename, name)",res,0.645522952079773
|
||
|
2865,"def fix_file ( filename, options = None, output = None, apply_config = False ) : <TAB> if not options : <TAB> <TAB> options = parse_args ( [ filename ], apply_config = apply_config ) <TAB> original_source = readlines_from_file ( filename ) <TAB> fixed_source = original_source <TAB> if options. in_place or output : <TAB> <TAB> encoding = detect_encoding ( filename ) <TAB> if<mask> : <TAB> <TAB> output = LineEndingWrapper ( wrap_output ( output, encoding = encoding ) ) <TAB> fixed_source = fix_lines ( fixed_source, options, filename = filename ) <TAB> if options. diff : <TAB> <TAB> new = io. StringIO ( fixed_source ) <TAB> <TAB> new = new. readlines ( ) <TAB> <TAB> diff = get_diff_text ( original_source, new, filename ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> output. write ( diff ) <TAB> <TAB> <TAB> output. flush ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return diff <TAB> elif options. in_place : <TAB> <TAB> fp = open_with_encoding ( filename, encoding = encoding, mode = ""w"" ) <TAB> <TAB> fp. write ( fixed_source ) <TAB> <TAB> fp. close ( ) <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> output. write ( fixed_source ) <TAB> <TAB> <TAB> output. flush ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return fixed_source",False,output,diff,0.6865870952606201
|
||
|
2866,"def update_variable_types ( self, func_addr, var_to_typevar ) : <TAB> for var, typevar in var_to_typevar. items ( ) : <TAB> <TAB> type_ = self. simtypes_solution. get ( typevar, None ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. kb. variables [ func_addr ]. types [ var ] = type_",True,type_ is not None,type_ is not None,0.6604834794998169
|
||
|
2867,"def filter_documentation ( cls ) : <TAB> result = [ ] <TAB> for sc in TrackSubClasses. sorted_by_kind ( cls ) : <TAB> <TAB> default_subfilter = getattr ( sc, ""__default_subfilter__"", None ) <TAB> <TAB> result. extend ( ( "" * %s - %s"" % ( sc. __kind__, sc. __doc__ ), ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> for key, doc in sc. __supported_subfilters__. items ( ) : <TAB> <TAB> <TAB> <TAB> result. append ( <TAB> <TAB> <TAB> <TAB> <TAB> "" %s%s%s... %s"" <TAB> <TAB> <TAB> <TAB> <TAB> % ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""["" if key == default_subfilter else """", <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> key, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""]"" if key == default_subfilter else """", <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> doc, <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> ) <TAB> result. append ( ""\n[]... Parameter can be supplied as unnamed value\n"" ) <TAB> return ""\n"". join ( result )",True,"hasattr(sc, '__supported_subfilters__')","hasattr(sc, '__supported_subfilters__')",0.6513280868530273
|
||
|
2868,"def download_subtitle ( self, subtitle ) : <TAB> r = self. session. get ( <TAB> <TAB> subtitle. download_link, headers = { ""Referer"" : self. api_url }, timeout = 10 <TAB> ) <TAB> r. raise_for_status ( ) <TAB> <TAB> archive_stream = io. BytesIO ( r. content ) <TAB> if is_rarfile ( archive_stream ) : <TAB> <TAB> logger. debug ( ""[#### Provider: titrari.ro] Archive identified as rar"" ) <TAB> <TAB> archive = RarFile ( archive_stream ) <TAB> elif is_zipfile ( archive_stream ) : <TAB> <TAB> logger. debug ( ""[#### Provider: titrari.ro] Archive identified as zip"" ) <TAB> <TAB> archive = ZipFile ( archive_stream ) <TAB> else : <TAB> <TAB> subtitle. content = r. content <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return <TAB> <TAB> subtitle. content = None <TAB> <TAB> raise ProviderError ( ""[#### Provider: titrari.ro] Unidentified archive type"" ) <TAB> subtitle. content = self. get_subtitle_from_archive ( subtitle, archive )",False,subtitle.is_valid(),subtitle.content == None,0.6502878069877625
|
||
|
2869,"def deleteOutline ( self, event = None, op_name = ""Delete Node"" ) : <TAB> """"""Deletes the selected outline."""""" <TAB> c, u = self, self. undoer <TAB> p = c. p <TAB> if not p : <TAB> <TAB> return <TAB> c. endEditing ( ) <TAB> if False : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> newNode = p. visNext ( c ) <TAB> <TAB> elif p. hasParent ( ) : <TAB> <TAB> <TAB> newNode = p. parent ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> newNode = p. back ( ) <TAB> else : <TAB> <TAB> <TAB> <TAB> if p. hasVisBack ( c ) : <TAB> <TAB> <TAB> newNode = p. visBack ( c ) <TAB> <TAB> else : <TAB> <TAB> <TAB> newNode = p. next ( ) <TAB> if not newNode : <TAB> <TAB> return <TAB> undoData = u. beforeDeleteNode ( p ) <TAB> dirtyVnodeList = p. setAllAncestorAtFileNodesDirty ( ) <TAB> p. doDelete ( newNode ) <TAB> c. setChanged ( True ) <TAB> u. afterDeleteNode ( newNode, op_name, undoData, dirtyVnodeList = dirtyVnodeList ) <TAB> c. redraw ( newNode ) <TAB> c. validateOutline ( )",True,p.hasVisNext(c),p.hasVisNext(c),0.6554625034332275
|
||
|
2870,"def _find_single_string ( <TAB> self, call, body, name ) : <TAB> value = self. _find_in_call ( call, name ) <TAB> if value is None : <TAB> <TAB> <TAB> <TAB> kwargs = self. _find_call_kwargs ( call ) <TAB> <TAB> if kwargs is None or not isinstance ( kwargs, ast. Name ) : <TAB> <TAB> <TAB> return <TAB> <TAB> variable = self. _find_variable_in_body ( body, kwargs. id ) <TAB> <TAB> if not isinstance ( variable, ( ast. Dict, ast. Call ) ) : <TAB> <TAB> <TAB> return <TAB> <TAB> if isinstance ( variable, ast. Call ) : <TAB> <TAB> <TAB> if not isinstance ( variable. func, ast. Name ) : <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> if variable. func. id!= ""dict"" : <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> value = self. _find_in_call ( variable, name ) <TAB> <TAB> else : <TAB> <TAB> <TAB> value = self. _find_in_dict ( variable, name ) <TAB> if value is None : <TAB> <TAB> return <TAB> if isinstance ( value, ast. Str ) : <TAB> <TAB> return value. s <TAB> elif isinstance ( value, ast. Name ) : <TAB> <TAB> variable = self. _find_variable_in_body ( body, value. id ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return variable. s",False,"variable is not None and isinstance(variable, ast.Str)",variable is not None,0.6507863402366638
|
||
|
2871,"def names ( self, persistent = None ) : <TAB> u = set ( ) <TAB> result = [ ] <TAB> for s in [ <TAB> <TAB> self. __storage ( None ), <TAB> <TAB> self. __storage ( self. __category ), <TAB> ] : <TAB> <TAB> for b in s : <TAB> <TAB> <TAB> if persistent is not None and b. persistent!= persistent : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if b. name not in u : <TAB> <TAB> <TAB> <TAB> result. append ( b. name ) <TAB> <TAB> <TAB> <TAB> u. add ( b. name ) <TAB> return result",False,b.name.startswith('__'),b.name is None,0.6507259011268616
|
||
|
2872,"def find_id ( self, doc_id ) : <TAB> self. _lock. acquire ( ) <TAB> try : <TAB> <TAB> doc = self. _docs. get ( doc_id ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> doc = copy. deepcopy ( doc ) <TAB> <TAB> <TAB> doc [ ""id"" ] = doc_id <TAB> <TAB> <TAB> return doc <TAB> finally : <TAB> <TAB> self. _lock. release ( )",True,doc,doc,0.6938542127609253
|
||
|
2873,"def _oauth2_web_server_flow_params ( kwargs ) : <TAB> """"""Configures redirect URI parameters for OAuth2WebServerFlow."""""" <TAB> params = { <TAB> <TAB> ""access_type"" : ""offline"", <TAB> <TAB> ""response_type"" : ""code"", <TAB> } <TAB> params. update ( kwargs ) <TAB> <TAB> <TAB> approval_prompt = params. get ( ""approval_prompt"" ) <TAB> if approval_prompt is not None : <TAB> <TAB> logger. warning ( <TAB> <TAB> <TAB> ""The approval_prompt parameter for OAuth2WebServerFlow is "" <TAB> <TAB> <TAB> ""deprecated. Please use the prompt parameter instead."" <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> logger. warning ( <TAB> <TAB> <TAB> <TAB> 'approval_prompt=""force"" has been adjusted to''prompt=""consent""' <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> params [ ""prompt"" ] = ""consent"" <TAB> <TAB> <TAB> del params [ ""approval_prompt"" ] <TAB> return params",False,approval_prompt == 'force',force_force is not None,0.659172534942627
|
||
|
2874,"def download ( self, url, filename, ** kwargs ) : <TAB> try : <TAB> <TAB> r = self. get ( url, timeout = 10, stream = True, ** kwargs ) <TAB> <TAB> if r. status_code >= 400 : <TAB> <TAB> <TAB> return False <TAB> <TAB> with open ( filename, ""wb"" ) as f : <TAB> <TAB> <TAB> for chunk in r. iter_content ( chunk_size = 1024 ) : <TAB> <TAB> <TAB> <TAB> if chunk : <TAB> <TAB> <TAB> <TAB> <TAB> f. write ( chunk ) <TAB> <TAB> helpers. chmod_as_parent ( filename ) <TAB> except Exception as e : <TAB> <TAB> sickrage. app. log. debug ( <TAB> <TAB> <TAB> ""Failed to download file from {} - ERROR: {}"". format ( url, e ) <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> os. remove ( filename ) <TAB> <TAB> return False <TAB> return True",True,os.path.exists(filename),os.path.exists(filename),0.6462802290916443
|
||
|
2875,"def search_event ( self, event_handle ) : <TAB> if not event_handle : <TAB> <TAB> return False <TAB> <TAB> if not event_handle in self. event_map : <TAB> <TAB> match = 0 <TAB> <TAB> event = self. db. get_event_from_handle ( event_handle ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> match = 1 <TAB> <TAB> elif event : <TAB> <TAB> <TAB> place_handle = event. get_place_handle ( ) <TAB> <TAB> <TAB> if place_handle and self. search_place ( place_handle ) : <TAB> <TAB> <TAB> <TAB> match = 1 <TAB> <TAB> <TAB> if any ( <TAB> <TAB> <TAB> <TAB> self. search_media ( media_ref. get_reference_handle ( ) ) <TAB> <TAB> <TAB> <TAB> for media_ref in event. get_media_list ( ) <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> return True <TAB> <TAB> if match : <TAB> <TAB> <TAB> self. event_map. add ( event_handle ) <TAB> return event_handle in self. event_map",False,self.match_object(event),not event,0.6504517197608948
|
||
|
2876,"def effective ( line ) : <TAB> for b in line : <TAB> <TAB> if not b. cond : <TAB> <TAB> <TAB> return <TAB> <TAB> else : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> val = 5 <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> if b. ignore : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> b. ignore -= 1 <TAB> <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return ( b, True ) <TAB> <TAB> <TAB> except : <TAB> <TAB> <TAB> <TAB> return ( b, False ) <TAB> return",False,val,val > 6,0.6950522661209106
|
||
|
2877,"def check_if_admin ( self, auth ) : <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. conn. sql_query ( ""EXEC sp_helpsrvrolemember'sysadmin'"" ) <TAB> <TAB> self. conn. printRows ( ) <TAB> <TAB> query_output = self. conn. _MSSQL__rowsPrinter. getMessage ( ) <TAB> <TAB> logging. debug ( ""'sysadmin' group members:\n{}"". format ( query_output ) ) <TAB> <TAB> if not auth : <TAB> <TAB> <TAB> search_string = ""{}\\{}"". format ( self. domain, self. username ) <TAB> <TAB> else : <TAB> <TAB> <TAB> search_string = self. username <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. admin_privs = True <TAB> <TAB> else : <TAB> <TAB> <TAB> return False <TAB> except Exception as e : <TAB> <TAB> self. logger. error ( ""Error calling check_if_admin(): {}"". format ( e ) ) <TAB> <TAB> return False <TAB> return True",False,"re.search('\\b' + search_string + '\\W', query_output)",self.admin_privs and search_string in self.username,0.6501891613006592
|
||
|
2878,"def __init__ ( <TAB> self, toklist = None, name = None, asList = True, modal = True, isinstance = isinstance ) : <TAB> if self. __doinit : <TAB> <TAB> self. __doinit = False <TAB> <TAB> self. __name = None <TAB> <TAB> self. __parent = None <TAB> <TAB> self. __accumNames = { } <TAB> <TAB> self. __asList = asList <TAB> <TAB> self. __modal = modal <TAB> <TAB> if toklist is None : <TAB> <TAB> <TAB> toklist = [ ] <TAB> <TAB> if isinstance ( toklist, list ) : <TAB> <TAB> <TAB> self. __toklist = toklist [ : ] <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> self. __toklist = list ( toklist ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. __toklist = [ toklist ] <TAB> <TAB> self. __tokdict = dict ( ) <TAB> if name is not None and name : <TAB> <TAB> if not modal : <TAB> <TAB> <TAB> self. __accumNames [ name ] = 0 <TAB> <TAB> if isinstance ( name, int ) : <TAB> <TAB> <TAB> name = _ustr ( <TAB> <TAB> <TAB> <TAB> name <TAB> <TAB> <TAB> ) <TAB> <TAB> self. __name = name <TAB> <TAB> if not ( <TAB> <TAB> <TAB> isinstance ( toklist, ( type ( None ), basestring, list ) ) <TAB> <TAB> <TAB> and toklist in ( None, """", [ ] ) <TAB> <TAB> ) : <TAB> <TAB> <TAB> if isinstance ( toklist, basestring ) : <TAB> <TAB> <TAB> <TAB> toklist = [ toklist ] <TAB> <TAB> <TAB> if asList : <TAB> <TAB> <TAB> <TAB> if isinstance ( toklist, ParseResults ) : <TAB> <TAB> <TAB> <TAB> <TAB> self [ name ]",False,"isinstance(toklist, _generatorType)","isinstance(toklist, ParseResults)",0.6552891135215759
|
||
|
2879,"def fill_buf ( self, db, len_ = None ) : <TAB> with open ( ""/dev/urandom"", ""rb"" ) as rfh : <TAB> <TAB> first = True <TAB> <TAB> for ( id_, ) in db. query ( ""SELECT id FROM test"" ) : <TAB> <TAB> <TAB> if len_ is None and first : <TAB> <TAB> <TAB> <TAB> val = b"""" <TAB> <TAB> <TAB> <TAB> first = False <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> val = rfh. read ( random. randint ( 0, 140 ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> val = rfh. read ( len_ ) <TAB> <TAB> <TAB> db. execute ( ""UPDATE test SET buf=? WHERE id=?"", ( val, id_ ) )",True,len_ is None,len_ is None,0.6642588973045349
|
||
|
2880,"def _target_generator ( self ) : <TAB> <TAB> if self. _internal_target_generator is None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return None <TAB> <TAB> from.... model_zoo. ssd. target import SSDTargetGenerator <TAB> <TAB> self. _internal_target_generator = SSDTargetGenerator ( <TAB> <TAB> <TAB> iou_thresh = self. _iou_thresh, <TAB> <TAB> <TAB> stds = self. _box_norm, <TAB> <TAB> <TAB> negative_mining_ratio = - 1, <TAB> <TAB> <TAB> ** self. _kwargs <TAB> <TAB> ) <TAB> <TAB> return self. _internal_target_generator <TAB> else : <TAB> <TAB> return self. _internal_target_generator",False,self._anchors_none,self._box_norm is None or self._kwargs[0] is None,0.6591485738754272
|
||
|
2881,"def rclone_check_progress ( job, proc ) : <TAB> cutter = RcloneVerboseLogCutter ( 300 ) <TAB> dropbox__restricted_content = False <TAB> try : <TAB> <TAB> while True : <TAB> <TAB> <TAB> read = ( await proc. stdout. readline ( ) ). decode ( ""utf-8"", ""ignore"" ) <TAB> <TAB> <TAB> if read == """" : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> if ""failed to open source object: path/restricted_content/"" in read : <TAB> <TAB> <TAB> <TAB> job. internal_data [ ""dropbox__restricted_content"" ] = True <TAB> <TAB> <TAB> <TAB> dropbox__restricted_content = True <TAB> <TAB> <TAB> result = cutter. notify ( read ) <TAB> <TAB> <TAB> if result : <TAB> <TAB> <TAB> <TAB> job. logs_fd. write ( result. encode ( ""utf-8"", ""ignore"" ) ) <TAB> <TAB> <TAB> reg = RE_TRANSF. search ( read ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> job. set_progress ( <TAB> <TAB> <TAB> <TAB> <TAB> int ( reg. group ( ""progress"" ) ), <TAB> <TAB> <TAB> <TAB> <TAB> reg. group ( ""progress_1"" ) + reg. group ( ""progress_2"" ), <TAB> <TAB> <TAB> <TAB> ) <TAB> finally : <TAB> <TAB> result = cutter. flush ( ) <TAB> <TAB> if result : <TAB> <TAB> <TAB> job. logs_fd. write ( result. encode ( ""utf-8"", ""ignore"" ) ) <TAB> if dropbox__restricted_content : <TAB> <TAB> message = ""\n"" + ( <TAB> <TAB> <TAB> ""Dropbox sync failed due to restricted content being present in one of the folders. This may include\n"" <TAB> <TAB> <TAB> ""copyrighted content",True,reg,reg,0.6758143901824951
|
||
|
2882,"def one_gpr_reg_one_mem_scalable ( ii ) : <TAB> n, r = 0, 0 <TAB> for op in _gen_opnds ( ii ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> n += 1 <TAB> <TAB> elif op_gprv ( op ) : <TAB> <TAB> <TAB> r += 1 <TAB> <TAB> else : <TAB> <TAB> <TAB> return False <TAB> return n == 1 and r == 1",False,op_agen(op) or (op_mem(op) and op.oc2 in ['v']),op_gprt(op),0.6512327194213867
|
||
|
2883,def finalize ( self ) : <TAB> if self. ct < 1 : <TAB> <TAB> return <TAB> elif self. ct == 1 : <TAB> <TAB> return 0 <TAB> total = ct = 0 <TAB> dtp = None <TAB> while self. heap : <TAB> <TAB> if total == 0 : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> dtp = heapq. heappop ( self. heap ) <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> dt = heapq. heappop ( self. heap ) <TAB> <TAB> diff = dt - dtp <TAB> <TAB> ct += 1 <TAB> <TAB> total += total_seconds ( diff ) <TAB> <TAB> dtp = dt <TAB> return float ( total ) / ct,True,dtp is None,dtp is None,0.667366087436676
|
||
|
2884,"def awaitTermination ( self, timeout = None ) : <TAB> if self. scheduler is None : <TAB> <TAB> raise RuntimeError ( ""StreamimgContext not started"" ) <TAB> try : <TAB> <TAB> deadline = time. time ( ) + timeout if timeout is not None else None <TAB> <TAB> while True : <TAB> <TAB> <TAB> is_terminated = self. _runOnce ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> if self. batchCallback : <TAB> <TAB> <TAB> <TAB> self. batchCallback ( ) <TAB> except KeyboardInterrupt : <TAB> <TAB> pass <TAB> finally : <TAB> <TAB> self. sc. stop ( ) <TAB> <TAB> logger. info ( ""StreamingContext stopped successfully"" )",False,is_terminated or (deadline is not None and time.time() > deadline),is_terminated,0.6506879329681396
|
||
|
2885,"def __init__ ( self, fileobj, length ) : <TAB> """"""Raises DescriptorError"""""" <TAB> r = BitReader ( fileobj ) <TAB> try : <TAB> <TAB> self. objectTypeIndication = r. bits ( 8 ) <TAB> <TAB> self. streamType = r. bits ( 6 ) <TAB> <TAB> self. upStream = r. bits ( 1 ) <TAB> <TAB> self. reserved = r. bits ( 1 ) <TAB> <TAB> self. bufferSizeDB = r. bits ( 24 ) <TAB> <TAB> self. maxBitrate = r. bits ( 32 ) <TAB> <TAB> self. avgBitrate = r. bits ( 32 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> <TAB> if length * 8 == r. get_position ( ) : <TAB> <TAB> <TAB> return <TAB> <TAB> tag = r. bits ( 8 ) <TAB> except BitReaderError as e : <TAB> <TAB> raise DescriptorError ( e ) <TAB> if tag == DecoderSpecificInfo. TAG : <TAB> <TAB> assert r. is_aligned ( ) <TAB> <TAB> self. decSpecificInfo = DecoderSpecificInfo. parse ( fileobj )",False,"self.objectTypeIndication, self.streamType)!= (64, 5",length == r.get_position(),0.6527019739151001
|
||
|
2886,"def get_graph_label ( <TAB> self, <TAB> graph, <TAB> label = ""f(x)"", <TAB> x_val = None, <TAB> direction = RIGHT, <TAB> buff = MED_SMALL_BUFF, <TAB> color = None, ) : <TAB> label = Tex ( label ) <TAB> color = color or graph. get_color ( ) <TAB> label. set_color ( color ) <TAB> if x_val is None : <TAB> <TAB> <TAB> <TAB> for x in np. linspace ( self. x_max, self. x_min, 100 ) : <TAB> <TAB> <TAB> point = self. input_to_graph_point ( x, graph ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> x_val = x <TAB> label. next_to ( self. input_to_graph_point ( x_val, graph ), direction, buff = buff ) <TAB> label. shift_onto_screen ( ) <TAB> return label",False,point[1] < FRAME_Y_RADIUS,point is None,0.6518159508705139
|
||
|
2887,"def handle_embed ( self, embed ) : <TAB> log. warning ( embed ) <TAB> if log. ThugOpts. features_logging : <TAB> <TAB> log. ThugLogging. Features. increase_embed_count ( ) <TAB> src = embed. get ( ""src"", None ) <TAB> if src is None : <TAB> <TAB> src = embed. get ( ""data"", None ) <TAB> if src is None : <TAB> <TAB> return <TAB> if log. ThugOpts. features_logging : <TAB> <TAB> log. ThugLogging. Features. increase_url_count ( ) <TAB> headers = dict ( ) <TAB> embed_type = embed. get ( ""type"", None ) <TAB> if embed_type : <TAB> <TAB> headers [ ""Content-Type"" ] = embed_type <TAB> if ""Content-Type"" in headers : <TAB> <TAB> if ""java"" in headers [ ""Content-Type"" ] and log. ThugOpts. Personality. javaUserAgent : <TAB> <TAB> <TAB> headers [ ""User-Agent"" ] = self. javaUserAgent <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> headers [ ""x-flash-version"" ] = self. shockwaveFlash <TAB> try : <TAB> <TAB> self. window. _navigator. fetch ( src, headers = headers, redirect_type = ""embed"" ) <TAB> except Exception as e : <TAB> <TAB> log. info ( ""[ERROR][handle_embed] %s"", str ( e ) )",False,'flash' in headers['Content-Type'],self.shockwave Flash,0.6483078002929688
|
||
|
2888,"def __call__ ( self, results ) : <TAB> """"""Perform data augmentation with random image flip."""""" <TAB> if np. random. rand ( ) > self. flip_prob : <TAB> <TAB> return results <TAB> img = results [ ""img"" ] <TAB> joints_2d = results [ ""joints_2d"" ] <TAB> joints_2d_visible = results [ ""joints_2d_visible"" ] <TAB> joints_3d = results [ ""joints_3d"" ] <TAB> joints_3d_visible = results [ ""joints_3d_visible"" ] <TAB> pose = results [ ""pose"" ] <TAB> center = results [ ""center"" ] <TAB> img = img [ :, : : - 1, : ] <TAB> pose = _flip_smpl_pose ( pose ) <TAB> joints_2d, joints_2d_visible = fliplr_joints ( <TAB> <TAB> joints_2d, joints_2d_visible, img. shape [ 1 ], results [ ""ann_info"" ] [ ""flip_pairs"" ] <TAB> ) <TAB> joints_3d, joints_3d_visible = _flip_joints_3d ( <TAB> <TAB> joints_3d, joints_3d_visible, results [ ""ann_info"" ] [ ""flip_pairs"" ] <TAB> ) <TAB> center [ 0 ] = img. shape [ 1 ] - center [ 0 ] - 1 <TAB> if ""iuv"" in results. keys ( ) : <TAB> <TAB> iuv = results [ ""iuv"" ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> iuv = _flip_iuv ( iuv, results [ ""ann_info"" ] [ ""uv_type"" ] ) <TAB> <TAB> results [ ""iuv"" ] = iuv <TAB> results [ ""img"" ] = img <TAB> results [ ""joints_2d"" ] = joints_2d <TAB> results [ ""joints_2d_visible"" ] = joints_2d_visible <TAB> results [ ""joints_3",False,iuv is not None,'uv_type' in results.keys(),0.665052056312561
|
||
|
2889,"def payments_for_address ( self, address ) : <TAB> ""return an array of (TX ids, net_payment)"" <TAB> URL = self. api_domain + ( ""/address/%s?format=json"" % address ) <TAB> d = urlopen ( URL ). read ( ) <TAB> json_response = json. loads ( d. decode ( ""utf8"" ) ) <TAB> response = [ ] <TAB> for tx in json_response. get ( ""txs"", [ ] ) : <TAB> <TAB> total_out = 0 <TAB> <TAB> for tx_out in tx. get ( ""out"", [ ] ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> total_out += tx_out. get ( ""value"", 0 ) <TAB> <TAB> if total_out > 0 : <TAB> <TAB> <TAB> response. append ( ( tx. get ( ""hash"" ), total_out ) ) <TAB> return response",False,tx_out.get('addr') == address,tx_out > 0,0.6535117626190186
|
||
|
2890,"def __enter__ ( self ) : <TAB> host, port, ssl = urlsplit ( self. host ) <TAB> http = httplib. HTTPSConnection if ssl else httplib. HTTPConnection <TAB> for _ in range ( MAX_RETRY_COUNT ) : <TAB> <TAB> self. con = http ( host, port, timeout = self. timeout ) <TAB> <TAB> try : <TAB> <TAB> <TAB> self. con. request ( self. method, self. path, headers = self. headers ) <TAB> <TAB> except ( httplib. HTTPException, socket. error ) : <TAB> <TAB> <TAB> return None <TAB> <TAB> try : <TAB> <TAB> <TAB> resp = self. con. getresponse ( ) <TAB> <TAB> <TAB> if resp. status == 301 : <TAB> <TAB> <TAB> <TAB> location = resp. getheader ( ""Location"" ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> self. con. close ( ) <TAB> <TAB> <TAB> <TAB> <TAB> self. path = urlparse ( location ). path <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> return None <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> return resp <TAB> <TAB> except ( httplib. HTTPException, socket. timeout, socket. error ) : <TAB> <TAB> <TAB> return None",True,location,location,0.6800907254219055
|
||
|
2891,"def _format_float_column ( precision, col ) : <TAB> format_str = ""%."" + str ( precision ) + ""f"" <TAB> assert col. ndim == 1 <TAB> <TAB> simple_float_chars = set ( ""+-0123456789."" ) <TAB> col_strs = np. array ( [ format_str % ( x, ) for x in col ], dtype = object ) <TAB> <TAB> <TAB> mask = np. array ( <TAB> <TAB> [ <TAB> <TAB> <TAB> simple_float_chars. issuperset ( col_str ) and ""."" in col_str <TAB> <TAB> <TAB> for col_str in col_strs <TAB> <TAB> ] <TAB> ) <TAB> mask_idxes = np. nonzero ( mask ) [ 0 ] <TAB> strip_char = ""0"" <TAB> if np. any ( mask ) : <TAB> <TAB> while True : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> for idx in mask_idxes : <TAB> <TAB> <TAB> <TAB> <TAB> col_strs [ idx ] = col_strs [ idx ] [ : - 1 ] <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> if strip_char == ""0"" : <TAB> <TAB> <TAB> <TAB> <TAB> strip_char = ""."" <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> return col_strs",False,np.all([s.endswith(strip_char) for s in col_strs[mask]]),len(mask_idxes) > 0,0.653414785861969
|
||
|
2892,"def _skip_unused_header_bits_normal ( bitreader, channel_mode ) : <TAB> r = bitreader <TAB> r. skip ( 5 ) <TAB> if r. bits ( 1 ) : <TAB> <TAB> r. skip ( 8 ) <TAB> if r. bits ( 1 ) : <TAB> <TAB> r. skip ( 8 ) <TAB> if r. bits ( 1 ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> r. skip ( 7 ) <TAB> if channel_mode == ChannelMode. DUALMONO : <TAB> <TAB> r. skip ( 5 ) <TAB> <TAB> if r. bits ( 1 ) : <TAB> <TAB> <TAB> r. skip ( 8 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> r. skip ( 8 ) <TAB> <TAB> if r. bits ( 1 ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> r. skip ( 7 ) <TAB> <TAB> <TAB> r. skip ( 2 ) <TAB> timecod1e = r. bits ( 1 ) <TAB> timecod2e = r. bits ( 1 ) <TAB> if timecod1e : <TAB> <TAB> r. skip ( 14 ) <TAB> if timecod2e : <TAB> <TAB> r. skip ( 14 ) <TAB> if r. bits ( 1 ) : <TAB> <TAB> addbsil = r. bit ( 6 ) <TAB> <TAB> r. skip ( ( addbsil + 1 ) * 8 )",False,r.bits(1),r.bits(2),0.6511002779006958
|
||
|
2893,"def _delete ( self, obj, entire_dir = False, ** kwargs ) : <TAB> rel_path = self. _construct_path ( obj, ** kwargs ) <TAB> extra_dir = kwargs. get ( ""extra_dir"", None ) <TAB> base_dir = kwargs. get ( ""base_dir"", None ) <TAB> dir_only = kwargs. get ( ""dir_only"", False ) <TAB> obj_dir = kwargs. get ( ""obj_dir"", False ) <TAB> try : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> shutil. rmtree ( os. path. abspath ( rel_path ) ) <TAB> <TAB> <TAB> return True <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if entire_dir and extra_dir : <TAB> <TAB> <TAB> shutil. rmtree ( self. _get_cache_path ( rel_path ) ) <TAB> <TAB> <TAB> results = self. bucket. objects. list ( prefix = rel_path ) <TAB> <TAB> <TAB> for key in results : <TAB> <TAB> <TAB> <TAB> log. debug ( ""Deleting key %s"", key. name ) <TAB> <TAB> <TAB> <TAB> key. delete ( ) <TAB> <TAB> <TAB> return True <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> os. unlink ( self. _get_cache_path ( rel_path ) ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if self. _key_exists ( rel_path ) : <TAB> <TAB> <TAB> <TAB> key = self. bucket. objects. get ( rel_path ) <TAB> <TAB> <TAB> <TAB> log. debug ( ""Deleting key %s"", key. name ) <TAB> <TAB> <TAB> <TAB> key. delete ( ) <TAB> <TAB> <TAB> <TAB> return True <TAB> except Exception : <TAB> <TAB> log. exception ( ""Could not delete key '%s",False,base_dir and dir_only and obj_dir,dir_only and self.dir_only,0.6498885154724121
|
||
|
2894,"def compute_backslash_indent ( self ) : <TAB> <TAB> self. _study2 ( ) <TAB> assert self. continuation == C_BACKSLASH <TAB> str = self. str <TAB> i = self. stmt_start <TAB> while str [ i ] in "" \t"" : <TAB> <TAB> i = i + 1 <TAB> startpos = i <TAB> <TAB> <TAB> endpos = str. find ( ""\n"", startpos ) + 1 <TAB> found = level = 0 <TAB> while i < endpos : <TAB> <TAB> ch = str [ i ] <TAB> <TAB> if ch in ""([{"" : <TAB> <TAB> <TAB> level = level + 1 <TAB> <TAB> <TAB> i = i + 1 <TAB> <TAB> elif ch in "")]}"" : <TAB> <TAB> <TAB> if level : <TAB> <TAB> <TAB> <TAB> level = level - 1 <TAB> <TAB> <TAB> i = i + 1 <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> i = _match_stringre ( str, i, endpos ). end ( ) <TAB> <TAB> elif ch == ""#"" : <TAB> <TAB> <TAB> break <TAB> <TAB> elif ( <TAB> <TAB> <TAB> level == 0 <TAB> <TAB> <TAB> and ch == ""="" <TAB> <TAB> <TAB> and ( i == 0 or str [ i - 1 ] not in ""=<>!"" ) <TAB> <TAB> <TAB> and str [ i + 1 ]!= ""="" <TAB> <TAB> ) : <TAB> <TAB> <TAB> found = 1 <TAB> <TAB> <TAB> break <TAB> <TAB> else : <TAB> <TAB> <TAB> i = i + 1 <TAB> if found : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> i = i + 1 <TAB> <TAB> found = re. match ( r""\s*\\"", str [ i : endpos ] ) is None <TAB> if not found : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> i =",False,"ch == '""' or ch == ""'""",i > 0,0.6636523008346558
|
||
|
2895,"def restoreSelection ( self ) : <TAB> if not self. cards : <TAB> <TAB> return <TAB> sm = self. browser. form. tableView. selectionModel ( ) <TAB> sm. clear ( ) <TAB> <TAB> items = QItemSelection ( ) <TAB> count = 0 <TAB> firstIdx = None <TAB> focusedIdx = None <TAB> for row, id in enumerate ( self. cards ) : <TAB> <TAB> <TAB> <TAB> if self. focusedCard == id : <TAB> <TAB> <TAB> focusedIdx = self. index ( row, 0 ) <TAB> <TAB> <TAB> items. select ( focusedIdx, focusedIdx ) <TAB> <TAB> <TAB> self. focusedCard = None <TAB> <TAB> <TAB> <TAB> if id in self. selectedCards : <TAB> <TAB> <TAB> count += 1 <TAB> <TAB> <TAB> idx = self. index ( row, 0 ) <TAB> <TAB> <TAB> items. select ( idx, idx ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> firstIdx = idx <TAB> <TAB> idx = focusedIdx or firstIdx <TAB> tv = self. browser. form. tableView <TAB> if idx : <TAB> <TAB> tv. selectRow ( idx. row ( ) ) <TAB> <TAB> tv. scrollTo ( idx, tv. PositionAtCenter ) <TAB> <TAB> if count < 500 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> sm. select ( <TAB> <TAB> <TAB> <TAB> items, QItemSelectionModel. SelectCurrent | QItemSelectionModel. Rows <TAB> <TAB> <TAB> ) <TAB> else : <TAB> <TAB> tv. selectRow ( 0 )",False,not firstIdx,firstIdx is None,0.6710411906242371
|
||
|
2896,"def command ( cmd ) : <TAB> global _current_group <TAB> cmd = cmd. lstrip ( ) <TAB> if cmd. startswith ( ""let g:"" ) : <TAB> <TAB> import re <TAB> <TAB> varname, value = re. compile ( r""^let g:(\w+)\s*=\s*(.*)"" ). match ( cmd ). groups ( ) <TAB> <TAB> vars [ varname ] = value <TAB> elif cmd. startswith ( ""hi "" ) : <TAB> <TAB> sp = cmd. split ( ) <TAB> <TAB> _highlights [ sp [ 1 ] ] = sp [ 2 : ] <TAB> elif cmd. startswith ( ""augroup"" ) : <TAB> <TAB> augroup = cmd. partition ( "" "" ) [ 2 ] <TAB> <TAB> if augroup. upper ( ) == ""END"" : <TAB> <TAB> <TAB> _current_group = None <TAB> <TAB> else : <TAB> <TAB> <TAB> _current_group = augroup <TAB> elif cmd. startswith ( ""autocmd"" ) : <TAB> <TAB> rest = cmd. partition ( "" "" ) [ 2 ] <TAB> <TAB> auevent, rest = rest. partition ( "" "" ) [ : : 2 ] <TAB> <TAB> pattern, aucmd = rest. partition ( "" "" ) [ : : 2 ] <TAB> <TAB> if auevent!= ""BufWipeout"" or pattern!= ""*"" : <TAB> <TAB> <TAB> raise NotImplementedError <TAB> <TAB> import sys <TAB> <TAB> if sys. version_info < ( 3, ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise NotImplementedError <TAB> <TAB> else : <TAB> <TAB> <TAB> if not aucmd. startswith ( "":python3 "" ) : <TAB> <TAB> <TAB> <TAB> raise NotImplementedError <TAB> <TAB> _on_wipeout. append ( aucmd. partition ( "" "" ) [ 2 ] ) <TAB> elif cmd. startswith ( ""set "" ) : <TAB> <TAB> if cmd. startswith ( ""set statusline="" ) : <TAB> <TAB> <TAB",False,not aucmd.startswith(':python '),not aucmd,0.6541320085525513
|
||
|
2897,"def evaluate ( net, dataloader ) : <TAB> """"""Evaluate network on the specified dataset"""""" <TAB> total_L = 0.0 <TAB> total_sample_num = 0 <TAB> total_correct_num = 0 <TAB> start_log_interval_time = time. time ( ) <TAB> print ( ""Begin Testing..."" ) <TAB> for i, ( data, label ) in enumerate ( dataloader ) : <TAB> <TAB> data = mx. nd. transpose ( data. as_in_context ( context ) ) <TAB> <TAB> label = label. as_in_context ( context ) <TAB> <TAB> output = net ( data ) <TAB> <TAB> L = loss ( output, label ) <TAB> <TAB> pred = nd. argmax ( output, axis = 1 ) <TAB> <TAB> total_L += L. sum ( ). asscalar ( ) <TAB> <TAB> total_sample_num += label. shape [ 0 ] <TAB> <TAB> total_correct_num += ( pred. astype ( ""int"" ) == label ). sum ( ). asscalar ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> ""[Batch {}/{}] elapsed {:.2f} s"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> i + 1, len ( dataloader ), time. time ( ) - start_log_interval_time <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> start_log_interval_time = time. time ( ) <TAB> avg_L = total_L / float ( total_sample_num ) <TAB> acc = total_correct_num / float ( total_sample_num ) <TAB> return avg_L, acc",False,(i + 1) % args.log_interval == 0,len(dataloading) > 0,0.6525769233703613
|
||
|
2898,"def _browse_toplist ( config, session, variant, region ) : <TAB> if region == ""countries"" : <TAB> <TAB> codes = config [ ""toplist_countries"" ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> codes = countries. COUNTRIES. keys ( ) <TAB> <TAB> return [ <TAB> <TAB> <TAB> models. Ref. directory ( <TAB> <TAB> <TAB> <TAB> uri = f""spotify:top:{variant}:{code.lower()}"", <TAB> <TAB> <TAB> <TAB> name = countries. COUNTRIES. get ( code. upper ( ), code. upper ( ) ), <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> for code in codes <TAB> <TAB> ] <TAB> if region in ( ""country"", ""everywhere"" ) : <TAB> <TAB> sp_toplist = session. get_toplist ( <TAB> <TAB> <TAB> type = _TOPLIST_TYPES [ variant ], <TAB> <TAB> <TAB> region = _TOPLIST_REGIONS [ region ] ( session ), <TAB> <TAB> ) <TAB> elif len ( region ) == 2 : <TAB> <TAB> sp_toplist = session. get_toplist ( <TAB> <TAB> <TAB> type = _TOPLIST_TYPES [ variant ], region = region. upper ( ) <TAB> <TAB> ) <TAB> else : <TAB> <TAB> return [ ] <TAB> if session. connection. state is spotify. ConnectionState. LOGGED_IN : <TAB> <TAB> sp_toplist. load ( config [ ""timeout"" ] ) <TAB> if not sp_toplist. is_loaded : <TAB> <TAB> return [ ] <TAB> if variant == ""tracks"" : <TAB> <TAB> return list ( translator. to_track_refs ( sp_toplist. tracks ) ) <TAB> elif variant == ""albums"" : <TAB> <TAB> return list ( <TAB> <TAB> <TAB> translator. to_album_refs ( sp_toplist. albums, timeout = config [ ""timeout"" ] ) <TAB> <TAB>",False,not codes,len(codes) == 1,0.6752448081970215
|
||
|
2899,"def _to_string_sequence ( x, force = True ) : <TAB> if isinstance ( x, ColumnString ) : <TAB> <TAB> return x. string_sequence <TAB> elif isinstance ( x, np. ndarray ) : <TAB> <TAB> mask = None <TAB> <TAB> if np. ma. isMaskedArray ( x ) : <TAB> <TAB> <TAB> mask = np. ma. getmaskarray ( x ) <TAB> <TAB> <TAB> x = x. data <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return ( <TAB> <TAB> <TAB> <TAB> vaex. strings. StringArray ( x ) <TAB> <TAB> <TAB> <TAB> if mask is None <TAB> <TAB> <TAB> <TAB> else vaex. strings. StringArray ( x, mask ) <TAB> <TAB> <TAB> ) <TAB> <TAB> elif x. dtype. kind in ""US"" : <TAB> <TAB> <TAB> x = x. astype ( ""O"" ) <TAB> <TAB> <TAB> return ( <TAB> <TAB> <TAB> <TAB> vaex. strings. StringArray ( x ) <TAB> <TAB> <TAB> <TAB> if mask is None <TAB> <TAB> <TAB> <TAB> else vaex. strings. StringArray ( x, mask ) <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if force : <TAB> <TAB> <TAB> <TAB> length = len ( x ) <TAB> <TAB> <TAB> <TAB> bytes = np. zeros ( ( 0, ), dtype = np. uint8 ) <TAB> <TAB> <TAB> <TAB> indices = np. zeros ( ( length + 1, ), dtype = np. int64 ) <TAB> <TAB> <TAB> <TAB> null_bitmap = np. ones ( ( ( length + 7 ) // 8, ), dtype = np. uint8 ) <TAB> <TAB> <TAB> <TAB> return vaex. strings. StringList64 ( <TAB>",False,x.dtype == 'O',x.dtype.kind in 'CC',0.6566579341888428
|
||
|
2900,"def _parse_policies ( self, policies_yaml ) : <TAB> for item in policies_yaml : <TAB> <TAB> id_ = required_key ( item, ""id"" ) <TAB> <TAB> controls_ids = required_key ( item, ""controls"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if controls_ids!= ""all"" : <TAB> <TAB> <TAB> <TAB> msg = ""Policy {id_} contains invalid controls list {controls}."". format ( <TAB> <TAB> <TAB> <TAB> <TAB> id_ = id_, controls = str ( controls_ids ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> raise ValueError ( msg ) <TAB> <TAB> self. policies [ id_ ] = controls_ids",False,"not isinstance(controls_ids, list)",id_ == 'invalid',0.6586120128631592
|
||
|
2901,def cut ( sentence ) : <TAB> sentence = strdecode ( sentence ) <TAB> blocks = re_han. split ( sentence ) <TAB> for blk in blocks : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> for word in __cut ( blk ) : <TAB> <TAB> <TAB> <TAB> if word not in Force_Split_Words : <TAB> <TAB> <TAB> <TAB> <TAB> yield word <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> for c in word : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> yield c <TAB> <TAB> else : <TAB> <TAB> <TAB> tmp = re_skip. split ( blk ) <TAB> <TAB> <TAB> for x in tmp : <TAB> <TAB> <TAB> <TAB> if x : <TAB> <TAB> <TAB> <TAB> <TAB> yield x,False,re_han.match(blk),blk,0.6532467007637024
|
||
|
2902,"def _EvaluateFile ( self, test_list, file ) : <TAB> ( name, ext ) = os. path. splitext ( file ) <TAB> if ext == "".cc"" or ext == "".cpp"" or ext == "".c"" : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> logger. SilentLog ( ""Found native test file %s"" % file ) <TAB> <TAB> <TAB> test_list. append ( name )",False,"re.search('_test$|_test_$|_unittest$|_unittest_$|^test_|Tests$', name)",name not in test_list,0.6552944779396057
|
||
|
2903,"def match ( img1, img2 ) : <TAB> if img1. ndim == 2 : <TAB> <TAB> temp = np. histogram ( img1, np. arange ( 257 ) ) [ 0 ] <TAB> <TAB> if img2. ndim == 2 : <TAB> <TAB> <TAB> hist = np. histogram ( img2, np. arange ( 257 ) ) [ 0 ] <TAB> <TAB> <TAB> ahist = like ( temp, hist ) <TAB> <TAB> <TAB> img2 [ : ] = ahist [ img2 ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> for i in range ( 3 ) : <TAB> <TAB> <TAB> <TAB> hist = np. histogram ( img2 [ :, :, i ], np. range ( 257 ) ) [ 0 ] <TAB> <TAB> <TAB> <TAB> ahist = like ( temp, hist ) <TAB> <TAB> <TAB> <TAB> img2 [ :, :, i ] = ahist [ img2 [ :, :, i ] ] <TAB> elif img1. ndim == 3 : <TAB> <TAB> if img2. ndim == 2 : <TAB> <TAB> <TAB> temp = np. histogram ( img1, np. arange ( 257 ) ) [ 0 ] <TAB> <TAB> <TAB> hist = np. histogram ( img2, np. arange ( 257 ) ) [ 0 ] <TAB> <TAB> <TAB> ahist = like ( temp, hist ) <TAB> <TAB> <TAB> img2 [ : ] = ahist [ img2 ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> for i in range ( 3 ) : <TAB> <TAB> <TAB> <TAB> temp = np. histogram ( img1 [ :, :, i ], np. arange ( 257 ) ) [ 0 ] <TAB> <TAB> <TAB> <TAB> hist = np. histogram ( img2 [ :, :, i ], np. arange ( 257 ) ) [ 0 ] <TAB> <TAB> <TAB> <TAB> ahist = like ( temp, hist ) <TAB> <TAB> <TAB> <TAB> img",False,img2.ndim == 3,img1.ndim == 2,0.6604496836662292
|
||
|
2904,"def _get_backend_info ( ) : <TAB> """"""Get information about raw backends available for testing"""""" <TAB> info = [ ] <TAB> <TAB> bi = Namespace ( ) <TAB> bi. name = ""local"" <TAB> bi. classname = ""local"" <TAB> info. append ( bi ) <TAB> <TAB> for name in backends. prefix_map : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> try : <TAB> <TAB> <TAB> ( login, password, storage_url ) = get_remote_test_info ( name + ""-test"" ) <TAB> <TAB> except NoTestSection as exc : <TAB> <TAB> <TAB> log. info ( ""Not running remote tests for %s backend: %s"", name, exc. reason ) <TAB> <TAB> <TAB> continue <TAB> <TAB> bi = Namespace ( ) <TAB> <TAB> bi. name = ""remote-"" + name <TAB> <TAB> bi. classname = name <TAB> <TAB> bi. storage_url = storage_url <TAB> <TAB> bi. login = login <TAB> <TAB> bi. password = password <TAB> <TAB> info. append ( bi ) <TAB> <TAB> for ( request_handler, storage_url ) in mock_server. handler_list : <TAB> <TAB> name = re. match ( r""^([a-zA-Z0-9]+)://"", storage_url ). group ( 1 ) <TAB> <TAB> bi = Namespace ( ) <TAB> <TAB> bi. name = ""mock-"" + name <TAB> <TAB> bi. classname = name <TAB> <TAB> bi. request_handler = request_handler <TAB> <TAB> bi. storage_url = storage_url <TAB> <TAB> info. append ( bi ) <TAB> return info",False,name == 'local',name == 'remote-' + name,0.657902717590332
|
||
|
2905,"def addClassFunction ( self, namelist, args = None, doc = None ) : <TAB> log. debug ( ""AddClassFunction: %s(%s)"", namelist, args ) <TAB> toScope = self. currentClass <TAB> if not toScope : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> toScope = self. _convertFunctionToClass ( self. currentScope ) <TAB> if not toScope or len ( namelist ) > 1 : <TAB> <TAB> self. addFunction ( namelist, args, doc ) <TAB> else : <TAB> <TAB> funcName = namelist [ - 1 ] <TAB> <TAB> log. info ( ""FUNC: %s(%s) on line %d"", funcName, args, self. lineno ) <TAB> <TAB> fn = JSFunction ( funcName, toScope, args, self. lineno, self. depth, doc = doc ) <TAB> <TAB> toScope. functions [ fn. name ] = fn <TAB> <TAB> self. currentScope = fn",False,"isinstance(self.currentScope, JSFunction)",self.currentScope,0.6540499925613403
|
||
|
2906,"def test ( self ) : <TAB> <TAB> <TAB> main = self. __constantLayer ( """", imath. Color4f ( 1, 0.5, 0.25, 1 ) ) <TAB> diffuse = self. __constantLayer ( ""diffuse"", imath. Color4f ( 0, 0.25, 0.5, 1 ) ) <TAB> copy = GafferImage. CopyChannels ( ) <TAB> copy [ ""in"" ] [ 0 ]. setInput ( main [ ""out"" ] ) <TAB> copy [ ""in"" ] [ 1 ]. setInput ( diffuse [ ""out"" ] ) <TAB> copy [ ""channels"" ]. setValue ( ""*"" ) <TAB> <TAB> self. assertEqual ( <TAB> <TAB> copy [ ""out"" ] [ ""channelNames"" ]. getValue ( ), <TAB> <TAB> IECore. StringVectorData ( <TAB> <TAB> <TAB> [ ""R"", ""G"", ""B"", ""A"", ""diffuse.R"", ""diffuse.G"", ""diffuse.B"", ""diffuse.A"" ] <TAB> <TAB> ), <TAB> ) <TAB> <TAB> <TAB> for constant in ( main, diffuse ) : <TAB> <TAB> for channel in ( ""R"", ""G"", ""B"", ""A"" ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> channel = constant [ ""layer"" ]. getValue ( ) + ""."" + channel <TAB> <TAB> <TAB> self. assertEqual ( <TAB> <TAB> <TAB> <TAB> copy [ ""out"" ]. channelDataHash ( channel, imath. V2i ( 0 ) ), <TAB> <TAB> <TAB> <TAB> constant [ ""out"" ]. channelDataHash ( channel, imath. V2i ( 0 ) ), <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> self. assertTrue ( <TAB> <TAB> <TAB> <TAB> copy [ ""out"" ] <TAB> <TAB> <TAB> <TAB>. channelData ( channel, imath. V2i ( 0 ),",False,constant['layer'].getValue(),constant is not None,0.6534030437469482
|
||
|
2907,"def gather_metrics ( dry_run = False ) : <TAB> today = datetime. date. today ( ) <TAB> first = today. replace ( day = 1 ) <TAB> last_month = first - datetime. timedelta ( days = 1 ) <TAB> filename = ""form_types_{}.csv"". format ( last_month. strftime ( ""%Y-%m"" ) ) <TAB> with connection. cursor ( ) as cursor : <TAB> <TAB> cursor. execute ( REGISTRATION_METRICS_SQL ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> for row in cursor. fetchall ( ) : <TAB> <TAB> <TAB> <TAB> logger. info ( encode_row ( row ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> write_raw_data ( cursor = cursor, filename = filename )",True,dry_run,dry_run,0.6743572950363159
|
||
|
2908,"def add_doc ( target, variables, body_lines ) : <TAB> if isinstance ( target, ast. Name ) : <TAB> <TAB> <TAB> <TAB> name = target. id <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> doc = find_doc_for ( target, body_lines ) <TAB> <TAB> <TAB> if doc is not None : <TAB> <TAB> <TAB> <TAB> variables [ name ] = doc <TAB> elif isinstance ( target, ast. Tuple ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for e in target. elts : <TAB> <TAB> <TAB> add_doc ( e, variables, body_lines )",False,name not in variables,"isinstance(target, ast.Variable)",0.6676352024078369
|
||
|
2909,"def __getitem__ ( self, idx ) : <TAB> retry_count = 0 <TAB> cur_idx = int ( idx ) <TAB> while True : <TAB> <TAB> data = self. _map_func ( self. _dataset [ cur_idx ] ) <TAB> <TAB> if data is not None : <TAB> <TAB> <TAB> self. _fallback_candidates. add ( cur_idx ) <TAB> <TAB> <TAB> return data <TAB> <TAB> <TAB> <TAB> retry_count += 1 <TAB> <TAB> self. _fallback_candidates. discard ( cur_idx ) <TAB> <TAB> cur_idx = self. _rng. sample ( self. _fallback_candidates, k = 1 ) [ 0 ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> logger = logging. getLogger ( __name__ ) <TAB> <TAB> <TAB> logger. warning ( <TAB> <TAB> <TAB> <TAB> ""Failed to apply `_map_func` for idx: {}, retry count: {}"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> idx, retry_count <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> )",False,retry_count >= 3,retry_count > 0,0.6667259931564331
|
||
|
2910,"def format_seconds_alt ( seconds, start, hide_seconds = False ) : <TAB> <TAB> start = max ( start, 86400 ) <TAB> output = """" <TAB> total_seconds = seconds <TAB> for period_seconds in ( <TAB> <TAB> 31557600, <TAB> <TAB> 86400, <TAB> <TAB> 3600, <TAB> <TAB> 60, <TAB> <TAB> 1, <TAB> ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> break <TAB> <TAB> actual_period_value = int ( seconds / period_seconds ) <TAB> <TAB> if actual_period_value > 0 : <TAB> <TAB> <TAB> output += str ( actual_period_value ). zfill ( 2 ) + "":"" <TAB> <TAB> elif start > period_seconds or total_seconds > period_seconds : <TAB> <TAB> <TAB> output += ""00:"" <TAB> <TAB> seconds = seconds % period_seconds <TAB> return output. rstrip ( "":"" )",False,hide_seconds and period_seconds == 1 and (total_seconds > 60),hide_seconds,0.6522300243377686
|
||
|
2911,"def create_resource ( self, name, ** kwargs ) : <TAB> if not os. environ. get ( ""AZURE_CLI_TEST_DEV_BACKUP_POLICY_NAME"", None ) : <TAB> <TAB> self. resource_group = self. _get_resource_group ( ** kwargs ) <TAB> <TAB> self. vault = self. _get_vault ( ** kwargs ) <TAB> <TAB> policy_json = execute ( <TAB> <TAB> <TAB> self. cli_ctx, <TAB> <TAB> <TAB> ""az backup policy show -g {} -v {} -n {}"". format ( <TAB> <TAB> <TAB> <TAB> self. resource_group, self. vault, ""DefaultPolicy"" <TAB> <TAB> <TAB> ), <TAB> <TAB> ). get_output_in_json ( ) <TAB> <TAB> policy_json [ ""name"" ] = name <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> policy_json [ ""properties"" ] [ <TAB> <TAB> <TAB> <TAB> ""instantRpRetentionRangeInDays"" <TAB> <TAB> <TAB> ] = self. instant_rp_days <TAB> <TAB> policy_json = json. dumps ( policy_json ) <TAB> <TAB> execute ( <TAB> <TAB> <TAB> self. cli_ctx, <TAB> <TAB> <TAB> ""az backup policy set -g {} -v {} --policy '{}'"". format ( <TAB> <TAB> <TAB> <TAB> self. resource_group, self. vault, policy_json <TAB> <TAB> <TAB> ), <TAB> <TAB> ) <TAB> <TAB> return { self. parameter_name : name } <TAB> return { <TAB> <TAB> self. parameter_name : os. environ. get ( <TAB> <TAB> <TAB> ""AZURE_CLI_TEST_DEV_BACKUP_POLICY_NAME"", None <TAB> <TAB> ) <TAB> }",False,self.instant_rp_days,self.instant_rp_days is not None,0.6537126302719116
|
||
|
2912,"def _expand_lang ( locale ) : <TAB> from locale import normalize <TAB> locale = normalize ( locale ) <TAB> COMPONENT_CODESET = 1 << 0 <TAB> COMPONENT_TERRITORY = 1 << 1 <TAB> COMPONENT_MODIFIER = 1 << 2 <TAB> <TAB> mask = 0 <TAB> pos = locale. find ( ""@"" ) <TAB> if pos >= 0 : <TAB> <TAB> modifier = locale [ pos : ] <TAB> <TAB> locale = locale [ : pos ] <TAB> <TAB> mask |= COMPONENT_MODIFIER <TAB> else : <TAB> <TAB> modifier = """" <TAB> pos = locale. find ( ""."" ) <TAB> if pos >= 0 : <TAB> <TAB> codeset = locale [ pos : ] <TAB> <TAB> locale = locale [ : pos ] <TAB> <TAB> mask |= COMPONENT_CODESET <TAB> else : <TAB> <TAB> codeset = """" <TAB> pos = locale. find ( ""_"" ) <TAB> if pos >= 0 : <TAB> <TAB> territory = locale [ pos : ] <TAB> <TAB> locale = locale [ : pos ] <TAB> <TAB> mask |= COMPONENT_TERRITORY <TAB> else : <TAB> <TAB> territory = """" <TAB> language = locale <TAB> ret = [ ] <TAB> for i in range ( mask + 1 ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> val = language <TAB> <TAB> <TAB> if i & COMPONENT_TERRITORY : <TAB> <TAB> <TAB> <TAB> val += territory <TAB> <TAB> <TAB> if i & COMPONENT_CODESET : <TAB> <TAB> <TAB> <TAB> val += codeset <TAB> <TAB> <TAB> if i & COMPONENT_MODIFIER : <TAB> <TAB> <TAB> <TAB> val += modifier <TAB> <TAB> <TAB> ret. append ( val ) <TAB> ret. reverse ( ) <TAB> return ret",False,not i & ~mask,i & language,0.6695008873939514
|
||
|
2913,"def fix_desktop_image_in_thema_callback ( install_dir_for_grub, dir_, fname ) : <TAB> if not fname. lower ( ). endswith ( "".txt"" ) : <TAB> <TAB> return <TAB> theme_file = os. path. join ( dir_, fname ) <TAB> updated = False <TAB> with open ( theme_file, ""r"", encoding = ""utf-8"" ) as f : <TAB> <TAB> pattern = re. compile ( r""^desktop-image\s*:\s*(.*)$"" ) <TAB> <TAB> try : <TAB> <TAB> <TAB> src_lines = f. readlines ( ) <TAB> <TAB> except UnicodeDecodeError : <TAB> <TAB> <TAB> log ( ""Unexpected encoding in %s"" % theme_file ) <TAB> <TAB> <TAB> return <TAB> <TAB> lines = [ ] <TAB> <TAB> for line in src_lines : <TAB> <TAB> <TAB> line = line. rstrip ( ) <TAB> <TAB> <TAB> m = pattern. match ( line ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> log ( ""Updating '%s' in %s"" % ( line, theme_file ) ) <TAB> <TAB> <TAB> <TAB> updated = True <TAB> <TAB> <TAB> <TAB> partial_path = m. group ( 1 ). strip ( '""' ). lstrip ( ""/"" ) <TAB> <TAB> <TAB> <TAB> line = 'desktop-image: ""%s/%s""' % ( install_dir_for_grub, partial_path ) <TAB> <TAB> <TAB> lines. append ( line ) <TAB> if updated : <TAB> <TAB> with open ( theme_file, ""w"" ) as f : <TAB> <TAB> <TAB> f. write ( ""\n"". join ( lines ) )",False,"m and m.group(1).startswith(('/', '""/'))",m,0.6482107639312744
|
||
|
2914,"def compare_readme_files ( self, ancestor_readme_files, current_readme_files ) : <TAB> """"""Determine if ancestor_readme_files is equal to or a subset of current_readme_files."""""" <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if len ( ancestor_readme_files ) <= len ( current_readme_files ) : <TAB> <TAB> for ancestor_readme_file in ancestor_readme_files : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return self. NOT_EQUAL_AND_NOT_SUBSET <TAB> <TAB> if len ( ancestor_readme_files ) == len ( current_readme_files ) : <TAB> <TAB> <TAB> return self. EQUAL <TAB> <TAB> else : <TAB> <TAB> <TAB> return self. SUBSET <TAB> return self. NOT_EQUAL_AND_NOT_SUBSET",False,ancestor_readme_file not in current_readme_files,current_readme_file == ancestor_readme_file,0.6503258943557739
|
||
|
2915,"def _transform_continuous_designs ( <TAB> self, design : np. ndarray, origin : str, cs : ConfigurationSpace ) -> typing. List [ Configuration ] : <TAB> params = cs. get_hyperparameters ( ) <TAB> for idx, param in enumerate ( params ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> elif isinstance ( param, Constant ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> design_ = np. zeros ( np. array ( design. shape ) + np. array ( ( 0, 1 ) ) ) <TAB> <TAB> <TAB> design_ [ :, : idx ] = design [ :, : idx ] <TAB> <TAB> <TAB> design_ [ :, idx + 1 : ] = design [ :, idx : ] <TAB> <TAB> <TAB> design = design_ <TAB> <TAB> elif isinstance ( param, CategoricalHyperparameter ) : <TAB> <TAB> <TAB> v_design = design [ :, idx ] <TAB> <TAB> <TAB> v_design [ v_design == 1 ] = 1 - 10 ** - 10 <TAB> <TAB> <TAB> design [ :, idx ] = np. array ( v_design * len ( param. choices ), dtype = np. int ) <TAB> <TAB> elif isinstance ( param, OrdinalHyperparameter ) : <TAB> <TAB> <TAB> v_design = design [ :, idx ] <TAB> <TAB> <TAB> v_design [ v_design == 1 ] = 1 - 10 ** - 10 <TAB> <TAB> <TAB> design [ :, idx ] = np. array ( v_design * len ( param. sequence ), dtype = np. int ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise ValueError ( ""Hyperparameter not supported in LHD"" ) <TAB> self. logger. debug ( ""Initial Design"" ) <TAB> configs = [ ] <TAB> for vector in design : <TAB> <TAB> conf = deactivate_inactive_hyperparameters ( <TAB> <TAB> <TAB> configuration = None, configuration_space = cs, vector = vector <TAB> <TAB> ) <",False,"isinstance(param, NumericalHyperparameter)",param is None,0.6549084186553955
|
||
|
2916,"def get_cloud_credential ( self ) : <TAB> """"""Return the credential which is directly tied to the inventory source type."""""" <TAB> credential = None <TAB> for cred in self. credentials. all ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if cred. kind == self. source. replace ( ""ec2"", ""aws"" ) : <TAB> <TAB> <TAB> <TAB> credential = cred <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if cred. credential_type. kind!= ""vault"" : <TAB> <TAB> <TAB> <TAB> credential = cred <TAB> <TAB> <TAB> <TAB> break <TAB> return credential",False,self.source in CLOUD_PROVIDERS,not credential,0.6631449460983276
|
||
|
2917,"def save ( cls, info, variant : ""ProductVariantModel"", cleaned_input : List ) : <TAB> for channel_listing_data in cleaned_input : <TAB> <TAB> channel = channel_listing_data [ ""channel"" ] <TAB> <TAB> defaults = { ""currency"" : channel. currency_code } <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> defaults [ ""price_amount"" ] = channel_listing_data. get ( ""price"", None ) <TAB> <TAB> if ""cost_price"" in channel_listing_data. keys ( ) : <TAB> <TAB> <TAB> defaults [ ""cost_price_amount"" ] = channel_listing_data. get ( ""cost_price"", None ) <TAB> <TAB> ProductVariantChannelListing. objects. update_or_create ( <TAB> <TAB> <TAB> variant = variant, <TAB> <TAB> <TAB> channel = channel, <TAB> <TAB> <TAB> defaults = defaults, <TAB> <TAB> ) <TAB> update_product_discounted_price_task. delay ( variant. product_id ) <TAB> info. context. plugins. product_updated ( variant. product )",True,'price' in channel_listing_data.keys(),'price' in channel_listing_data.keys(),0.6530414819717407
|
||
|
2918,"def __cut_DAG ( self, sentence ) : <TAB> DAG = self. tokenizer. get_DAG ( sentence ) <TAB> route = { } <TAB> self. tokenizer. calc ( sentence, DAG, route ) <TAB> x = 0 <TAB> buf = """" <TAB> N = len ( sentence ) <TAB> while x < N : <TAB> <TAB> y = route [ x ] [ 1 ] + 1 <TAB> <TAB> l_word = sentence [ x : y ] <TAB> <TAB> if y - x == 1 : <TAB> <TAB> <TAB> buf += l_word <TAB> <TAB> else : <TAB> <TAB> <TAB> if buf : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> yield pair ( buf, self. word_tag_tab. get ( buf, ""x"" ) ) <TAB> <TAB> <TAB> <TAB> elif not self. tokenizer. FREQ. get ( buf ) : <TAB> <TAB> <TAB> <TAB> <TAB> recognized = self. __cut_detail ( buf ) <TAB> <TAB> <TAB> <TAB> <TAB> for t in recognized : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> yield t <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> for elem in buf : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> yield pair ( elem, self. word_tag_tab. get ( elem, ""x"" ) ) <TAB> <TAB> <TAB> <TAB> buf = """" <TAB> <TAB> <TAB> yield pair ( l_word, self. word_tag_tab. get ( l_word, ""x"" ) ) <TAB> <TAB> x = y <TAB> if buf : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> yield pair ( buf, self. word_tag_tab. get ( buf, ""x"" ) ) <TAB> <TAB> elif not self. tokenizer. FREQ. get ( buf ) : <TAB> <TAB>",False,len(buf) == 1,self.tokenizer.FREQ.get(buf),0.6572306156158447
|
||
|
2919,"def _rewrite_prepend_append ( self, string, prepend, append = None ) : <TAB> if append is None : <TAB> <TAB> append = prepend <TAB> if not isinstance ( string, StringElem ) : <TAB> <TAB> string = StringElem ( string ) <TAB> string. sub. insert ( 0, prepend ) <TAB> if unicode ( string ). endswith ( u""\n"" ) : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> lastnode = string. flatten ( ) [ - 1 ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> lastnode. sub [ - 1 ] = lastnode. sub [ - 1 ]. rstrip ( u""\n"" ) <TAB> <TAB> except IndexError : <TAB> <TAB> <TAB> pass <TAB> <TAB> string. sub. append ( append + u""\n"" ) <TAB> else : <TAB> <TAB> string. sub. append ( append ) <TAB> return string",False,"isinstance(lastnode.sub[-1], unicode)",lastnode.sub[0] != 0,0.6494630575180054
|
||
|
2920,"def autoformat_kernel_3d ( kernel ) : <TAB> if isinstance ( kernel, int ) : <TAB> <TAB> return [ 1, kernel, kernel, kernel, 1 ] <TAB> elif isinstance ( kernel, ( tuple, list, tf. TensorShape ) ) : <TAB> <TAB> if len ( kernel ) == 3 : <TAB> <TAB> <TAB> return [ 1, kernel [ 0 ], kernel [ 1 ], kernel [ 2 ], 1 ] <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> assert ( <TAB> <TAB> <TAB> <TAB> kernel [ 0 ] == kernel [ 4 ] == 1 <TAB> <TAB> <TAB> ), ""Must have kernel_size[0] = kernel_size[4] = 1"" <TAB> <TAB> <TAB> return [ kernel [ 0 ], kernel [ 1 ], kernel [ 2 ], kernel [ 3 ], kernel [ 4 ] ] <TAB> <TAB> else : <TAB> <TAB> <TAB> raise Exception ( <TAB> <TAB> <TAB> <TAB> ""kernel length error: "" <TAB> <TAB> <TAB> <TAB> + str ( len ( kernel ) ) <TAB> <TAB> <TAB> <TAB> + "", only a length of 3 or 5 is supported."" <TAB> <TAB> <TAB> ) <TAB> else : <TAB> <TAB> raise Exception ( ""kernel format error: "" + str ( type ( kernel ) ) )",True,len(kernel) == 5,len(kernel) == 5,0.6636805534362793
|
||
|
2921,"def __exit__ ( self, exc_type, exc_value, tb ) : <TAB> <TAB> self. warnings_manager. __exit__ ( exc_type, exc_value, tb ) <TAB> if exc_type is not None : <TAB> <TAB> <TAB> <TAB> return <TAB> try : <TAB> <TAB> exc_name = self. expected. __name__ <TAB> except AttributeError : <TAB> <TAB> exc_name = str ( self. expected ) <TAB> first_matching = None <TAB> for m in self. warnings : <TAB> <TAB> w = m. message <TAB> <TAB> if not isinstance ( w, self. expected ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> if first_matching is None : <TAB> <TAB> <TAB> first_matching = w <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> self. warning = w <TAB> <TAB> self. filename = m. filename <TAB> <TAB> self. lineno = m. lineno <TAB> <TAB> return <TAB> <TAB> if first_matching is not None : <TAB> <TAB> self. _raiseFailure ( <TAB> <TAB> <TAB> '""{}"" does not match ""{}""'. format ( <TAB> <TAB> <TAB> <TAB> self. expected_regex. pattern, str ( first_matching ) <TAB> <TAB> <TAB> ) <TAB> <TAB> ) <TAB> if self. obj_name : <TAB> <TAB> self. _raiseFailure ( ""{} not triggered by {}"". format ( exc_name, self. obj_name ) ) <TAB> else : <TAB> <TAB> self. _raiseFailure ( ""{} not triggered"". format ( exc_name ) )",False,self.expected_regex is not None and (not self.expected_regex.search(str(w))),not self.expected_regex,0.6492741107940674
|
||
|
2922,"def get_javlib_cookie ( ) -> [ dict, str ] : <TAB> import cloudscraper <TAB> switch, proxy, timeout, retry_count, proxytype = config. Config ( ). proxy ( ) <TAB> proxies = get_proxy ( proxy, proxytype ) <TAB> raw_cookie = { } <TAB> user_agent = """" <TAB> <TAB> for i in range ( retry_count ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raw_cookie, user_agent = cloudscraper. get_cookie_string ( <TAB> <TAB> <TAB> <TAB> <TAB> ""http://www.m45e.com/"", proxies = proxies <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> raw_cookie, user_agent = cloudscraper. get_cookie_string ( <TAB> <TAB> <TAB> <TAB> <TAB> ""http://www.m45e.com/"" <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> except requests. exceptions. ProxyError : <TAB> <TAB> <TAB> print ( ""[-] ProxyError, retry {}/{}"". format ( i + 1, retry_count ) ) <TAB> <TAB> except cloudscraper. exceptions. CloudflareIUAMError : <TAB> <TAB> <TAB> print ( ""[-] IUAMError, retry {}/{}"". format ( i + 1, retry_count ) ) <TAB> return raw_cookie, user_agent",False,switch == 1 or switch == '1',"hasattr(cloudscraper, 'get_cookie_string')",0.6572971343994141
|
||
|
2923,"def _output_test_report ( self, report ) : <TAB> self. logger. info ( ""%s--- Test report ---"", os. linesep ) <TAB> error_count = 0 <TAB> for result_type in sorted ( list ( report. keys ( ) ) ) : <TAB> <TAB> test_descriptions = report [ result_type ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> error_count += len ( test_descriptions ) <TAB> <TAB> self. logger. info ( ""%s(%d)"", result_type, len ( test_descriptions ) ) <TAB> <TAB> for file_desc, test_desc in test_descriptions : <TAB> <TAB> <TAB> self. logger. info ( "" %-40s %s"", file_desc, test_desc ) <TAB> self. logger. info ( <TAB> <TAB> ""%s%s(%d) / %s(%d)"", <TAB> <TAB> os. linesep, <TAB> <TAB> TEST_OK, <TAB> <TAB> len ( report. get ( TEST_OK, [ ] ) ), <TAB> <TAB> TEST_ERROR, <TAB> <TAB> error_count, <TAB> )",False,result_type == TEST_OK,len(test_descriptions) == 0,0.6553997993469238
|
||
|
2924,"def start ( self, connection ) : <TAB> try : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> creds = gssapi. Credentials ( name = gssapi. Name ( self. client_name ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> creds = None <TAB> <TAB> hostname = self. get_hostname ( connection ) <TAB> <TAB> name = gssapi. Name ( <TAB> <TAB> <TAB> b""@"". join ( [ self. service, hostname ] ), gssapi. NameType. hostbased_service <TAB> <TAB> ) <TAB> <TAB> context = gssapi. SecurityContext ( name = name, creds = creds ) <TAB> <TAB> return context. step ( None ) <TAB> except gssapi. raw. misc. GSSError : <TAB> <TAB> if self. fail_soft : <TAB> <TAB> <TAB> return NotImplemented <TAB> <TAB> else : <TAB> <TAB> <TAB> raise",True,self.client_name,self.client_name,0.6576448678970337
|
||
|
2925,"def consume_dependencies ( item, args = None ) : <TAB> hydrated_args = args or { } <TAB> for key, value in sorted ( item. _asdict ( ). items ( ), key = _key_func ) : <TAB> <TAB> if not AddressableDescriptor. is_addressable ( item, key ) : <TAB> <TAB> <TAB> hydrated_args [ key ] = value <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> container_type = type ( value ) <TAB> <TAB> <TAB> hydrated_args [ key ] = container_type ( <TAB> <TAB> <TAB> <TAB> ( k, maybe_consume ( key, v ) ) <TAB> <TAB> <TAB> <TAB> for k, v in sorted ( value. items ( ), key = _key_func ) <TAB> <TAB> <TAB> ) <TAB> <TAB> elif isinstance ( value, MutableSequence ) : <TAB> <TAB> <TAB> container_type = type ( value ) <TAB> <TAB> <TAB> hydrated_args [ key ] = container_type ( maybe_consume ( key, v ) for v in value ) <TAB> <TAB> else : <TAB> <TAB> <TAB> hydrated_args [ key ] = maybe_consume ( key, value ) <TAB> return _hydrate ( type ( item ), address. spec_path, ** hydrated_args )",False,"isinstance(value, MutableMapping)","isinstance(value, MutableSequence)",0.6477214694023132
|
||
|
2926,"def main ( client ) : <TAB> <TAB> creative_wrapper_service = client. GetService ( <TAB> <TAB> ""CreativeWrapperService"", version = ""v202005"" <TAB> ) <TAB> <TAB> statement = ( <TAB> <TAB> ad_manager. StatementBuilder ( version = ""v202005"" ) <TAB> <TAB>. Where ( ""status = :status"" ) <TAB> <TAB>. WithBindVariable ( ""status"", ""ACTIVE"" ) <TAB> ) <TAB> <TAB> <TAB> while True : <TAB> <TAB> response = creative_wrapper_service. getCreativeWrappersByStatement ( <TAB> <TAB> <TAB> statement. ToStatement ( ) <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> for creative_wrapper in response [ ""results"" ] : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> <TAB> 'Creative wrapper with ID ""%d"" and label ID ""%d"" was found.\n' <TAB> <TAB> <TAB> <TAB> <TAB> % ( creative_wrapper [ ""id"" ], creative_wrapper [ ""labelId"" ] ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> statement. offset += statement. limit <TAB> <TAB> else : <TAB> <TAB> <TAB> break <TAB> print ( ""\nNumber of results found: %s"" % response [ ""totalResultSetSize"" ] )",False,'results' in response and len(response['results']),response['results'],0.6589622497558594
|
||
|
2927,"def _get_sparse_matrix_from_indices_distances_umap ( <TAB> knn_indices, knn_dists, n_obs, n_neighbors ) : <TAB> rows = np. zeros ( ( n_obs * n_neighbors ), dtype = np. int64 ) <TAB> cols = np. zeros ( ( n_obs * n_neighbors ), dtype = np. int64 ) <TAB> vals = np. zeros ( ( n_obs * n_neighbors ), dtype = np. float64 ) <TAB> for i in range ( knn_indices. shape [ 0 ] ) : <TAB> <TAB> for j in range ( n_neighbors ) : <TAB> <TAB> <TAB> if knn_indices [ i, j ] == - 1 : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> val = 0.0 <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> val = knn_dists [ i, j ] <TAB> <TAB> <TAB> rows [ i * n_neighbors + j ] = i <TAB> <TAB> <TAB> cols [ i * n_neighbors + j ] = knn_indices [ i, j ] <TAB> <TAB> <TAB> vals [ i * n_neighbors + j ] = val <TAB> result = coo_matrix ( ( vals, ( rows, cols ) ), shape = ( n_obs, n_obs ) ) <TAB> result. eliminate_zeros ( ) <TAB> return result. tocsr ( )",False,"knn_indices[i, j] == i","knn_dists[i, j] == -1",0.6606323719024658
|
||
|
2928,"def process_rotate_aes_key ( self ) : <TAB> if hasattr ( self. options, ""rotate_aes_key"" ) and isinstance ( <TAB> <TAB> self. options. rotate_aes_key, six. string_types <TAB> ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. options. rotate_aes_key = True <TAB> <TAB> elif self. options. rotate_aes_key. lower ( ) == ""false"" : <TAB> <TAB> <TAB> self. options. rotate_aes_key = False",True,self.options.rotate_aes_key.lower() == 'true',self.options.rotate_aes_key.lower() == 'true',0.6495324373245239
|
||
|
2929,"def _cluster_info_state_get ( self, name ) : <TAB> if not self. _cluster_info_state : <TAB> <TAB> try : <TAB> <TAB> <TAB> result = self. _is_leader_retry ( <TAB> <TAB> <TAB> <TAB> self. _query, self. cluster_info_query <TAB> <TAB> <TAB> ). fetchone ( ) <TAB> <TAB> <TAB> self. _cluster_info_state = dict ( <TAB> <TAB> <TAB> <TAB> zip ( <TAB> <TAB> <TAB> <TAB> <TAB> [ <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""timeline"", <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""wal_position"", <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""replayed_location"", <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""received_location"", <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""replay_paused"", <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""pg_control_timeline"", <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""received_tli"", <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""slot_name"", <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""conninfo"", <TAB> <TAB> <TAB> <TAB> <TAB> ], <TAB> <TAB> <TAB> <TAB> <TAB> result, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> except RetryFailedError as e : <TAB> <TAB> <TAB> self. _cluster_info_state = { ""error"" : str ( e ) } <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. set_state ( ""starting"" ) <TAB> if ""error"" in self. _cluster",False,not self.is_starting() and self.pg_isready() == STATE_REJECT,name in self._cluster,0.6505073308944702
|
||
|
2930,"def close ( self, finished = True ) : <TAB> if self. _closed : <TAB> <TAB> return <TAB> if self. _raw_buf is not self. _buf : <TAB> <TAB> self. _buf. close ( ) <TAB> last_offset = self. _raw_buf. tell ( ) <TAB> self. _raw_buf. close ( ) <TAB> self. _raw_buf = self. _buf = None <TAB> transfer_speed = None <TAB> if finished and abs ( self. _total_time ) > 1e-6 : <TAB> <TAB> transfer_speed = self. _nbytes * 1.0 / self. _total_time <TAB> if self. is_writable : <TAB> <TAB> status_key = ""disk_write_speed"" <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. register ( self. _nbytes ) <TAB> <TAB> <TAB> if self. _merge_file : <TAB> <TAB> <TAB> <TAB> self. _handler. disk_merger_ref. release_file_writer ( <TAB> <TAB> <TAB> <TAB> <TAB> self. _session_id, <TAB> <TAB> <TAB> <TAB> <TAB> self. _data_key, <TAB> <TAB> <TAB> <TAB> <TAB> self. _filename, <TAB> <TAB> <TAB> <TAB> <TAB> self. _offset, <TAB> <TAB> <TAB> <TAB> <TAB> last_offset, <TAB> <TAB> <TAB> <TAB> <TAB> _tell = True, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> os. unlink ( self. _filename ) <TAB> else : <TAB> <TAB> status_key = ""disk_read_speed"" <TAB> <TAB> if self. _merge_file : <TAB> <TAB> <TAB> self. _handler. disk_merger_ref. release_file_reader ( <TAB> <TAB> <TAB> <TAB> self. _session_id, self. _data_",False,finished,self.is_register,0.6946910619735718
|
||
|
2931,"def decompose_incoming_envelope ( self, ctx, message = JsonDocument. REQUEST ) : <TAB> indoc = ctx. in_document <TAB> if not isinstance ( indoc, dict ) : <TAB> <TAB> raise ValidationError ( indoc, ""Invalid Request"" ) <TAB> ver = indoc. get ( self. VERSION ) <TAB> if ver is None : <TAB> <TAB> raise ValidationError ( ver, ""Unknown Version"" ) <TAB> body = indoc. get ( self. BODY ) <TAB> err = indoc. get ( self. FAULT ) <TAB> if body is None and err is None : <TAB> <TAB> raise ValidationError ( ( body, err ), ""Request data not found"" ) <TAB> ctx. protocol. error = False <TAB> if err is not None : <TAB> <TAB> ctx. in_body_doc = err <TAB> <TAB> ctx. protocol. error = True <TAB> else : <TAB> <TAB> if not isinstance ( body, dict ) : <TAB> <TAB> <TAB> raise ValidationError ( body, ""Request body not found"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValidationError ( body, ""Need len(body) == 1"" ) <TAB> <TAB> ctx. in_header_doc = indoc. get ( self. HEAD ) <TAB> <TAB> if not isinstance ( ctx. in_header_doc, list ) : <TAB> <TAB> <TAB> ctx. in_header_doc = [ ctx. in_header_doc ] <TAB> <TAB> ( ( ctx. method_request_string, ctx. in_body_doc ), ) = body. items ( )",False,not len(body) == 1,len(body) == 0,0.6558464169502258
|
||
|
2932,"def _osp2ec ( self, bytes ) : <TAB> compressed = self. _from_bytes ( bytes ) <TAB> y = compressed >> self. _bits <TAB> x = compressed & ( 1 << self. _bits ) - 1 <TAB> if x == 0 : <TAB> <TAB> y = self. _curve. b <TAB> else : <TAB> <TAB> result = self. sqrtp ( <TAB> <TAB> <TAB> x ** 3 + self. _curve. a * x + self. _curve. b, self. _curve. field. p <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> y = result [ 0 ] <TAB> <TAB> elif len ( result ) == 2 : <TAB> <TAB> <TAB> y1, y2 = result <TAB> <TAB> <TAB> y = y1 if ( y1 & 1 == y ) else y2 <TAB> <TAB> else : <TAB> <TAB> <TAB> return None <TAB> return ec. Point ( self. _curve, x, y )",True,len(result) == 1,len(result) == 1,0.6617035865783691
|
||
|
2933,"def populate ( self, item_id ) : <TAB> """"""Populate the subitems of a tree"""""" <TAB> try : <TAB> <TAB> d = self. get_item_data ( item_id ) <TAB> <TAB> assert len ( d ) > 1 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> for key in sorted ( [ x for x in list ( d. keys ( ) ) if x is not None ] ) : <TAB> <TAB> <TAB> <TAB> d1 = d [ key ] <TAB> <TAB> <TAB> <TAB> if hasattr ( d1, ""__call__"" ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. SetCursor ( wx. Cursor ( wx. CURSOR_WAIT ) ) <TAB> <TAB> <TAB> <TAB> <TAB> d1 = d1 ( ) <TAB> <TAB> <TAB> <TAB> <TAB> d [ key ] = d1 <TAB> <TAB> <TAB> <TAB> image_index, selected_index = self. img_idx ( d1 ) <TAB> <TAB> <TAB> <TAB> sub_id = self. tree_ctrl. AppendItem ( <TAB> <TAB> <TAB> <TAB> <TAB> item_id, key, image_index, selected_index, d1 <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> self. tree_ctrl. SetItemImage ( sub_id, image_index, wx. TreeItemIcon_Normal ) <TAB> <TAB> <TAB> <TAB> self. tree_ctrl. SetItemImage ( <TAB> <TAB> <TAB> <TAB> <TAB> sub_id, selected_index, wx. TreeItemIcon_Selected <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> self. tree_ctrl. SetItemImage ( <TAB> <TAB> <TAB> <TAB> <TAB> sub_id, image_index, wx. TreeItemIcon_Expanded <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB>",False,"self.tree_ctrl.GetChildrenCount(item_id, False) == 0",d,0.6518797874450684
|
||
|
2934,"def start_namemap ( self, attrs ) : <TAB> type = attrs. get ( ""type"" ) <TAB> key = attrs [ ""key"" ] <TAB> value = attrs [ ""value"" ] <TAB> if type == ""group_as"" : <TAB> <TAB> if self. db. has_name_group_key ( key ) : <TAB> <TAB> <TAB> present = self. db. get_name_group_mapping ( key ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> msg = _ ( <TAB> <TAB> <TAB> <TAB> <TAB> 'Your Family Tree groups name ""%(key)s"" together' <TAB> <TAB> <TAB> <TAB> <TAB>'with ""%(parent)s"", did not change this grouping to ""%(value)s"".' <TAB> <TAB> <TAB> <TAB> ) % { ""key"" : key, ""parent"" : present, ""value"" : value } <TAB> <TAB> <TAB> <TAB> self. user. warn ( _ ( ""Gramps ignored a name grouping"" ), msg ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. db. set_name_group_mapping ( key, value )",False,not value == present,present,0.6622654795646667
|
||
|
2935,"def on_get ( self, req, resp, app_name ) : <TAB> connection = db. engine. raw_connection ( ) <TAB> cursor = connection. cursor ( db. dict_cursor ) <TAB> app_query = get_applications_query + "" AND `application`.`name` = %s"" <TAB> cursor. execute ( app_query, app_name ) <TAB> app = cursor. fetchone ( ) <TAB> if not app : <TAB> <TAB> cursor. close ( ) <TAB> <TAB> connection. close ( ) <TAB> <TAB> raise HTTPBadRequest ( ""Application %s not found"" % app_name ) <TAB> cursor. execute ( get_vars_query, app [ ""id"" ] ) <TAB> app [ ""variables"" ] = [ ] <TAB> app [ ""required_variables"" ] = [ ] <TAB> app [ ""title_variable"" ] = None <TAB> for row in cursor : <TAB> <TAB> app [ ""variables"" ]. append ( row [ ""name"" ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> app [ ""required_variables"" ]. append ( row [ ""name"" ] ) <TAB> <TAB> if row [ ""title_variable"" ] : <TAB> <TAB> <TAB> app [ ""title_variable"" ] = row [ ""name"" ] <TAB> cursor. execute ( get_default_application_modes_query, app_name ) <TAB> app [ ""default_modes"" ] = { row [ ""priority"" ] : row [ ""mode"" ] for row in cursor } <TAB> cursor. execute ( get_supported_application_modes_query, app [ ""id"" ] ) <TAB> app [ ""supported_modes"" ] = [ row [ ""name"" ] for row in cursor ] <TAB> cursor. execute ( get_application_owners_query, app [ ""id"" ] ) <TAB> app [ ""owners"" ] = [ row [ ""name"" ] for row in cursor ] <TAB> cursor. execute ( get_application_custom_sender_addresses, app [ ""id"" ] ) <TAB> app [ ""custom_sender_addresses"" ] = { <TAB> <TAB> row [ ""mode_name"" ]",False,row['required'],row['required_variables'],0.6650182008743286
|
||
|
2936,"def _find_delimiter ( f, block_size = 2 ** 16 ) : <TAB> delimiter = b""\n"" <TAB> if f. tell ( ) == 0 : <TAB> <TAB> return 0 <TAB> while True : <TAB> <TAB> b = f. read ( block_size ) <TAB> <TAB> if not b : <TAB> <TAB> <TAB> return f. tell ( ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> return f. tell ( ) - len ( b ) + b. index ( delimiter ) + 1",True,delimiter in b,delimiter in b,0.6751538515090942
|
||
|
2937,"def find_class ( self, module, name ) : <TAB> <TAB> sys. audit ( ""pickle.find_class"", module, name ) <TAB> if self. proto < 3 and self. fix_imports : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> module, name = _compat_pickle. NAME_MAPPING [ ( module, name ) ] <TAB> <TAB> elif module in _compat_pickle. IMPORT_MAPPING : <TAB> <TAB> <TAB> module = _compat_pickle. IMPORT_MAPPING [ module ] <TAB> __import__ ( module, level = 0 ) <TAB> if self. proto >= 4 : <TAB> <TAB> return _getattribute ( sys. modules [ module ], name ) [ 0 ] <TAB> else : <TAB> <TAB> return getattr ( sys. modules [ module ], name )",False,"(module, name) in _compat_pickle.NAME_MAPPING",module in _compat_pickle.NAME_MAPPING,0.6628648042678833
|
||
|
2938,"def _thread_body ( self ) : <TAB> while True : <TAB> <TAB> stats = self. stats ( ) <TAB> <TAB> for stat, value in stats. items ( ) : <TAB> <TAB> <TAB> if isinstance ( value, ( int, float ) ) : <TAB> <TAB> <TAB> <TAB> self. sampler [ stat ] = self. sampler. get ( stat, [ ] ) <TAB> <TAB> <TAB> <TAB> self. sampler [ stat ]. append ( value ) <TAB> <TAB> self. samples += 1 <TAB> <TAB> if self. _shutdown or self. samples >= self. samples_to_average : <TAB> <TAB> <TAB> self. flush ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> seconds = 0.0 <TAB> <TAB> while seconds < self. sample_rate_seconds : <TAB> <TAB> <TAB> time. sleep ( 0.1 ) <TAB> <TAB> <TAB> seconds += 0.1 <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. flush ( ) <TAB> <TAB> <TAB> <TAB> return",False,self._shutdown,self._shutdown or self.sample_rate_seconds is None,0.6742994785308838
|
||
|
2939,"def update_thumbnail_uri ( self, kp, images, image_mapping ) : <TAB> thumbnail = kp. headers. get ( ""thumbnail"", 0 ) <TAB> <TAB> if isinstance ( thumbnail, str ) and thumbnail. isdigit ( ) : <TAB> <TAB> thumbnail = int ( thumbnail ) <TAB> if isinstance ( thumbnail, int ) : <TAB> <TAB> if len ( images ) > 0 : <TAB> <TAB> <TAB> image_index = 0 <TAB> <TAB> <TAB> if thumbnail < len ( images ) : <TAB> <TAB> <TAB> <TAB> image_index = thumbnail <TAB> <TAB> <TAB> thumbnail = images [ image_index ] [ ""src"" ] <TAB> <TAB> else : <TAB> <TAB> <TAB> thumbnail = None <TAB> <TAB> if thumbnail and not self. skip_image ( kp, { ""src"" : thumbnail } ) : <TAB> <TAB> orig_path = os. path. join ( kp. orig_context, os. path. expanduser ( thumbnail ) ) <TAB> <TAB> if thumbnail in image_mapping : <TAB> <TAB> <TAB> thumbnail = image_mapping [ thumbnail ] <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> thumbnail = self. copy_image ( kp, orig_path ) <TAB> <TAB> else : <TAB> <TAB> <TAB> logger. warning ( ""Could not find a thumbnail image at: {}"". format ( thumbnail ) ) <TAB> <TAB> kp. update_headers ( thumbnail = thumbnail )",False,os.path.exists(orig_path),thumbnail,0.6469538807868958
|
||
|
2940,"def get_queryset ( self ) : <TAB> if not hasattr ( self, ""_queryset"" ) : <TAB> <TAB> if self. queryset is not None : <TAB> <TAB> <TAB> qs = self. queryset <TAB> <TAB> else : <TAB> <TAB> <TAB> qs = self. model. _default_manager. get_queryset ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> qs = qs. order_by ( self. model. _meta. pk. name ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _queryset = qs <TAB> return self. _queryset",False,not qs.ordered,self.model._meta.pk,0.6765753030776978
|
||
|
2941,"def _parse_season ( self, row, download_url, title ) : <TAB> """"""Parse the torrent's detail page and return the season pack title."""""" <TAB> details_url = row. find ( ""span"" ). find_next ( title = ""View torrent"" ). get ( ""href"" ) <TAB> torrent_id = parse_qs ( download_url ). get ( ""id"" ) <TAB> if not all ( [ details_url, torrent_id ] ) : <TAB> <TAB> log. debug ( ""Couldn't parse season pack details page for title: {0}"", title ) <TAB> <TAB> return title <TAB> <TAB> time. sleep ( 0.5 ) <TAB> response = self. session. get ( urljoin ( self. url, details_url ) ) <TAB> if not response or not response. text : <TAB> <TAB> log. debug ( ""Couldn't open season pack details page for title: {0}"", title ) <TAB> <TAB> return title <TAB> with BS4Parser ( response. text, ""html5lib"" ) as html : <TAB> <TAB> torrent_table = html. find ( ""table"", class_ = ""torrent_table"" ) <TAB> <TAB> torrent_row = ( <TAB> <TAB> <TAB> torrent_table. find ( ""tr"", id = ""torrent_{0}"". format ( torrent_id [ 0 ] ) ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> else None <TAB> <TAB> ) <TAB> <TAB> if not torrent_row : <TAB> <TAB> <TAB> log. debug ( ""Couldn't find season pack details for title: {0}"", title ) <TAB> <TAB> <TAB> return title <TAB> <TAB> <TAB> <TAB> season_title = torrent_row. find ( ""div"", class_ = ""filelist_path"" ) <TAB> <TAB> if not season_title or not season_title. get_text ( ) : <TAB> <TAB> <TAB> log. debug ( ""Couldn't parse season pack title for: {0}"", title ) <TAB> <TAB> <TAB> return title <TAB> <TAB",False,torrent_table,torrent_row,0.6557924747467041
|
||
|
2942,"def identwaf ( self, findall = False ) : <TAB> detected = list ( ) <TAB> try : <TAB> <TAB> self. attackres = self. performCheck ( self. centralAttack ) <TAB> except RequestBlocked : <TAB> <TAB> return detected <TAB> for wafvendor in self. checklist : <TAB> <TAB> self. log. info ( ""Checking for %s"" % wafvendor ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> detected. append ( wafvendor ) <TAB> <TAB> <TAB> if not findall : <TAB> <TAB> <TAB> <TAB> break <TAB> self. knowledge [ ""wafname"" ] = detected <TAB> return detected",False,self.wafdetections[wafvendor](self),findf,0.6564560532569885
|
||
|
2943,"def test_name_mapping ( self ) : <TAB> for ( module3, name3 ), ( module2, name2 ) in REVERSE_NAME_MAPPING. items ( ) : <TAB> <TAB> with self. subTest ( ( ( module3, name3 ), ( module2, name2 ) ) ) : <TAB> <TAB> <TAB> if ( module2, name2 ) == ( ""exceptions"", ""OSError"" ) : <TAB> <TAB> <TAB> <TAB> attr = getattribute ( module3, name3 ) <TAB> <TAB> <TAB> <TAB> self. assertTrue ( issubclass ( attr, OSError ) ) <TAB> <TAB> <TAB> elif ( module2, name2 ) == ( ""exceptions"", ""ImportError"" ) : <TAB> <TAB> <TAB> <TAB> attr = getattribute ( module3, name3 ) <TAB> <TAB> <TAB> <TAB> self. assertTrue ( issubclass ( attr, ImportError ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> module, name = mapping ( module2, name2 ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> self. assertEqual ( ( module, name ), ( module3, name3 ) ) <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> attr = getattribute ( module3, name3 ) <TAB> <TAB> <TAB> <TAB> except ImportError : <TAB> <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> self. assertEqual ( getattribute ( module, name ), attr )",False,module3[:1] != '_',module is not None,0.6664990186691284
|
||
|
2944,"def dict_no_value_from_proto_list ( obj_list ) : <TAB> d = dict ( ) <TAB> for item in obj_list : <TAB> <TAB> possible_dict = json. loads ( item. value_json ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> logger. warning ( ""key '{}' has no 'value' attribute"". format ( item. key ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> d [ item. key ] = possible_dict [ ""value"" ] <TAB> return d",False,"not isinstance(possible_dict, dict) or 'value' not in possible_dict",'value' not in possible_dict,0.6492003202438354
|
||
|
2945,"def pack_headers ( headers ) : <TAB> out_list = [ ] <TAB> for k, v in headers. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> out_list. append ( b""%s: %d\r\n"" % ( utils. to_bytes ( k ), v ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> out_list. append ( b""%s: %s\r\n"" % ( utils. to_bytes ( k ), utils. to_bytes ( v ) ) ) <TAB> return b"""". join ( out_list )",False,"isinstance(v, int)",k == 'TAB>',0.6497293710708618
|
||
|
2946,"def prepare_request ( next_link = None ) : <TAB> <TAB> header_parameters = { } <TAB> header_parameters [ ""Accept"" ] = self. _serialize. header ( ""accept"", accept, ""str"" ) <TAB> if not next_link : <TAB> <TAB> <TAB> <TAB> url = self. list. metadata [ ""url"" ] <TAB> <TAB> path_format_arguments = { <TAB> <TAB> <TAB> ""subscriptionId"" : self. _serialize. url ( <TAB> <TAB> <TAB> <TAB> ""self._config.subscription_id"", self. _config. subscription_id, ""str"" <TAB> <TAB> <TAB> ), <TAB> <TAB> } <TAB> <TAB> url = self. _client. format_url ( url, ** path_format_arguments ) <TAB> <TAB> <TAB> <TAB> query_parameters = { } <TAB> <TAB> query_parameters [ ""api-version"" ] = self. _serialize. query ( <TAB> <TAB> <TAB> ""api_version"", api_version, ""str"" <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> query_parameters [ ""$skipToken"" ] = self. _serialize. query ( <TAB> <TAB> <TAB> <TAB> ""skip_token"", skip_token, ""str"" <TAB> <TAB> <TAB> ) <TAB> <TAB> request = self. _client. get ( url, query_parameters, header_parameters ) <TAB> else : <TAB> <TAB> url = next_link <TAB> <TAB> query_parameters = { } <TAB> <TAB> request = self. _client. get ( url, query_parameters, header_parameters ) <TAB> return request",True,skip_token is not None,skip_token is not None,0.6575905084609985
|
||
|
2947,"def compiler_has_function ( <TAB> compiler, function_name, libraries, library_dirs, include_dirs ) -> bool : <TAB> tmp_dir = tempfile. mkdtemp ( prefix = ""urh-"" ) <TAB> devnull = old_stderr = None <TAB> try : <TAB> <TAB> try : <TAB> <TAB> <TAB> file_name = os. path. join ( tmp_dir, ""{}.c"". format ( function_name ) ) <TAB> <TAB> <TAB> with open ( file_name, ""w"" ) as f : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> f. write ( ""void %s();\n"" % function_name ) <TAB> <TAB> <TAB> <TAB> f. write ( ""int main(void) {\n"" ) <TAB> <TAB> <TAB> <TAB> f. write ( "" %s();\n"" % function_name ) <TAB> <TAB> <TAB> <TAB> f. write ( ""}\n"" ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> devnull = open ( os. devnull, ""w"" ) <TAB> <TAB> <TAB> old_stderr = os. dup ( sys. stderr. fileno ( ) ) <TAB> <TAB> <TAB> os. dup2 ( devnull. fileno ( ), sys. stderr. fileno ( ) ) <TAB> <TAB> <TAB> objects = compiler. compile ( [ file_name ], include_dirs = include_dirs ) <TAB> <TAB> <TAB> compiler. link_executable ( <TAB> <TAB> <TAB> <TAB> objects, <TAB> <TAB> <TAB> <TAB> os. path. join ( tmp_dir, ""a.out"" ), <TAB> <TAB> <TAB> <TAB> library_dirs = library_dirs, <TAB> <TAB> <TAB> <TAB> libraries = libraries, <TAB> <TAB> <TAB> ) <TAB> <TAB> except Exception as e : <TAB> <TAB> <TAB> return False <TAB> <TAB> return True <TAB> finally : <TAB> <TAB> if old_",False,devnull is not None,devnull,0.6567244529724121
|
||
|
2948,"def _subsample_site_value ( self, value, event_dim = None ) : <TAB> if ( <TAB> <TAB> self. dim is not None <TAB> <TAB> and event_dim is not None <TAB> <TAB> and self. subsample_size < self. _full_size <TAB> ) : <TAB> <TAB> event_shape = value. shape [ len ( value. shape ) - event_dim : ] <TAB> <TAB> funsor_value = to_funsor ( value, output = funsor. Reals [ event_shape ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return to_data ( funsor_value ( ** { self. name : self. _indices } ) ) <TAB> return value",False,self.name in funsor_value.inputs,self.subsample_size is not None,0.6535462141036987
|
||
|
2949,"def scan_tag_handle ( self, name, start_mark ) : <TAB> <TAB> <TAB> <TAB> ch = self. peek ( ) <TAB> if<mask> : <TAB> <TAB> raise ScannerError ( <TAB> <TAB> <TAB> ""while scanning a %s"" % name, <TAB> <TAB> <TAB> start_mark, <TAB> <TAB> <TAB> ""expected '!', but found %r"" % ch. encode ( ""utf-8"" ), <TAB> <TAB> <TAB> self. get_mark ( ), <TAB> <TAB> ) <TAB> length = 1 <TAB> ch = self. peek ( length ) <TAB> if ch!= u"" "" : <TAB> <TAB> while ( <TAB> <TAB> <TAB> u""0"" <= ch <= u""9"" or u""A"" <= ch <= ""Z"" or u""a"" <= ch <= ""z"" or ch in u""-_"" <TAB> <TAB> ) : <TAB> <TAB> <TAB> length += 1 <TAB> <TAB> <TAB> ch = self. peek ( length ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. forward ( length ) <TAB> <TAB> <TAB> raise ScannerError ( <TAB> <TAB> <TAB> <TAB> ""while scanning a %s"" % name, <TAB> <TAB> <TAB> <TAB> start_mark, <TAB> <TAB> <TAB> <TAB> ""expected '!', but found %r"" % ch. encode ( ""utf-8"" ), <TAB> <TAB> <TAB> <TAB> self. get_mark ( ), <TAB> <TAB> <TAB> ) <TAB> <TAB> length += 1 <TAB> value = self. prefix ( length ) <TAB> self. forward ( length ) <TAB> return value",True,ch != u'!',ch != u'!',0.6683789491653442
|
||
|
2950,"def open ( self, event = None, editFile = None ) : <TAB> if self. editwin. flist : <TAB> <TAB> if not editFile : <TAB> <TAB> <TAB> filename = self. askopenfile ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> filename = editFile <TAB> <TAB> if filename : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> interp = self. editwin. interp <TAB> <TAB> <TAB> except AttributeError : <TAB> <TAB> <TAB> <TAB> interp = None <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. editwin. flist. open ( filename, self. loadfile ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. editwin. flist. open ( filename ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. text. focus_set ( ) <TAB> <TAB> return ""break"" <TAB> <TAB> <TAB> if self. get_saved ( ) : <TAB> <TAB> reply = self. maybesave ( ) <TAB> <TAB> if reply == ""cancel"" : <TAB> <TAB> <TAB> self. text. focus_set ( ) <TAB> <TAB> <TAB> return ""break"" <TAB> if not editFile : <TAB> <TAB> filename = self. askopenfile ( ) <TAB> else : <TAB> <TAB> filename = editFile <TAB> if filename : <TAB> <TAB> self. loadfile ( filename ) <TAB> else : <TAB> <TAB> self. text. focus_set ( ) <TAB> return ""break""",False,not self.filename and self.get_saved() and (not interp),filename,0.6521525979042053
|
||
|
2951,"def configure ( self ) : <TAB> <TAB> if ""from_"" in self. wmeta. properties : <TAB> <TAB> from_ = float ( self. wmeta. properties [ ""from_"" ] ) <TAB> <TAB> to = float ( self. wmeta. properties. get ( ""to"", 0 ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> to = from_ + 1 <TAB> <TAB> <TAB> self. wmeta. properties [ ""to"" ] = str ( to ) <TAB> super ( TKSpinbox, self ). configure ( )",False,from_ > to,from_ + 1 < to,0.6622198820114136
|
||
|
2952,"def test_put_block_list_with_if_unmodified_fail ( <TAB> self, resource_group, location, storage_account, storage_account_key ) : <TAB> bsc = BlobServiceClient ( <TAB> <TAB> self. account_url ( storage_account, ""blob"" ), <TAB> <TAB> storage_account_key, <TAB> <TAB> connection_data_block_size = 4 * 1024, <TAB> <TAB> transport = AiohttpTestTransport ( ), <TAB> ) <TAB> self. _setup ( ) <TAB> container, blob = await self. _create_container_and_block_blob ( <TAB> <TAB> self. container_name, ""blob1"", b"""", bsc <TAB> ) <TAB> await asyncio. gather ( <TAB> <TAB> * [ <TAB> <TAB> <TAB> blob. stage_block ( ""1"", b""AAA"" ), <TAB> <TAB> <TAB> blob. stage_block ( ""2"", b""BBB"" ), <TAB> <TAB> <TAB> blob. stage_block ( ""3"", b""CCC"" ), <TAB> <TAB> ] <TAB> ) <TAB> test_datetime = datetime. utcnow ( ) - timedelta ( minutes = 15 ) <TAB> <TAB> with self. assertRaises ( ResourceModifiedError ) as e : <TAB> <TAB> await blob. commit_block_list ( <TAB> <TAB> <TAB> [ BlobBlock ( block_id = ""1"" ), BlobBlock ( block_id = ""2"" ), BlobBlock ( block_id = ""3"" ) ], <TAB> <TAB> <TAB><mask> : <TAB> <TAB> ) <TAB> <TAB> self. assertEqual ( StorageErrorCode. condition_not_met, e. exception. error_code )",False,"if_unmodified_since = (test_datetime,)",e.exception is not None,0.6457321047782898
|
||
|
2953,"def write_entries ( cmd, basename, filename ) : <TAB> ep = cmd. distribution. entry_points <TAB> if isinstance ( ep, basestring ) or ep is None : <TAB> <TAB> data = ep <TAB> elif ep is not None : <TAB> <TAB> data = [ ] <TAB> <TAB> for section, contents in ep. items ( ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> contents = EntryPoint. parse_group ( section, contents ) <TAB> <TAB> <TAB> <TAB> contents = ""\n"". join ( map ( str, contents. values ( ) ) ) <TAB> <TAB> <TAB> data. append ( ""[%s]\n%s\n\n"" % ( section, contents ) ) <TAB> <TAB> data = """". join ( data ) <TAB> cmd. write_or_delete_file ( ""entry points"", filename, data, True )",False,"not isinstance(contents, basestring)",contents,0.655453085899353
|
||
|
2954,"def test_the_translation_of_ambig_codons ( self ) : <TAB> """"""Check obj.translate() method with ambiguous codons."""""" <TAB> for ambig_values in [ ambiguous_dna_values, ambiguous_rna_values ] : <TAB> <TAB> ambig = set ( ambig_values. keys ( ) ) <TAB> <TAB> ambig. remove ( ""X"" ) <TAB> <TAB> for c1 in ambig : <TAB> <TAB> <TAB> for c2 in ambig : <TAB> <TAB> <TAB> <TAB> for c3 in ambig : <TAB> <TAB> <TAB> <TAB> <TAB> values = { <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> str ( Seq ( a + b + c ). translate ( ) ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for a in ambig_values [ c1 ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for b in ambig_values [ c2 ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for c in ambig_values [ c3 ] <TAB> <TAB> <TAB> <TAB> <TAB> } <TAB> <TAB> <TAB> <TAB> <TAB> t = str ( Seq ( c1 + c2 + c3 ). translate ( ) ) <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. assertEqual ( values, set ( ""*"" ) ) <TAB> <TAB> <TAB> <TAB> <TAB> elif t == ""X"" : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. assertGreater ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> len ( values ), <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> 1, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""translate('%s') = '%s' not '%s'"" <TAB> <",False,t == '*',t == 'X',0.6845865249633789
|
||
|
2955,"def _cursor ( self ) : <TAB> new_connection = False <TAB> set_tz = False <TAB> settings_dict = self. settings_dict <TAB> if self. connection is None : <TAB> <TAB> new_connection = True <TAB> <TAB> set_tz = settings_dict. get ( ""TIME_ZONE"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> from django. core. exceptions import ImproperlyConfigured <TAB> <TAB> <TAB> raise ImproperlyConfigured ( <TAB> <TAB> <TAB> <TAB> ""You need to specify NAME in your Django settings file."" <TAB> <TAB> <TAB> ) <TAB> <TAB> conn_string = ""dbname=%s"" % settings_dict [ ""NAME"" ] <TAB> <TAB> if settings_dict [ ""USER"" ] : <TAB> <TAB> <TAB> conn_string = ""user=%s %s"" % ( settings_dict [ ""USER"" ], conn_string ) <TAB> <TAB> if settings_dict [ ""PASSWORD"" ] : <TAB> <TAB> <TAB> conn_string += "" password='%s'"" % settings_dict [ ""PASSWORD"" ] <TAB> <TAB> if settings_dict [ ""HOST"" ] : <TAB> <TAB> <TAB> conn_string += "" host=%s"" % settings_dict [ ""HOST"" ] <TAB> <TAB> if settings_dict [ ""PORT"" ] : <TAB> <TAB> <TAB> conn_string += "" port=%s"" % settings_dict [ ""PORT"" ] <TAB> <TAB> self. connection = Database. connect ( conn_string, ** settings_dict [ ""OPTIONS"" ] ) <TAB> <TAB> <TAB> <TAB> self. connection. set_isolation_level ( 1 ) <TAB> <TAB> connection_created. send ( sender = self. __class__, connection = self ) <TAB> cursor = self. connection. cursor ( ) <TAB> if new_connection : <TAB> <TAB> if set_tz : <TAB> <TAB> <TAB> cursor. execute ( ""SET TIME ZONE %s"", [ settings_dict [ ""TIME_ZONE"" ] ] ) <TAB> <TAB> if not hasattr",False,settings_dict['NAME'] == '',settings_dict is None,0.6612499952316284
|
||
|
2956,"def check_initializer_statistics ( self, backend_config, n ) : <TAB> from scipy import stats <TAB> xp = backend_config. xp <TAB> ws = numpy. empty ( ( n, ) + self. shape, dtype = self. dtype ) <TAB> ws = backend_config. get_array ( ws ) <TAB> for i in range ( n ) : <TAB> <TAB> initializer = self. target ( ** self. target_kwargs ) <TAB> <TAB> initializer ( xp. squeeze ( ws [ i : i + 1 ], axis = 0 ) ) <TAB> fan = self. fan_option or default_fan. get ( self. target ) <TAB> expected_std = self. scale or default_scale. get ( self. target ) or 1.0 <TAB> expected_std *= default_coeff. get ( self. target ) or 1.0 <TAB> if fan is not None : <TAB> <TAB> if fan == ""fan_in"" : <TAB> <TAB> <TAB> expected_std *= math. sqrt ( 1.0 / self. fans [ 0 ] ) <TAB> <TAB> elif fan == ""fan_out"" : <TAB> <TAB> <TAB> expected_std *= math. sqrt ( 1.0 / self. fans [ 1 ] ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> expected_std *= math. sqrt ( 2.0 / sum ( self. fans ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> assert False <TAB> sampless = cuda. to_cpu ( ws. reshape ( n, - 1 ). T ) <TAB> alpha = 0.01 / len ( sampless ) <TAB> for samples in sampless : <TAB> <TAB> _, p = stats. kstest ( samples, stats. norm ( 0, expected_std ). cdf ) <TAB> <TAB> assert p >= alpha",False,fan == 'fan_avg',fan == 'cuda',0.6550541520118713
|
||
|
2957,"def init ( self ) : <TAB> """"""Initialize a module from the database and validate"""""" <TAB> self. __item = None <TAB> self. __baseItem = None <TAB> self. __charge = None <TAB> self. __mutaplasmid = None <TAB> <TAB> self. __slot = self. dummySlot <TAB> if self. itemID : <TAB> <TAB> self. __item = eos. db. getItem ( self. itemID ) <TAB> <TAB> if self. __item is None : <TAB> <TAB> <TAB> pyfalog. error ( ""Item (id: {0}) does not exist"", self. itemID ) <TAB> <TAB> <TAB> return <TAB> if self. baseItemID : <TAB> <TAB> self. __item = eos. db. getItemWithBaseItemAttribute ( self. itemID, self. baseItemID ) <TAB> <TAB> self. __baseItem = eos. db. getItem ( self. baseItemID ) <TAB> <TAB> self. __mutaplasmid = eos. db. getMutaplasmid ( self. mutaplasmidID ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> pyfalog. error ( ""Base Item (id: {0}) does not exist"", self. itemID ) <TAB> <TAB> <TAB> return <TAB> if self. isInvalid : <TAB> <TAB> pyfalog. error ( ""Item (id: {0}) is not a Module"", self. itemID ) <TAB> <TAB> return <TAB> if self. chargeID : <TAB> <TAB> self. __charge = eos. db. getItem ( self. chargeID ) <TAB> self. build ( )",True,self.__baseItem is None,self.__baseItem is None,0.6674394607543945
|
||
|
2958,"def test_iterwalk_ns_skip ( self ) : <TAB> iterwalk = self. etree. iterwalk <TAB> root = self. etree. XML ( <TAB> <TAB> _bytes ( <TAB> <TAB> <TAB> '<a xmlns=""ns1""><b xmlns=""nsb""><c xmlns=""ns2""/></b><d xmlns=""ns2""><e/></d></a>' <TAB> <TAB> ) <TAB> ) <TAB> events = [ ] <TAB> iterator = iterwalk ( root, events = ( ""start"", ""start-ns"", ""end-ns"" ) ) <TAB> for event, elem in iterator : <TAB> <TAB> if event in ( ""start-ns"", ""end-ns"" ) : <TAB> <TAB> <TAB> events. append ( ( event, elem ) ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> events. append ( ""skip"" ) <TAB> <TAB> <TAB> <TAB> iterator. skip_subtree ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> events. append ( ( event, elem. tag ) ) <TAB> self. assertEqual ( <TAB> <TAB> [ <TAB> <TAB> <TAB> ( ""start-ns"", ( """", ""ns1"" ) ), <TAB> <TAB> <TAB> ( ""start"", ""{ns1}a"" ), <TAB> <TAB> <TAB> ( ""start-ns"", ( """", ""nsb"" ) ), <TAB> <TAB> <TAB> ""skip"", <TAB> <TAB> <TAB> ( ""start"", ""{nsb}b"" ), <TAB> <TAB> <TAB> ( ""end-ns"", None ), <TAB> <TAB> <TAB> ( ""start-ns"", ( """", ""ns2"" ) ), <TAB> <TAB> <TAB> ( ""start"", ""{ns2}d"" ), <TAB> <TAB> <TAB> ( ""start"", ""{ns2}e"" ), <TAB> <TAB> <TAB> ( ""end-ns"", None ), <TAB> <TAB> <TAB",False,"event == 'start-ns' and elem == ('', 'nsb')","hasattr(elem, 'tag')",0.6504391431808472
|
||
|
2959,"def limited_by_marker ( items, request, max_limit = FLAGS. osapi_max_limit ) : <TAB> """"""Return a slice of items according to the requested marker and limit."""""" <TAB> params = get_pagination_params ( request ) <TAB> limit = params. get ( ""limit"", max_limit ) <TAB> marker = params. get ( ""marker"" ) <TAB> limit = min ( max_limit, limit ) <TAB> start_index = 0 <TAB> if marker : <TAB> <TAB> start_index = - 1 <TAB> <TAB> for i, item in enumerate ( items ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> start_index = i + 1 <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> if start_index < 0 : <TAB> <TAB> <TAB> msg = _ ( ""marker [%s] not found"" ) % marker <TAB> <TAB> <TAB> raise webob. exc. HTTPBadRequest ( explanation = msg ) <TAB> range_end = start_index + limit <TAB> return items [ start_index : range_end ]",False,item['id'] == marker or item.get('uuid') == marker,item,0.6548517942428589
|
||
|
2960,"def assign_attributes_to_variants ( variant_attributes ) : <TAB> for value in variant_attributes : <TAB> <TAB> pk = value [ ""pk"" ] <TAB> <TAB> defaults = value [ ""fields"" ] <TAB> <TAB> defaults [ ""variant_id"" ] = defaults. pop ( ""variant"" ) <TAB> <TAB> defaults [ ""assignment_id"" ] = defaults. pop ( ""assignment"" ) <TAB> <TAB> assigned_values = defaults. pop ( ""values"" ) <TAB> <TAB> assoc, created = AssignedVariantAttribute. objects. update_or_create ( <TAB> <TAB> <TAB> pk = pk, defaults = defaults <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> assoc. values. set ( AttributeValue. objects. filter ( pk__in = assigned_values ) )",True,created,created,0.6857447624206543
|
||
|
2961,"def render ( self, context ) : <TAB> block_context = context. render_context. get ( BLOCK_CONTEXT_KEY ) <TAB> with context. push ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> context [ ""block"" ] = self <TAB> <TAB> <TAB> result = self. nodelist. render ( context ) <TAB> <TAB> else : <TAB> <TAB> <TAB> push = block = block_context. pop ( self. name ) <TAB> <TAB> <TAB> if block is None : <TAB> <TAB> <TAB> <TAB> block = self <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> block = type ( self ) ( block. name, block. nodelist ) <TAB> <TAB> <TAB> block. context = context <TAB> <TAB> <TAB> context [ ""block"" ] = block <TAB> <TAB> <TAB> result = block. nodelist. render ( context ) <TAB> <TAB> <TAB> if push is not None : <TAB> <TAB> <TAB> <TAB> block_context. push ( self. name, push ) <TAB> return result",True,block_context is None,block_context is None,0.6572163105010986
|
||
|
2962,"def read ( self, count ) : <TAB> if self. closed : <TAB> <TAB> return self. upstream. read ( count ) <TAB> try : <TAB> <TAB> while len ( self. upstream ) < count : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> with self. buf_in : <TAB> <TAB> <TAB> <TAB> <TAB> self. transport. downstream_recv ( self. buf_in ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> return self. upstream. read ( count ) <TAB> except : <TAB> <TAB> logger. debug ( traceback. format_exc ( ) )",False,self.buf_in or self._poll_read(10),self.transport.downstream,0.6506208777427673
|
||
|
2963,"def make_node ( self, _input ) : <TAB> input = as_tensor_variable ( _input ) <TAB> ib = tuple ( input. type. broadcastable ) <TAB> if not ib == self. input_broadcastable : <TAB> <TAB> if len ( ib )!= len ( self. input_broadcastable ) : <TAB> <TAB> <TAB> raise TypeError ( <TAB> <TAB> <TAB> <TAB> ( <TAB> <TAB> <TAB> <TAB> <TAB> ""The number of dimensions of the "" <TAB> <TAB> <TAB> <TAB> <TAB> ""input is incorrect for this op. Expected %s, got %s."" <TAB> <TAB> <TAB> <TAB> <TAB> % ( self. input_broadcastable, ib ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> for expected, b in zip ( self. input_broadcastable, ib ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise TypeError ( <TAB> <TAB> <TAB> <TAB> <TAB> ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""The broadcastable pattern of the "" <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""input is incorrect for this op. Expected %s, got %s."" <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> % ( self. input_broadcastable, ib ) <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ob = [ ] <TAB> for value in self. new_order : <TAB> <TAB> if value == ""x"" : <TAB> <TAB> <TAB> ob. append ( True ) <TAB> <TAB> else : <TAB> <TAB> <TAB> ob. append ( ib [ value ] ) <TAB> output = TensorType ( dtype = input. type. dtype, broadcastable = ob ) ( ) <TAB> return Apply ( self, [",False,expected is True and b is False,not b,0.6585415601730347
|
||
|
2964,"def button_press_cb ( self, tdw, event ) : <TAB> result = False <TAB> current_layer = tdw. doc. layer_stack. current <TAB> if ( <TAB> <TAB> current_layer. get_paintable ( ) <TAB> <TAB> and event. button == 1 <TAB> <TAB> and event. type == Gdk. EventType. BUTTON_PRESS <TAB> ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. doc. input_stroke_started ( event ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> drawstate = self. _get_drawing_state ( tdw ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. motion_notify_cb ( tdw, event, fakepressure = tdw. app. fakepressure ) <TAB> <TAB> drawstate. button_down = event. button <TAB> <TAB> drawstate. last_good_raw_pressure = 0.0 <TAB> <TAB> drawstate. last_good_raw_xtilt = 0.0 <TAB> <TAB> drawstate. last_good_raw_ytilt = 0.0 <TAB> <TAB> drawstate. last_good_raw_viewzoom = 0.0 <TAB> <TAB> drawstate. last_good_raw_viewrotation = 0.0 <TAB> <TAB> drawstate. last_good_raw_barrel_rotation = 0.0 <TAB> <TAB> <TAB> <TAB> self. _hide_drawing_cursor ( tdw ) <TAB> <TAB> result = True <TAB> return super ( FreehandMode, self ). button_press_cb ( tdw, event ) or result",False,not drawstate.last_event_had_pressure,drawstate is not None,0.6527959704399109
|
||
|
2965,"def get_content ( self, path ) : <TAB> """"""Returns a list of the type [[Folder List], [file list]]."""""" <TAB> try : <TAB> <TAB> files = [ ] <TAB> <TAB> dirs = [ ] <TAB> <TAB> if self. history_flag : <TAB> <TAB> <TAB> self. history. append ( path ) <TAB> <TAB> if not self. history_flag : <TAB> <TAB> <TAB> self. history_flag = True <TAB> <TAB> for content in os. listdir ( path ) : <TAB> <TAB> <TAB> if os. path. isdir ( os. path. join ( path, content ) ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> dirs. append ( content ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> if self. search == ""all"" or self. search == ""files"" : <TAB> <TAB> <TAB> <TAB> <TAB> if len ( self. ext )!= 0 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if self. count_ext ( content ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if self. previous : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> files. append ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> os. path. join ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. app. user_data_dir, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""thumb"", <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB>",False,self.search == 'all' or self.search == 'dirs',self.search_dir,0.6568790078163147
|
||
|
2966,"def compare_authors ( amazon, marc ) : <TAB> warnings. warn ( <TAB> <TAB> ""Deprecated, use openlibrary.catalog.merge.merge_marc.compare_authors() instead."", <TAB> <TAB> DeprecationWarning, <TAB> ) <TAB> if len ( amazon [ ""authors"" ] ) == 0 and ""authors"" not in marc : <TAB> <TAB> return ( ""authors"", ""no authors"", 75 ) <TAB> if len ( amazon [ ""authors"" ] ) == 0 : <TAB> <TAB> return ( ""authors"", ""field missing from one record"", - 25 ) <TAB> for name in amazon [ ""authors"" ] : <TAB> <TAB> if ""authors"" in marc and match_name ( name, marc [ ""authors"" ] [ 0 ] [ ""name"" ] ) : <TAB> <TAB> <TAB> return ( ""authors"", ""exact match"", 125 ) <TAB> <TAB> if ""by_statement"" in marc and marc [ ""by_statement"" ]. find ( name )!= - 1 : <TAB> <TAB> <TAB> return ( ""authors"", ""exact match"", 125 ) <TAB> if ""authors"" not in marc : <TAB> <TAB> return ( ""authors"", ""field missing from one record"", - 25 ) <TAB> max_score = 0 <TAB> for a in amazon [ ""authors"" ] : <TAB> <TAB> percent, ordered = keyword_match ( a [ 0 ], marc [ ""authors"" ] [ 0 ] [ ""name"" ] ) <TAB> <TAB> if percent > 0.50 : <TAB> <TAB> <TAB> score = percent * 80 <TAB> <TAB> <TAB> if ordered : <TAB> <TAB> <TAB> <TAB> score += 10 <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> max_score = score <TAB> if max_score : <TAB> <TAB> return ( ""authors"", ""keyword match"", max_score ) <TAB> else : <TAB> <TAB> return ( ""authors"", ""mismatch"", - 200 )",False,score > max_score,max_score,0.6624674797058105
|
||
|
2967,"def _convert ( container ) : <TAB> if _value_marker in container : <TAB> <TAB> force_list = False <TAB> <TAB> values = container. pop ( _value_marker ) <TAB> <TAB> if container. pop ( _list_marker, False ) : <TAB> <TAB> <TAB> force_list = True <TAB> <TAB> <TAB> values. extend ( _convert ( x [ 1 ] ) for x in sorted ( container. items ( ) ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> values = values [ 0 ] <TAB> <TAB> if not container : <TAB> <TAB> <TAB> return values <TAB> <TAB> return _convert ( container ) <TAB> elif container. pop ( _list_marker, False ) : <TAB> <TAB> return [ _convert ( x [ 1 ] ) for x in sorted ( container. items ( ) ) ] <TAB> return dict_cls ( ( k, _convert ( v ) ) for k, v in iteritems ( container ) )",False,not force_list and len(values) == 1,force_list,0.651579737663269
|
||
|
2968,"def start ( self ) : <TAB> """"""Called by main to start the rqd service"""""" <TAB> if self. machine. isDesktop ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> log. warning ( ""Nimby startup has been disabled via --nimbyoff"" ) <TAB> <TAB> elif not rqd. rqconstants. OVERRIDE_NIMBY : <TAB> <TAB> <TAB> if rqd. rqconstants. OVERRIDE_NIMBY is None : <TAB> <TAB> <TAB> <TAB> log. warning ( <TAB> <TAB> <TAB> <TAB> <TAB> ""OVERRIDE_NIMBY is not defined, Nimby startup has been disabled"" <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> log. warning ( ""OVERRIDE_NIMBY is False, Nimby startup has been disabled"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. nimbyOn ( ) <TAB> elif rqd. rqconstants. OVERRIDE_NIMBY : <TAB> <TAB> log. warning ( ""Nimby startup has been triggered by OVERRIDE_NIMBY"" ) <TAB> <TAB> self. nimbyOn ( ) <TAB> self. network. start_grpc ( )",False,self.__optNimbyoff,not rqd.rqconstants.NimbyOn,0.6673377156257629
|
||
|
2969,"def _process_demands ( self ) : <TAB> demands = self. demands <TAB> repos = self. base. repos <TAB> if demands. root_user : <TAB> <TAB> if not dnf. util. am_i_root ( ) : <TAB> <TAB> <TAB> raise dnf. exceptions. Error ( <TAB> <TAB> <TAB> <TAB> _ ( <TAB> <TAB> <TAB> <TAB> <TAB> ""This command has to be run with superuser privileges "" <TAB> <TAB> <TAB> <TAB> <TAB> ""(under the root user on most systems)."" <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> if demands. changelogs : <TAB> <TAB> for repo in repos. iter_enabled ( ) : <TAB> <TAB> <TAB> repo. load_metadata_other = True <TAB> if demands. cacheonly or self. base. conf. cacheonly : <TAB> <TAB> self. base. conf. cacheonly = True <TAB> <TAB> for repo in repos. values ( ) : <TAB> <TAB> <TAB> repo. _repo. setSyncStrategy ( dnf. repo. SYNC_ONLY_CACHE ) <TAB> else : <TAB> <TAB> if demands. freshest_metadata : <TAB> <TAB> <TAB> for repo in repos. iter_enabled ( ) : <TAB> <TAB> <TAB> <TAB> repo. _repo. expire ( ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> for repo in repos. values ( ) : <TAB> <TAB> <TAB> <TAB> repo. _repo. setSyncStrategy ( dnf. repo. SYNC_LAZY ) <TAB> if demands. sack_activation : <TAB> <TAB> self. base. fill_sack ( <TAB> <TAB> <TAB> load_system_repo = ""auto"" if self. demands. load_system_repo else False, <TAB> <TAB> <TAB> load_available_repos = self. demands. available_repos, <TAB> <TAB> )",False,not demands.fresh_metadata,demands.lstat_local,0.6565486788749695
|
||
|
2970,"def iter_region ( <TAB> self, start_offset = None, end_offset = None, protec = None, optimizations = None ) : <TAB> offset = start_offset or self. min_addr <TAB> end_offset = end_offset or self. max_addr <TAB> while True : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> break <TAB> <TAB> mbi = self. VirtualQueryEx ( offset ) <TAB> <TAB> offset = mbi. BaseAddress <TAB> <TAB> chunk = mbi. RegionSize <TAB> <TAB> protect = mbi. Protect <TAB> <TAB> state = mbi. State <TAB> <TAB> <TAB> <TAB> if state & MEM_FREE or state & MEM_RESERVE : <TAB> <TAB> <TAB> offset += chunk <TAB> <TAB> <TAB> continue <TAB> <TAB> if protec : <TAB> <TAB> <TAB> if ( <TAB> <TAB> <TAB> <TAB> not protect & protec <TAB> <TAB> <TAB> <TAB> or protect & PAGE_NOCACHE <TAB> <TAB> <TAB> <TAB> or protect & PAGE_WRITECOMBINE <TAB> <TAB> <TAB> <TAB> or protect & PAGE_GUARD <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> offset += chunk <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> yield offset, chunk <TAB> <TAB> offset += chunk",False,offset >= end_offset,optimizations,0.6689964532852173
|
||
|
2971,"def validate_weight ( self, weight ) : <TAB> try : <TAB> <TAB> add_acl_to_obj ( self. context [ ""user_acl"" ], self. category ) <TAB> except AttributeError : <TAB> <TAB> return weight <TAB> if weight > self. category. acl. get ( ""can_pin_threads"", 0 ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValidationError ( <TAB> <TAB> <TAB> <TAB> _ ( <TAB> <TAB> <TAB> <TAB> <TAB> ""You don't have permission to pin threads globally "" <TAB> <TAB> <TAB> <TAB> <TAB> ""in this category."" <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise ValidationError ( <TAB> <TAB> <TAB> <TAB> _ ( ""You don't have permission to pin threads in this category."" ) <TAB> <TAB> <TAB> ) <TAB> return weight",False,weight == 2,"self.category.acl.get('can_pin_threads', 0) is False",0.6777848601341248
|
||
|
2972,"def replacement ( self, match_layer ) : <TAB> concat_layer_node = match_layer <TAB> feeding_layer_nodes = match_layer. input_layers <TAB> default_registry = default_8bit_quantize_registry. Default8BitQuantizeRegistry ( ) <TAB> feed_quantize_configs = [ ] <TAB> for feed_layer_node in feeding_layer_nodes : <TAB> <TAB> quantize_config = feed_layer_node. metadata. get ( ""quantize_config"" ) <TAB> <TAB> if not quantize_config : <TAB> <TAB> <TAB> layer_class = self. _get_layer_type ( feed_layer_node. layer [ ""class_name"" ] ) <TAB> <TAB> <TAB> if layer_class is None : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return match_layer <TAB> <TAB> <TAB> if layer_class == keras. layers. Concatenate : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> feed_layer_node. metadata [ <TAB> <TAB> <TAB> <TAB> <TAB> ""quantize_config"" <TAB> <TAB> <TAB> <TAB> ] = default_8bit_quantize_configs. NoOpQuantizeConfig ( ) <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return match_layer <TAB> <TAB> <TAB> quantize_config = default_registry. _get_quantize_config ( layer_class ) <TAB> <TAB> <TAB> feed_layer_node. metadata [ ""quantize_config"" ] = quantize_config <TAB> <TAB> feed_quantize_configs. append ( quantize_config ) <TAB> <TAB> <TAB> <TAB> for quantize_config in feed_quantize_configs : <TAB> <TAB> self. _disable_output_quantize ( quantize_config ) <TAB> if not concat_layer_node.",False,not default_registry._is_supported_layer(layer_class),layer_class is None,0.6470897197723389
|
||
|
2973,"def OnBodyClick ( self, event = None ) : <TAB> try : <TAB> <TAB> c = self. c <TAB> <TAB> p = c. currentPosition ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. OnActivateBody ( event = event ) <TAB> <TAB> g. doHook ( ""bodyclick2"", c = c, p = p, v = p, event = event ) <TAB> except : <TAB> <TAB> g. es_event_exception ( ""bodyclick"" )",False,"not g.doHook('bodyclick1', c=c, p=p, v=p, event=event)",p and self.c.currentIndex() == 0,0.6513603925704956
|
||
|
2974,"def register_old ( bl_id ) : <TAB> if bl_id in old_bl_idnames : <TAB> <TAB> mod = importlib. import_module ( "".{}"". format ( old_bl_idnames [ bl_id ] ), __name__ ) <TAB> <TAB> res = inspect. getmembers ( mod ) <TAB> <TAB> <TAB> <TAB> for name, cls in res : <TAB> <TAB> <TAB> if inspect. isclass ( cls ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> if bl_id not in imported_mods : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> mod. register ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> except Exception as err : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> print ( ""failed mod register"" ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> exception ( err ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> imported_mods [ bl_id ] = mod <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return mod <TAB> <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return imported_mods [ bl_id ] <TAB> error ( ""Cannot find {} among old nodes"". format ( bl_id ) ) <TAB> return None",False,"issubclass(cls, bpy.types.Node) and cls.bl_idname == bl_id",bl_id not in imported_mods,0.652646541595459
|
||
|
2975,"def nextPair ( self ) : <TAB> if not self. _file : <TAB> <TAB> raise StopIteration <TAB> entryLines = [ ] <TAB> while True : <TAB> <TAB> line = self. _file. readline ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise StopIteration <TAB> <TAB> line = line. rstrip ( ""\n\r"" ) <TAB> <TAB> if line : <TAB> <TAB> <TAB> entryLines. append ( line ) <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> if not entryLines : <TAB> <TAB> <TAB> return <TAB> <TAB> if len ( entryLines ) < 2 : <TAB> <TAB> <TAB> log. error ( <TAB> <TAB> <TAB> <TAB> ""invalid block near line %s"" % fileObj. line + "" in file %s"" % filename <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> return <TAB> <TAB> word = entryLines [ 0 ] <TAB> <TAB> defi = ""\n"". join ( entryLines [ 1 : ] ) <TAB> <TAB> defi = defi. replace ( ""<br/>"", ""\n"" ) <TAB> <TAB> word = [ p. strip ( ) for p in word. split ( ""|"" ) ] <TAB> <TAB> return word, defi",True,not line,not line,0.6741937398910522
|
||
|
2976,"def _build_io_mapping ( self, intent_id, utterance, entity_placeholders ) : <TAB> input_ = [ ] <TAB> output = [ intent_id ] <TAB> slots = [ ] <TAB> for chunk in utterance [ DATA ] : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> slot_name = chunk [ SLOT_NAME ] <TAB> <TAB> <TAB> slot_id = self. _get_slot_id ( slot_name ) <TAB> <TAB> <TAB> entity_name = chunk [ ENTITY ] <TAB> <TAB> <TAB> placeholder = entity_placeholders [ entity_name ] <TAB> <TAB> <TAB> input_. append ( placeholder ) <TAB> <TAB> <TAB> slots. append ( slot_id ) <TAB> <TAB> else : <TAB> <TAB> <TAB> input_. append ( chunk [ TEXT ] ) <TAB> output. append ( slots ) <TAB> intent = self. _intents_names [ intent_id ] <TAB> key = self. _preprocess_text ( "" "". join ( input_ ), intent ) <TAB> return key, output",False,SLOT_NAME in chunk,chunk[SLOT_NAME] in entity_placeholders,0.6669102907180786
|
||
|
2977,"def update_neighbor ( neigh_ip_address, changes ) : <TAB> rets = [ ] <TAB> for k, v in changes. items ( ) : <TAB> <TAB> if k == neighbors. MULTI_EXIT_DISC : <TAB> <TAB> <TAB> rets. append ( _update_med ( neigh_ip_address, v ) ) <TAB> <TAB> if k == neighbors. ENABLED : <TAB> <TAB> <TAB> rets. append ( update_neighbor_enabled ( neigh_ip_address, v ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> rets. append ( _update_connect_mode ( neigh_ip_address, v ) ) <TAB> return all ( rets )",True,k == neighbors.CONNECT_MODE,k == neighbors.CONNECT_MODE,0.6641629934310913
|
||
|
2978,"def redrawHelper ( self, scroll = True, forceDraw = False ) : <TAB> <TAB> if g. app. quitting or self. frame not in g. app. windowList : <TAB> <TAB> return <TAB> if self. drag_p and not forceDraw : <TAB> <TAB> return <TAB> if not hasattr ( self, ""c"" ) : <TAB> <TAB> return <TAB> c = self. c <TAB> trace = False <TAB> oldcursor = self. canvas [ ""cursor"" ] <TAB> self. canvas [ ""cursor"" ] = ""watch"" <TAB> if not g. doHook ( ""redraw-entire-outline"", c = c ) : <TAB> <TAB> c. setTopVnode ( None ) <TAB> <TAB> self. setVisibleAreaToFullCanvas ( ) <TAB> <TAB> self. drawTopTree ( ) <TAB> <TAB> <TAB> <TAB> bbox = self. canvas. bbox ( ""all"" ) <TAB> <TAB> if trace : <TAB> <TAB> <TAB> g. trace ( ""bbox"", bbox, g. callers ( ) ) <TAB> <TAB> if bbox is None : <TAB> <TAB> <TAB> x0, y0, x1, y1 = 0, 0, 100, 100 <TAB> <TAB> else : <TAB> <TAB> <TAB> x0, y0, x1, y1 = bbox <TAB> <TAB> self. canvas. configure ( scrollregion = ( 0, 0, x1, y1 ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. canvas. update_idletasks ( ) <TAB> <TAB> <TAB> self. scrollTo ( ) <TAB> g. doHook ( ""after-redraw-outline"", c = c ) <TAB> self. canvas [ ""cursor"" ] = oldcursor",True,scroll,scroll,0.704870343208313
|
||
|
2979,"def __init__ ( self, base, config, ** kwargs ) : <TAB> <TAB> self. as_assert ( base, ""No base Address Space"" ) <TAB> addrspace. AbstractRunBasedMemory. __init__ ( self, base, config, ** kwargs ) <TAB> <TAB> <TAB> <TAB> self. as_assert ( <TAB> <TAB> base. read ( 0, 6 ) in [ ""\x7fELF\x02\x01"", ""\x7fELF\x01\x01"" ], <TAB> <TAB> ""ELF Header signature invalid"", <TAB> ) <TAB> <TAB> elf = obj. Object ( ""elf_hdr"", offset = 0, vm = base ) <TAB> <TAB> self. as_assert ( str ( elf. e_type ) == ""ET_CORE"", ""ELF type is not a Core file"" ) <TAB> <TAB> self. runs = [ ] <TAB> <TAB> self. header = None <TAB> for phdr in elf. program_headers ( ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> note = obj. Object ( ""elf_note"", offset = phdr. p_offset, vm = base, parent = phdr ) <TAB> <TAB> <TAB> self. check_note ( note ) <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> if ( <TAB> <TAB> <TAB> str ( phdr. p_type )!= ""PT_LOAD"" <TAB> <TAB> <TAB> or phdr. p_filesz == 0 <TAB> <TAB> <TAB> or phdr. p_filesz!= phdr. p_memsz <TAB> <TAB> ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> self. runs. append ( ( int ( phdr. p_paddr ), int ( phdr. p_offset ), int ( phdr. p_memsz ) ) ) <TAB> self. validate ( )",False,str(phdr.p_type) == 'PT_NOTE',phdr.e_type == 'ET_CORE',0.6510789394378662
|
||
|
2980,"def render ( self, context ) : <TAB> try : <TAB> <TAB> user = self. resolve ( self. user, context ) <TAB> <TAB> perm = self. resolve ( self. perm, context ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> objs = [ ] <TAB> <TAB> <TAB> for obj in self. objs : <TAB> <TAB> <TAB> <TAB> if obj is not None : <TAB> <TAB> <TAB> <TAB> <TAB> objs. append ( self. resolve ( obj, context ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> objs = None <TAB> <TAB> check = get_check ( user, perm ) <TAB> <TAB> if check is not None : <TAB> <TAB> <TAB> if check ( * objs ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return self. nodelist_true. render ( context ) <TAB> <TAB> except ( ImproperlyConfigured, ImportError ) : <TAB> <TAB> return """" <TAB> <TAB> except template. VariableDoesNotExist : <TAB> <TAB> return """" <TAB> <TAB> except ( TypeError, AttributeError ) : <TAB> <TAB> return """" <TAB> return self. nodelist_false. render ( context )",False,self.objs,self.has_objs,0.6779689788818359
|
||
|
2981,"def replace ( self, variable, expression, replace_bound = False, alpha_convert = True ) : <TAB> """""":see: Expression.replace()"""""" <TAB> assert isinstance ( variable, Variable ), ""%s is not a Variable"" % variable <TAB> assert isinstance ( expression, Expression ), ""%s is not an Expression"" % expression <TAB> <TAB> if self. variable == variable : <TAB> <TAB> if replace_bound : <TAB> <TAB> <TAB> assert isinstance ( expression, AbstractVariableExpression ), ( <TAB> <TAB> <TAB> <TAB> ""%s is not a AbstractVariableExpression"" % expression <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> return self. __class__ ( <TAB> <TAB> <TAB> <TAB> expression. variable, <TAB> <TAB> <TAB> <TAB> self. term. replace ( variable, expression, True, alpha_convert ), <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return self <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self = self. alpha_convert ( unique_variable ( pattern = self. variable ) ) <TAB> <TAB> <TAB> <TAB> return self. __class__ ( <TAB> <TAB> <TAB> self. variable, <TAB> <TAB> <TAB> self. term. replace ( variable, expression, replace_bound, alpha_convert ), <TAB> <TAB> )",False,alpha_convert and self.variable in expression.free(),alpha_convert,0.6503363847732544
|
||
|
2982,"def validate ( self, strn, pos ) : <TAB> if self. skipValidate : <TAB> <TAB> ret = QtGui. QValidator. Acceptable <TAB> else : <TAB> <TAB> try : <TAB> <TAB> <TAB> val = self. interpret ( ) <TAB> <TAB> <TAB> if val is False : <TAB> <TAB> <TAB> <TAB> ret = QtGui. QValidator. Intermediate <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> if self. valueInRange ( val ) : <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. setValue ( val, update = False ) <TAB> <TAB> <TAB> <TAB> <TAB> ret = QtGui. QValidator. Acceptable <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> ret = QtGui. QValidator. Intermediate <TAB> <TAB> except : <TAB> <TAB> <TAB> import sys <TAB> <TAB> <TAB> sys. excepthook ( * sys. exc_info ( ) ) <TAB> <TAB> <TAB> ret = QtGui. QValidator. Intermediate <TAB> <TAB> if ret == QtGui. QValidator. Intermediate : <TAB> <TAB> self. textValid = False <TAB> elif ret == QtGui. QValidator. Acceptable : <TAB> <TAB> self. textValid = True <TAB> <TAB> <TAB> self. update ( ) <TAB> self. errorBox. setVisible ( not self. textValid ) <TAB> <TAB> if hasattr ( QtCore, ""QString"" ) : <TAB> <TAB> return ( ret, pos ) <TAB> else : <TAB> <TAB> return ( ret, strn, pos )",False,not self.opts['delayUntilEditFinished'],self.hasValue(),0.6634962558746338
|
||
|
2983,"def state_dict ( self, destination = None, prefix = """", keep_vars = False ) : <TAB> destination = super ( ). state_dict ( <TAB> <TAB> destination = destination, prefix = prefix, keep_vars = keep_vars <TAB> ) <TAB> <TAB> for key in self. _defaults. keys ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> current_val = getattr ( self, key ) <TAB> <TAB> <TAB> if not keep_vars : <TAB> <TAB> <TAB> <TAB> if torch. is_tensor ( current_val ) : <TAB> <TAB> <TAB> <TAB> <TAB> current_val = current_val. detach ( ) <TAB> <TAB> <TAB> <TAB> elif isinstance ( current_val, list ) : <TAB> <TAB> <TAB> <TAB> <TAB> current_val = [ <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> cur_v. detach ( ) if torch. is_tensor ( cur_v ) else cur_v <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for cur_v in current_val <TAB> <TAB> <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> destination [ prefix + key ] = current_val <TAB> return destination",False,self._persistent[key],"hasattr(self, key)",0.660008430480957
|
||
|
2984,"def _execute_block ( conn, block ) : <TAB> sql_text = block. to_string ( ) <TAB> if debug. flags. bootstrap : <TAB> <TAB> debug. header ( ""Bootstrap Script"" ) <TAB> <TAB> debug. dump_code ( sql_text, lexer = ""sql"" ) <TAB> try : <TAB> <TAB> await conn. execute ( sql_text ) <TAB> except Exception as e : <TAB> <TAB> position = getattr ( e, ""position"", None ) <TAB> <TAB> internal_position = getattr ( e, ""internal_position"", None ) <TAB> <TAB> context = getattr ( e, ""context"", """" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> pl_func_line = re. search ( <TAB> <TAB> <TAB> <TAB> r""^PL/pgSQL function inline_code_block line (\d+).*"", context, re. M <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if pl_func_line : <TAB> <TAB> <TAB> <TAB> pl_func_line = int ( pl_func_line. group ( 1 ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> pl_func_line = None <TAB> <TAB> point = None <TAB> <TAB> if position is not None : <TAB> <TAB> <TAB> position = int ( position ) <TAB> <TAB> <TAB> point = parser_context. SourcePoint ( None, None, position ) <TAB> <TAB> <TAB> text = e. query <TAB> <TAB> <TAB> if text is None : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> text = sql_text <TAB> <TAB> elif internal_position is not None : <TAB> <TAB> <TAB> internal_position = int ( internal_position ) <TAB> <TAB> <TAB> point = parser_context. SourcePoint ( None, None, internal_position ) <TAB> <TAB> <TAB> text = e. internal_query <TAB> <TAB> elif pl_func_line : <",True,context,context,0.679485559463501
|
||
|
2985,"def _choose_instance ( self, timeout_time ) : <TAB> """"""Returns the best Instance to handle a request or None if all are busy."""""" <TAB> with self. _condition : <TAB> <TAB> while time. time ( ) < timeout_time : <TAB> <TAB> <TAB> required_instances, not_required_instances = self. _split_instances ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> required_instances = sorted ( <TAB> <TAB> <TAB> <TAB> <TAB> required_instances, key = lambda inst : inst. remaining_request_capacity <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> if required_instances [ - 1 ]. remaining_request_capacity : <TAB> <TAB> <TAB> <TAB> <TAB> return required_instances [ - 1 ] <TAB> <TAB> <TAB> available_instances = [ <TAB> <TAB> <TAB> <TAB> inst <TAB> <TAB> <TAB> <TAB> for inst in not_required_instances <TAB> <TAB> <TAB> <TAB> if inst. remaining_request_capacity > 0 and inst. can_accept_requests <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> if available_instances : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> available_instances. sort ( <TAB> <TAB> <TAB> <TAB> <TAB> key = lambda instance : instance. num_outstanding_requests <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> return available_instances [ - 1 ] <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. _condition. wait ( timeout_time - time. time ( ) ) <TAB> return None",False,required_instances,not_required_instances,0.664190411567688
|
||
|
2986,"def trap ( self, func, * args, ** kwargs ) : <TAB> try : <TAB> <TAB> return func ( * args, ** kwargs ) <TAB> except self. throws : <TAB> <TAB> raise <TAB> except StopIteration : <TAB> <TAB> raise <TAB> except Exception : <TAB> <TAB> tb = _cperror. format_exc ( ) <TAB> <TAB> _cherrypy. log ( tb, severity = 40 ) <TAB> <TAB> if not _cherrypy. request. show_tracebacks : <TAB> <TAB> <TAB> tb = """" <TAB> <TAB> s, h, b = _cperror. bare_error ( tb ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> s = s. decode ( ""ISO-8859-1"" ) <TAB> <TAB> <TAB> h = [ ( k. decode ( ""ISO-8859-1"" ), v. decode ( ""ISO-8859-1"" ) ) for k, v in h ] <TAB> <TAB> if self. started_response : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. iter_response = iter ( [ ] ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. iter_response = iter ( b ) <TAB> <TAB> try : <TAB> <TAB> <TAB> self. start_response ( s, h, _sys. exc_info ( ) ) <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> _cherrypy. log ( traceback = True, severity = 40 ) <TAB> <TAB> <TAB> raise <TAB> <TAB> if self. started_response : <TAB> <TAB> <TAB> return ntob ( """" ). join ( b ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return b",False,six.PY3,s is not None,0.6630895137786865
|
||
|
2987,"def confirm ( self ) : <TAB> if self. interactive : <TAB> <TAB> answer = None <TAB> <TAB> while not answer or answer not in ""yn"" : <TAB> <TAB> <TAB> answer = six. moves. input ( ""Do you wish to proceed? [yN] "" ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> answer = ""n"" <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> answer = answer [ 0 ]. lower ( ) <TAB> <TAB> return answer == ""y"" <TAB> return True",True,not answer,not answer,0.6765745878219604
|
||
|
2988,"def export_suffix_generator ( a_block, datatype = False ) : <TAB> if datatype is False : <TAB> <TAB> for name, suffix in iteritems ( a_block. component_map ( Suffix ) ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> yield name, suffix <TAB> else : <TAB> <TAB> for name, suffix in iteritems ( a_block. component_map ( Suffix ) ) : <TAB> <TAB> <TAB> if ( suffix. export_enabled ( ) is True ) and ( <TAB> <TAB> <TAB> <TAB> suffix. get_datatype ( ) is datatype <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> yield name, suffix",False,suffix.export_enabled() is True,datatype is False,0.6520780920982361
|
||
|
2989,"def clean_subevent ( event, subevent ) : <TAB> if event. has_subevents : <TAB> <TAB> if not subevent : <TAB> <TAB> <TAB> raise ValidationError ( _ ( ""Subevent cannot be null for event series."" ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValidationError ( _ ( ""The subevent does not belong to this event."" ) ) <TAB> else : <TAB> <TAB> if subevent : <TAB> <TAB> <TAB> raise ValidationError ( _ ( ""The subevent does not belong to this event."" ) )",False,event != subevent.event,event and event not in subevent,0.6532505750656128
|
||
|
2990,"def execute ( cls, ctx, op ) : <TAB> inputs, device_id, xp = as_same_device ( <TAB> <TAB> [ ctx [ inp. key ] for inp in op. inputs ], device = op. device, ret_extra = True <TAB> ) <TAB> a = inputs [ 0 ] <TAB> if len ( inputs ) == 2 : <TAB> <TAB> val = inputs [ 1 ] <TAB> else : <TAB> <TAB> val = op. val <TAB> with device ( device_id ) : <TAB> <TAB> if not op. k : <TAB> <TAB> <TAB> a = a. copy ( ) <TAB> <TAB> <TAB> xp. fill_diagonal ( a, val, wrap = op. wrap ) <TAB> <TAB> else : <TAB> <TAB> <TAB> assert a. ndim == 2 <TAB> <TAB> <TAB> k = op. k or 0 <TAB> <TAB> <TAB> n_rows, n_cols = a. shape <TAB> <TAB> <TAB> if k > 0 : <TAB> <TAB> <TAB> <TAB> n_cols -= k <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> n_rows += k <TAB> <TAB> <TAB> n = min ( n_rows, n_cols ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> rows, cols = np. diag_indices ( n ) <TAB> <TAB> <TAB> if k > 0 : <TAB> <TAB> <TAB> <TAB> cols = cols. copy ( ) <TAB> <TAB> <TAB> <TAB> cols += k <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> rows = rows. copy ( ) <TAB> <TAB> <TAB> <TAB> rows -= k <TAB> <TAB> <TAB> a = a. copy ( ) <TAB> <TAB> <TAB> a [ rows, cols ] = val <TAB> <TAB> ctx [ op. outputs [ 0 ]. key ] = a",False,k < 0,n_rows > 0,0.6819108724594116
|
||
|
2991,"def focused_windows ( ) : <TAB> tree = i3. get_tree ( ) <TAB> workspaces = tree. workspaces ( ) <TAB> for workspace in workspaces : <TAB> <TAB> container = workspace <TAB> <TAB> while container : <TAB> <TAB> <TAB> if not hasattr ( container, ""focus"" ) or not container. focus : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> container_id = container. focus [ 0 ] <TAB> <TAB> <TAB> container = container. find_by_id ( container_id ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> coname = container. name <TAB> <TAB> <TAB> wsname = workspace. name <TAB> <TAB> <TAB> print ( ""WS"", wsname + "":"", coname )",True,container,container,0.6867494583129883
|
||
|
2992,"def find_version ( * filepath ) : <TAB> <TAB> with open ( os. path. join ( ROOT_DIR, * filepath ) ) as fp : <TAB> <TAB> version_match = re. search ( <TAB> <TAB> <TAB> r""^__version__ = ['\""]([^'\""]*)['\""]"", fp. read ( ), re. M <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return version_match. group ( 1 ) <TAB> <TAB> raise RuntimeError ( ""Unable to find version string."" )",True,version_match,version_match,0.6590712070465088
|
||
|
2993,"def _quil_ ( <TAB> self, qubits : Tuple [ ""cirq.Qid"",... ], formatter : ""cirq.QuilFormatter"" ) -> Optional [ str ] : <TAB> if np. count_nonzero ( self. _diag_angles_radians ) == 1 : <TAB> <TAB> if self. _diag_angles_radians [ 0 ]!= 0 : <TAB> <TAB> <TAB> return formatter. format ( <TAB> <TAB> <TAB> <TAB> ""CPHASE00({0}) {1} {2}\n"", <TAB> <TAB> <TAB> <TAB> self. _diag_angles_radians [ 0 ], <TAB> <TAB> <TAB> <TAB> qubits [ 0 ], <TAB> <TAB> <TAB> <TAB> qubits [ 1 ], <TAB> <TAB> <TAB> ) <TAB> <TAB> elif self. _diag_angles_radians [ 1 ]!= 0 : <TAB> <TAB> <TAB> return formatter. format ( <TAB> <TAB> <TAB> <TAB> ""CPHASE01({0}) {1} {2}\n"", <TAB> <TAB> <TAB> <TAB> self. _diag_angles_radians [ 1 ], <TAB> <TAB> <TAB> <TAB> qubits [ 0 ], <TAB> <TAB> <TAB> <TAB> qubits [ 1 ], <TAB> <TAB> <TAB> ) <TAB> <TAB> elif self. _diag_angles_radians [ 2 ]!= 0 : <TAB> <TAB> <TAB> return formatter. format ( <TAB> <TAB> <TAB> <TAB> ""CPHASE10({0}) {1} {2}\n"", <TAB> <TAB> <TAB> <TAB> self. _diag_angles_radians [ 2 ], <TAB> <TAB> <TAB> <TAB> qubits [ 0 ], <TAB> <TAB> <TAB> <TAB> qubits [ 1 ], <TAB> <TAB> <TAB> ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> return formatter. format ( <TAB> <TAB> <TAB> <TAB> ""CPHASE({0})",False,self._diag_angles_radians[3] != 0,self.cphASE != 0,0.6663739085197449
|
||
|
2994,"def comment ( request, pk ) : <TAB> """"""Add new comment."""""" <TAB> scope = unit = get_object_or_404 ( Unit, pk = pk ) <TAB> component = unit. translation. component <TAB> if not request. user. has_perm ( ""comment.add"", unit. translation ) : <TAB> <TAB> raise PermissionDenied ( ) <TAB> form = CommentForm ( component. project, request. POST ) <TAB> if form. is_valid ( ) : <TAB> <TAB> <TAB> <TAB> if form. cleaned_data [ ""scope"" ] in ( ""global"", ""report"" ) : <TAB> <TAB> <TAB> scope = unit. source_unit <TAB> <TAB> <TAB> <TAB> Comment. objects. add ( scope, request, form. cleaned_data [ ""comment"" ] ) <TAB> <TAB> <TAB> <TAB> if form. cleaned_data [ ""scope"" ] == ""report"" : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> if scope. translated and not scope. readonly : <TAB> <TAB> <TAB> <TAB> <TAB> scope. translate ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> request. user, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> scope. target, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> STATE_FUZZY, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> change_action = Change. ACTION_MARKED_EDIT, <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> label = component. project. label_set. get_or_create ( <TAB> <TAB> <TAB> <TAB> <TAB> name = gettext_noop ( ""Source needs review"" ), defaults = { ""color"" : ""red"" } <TAB> <TAB> <TAB> <TAB> ) [ 0 ] <TAB> <TAB> <TAB> <TAB> scope. labels. add ( label ) <TAB> <TAB",False,component.has_template(),scope.labels,0.6517886519432068
|
||
|
2995,"def test_default_values_for_objects_are_valid ( self ) : <TAB> for _, member in inspect. getmembers ( objects ) : <TAB> <TAB> if inspect. isclass ( member ) and member. default_value is not None : <TAB> <TAB> <TAB> self. assertEqual ( <TAB> <TAB> <TAB> <TAB> member. normalize ( member. default_value ), member. default_value <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> type_error_message = ( <TAB> <TAB> <TAB> <TAB> ""Mismatched default value types for object class %s"" % member. __name__ <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. assertIsInstance ( <TAB> <TAB> <TAB> <TAB> <TAB> member. normalize ( member. default_value ), <TAB> <TAB> <TAB> <TAB> <TAB> python_utils. BASESTRING, <TAB> <TAB> <TAB> <TAB> <TAB> msg = type_error_message, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. assertIsInstance ( <TAB> <TAB> <TAB> <TAB> <TAB> member. normalize ( member. default_value ), <TAB> <TAB> <TAB> <TAB> <TAB> type ( member. default_value ), <TAB> <TAB> <TAB> <TAB> <TAB> msg = type_error_message, <TAB> <TAB> <TAB> <TAB> )",False,"isinstance(member.default_value, python_utils.BASESTRING)",inspect.isclass(member),0.6512900590896606
|
||
|
2996,"def extract_function_names ( <TAB> test_folder : Path, exclude_names : List [ str ] ) -> List [ str ] : <TAB> """"""Extract function names from the list of functions."""""" <TAB> function_names = [ ] <TAB> for name in test_folder. iterdir ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> function_names. append ( name. stem. split ( ""_"", 1 ) [ - 1 ]. strip ( ) ) <TAB> return function_names",False,"not name.is_dir() and path_does_not_contain(name, exclude_names)",name.stem.startswith(exclude_names),0.6481598019599915
|
||
|
2997,"def parse_msg_comment ( parse_state, msg_comment_list, string ) : <TAB> while string is not None : <TAB> <TAB> append ( msg_comment_list, parse_state. decode ( string ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return parse_quoted ( parse_state ) <TAB> <TAB> string = parse_quoted ( parse_state ) <TAB> return None",False,"find(string, '\\n') > -1",parse_state.value() == '',0.653272271156311
|
||
|
2998,"def get_line_changed_regions ( oldline, newline ) : <TAB> """"""Returns regions of changes between two similar lines."""""" <TAB> if oldline is None or newline is None : <TAB> <TAB> return None, None <TAB> <TAB> <TAB> differ = SequenceMatcher ( None, oldline, newline ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if differ. ratio ( ) < 0.6 : <TAB> <TAB> return None, None <TAB> oldchanges = [ ] <TAB> newchanges = [ ] <TAB> back = ( 0, 0 ) <TAB> for tag, i1, i2, j1, j2 in differ. get_opcodes ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if ( i2 - i1 < 3 ) or ( j2 - j1 < 3 ) : <TAB> <TAB> <TAB> <TAB> back = ( j2 - j1, i2 - i1 ) <TAB> <TAB> <TAB> continue <TAB> <TAB> oldstart, oldend = i1 - back [ 0 ], i2 <TAB> <TAB> newstart, newend = j1 - back [ 1 ], j2 <TAB> <TAB> if oldchanges and oldstart <= oldchanges [ - 1 ] [ 1 ] < oldend : <TAB> <TAB> <TAB> oldchanges [ - 1 ] = ( oldchanges [ - 1 ] [ 0 ], oldend ) <TAB> <TAB> elif not oldline [ oldstart : oldend ]. isspace ( ) : <TAB> <TAB> <TAB> oldchanges. append ( ( oldstart, oldend ) ) <TAB> <TAB> if newchanges and newstart <= newchanges [ - 1 ] [ 1 ] < newend : <TAB> <TAB> <TAB> newchanges [ - 1 ] = ( newchanges [ - 1 ] [ 0 ], newend ) <TAB> <TAB> elif not newline [ newstart : newend ]. isspace ( ) : <TAB> <TAB> <TAB> newchanges. append ( ( newstart, newend ) ) <TAB> <TAB> back = ( 0, 0 ) <TAB> return oldchanges, newchanges",False,tag == 'equal',tag == 'TAB',0.657238245010376
|
||
|
2999,"def validate ( self ) : <TAB> if self. data. get ( ""state"" ) == ""enabled"" : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise PolicyValidationError ( <TAB> <TAB> <TAB> <TAB> ( <TAB> <TAB> <TAB> <TAB> <TAB> ""redshift logging enablement requires `bucket` "" <TAB> <TAB> <TAB> <TAB> <TAB> ""and `prefix` specification on %s"" % ( self. manager. data, ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> return self",False,'bucket' not in self.data,not self.manager.bucket or not self.prefix,0.6614989042282104
|
||
|
3000,"def upgrade_properties ( self, lang = ""hive"", properties = None ) : <TAB> upgraded_properties = copy. deepcopy ( self. get_properties ( lang ) ) <TAB> <TAB> if ( <TAB> <TAB> not isinstance ( properties, list ) <TAB> <TAB> or not all ( isinstance ( prop, dict ) for prop in properties ) <TAB> <TAB> or not all ( ""key"" in prop for prop in properties ) <TAB> <TAB> or not all ( ""value"" in prop for prop in properties ) <TAB> ) : <TAB> <TAB> LOG. warn ( <TAB> <TAB> <TAB> ""Current properties are not formatted correctly, will replace with defaults."" <TAB> <TAB> ) <TAB> <TAB> return upgraded_properties <TAB> valid_props_dict = dict ( ( prop [ ""key"" ], prop ) for prop in upgraded_properties ) <TAB> curr_props_dict = dict ( ( prop [ ""key"" ], prop ) for prop in properties ) <TAB> <TAB> if set ( valid_props_dict. keys ( ) )!= set ( curr_props_dict. keys ( ) ) : <TAB> <TAB> settings = next ( <TAB> <TAB> <TAB> ( prop for prop in upgraded_properties if prop [ ""key"" ] == ""settings"" ), None <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> settings [ ""value"" ] = properties <TAB> else : <TAB> <TAB> upgraded_properties = properties <TAB> return upgraded_properties",False,"settings is not None and isinstance(properties, list)",settings,0.6471186280250549
|
||
|
3001,"def set_currentPlace ( self, uri, callback = None ) : <TAB> if self. _currentPlace_uri is not None : <TAB> <TAB> self. closePlace ( ) <TAB> if uri : <TAB> <TAB> self. _currentPlace_uri = uri <TAB> <TAB> self. _currentPlace_koFileEx = components. classes [ <TAB> <TAB> <TAB> ""@activestate.com/koFileEx;1"" <TAB> <TAB> ]. createInstance ( components. interfaces. koIFileEx ) <TAB> <TAB> self. _currentPlace_koFileEx. URI = uri <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> msg = ""set_currentPlace: URI %s doesn't exist"" % ( uri, ) <TAB> <TAB> <TAB> log. error ( ""%s"", msg ) <TAB> <TAB> <TAB> self. closePlace ( ) <TAB> <TAB> <TAB> if callback : <TAB> <TAB> <TAB> <TAB> callback. callback ( <TAB> <TAB> <TAB> <TAB> <TAB> components. interfaces. koIAsyncCallback. RESULT_ERROR, msg <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> return <TAB> <TAB> self. openPlace ( uri, callback )",False,not self._currentPlace_koFileEx.exists,not self.URI,0.6656754016876221
|
||
|
3002,"def _shift ( self ) : <TAB> self. compiled = """" <TAB> self. args. update ( { ""_t0"" : 0 } ) <TAB> new_ops = [ ] <TAB> for op in self. ops : <TAB> <TAB> new_op = [ op. qobj, None, None, op. type ] <TAB> <TAB> if op. type == ""func"" : <TAB> <TAB> <TAB> new_op [ 1 ] = _Shift ( op. get_coeff ) <TAB> <TAB> <TAB> new_op [ 2 ] = new_op [ 1 ] <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> new_op [ 2 ] = sub ( <TAB> <TAB> <TAB> <TAB> ""(?<=[^0-9a-zA-Z_])t(?=[^0-9a-zA-Z_])"", ""(t+_t0)"", "" "" + op. coeff + "" "" <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> new_op [ 1 ] = _StrWrapper ( new_op [ 2 ] ) <TAB> <TAB> elif op. type == ""array"" : <TAB> <TAB> <TAB> new_op [ 2 ] = _Shift ( op. get_coeff ) <TAB> <TAB> <TAB> new_op [ 1 ] = new_op [ 2 ] <TAB> <TAB> <TAB> new_op [ 3 ] = ""func"" <TAB> <TAB> <TAB> self. type = ""mixed_callable"" <TAB> <TAB> elif op. type == ""spline"" : <TAB> <TAB> <TAB> new_op [ 1 ] = _Shift ( op. get_coeff ) <TAB> <TAB> <TAB> new_op [ 2 ] = new_op [ 1 ] <TAB> <TAB> <TAB> new_op [ 3 ] = ""func"" <TAB> <TAB> <TAB> self. type = ""mixed_callable"" <TAB> <TAB> new_ops. append ( EvoElement. make ( new_op ) ) <TAB> self. ops = new_ops <TAB> return self",True,op.type == 'string',op.type == 'string',0.6544263362884521
|
||
|
3003,"def onMESSAGE ( self, hwnd, msg, wp, lp ) : <TAB> if msg == fw. WND_WM_NOTIFY : <TAB> <TAB> if wp == fw. WND_NM_MSGREFLECT : <TAB> <TAB> <TAB> msgr = fw. WND_MSGREFLECT. from_address ( lp ) <TAB> <TAB> <TAB> msgr. fReturn = self. _base_fMsgReflect <TAB> <TAB> <TAB> if msgr. msg == self. Msg. NM_RELEASEDCAPTURE : <TAB> <TAB> <TAB> <TAB> self. onMSG ( hwnd, ""releasedcapture"", 0, 0 ) <TAB> <TAB> <TAB> <TAB> return 0 <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> nmrb = NMREBAR. from_address ( msgr. lParam ) <TAB> <TAB> <TAB> <TAB> result = self. onMSG ( hwnd, ""begindrag"", ( nmrb. wID, nmrb. uBand ), 0 ) <TAB> <TAB> <TAB> <TAB> if result == False : <TAB> <TAB> <TAB> <TAB> <TAB> return 1 <TAB> <TAB> <TAB> <TAB> return 0 <TAB> <TAB> <TAB> return 0 <TAB> elif msg == self. Msg. WM_DESTROY : <TAB> <TAB> self. onMSG ( hwnd, ""destroy"", 0, 0 )",False,msgr.msg == self.Msg.RBN_BEGINDRAG,msg == fw.WND_NMREBAR,0.6540602445602417
|
||
|
3004,"def _makefiles ( self, f ) : <TAB> if isinstance ( f, dict ) : <TAB> <TAB> for k, v in list ( f. items ( ) ) : <TAB> <TAB> <TAB> if isinstance ( v, list ) : <TAB> <TAB> <TAB> <TAB> self. makedir ( dirname = k, content = v ) <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> self. make_file ( filename = k, content = v ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> raise ValueError ( ""Unexpected:"", k, v ) <TAB> elif isinstance ( f, str ) : <TAB> <TAB> self. _make_empty_file ( f ) <TAB> elif isinstance ( f, list ) : <TAB> <TAB> self. make_list ( f ) <TAB> else : <TAB> <TAB> raise ValueError ( ""Unknown type:"", f )",True,"isinstance(v, str)","isinstance(v, str)",0.6542247533798218
|
||
|
3005,"def handle ( self, * args, ** options ) : <TAB> self. verbosity = options [ ""verbosity"" ] <TAB> for document in Document. objects. filter ( correspondent__isnull = True ) : <TAB> <TAB> potential_correspondents = list ( Correspondent. match_all ( document. content ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> potential_count = len ( potential_correspondents ) <TAB> <TAB> correspondent = potential_correspondents [ 0 ] <TAB> <TAB> if potential_count > 1 : <TAB> <TAB> <TAB> if not options [ ""use_first"" ] : <TAB> <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> <TAB> self. TOO_MANY_SKIP. format ( potential_count, document ), <TAB> <TAB> <TAB> <TAB> <TAB> file = sys. stderr, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> self. TOO_MANY_CONTINUE. format ( potential_count, document, correspondent ), <TAB> <TAB> <TAB> <TAB> file = sys. stderr, <TAB> <TAB> <TAB> ) <TAB> <TAB> document. correspondent = correspondent <TAB> <TAB> document. save ( update_fields = ( ""correspondent"", ) ) <TAB> <TAB> print ( <TAB> <TAB> <TAB> self. CHANGE_MESSAGE. format ( <TAB> <TAB> <TAB> <TAB> document. pk, document. title, correspondent. pk, correspondent. name <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> file = sys. stderr, <TAB> <TAB> )",True,not potential_correspondents,not potential_correspondents,0.6692060828208923
|
||
|
3006,"def flask_debug_true ( context ) : <TAB> if context. is_module_imported_like ( ""flask"" ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if context. check_call_arg_value ( ""debug"", ""True"" ) : <TAB> <TAB> <TAB> <TAB> return bandit. Issue ( <TAB> <TAB> <TAB> <TAB> <TAB> severity = bandit. HIGH, <TAB> <TAB> <TAB> <TAB> <TAB> confidence = bandit. MEDIUM, <TAB> <TAB> <TAB> <TAB> <TAB> text = ""A Flask app appears to be run with debug=True, "" <TAB> <TAB> <TAB> <TAB> <TAB> ""which exposes the Werkzeug debugger and allows "" <TAB> <TAB> <TAB> <TAB> <TAB> ""the execution of arbitrary code."", <TAB> <TAB> <TAB> <TAB> <TAB> lineno = context. get_lineno_for_call_arg ( ""debug"" ), <TAB> <TAB> <TAB> <TAB> )",False,context.call_function_name_qual.endswith('.run'),"context.check_call_arg_is_string( ""debug"", ""True')",0.6473018527030945
|
||
|
3007,"def load_images ( n_batches = 10, sleep = 0.0 ) : <TAB> batch_size = 4 <TAB> astronaut = data. astronaut ( ) <TAB> astronaut = ia. imresize_single_image ( astronaut, ( 64, 64 ) ) <TAB> kps = ia. KeypointsOnImage ( [ ia. Keypoint ( x = 15, y = 25 ) ], shape = astronaut. shape ) <TAB> counter = 0 <TAB> for i in range ( n_batches ) : <TAB> <TAB> batch_images = [ ] <TAB> <TAB> batch_kps = [ ] <TAB> <TAB> for b in range ( batch_size ) : <TAB> <TAB> <TAB> astronaut_text = ia. draw_text ( <TAB> <TAB> <TAB> <TAB> astronaut, x = 0, y = 0, text = ""%d"" % ( counter, ), color = [ 0, 255, 0 ], size = 16 <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> batch_images. append ( astronaut_text ) <TAB> <TAB> <TAB> batch_kps. append ( kps ) <TAB> <TAB> <TAB> counter += 1 <TAB> <TAB> batch = ia. Batch ( <TAB> <TAB> <TAB> images = np. array ( batch_images, dtype = np. uint8 ), keypoints = batch_kps <TAB> <TAB> ) <TAB> <TAB> yield batch <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> time. sleep ( sleep )",False,sleep > 0,i == 0,0.6694655418395996
|
||
|
3008,"def execute ( cls, ctx, op : ""DataFrameCheckMonotonic"" ) : <TAB> in_data = ctx [ op. inputs [ 0 ]. key ] <TAB> if op. stage == OperandStage. map : <TAB> <TAB> is_mono = ( <TAB> <TAB> <TAB> in_data. is_monotonic_increasing <TAB> <TAB> <TAB> if not op. decreasing <TAB> <TAB> <TAB> else in_data. is_monotonic_decreasing <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> is_mono = in_data. is_unique <TAB> <TAB> if isinstance ( in_data, pd. Index ) : <TAB> <TAB> <TAB> edge_array = np. array ( [ in_data [ 0 ], in_data [ - 1 ] ] ) <TAB> <TAB> else : <TAB> <TAB> <TAB> edge_array = np. array ( [ in_data. iloc [ 0 ], in_data. iloc [ - 1 ] ] ) <TAB> <TAB> ctx [ op. outputs [ 0 ]. key ] = ( <TAB> <TAB> <TAB> np. array ( [ is_mono ] ), <TAB> <TAB> <TAB> edge_array, <TAB> <TAB> ) <TAB> else : <TAB> <TAB> in_series = pd. Series ( in_data [ 1 ] ) <TAB> <TAB> is_edge_mono = ( <TAB> <TAB> <TAB> in_series. is_monotonic_increasing <TAB> <TAB> <TAB> if not op. decreasing <TAB> <TAB> <TAB> else in_series. is_monotonic_decreasing <TAB> <TAB> ) <TAB> <TAB> if op. strict and is_edge_mono : <TAB> <TAB> <TAB> is_edge_mono = in_series. is_unique <TAB> <TAB> ctx [ op. outputs [ 0 ]. key ] = in_data [ 0 ]. all ( ) and is_edge_mono",True,op.strict and is_mono,op.strict and is_mono,0.6560088396072388
|
||
|
3009,"def __init__ ( <TAB> self, <TAB> repository, <TAB> key, <TAB> manifest, <TAB> name, <TAB> cache = None, <TAB> create = False, <TAB> checkpoint_interval = 300, <TAB> numeric_owner = False, ) : <TAB> self. cwd = os. getcwd ( ) <TAB> self. key = key <TAB> self. repository = repository <TAB> self. cache = cache <TAB> self. manifest = manifest <TAB> self. hard_links = { } <TAB> self. stats = Statistics ( ) <TAB> self. name = name <TAB> self. checkpoint_interval = checkpoint_interval <TAB> self. numeric_owner = numeric_owner <TAB> self. items_buffer = ChunkBuffer ( self. cache, self. key, self. stats ) <TAB> self. pipeline = DownloadPipeline ( self. repository, self. key ) <TAB> if create : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise self. AlreadyExists ( name ) <TAB> <TAB> self. last_checkpoint = time. time ( ) <TAB> <TAB> i = 0 <TAB> <TAB> while True : <TAB> <TAB> <TAB> self. checkpoint_name = ""%s.checkpoint%s"" % ( name, i and ( "".%d"" % i ) or """" ) <TAB> <TAB> <TAB> if not self. checkpoint_name in manifest. archives : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> i += 1 <TAB> else : <TAB> <TAB> if name not in self. manifest. archives : <TAB> <TAB> <TAB> raise self. DoesNotExist ( name ) <TAB> <TAB> info = self. manifest. archives [ name ] <TAB> <TAB> self. load ( info [ b""id"" ] )",False,name in manifest.archives,name in self.names,0.6576589941978455
|
||
|
3010,"def mock_as_dataset_base ( self, ** kwargs ) : <TAB> """"""Function which overwrite `builder.as_dataset`."""""" <TAB> <TAB> if tf. io. gfile. exists ( self. data_dir ) : <TAB> <TAB> logging. info ( ""Metadata found for %s at %s"", self. name, self. data_dir ) <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""TFDS has been mocked with `MockPolicy.USE_FILES`, but metadata "" <TAB> <TAB> <TAB> <TAB> f""files were not found in {self.data_dir}. "" <TAB> <TAB> <TAB> <TAB> ""You should copy the real metadata files, so that the dataset "" <TAB> <TAB> <TAB> <TAB> ""can be loaded properly, or set the data_dir kwarg of "" <TAB> <TAB> <TAB> <TAB> ""tfds.testing.mock_tfds(data_dir=...).\n"" <TAB> <TAB> <TAB> ) <TAB> <TAB> if policy == MockPolicy. AUTO : <TAB> <TAB> <TAB> logging. info ( <TAB> <TAB> <TAB> <TAB> ""Metadata NOT found for %s at %s. Will use `MockPolicy.USE_CODE.`"", <TAB> <TAB> <TAB> <TAB> self. name, <TAB> <TAB> <TAB> <TAB> self. data_dir, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> with test_utils. MockFs ( ) as fs : <TAB> <TAB> fs. add_file ( os. path. join ( self. data_dir, ""tmp.txt"" ) ) <TAB> <TAB> return original_as_dataset_fn ( self, ** kwargs )",False,policy == MockPolicy.USE_FILES,not tf.io.gfile.exists(self.data_dir),0.6643929481506348
|
||
|
3011,"def process_seekhead ( self, elem ) : <TAB> for seek_elem in self. process_one_level ( elem ) : <TAB> <TAB> if seek_elem. get_id ( )!= MATROSKA_SEEK_ID : <TAB> <TAB> <TAB> continue <TAB> <TAB> for sub_elem in self. process_one_level ( seek_elem ) : <TAB> <TAB> <TAB> if sub_elem. get_id ( ) == MATROSKA_SEEKID_ID : <TAB> <TAB> <TAB> <TAB> if sub_elem. get_value ( ) == MATROSKA_CLUSTER_ID : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> self. file. seek ( self. segment. offset + sub_elem. get_value ( ) ) <TAB> <TAB> <TAB> <TAB> buffer = self. file. read ( 100 ) <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> elem = EbmlEntity ( buffer ) <TAB> <TAB> <TAB> <TAB> except ParseError : <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> elem. add_data ( self. file. read ( elem. ebml_length ) ) <TAB> <TAB> <TAB> <TAB> self. process_elem ( elem )",False,sub_elem.get_id() == MATROSKA_SEEK_POSITION_ID,self.segment.seek_length > 0,0.6536352038383484
|
||
|
3012,"def main ( ) : <TAB> global_config = config [ ""Global"" ] <TAB> <TAB> post_process_class = build_post_process ( config [ ""PostProcess"" ], global_config ) <TAB> <TAB> model = build_model ( config [ ""Architecture"" ] ) <TAB> init_model ( config, model, logger ) <TAB> <TAB> transforms = [ ] <TAB> for op in config [ ""Eval"" ] [ ""dataset"" ] [ ""transforms"" ] : <TAB> <TAB> op_name = list ( op ) [ 0 ] <TAB> <TAB> if ""Label"" in op_name : <TAB> <TAB> <TAB> continue <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> op [ op_name ] [ ""keep_keys"" ] = [ ""image"" ] <TAB> <TAB> transforms. append ( op ) <TAB> global_config [ ""infer_mode"" ] = True <TAB> ops = create_operators ( transforms, global_config ) <TAB> model. eval ( ) <TAB> for file in get_image_file_list ( config [ ""Global"" ] [ ""infer_img"" ] ) : <TAB> <TAB> logger. info ( ""infer_img: {}"". format ( file ) ) <TAB> <TAB> with open ( file, ""rb"" ) as f : <TAB> <TAB> <TAB> img = f. read ( ) <TAB> <TAB> <TAB> data = { ""image"" : img } <TAB> <TAB> batch = transform ( data, ops ) <TAB> <TAB> images = np. expand_dims ( batch [ 0 ], axis = 0 ) <TAB> <TAB> images = paddle. to_tensor ( images ) <TAB> <TAB> preds = model ( images ) <TAB> <TAB> post_result = post_process_class ( preds ) <TAB> <TAB> for rec_reuslt in post_result : <TAB> <TAB> <TAB> logger. info ( ""\t result: {}"". format ( rec_reuslt ) ) <TAB> logger. info ( ""success!"" )",False,op_name == 'KeepKeys','keep_keys' in op_name,0.6550508141517639
|
||
|
3013,"def _macro_repl ( match ) : <TAB> macro_name = match. group ( 1 ) <TAB> if _is_conditional ( macro_name ) : <TAB> <TAB> parts = macro_name [ 1 : ]. split ( "":"" ) <TAB> <TAB> assert parts <TAB> <TAB> retv = """" <TAB> <TAB> if _test_conditional ( macro_name ) : <TAB> <TAB> <TAB> if _is_macro_defined ( parts [ 0 ] ) : <TAB> <TAB> <TAB> <TAB> if len ( parts ) == 2 : <TAB> <TAB> <TAB> <TAB> <TAB> retv = parts [ 1 ] <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> retv = _get_macro ( parts [ 0 ] ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> if len ( parts ) == 2 : <TAB> <TAB> <TAB> <TAB> <TAB> retv = parts [ 1 ] <TAB> <TAB> return retv <TAB> if _is_macro_defined ( macro_name ) : <TAB> <TAB> return _get_macro ( macro_name ) <TAB> return match. string [ match. start ( ) : match. end ( ) ]",False,not _is_macro_defined(parts[0]),len(parts) == 1,0.6512171626091003
|
||
|
3014,"def _find_all_variables ( transfer_variable ) : <TAB> d = { } <TAB> for _k, _v in transfer_variable. __dict__. items ( ) : <TAB> <TAB> if isinstance ( _v, Variable ) : <TAB> <TAB> <TAB> d [ _v. _name ] = _v <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> d. update ( _find_all_variables ( _v ) ) <TAB> return d",False,"isinstance(_v, BaseTransferVariables)","isinstance(_v, list)",0.663145899772644
|
||
|
3015,"def macro_expand_args ( self, macro, args ) : <TAB> <TAB> rep = [ copy. copy ( _x ) for _x in macro. value ] <TAB> <TAB> str_expansion = { } <TAB> for argnum, i in macro. str_patch : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> str_expansion [ argnum ] = ( <TAB> <TAB> <TAB> <TAB> '""%s""' % """". join ( [ x. value for x in args [ argnum ] ] ) <TAB> <TAB> <TAB> ). replace ( ""\\"", ""\\\\"" ) <TAB> <TAB> rep [ i ] = copy. copy ( rep [ i ] ) <TAB> <TAB> rep [ i ]. value = str_expansion [ argnum ] <TAB> <TAB> comma_patch = False <TAB> if macro. variadic and not args [ - 1 ] : <TAB> <TAB> for i in macro. var_comma_patch : <TAB> <TAB> <TAB> rep [ i ] = None <TAB> <TAB> <TAB> comma_patch = True <TAB> <TAB> <TAB> <TAB> expanded = { } <TAB> for ptype, argnum, i in macro. patch : <TAB> <TAB> <TAB> <TAB> if ptype == ""c"" : <TAB> <TAB> <TAB> rep [ i : i + 1 ] = args [ argnum ] <TAB> <TAB> <TAB> <TAB> elif ptype == ""e"" : <TAB> <TAB> <TAB> if argnum not in expanded : <TAB> <TAB> <TAB> <TAB> expanded [ argnum ] = self. expand_macros ( args [ argnum ] ) <TAB> <TAB> <TAB> rep [ i : i + 1 ] = expanded [ argnum ] <TAB> <TAB> if comma_patch : <TAB> <TAB> rep = [ _i for _i in rep if _i ] <TAB> return rep",False,argnum not in str_expansion,argnum in args,0.6647653579711914
|
||
|
3016,"def typeoffsetof ( self, BType, fieldname, num = 0 ) : <TAB> if isinstance ( fieldname, str ) : <TAB> <TAB> if num == 0 and issubclass ( BType, CTypesGenericPtr ) : <TAB> <TAB> <TAB> BType = BType. _BItem <TAB> <TAB> if not issubclass ( BType, CTypesBaseStructOrUnion ) : <TAB> <TAB> <TAB> raise TypeError ( ""expected a struct or union ctype"" ) <TAB> <TAB> BField = BType. _bfield_types [ fieldname ] <TAB> <TAB> if BField is Ellipsis : <TAB> <TAB> <TAB> raise TypeError ( ""not supported for bitfields"" ) <TAB> <TAB> return ( BField, BType. _offsetof ( fieldname ) ) <TAB> elif isinstance ( fieldname, ( int, long ) ) : <TAB> <TAB> if issubclass ( BType, CTypesGenericArray ) : <TAB> <TAB> <TAB> BType = BType. _CTPtr <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise TypeError ( ""expected an array or ptr ctype"" ) <TAB> <TAB> BItem = BType. _BItem <TAB> <TAB> offset = BItem. _get_size ( ) * fieldname <TAB> <TAB> if offset > sys. maxsize : <TAB> <TAB> <TAB> raise OverflowError <TAB> <TAB> return ( BItem, offset ) <TAB> else : <TAB> <TAB> raise TypeError ( type ( fieldname ) )",False,"not issubclass(BType, CTypesGenericPtr)","not isinstance(BType, CTypesBaseStructOrUnion)",0.6568522453308105
|
||
|
3017,"def __init__ ( self, * args, ** kwargs ) : <TAB> _kwargs = { <TAB> <TAB> ""max_length"" : 20, <TAB> <TAB> ""widget"" : forms. TextInput ( attrs = { ""autocomplete"" : ""off"" } ), <TAB> <TAB> ""label"" : _ ( ""Card number"" ), <TAB> } <TAB> if ""types"" in kwargs : <TAB> <TAB> self. accepted_cards = set ( kwargs. pop ( ""types"" ) ) <TAB> <TAB> difference = self. accepted_cards - VALID_CARDS <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ImproperlyConfigured ( <TAB> <TAB> <TAB> <TAB> ""The following accepted_cards are "" ""unknown: %s"" % difference <TAB> <TAB> <TAB> ) <TAB> _kwargs. update ( kwargs ) <TAB> super ( ). __init__ ( * args, ** _kwargs )",False,difference,difference < TAB > 0,0.681392252445221
|
||
|
3018,"def cal_pads ( auto_pad, pad_shape ) : <TAB> spatial_size = len ( pad_shape ) <TAB> pads = [ 0 ] * spatial_size * 2 <TAB> for i in range ( spatial_size ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> pads [ i + spatial_size ] = pad_shape [ i ] // 2 <TAB> <TAB> <TAB> pads [ i ] = pad_shape [ i ] - pads [ i + spatial_size ] <TAB> <TAB> elif auto_pad == ""SAME_UPPER"" : <TAB> <TAB> <TAB> pads [ i ] = pad_shape [ i ] // 2 <TAB> <TAB> <TAB> pads [ i + spatial_size ] = pad_shape [ i ] - pads [ i ] <TAB> return pads",False,auto_pad == 'SAME_LOWER',auto_pad == 'SAME_UPPER',0.6543803215026855
|
||
|
3019,"def check_pairwise_arrays ( X, Y, precomputed = False, dtype = None ) : <TAB> X, Y, dtype_float = PairwiseDistances. _return_float_dtype ( X, Y ) <TAB> estimator = ""check_pairwise_arrays"" <TAB> if dtype is None : <TAB> <TAB> dtype = dtype_float <TAB> if Y is X or Y is None : <TAB> <TAB> X = Y = check_array ( X, accept_sparse = True, dtype = dtype, estimator = estimator ) <TAB> else : <TAB> <TAB> X = check_array ( X, accept_sparse = True, dtype = dtype, estimator = estimator ) <TAB> <TAB> Y = check_array ( Y, accept_sparse = True, dtype = dtype, estimator = estimator ) <TAB> if precomputed : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""Precomputed metric requires shape "" <TAB> <TAB> <TAB> <TAB> f""(n_queries, n_indexed). Got ({X.shape[0]}, {X.shape[1]}) "" <TAB> <TAB> <TAB> <TAB> f""for {Y.shape[0]} indexed."" <TAB> <TAB> <TAB> ) <TAB> elif X. shape [ 1 ]!= Y. shape [ 1 ] : <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> ""Incompatible dimension for X and Y matrices: "" <TAB> <TAB> <TAB> f""X.shape[1] == {X.shape[1]} while Y.shape[1] == {Y.shape[1]}"" <TAB> <TAB> ) <TAB> return X, Y",False,X.shape[1] != Y.shape[0],Y.shape[0] != X.shape[0],0.658932626247406
|
||
|
3020,"def _check_imported_dataset ( <TAB> self, <TAB> history_id, <TAB> hid, <TAB> assert_ok = True, <TAB> has_job = True, <TAB> hda_checker = None, <TAB> job_checker = None, ) : <TAB> imported_dataset_metadata = self. dataset_populator. get_history_dataset_details ( <TAB> <TAB> history_id = history_id, <TAB> <TAB> hid = hid, <TAB> <TAB> assert_ok = assert_ok, <TAB> ) <TAB> assert imported_dataset_metadata [ ""history_content_type"" ] == ""dataset"" <TAB> assert imported_dataset_metadata [ ""history_id"" ] == history_id <TAB> if hda_checker is not None : <TAB> <TAB> hda_checker ( imported_dataset_metadata ) <TAB> assert ""creating_job"" in imported_dataset_metadata <TAB> job_id = imported_dataset_metadata [ ""creating_job"" ] <TAB> if has_job : <TAB> <TAB> assert job_id <TAB> <TAB> job_details = self. dataset_populator. get_job_details ( job_id, full = True ) <TAB> <TAB> assert job_details. status_code == 200, job_details. content <TAB> <TAB> job = job_details. json ( ) <TAB> <TAB> assert ""history_id"" in job, job <TAB> <TAB> assert job [ ""history_id"" ] == history_id, job <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> job_checker ( job )",True,job_checker is not None,job_checker is not None,0.6517950296401978
|
||
|
3021,"def login_prompt ( ) : <TAB> from hummingbot. client. config. security import Security <TAB> import time <TAB> err_msg = None <TAB> if Security. new_password_required ( ) : <TAB> <TAB> show_welcome ( ) <TAB> <TAB> password = input_dialog ( <TAB> <TAB> <TAB> title = ""Set Password"", <TAB> <TAB> <TAB> text = ""Create a password to protect your sensitive data. "" <TAB> <TAB> <TAB> ""This password is not shared with us nor with anyone else, so please store it securely."" <TAB> <TAB> <TAB> ""\n\nEnter your new password:"", <TAB> <TAB> <TAB> password = True, <TAB> <TAB> <TAB> style = dialog_style, <TAB> <TAB> ). run ( ) <TAB> <TAB> if password is None : <TAB> <TAB> <TAB> return False <TAB> <TAB> re_password = input_dialog ( <TAB> <TAB> <TAB> title = ""Set Password"", <TAB> <TAB> <TAB> text = ""Please re-enter your password:"", <TAB> <TAB> <TAB> password = True, <TAB> <TAB> <TAB> style = dialog_style, <TAB> <TAB> ). run ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return False <TAB> <TAB> if password!= re_password : <TAB> <TAB> <TAB> err_msg = ""Passwords entered do not match, please try again."" <TAB> <TAB> else : <TAB> <TAB> <TAB> Security. login ( password ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> dummy = f""{time.time()}"" <TAB> <TAB> <TAB> Security. update_secure_config ( ""default"", dummy ) <TAB> else : <TAB> <TAB> password = input_dialog ( <TAB> <TAB> <TAB> title = ""Welcome back to Hummingbot"", <TAB> <TAB> <TAB> text = ""Enter your password:"", <TAB> <TAB> <TAB> password = True, <",False,re_password is None,err_msg is None,0.6561622619628906
|
||
|
3022,"def run_cmd ( self, util, commands, ensure_point_visible = False ) : <TAB> for c in commands : <TAB> <TAB> if ""window_command"" in c : <TAB> <TAB> <TAB> util. run_window_command ( c [ ""window_command"" ], c [ ""args"" ] ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> util. run_command ( c [ ""command"" ], c [ ""args"" ] ) <TAB> if ensure_point_visible : <TAB> <TAB> util. ensure_visible ( sublime. Region ( util. get_point ( ) ) )",True,'command' in c,'command' in c,0.6702516078948975
|
||
|
3023,def __download_thread ( self ) : <TAB> while True : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. __current_download = self. __queue. get ( ) <TAB> <TAB> <TAB> self. __download_file ( self. __current_download ) <TAB> <TAB> time. sleep ( 0.1 ),False,not self.__queue.empty(),self.__queue.empty(),0.653109073638916
|
||
|
3024,"def delete_snapshot ( self, snapshot ) : <TAB> snap_name = self. _get_snap_name ( snapshot [ ""id"" ] ) <TAB> LOG. debug ( ""Deleting snapshot (%s)"", snapshot [ ""id"" ] ) <TAB> self. client_login ( ) <TAB> try : <TAB> <TAB> self. client. delete_snapshot ( snap_name, self. backend_type ) <TAB> except exception. DotHillRequestError as ex : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return <TAB> <TAB> LOG. exception ( ""Deleting snapshot %s failed"", snapshot [ ""id"" ] ) <TAB> <TAB> raise exception. Invalid ( ex ) <TAB> finally : <TAB> <TAB> self. client_logout ( )",False,'The volume was not found on this system.' in ex.args,ex.args[0] == 'NoSuchSnapshot',0.6501138210296631
|
||
|
3025,"def data ( self, data ) : <TAB> if data is None : <TAB> <TAB> raise Exception ( ""Data cannot be None"" ) <TAB> val = [ ] <TAB> for d in data : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> val. append ( bytes ( d, ""utf-8"" ) ) <TAB> <TAB> elif isinstance ( d, bytes ) : <TAB> <TAB> <TAB> val. append ( d ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise Exception ( <TAB> <TAB> <TAB> <TAB> ""Invalid type, data can only be an str or a bytes not {}: {}"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> type ( data ), d <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> self. __data = val",False,"isinstance(d, str)","isinstance(d, unicode)",0.6534943580627441
|
||
|
3026,"def _duplicate_sequences ( self, same ) : <TAB> sequences = [ ( n, n ) for n in same ] <TAB> queues = deque ( [ sequences ] ) <TAB> while queues : <TAB> <TAB> sequences = queues. popleft ( ) <TAB> <TAB> if self. _full_inclusive_sequences ( sequences ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> nexts = [ <TAB> <TAB> <TAB> ( s, n + 1 ) <TAB> <TAB> <TAB> for s, n in sequences <TAB> <TAB> <TAB> if n + 1 not in self. boundaries and n + 1 not in self. dup_starts <TAB> <TAB> ] <TAB> <TAB> nexts = sorted ( nexts, key = self. keyfunc ) <TAB> <TAB> full_duplicate_stopped = len ( nexts ) < len ( sequences ) <TAB> <TAB> for _, group in groupby ( nexts, self. keyfunc ) : <TAB> <TAB> <TAB> group = list ( group ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> queues. append ( group ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> full_duplicate_stopped = True <TAB> <TAB> if full_duplicate_stopped : <TAB> <TAB> <TAB> yield sequences",False,len(group) > 1,group,0.6520954966545105
|
||
|
3027,"def parse_para ( self, builder, text ) : <TAB> """"""Split a text into paragraphs and empty lines"""""" <TAB> if text. isspace ( ) : <TAB> <TAB> builder. text ( text ) <TAB> else : <TAB> <TAB> for block in empty_lines_re. split ( text ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> elif block. isspace ( ) : <TAB> <TAB> <TAB> <TAB> builder. text ( block ) <TAB> <TAB> <TAB> elif self. backward_indented_blocks and not unindented_line_re. search ( block ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> builder. append ( VERBATIM_BLOCK, None, block ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> block = convert_space_to_tab ( block ) <TAB> <TAB> <TAB> <TAB> builder. start ( PARAGRAPH ) <TAB> <TAB> <TAB> <TAB> self. list_and_indent_parser ( builder, block ) <TAB> <TAB> <TAB> <TAB> builder. end ( PARAGRAPH )",False,not block,block.isblock(()),0.679229736328125
|
||
|
3028,"def connected_registry_list_output_format ( result ) : <TAB> family_tree = { } <TAB> for reg in result : <TAB> <TAB> parent_id = _get_value ( reg, ""parent"", ""id"" ) <TAB> <TAB> parent_name = ( <TAB> <TAB> <TAB> """" if parent_id. isspace ( ) else parent_id. split ( ""/connectedRegistries/"" ) [ 1 ] <TAB> <TAB> ) <TAB> <TAB> family_tree [ _get_value ( reg, ""id"" ) ] = { <TAB> <TAB> <TAB> ""name"" : _get_value ( reg, ""name"" ), <TAB> <TAB> <TAB> ""id"" : _get_value ( reg, ""id"" ), <TAB> <TAB> <TAB> ""connectionState"" : _get_value ( reg, ""connectionState"" ), <TAB> <TAB> <TAB> ""parent_name"" : parent_name, <TAB> <TAB> <TAB> ""parent_id"" : parent_id, <TAB> <TAB> <TAB> ""loginServer_host"" : _get_value ( reg, ""loginServer"", ""host"" ), <TAB> <TAB> <TAB> ""parent_syncProperties_lastSyncTime"" : _get_value ( <TAB> <TAB> <TAB> <TAB> reg, ""parent"", ""syncProperties"", ""lastSyncTime"" <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> ""mode"" : _get_value ( reg, ""mode"" ), <TAB> <TAB> <TAB> ""childs"" : [ ], <TAB> <TAB> } <TAB> roots = [ ] <TAB> for reg in result : <TAB> <TAB> parent_id = _get_value ( reg, ""parent"", ""id"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> roots. append ( _get_value ( reg, ""id"" ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> family_tree [ parent_id ] [ ""childs"" ]. append ( _get_value ( reg, """,False,parent_id.isspace() or parent_id not in family_tree,parent_id == 0,0.6466551423072815
|
||
|
3029,"def kill_members ( members, sig, hosts = nodes ) : <TAB> for member in sorted ( members ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> if ha_tools_debug : <TAB> <TAB> <TAB> <TAB> print ( ""killing %s"" % member ) <TAB> <TAB> <TAB> proc = hosts [ member ] [ ""proc"" ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> os. kill ( proc. pid, signal. CTRL_C_EVENT ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> os. kill ( proc. pid, sig ) <TAB> <TAB> except OSError : <TAB> <TAB> <TAB> if ha_tools_debug : <TAB> <TAB> <TAB> <TAB> print ( ""%s already dead?"" % member )",False,"sys.platform in ('win32', 'cygwin')",sig == signal.CTRL_C_EVENT,0.6513755917549133
|
||
|
3030,"def test_factory ( self ) : <TAB> with pyomo. opt. ReaderFactory ( ""sol"" ) as reader : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise IOError ( ""Reader'sol' is not registered"" ) <TAB> <TAB> soln = reader ( currdir + ""test4_sol.sol"", suffixes = [ ""dual"" ] ) <TAB> <TAB> soln. write ( filename = currdir + ""factory.txt"", format = ""json"" ) <TAB> <TAB> self. assertMatchesJsonBaseline ( <TAB> <TAB> <TAB> currdir + ""factory.txt"", currdir + ""test4_sol.jsn"" <TAB> <TAB> )",False,reader is None,"currdir + ""test4_sol.sol' not in reader",0.6653777956962585
|
||
|
3031,"def cache_sqs_queues_across_accounts ( ) -> bool : <TAB> function : str = f""{__name__}.{sys._getframe().f_code.co_name}"" <TAB> <TAB> accounts_d : list = async_to_sync ( get_account_id_to_name_mapping ) ( ) <TAB> <TAB> for account_id in accounts_d. keys ( ) : <TAB> <TAB> if config. get ( ""environment"" ) == ""prod"" : <TAB> <TAB> <TAB> cache_sqs_queues_for_account. delay ( account_id ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> cache_sqs_queues_for_account. delay ( account_id ) <TAB> stats. count ( f""{function}.success"" ) <TAB> return True",False,"account_id in config.get('celery.test_account_ids', [])","config.get( ""environment"""") == 'local'",0.6497926712036133
|
||
|
3032,"def process_status ( self, info ) : <TAB> if not info. get ( ""_children"" ) : <TAB> <TAB> return False <TAB> notification = info [ ""_children"" ] [ 0 ] <TAB> title = notification. get ( ""title"" ) <TAB> if not title : <TAB> <TAB> return False <TAB> <TAB> if SCAN_COMPLETE_REGEX. match ( title ) : <TAB> <TAB> self. emit_notification ( ""%s.scanner.finished"" % self. name ) <TAB> <TAB> return True <TAB> <TAB> match = SCANNING_REGEX. match ( title ) <TAB> if match : <TAB> <TAB> section = match. group ( ""section"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. emit_notification ( <TAB> <TAB> <TAB> <TAB> ""%s.scanner.started"" % self. name, { ""section"" : section } <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> return True <TAB> return False",True,section,section,0.678980827331543
|
||
|
3033,"def fit_one ( self, x ) : <TAB> for i, xi in x. items ( ) : <TAB> <TAB> if self. with_centering : <TAB> <TAB> <TAB> self. median [ i ]. update ( xi ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. iqr [ i ]. update ( xi ) <TAB> return self",False,self.with_scaling,self.with_iqr,0.6624505519866943
|
||
|
3034,"def test_dynamic_segment ( self ) : <TAB> """"""Test that the degenerate case for the dynamic segment does not crash"""""" <TAB> with open ( <TAB> <TAB> os. path. join ( ""test"", ""testfiles_for_unittests"", ""debug_info.elf"" ), ""rb"" <TAB> ) as f : <TAB> <TAB> elf = ELFFile ( f ) <TAB> <TAB> seen_dynamic_segment = False <TAB> <TAB> for segment in elf. iter_segments ( ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. assertEqual ( <TAB> <TAB> <TAB> <TAB> <TAB> segment. num_tags ( ), <TAB> <TAB> <TAB> <TAB> <TAB> 0, <TAB> <TAB> <TAB> <TAB> <TAB> ""The dynamic segment in this file should be empty"", <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> seen_dynamic_segment = True <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> self. assertTrue ( <TAB> <TAB> <TAB> seen_dynamic_segment, ""There should be a dynamic segment in this file"" <TAB> <TAB> )",False,segment.header.p_type == 'PT_DYNAMIC',not seen_dynamic_segment,0.6501194834709167
|
||
|
3035,"def tearDown ( self ) : <TAB> os. chdir ( self. orig_working_dir ) <TAB> sys. argv = self. orig_argv <TAB> sys. stdout = self. orig_stdout <TAB> sys. stderr = self. orig_stderr <TAB> for dirname in [ ""lv_LV"", ""ja_JP"" ] : <TAB> <TAB> locale_dir = os. path. join ( self. datadir, ""project"", ""i18n"", dirname ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> shutil. rmtree ( locale_dir )",False,os.path.isdir(locale_dir),os.path.exists(locale_dir),0.6469252109527588
|
||
|
3036,"def _check_for_batch_clashes ( xs ) : <TAB> """"""Check that batch names do not overlap with sample names."""""" <TAB> names = set ( [ x [ ""description"" ] for x in xs ] ) <TAB> dups = set ( [ ] ) <TAB> for x in xs : <TAB> <TAB> batches = tz. get_in ( ( ""metadata"", ""batch"" ), x ) <TAB> <TAB> if batches : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> batches = [ batches ] <TAB> <TAB> <TAB> for batch in batches : <TAB> <TAB> <TAB> <TAB> if batch in names : <TAB> <TAB> <TAB> <TAB> <TAB> dups. add ( batch ) <TAB> if len ( dups ) > 0 : <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> ""Batch names must be unique from sample descriptions.\n"" <TAB> <TAB> <TAB> ""Clashing batch names: %s"" % sorted ( list ( dups ) ) <TAB> <TAB> )",False,"not isinstance(batches, (list, tuple))",len(names) > 0,0.652149498462677
|
||
|
3037,"def open ( self ) -> ""KeyValueDb"" : <TAB> """"""Create a new data base or open existing one"""""" <TAB> if os. path. exists ( self. _name ) : <TAB> <TAB> if not os. path. isfile ( self. _name ) : <TAB> <TAB> <TAB> raise IOError ( ""%s exists and is not a file"" % self. _name ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return self <TAB> <TAB> with open ( self. _name, ""rb"" ) as _in : <TAB> <TAB> <TAB> self. set_records ( pickle. load ( _in ) ) <TAB> else : <TAB> <TAB> <TAB> <TAB> mkpath ( os. path. dirname ( self. _name ) ) <TAB> <TAB> self. commit ( ) <TAB> return self",False,os.path.getsize(self._name) == 0,not self._name,0.6539309024810791
|
||
|
3038,"def handle_1_roomid_raffle ( self, i ) : <TAB> if i [ 1 ] in [ ""handle_1_room_TV"", ""handle_1_room_captain"" ] : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> await self. notify ( ""post_watching_history"", i [ 0 ] ) <TAB> <TAB> <TAB> await self. notify ( i [ 1 ], i [ 0 ], i [ 2 ] ) <TAB> else : <TAB> <TAB> print ( ""hhjjkskddrsfvsfdfvdfvvfdvdvdfdfffdfsvh"", i )",False,"await self.notify('check_if_normal_room', i[0], -1)",i[0] == 'number',0.6524509191513062
|
||
|
3039,"def prepare_request ( next_link = None ) : <TAB> <TAB> header_parameters = { } <TAB> header_parameters [ ""Accept"" ] = self. _serialize. header ( ""accept"", accept, ""str"" ) <TAB> if not next_link : <TAB> <TAB> <TAB> <TAB> url = self. list. metadata [ ""url"" ] <TAB> <TAB> path_format_arguments = { <TAB> <TAB> <TAB> ""subscriptionId"" : self. _serialize. url ( <TAB> <TAB> <TAB> <TAB> ""self._config.subscription_id"", self. _config. subscription_id, ""str"" <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> ""resourceGroupName"" : self. _serialize. url ( <TAB> <TAB> <TAB> <TAB> ""resource_group_name"", resource_group_name, ""str"", min_length = 1 <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> ""registryName"" : self. _serialize. url ( <TAB> <TAB> <TAB> <TAB> ""registry_name"", <TAB> <TAB> <TAB> <TAB> registry_name, <TAB> <TAB> <TAB> <TAB> ""str"", <TAB> <TAB> <TAB> <TAB> max_length = 50, <TAB> <TAB> <TAB> <TAB> min_length = 5, <TAB> <TAB> <TAB> <TAB> pattern = r""^[a-zA-Z0-9]*$"", <TAB> <TAB> <TAB> ), <TAB> <TAB> } <TAB> <TAB> url = self. _client. format_url ( url, ** path_format_arguments ) <TAB> <TAB> <TAB> <TAB> query_parameters = { } <TAB> <TAB> query_parameters [ ""api-version"" ] = self. _serialize. query ( <TAB> <TAB> <TAB> ""api_version"", api_version, ""str"" <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> query_parameters [ ""$filter"" ] = self",False,filter is not None,self._config.get_property('$filter') is not None,0.6617841720581055
|
||
|
3040,"def addEntryPoint ( self, va ) : <TAB> node = self. getNode ( va ) <TAB> if node is not None : <TAB> <TAB> return node <TAB> <TAB> enode = self. getCodeBlockNode ( va ) <TAB> done = set ( ) <TAB> todo = [ <TAB> <TAB> va, <TAB> ] <TAB> while todo : <TAB> <TAB> va = todo. pop ( ) <TAB> <TAB> if va in done : <TAB> <TAB> <TAB> continue <TAB> <TAB> done. add ( va ) <TAB> <TAB> branches = self. _getCodeBranches ( va ) <TAB> <TAB> tdone = set ( ) <TAB> <TAB> for tova, bflags in branches : <TAB> <TAB> <TAB> if tova in tdone : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> tdone. add ( tova ) <TAB> <TAB> <TAB> node = self. getNodeByVa ( va ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> todo. append ( tova ) <TAB> return enode",False,"self._addCodeBranch(node, va, tova, bflags)",node in todo,0.6505327224731445
|
||
|
3041,"def SaveAllChangedConfigs ( self ) : <TAB> ""Save configuration changes to the user config file."" <TAB> idleConf. userCfg [ ""main"" ]. Save ( ) <TAB> for configType in self. changedItems : <TAB> <TAB> cfgTypeHasChanges = False <TAB> <TAB> for section in self. changedItems [ configType ] : <TAB> <TAB> <TAB> if section == ""HelpFiles"" : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> idleConf. userCfg [ ""main"" ]. remove_section ( ""HelpFiles"" ) <TAB> <TAB> <TAB> <TAB> cfgTypeHasChanges = True <TAB> <TAB> <TAB> for item in self. changedItems [ configType ] [ section ] : <TAB> <TAB> <TAB> <TAB> value = self. changedItems [ configType ] [ section ] [ item ] <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> cfgTypeHasChanges = True <TAB> <TAB> if cfgTypeHasChanges : <TAB> <TAB> <TAB> idleConf. userCfg [ configType ]. Save ( ) <TAB> for configType in [ ""keys"", ""highlight"" ] : <TAB> <TAB> <TAB> <TAB> idleConf. userCfg [ configType ]. Save ( ) <TAB> self. ResetChangedItems ( ) <TAB> self. save_all_changed_extensions ( )",False,"self.SetUserValue(configType, section, item, value)",cfgTypeHasChanges,0.6455776691436768
|
||
|
3042,"def _reduce_batch_count_l_moments ( x ) : <TAB> result = tf_utils. reduce_batch_count_l_moments ( <TAB> <TAB> x, reduce_instance_dims = reduce_instance_dims <TAB> ) <TAB> for tensor in result : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. assertEqual ( x. get_shape ( ) [ 1 : ]. as_list ( ), tensor. get_shape ( ). as_list ( ) ) <TAB> return result",False,not reduce_instance_dims and x.get_shape().ndims,tensor.is_list(),0.6523606777191162
|
||
|
3043,"def process_xml_data ( ) : <TAB> while True : <TAB> <TAB> info_msg = ""SOAP/XML data found in POST data."" <TAB> <TAB> if not menu. options. batch : <TAB> <TAB> <TAB> question_msg = info_msg <TAB> <TAB> <TAB> question_msg += "" Do you want to process it? [Y/n] > "" <TAB> <TAB> <TAB> xml_process = _input ( settings. print_question_msg ( question_msg ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if settings. VERBOSITY_LEVEL >= 1 : <TAB> <TAB> <TAB> <TAB> print ( settings. print_bold_info_msg ( info_msg ) ) <TAB> <TAB> <TAB> xml_process = """" <TAB> <TAB> if len ( xml_process ) == 0 : <TAB> <TAB> <TAB> xml_process = ""Y"" <TAB> <TAB> if xml_process in settings. CHOICE_YES : <TAB> <TAB> <TAB> settings. IS_XML = True <TAB> <TAB> <TAB> break <TAB> <TAB> elif xml_process in settings. CHOICE_NO : <TAB> <TAB> <TAB> break <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> raise SystemExit ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> err_msg = ""'"" + xml_process + ""' is not a valid answer."" <TAB> <TAB> <TAB> print ( settings. print_error_msg ( err_msg ) ) <TAB> <TAB> <TAB> pass",False,xml_process in settings.CHOICE_QUIT,xml_process in settings.CHOICE_YES or xml_process in settings.CHOICE_NO,0.657004714012146
|
||
|
3044,"def do_GET ( self ) : <TAB> """"""Serve a GET request."""""" <TAB> f, start_range, end_range = self. send_head ( ) <TAB> if f : <TAB> <TAB> f. seek ( start_range, 0 ) <TAB> <TAB> chunk = 0x1000 <TAB> <TAB> total = 0 <TAB> <TAB> while chunk > 0 : <TAB> <TAB> <TAB> if start_range + chunk > end_range : <TAB> <TAB> <TAB> <TAB> chunk = end_range - start_range <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> self. wfile. write ( f. read ( chunk ) ) <TAB> <TAB> <TAB> except : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> total += chunk <TAB> <TAB> <TAB> start_range += chunk <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if self. report_download ( self. client_address ) : <TAB> <TAB> <TAB> <TAB> self. close_connection = 1 <TAB> <TAB> f. close ( )",False,f.tell() == monkeyfs.getsize(self.filename),start_range > end_range,0.6491347551345825
|
||
|
3045,"def update_model_id_version ( self, model_id = None, model_version = None ) : <TAB> if int ( self. job_runtime_conf. get ( ""dsl_version"", 1 ) ) == 2 : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. job_runtime_conf [ ""job_parameters"" ]. get ( ""common"", { } ) [ <TAB> <TAB> <TAB> <TAB> ""model_id"" <TAB> <TAB> <TAB> ] = model_id <TAB> <TAB> if model_version : <TAB> <TAB> <TAB> self. job_runtime_conf [ ""job_parameters"" ]. get ( ""common"", { } ) [ <TAB> <TAB> <TAB> <TAB> ""model_version"" <TAB> <TAB> <TAB> ] = model_version <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. job_runtime_conf [ ""job_parameters"" ] [ ""model_id"" ] = model_id <TAB> <TAB> if model_version : <TAB> <TAB> <TAB> self. job_runtime_conf [ ""job_parameters"" ] [ ""model_version"" ] = model_version <TAB> return self. job_runtime_conf",True,model_id,model_id,0.6701012849807739
|
||
|
3046,"def default ( cls, connection = None ) : <TAB> """"""show the default connection, or make CONNECTION the default"""""" <TAB> if connection is not None : <TAB> <TAB> target = cls. _get_config_filename ( connection ) <TAB> <TAB> if os. path. exists ( target ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> os. remove ( cls. _default_symlink ) <TAB> <TAB> <TAB> os. symlink ( target, cls. _default_symlink ) <TAB> <TAB> else : <TAB> <TAB> <TAB> cls. _no_config_file_error ( target ) <TAB> if<mask> : <TAB> <TAB> print ( ""Default connection is "" + cls. _default_connection ( ) ) <TAB> else : <TAB> <TAB> print ( ""There is no default connection set"" )",False,os.path.exists(cls._default_symlink),os.path.isfile(cls._default_symlink),0.651073694229126
|
||
|
3047,"def DeleteEmptyCols ( self ) : <TAB> cols2delete = [ ] <TAB> for c in range ( 0, self. GetCols ( ) ) : <TAB> <TAB> f = True <TAB> <TAB> for r in range ( 0, self. GetRows ( ) ) : <TAB> <TAB> <TAB> if self. FindItemAtPosition ( ( r, c ) ) is not None : <TAB> <TAB> <TAB> <TAB> f = False <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> cols2delete. append ( c ) <TAB> for i in range ( 0, len ( cols2delete ) ) : <TAB> <TAB> self. ShiftColsLeft ( cols2delete [ i ] + 1 ) <TAB> <TAB> cols2delete = [ x - 1 for x in cols2delete ]",True,f,f,0.6925818920135498
|
||
|
3048,"def coverage_zuul ( conf_zuul ) : <TAB> data = get_yaml ( ""{0}{1}{2}"". format ( BASE_URL, PATH_INFRA, conf_zuul ) ) <TAB> <TAB> bandit_jobs = { } <TAB> bandit_tests = { key : set ( ) for key in TEST_TYPES } <TAB> for job in data [ ""jobs"" ] : <TAB> <TAB> if ""bandit"" in job [ ""name"" ] : <TAB> <TAB> <TAB> if job. get ( ""voting"", True ) is False : <TAB> <TAB> <TAB> <TAB> bandit_jobs [ job [ ""name"" ] ] = False <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> bandit_jobs [ job [ ""name"" ] ] = True <TAB> for project in data [ ""projects"" ] : <TAB> <TAB> project_name = project [ ""name"" ] <TAB> <TAB> for test_type in bandit_tests. keys ( ) : <TAB> <TAB> <TAB> for test in project. get ( test_type, [ ] ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> voting = bandit_jobs. get ( test, False ) <TAB> <TAB> <TAB> <TAB> <TAB> bandit_tests [ test_type ]. add ( ( project_name, voting ) ) <TAB> <TAB> for test_type in bandit_tests : <TAB> <TAB> print ( <TAB> <TAB> <TAB> ""\n{0} tests exist for the following OpenStack projects:"". format ( <TAB> <TAB> <TAB> <TAB> test_type. capitalize ( ) <TAB> <TAB> <TAB> ) <TAB> <TAB> ) <TAB> <TAB> for project in sorted ( bandit_tests [ test_type ] ) : <TAB> <TAB> <TAB> if project [ 1 ] is False : <TAB> <TAB> <TAB> <TAB> print ( "" - {0}"". format ( project [ 0 ] ) ) <TAB",False,str(test).endswith('bandit'),test_type in bandit_jobs,0.6527649164199829
|
||
|
3049,"def explode_contact_groups_into_contacts ( self, item, contactgroups ) : <TAB> if hasattr ( item, ""contact_groups"" ) : <TAB> <TAB> <TAB> <TAB> if isinstance ( item. contact_groups, list ) : <TAB> <TAB> <TAB> cgnames = item. contact_groups <TAB> <TAB> else : <TAB> <TAB> <TAB> cgnames = item. contact_groups. split ( "","" ) <TAB> <TAB> cgnames = strip_and_uniq ( cgnames ) <TAB> <TAB> for cgname in cgnames : <TAB> <TAB> <TAB> cg = contactgroups. find_by_name ( cgname ) <TAB> <TAB> <TAB> if cg is None : <TAB> <TAB> <TAB> <TAB> err = ( <TAB> <TAB> <TAB> <TAB> <TAB> ""The contact group '%s' defined on the %s '%s' do "" <TAB> <TAB> <TAB> <TAB> <TAB> ""not exist"" % ( cgname, item. __class__. my_type, item. get_name ( ) ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> item. configuration_errors. append ( err ) <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> cnames = contactgroups. get_members_by_name ( cgname ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if cnames!= [ ] : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> item. contacts. extend ( cnames ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> item. contacts = cnames",False,"hasattr(item, 'contacts')",item.contacts,0.6532468199729919
|
||
|
3050,"def decorated_function ( * args, ** kwargs ) : <TAB> rv = f ( * args, ** kwargs ) <TAB> if ""Last-Modified"" not in rv. headers : <TAB> <TAB> try : <TAB> <TAB> <TAB> result = date <TAB> <TAB> <TAB> if callable ( result ) : <TAB> <TAB> <TAB> <TAB> result = result ( rv ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> from werkzeug. http import http_date <TAB> <TAB> <TAB> <TAB> result = http_date ( result ) <TAB> <TAB> <TAB> if result : <TAB> <TAB> <TAB> <TAB> rv. headers [ ""Last-Modified"" ] = result <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> logging. getLogger ( __name__ ). exception ( <TAB> <TAB> <TAB> <TAB> ""Error while calculating the lastmodified value for response {!r}"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> rv <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> return rv",False,"not isinstance(result, basestring)",not result,0.6563360691070557
|
||
|
3051,"def database_app ( request ) : <TAB> if request. param == ""postgres_app"" : <TAB> <TAB> if not which ( ""initdb"" ) : <TAB> <TAB> <TAB> pytest. skip ( ""initdb must be on PATH for postgresql fixture"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> pytest. skip ( ""psycopg2 must be installed for postgresql fixture"" ) <TAB> if request. param == ""sqlite_rabbitmq_app"" : <TAB> <TAB> if not os. environ. get ( ""GALAXY_TEST_AMQP_INTERNAL_CONNECTION"" ) : <TAB> <TAB> <TAB> pytest. skip ( <TAB> <TAB> <TAB> <TAB> ""rabbitmq tests will be skipped if GALAXY_TEST_AMQP_INTERNAL_CONNECTION env var is unset"" <TAB> <TAB> <TAB> ) <TAB> return request. getfixturevalue ( request. param )",False,not psycopg2,which(psycopg2),0.6733962297439575
|
||
|
3052,"def _create_html_files ( self, defects ) : <TAB> sources = { } <TAB> defects = [ defect for defect in defects if ""file"" in defect ] <TAB> for defect in defects : <TAB> <TAB> name = defect [ ""file"" ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> sources [ name ] = [ defect ] <TAB> <TAB> else : <TAB> <TAB> <TAB> sources [ name ]. append ( defect ) <TAB> files = { } <TAB> css_style_defs = None <TAB> bpath = self. generator. path. get_bld ( ). abspath ( ) <TAB> names = list ( sources. keys ( ) ) <TAB> for i in range ( 0, len ( names ) ) : <TAB> <TAB> name = names [ i ] <TAB> <TAB> if self. env. CPPCHECK_SINGLE_HTML : <TAB> <TAB> <TAB> htmlfile = ""cppcheck/%i.html"" % ( i ) <TAB> <TAB> else : <TAB> <TAB> <TAB> htmlfile = ""cppcheck/%s%i.html"" % ( self. generator. get_name ( ), i ) <TAB> <TAB> errors = sources [ name ] <TAB> <TAB> files [ name ] = { ""htmlfile"" : ""%s/%s"" % ( bpath, htmlfile ), ""errors"" : errors } <TAB> <TAB> css_style_defs = self. _create_html_file ( name, htmlfile, errors ) <TAB> return files, css_style_defs",False,not name in sources,name not in sources,0.6687008142471313
|
||
|
3053,"def avgpp ( cp, size ) : <TAB> _check_params ( len ( cp ), size ) <TAB> sample_count = _sample_count ( cp, size ) <TAB> prevextremevalid = False <TAB> prevextreme = None <TAB> avg = 0 <TAB> nextreme = 0 <TAB> prevval = getsample ( cp, size, 0 ) <TAB> val = getsample ( cp, size, 1 ) <TAB> prevdiff = val - prevval <TAB> for i in range ( 1, sample_count ) : <TAB> <TAB> val = getsample ( cp, size, i ) <TAB> <TAB> diff = val - prevval <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if prevextremevalid : <TAB> <TAB> <TAB> <TAB> avg += abs ( prevval - prevextreme ) <TAB> <TAB> <TAB> <TAB> nextreme += 1 <TAB> <TAB> <TAB> prevextremevalid = True <TAB> <TAB> <TAB> prevextreme = prevval <TAB> <TAB> prevval = val <TAB> <TAB> if diff!= 0 : <TAB> <TAB> <TAB> prevdiff = diff <TAB> if nextreme == 0 : <TAB> <TAB> return 0 <TAB> return avg / nextreme",False,diff * prevdiff < 0,diff != 0,0.6591594815254211
|
||
|
3054,"def testFormatFileInPlace ( self ) : <TAB> unformatted_code = u""True==False\n"" <TAB> formatted_code = u""True == False\n"" <TAB> with utils. TempFileContents ( self. test_tmpdir, unformatted_code ) as filepath : <TAB> <TAB> result, _, _ = yapf_api. FormatFile ( filepath, in_place = True ) <TAB> <TAB> self. assertEqual ( result, None ) <TAB> <TAB> with open ( filepath ) as fd : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. assertCodeEqual ( formatted_code, fd. read ( ). decode ( ""ascii"" ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. assertCodeEqual ( formatted_code, fd. read ( ) ) <TAB> <TAB> self. assertRaises ( <TAB> <TAB> <TAB> ValueError, yapf_api. FormatFile, filepath, in_place = True, print_diff = True <TAB> <TAB> )",False,sys.version_info[0] <= 2,formatted_code is None,0.650470495223999
|
||
|
3055,"def _FindSolution ( self, state, seen_states ) : <TAB> """"""Find a sequence of assignments that would solve the given state."""""" <TAB> if state. pos. condition : <TAB> <TAB> state. goals. add ( state. pos. condition ) <TAB> Solver. _goals_per_find_metric. add ( len ( state. goals ) ) <TAB> for removed_goals, new_goals in state. RemoveFinishedGoals ( ) : <TAB> <TAB> assert not state. pos. bindings & new_goals <TAB> <TAB> if _GoalsConflict ( removed_goals ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> if not new_goals : <TAB> <TAB> <TAB> return True <TAB> <TAB> blocked = frozenset ( ). union ( * ( goal. variable. nodes for goal in new_goals ) ) <TAB> <TAB> new_positions = set ( ) <TAB> <TAB> for goal in new_goals : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for origin in goal. origins : <TAB> <TAB> <TAB> <TAB> path_exist, path = self. _path_finder. FindNodeBackwards ( <TAB> <TAB> <TAB> <TAB> <TAB> state. pos, origin. where, blocked <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> if path_exist : <TAB> <TAB> <TAB> <TAB> <TAB> where = origin. where <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for node in path : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> where = node <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> <TAB> new_positions. add ( where ) <TAB> <TAB> for new_pos in new_positions : <TAB> <TAB>",False,node is not state.pos,node,0.6551216840744019
|
||
|
3056,"def create_tmp_file_from_contents ( rname, data, ftype = ""yaml"" ) : <TAB> """"""create a file in tmp with name and contents"""""" <TAB> tmp = Utils. create_tmpfile ( prefix = rname ) <TAB> if ftype == ""yaml"" : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> Utils. _write ( tmp, yaml. dump ( data, Dumper = yaml. RoundTripDumper ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> Utils. _write ( tmp, yaml. safe_dump ( data, default_flow_style = False ) ) <TAB> elif ftype == ""json"" : <TAB> <TAB> Utils. _write ( tmp, json. dumps ( data ) ) <TAB> else : <TAB> <TAB> Utils. _write ( tmp, data ) <TAB> <TAB> atexit. register ( Utils. cleanup, [ tmp ] ) <TAB> return tmp",False,"hasattr(yaml, 'RoundTripDumper')","hasattr(yaml, 'dumps')",0.6580820083618164
|
||
|
3057,"def _translate_ocsp_query ( cert_path, ocsp_output, ocsp_errors ) : <TAB> """"""Parse openssl's weird output to work out what it means."""""" <TAB> states = ( ""good"", ""revoked"", ""unknown"" ) <TAB> patterns = [ r""{0}: (WARNING.*)?{1}"". format ( cert_path, s ) for s in states ] <TAB> good, revoked, unknown = ( <TAB> <TAB> re. search ( p, ocsp_output, flags = re. DOTALL ) for p in patterns <TAB> ) <TAB> warning = good. group ( 1 ) if good else None <TAB> if ( ""Response verify OK"" not in ocsp_errors ) or ( good and warning ) or unknown : <TAB> <TAB> logger. info ( ""Revocation status for %s is unknown"", cert_path ) <TAB> <TAB> logger. debug ( ""Uncertain output:\n%s\nstderr:\n%s"", ocsp_output, ocsp_errors ) <TAB> <TAB> return False <TAB> elif good and not warning : <TAB> <TAB> return False <TAB> elif revoked : <TAB> <TAB> warning = revoked. group ( 1 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> logger. info ( ""OCSP revocation warning: %s"", warning ) <TAB> <TAB> return True <TAB> else : <TAB> <TAB> logger. warning ( <TAB> <TAB> <TAB> ""Unable to properly parse OCSP output: %s\nstderr:%s"", <TAB> <TAB> <TAB> ocsp_output, <TAB> <TAB> <TAB> ocsp_errors, <TAB> <TAB> ) <TAB> <TAB> return False",True,warning,warning,0.6974195241928101
|
||
|
3058,"def expectation_kwarg_dict_to_ge_kwargs ( self, kwarg_dict ) : <TAB> <TAB> <TAB> ancillary_kwargs = [ ""min_max_type"" ] <TAB> expectation_kwargs = { } <TAB> for kwarg_name, widget_dict in kwarg_dict. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> expectation_kwargs [ ""column"" ] = widget_dict <TAB> <TAB> <TAB> continue <TAB> <TAB> if kwarg_name in ancillary_kwargs : <TAB> <TAB> <TAB> continue <TAB> <TAB> elif not hasattr ( <TAB> <TAB> <TAB> self, ""generate_{kwarg_name}_widget_dict"". format ( kwarg_name = kwarg_name ) <TAB> <TAB> ) : <TAB> <TAB> <TAB> expectation_kwargs [ kwarg_name ] = widget_dict. get ( ""ge_kwarg_value"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> expectation_kwargs [ kwarg_name ] = ( <TAB> <TAB> <TAB> <TAB> widget_dict. get ( ""ge_kwarg_value"" ) <TAB> <TAB> <TAB> <TAB> if ""ge_kwarg_value"" in widget_dict <TAB> <TAB> <TAB> <TAB> else widget_dict [ ""kwarg_widget"" ]. value <TAB> <TAB> <TAB> ) <TAB> return expectation_kwargs",True,kwarg_name == 'column',kwarg_name == 'column',0.6595802307128906
|
||
|
3059,"def modified ( self ) : <TAB> paths = set ( ) <TAB> dictionary_list = [ ] <TAB> for op_list in self. _operations : <TAB> <TAB> if not isinstance ( op_list, list ) : <TAB> <TAB> <TAB> op_list = ( op_list, ) <TAB> <TAB> for item in chain ( * op_list ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> dictionary = item. dictionary <TAB> <TAB> <TAB> if dictionary. path in paths : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> paths. add ( dictionary. path ) <TAB> <TAB> <TAB> dictionary_list. append ( dictionary ) <TAB> return dictionary_list",False,item is None,"not hasattr(item, 'dictionary')",0.6668153405189514
|
||
|
3060,"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<mask> : <TAB> <TAB> <TAB> if ftype == TType. STRING : <TAB> <TAB> <TAB> <TAB> self. authenticationToken = iprot. readString ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif fid == 2 : <TAB> <TAB> <TAB> if ftype == TType. STRING : <TAB> <TAB> <TAB> <TAB> self. guid = 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 == 1,fid == 1,0.6753830909729004
|
||
|
3061,"def query_to_script_path ( path, query ) : <TAB> if path!= ""*"" : <TAB> <TAB> script = os. path. join ( path, query. split ( "" "" ) [ 0 ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise IOError ( ""Script '{}' not found in script directory"". format ( query ) ) <TAB> <TAB> return os. path. join ( path, query ). split ( "" "" ) <TAB> return query",False,not os.path.exists(script),not os.path.isdir(script),0.6496453285217285
|
||
|
3062,"def prepare_request ( next_link = None ) : <TAB> <TAB> header_parameters = { } <TAB> header_parameters [ ""Accept"" ] = self. _serialize. header ( ""accept"", accept, ""str"" ) <TAB> if not next_link : <TAB> <TAB> <TAB> <TAB> url = self. list. metadata [ ""url"" ] <TAB> <TAB> path_format_arguments = { <TAB> <TAB> <TAB> ""resourceGroupName"" : self. _serialize. url ( <TAB> <TAB> <TAB> <TAB> ""resource_group_name"", resource_group_name, ""str"" <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> ""virtualMachineScaleSetName"" : self. _serialize. url ( <TAB> <TAB> <TAB> <TAB> ""virtual_machine_scale_set_name"", virtual_machine_scale_set_name, ""str"" <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> ""subscriptionId"" : self. _serialize. url ( <TAB> <TAB> <TAB> <TAB> ""self._config.subscription_id"", self. _config. subscription_id, ""str"" <TAB> <TAB> <TAB> ), <TAB> <TAB> } <TAB> <TAB> url = self. _client. format_url ( url, ** path_format_arguments ) <TAB> <TAB> <TAB> <TAB> query_parameters = { } <TAB> <TAB> if filter is not None : <TAB> <TAB> <TAB> query_parameters [ ""$filter"" ] = self. _serialize. query ( ""filter"", filter, ""str"" ) <TAB> <TAB> if select is not None : <TAB> <TAB> <TAB> query_parameters [ ""$select"" ] = self. _serialize. query ( ""select"", select, ""str"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> query_parameters [ ""$expand"" ] = self. _serialize. query ( ""expand"", expand, ""str"" ) <TAB> <TAB> query_parameters [ ""api-version"" ] = self. _serialize. query ( <",True,expand is not None,expand is not None,0.672986626625061
|
||
|
3063,"def _convert ( self, raw_data : Any ) -> Union [ Dict [ str, Any ], List [ Dict [ str, Any ] ] ] : <TAB> results = { } <TAB> for table in raw_data. tables : <TAB> <TAB> result = [ ] <TAB> <TAB> for row in table. rows : <TAB> <TAB> <TAB> converted = { <TAB> <TAB> <TAB> <TAB> table. columns [ x ]. name : y <TAB> <TAB> <TAB> <TAB> for ( x, y ) in enumerate ( row ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> } <TAB> <TAB> <TAB> if ""customDimensions"" in converted : <TAB> <TAB> <TAB> <TAB> converted [ ""customDimensions"" ] = json. loads ( <TAB> <TAB> <TAB> <TAB> <TAB> converted [ ""customDimensions"" ] <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> result. append ( converted ) <TAB> <TAB> results [ table. name ] = result <TAB> if list ( results. keys ( ) ) == [ ""PrimaryResult"" ] : <TAB> <TAB> return results [ ""PrimaryResult"" ] <TAB> return results",False,"y not in [None, '']",y > 0,0.6545475721359253
|
||
|
3064,"def __init__ ( self, app, xml_filename = None ) : <TAB> self. app = app <TAB> self. data_managers = OrderedDict ( ) <TAB> self. managed_data_tables = OrderedDict ( ) <TAB> self. tool_path = None <TAB> self. _reload_count = 0 <TAB> self. filename = xml_filename or self. app. config. data_manager_config_file <TAB> for filename in util. listify ( self. filename ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> self. load_from_xml ( filename ) <TAB> if self. app. config. shed_data_manager_config_file : <TAB> <TAB> try : <TAB> <TAB> <TAB> self. load_from_xml ( <TAB> <TAB> <TAB> <TAB> self. app. config. shed_data_manager_config_file, store_tool_path = True <TAB> <TAB> <TAB> ) <TAB> <TAB> except OSError as exc : <TAB> <TAB> <TAB> if exc. errno!= errno. ENOENT or self. app. config. is_set ( <TAB> <TAB> <TAB> <TAB> ""shed_data_manager_config_file"" <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> raise",False,not filename,not os.path.isfile(filename),0.6764262914657593
|
||
|
3065,"def update_virtual_meta ( self ) : <TAB> """"""Will read back the virtual column etc, written by :func:`DataFrame.write_virtual_meta`. This will be done when opening a DataFrame."""""" <TAB> import astropy. units <TAB> try : <TAB> <TAB> path = os. path. join ( self. get_private_dir ( create = False ), ""virtual_meta.yaml"" ) <TAB> <TAB> if os. path. exists ( path ) : <TAB> <TAB> <TAB> meta_info = vaex. utils. read_json_or_yaml ( path ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> self. virtual_columns. update ( meta_info [ ""virtual_columns"" ] ) <TAB> <TAB> <TAB> self. variables. update ( meta_info [ ""variables"" ] ) <TAB> <TAB> <TAB> self. ucds. update ( meta_info [ ""ucds"" ] ) <TAB> <TAB> <TAB> self. descriptions. update ( meta_info [ ""descriptions"" ] ) <TAB> <TAB> <TAB> units = { <TAB> <TAB> <TAB> <TAB> key : astropy. units. Unit ( value ) <TAB> <TAB> <TAB> <TAB> for key, value in meta_info [ ""units"" ]. items ( ) <TAB> <TAB> <TAB> } <TAB> <TAB> <TAB> self. units. update ( units ) <TAB> except : <TAB> <TAB> logger. exception ( ""non fatal error"" )",False,'virtual_columns' not in meta_info,meta_info is None,0.6538059115409851
|
||
|
3066,"def global_fixes ( ) : <TAB> """"""Yield multiple (code, function) tuples."""""" <TAB> for function in list ( globals ( ). values ( ) ) : <TAB> <TAB> if inspect. isfunction ( function ) : <TAB> <TAB> <TAB> arguments = _get_parameters ( function ) <TAB> <TAB> <TAB> if arguments [ : 1 ]!= [ ""source"" ] : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> code = extract_code_from_function ( function ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> yield ( code, function )",True,code,code,0.685844361782074
|
||
|
3067,"def __Suffix_Noun_Step1b ( self, token ) : <TAB> for suffix in self. __suffix_noun_step1b : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> token = token [ : - 1 ] <TAB> <TAB> <TAB> self. suffixe_noun_step1b_success = True <TAB> <TAB> <TAB> break <TAB> return token",False,token.endswith(suffix) and len(token) > 5,token.endswith(suffix),0.6464305520057678
|
||
|
3068,"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<mask> : <TAB> <TAB> <TAB> if ftype == TType. LIST : <TAB> <TAB> <TAB> <TAB> self. new_parts = [ ] <TAB> <TAB> <TAB> <TAB> ( _etype632, _size629 ) = iprot. readListBegin ( ) <TAB> <TAB> <TAB> <TAB> for _i633 in xrange ( _size629 ) : <TAB> <TAB> <TAB> <TAB> <TAB> _elem634 = PartitionSpec ( ) <TAB> <TAB> <TAB> <TAB> <TAB> _elem634. read ( iprot ) <TAB> <TAB> <TAB> <TAB> <TAB> self. new_parts. append ( _elem634 ) <TAB> <TAB> <TAB> <TAB> iprot. readListEnd ( ) <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,fid == 1,fid == TType.PUSH,0.6747313141822815
|
||
|
3069,"def run_self_environ ( ) : <TAB> global se_url <TAB> global se_headers <TAB> global se_header_pars <TAB> global ahactive <TAB> global ahenvurl <TAB> if ahactive is False : <TAB> <TAB> se_url = input ( ""\n[*] Enter the /proc/self/environ vulnerable URL -> "" ) <TAB> else : <TAB> <TAB> se_url = ahenvurl <TAB> se_url = checkHttp ( se_url ) <TAB> se_headers [ ""Referer"" ] = extractWebsiteFromUrl ( se_url ) <TAB> auto = chooseSe_Par ( ) <TAB> if auto is False : <TAB> <TAB> hackSE ( ""None"" ) <TAB> else : <TAB> <TAB> for i in range ( 0, 7 ) : <TAB> <TAB> <TAB> restoreVars ( ) <TAB> <TAB> <TAB> print ( colored ( ""\n[*] Trying to inject '%s'"" % se_header_pars [ i ], ""white"" ) ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> setHttpCookie ( ) <TAB> <TAB> <TAB> hackSE ( se_header_pars [ i ] )",False,i == 6,se_header_pars[i] is not None,0.6837210655212402
|
||
|
3070,"def remove_cors ( cmd, resource_group_name, name, allowed_origins, slot = None ) : <TAB> configs = get_site_configs ( cmd, resource_group_name, name, slot ) <TAB> if configs. cors : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> configs. cors. allowed_origins = [ <TAB> <TAB> <TAB> <TAB> x <TAB> <TAB> <TAB> <TAB> for x in ( configs. cors. allowed_origins or [ ] ) <TAB> <TAB> <TAB> <TAB> if x not in allowed_origins <TAB> <TAB> <TAB> ] <TAB> <TAB> else : <TAB> <TAB> <TAB> configs. cors. allowed_origins = [ ] <TAB> <TAB> configs = _generic_site_operation ( <TAB> <TAB> <TAB> cmd. cli_ctx, <TAB> <TAB> <TAB> resource_group_name, <TAB> <TAB> <TAB> name, <TAB> <TAB> <TAB> ""update_configuration"", <TAB> <TAB> <TAB> slot, <TAB> <TAB> <TAB> configs, <TAB> <TAB> ) <TAB> return configs. cors",True,allowed_origins,allowed_origins,0.6703191995620728
|
||
|
3071,"def seek_to_block ( self, pos ) : <TAB> baseofs = 0 <TAB> ofs = 0 <TAB> for b in self. blocks : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. current_block = b <TAB> <TAB> <TAB> break <TAB> <TAB> baseofs += b. compressed_size <TAB> <TAB> ofs += b. uncompressed_size <TAB> else : <TAB> <TAB> self. current_block = None <TAB> <TAB> self. current_stream = BytesIO ( b"""" ) <TAB> <TAB> return <TAB> self. current_block_start = ofs <TAB> self. stream. seek ( self. basepos + baseofs ) <TAB> buf = BytesIO ( self. stream. read ( self. current_block. compressed_size ) ) <TAB> self. current_stream = self. current_block. decompress ( buf )",False,ofs + b.uncompressed_size > pos,pos > b.block_pos,0.6529514789581299
|
||
|
3072,"def dropEvent ( self, event ) : <TAB> rewindFile = False <TAB> if QtGui. QDropEvent. proposedAction ( event ) == Qt. MoveAction : <TAB> <TAB> QtGui. QDropEvent. setDropAction ( <TAB> <TAB> <TAB> event, Qt. CopyAction <TAB> <TAB> ) <TAB> <TAB> rewindFile = True <TAB> data = event. mimeData ( ) <TAB> urls = data. urls ( ) <TAB> if urls and urls [ 0 ]. scheme ( ) == ""file"" : <TAB> <TAB> url = event. mimeData ( ). urls ( ) [ 0 ] <TAB> <TAB> if isMacOS ( ) and IsPySide : <TAB> <TAB> <TAB> macURL = NSString. alloc ( ). initWithString_ ( str ( url. toString ( ) ) ) <TAB> <TAB> <TAB> pathString = macURL. stringByAddingPercentEscapesUsingEncoding_ ( <TAB> <TAB> <TAB> <TAB> NSUTF8StringEncoding <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> dropfilepath = os. path. abspath ( <TAB> <TAB> <TAB> <TAB> NSURL. URLWithString_ ( pathString ). filePathURL ( ). path ( ) <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> dropfilepath = os. path. abspath ( str ( url. toLocalFile ( ) ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _syncplayClient. openFile ( <TAB> <TAB> <TAB> <TAB> dropfilepath, resetPosition = False, fromUser = True <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. _syncplayClient. setPosition ( 0 ) <TAB> <TAB> <TAB> self. _syncplayClient. openFile ( <TAB> <TAB> <TAB> <TAB> dropfilepath, resetPosition = True, fromUser = True <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> self. _syncplayClient. setPosition ( 0 )",False,rewindFile == False,rewindFile,0.6644214987754822
|
||
|
3073,"def apply_implicit_inheritance ( self, hosts ) : <TAB> for prop in ( <TAB> <TAB> ""contacts"", <TAB> <TAB> ""contact_groups"", <TAB> <TAB> ""notification_interval"", <TAB> <TAB> ""notification_period"", <TAB> <TAB> ""resultmodulations"", <TAB> <TAB> ""business_impact_modulations"", <TAB> <TAB> ""escalations"", <TAB> <TAB> ""poller_tag"", <TAB> <TAB> ""reactionner_tag"", <TAB> <TAB> ""check_period"", <TAB> <TAB> ""business_impact"", <TAB> <TAB> ""maintenance_period"", <TAB> ) : <TAB> <TAB> for s in self : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> h = hosts. find_by_name ( s. host_name ) <TAB> <TAB> <TAB> <TAB> if h is not None and hasattr ( h, prop ) : <TAB> <TAB> <TAB> <TAB> <TAB> setattr ( s, prop, getattr ( h, prop ) )",False,"not hasattr(s, prop) and hasattr(s, 'host_name')","hasattr(s, prop)",0.646237313747406
|
||
|
3074,"def scan_folder ( folder ) : <TAB> scanned_files = [ ] <TAB> for root, dirs, files in os. walk ( folder ) : <TAB> <TAB> dirs [ : ] = [ d for d in dirs if d!= ""__pycache__"" ] <TAB> <TAB> relative_path = os. path. relpath ( root, folder ) <TAB> <TAB> for f in files : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> relative_name = os. path. normpath ( os. path. join ( relative_path, f ) ). replace ( <TAB> <TAB> <TAB> <TAB> ""\\"", ""/"" <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> scanned_files. append ( relative_name ) <TAB> return sorted ( scanned_files )",False,f.endswith('.pyc'),f.endswith('__pycache__'),0.6481367945671082
|
||
|
3075,"def _setAbsoluteY ( self, value ) : <TAB> if value is None : <TAB> <TAB> self. _absoluteY = None <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> value = 10 <TAB> <TAB> elif value == ""below"" : <TAB> <TAB> <TAB> value = - 70 <TAB> <TAB> try : <TAB> <TAB> <TAB> value = common. numToIntOrFloat ( value ) <TAB> <TAB> except ValueError as ve : <TAB> <TAB> <TAB> raise TextFormatException ( <TAB> <TAB> <TAB> <TAB> f""Not a supported absoluteY position: {value!r}"" <TAB> <TAB> <TAB> ) from ve <TAB> <TAB> self. _absoluteY = value",False,value == 'above',value == 'right',0.6653578281402588
|
||
|
3076,"def feed ( self, aBuf ) : <TAB> aLen = len ( aBuf ) <TAB> for i in xrange ( 0, aLen ) : <TAB> <TAB> codingState = self. _mCodingSM. next_state ( aBuf [ i ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if constants. _debug : <TAB> <TAB> <TAB> <TAB> sys. stderr. write ( <TAB> <TAB> <TAB> <TAB> <TAB> self. get_charset_name ( ) <TAB> <TAB> <TAB> <TAB> <TAB> + "" prober hit error at byte "" <TAB> <TAB> <TAB> <TAB> <TAB> + str ( i ) <TAB> <TAB> <TAB> <TAB> <TAB> + ""\n"" <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> self. _mState = constants. eNotMe <TAB> <TAB> <TAB> break <TAB> <TAB> elif codingState == constants. eItsMe : <TAB> <TAB> <TAB> self. _mState = constants. eFoundIt <TAB> <TAB> <TAB> break <TAB> <TAB> elif codingState == constants. eStart : <TAB> <TAB> <TAB> charLen = self. _mCodingSM. get_current_charlen ( ) <TAB> <TAB> <TAB> if i == 0 : <TAB> <TAB> <TAB> <TAB> self. _mLastChar [ 1 ] = aBuf [ 0 ] <TAB> <TAB> <TAB> <TAB> self. _mDistributionAnalyzer. feed ( self. _mLastChar, charLen ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. _mDistributionAnalyzer. feed ( aBuf [ i - 1 : i + 1 ], charLen ) <TAB> self. _mLastChar [ 0 ] = aBuf [ aLen - 1 ] <TAB> if self. get_state ( ) == constants. eDetecting : <TAB> <TAB> if self. _mDistributionAnalyzer. got_enough_data ( ) and ( <TAB> <TAB> <",False,codingState == constants.eError,self.get_state() == constants.eNotMe,0.6586983799934387
|
||
|
3077,"def _tunnel ( self ) : <TAB> connect_str = ""CONNECT %s:%d HTTP/1.0\r\n"" % ( self. _tunnel_host, self. _tunnel_port ) <TAB> connect_bytes = connect_str. encode ( ""ascii"" ) <TAB> self. send ( connect_bytes ) <TAB> for header, value in self. _tunnel_headers. items ( ) : <TAB> <TAB> header_str = ""%s: %s\r\n"" % ( header, value ) <TAB> <TAB> header_bytes = header_str. encode ( ""latin-1"" ) <TAB> <TAB> self. send ( header_bytes ) <TAB> self. send ( b""\r\n"" ) <TAB> response = self. response_class ( self. sock, method = self. _method ) <TAB> ( version, code, message ) = response. _read_status ( ) <TAB> if code!= http. HTTPStatus. OK : <TAB> <TAB> self. close ( ) <TAB> <TAB> raise OSError ( ""Tunnel connection failed: %d %s"" % ( code, message. strip ( ) ) ) <TAB> while True : <TAB> <TAB> line = response. fp. readline ( _MAXLINE + 1 ) <TAB> <TAB> if len ( line ) > _MAXLINE : <TAB> <TAB> <TAB> raise LineTooLong ( ""header line"" ) <TAB> <TAB> if not line : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> break <TAB> <TAB> if self. debuglevel > 0 : <TAB> <TAB> <TAB> print ( ""header:"", line. decode ( ) )",False,"line in (b'\r\n', b'\n', b'')",self.debuglevel > 0,0.6474130749702454
|
||
|
3078,"def __get_store_id_for ( self, obj, ** kwargs ) : <TAB> if obj. object_store_id is not None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return obj. object_store_id <TAB> <TAB> else : <TAB> <TAB> <TAB> log. warning ( <TAB> <TAB> <TAB> <TAB> ""The backend object store ID (%s) for %s object with ID %s is invalid"" <TAB> <TAB> <TAB> <TAB> % ( obj. object_store_id, obj. __class__. __name__, obj. id ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> for id, store in self. backends. items ( ) : <TAB> <TAB> if store. exists ( obj, ** kwargs ) : <TAB> <TAB> <TAB> log. warning ( <TAB> <TAB> <TAB> <TAB> ""%s object with ID %s found in backend object store with ID %s"" <TAB> <TAB> <TAB> <TAB> % ( obj. __class__. __name__, obj. id, id ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> obj. object_store_id = id <TAB> <TAB> <TAB> return id <TAB> return None",False,obj.object_store_id in self.backends,obj.object_store_id,0.6517153978347778
|
||
|
3079,"def Read ( self, lex_mode ) : <TAB> while True : <TAB> <TAB> t = self. _Read ( lex_mode ) <TAB> <TAB> self. was_line_cont = t. id == Id. Ignored_LineCont <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> break <TAB> <TAB> return t",False,t.id != Id.Ignored_LineCont,not self.was_line_cont,0.6525219678878784
|
||
|
3080,"def css ( self, * args, ** kwargs ) : <TAB> """"""css attributes manipulation"""""" <TAB> attr = value = no_default <TAB> length = len ( args ) <TAB> if length == 1 : <TAB> <TAB> attr = args [ 0 ] <TAB> elif length == 2 : <TAB> <TAB> attr, value = args <TAB> elif kwargs : <TAB> <TAB> attr = kwargs <TAB> else : <TAB> <TAB> raise ValueError ( ""Invalid arguments %s %s"" % ( args, kwargs ) ) <TAB> if isinstance ( attr, dict ) : <TAB> <TAB> for tag in self : <TAB> <TAB> <TAB> stripped_keys = [ key. strip ( ). replace ( ""_"", ""-"" ) for key in attr. keys ( ) ] <TAB> <TAB> <TAB> current = [ <TAB> <TAB> <TAB> <TAB> el. strip ( ) <TAB> <TAB> <TAB> <TAB> for el in ( tag. get ( ""style"" ) or """" ). split ( "";"" ) <TAB> <TAB> <TAB> <TAB> if el. strip ( ) and not el. split ( "":"" ) [ 0 ]. strip ( ) in stripped_keys <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> for key, value in attr. items ( ) : <TAB> <TAB> <TAB> <TAB> key = key. replace ( ""_"", ""-"" ) <TAB> <TAB> <TAB> <TAB> current. append ( ""%s: %s"" % ( key, value ) ) <TAB> <TAB> <TAB> tag. set ( ""style"", ""; "". join ( current ) ) <TAB> elif isinstance ( value, basestring ) : <TAB> <TAB> attr = attr. replace ( ""_"", ""-"" ) <TAB> <TAB> for tag in self : <TAB> <TAB> <TAB> current = [ <TAB> <TAB> <TAB> <TAB> el. strip ( ) <TAB> <TAB> <TAB> <TAB> for el in ( tag. get ( ""style"" ) or """" ). split ( "";"" ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> ] <TAB>",False,el.strip() and (not el.split(':')[0].strip() == attr.strip()),current,0.6479524374008179
|
||
|
3081,"def search ( <TAB> self, search_strings, age = 0, show_id = None, season = None, episode = None, ** kwargs ) : <TAB> results = [ ] <TAB> for mode in search_strings : <TAB> <TAB> sickrage. app. log. debug ( ""Search Mode: {}"". format ( mode ) ) <TAB> <TAB> for search_string in search_strings [ mode ] : <TAB> <TAB> <TAB> search_url = self. urls [ ""feed"" ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> sickrage. app. log. debug ( ""Search string: {}"". format ( search_string ) ) <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> data = self. session. get ( search_url, params = { ""f"" : search_string } ). text <TAB> <TAB> <TAB> <TAB> results += self. parse ( data, mode ) <TAB> <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> <TAB> sickrage. app. log. debug ( ""No data returned from provider"" ) <TAB> return results",False,mode != 'RSS',search_url,0.671477198600769
|
||
|
3082,"def _truncate_to_length ( generator, len_map = None ) : <TAB> for example in generator : <TAB> <TAB> example = list ( example ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> for key, max_len in len_map. items ( ) : <TAB> <TAB> <TAB> <TAB> example_len = example [ key ]. shape <TAB> <TAB> <TAB> <TAB> if example_len > max_len : <TAB> <TAB> <TAB> <TAB> <TAB> example [ key ] = np. resize ( example [ key ], max_len ) <TAB> <TAB> yield tuple ( example )",True,len_map is not None,len_map is not None,0.6523240804672241
|
||
|
3083,"def edit_soa_configs ( filename, instance, cpu, mem, disk ) : <TAB> if not os. path. exists ( filename ) : <TAB> <TAB> filename = filename. replace ( ""marathon"", ""kubernetes"" ) <TAB> if os. path. islink ( filename ) : <TAB> <TAB> real_filename = os. path. realpath ( filename ) <TAB> <TAB> os. remove ( filename ) <TAB> else : <TAB> <TAB> real_filename = filename <TAB> try : <TAB> <TAB> with open ( real_filename, ""r"" ) as fi : <TAB> <TAB> <TAB> yams = fi. read ( ) <TAB> <TAB> <TAB> yams = yams. replace ( ""cpus:."", ""cpus: 0."" ) <TAB> <TAB> <TAB> data = yaml. round_trip_load ( yams, preserve_quotes = True ) <TAB> <TAB> instdict = data [ instance ] <TAB> <TAB> if cpu : <TAB> <TAB> <TAB> instdict [ ""cpus"" ] = float ( cpu ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> mem = max ( 128, round ( float ( mem ) ) ) <TAB> <TAB> <TAB> instdict [ ""mem"" ] = mem <TAB> <TAB> if disk : <TAB> <TAB> <TAB> instdict [ ""disk"" ] = round ( float ( disk ) ) <TAB> <TAB> out = yaml. round_trip_dump ( data, width = 120 ) <TAB> <TAB> with open ( filename, ""w"" ) as fi : <TAB> <TAB> <TAB> fi. write ( out ) <TAB> except FileNotFoundError : <TAB> <TAB> log. exception ( f""Could not find {filename}"" ) <TAB> except KeyError : <TAB> <TAB> log. exception ( f""Error in {filename}. Will continue"" )",True,mem,mem,0.6766725778579712
|
||
|
3084,"def _try_lock ( self, pid ) : <TAB> fd = os. open ( self. target, os. O_CREAT | os. O_RDWR, 0o644 ) <TAB> try : <TAB> <TAB> try : <TAB> <TAB> <TAB> fcntl. flock ( fd, fcntl. LOCK_EX | fcntl. LOCK_NB ) <TAB> <TAB> except OSError as e : <TAB> <TAB> <TAB> if e. errno == errno. EWOULDBLOCK : <TAB> <TAB> <TAB> <TAB> return - 1 <TAB> <TAB> <TAB> raise <TAB> <TAB> old_pid = os. read ( fd, 20 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> os. write ( fd, str ( pid ). encode ( ""utf-8"" ) ) <TAB> <TAB> <TAB> return pid <TAB> <TAB> try : <TAB> <TAB> <TAB> old_pid = int ( old_pid ) <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> msg = _ ( <TAB> <TAB> <TAB> <TAB> ""Malformed lock file found: %s.\n"" <TAB> <TAB> <TAB> <TAB> ""Ensure no other dnf/yum process is running and "" <TAB> <TAB> <TAB> <TAB> ""remove the lock file manually or run "" <TAB> <TAB> <TAB> <TAB> ""systemd-tmpfiles --remove dnf.conf."" <TAB> <TAB> <TAB> ) % ( self. target ) <TAB> <TAB> <TAB> raise LockError ( msg ) <TAB> <TAB> if old_pid == pid : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return pid <TAB> <TAB> if not os. access ( ""/proc/%d/stat"" % old_pid, os. F_OK ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> os. lseek ( fd, 0, os. SEEK_SET ) <TAB> <TAB> <TAB> os. ftruncate ( fd, 0 ) <TAB>",False,len(old_pid) == 0,pid != -1,0.6590087413787842
|
||
|
3085,"def callback ( lexer, match, ctx = None ) : <TAB> for i, action in enumerate ( args ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> elif type ( action ) is _TokenType : <TAB> <TAB> <TAB> data = match. group ( i + 1 ) <TAB> <TAB> <TAB> if data : <TAB> <TAB> <TAB> <TAB> yield match. start ( i + 1 ), action, data <TAB> <TAB> else : <TAB> <TAB> <TAB> data = match. group ( i + 1 ) <TAB> <TAB> <TAB> if data is not None : <TAB> <TAB> <TAB> <TAB> if ctx : <TAB> <TAB> <TAB> <TAB> <TAB> ctx. pos = match. start ( i + 1 ) <TAB> <TAB> <TAB> <TAB> for item in action ( lexer, _PseudoMatch ( match. start ( i + 1 ), data ), ctx ) : <TAB> <TAB> <TAB> <TAB> <TAB> if item : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> yield item <TAB> if ctx : <TAB> <TAB> ctx. pos = match. end ( )",True,action is None,action is None,0.6623001098632812
|
||
|
3086,"def writeRecords ( self, modelResults, progressCB = None ) : <TAB> <TAB> if self. __logAdapter is None and modelResults : <TAB> <TAB> self. __writer = _BasicPredictionWriter ( <TAB> <TAB> <TAB> experimentDir = self. __experimentDir, <TAB> <TAB> <TAB> label = self. __label, <TAB> <TAB> <TAB> inferenceType = self. __inferenceType, <TAB> <TAB> <TAB> fields = self. __inputFieldsMeta, <TAB> <TAB> <TAB> metricNames = self. __loggedMetricNames, <TAB> <TAB> <TAB> checkpointSource = self. __checkpointCache, <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. __checkpointCache. close ( ) <TAB> <TAB> <TAB> self. __checkpointCache = None <TAB> <TAB> if InferenceType. isTemporal ( self. __inferenceType ) : <TAB> <TAB> <TAB> logAdapterClass = TemporalPredictionLogAdapter <TAB> <TAB> else : <TAB> <TAB> <TAB> logAdapterClass = NonTemporalPredictionLogAdapter <TAB> <TAB> self. __logAdapter = logAdapterClass ( self. __writer ) <TAB> <TAB> self. __writer. setLoggedMetrics ( self. __loggedMetricNames ) <TAB> for modelResult in modelResults : <TAB> <TAB> if modelResult. inferences is not None : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. __logAdapter. update ( modelResult ) <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. __logAdapter. update ( modelResult ) <TAB> return",True,self.__checkpointCache is not None,self.__checkpointCache is not None,0.6766112446784973
|
||
|
3087,"def get_context_data ( self, ** kwargs ) : <TAB> context = super ( AddonUploadConfirmView, self ). get_context_data ( ** kwargs ) <TAB> with zipfile. ZipFile ( self. get_addon_path ( ) ) as zf : <TAB> <TAB> context [ ""filenames"" ] = sorted ( zf. namelist ( ) ) <TAB> <TAB> pkg_info_path = first ( <TAB> <TAB> <TAB> filename <TAB> <TAB> <TAB> for filename in context [ ""filenames"" ] <TAB> <TAB> <TAB> if filename. endswith ( ""PKG-INFO"" ) <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> context [ ""pkg_info"" ] = zf. read ( pkg_info_path ). decode ( ""UTF-8"", ""replace"" ) <TAB> context [ ""toolbar"" ] = Toolbar ( <TAB> <TAB> [ <TAB> <TAB> <TAB> PostActionButton ( <TAB> <TAB> <TAB> <TAB> icon = ""fa fa-download"", <TAB> <TAB> <TAB> <TAB> form_id = ""install_form"", <TAB> <TAB> <TAB> <TAB> text = _ ( ""Install Addon"" ), <TAB> <TAB> <TAB> <TAB> extra_css_class = ""btn-success"", <TAB> <TAB> <TAB> ) <TAB> <TAB> ] <TAB> ) <TAB> return context",True,pkg_info_path,pkg_info_path,0.6568889617919922
|
||
|
3088,"def compile ( self, args ) : <TAB> compiled_args = { } <TAB> for key, value in six. iteritems ( args ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> compiled_args [ key ] = str ( value ) <TAB> <TAB> else : <TAB> <TAB> <TAB> compiled_args [ key ] = sjson_dumps ( value ) <TAB> return self. _minified_code % compiled_args",False,key in self.clean_args,"isinstance(value, six.string_types)",0.6603339910507202
|
||
|
3089,"def _update_widgets ( self, * events ) : <TAB> parameters = [ ] <TAB> for event in sorted ( events, key = lambda x : x. name ) : <TAB> <TAB> if event. name == ""object"" : <TAB> <TAB> <TAB> if isinstance ( event. new, param. parameterized. Parameters ) : <TAB> <TAB> <TAB> <TAB> self. object = ( <TAB> <TAB> <TAB> <TAB> <TAB> event. new. cls if event. new. self is None else event. new. self <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> if event. new is None : <TAB> <TAB> <TAB> <TAB> parameters = [ ] <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> parameters = [ p for p in event. new. param if p!= ""name"" ] <TAB> <TAB> <TAB> <TAB> self. name = param_name ( event. new. name ) <TAB> <TAB> if event. name == ""parameters"" : <TAB> <TAB> <TAB> parameters = [ ] if event. new == [ ] else event. new <TAB> if parameters!= [ ] and parameters!= self. parameters : <TAB> <TAB> self. parameters = parameters <TAB> <TAB> return <TAB> for cb in list ( self. _callbacks ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> cb. inst. param. unwatch ( cb ) <TAB> <TAB> <TAB> self. _callbacks. remove ( cb ) <TAB> <TAB> if self. object is None : <TAB> <TAB> self. _widgets = { } <TAB> else : <TAB> <TAB> self. _widgets = self. _get_widgets ( ) <TAB> alias = { ""_title"" : ""name"" } <TAB> widgets = [ <TAB> <TAB> widget <TAB> <TAB> for p, widget in self. _widgets. items ( ) <TAB> <TAB> if ( self. object. param [ alias. get ( p, p ) ]. precedence is None",False,cb.inst in self._widget_box.objects,cb.inst is not None,0.6571661829948425
|
||
|
3090,"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 ftype == TType. MAP : <TAB> <TAB> <TAB> <TAB> self. success = { } <TAB> <TAB> <TAB> <TAB> ( _ktype944, _vtype945, _size943 ) = iprot. readMapBegin ( ) <TAB> <TAB> <TAB> <TAB> for _i947 in xrange ( _size943 ) : <TAB> <TAB> <TAB> <TAB> <TAB> _key948 = iprot. readString ( ) <TAB> <TAB> <TAB> <TAB> <TAB> _val949 = iprot. readString ( ) <TAB> <TAB> <TAB> <TAB> <TAB> self. success [ _key948 ] = _val949 <TAB> <TAB> <TAB> <TAB> iprot. readMapEnd ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif fid == 1 : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. o1 = MetaException ( ) <TAB> <TAB> <TAB> <TAB> self. o1. read ( iprot ) <TAB> <TAB> <TAB>",False,ftype == TType.STRUCT,self.o1 is None,0.664229691028595
|
||
|
3091,"def test_detach ( self ) : <TAB> N = 5 <TAB> mesh = TestMeshes. init_mesh ( N, 10, 100, requires_grad = True ) <TAB> for force in [ 0, 1 ] : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> mesh. verts_packed ( ) <TAB> <TAB> <TAB> mesh. edges_packed ( ) <TAB> <TAB> <TAB> mesh. verts_padded ( ) <TAB> <TAB> new_mesh = mesh. detach ( ) <TAB> <TAB> self. assertFalse ( new_mesh. verts_packed ( ). requires_grad ) <TAB> <TAB> self. assertClose ( new_mesh. verts_packed ( ), mesh. verts_packed ( ) ) <TAB> <TAB> self. assertFalse ( new_mesh. verts_padded ( ). requires_grad ) <TAB> <TAB> self. assertClose ( new_mesh. verts_padded ( ), mesh. verts_padded ( ) ) <TAB> <TAB> for v, newv in zip ( mesh. verts_list ( ), new_mesh. verts_list ( ) ) : <TAB> <TAB> <TAB> self. assertFalse ( newv. requires_grad ) <TAB> <TAB> <TAB> self. assertClose ( newv, v )",True,force,force,0.6832422018051147
|
||
|
3092,"def _check_for_req_data ( data ) : <TAB> required_args = [ ""columns"" ] <TAB> for arg in required_args : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return True, make_json_response ( <TAB> <TAB> <TAB> <TAB> status = 400, <TAB> <TAB> <TAB> <TAB> success = 0, <TAB> <TAB> <TAB> <TAB> errormsg = gettext ( ""Could not find required parameter ({})."" ). format ( arg ), <TAB> <TAB> <TAB> ) <TAB> return False, """"",False,"arg not in data or (isinstance(data[arg], list) and len(data[arg]) < 1)",arg in data,0.6534847617149353
|
||
|
3093,"def handle_local_result ( self ) -> bool : <TAB> test_name = self. format ( ""{self.path.k8s}"" ) <TAB> print ( f""{test_name} {type(self)} HANDLE_LOCAL_RESULT"" ) <TAB> end_result = self. find_local_result ( ) <TAB> if end_result is not None : <TAB> <TAB> result_type = end_result [ ""result"" ] <TAB> <TAB> if result_type == ""pass"" : <TAB> <TAB> <TAB> pass <TAB> <TAB> elif result_type == ""skip"" : <TAB> <TAB> <TAB> pytest. skip ( end_result [ ""reason"" ] ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> sys. stdout. write ( end_result [ ""stdout"" ] ) <TAB> <TAB> <TAB> if os. environ. get ( ""KAT_VERBOSE"", None ) : <TAB> <TAB> <TAB> <TAB> sys. stderr. write ( end_result [ ""stderr"" ] ) <TAB> <TAB> <TAB> pytest. fail ( ""local check failed"" ) <TAB> <TAB> elif result_type == ""xfail"" : <TAB> <TAB> <TAB> pytest. xfail ( end_result [ ""reason"" ] ) <TAB> <TAB> return True <TAB> return False",False,result_type == 'fail',"os.environ.get('KAT_VERBOSE', None)",0.6539344191551208
|
||
|
3094,"def on_message ( self, message ) : <TAB> """"""Receiving a message from the websocket, parse, and act accordingly."""""" <TAB> if<mask> : <TAB> <TAB> print ( message ) <TAB> msg = tornado. escape. json_decode ( message ) <TAB> if msg [ ""type"" ] == ""get_step"" : <TAB> <TAB> if not self. application. model. running : <TAB> <TAB> <TAB> self. write_message ( { ""type"" : ""end"" } ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. application. model. step ( ) <TAB> <TAB> <TAB> self. write_message ( self. viz_state_message ) <TAB> elif msg [ ""type"" ] == ""reset"" : <TAB> <TAB> self. application. reset_model ( ) <TAB> <TAB> self. write_message ( self. viz_state_message ) <TAB> elif msg [ ""type"" ] == ""submit_params"" : <TAB> <TAB> param = msg [ ""param"" ] <TAB> <TAB> value = msg [ ""value"" ] <TAB> <TAB> <TAB> <TAB> if param in self. application. user_params : <TAB> <TAB> <TAB> if isinstance ( self. application. model_kwargs [ param ], UserSettableParameter ) : <TAB> <TAB> <TAB> <TAB> self. application. model_kwargs [ param ]. value = value <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. application. model_kwargs [ param ] = value <TAB> elif msg [ ""type"" ] == ""get_params"" : <TAB> <TAB> self. write_message ( <TAB> <TAB> <TAB> { ""type"" : ""model_params"", ""params"" : self. application. user_params } <TAB> <TAB> ) <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> print ( ""Unexpected message!"" )",False,self.application.verbose,message,0.6572911739349365
|
||
|
3095,"def analyze ( ip, results ) : <TAB> links = set ( ) <TAB> r = IPWhois ( ip. value ) <TAB> result = r. lookup_whois ( ) <TAB> results. update ( raw = pformat ( result ) ) <TAB> <TAB> <TAB> n = 0 <TAB> smallest_subnet = None <TAB> for network in result [ ""nets"" ] : <TAB> <TAB> cidr_bits = int ( network [ ""cidr"" ]. split ( ""/"" ) [ 1 ]. split ( "","" ) [ 0 ] ) <TAB> <TAB> if cidr_bits > n : <TAB> <TAB> <TAB> n = cidr_bits <TAB> <TAB> <TAB> smallest_subnet = network <TAB> if smallest_subnet : <TAB> <TAB> <TAB> <TAB> company = Company. get_or_create ( <TAB> <TAB> <TAB> name = smallest_subnet [ ""description"" ]. split ( ""\n"" ) [ 0 ] <TAB> <TAB> ) <TAB> <TAB> links. update ( ip. active_link_to ( company, ""hosting"", ""Network Whois"" ) ) <TAB> <TAB> <TAB> <TAB> if smallest_subnet [ ""emails"" ] : <TAB> <TAB> <TAB> for email_address in smallest_subnet [ ""emails"" ] : <TAB> <TAB> <TAB> <TAB> email = Email. get_or_create ( value = email_address ) <TAB> <TAB> <TAB> <TAB> links. update ( company. link_to ( email, None, ""Network Whois"" ) ) <TAB> <TAB> <TAB> <TAB> for key in smallest_subnet : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> result [ ""net_{}"". format ( key ) ] = smallest_subnet [ key ] <TAB> <TAB> for context in ip. context : <TAB> <TAB> if context [ ""source"" ] == ""network_whois"" : <TAB> <TAB> <TAB> break <TAB> else : <TAB> <TAB> <TAB> <TAB> result. pop ( ""nets"", None ) <TAB> <TAB> result",False,smallest_subnet[key],key in smallest_subnet,0.676307201385498
|
||
|
3096,"def predict_action_probabilities ( <TAB> self, <TAB> tracker : DialogueStateTracker, <TAB> domain : Domain, <TAB> interpreter : NaturalLanguageInterpreter, <TAB> ** kwargs : Any, ) -> PolicyPrediction : <TAB> """"""Predicts the corresponding form action if there is an active form."""""" <TAB> result = self. _default_predictions ( domain ) <TAB> if tracker. active_loop_name : <TAB> <TAB> logger. debug ( ""There is an active form '{}'"". format ( tracker. active_loop_name ) ) <TAB> <TAB> if tracker. latest_action_name == ACTION_LISTEN_NAME : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if tracker. active_loop. get ( LOOP_REJECTED ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> return self. _prediction ( result, events = [ LoopInterrupted ( True ) ] ) <TAB> <TAB> <TAB> result = self. _prediction_result ( tracker. active_loop_name, tracker, domain ) <TAB> <TAB> elif tracker. latest_action_name == tracker. active_loop_name : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> result = self. _prediction_result ( ACTION_LISTEN_NAME, tracker, domain ) <TAB> else : <TAB> <TAB> logger. debug ( ""There is no active form"" ) <TAB> return self. _prediction ( result )",False,"self.state_is_unhappy(tracker, domain)",result is not None,0.6467951536178589
|
||
|
3097,"def _bin_op ( self, other, op ) : <TAB> if not type ( other ) is DataSet : <TAB> <TAB> raise TypeError ( ""_bin_op() only works on another DataSet instance."" ) <TAB> res = set ( ) <TAB> <TAB> <TAB> for o in other : <TAB> <TAB> for s in self : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> res. add ( UNDEFINED ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> tmp = op ( s, o ) <TAB> <TAB> <TAB> <TAB> <TAB> if isinstance ( tmp, int ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> tmp &= self. _mask <TAB> <TAB> <TAB> <TAB> <TAB> res. add ( tmp ) <TAB> <TAB> <TAB> <TAB> except TypeError as ex : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> raise <TAB> return DataSet ( res, self. _bits )",False,type(o) is Undefined or type(s) is Undefined,s is None,0.6576385498046875
|
||
|
3098,"def dataReceived ( self, data ) : <TAB> if not self. known_proto : <TAB> <TAB> self. known_proto = self. transport. negotiatedProtocol <TAB> <TAB> assert self. known_proto == b""h2"" <TAB> events = self. conn. receive_data ( data ) <TAB> for event in events : <TAB> <TAB> if isinstance ( event, ResponseReceived ) : <TAB> <TAB> <TAB> self. handleResponse ( event. headers, event. stream_id ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> self. handleData ( event. data, event. stream_id ) <TAB> <TAB> elif isinstance ( event, StreamEnded ) : <TAB> <TAB> <TAB> self. endStream ( event. stream_id ) <TAB> <TAB> elif isinstance ( event, SettingsAcknowledged ) : <TAB> <TAB> <TAB> self. settingsAcked ( event ) <TAB> <TAB> elif isinstance ( event, StreamReset ) : <TAB> <TAB> <TAB> reactor. stop ( ) <TAB> <TAB> <TAB> raise RuntimeError ( ""Stream reset: %d"" % event. error_code ) <TAB> <TAB> else : <TAB> <TAB> <TAB> print ( event ) <TAB> data = self. conn. data_to_send ( ) <TAB> if data : <TAB> <TAB> self. transport. write ( data )",False,"isinstance(event, DataReceived)","isinstance(event, Data)",0.6573208570480347
|
||
|
3099,"def add_legacy_moderation_warning ( self ) : <TAB> <TAB> if self. latest_revision and self. latest_revision. submitted_for_moderation : <TAB> <TAB> buttons = [ ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> buttons. append ( self. get_compare_with_live_message_button ( ) ) <TAB> <TAB> messages. warning ( <TAB> <TAB> <TAB> self. request, <TAB> <TAB> <TAB> _ ( ""This page is currently awaiting moderation"" ), <TAB> <TAB> <TAB> buttons = buttons, <TAB> <TAB> )",False,self.page.live,self.is_live_moderation(),0.6671584248542786
|
||
|
3100,"def __init__ ( self, encoding, ** kwds ) : <TAB> if not encoding : <TAB> <TAB> <TAB> <TAB> chcp = os. popen ( ""chcp"" ) <TAB> <TAB> chcp_encoding = re. match ( r""[^\d]+(\d+)"", chcp. read ( ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise LookupError ( ""Can't detect encoding from chcp"" ) <TAB> <TAB> encoding = ""cp"" + chcp_encoding. groups ( ) [ 0 ] <TAB> <TAB> print ( encoding ) <TAB> super ( PowershellRepl, self ). __init__ ( encoding, ** kwds ) <TAB> <TAB> <TAB> <TAB> self. got_output = True <TAB> self. multiline = False <TAB> self. prompt ( )",True,not chcp_encoding,not chcp_encoding,0.6602431535720825
|
||
|
3101,"def __call__ ( self, p1, p2 ) : <TAB> self. temp = self. minTemperature <TAB> if self. useNetworks : <TAB> <TAB> p1 = ModuleDecidingPlayer ( p1, self. task. env, temperature = self. temp ) <TAB> <TAB> p2 = ModuleDecidingPlayer ( p2, self. task. env, temperature = self. temp ) <TAB> else : <TAB> <TAB> assert isinstance ( p1, CapturePlayer ) <TAB> <TAB> assert isinstance ( p2, CapturePlayer ) <TAB> <TAB> p1. game = self. task. env <TAB> <TAB> p2. game = self. task. env <TAB> p1. color = CaptureGame. BLACK <TAB> p2. color = - p1. color <TAB> self. player = p1 <TAB> self. opponent = p2 <TAB> <TAB> coeffSum = 0.0 <TAB> score = 0.0 <TAB> np = int ( self. cases * ( 1 - self. presetGamesProportion ) ) <TAB> for i in range ( self. maxGames ) : <TAB> <TAB> coeff = 1 / ( 10 * self. temp + 1 ) <TAB> <TAB> preset = None <TAB> <TAB> if self. cases > 1 : <TAB> <TAB> <TAB> if i % self. cases >= np : <TAB> <TAB> <TAB> <TAB> preset = self. sPos [ ( i - np ) % self. cases ] <TAB> <TAB> <TAB> elif i < self. cases : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if i == 0 : <TAB> <TAB> <TAB> <TAB> <TAB> coeff *= np <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> res = self. _oneGame ( preset ) <TAB> <TAB> score += coeff * res <TAB> <TAB> coeffSum += coeff <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _globalWarming ( ) <TAB",False,self.cases == 1 or (i % self.cases == 0 and i > 0),self.warming(),0.6555721759796143
|
||
|
3102,"def _initialize_filesystem ( self ) : <TAB> util. ensure_dirs ( self. _initial_subdirs ( ) ) <TAB> log_file = util. get_cfg_option_str ( self. cfg, ""def_log_file"" ) <TAB> if log_file : <TAB> <TAB> util. ensure_file ( log_file, preserve_mode = True ) <TAB> <TAB> perms = self. cfg. get ( ""syslog_fix_perms"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> perms = { } <TAB> <TAB> if not isinstance ( perms, list ) : <TAB> <TAB> <TAB> perms = [ perms ] <TAB> <TAB> error = None <TAB> <TAB> for perm in perms : <TAB> <TAB> <TAB> u, g = util. extract_usergroup ( perm ) <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> util. chownbyname ( log_file, u, g ) <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> except OSError as e : <TAB> <TAB> <TAB> <TAB> error = e <TAB> <TAB> LOG. warning ( <TAB> <TAB> <TAB> ""Failed changing perms on '%s'. tried: %s. %s"", <TAB> <TAB> <TAB> log_file, <TAB> <TAB> <TAB> "","". join ( perms ), <TAB> <TAB> <TAB> error, <TAB> <TAB> )",True,not perms,not perms,0.6838549375534058
|
||
|
3103,"def leave_room ( self, sid, namespace, room ) : <TAB> """"""Remove a client from a room."""""" <TAB> try : <TAB> <TAB> del self. rooms [ namespace ] [ room ] [ sid ] <TAB> <TAB> if len ( self. rooms [ namespace ] [ room ] ) == 0 : <TAB> <TAB> <TAB> del self. rooms [ namespace ] [ room ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> del self. rooms [ namespace ] <TAB> except KeyError : <TAB> <TAB> pass",True,len(self.rooms[namespace]) == 0,len(self.rooms[namespace]) == 0,0.6592134237289429
|
||
|
3104,"def testPersistencyCompressed ( self ) : <TAB> if self. cls == similarities. WmdSimilarity and not PYEMD_EXT : <TAB> <TAB> return <TAB> fname = testfile ( ) + "".gz"" <TAB> if self. cls == similarities. Similarity : <TAB> <TAB> index = self. cls ( None, corpus, num_features = len ( dictionary ), shardsize = 5 ) <TAB> elif self. cls == similarities. WmdSimilarity : <TAB> <TAB> index = self. cls ( texts, self. w2v_model ) <TAB> else : <TAB> <TAB> index = self. cls ( corpus, num_features = len ( dictionary ) ) <TAB> index. save ( fname ) <TAB> index2 = self. cls. load ( fname ) <TAB> if self. cls == similarities. Similarity : <TAB> <TAB> <TAB> <TAB> self. assertTrue ( len ( index. shards ) == len ( index2. shards ) ) <TAB> <TAB> index. destroy ( ) <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> index. index = index. index. todense ( ) <TAB> <TAB> <TAB> index2. index = index2. index. todense ( ) <TAB> <TAB> self. assertTrue ( numpy. allclose ( index. index, index2. index ) ) <TAB> <TAB> self. assertEqual ( index. num_best, index2. num_best )",False,"isinstance(index, similarities.SparseMatrixSimilarity)",index.index is not None and index2.index is not None,0.6534357666969299
|
||
|
3105,"def check_classes ( self, node ) : <TAB> if isinstance ( node, nodes. Element ) : <TAB> <TAB> for class_value in node [ ""classes"" ] [ : ] : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> node [ ""classes"" ]. remove ( class_value ) <TAB> <TAB> <TAB> if class_value in self. strip_elements : <TAB> <TAB> <TAB> <TAB> return 1",False,class_value in self.strip_classes,class_value in self.strip_elements,0.6564825773239136
|
||
|
3106,"def on_msg ( self, evt ) : <TAB> msg = evt [ ""message"" ] <TAB> event_type = msg [ 0 ] <TAB> if event_type == ""user_disconnect"" : <TAB> <TAB> user_id = msg [ 1 ] <TAB> <TAB> self. clients. disconnect_user ( user_id ) <TAB> elif event_type == ""user_disconnect_id"" : <TAB> <TAB> user_id = msg [ 1 ] <TAB> <TAB> client_id = msg [ 2 ] <TAB> <TAB> server_id = None <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> server_id = msg [ 3 ] <TAB> <TAB> self. clients. disconnect_user_id ( user_id, client_id, server_id ) <TAB> elif event_type == ""user_disconnect_mac"" : <TAB> <TAB> user_id = msg [ 1 ] <TAB> <TAB> host_id = msg [ 2 ] <TAB> <TAB> mac_addr = msg [ 3 ] <TAB> <TAB> server_id = None <TAB> <TAB> if len ( msg ) > 4 : <TAB> <TAB> <TAB> server_id = msg [ 4 ] <TAB> <TAB> self. clients. disconnect_user_mac ( user_id, host_id, mac_addr, server_id ) <TAB> elif event_type == ""user_reconnect"" : <TAB> <TAB> user_id = msg [ 1 ] <TAB> <TAB> host_id = msg [ 2 ] <TAB> <TAB> server_id = None <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> server_id = msg [ 3 ] <TAB> <TAB> self. clients. reconnect_user ( user_id, host_id, server_id ) <TAB> elif event_type == ""route_advertisement"" : <TAB> <TAB> server_id = msg [ 1 ] <TAB> <TAB> vpc_region = msg [ 2 ] <TAB> <TAB> vpc_id = msg [ 3 ] <TAB> <TAB> network = msg [ 4 ] <TAB> <TAB> if server_id!= self. server.",True,len(msg) > 3,len(msg) > 3,0.6539647579193115
|
||
|
3107,"def uploadFile ( self, suffix, mime, payload ) : <TAB> with tempfile. NamedTemporaryFile ( suffix = suffix ) as fd : <TAB> <TAB> fd. write ( payload ) <TAB> <TAB> fd. flush ( ) <TAB> <TAB> fd. seek ( 0 ) <TAB> <TAB> filename = os. path. basename ( fd. name ) <TAB> <TAB> if self. shouldLog : <TAB> <TAB> <TAB> self. logger. debug ( ""Sending file %s with mime type : %s"", filename, mime ) <TAB> <TAB> fu = self. session. post ( <TAB> <TAB> <TAB> self. uploadUrl, <TAB> <TAB> <TAB> files = { self. inputName : ( filename, fd, mime ) }, <TAB> <TAB> <TAB> data = self. postData, <TAB> <TAB> ) <TAB> <TAB> self. httpRequests += 1 <TAB> <TAB> if self. shouldLog : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> printSimpleResponseObject ( fu ) <TAB> <TAB> <TAB> if self. logger. verbosity > 2 : <TAB> <TAB> <TAB> <TAB> print ( ""\033[36m"" + fu. text + ""\033[m"" ) <TAB> return ( fu, filename )",False,self.logger.verbosity > 1,self.logger.verbosity > 2,0.6590648889541626
|
||
|
3108,"def _chars_to_indices ( self, chars ) : <TAB> r""""""Helper for Sequence.frequencies."""""" <TAB> if isinstance ( chars, ( str, bytes ) ) : <TAB> <TAB> chars = set ( [ chars ] ) <TAB> elif not isinstance ( chars, set ) : <TAB> <TAB> raise TypeError ( ""`chars` must be of type `set`, not %r"" % type ( chars ). __name__ ) <TAB> <TAB> <TAB> chars = list ( chars ) <TAB> indices = [ ] <TAB> for char in chars : <TAB> <TAB> if not isinstance ( char, ( str, bytes ) ) : <TAB> <TAB> <TAB> raise TypeError ( <TAB> <TAB> <TAB> <TAB> ""Each element of `chars` must be string-like, not %r"" <TAB> <TAB> <TAB> <TAB> % type ( char ). __name__ <TAB> <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""Each element of `chars` must contain a single "" <TAB> <TAB> <TAB> <TAB> ""character (found %d characters)"" % len ( char ) <TAB> <TAB> <TAB> ) <TAB> <TAB> index = ord ( char ) <TAB> <TAB> if index >= self. _number_of_extended_ascii_codes : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""Character %r in `chars` is outside the range of "" <TAB> <TAB> <TAB> <TAB> ""allowable characters in a `Sequence` object."" % char <TAB> <TAB> <TAB> ) <TAB> <TAB> indices. append ( index ) <TAB> return chars, indices",False,len(char) != 1,len(char) < len(chars),0.6582775115966797
|
||
|
3109,"def parse_hits ( self ) : <TAB> """"""Parse a HMMER2 hit block, beginning with the hit table."""""" <TAB> hit_placeholders = [ ] <TAB> while self. read_next ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> break <TAB> <TAB> if self. line. find ( ""no hits"" ) > - 1 : <TAB> <TAB> <TAB> break <TAB> <TAB> if ( <TAB> <TAB> <TAB> self. line. startswith ( ""Sequence"" ) <TAB> <TAB> <TAB> or self. line. startswith ( ""Model"" ) <TAB> <TAB> <TAB> or self. line. startswith ( ""-------- "" ) <TAB> <TAB> ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> fields = self. line. split ( ) <TAB> <TAB> id_ = fields. pop ( 0 ) <TAB> <TAB> domain_obs_num = int ( fields. pop ( ) ) <TAB> <TAB> evalue = float ( fields. pop ( ) ) <TAB> <TAB> bitscore = float ( fields. pop ( ) ) <TAB> <TAB> description = "" "". join ( fields ). strip ( ) <TAB> <TAB> hit = _HitPlaceholder ( ) <TAB> <TAB> hit. id_ = id_ <TAB> <TAB> hit. evalue = evalue <TAB> <TAB> hit. bitscore = bitscore <TAB> <TAB> hit. description = description <TAB> <TAB> hit. domain_obs_num = domain_obs_num <TAB> <TAB> hit_placeholders. append ( hit ) <TAB> return hit_placeholders",False,self.line.startswith('Parsed'),self.line.find(hits) == -1,0.6521663069725037
|
||
|
3110,"def transform_cart_positions ( cls, cp : List, order ) -> list : <TAB> from. import Voucher <TAB> ops = [ ] <TAB> cp_mapping = { } <TAB> <TAB> for i, cartpos in enumerate ( <TAB> <TAB> sorted ( cp, key = lambda c : ( c. addon_to_id or c. pk, c. addon_to_id or 0 ) ) <TAB> ) : <TAB> <TAB> op = OrderPosition ( order = order ) <TAB> <TAB> for f in AbstractPosition. _meta. fields : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> setattr ( op, f. name, cp_mapping. get ( cartpos. addon_to_id ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> setattr ( op, f. name, getattr ( cartpos, f. name ) ) <TAB> <TAB> op. _calculate_tax ( ) <TAB> <TAB> op. positionid = i + 1 <TAB> <TAB> op. save ( ) <TAB> <TAB> cp_mapping [ cartpos. pk ] = op <TAB> <TAB> for answ in cartpos. answers. all ( ) : <TAB> <TAB> <TAB> answ. orderposition = op <TAB> <TAB> <TAB> answ. cartposition = None <TAB> <TAB> <TAB> answ. save ( ) <TAB> <TAB> if cartpos. voucher : <TAB> <TAB> <TAB> Voucher. objects. filter ( pk = cartpos. voucher. pk ). update ( <TAB> <TAB> <TAB> <TAB> redeemed = F ( ""redeemed"" ) + 1 <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> cartpos. voucher. log_action ( <TAB> <TAB> <TAB> <TAB> ""pretix.voucher.redeemed"", { ""order_code"" : order. code } <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> for cartpos in cp : <TAB> <TAB> if cartpos.",False,f.name == 'addon_to',f.cpposition,0.6532551646232605
|
||
|
3111,"def _analysis_core_graph ( self ) : <TAB> while not self. should_abort : <TAB> <TAB> self. _intra_analysis ( ) <TAB> <TAB> n = self. _graph_visitor. next_node ( ) <TAB> <TAB> if n is None : <TAB> <TAB> <TAB> break <TAB> <TAB> job_state = self. _get_input_state ( n ) <TAB> <TAB> if job_state is None : <TAB> <TAB> <TAB> job_state = self. _initial_abstract_state ( n ) <TAB> <TAB> changed, output_state = self. _run_on_node ( n, job_state ) <TAB> <TAB> <TAB> <TAB> successors_to_visit = self. _add_input_state ( n, output_state ) <TAB> <TAB> if changed is False : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _graph_visitor. revisit_successors ( n, include_self = False ) <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for succ in successors_to_visit : <TAB> <TAB> <TAB> <TAB> self. _graph_visitor. revisit_node ( succ )",False,changed is True,successors_to_visit is None,0.6661714315414429
|
||
|
3112,"def get_relationship ( self, secondRel, firstRel, orig_person, other_person ) : <TAB> common = """" <TAB> if not firstRel : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return ( """", common ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return ( self. get_direct_ancestor ( other_person, secondRel ), common ) <TAB> el if<mask> : <TAB> <TAB> return ( self. get_direct_descendant ( other_person, firstRel ), common ) <TAB> elif len ( firstRel ) == 1 : <TAB> <TAB> if other_person == Person. MALE : <TAB> <TAB> <TAB> return ( self. get_ancestors_brother ( secondRel ), common ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return ( self. get_ancestors_sister ( secondRel ), common ) <TAB> elif len ( secondRel ) >= len ( firstRel ) : <TAB> <TAB> return ( self. get_ancestors_cousin ( secondRel, firstRel ), common ) <TAB> else : <TAB> <TAB> return ( self. get_cousins_descendant ( other_person, firstRel, secondRel ), common )",False,not secondRel,first_person == Person.MALE,0.6727899312973022
|
||
|
3113,"def least_squares_cg ( Cui, X, Y, regularization, num_threads = 0, cg_steps = 3 ) : <TAB> users, factors = X. shape <TAB> YtY = Y. T. dot ( Y ) + regularization * np. eye ( factors, dtype = Y. dtype ) <TAB> for u in range ( users ) : <TAB> <TAB> <TAB> <TAB> x = X [ u ] <TAB> <TAB> <TAB> <TAB> r = - YtY. dot ( x ) <TAB> <TAB> for i, confidence in nonzeros ( Cui, u ) : <TAB> <TAB> <TAB> if confidence > 0 : <TAB> <TAB> <TAB> <TAB> r += ( confidence - ( confidence - 1 ) * Y [ i ]. dot ( x ) ) * Y [ i ] <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> confidence *= - 1 <TAB> <TAB> <TAB> <TAB> r += - ( confidence - 1 ) * Y [ i ]. dot ( x ) * Y [ i ] <TAB> <TAB> p = r. copy ( ) <TAB> <TAB> rsold = r. dot ( r ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> for it in range ( cg_steps ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> Ap = YtY. dot ( p ) <TAB> <TAB> <TAB> for i, confidence in nonzeros ( Cui, u ) : <TAB> <TAB> <TAB> <TAB> if confidence < 0 : <TAB> <TAB> <TAB> <TAB> <TAB> confidence *= - 1 <TAB> <TAB> <TAB> <TAB> Ap += ( confidence - 1 ) * Y [ i ]. dot ( p ) * Y [ i ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> alpha = rsold / p. dot ( Ap ) <TAB> <TAB> <TAB> x += alpha * p <TAB> <TAB> <TAB> r -= alpha * Ap <TAB> <TAB> <TAB> rsnew",False,rsold < 1e-20,rsold == 0,0.6612157225608826
|
||
|
3114,"def test_sobel ( ) : <TAB> I = np. array ( <TAB> <TAB> [ <TAB> <TAB> <TAB> [ 0, 0, 0, 0, 0, 0 ], <TAB> <TAB> <TAB> [ 0, 0, 0, 1, 0, 0 ], <TAB> <TAB> <TAB> [ 0, 0, 0, 1, 0, 0 ], <TAB> <TAB> <TAB> [ 0, 0, 0, 1, 0, 0 ], <TAB> <TAB> <TAB> [ 0, 0, 0, 1, 0, 0 ], <TAB> <TAB> <TAB> [ 0, 0, 0, 0, 0, 0 ], <TAB> <TAB> ] <TAB> ) <TAB> E = sobel ( I ) <TAB> r, c = I. shape <TAB> for y, x in zip ( * np. where ( E ) ) : <TAB> <TAB> N = [ I [ y, x ] ] <TAB> <TAB> if y > 0 : <TAB> <TAB> <TAB> N. append ( I [ y - 1, x ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> N. append ( I [ y, x - 1 ] ) <TAB> <TAB> if y < ( r - 1 ) : <TAB> <TAB> <TAB> N. append ( I [ y + 1, x ] ) <TAB> <TAB> if x < ( c - 1 ) : <TAB> <TAB> <TAB> N. append ( I [ y, x + 1 ] ) <TAB> <TAB> assert len ( set ( N ) ) > 1",True,x > 0,x > 0,0.6758773326873779
|
||
|
3115,"def _flatten ( * args ) : <TAB> ahs = set ( ) <TAB> if len ( args ) > 0 : <TAB> <TAB> for item in args : <TAB> <TAB> <TAB> if type ( item ) is ActionHandle : <TAB> <TAB> <TAB> <TAB> ahs. add ( item ) <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> for ah in item : <TAB> <TAB> <TAB> <TAB> <TAB> if type ( ah ) is not ActionHandle : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> raise ActionManagerError ( ""Bad argument type %s"" % str ( ah ) ) <TAB> <TAB> <TAB> <TAB> <TAB> ahs. add ( ah ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> raise ActionManagerError ( ""Bad argument type %s"" % str ( item ) ) <TAB> return ahs",False,"type(item) in (list, tuple, dict, set)",type(item) is ActionHandle,0.6513932347297668
|
||
|
3116,"def batch_reduce_implementation ( self, reduce_op, value_destination_pairs ) : <TAB> all_devices_match = _all_devices_match ( value_destination_pairs ) <TAB> if all_devices_match : <TAB> <TAB> return self. _batch_all_reduce ( <TAB> <TAB> <TAB> reduce_op, [ v [ 0 ] for v in value_destination_pairs ] <TAB> <TAB> ) <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> logging. log_first_n ( <TAB> <TAB> <TAB> <TAB> logging. WARN, <TAB> <TAB> <TAB> <TAB> ""Efficient batch_reduce is not supported if "" <TAB> <TAB> <TAB> <TAB> ""destinations are different."", <TAB> <TAB> <TAB> <TAB> 10, <TAB> <TAB> <TAB> ) <TAB> <TAB> return [ <TAB> <TAB> <TAB> self. reduce_implementation ( reduce_op, t, destinations = v ) <TAB> <TAB> <TAB> for t, v in value_destination_pairs <TAB> <TAB> ]",False,not all_devices_match,all_devices_match,0.6497336626052856
|
||
|
3117,"def test08_ExceptionTypes ( self ) : <TAB> self. assertTrue ( issubclass ( db. DBError, Exception ) ) <TAB> for i, j in db. __dict__. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. assertTrue ( issubclass ( j, db. DBError ), msg = i ) <TAB> <TAB> <TAB> if i not in ( ""DBKeyEmptyError"", ""DBNotFoundError"" ) : <TAB> <TAB> <TAB> <TAB> self. assertFalse ( issubclass ( j, KeyError ), msg = i ) <TAB> <TAB> self. assertTrue ( issubclass ( db. DBKeyEmptyError, KeyError ) ) <TAB> self. assertTrue ( issubclass ( db. DBNotFoundError, KeyError ) )",False,i.startswith('DB') and i.endswith('Error'),"i not in (_TAB_EMPTY_ERROR, _TABNotFoundError)",0.6477315425872803
|
||
|
3118,"def get_target_dimensions ( self ) : <TAB> width, height = self. engine. size <TAB> for operation in self. operations : <TAB> <TAB> if operation [ ""type"" ] == ""crop"" : <TAB> <TAB> <TAB> width = operation [ ""right"" ] - operation [ ""left"" ] <TAB> <TAB> <TAB> height = operation [ ""bottom"" ] - operation [ ""top"" ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> width = operation [ ""width"" ] <TAB> <TAB> <TAB> height = operation [ ""height"" ] <TAB> return ( width, height )",False,operation['type'] == 'resize',"operation['type""] == 'clamp'",0.660369873046875
|
||
|
3119,"def sort_dict ( od, d ) : <TAB> """"""Sort parameters (same order as xsd:sequence)"""""" <TAB> if isinstance ( od, dict ) : <TAB> <TAB> ret = Struct ( ) <TAB> <TAB> for k in od. keys ( ) : <TAB> <TAB> <TAB> v = d. get ( k ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if v is not None : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> v = sort_dict ( od [ k ], v ) <TAB> <TAB> <TAB> <TAB> elif isinstance ( v, list ) : <TAB> <TAB> <TAB> <TAB> <TAB> v = [ sort_dict ( od [ k ] [ 0 ], v1 ) for v1 in v ] <TAB> <TAB> <TAB> <TAB> ret [ k ] = v <TAB> <TAB> if hasattr ( od, ""namespaces"" ) : <TAB> <TAB> <TAB> ret. namespaces. update ( od. namespaces ) <TAB> <TAB> <TAB> ret. references. update ( od. references ) <TAB> <TAB> <TAB> ret. qualified = od. qualified <TAB> <TAB> return ret <TAB> else : <TAB> <TAB> return d",True,"isinstance(v, dict)","isinstance(v, dict)",0.653754472732544
|
||
|
3120,"def select ( self ) : <TAB> e = xlib. XEvent ( ) <TAB> while xlib. XPending ( self. _display ) : <TAB> <TAB> xlib. XNextEvent ( self. _display, e ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if xlib. XFilterEvent ( e, e. xany. window ) : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> try : <TAB> <TAB> <TAB> dispatch = self. _window_map [ e. xany. window ] <TAB> <TAB> except KeyError : <TAB> <TAB> <TAB> continue <TAB> <TAB> dispatch ( e )",False,"e.xany.type not in (xlib.KeyPress, xlib.KeyRelease)",e.xany.window,0.6514461636543274
|
||
|
3121,"def _find_port_mapping ( self, port_mappings ) : <TAB> port_mapping = None <TAB> if len ( port_mappings ) > 1 : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> for _port_mapping in port_mappings : <TAB> <TAB> <TAB> <TAB> if _port_mapping [ 0 ] == self. attr. docker_connect_port : <TAB> <TAB> <TAB> <TAB> <TAB> port_mapping = _port_mapping <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> else : <TAB> <TAB> <TAB> log. warning ( <TAB> <TAB> <TAB> <TAB> ""Don't know how to handle proxies to containers with multiple exposed ports. Arbitrarily choosing first. Please set 'docker_connect_port' in your config file to be more specific."" <TAB> <TAB> <TAB> ) <TAB> elif len ( port_mappings ) == 0 : <TAB> <TAB> log. warning ( ""No exposed ports to map! Images MUST EXPOSE"" ) <TAB> <TAB> return None <TAB> if port_mapping is None : <TAB> <TAB> <TAB> <TAB> port_mapping = port_mappings [ 0 ] <TAB> return port_mapping",False,self.attr.docker_connect_port is not None,self.attr.docker_connect_port,0.6572071313858032
|
||
|
3122,"def __init__ ( self, name ) : <TAB> if name not in self. themes : <TAB> <TAB> raise ThemeError ( ""no theme named %r found "" ""(missing theme.conf?)"" % name ) <TAB> self. name = name <TAB> tdir, tinfo = self. themes [ name ] <TAB> if tinfo is None : <TAB> <TAB> <TAB> <TAB> self. themedir = tdir <TAB> <TAB> self. themedir_created = False <TAB> else : <TAB> <TAB> <TAB> <TAB> self. themedir = tempfile. mkdtemp ( ""sxt"" ) <TAB> <TAB> self. themedir_created = True <TAB> <TAB> for name in tinfo. namelist ( ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> dirname = path. dirname ( name ) <TAB> <TAB> <TAB> if not path. isdir ( path. join ( self. themedir, dirname ) ) : <TAB> <TAB> <TAB> <TAB> os. makedirs ( path. join ( self. themedir, dirname ) ) <TAB> <TAB> <TAB> fp = open ( path. join ( self. themedir, name ), ""w"" ) <TAB> <TAB> <TAB> fp. write ( tinfo. read ( name ) ) <TAB> <TAB> <TAB> fp. close ( ) <TAB> self. themeconf = ConfigParser. RawConfigParser ( ) <TAB> self. themeconf. read ( path. join ( self. themedir, THEMECONF ) ) <TAB> try : <TAB> <TAB> inherit = self. themeconf. get ( ""theme"", ""inherit"" ) <TAB> except ConfigParser. NoOptionError : <TAB> <TAB> raise ThemeError ( 'theme %r doesn\'t have ""inherit"" setting' % name ) <TAB> if inherit == ""none"" : <TAB> <TAB> self. base = None <TAB> elif inherit not in self. themes : <TAB> <TAB> raise ThemeError ( ""no theme named %r found, inherited by %r"" % ( inherit, name ) ) <TAB>",False,name.endswith('/'),thedir_created,0.6482813358306885
|
||
|
3123,"def extract ( self ) : <TAB> try : <TAB> <TAB> self. stdin. write ( ""show status like 'Key_%';\n"" ) <TAB> <TAB> for line in readpipe ( self. stdout ) : <TAB> <TAB> <TAB> l = line. split ( ) <TAB> <TAB> <TAB> if len ( l ) < 2 : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if l [ 0 ] in self. vars : <TAB> <TAB> <TAB> <TAB> self. set2 [ l [ 0 ] ] = float ( l [ 1 ] ) <TAB> <TAB> for name in self. vars : <TAB> <TAB> <TAB> self. val [ name ] = ( self. set2 [ name ] - self. set1 [ name ] ) * 1.0 / elapsed <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. set1. update ( self. set2 ) <TAB> except IOError as e : <TAB> <TAB> if op. debug > 1 : <TAB> <TAB> <TAB> print ( ""%s: lost pipe to mysql, %s"" % ( self. filename, e ) ) <TAB> <TAB> for name in self. vars : <TAB> <TAB> <TAB> self. val [ name ] = - 1 <TAB> except Exception as e : <TAB> <TAB> if op. debug > 1 : <TAB> <TAB> <TAB> print ( ""%s: exception"" ( self. filename, e ) ) <TAB> <TAB> for name in self. vars : <TAB> <TAB> <TAB> self. val [ name ] = - 1",False,step == op.delay,self.set1 is not None,0.6596900224685669
|
||
|
3124,"def to_sympy ( self, expr, ** kwargs ) : <TAB> leaves = expr. leaves <TAB> if len ( leaves ) not in ( 1, 2 ) : <TAB> <TAB> return <TAB> sympy_cases = [ ] <TAB> for case in leaves [ 0 ]. leaves : <TAB> <TAB> if case. get_head_name ( )!= ""System`List"" : <TAB> <TAB> <TAB> return <TAB> <TAB> if len ( case. leaves )!= 2 : <TAB> <TAB> <TAB> return <TAB> <TAB> then, cond = case. leaves <TAB> <TAB> sympy_cond = None <TAB> <TAB> if isinstance ( cond, Symbol ) : <TAB> <TAB> <TAB> if cond == SymbolTrue : <TAB> <TAB> <TAB> <TAB> sympy_cond = True <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> sympy_cond = False <TAB> <TAB> if sympy_cond is None : <TAB> <TAB> <TAB> sympy_cond = cond. to_sympy ( ** kwargs ) <TAB> <TAB> <TAB> if not ( sympy_cond. is_Relational or sympy_cond. is_Boolean ) : <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> sympy_cases. append ( ( then. to_sympy ( ** kwargs ), sympy_cond ) ) <TAB> if len ( leaves ) == 2 : <TAB> <TAB> sympy_cases. append ( ( leaves [ 1 ]. to_sympy ( ** kwargs ), True ) ) <TAB> else : <TAB> <TAB> sympy_cases. append ( ( Integer ( 0 ). to_sympy ( ** kwargs ), True ) ) <TAB> return sympy. Piecewise ( * sympy_cases )",False,cond == SymbolFalse,"isinstance(cond, SymbolFalse)",0.6809082627296448
|
||
|
3125,"def brightness_func ( args ) : <TAB> device = _get_device_from_filter ( args ) <TAB> if args. set is None : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> print ( str ( device. brightness ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> print ( ""Brightness: {0}%"". format ( device. brightness ) ) <TAB> else : <TAB> <TAB> brightness_value = float ( _clamp_u8 ( args. set ) ) <TAB> <TAB> if not args. raw : <TAB> <TAB> <TAB> print ( ""Setting brightness to {0}%"". format ( brightness_value ) ) <TAB> <TAB> device. brightness = brightness_value",True,args.raw,args.raw,0.66314297914505
|
||
|
3126,"def _get_cache ( ) : <TAB> if _ST3 : <TAB> <TAB> cache_path = os. path. normpath ( os. path. join ( sublime. cache_path ( ), ""LaTeXTools"" ) ) <TAB> else : <TAB> <TAB> cache_path = os. path. normpath ( os. path. join ( sublime. packages_path ( ), ""User"" ) ) <TAB> pkg_cache_file = os. path. normpath ( <TAB> <TAB> os. path. join ( <TAB> <TAB> <TAB> cache_path, ""pkg_cache.cache"" if _ST3 else ""latextools_pkg_cache.cache"" <TAB> <TAB> ) <TAB> ) <TAB> cache = None <TAB> if not os. path. exists ( pkg_cache_file ) : <TAB> <TAB> gen_cache = sublime. ok_cancel_dialog ( <TAB> <TAB> <TAB> ""Cache files for installed packages, "" <TAB> <TAB> <TAB> ""classes and bibliographystyles do not exists, "" <TAB> <TAB> <TAB> ""would you like to generate it? After generating complete, "" <TAB> <TAB> <TAB> ""please re-run this completion action!"" <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> sublime. active_window ( ). run_command ( ""latex_gen_pkg_cache"" ) <TAB> else : <TAB> <TAB> with open ( pkg_cache_file ) as f : <TAB> <TAB> <TAB> cache = json. load ( f ) <TAB> return cache",False,gen_cache,_ST3,0.661515474319458
|
||
|
3127,"def _update_brush_header ( self, modified = False ) : <TAB> """"""Updates the header strip with the current brush's icon and name"""""" <TAB> mb = None <TAB> if self. app : <TAB> <TAB> mb = self. app. brushmanager. selected_brush <TAB> <TAB> if mb : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> name = mb. name. replace ( ""_"", "" "" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> name = C_ ( <TAB> <TAB> <TAB> <TAB> ""brush settings editor: header: fallback name"", <TAB> <TAB> <TAB> <TAB> ""(Unnamed brush)"", <TAB> <TAB> <TAB> ) <TAB> else : <TAB> <TAB> name = ""(Not running as part of MyPaint)"" <TAB> if modified : <TAB> <TAB> name = C_ ( <TAB> <TAB> <TAB> ""brush settings editor: header: is-modified hint"", <TAB> <TAB> <TAB> ""{brush_name} [unsaved]"", <TAB> <TAB> ). format ( <TAB> <TAB> <TAB> brush_name = name, <TAB> <TAB> ) <TAB> label = self. _builder. get_object ( ""brush_name_label"" ) <TAB> label. set_text ( name ) <TAB> <TAB> image = self. _builder. get_object ( ""brush_preview_image"" ) <TAB> w = image. get_allocated_width ( ) <TAB> h = image. get_allocated_height ( ) <TAB> if mb : <TAB> <TAB> pixbuf = mb. preview <TAB> else : <TAB> <TAB> pixbuf = None <TAB> if pixbuf : <TAB> <TAB> pixbuf = pixbuf. scale_simple ( w, h, GdkPixbuf. InterpType. BILINEAR ) <TAB> if not pixbuf : <TAB> <TAB> pixbuf = GdkPixbuf. Pixbuf. new ( GdkPixbuf. Colorspace. RGB, True, 8, w, h ) <TAB> image.",True,mb.name,mb.name,0.6675001382827759
|
||
|
3128,"def collector_data ( self ) : <TAB> """"""collector data"""""" <TAB> logger. info ( ""start collector yahoo data......"" ) <TAB> stock_list = self. stock_list <TAB> for i in range ( self. _max_collector_count ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> break <TAB> <TAB> logger. info ( f""getting data: {i+1}"" ) <TAB> <TAB> stock_list = self. _collector ( stock_list ) <TAB> <TAB> logger. info ( f""{i+1} finish."" ) <TAB> for _symbol, _df_list in self. _mini_symbol_map. items ( ) : <TAB> <TAB> self. save_stock ( <TAB> <TAB> <TAB> _symbol, <TAB> <TAB> <TAB> pd. concat ( _df_list, sort = False ) <TAB> <TAB> <TAB>. drop_duplicates ( [ ""date"" ] ) <TAB> <TAB> <TAB>. sort_values ( [ ""date"" ] ), <TAB> <TAB> ) <TAB> if self. _mini_symbol_map : <TAB> <TAB> logger. warning ( <TAB> <TAB> <TAB> f""less than {self.min_numbers_trading} stock list: {list(self._mini_symbol_map.keys())}"" <TAB> <TAB> ) <TAB> logger. info ( f""total {len(self.stock_list)}, error: {len(set(stock_list))}"" ) <TAB> self. download_index_data ( )",False,not stock_list,self.has_data_for_item(i),0.6725294589996338
|
||
|
3129,"def __next__ ( self ) : <TAB> if len ( self ) == 0 : <TAB> <TAB> raise StopIteration <TAB> index = self. index <TAB> if self. data [ index : ]. startswith ( self. UTF16_START ) : <TAB> <TAB> match = self. UTF16_END. search ( self. data [ index : ] ) <TAB> <TAB> if match is None : <TAB> <TAB> <TAB> raise ValueError ( ""Invalid token: %r"" % ( self. data [ index : ] ) ) <TAB> <TAB> token = self. data [ index : index + match. end ( ) ] <TAB> <TAB> self. index += match. end ( ) <TAB> else : <TAB> <TAB> match = self. DIVIDER. search ( self. data [ index : ] ) <TAB> <TAB> if match is None : <TAB> <TAB> <TAB> token = self. data [ index : ] <TAB> <TAB> <TAB> self. index = len ( self. data ) <TAB> <TAB> else : <TAB> <TAB> <TAB> token = self. data [ index : index + match. start ( ) ] <TAB> <TAB> <TAB> self. index += match. end ( ) <TAB> <TAB> <TAB> if token == b"""" : <TAB> <TAB> <TAB> <TAB> return self. __next__ ( ) <TAB> for token_type in EngineToken : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return token, token_type <TAB> raise ValueError ( ""Unknown token: %r"" % ( token ) )",False,token_type.value.search(token),token_type in self.data[token:],0.6484460830688477
|
||
|
3130,"def find_reentrancies ( self ) : <TAB> result = defaultdict ( set ) <TAB> for contract in self. contracts : <TAB> <TAB> for f in contract. functions_and_modifiers_declared : <TAB> <TAB> <TAB> for node in f. nodes : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> if node. context [ self. KEY ]. calls : <TAB> <TAB> <TAB> <TAB> <TAB> if not any ( n!= node for n in node. context [ self. KEY ]. calls ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> finding_key = FindingKey ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> function = node. function, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> calls = to_hashable ( node. context [ self. KEY ]. calls ), <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> send_eth = to_hashable ( node. context [ self. KEY ]. send_eth ), <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> finding_vars = { <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> FindingValue ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> e, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> e. node, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> tuple ( sorted ( nodes, key = lambda x : x. node_id ) ), <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for",False,self.KEY not in node.context,self.KEY not in result,0.6578574776649475
|
||
|
3131,"def redirect_aware_commmunicate ( p, sys = _sys ) : <TAB> """"""Variant of process.communicate that works with in process I/O redirection."""""" <TAB> assert sys is not None <TAB> out, err = p. communicate ( ) <TAB> if redirecting_io ( sys = sys ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> out = unicodify ( out ) <TAB> <TAB> <TAB> sys. stdout. write ( out ) <TAB> <TAB> <TAB> out = None <TAB> <TAB> if err : <TAB> <TAB> <TAB> err = unicodify ( err ) <TAB> <TAB> <TAB> sys. stderr. write ( err ) <TAB> <TAB> <TAB> err = None <TAB> return out, err",True,out,out,0.6974935531616211
|
||
|
3132,"def match_readline ( self, req, body, sizes ) : <TAB> data = self. szread ( req. body. readline, sizes ) <TAB> count = 1000 <TAB> while body : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise AssertionError ( ""Invalid data read: %r"" % data ) <TAB> <TAB> if b""\n"" in data [ : - 1 ] : <TAB> <TAB> <TAB> raise AssertionError ( ""Embedded new line: %r"" % data ) <TAB> <TAB> body = body [ len ( data ) : ] <TAB> <TAB> data = self. szread ( req. body. readline, sizes ) <TAB> <TAB> if not data : <TAB> <TAB> <TAB> count -= 1 <TAB> <TAB> if count <= 0 : <TAB> <TAB> <TAB> raise AssertionError ( ""Apparent unexpected EOF"" ) <TAB> if body : <TAB> <TAB> raise AssertionError ( ""Failed to read entire body: %r"" % body ) <TAB> elif data : <TAB> <TAB> raise AssertionError ( ""Read beyond expected body: %r"" % data ) <TAB> data = req. body. readline ( sizes ( ) ) <TAB> if data : <TAB> <TAB> raise AssertionError ( ""Read data after body finished: %r"" % data )",False,body[:len(data)] != data,data.len(data) < count,0.6537233591079712
|
||
|
3133,"def __split ( self, line ) : <TAB> if not line. endswith ( ""\n"" ) : <TAB> <TAB> self. partial_buffer += line <TAB> <TAB> return None, None <TAB> line = ""%s%s"" % ( self. partial_buffer, line ) <TAB> self. partial_buffer = """" <TAB> line = line. strip ( ) <TAB> if not line. startswith ( ""data."" ) : <TAB> <TAB> line_parts = line. split ( "" "" ) <TAB> <TAB> if len ( line_parts ) > 1 : <TAB> <TAB> <TAB> if line_parts [ 1 ] == ""starting,"" : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> elif line_parts [ 1 ] == ""finished"" : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> self. concurrency -= 1 <TAB> <TAB> <TAB> elif set ( line_parts [ 1 : 5 ] ) == { ""Test"", ""name"", ""for"", ""ID"" } : <TAB> <TAB> <TAB> <TAB> test_id = line_parts [ 5 ] [ : - 1 ] <TAB> <TAB> <TAB> <TAB> test_name = "" "". join ( line_parts [ 6 : ] ) <TAB> <TAB> <TAB> <TAB> self. test_names [ test_id ] = test_name <TAB> <TAB> <TAB> <TAB> self. log. debug ( ""Recognized test id %s => %s"", test_id, test_name ) <TAB> <TAB> return None, None <TAB> worker_id = line [ : line. find ( "" "" ) ] <TAB> line = line [ line. find ( "" "" ) : ] <TAB> data_fields = line. split ( self. DELIMITER ) <TAB> if not data_fields [ 1 ]. strip ( ). isdigit ( ) : <TAB> <TAB> return None, None <TAB> if len ( data_fields ) < max ( self. idx. values ( ) ) : <TAB>",False,self.concurrency > 0,self.conconverged,0.6566463708877563
|
||
|
3134,"def method_for_doctype ( doctype ) : <TAB> method = ""xhtml"" <TAB> if doctype : <TAB> <TAB> if doctype. startswith ( ""html"" ) : <TAB> <TAB> <TAB> method = ""html"" <TAB> <TAB> elif doctype. startswith ( ""xhtml"" ) : <TAB> <TAB> <TAB> method = ""xhtml"" <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> method = ""xml"" <TAB> <TAB> else : <TAB> <TAB> <TAB> method = ""xhtml"" <TAB> return method",False,doctype.startswith('svg'),doctype.startswith(xml),0.6676748394966125
|
||
|
3135,"def from_obj ( cls, py_obj ) : <TAB> if not isinstance ( py_obj, Image ) : <TAB> <TAB> raise TypeError ( ""py_obj must be a wandb.Image"" ) <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> box_keys = list ( py_obj. _boxes. keys ( ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> box_keys = [ ] <TAB> <TAB> if hasattr ( py_obj, ""masks"" ) and py_obj. masks : <TAB> <TAB> <TAB> mask_keys = list ( py_obj. masks. keys ( ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> mask_keys = [ ] <TAB> <TAB> return cls ( box_keys, mask_keys )",False,"hasattr(py_obj, '_boxes') and py_obj._boxes","hasattr(py_obj, '_boxes')",0.6506568789482117
|
||
|
3136,"def check_result ( got ) : <TAB> try : <TAB> <TAB> self. assertLen ( got, 2 ) <TAB> <TAB> <TAB> <TAB> for item in got : <TAB> <TAB> <TAB> self. assertIn ( constants. PREDICTIONS_KEY, item ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. assertIn ( ""model1"", item [ constants. PREDICTIONS_KEY ] ) <TAB> <TAB> <TAB> <TAB> self. assertIn ( ""model2"", item [ constants. PREDICTIONS_KEY ] ) <TAB> <TAB> <TAB> <TAB> if multi_output : <TAB> <TAB> <TAB> <TAB> <TAB> self. assertIn ( ""Identity"", item [ constants. PREDICTIONS_KEY ] [ ""model1"" ] ) <TAB> <TAB> <TAB> <TAB> <TAB> self. assertIn ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""Identity_1"", item [ constants. PREDICTIONS_KEY ] [ ""model1"" ] <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> elif multi_output : <TAB> <TAB> <TAB> <TAB> self. assertIn ( ""Identity"", item [ constants. PREDICTIONS_KEY ] ) <TAB> <TAB> <TAB> <TAB> self. assertIn ( ""Identity_1"", item [ constants. PREDICTIONS_KEY ] ) <TAB> except AssertionError as err : <TAB> <TAB> raise util. BeamAssertException ( err )",False,multi_model,model2,0.6727745532989502
|
||
|
3137,"def _train_one_epoch ( self, epoch ) : <TAB> self. model. train ( ) <TAB> meters = AverageMeterGroup ( ) <TAB> for step, ( ( trn_X, trn_y ), ( val_X, val_y ) ) in enumerate ( <TAB> <TAB> zip ( self. train_loader, self. valid_loader ) <TAB> ) : <TAB> <TAB> trn_X, trn_y = trn_X. to ( self. device ), trn_y. to ( self. device ) <TAB> <TAB> val_X, val_y = val_X. to ( self. device ), val_y. to ( self. device ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for _, module in self. nas_modules : <TAB> <TAB> <TAB> <TAB> module. resample ( ) <TAB> <TAB> <TAB> self. ctrl_optim. zero_grad ( ) <TAB> <TAB> <TAB> logits, loss = self. _logits_and_loss ( val_X, val_y ) <TAB> <TAB> <TAB> loss. backward ( ) <TAB> <TAB> <TAB> for _, module in self. nas_modules : <TAB> <TAB> <TAB> <TAB> module. finalize_grad ( ) <TAB> <TAB> <TAB> self. ctrl_optim. step ( ) <TAB> <TAB> <TAB> <TAB> for _, module in self. nas_modules : <TAB> <TAB> <TAB> module. resample ( ) <TAB> <TAB> self. optimizer. zero_grad ( ) <TAB> <TAB> logits, loss = self. _logits_and_loss ( trn_X, trn_y ) <TAB> <TAB> loss. backward ( ) <TAB> <TAB> self. optimizer. step ( ) <TAB> <TAB> metrics = self. metrics ( logits, trn_y ) <TAB> <TAB> metrics [ ""loss"" ] = loss. item ( ) <TAB> <TAB> meters. update ( metrics ) <TAB> <TAB> if self. log_frequency is",False,epoch >= self.warmup_epochs,self.ctrl_optim is not None,0.6621540784835815
|
||
|
3138,"def spans_score ( gold_spans, system_spans ) : <TAB> correct, gi, si = 0, 0, 0 <TAB> while gi < len ( gold_spans ) and si < len ( system_spans ) : <TAB> <TAB> if system_spans [ si ]. start < gold_spans [ gi ]. start : <TAB> <TAB> <TAB> si += 1 <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> gi += 1 <TAB> <TAB> else : <TAB> <TAB> <TAB> correct += gold_spans [ gi ]. end == system_spans [ si ]. end <TAB> <TAB> <TAB> si += 1 <TAB> <TAB> <TAB> gi += 1 <TAB> return Score ( len ( gold_spans ), len ( system_spans ), correct )",False,gold_spans[gi].start < system_spans[si].start,system_spans[si].end < gold_spans[si].end,0.6611117124557495
|
||
|
3139,"def main ( ) : <TAB> parser = argparse. ArgumentParser ( ) <TAB> parser. add_argument ( <TAB> <TAB> ""-D"", ""--debug"", help = ""Enable debug logging"", action = ""store_true"" <TAB> ) <TAB> parser. add_argument ( <TAB> <TAB> ""--version"", <TAB> <TAB> action = ""version"", <TAB> <TAB> help = ""show program version"", <TAB> <TAB> version = version. __version__, <TAB> ) <TAB> parser. add_argument ( ""--site"", help = ""backup site"", required = False ) <TAB> parser. add_argument ( <TAB> <TAB> ""--key-id"", <TAB> <TAB> help = ""key alias as used with encryption_key_id configuration directive"", <TAB> <TAB> required = True, <TAB> ) <TAB> parser. add_argument ( <TAB> <TAB> ""--bits"", <TAB> <TAB> help = ""length of the generated key in bits, default %(default)d"", <TAB> <TAB> default = 3072, <TAB> <TAB> type = int, <TAB> ) <TAB> parser. add_argument ( <TAB> <TAB> ""--config"", <TAB> <TAB> help = ""configuration file to store the keys in"", <TAB> <TAB> default = os. environ. get ( ""PGHOARD_CONFIG"" ), <TAB> ) <TAB> args = parser. parse_args ( ) <TAB> logutil. configure_logging ( level = logging. DEBUG if args. debug else logging. INFO ) <TAB> rsa_private_key, rsa_public_key = create_keys ( args. bits ) <TAB> try : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return save_keys ( <TAB> <TAB> <TAB> <TAB> args. config, args. site, args. key_id, rsa_private_key, rsa_public_key <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return show_key_config ( <TAB> <TAB> <TAB> <TAB> args. site, args.",True,args.config,args.config,0.6580674648284912
|
||
|
3140,"def patched_toml ( ) : <TAB> parser = configparser. ConfigParser ( ) <TAB> parser. read ( SETUP_CFG ) <TAB> requirements = parser. get ( ""options"", ""install_requires"" ). splitlines ( ) <TAB> requirements = [ r. split ( ""#"" ) [ 0 ]. strip ( ) for r in requirements if r ] <TAB> with open ( PYPROJECT_TOML ) as f : <TAB> <TAB> original_toml = f. read ( ) <TAB> toml = tomlkit. parse ( original_toml ) <TAB> <TAB> if ""--add"" in sys. argv : <TAB> <TAB> for item in sys. argv [ sys. argv. index ( ""--add"" ) + 1 : ] : <TAB> <TAB> <TAB> if item. startswith ( ""-"" ) : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> EXTRA_REQS. append ( item ) <TAB> for item in EXTRA_REQS : <TAB> <TAB> _base = re. split ( ""<|>|="", item, maxsplit = 1 ) [ 0 ] <TAB> <TAB> for r in requirements : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> requirements. remove ( r ) <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> if _base. lower ( ). startswith ( ""pyqt5"" ) : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> i = next ( x for x in requirements if x. startswith ( ""PySide"" ) ) <TAB> <TAB> <TAB> <TAB> requirements. remove ( i ) <TAB> <TAB> <TAB> except StopIteration : <TAB> <TAB> <TAB> <TAB> pass <TAB> requirements += EXTRA_REQS <TAB> toml [ ""tool"" ] [ ""briefcase"" ] [ ""app"" ] [ APP ] [ ""requires"" ] = requirements <TAB> toml [ ""tool"" ] [ ""briefcase"" ] [ ""version"" ] = VERSION <TAB> print ( ""patching pyroject.toml to version: "", VERSION ) <TAB> print ( <TAB> <",False,r.startswith(_base),r.startswith(r),0.656227707862854
|
||
|
3141,"def save ( self, commit = True ) : <TAB> """"""Custom save method."""""" <TAB> alias = super ( AliasForm, self ). save ( commit = False ) <TAB> if self. cleaned_data. get ( ""random_address"" ) : <TAB> <TAB> alias. address = ""{}@{}"". format ( Alias. generate_random_address ( ), alias. domain ) <TAB> else : <TAB> <TAB> local_part, domname = split_mailbox ( self. cleaned_data [ ""address"" ] ) <TAB> <TAB> alias. domain = Domain. objects. get ( name = domname ) <TAB> if commit : <TAB> <TAB> alias. save ( ) <TAB> <TAB> address_list = [ <TAB> <TAB> <TAB> value <TAB> <TAB> <TAB> for field, value in self. cleaned_data. items ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> ] <TAB> <TAB> alias. set_recipients ( address_list ) <TAB> return alias",False,field.startswith('recipients') and value,address_list,0.6434787511825562
|
||
|
3142,"def extract_domains ( self, resp ) : <TAB> link_regx2 = re. compile ( '<span class="" fz-.*? fw-m fc-12th wr-bw.*?"">(.*?)</span>' ) <TAB> link_regx = re. compile ( <TAB> <TAB> '<span class=""txt""><span class="" cite fw-xl fz-15px"">(.*?)</span>' <TAB> ) <TAB> links_list = [ ] <TAB> try : <TAB> <TAB> links = link_regx. findall ( resp ) <TAB> <TAB> links2 = link_regx2. findall ( resp ) <TAB> <TAB> links_list = links + links2 <TAB> <TAB> for link in links_list : <TAB> <TAB> <TAB> link = re. sub ( ""<(\/)?b>"", """", link ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> link = ""http://"" + link <TAB> <TAB> <TAB> subdomain = urlparse. urlparse ( link ). netloc <TAB> <TAB> <TAB> if not subdomain. endswith ( self. domain ) : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if ( <TAB> <TAB> <TAB> <TAB> subdomain <TAB> <TAB> <TAB> <TAB> and subdomain not in self. subdomains <TAB> <TAB> <TAB> <TAB> and subdomain!= self. domain <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> if self. verbose : <TAB> <TAB> <TAB> <TAB> <TAB> self. print_ ( ""%s%s: %s%s"" % ( R, self. engine_name, W, subdomain ) ) <TAB> <TAB> <TAB> <TAB> self. subdomains. append ( subdomain. strip ( ) ) <TAB> except Exception : <TAB> <TAB> pass <TAB> return links_list",False,not link.startswith('http'),self.domain,0.65171217918396
|
||
|
3143,"def get_dummy_ray_distributed_retriever ( <TAB> self, init_retrieval : bool ) -> RagRayDistributedRetriever : <TAB> <TAB> <TAB> <TAB> ray. init ( local_mode = True ) <TAB> config = RagConfig ( <TAB> <TAB> retrieval_vector_size = self. retrieval_vector_size, <TAB> <TAB> question_encoder = DPRConfig ( ). to_dict ( ), <TAB> <TAB> generator = BartConfig ( ). to_dict ( ), <TAB> ) <TAB> remote_cls = ray. remote ( RayRetriever ) <TAB> workers = [ remote_cls. remote ( ) for _ in range ( 1 ) ] <TAB> with patch ( <TAB> <TAB> ""transformers.models.rag.retrieval_rag.load_dataset"" <TAB> ) as mock_load_dataset : <TAB> <TAB> mock_load_dataset. return_value = self. get_dummy_dataset ( ) <TAB> <TAB> retriever = RagRayDistributedRetriever ( <TAB> <TAB> <TAB> config, <TAB> <TAB> <TAB> question_encoder_tokenizer = self. get_dpr_tokenizer ( ), <TAB> <TAB> <TAB> generator_tokenizer = self. get_bart_tokenizer ( ), <TAB> <TAB> <TAB> retrieval_workers = workers, <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> retriever. init_retrieval ( ) <TAB> return retriever",True,init_retrieval,init_retrieval,0.6591958999633789
|
||
|
3144,"def _find_logs ( self, compile_workunit ) : <TAB> """"""Finds all logs under the given workunit."""""" <TAB> for idx, workunit in enumerate ( compile_workunit. children ) : <TAB> <TAB> for output_name, outpath in workunit. output_paths ( ). items ( ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> yield idx, workunit. name, output_name, outpath",False,"output_name in ('stdout', 'stderr')",output_name,0.6517871618270874
|
||
|
3145,"def result_item ( self, item, obj, field_name, row ) : <TAB> if ( <TAB> <TAB> self. list_editable <TAB> <TAB> and item. field <TAB> <TAB> and item. field. editable <TAB> <TAB> and ( field_name in self. list_editable ) <TAB> ) : <TAB> <TAB> pk = getattr ( obj, obj. _meta. pk. attname ) <TAB> <TAB> field_label = label_for_field ( <TAB> <TAB> <TAB> field_name, obj, model_admin = self. admin_view, return_attr = False <TAB> <TAB> ) <TAB> <TAB> item. wraps. insert ( 0, '<span class=""editable-field"">%s</span>' ) <TAB> <TAB> item. btns. append ( <TAB> <TAB> <TAB> ( <TAB> <TAB> <TAB> <TAB> '<a class=""editable-handler"" title=""%s"" data-editable-field=""%s"" data-editable-loadurl=""%s"">' <TAB> <TAB> <TAB> <TAB> + '<i class=""icon-edit""></i></a>' <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> % ( <TAB> <TAB> <TAB> <TAB> _ ( u""Enter %s"" ) % field_label, <TAB> <TAB> <TAB> <TAB> field_name, <TAB> <TAB> <TAB> <TAB> self. admin_view. model_admin_url ( ""patch"", pk ) + ""?fields="" + field_name, <TAB> <TAB> <TAB> ) <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. editable_need_fields [ field_name ] = item. field <TAB> return item",False,field_name not in self.editable_need_fields,field_name in self.editable_need_fields,0.6501064300537109
|
||
|
3146,"def set_new_instance_id ( apps, source, new_id ) : <TAB> """"""This methods adds an instance_id in cases where there was not one before"""""" <TAB> from django. conf import settings <TAB> id_from_settings = getattr ( settings, ""{}_INSTANCE_ID_VAR"". format ( source. upper ( ) ) ) <TAB> if id_from_settings!= new_id : <TAB> <TAB> <TAB> <TAB> logger. warn ( ""You have an instance ID set for {}, not migrating"". format ( source ) ) <TAB> <TAB> return <TAB> logger. debug ( ""Migrating inventory instance_id for {} to {}"". format ( source, new_id ) ) <TAB> Host = apps. get_model ( ""main"", ""Host"" ) <TAB> modified_ct = 0 <TAB> for host in Host. objects. filter ( inventory_sources__source = source ). iterator ( ) : <TAB> <TAB> new_id_value = _get_instance_id_for_upgrade ( host, new_id ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> host. instance_id = new_id_value <TAB> <TAB> host. save ( update_fields = [ ""instance_id"" ] ) <TAB> <TAB> modified_ct += 1 <TAB> if modified_ct : <TAB> <TAB> logger. info ( <TAB> <TAB> <TAB> ""Migrated instance ID for {} hosts imported by {} source"". format ( <TAB> <TAB> <TAB> <TAB> modified_ct, source <TAB> <TAB> <TAB> ) <TAB> <TAB> )",False,not new_id_value,new_id_value is None,0.6541956663131714
|
||
|
3147,"def __init__ ( self, spec ) : <TAB> self. spec = spec <TAB> self. isIOS = False <TAB> <TAB> <TAB> <TAB> <TAB> self. xcode_settings = { } <TAB> configs = spec [ ""configurations"" ] <TAB> for configname, config in configs. iteritems ( ) : <TAB> <TAB> self. xcode_settings [ configname ] = config. get ( ""xcode_settings"", { } ) <TAB> <TAB> self. _ConvertConditionalKeys ( configname ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. isIOS = True <TAB> <TAB> self. configname = None <TAB> <TAB> self. library_re = re. compile ( r""^lib([^/]+)\.(a|dylib)$"" )",False,"self.xcode_settings[configname].get('IPHONEOS_DEPLOYMENT_TARGET', None)",spec.get('has_key'),0.6572945713996887
|
||
|
3148,"def one_line_description ( self ) : <TAB> MAX_LINE_LENGTH = 120 <TAB> desc = util. remove_html_tags ( self. description or """" ) <TAB> desc = re. sub ( ""\s+"", "" "", desc ). strip ( ) <TAB> if not desc : <TAB> <TAB> return _ ( ""No description available"" ) <TAB> else : <TAB> <TAB> <TAB> <TAB> desc = util. convert_bytes ( desc ). strip ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return desc [ : MAX_LINE_LENGTH ] + ""..."" <TAB> <TAB> else : <TAB> <TAB> <TAB> return desc",True,len(desc) > MAX_LINE_LENGTH,len(desc) > MAX_LINE_LENGTH,0.6557559967041016
|
||
|
3149,"def _get_rule_from_ctx ( self, ctx : ""Context"" ) -> PermState : <TAB> author = ctx. author <TAB> guild = ctx. guild <TAB> if ctx. guild is None : <TAB> <TAB> <TAB> <TAB> rule = self. _global_rules. get ( author. id ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return rule <TAB> <TAB> return self. get_rule ( self. DEFAULT, self. GLOBAL ) <TAB> rules_chain = [ self. _global_rules ] <TAB> guild_rules = self. _guild_rules. get ( ctx. guild. id ) <TAB> if guild_rules : <TAB> <TAB> rules_chain. append ( guild_rules ) <TAB> channels = [ ] <TAB> if author. voice is not None : <TAB> <TAB> channels. append ( author. voice. channel ) <TAB> channels. append ( ctx. channel ) <TAB> category = ctx. channel. category <TAB> if category is not None : <TAB> <TAB> channels. append ( category ) <TAB> <TAB> author_roles = reversed ( author. roles [ 1 : ] ) <TAB> model_chain = [ author, * channels, * author_roles, guild ] <TAB> for rules in rules_chain : <TAB> <TAB> for model in model_chain : <TAB> <TAB> <TAB> rule = rules. get ( model. id ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return rule <TAB> <TAB> del model_chain [ - 1 ] <TAB> default_rule = self. get_rule ( self. DEFAULT, guild. id ) <TAB> if default_rule is PermState. NORMAL : <TAB> <TAB> default_rule = self. get_rule ( self. DEFAULT, self. GLOBAL ) <TAB> return default_rule",False,rule is not None,rule,0.6613626480102539
|
||
|
3150,"def _str_param_list ( self, name ) : <TAB> out = [ ] <TAB> if self [ name ] : <TAB> <TAB> out += self. _str_header ( name ) <TAB> <TAB> for param in self [ name ] : <TAB> <TAB> <TAB> parts = [ ] <TAB> <TAB> <TAB> if param. name : <TAB> <TAB> <TAB> <TAB> parts. append ( param. name ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> parts. append ( param. type ) <TAB> <TAB> <TAB> out += [ "" : "". join ( parts ) ] <TAB> <TAB> <TAB> if param. desc and """". join ( param. desc ). strip ( ) : <TAB> <TAB> <TAB> <TAB> out += self. _str_indent ( param. desc ) <TAB> <TAB> out += [ """" ] <TAB> return out",False,param.type,param.type and param.type,0.6665401458740234
|
||
|
3151,"def current_storage_dir ( self ) : <TAB> if config. SERVER_MODE : <TAB> <TAB> file = self. bfile <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> file = self. bfile. decode ( ""utf-8"" ) <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> path = get_complete_file_path ( file ) <TAB> <TAB> path = file if path is None else path <TAB> <TAB> if IS_WIN : <TAB> <TAB> <TAB> path = os. path. realpath ( path ) <TAB> <TAB> storage_directory = os. path. basename ( get_storage_directory ( ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> start = path. index ( storage_directory ) <TAB> <TAB> <TAB> end = start + ( len ( storage_directory ) ) <TAB> <TAB> <TAB> last_dir = os. path. dirname ( path [ end : ] ) <TAB> <TAB> else : <TAB> <TAB> <TAB> last_dir = file <TAB> <TAB> last_dir = replace_path_for_win ( last_dir ) <TAB> <TAB> return None if hasattr ( self, ""is_import"" ) and self. is_import else last_dir <TAB> return None",True,storage_directory in path,storage_directory in path,0.6578084230422974
|
||
|
3152,"def get_current_connections ( session ) : <TAB> """"""Retrieves open connections using the the given session"""""" <TAB> <TAB> res = session. sql ( ""SHOW PROCESSLIST"" ). execute ( ) <TAB> rows = res. fetch_all ( ) <TAB> connections = { } <TAB> for row in rows : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> connections [ row. get_string ( ""User"" ) ] = [ row. get_string ( ""Host"" ) ] <TAB> <TAB> else : <TAB> <TAB> <TAB> connections [ row. get_string ( ""User"" ) ]. append ( row. get_string ( ""Host"" ) ) <TAB> return connections",False,row.get_string('User') not in connections,"row.get_string( ""Host') in connections",0.6525547504425049
|
||
|
3153,"def _get_between ( content, start, end = None ) : <TAB> should_yield = False <TAB> for line in content. split ( ""\n"" ) : <TAB> <TAB> if start in line : <TAB> <TAB> <TAB> should_yield = True <TAB> <TAB> <TAB> continue <TAB> <TAB> if end and end in line : <TAB> <TAB> <TAB> return <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> yield line. strip ( ). split ( "" "" ) [ 0 ]",False,should_yield and line,should_yield,0.6550772190093994
|
||
|
3154,"def downstream_recv ( self, data ) : <TAB> if self. decryptor : <TAB> <TAB> while len ( data ) : <TAB> <TAB> <TAB> if not self. chunk_len : <TAB> <TAB> <TAB> <TAB> if self. need_validation : <TAB> <TAB> <TAB> <TAB> <TAB> if len ( data ) < 16 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> <TAB> <TAB> vblock = data. read ( 16 ) <TAB> <TAB> <TAB> <TAB> <TAB> self. update_decryptor ( vblock ) <TAB> <TAB> <TAB> <TAB> <TAB> self. need_validation = False <TAB> <TAB> <TAB> <TAB> <TAB> self. dec_buffer. write_to ( self. upstream ) <TAB> <TAB> <TAB> <TAB> if len ( data ) < 4 : <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> raw_chunk_len = self. decryptor. decrypt ( data. read ( 4 ) ) <TAB> <TAB> <TAB> <TAB> ( self. chunk_len, ) = struct. unpack ( ""<I"", raw_chunk_len ) <TAB> <TAB> <TAB> if not len ( data ) : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> nr, nw = data. write_to ( <TAB> <TAB> <TAB> <TAB> self. dec_buffer, modificator = self. decryptor. decrypt, n = self. chunk_len <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> self. chunk_len -= nr <TAB> <TAB> <TAB> if not self. chunk_len : <TAB> <TAB> <TAB> <TAB> self. need_validation = True <TAB> elif self. kex ( data ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. upstream_recv ( self. up_buffer ) <TAB> <TAB> if len ( data",False,len(self.up_buffer),self.up_buffer,0.6499927043914795
|
||
|
3155,"def iter ( self ) : <TAB> if isinstance ( self. validator, dict ) : <TAB> <TAB> if not isinstance ( self. data, dict ) : <TAB> <TAB> <TAB> yield Result ( False, ""is not a dictionary."", level = 1 ) <TAB> <TAB> else : <TAB> <TAB> <TAB> for i in self. iter_dict ( ) : <TAB> <TAB> <TAB> <TAB> yield i <TAB> elif isinstance ( self. validator, list ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> yield Result ( False, ""is an empty list"", data = self. data ) <TAB> <TAB> if len ( self. validator ) > 0 : <TAB> <TAB> <TAB> for key, value in enumerate ( self. data ) : <TAB> <TAB> <TAB> <TAB> for v in Schema ( self. validator [ 0 ] ). validate ( value ) : <TAB> <TAB> <TAB> <TAB> <TAB> yield Result ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> v. status, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> v. error, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> path = ( str ( key ) + ( ""."" + v. path if v. path else """" ) ), <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> level = v. level, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> data = value, <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> elif isinstance ( self. validator, Directory ) : <TAB> <TAB> for v in self. validator. validate ( self. data ) : <TAB> <TAB> <TAB> yield v <TAB> elif isinstance ( self. validator, Or ) : <TAB> <TAB> for i in self. iter_or ( ) : <TAB> <TAB> <TAB> yield i",True,len(self.data) == 0,len(self.data) == 0,0.6528366208076477
|
||
|
3156,"def _select_optimizer_cls ( self ) -> base. OptCls : <TAB> <TAB> assert self. budget is not None <TAB> optimClass : base. OptCls <TAB> if self. has_noise and ( <TAB> <TAB> self. has_discrete_not_softmax or not self. parametrization. descriptors. metrizable <TAB> ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> optimClass = RecombiningPortfolioOptimisticNoisyDiscreteOnePlusOne <TAB> <TAB> else : <TAB> <TAB> <TAB> optimClass = ParametrizedOnePlusOne ( <TAB> <TAB> <TAB> <TAB> crossover = True, mutation = ""discrete"", noise_handling = ""optimistic"" <TAB> <TAB> <TAB> ) <TAB> elif self. _arity > 0 : <TAB> <TAB> if self. budget < 1000 and self. num_workers == 1 : <TAB> <TAB> <TAB> optimClass = DiscreteBSOOnePlusOne <TAB> <TAB> elif self. num_workers > 2 : <TAB> <TAB> <TAB> optimClass = CMandAS2 <TAB> <TAB> else : <TAB> <TAB> <TAB> optimClass = super ( ). _select_optimizer_cls ( ) <TAB> else : <TAB> <TAB> if ( <TAB> <TAB> <TAB> not ( self. has_noise and self. fully_continuous and self. dimension > 100 ) <TAB> <TAB> <TAB> and not ( self. has_noise and self. fully_continuous ) <TAB> <TAB> <TAB> and not ( self. num_workers > self. budget / 5 ) <TAB> <TAB> <TAB> and ( self. num_workers == 1 and self. budget > 6000 and self. dimension > 7 ) <TAB> <TAB> ) : <TAB> <TAB> <TAB> optimClass = ChainMetaModelPowell <TAB> <TAB> else : <TAB> <TAB> <TAB> optimClass = super ( ). _select_optimizer_cls ( ) <TAB> return optimClass",False,self.budget > 10000,self.has_discrete_not_softmax,0.6765813827514648
|
||
|
3157,"def transform ( self, ctx, param ) : <TAB> required = param. default is param. empty <TAB> converter = self. _get_converter ( param ) <TAB> consume_rest_is_special = param. kind == param. KEYWORD_ONLY and not self. rest_is_raw <TAB> view = ctx. view <TAB> view. skip_ws ( ) <TAB> <TAB> <TAB> if type ( converter ) is converters. _Greedy : <TAB> <TAB> if param. kind == param. POSITIONAL_OR_KEYWORD : <TAB> <TAB> <TAB> return await self. _transform_greedy_pos ( <TAB> <TAB> <TAB> <TAB> ctx, param, required, converter. converter <TAB> <TAB> <TAB> ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> return await self. _transform_greedy_var_pos ( ctx, param, converter. converter ) <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> converter = converter. converter <TAB> if view. eof : <TAB> <TAB> if param. kind == param. VAR_POSITIONAL : <TAB> <TAB> <TAB> raise RuntimeError ( ) <TAB> <TAB> if required : <TAB> <TAB> <TAB> if self. _is_typing_optional ( param. annotation ) : <TAB> <TAB> <TAB> <TAB> return None <TAB> <TAB> <TAB> raise MissingRequiredArgument ( param ) <TAB> <TAB> return param. default <TAB> previous = view. index <TAB> if consume_rest_is_special : <TAB> <TAB> argument = view. read_rest ( ). strip ( ) <TAB> else : <TAB> <TAB> argument = view. get_quoted_word ( ) <TAB> view. previous = previous <TAB> return await self. do_conversion ( ctx, converter, argument, param )",False,param.kind == param.VAR_POSITIONAL,param.kind == param.VAR_POS,0.6551419496536255
|
||
|
3158,"def _send_handling_redirects ( <TAB> self, <TAB> request : Request, <TAB> timeout : Timeout, <TAB> allow_redirects : bool, <TAB> history : typing. List [ Response ], ) -> Response : <TAB> while True : <TAB> <TAB> if len ( history ) > self. max_redirects : <TAB> <TAB> <TAB> raise TooManyRedirects ( <TAB> <TAB> <TAB> <TAB> ""Exceeded maximum allowed redirects."", request = request <TAB> <TAB> <TAB> ) <TAB> <TAB> response = await self. _send_single_request ( request, timeout ) <TAB> <TAB> response. history = list ( history ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return response <TAB> <TAB> if allow_redirects : <TAB> <TAB> <TAB> await response. aread ( ) <TAB> <TAB> request = self. _build_redirect_request ( request, response ) <TAB> <TAB> history = history + [ response ] <TAB> <TAB> if not allow_redirects : <TAB> <TAB> <TAB> response. next_request = request <TAB> <TAB> <TAB> return response",False,not response.is_redirect,response.next_request,0.6534968614578247
|
||
|
3159,"def get_source_path ( cmdelements ) : <TAB> """"""Find the source path specified within a command"""""" <TAB> command = cmdelements [ 0 ] <TAB> if command in [ ""install"", ""cp"" ] : <TAB> <TAB> helptext = subprocess. check_output ( <TAB> <TAB> <TAB> ""LC_ALL=C %s --help"" % command, shell = True <TAB> <TAB> ). decode ( ""utf-8"" ) <TAB> <TAB> argopts = """" <TAB> <TAB> argopt_line_re = re. compile ( ""^-([a-zA-Z0-9]), --[a-z-]+="" ) <TAB> <TAB> for line in helptext. splitlines ( ) : <TAB> <TAB> <TAB> line = line. lstrip ( ) <TAB> <TAB> <TAB> res = argopt_line_re. search ( line ) <TAB> <TAB> <TAB> if res : <TAB> <TAB> <TAB> <TAB> argopts += res. group ( 1 ) <TAB> <TAB> if not argopts : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if command == ""install"" : <TAB> <TAB> <TAB> <TAB> argopts = ""gmoSt"" <TAB> <TAB> <TAB> elif command == ""cp"" : <TAB> <TAB> <TAB> <TAB> argopts = ""t"" <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> raise Exception ( ""No fallback arguments for command %s"" % command ) <TAB> <TAB> skipnext = False <TAB> <TAB> for elem in cmdelements [ 1 : - 1 ] : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> if len ( elem ) > 1 and elem [ 1 ] in argopts : <TAB> <TAB> <TAB> <TAB> <TAB> skipnext = True <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if skipnext : <TAB> <TAB> <TAB> <TAB> skipnext = False <TAB> <TAB> <TAB>",False,elem.startswith('-'),elem,0.6485550403594971
|
||
|
3160,"def _validate ( headers, key, subprotocols ) : <TAB> subproto = None <TAB> for k, v in _HEADERS_TO_CHECK. items ( ) : <TAB> <TAB> r = headers. get ( k, None ) <TAB> <TAB> if not r : <TAB> <TAB> <TAB> return False, None <TAB> <TAB> r = r. lower ( ) <TAB> <TAB> if v!= r : <TAB> <TAB> <TAB> return False, None <TAB> if subprotocols : <TAB> <TAB> subproto = headers. get ( ""sec-websocket-protocol"", None ). lower ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> error ( ""Invalid subprotocol: "" + str ( subprotocols ) ) <TAB> <TAB> <TAB> return False, None <TAB> result = headers. get ( ""sec-websocket-accept"", None ) <TAB> if not result : <TAB> <TAB> return False, None <TAB> result = result. lower ( ) <TAB> if isinstance ( result, six. text_type ) : <TAB> <TAB> result = result. encode ( ""utf-8"" ) <TAB> value = ( key + ""258EAFA5-E914-47DA-95CA-C5AB0DC85B11"" ). encode ( ""utf-8"" ) <TAB> hashed = base64encode ( hashlib. sha1 ( value ). digest ( ) ). strip ( ). lower ( ) <TAB> success = compare_digest ( hashed, result ) <TAB> if success : <TAB> <TAB> return True, subproto <TAB> else : <TAB> <TAB> return False, None",False,not subproto or subproto not in [s.lower() for s in subprotocols],subproto and (not subproto),0.6464719772338867
|
||
|
3161,"def _check_live ( self ) : <TAB> """"""check whether the handler is alive"""""" <TAB> <TAB> if self. _shutdown. is_set ( ) : <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> ""The handler has already been shutdown. Please use ServiceBusClient to "" <TAB> <TAB> <TAB> ""create a new instance."" <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise SessionLockLostError ( error = self. _session. auto_renew_error ) <TAB> except AttributeError : <TAB> <TAB> pass",False,self._session and (self._session._lock_lost or self._session._lock_expired),self._session.is_alive(),0.6603705286979675
|
||
|
3162,"def check_new_version ( new_version ) : <TAB> parsed_version = packaging. version. parse ( new_version ) <TAB> module_versions = check_existing_version ( ) <TAB> errors = { } <TAB> last_version = None <TAB> for module_name, module_version in module_versions. items ( ) : <TAB> <TAB> last_version = module_version <TAB> <TAB> if packaging. version. parse ( module_version [ ""__version__"" ] ) >= parsed_version : <TAB> <TAB> <TAB> errors [ module_name ] = module_version [ ""__version__"" ] <TAB> if errors : <TAB> <TAB> raise Exception ( <TAB> <TAB> <TAB> ""Bailing: Found modules with existing versions greater than or equal to the new "" <TAB> <TAB> <TAB> ""version {new_version}:\n{versions}"". format ( <TAB> <TAB> <TAB> <TAB> new_version = new_version, <TAB> <TAB> <TAB> <TAB> versions = format_module_versions ( module_versions ), <TAB> <TAB> <TAB> ) <TAB> <TAB> ) <TAB> if not ( <TAB> <TAB> parsed_version. is_prerelease <TAB> <TAB> or parsed_version. is_postrelease <TAB> <TAB> or parsed_version. is_devrelease <TAB> ) : <TAB> <TAB> parsed_previous_version = packaging. version. parse ( last_version [ ""__version__"" ] ) <TAB> <TAB> if not ( parsed_previous_version. release == parsed_version. release ) : <TAB> <TAB> <TAB> should_continue = input ( <TAB> <TAB> <TAB> <TAB> ""You appear to be releasing a new version, {new_version}, without having "" <TAB> <TAB> <TAB> <TAB> ""previously run a prerelease.\n(Last version found was {previous_version})\n"" <TAB> <TAB> <TAB> <TAB> ""Are you sure you know what you're doing? (Y/n)"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> new_version = new_",False,not should_continue == 'Y',new_version is not None,0.652093768119812
|
||
|
3163,"def __init__ ( self, graph = None, bindings = None, initBindings = None ) : <TAB> self. initBindings = initBindings <TAB> self. bindings = Bindings ( d = bindings or [ ] ) <TAB> if initBindings : <TAB> <TAB> self. bindings. update ( initBindings ) <TAB> if isinstance ( graph, ConjunctiveGraph ) : <TAB> <TAB> self. _dataset = graph <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. graph = self. dataset <TAB> <TAB> else : <TAB> <TAB> <TAB> self. graph = self. dataset. default_context <TAB> else : <TAB> <TAB> self. _dataset = None <TAB> <TAB> self. graph = graph <TAB> self. prologue = None <TAB> self. now = datetime. datetime. now ( ) <TAB> self. bnodes = collections. defaultdict ( BNode )",False,rdflib.plugins.sparql.SPARQL_DEFAULT_GRAPH_UNION,"isinstance(self.dataset, dict)",0.6531961560249329
|
||
|
3164,"def _init_metrics_dict ( self, metrics_dict ) : <TAB> if not metrics_dict : <TAB> <TAB> raise ValueError ( ""Evaluation metrics dictionary must not be empty."" ) <TAB> first_metrics = list ( metrics_dict. values ( ) ) [ 0 ] <TAB> if isinstance ( first_metrics, dict ) : <TAB> <TAB> self. _model_have_multiple_outputs = True <TAB> <TAB> self. _metrics_dict = metrics_dict <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _model_have_multiple_outputs = False <TAB> <TAB> self. _metrics_dict = { MetricsDictKey. MODEL_OUTPUT : metrics_dict } <TAB> for output_name, metrics in self. _metrics_dict. items ( ) : <TAB> <TAB> for metric_name, metric in metrics. items ( ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> metrics [ metric_name ] = metrics_module. MeanMetricWrapper ( <TAB> <TAB> <TAB> <TAB> <TAB> metric, name = metric_name <TAB> <TAB> <TAB> <TAB> )",False,"not isinstance(metric, metrics_module.Metric)",metric_name in first_metrics,0.6523167490959167
|
||
|
3165,"def main ( client ) : <TAB> report_downloader = client. GetReportDownloader ( version = ""v201809"" ) <TAB> <TAB> report = { <TAB> <TAB> ""reportName"" : ""Last 7 days CRITERIA_PERFORMANCE_REPORT"", <TAB> <TAB> ""dateRangeType"" : ""LAST_7_DAYS"", <TAB> <TAB> ""reportType"" : ""CRITERIA_PERFORMANCE_REPORT"", <TAB> <TAB> ""downloadFormat"" : ""CSV"", <TAB> <TAB> ""selector"" : { <TAB> <TAB> <TAB> ""fields"" : [ <TAB> <TAB> <TAB> <TAB> ""CampaignId"", <TAB> <TAB> <TAB> <TAB> ""AdGroupId"", <TAB> <TAB> <TAB> <TAB> ""Id"", <TAB> <TAB> <TAB> <TAB> ""CriteriaType"", <TAB> <TAB> <TAB> <TAB> ""Criteria"", <TAB> <TAB> <TAB> <TAB> ""FinalUrls"", <TAB> <TAB> <TAB> <TAB> ""Impressions"", <TAB> <TAB> <TAB> <TAB> ""Clicks"", <TAB> <TAB> <TAB> <TAB> ""Cost"", <TAB> <TAB> <TAB> ] <TAB> <TAB> }, <TAB> } <TAB> <TAB> report_data = StringIO. StringIO ( ) <TAB> stream_data = report_downloader. DownloadReportAsStream ( <TAB> <TAB> report, <TAB> <TAB> skip_report_header = False, <TAB> <TAB> skip_column_header = False, <TAB> <TAB> skip_report_summary = False, <TAB> <TAB> include_zero_impressions = True, <TAB> ) <TAB> try : <TAB> <TAB> while True : <TAB> <TAB> <TAB> chunk = stream_data. read ( CHUNK_SIZE ) <TAB> <TAB> <TAB> if not chunk : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> report_data. write ( <TAB> <TAB> <TAB> <TAB> chunk. decode (",False,"sys.version_info[0] == 3 and getattr(report_data, 'mode', 'w') == 'w'",report_downloader.getReportStatus() == 5,0.6485812664031982
|
||
|
3166,"def safeMessage ( self, msg, replace_tuple = ( ) ) : <TAB> from couchpotato. core. helpers. encoding import ss, toUnicode <TAB> msg = ss ( msg ) <TAB> try : <TAB> <TAB> if isinstance ( replace_tuple, tuple ) : <TAB> <TAB> <TAB> msg = msg % tuple ( <TAB> <TAB> <TAB> <TAB> [ <TAB> <TAB> <TAB> <TAB> <TAB> ss ( x ) if not isinstance ( x, ( int, float ) ) else x <TAB> <TAB> <TAB> <TAB> <TAB> for x in list ( replace_tuple ) <TAB> <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> ) <TAB> <TAB> elif isinstance ( replace_tuple, dict ) : <TAB> <TAB> <TAB> msg = msg % dict ( <TAB> <TAB> <TAB> <TAB> ( k, ss ( v ) if not isinstance ( v, ( int, float ) ) else v ) <TAB> <TAB> <TAB> <TAB> for k, v in replace_tuple. iteritems ( ) <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> msg = msg % ss ( replace_tuple ) <TAB> except Exception as e : <TAB> <TAB> self. logger. error ( 'Failed encoding stuff to log ""%s"": %s' % ( msg, e ) ) <TAB> self. setup ( ) <TAB> if not self. is_develop : <TAB> <TAB> for replace in self. replace_private : <TAB> <TAB> <TAB> msg = re. sub ( ""(\?%s=)[^\&]+"" % replace, ""?%s=xxx"" % replace, msg ) <TAB> <TAB> <TAB> msg = re. sub ( ""(&%s=)[^\&]+"" % replace, ""&%s=xxx"" % replace, msg ) <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> api_key = self. Env. setting ( ""api_key"" ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB",False,api_key,api_key and api_key.lower(),0.6642808318138123
|
||
|
3167,"def setUpModule ( ) : <TAB> home = tempfile. mkdtemp ( ) <TAB> MOD_CLEAN. add_cleanup ( shutil. rmtree, home ) <TAB> mock_home = mock. patch. dict ( os. environ, { ""GNUPGHOME"" : home } ) <TAB> mock_home. start ( ) <TAB> MOD_CLEAN. add_cleanup ( mock_home. stop ) <TAB> with gpg. core. Context ( armor = True ) as ctx : <TAB> <TAB> <TAB> <TAB> search_dir = os. path. join ( os. path. dirname ( __file__ ), ""../static/gpg-keys"" ) <TAB> <TAB> for each in os. listdir ( search_dir ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> with open ( os. path. join ( search_dir, each ) ) as f : <TAB> <TAB> <TAB> <TAB> <TAB> ctx. op_import ( f )",False,os.path.splitext(each)[1] == '.gpg',each,0.6460021734237671
|
||
|
3168,"def parse_statement ( self ) : <TAB> """"""Parse a single statement."""""" <TAB> token = self. stream. current <TAB> if token. type!= ""name"" : <TAB> <TAB> self. fail ( ""tag name expected"", token. lineno ) <TAB> self. _tag_stack. append ( token. value ) <TAB> pop_tag = True <TAB> try : <TAB> <TAB> if token. value in _statement_keywords : <TAB> <TAB> <TAB> return getattr ( self, ""parse_"" + self. stream. current. value ) ( ) <TAB> <TAB> if token. value == ""call"" : <TAB> <TAB> <TAB> return self. parse_call_block ( ) <TAB> <TAB> if token. value == ""filter"" : <TAB> <TAB> <TAB> return self. parse_filter_block ( ) <TAB> <TAB> ext = self. extensions. get ( token. value ) <TAB> <TAB> if ext is not None : <TAB> <TAB> <TAB> return ext ( self ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _tag_stack. pop ( ) <TAB> <TAB> pop_tag = False <TAB> <TAB> self. fail_unknown_tag ( token. value, token. lineno ) <TAB> finally : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _tag_stack. pop ( )",True,pop_tag,pop_tag,0.6643941402435303
|
||
|
3169,"def loop_skeleton ( greater_f, less_f, l, l_b, u_b, l_c ) : <TAB> <TAB> for _ in range ( 100 ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> for _ in range ( random. randint ( l_b, u_b ) ) : <TAB> <TAB> <TAB> <TAB> greater_f ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> for _ in range ( random. randint ( l_b, u_b ) ) : <TAB> <TAB> <TAB> <TAB> less_f ( )",False,len(l) > l_c,l,0.6513203382492065
|
||
|
3170,"def _mongo_query_and ( self, queries ) : <TAB> if len ( queries ) == 1 : <TAB> <TAB> return queries [ 0 ] <TAB> query = { } <TAB> for q in queries : <TAB> <TAB> for k, v in q. items ( ) : <TAB> <TAB> <TAB> if k not in query : <TAB> <TAB> <TAB> <TAB> query [ k ] = { } <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> query [ k ] = v <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> query [ k ]. update ( v ) <TAB> return query",False,"isinstance(v, list)","hasattr(v, '__iter__')",0.6520874500274658
|
||
|
3171,"def _get_merged_init_op_name ( merged_graph, graph_names_list, init_op_names_list ) : <TAB> """"""Groups init ops and returns name of group."""""" <TAB> merged_init_op_list = [ ] <TAB> proposed_name = ""merged_init"" <TAB> for graph_name, init_op_name in zip ( graph_names_list, init_op_names_list ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> else : <TAB> <TAB> <TAB> merged_init_op_list. append ( <TAB> <TAB> <TAB> <TAB> merged_graph. get_operation_by_name ( <TAB> <TAB> <TAB> <TAB> <TAB> ""{}/{}"". format ( graph_name, init_op_name ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> with merged_graph. as_default ( ) : <TAB> <TAB> init_op = tf. group ( merged_init_op_list, name = proposed_name ) <TAB> return init_op. name",False,init_op_name is None,not merged_graph,0.6517167687416077
|
||
|
3172,"def assertRaises ( error, func, * args, ** kwargs ) : <TAB> try : <TAB> <TAB> func ( * args, ** kwargs ) <TAB> except BaseException as e : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return <TAB> <TAB> else : <TAB> <TAB> <TAB> assert False, ""expected %s(%s) to raise %s, but raised %s"" % ( <TAB> <TAB> <TAB> <TAB> func, <TAB> <TAB> <TAB> <TAB> args, <TAB> <TAB> <TAB> <TAB> error, <TAB> <TAB> <TAB> <TAB> type ( e ), <TAB> <TAB> <TAB> ) <TAB> else : <TAB> <TAB> assert False, ""expected %s(%s) to raise %s, but did not raise"" % ( <TAB> <TAB> <TAB> func, <TAB> <TAB> <TAB> args, <TAB> <TAB> <TAB> error, <TAB> <TAB> )",False,"isinstance(e, error)",error is None,0.6500612497329712
|
||
|
3173,"def apply ( self ) : <TAB> new_block = self. block. copy ( ) <TAB> new_block. clear ( ) <TAB> for inst in self. block. body : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> const_assign = self. _assign_const ( inst ) <TAB> <TAB> <TAB> new_block. append ( const_assign ) <TAB> <TAB> <TAB> inst = self. _assign_getitem ( inst, index = const_assign. target ) <TAB> <TAB> new_block. append ( inst ) <TAB> return new_block",False,"isinstance(inst, Assign) and inst.value in self.getattrs",self.check_inst(inst),0.6538102626800537
|
||
|
3174,"def join_search_results ( <TAB> all_search_results : Sequence [ Union [ List [ AURPackageInfo ], List [ pyalpm. Package ] ] ] ) -> Iterable [ Union [ AURPackageInfo, pyalpm. Package ] ] : <TAB> pkgnames_set : Set [ str ] = set ( ) <TAB> for search_results in all_search_results : <TAB> <TAB> new_pkgnames_set = set ( get_pkg_id ( result ) for result in search_results ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> pkgnames_set = pkgnames_set. intersection ( new_pkgnames_set ) <TAB> <TAB> else : <TAB> <TAB> <TAB> pkgnames_set = new_pkgnames_set <TAB> return { <TAB> <TAB> get_pkg_id ( result ) : result <TAB> <TAB> for result in all_search_results [ 0 ] <TAB> <TAB> if get_pkg_id ( result ) in pkgnames_set <TAB> }. values ( )",True,pkgnames_set,pkgnames_set,0.6854405403137207
|
||
|
3175,"def header_tag_files ( env, files, legal_header, script_files = False ) : <TAB> """"""Apply the legal_header to the list of files"""""" <TAB> try : <TAB> <TAB> import apply_legal_header <TAB> except : <TAB> <TAB> xbc. cdie ( ""XED ERROR: mfile.py could not find scripts directory"" ) <TAB> for g in files : <TAB> <TAB> print ( ""G: "", g ) <TAB> <TAB> for f in mbuild. glob ( g ) : <TAB> <TAB> <TAB> print ( ""F: "", f ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> apply_legal_header. apply_header_to_data_file ( legal_header, f ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> apply_legal_header. apply_header_to_source_file ( legal_header, f )",True,script_files,script_files,0.6592926979064941
|
||
|
3176,"def run ( self ) : <TAB> while True : <TAB> <TAB> addr = self. request_queue. get ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> break <TAB> <TAB> try : <TAB> <TAB> <TAB> sock = socket. socket ( socket. AF_INET, socket. SOCK_STREAM ) <TAB> <TAB> <TAB> sock. settimeout ( self. scan_timeout ) <TAB> <TAB> <TAB> sock. connect ( ( addr, self. port ) ) <TAB> <TAB> <TAB> sock. close ( ) <TAB> <TAB> <TAB> dev = get_device ( addr, timeout = self. connect_timeout ) <TAB> <TAB> <TAB> print ( ""Found WeMo device: {}"". format ( dev ) ) <TAB> <TAB> <TAB> self. process_response ( dev ) <TAB> <TAB> except OSError : <TAB> <TAB> <TAB> pass",False,addr == self._END_OF_STREAM,addr is None,0.6672773361206055
|
||
|
3177,"def render_token_list ( self, tokens ) : <TAB> result = [ ] <TAB> vars = [ ] <TAB> for token in tokens : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> result. append ( token. contents. replace ( ""%"", ""%%"" ) ) <TAB> <TAB> elif token. token_type == TOKEN_VAR : <TAB> <TAB> <TAB> result. append ( ""%%(%s)s"" % token. contents ) <TAB> <TAB> <TAB> vars. append ( token. contents ) <TAB> msg = """". join ( result ) <TAB> if self. trimmed : <TAB> <TAB> msg = translation. trim_whitespace ( msg ) <TAB> return msg, vars",False,token.token_type == TOKEN_TEXT,token.token_type == TOKEN_LINE,0.6562853455543518
|
||
|
3178,"def interact ( self ) : <TAB> """"""Interaction function, emulates a very dumb telnet client."""""" <TAB> if sys. platform == ""win32"" : <TAB> <TAB> self. mt_interact ( ) <TAB> <TAB> return <TAB> with _TelnetSelector ( ) as selector : <TAB> <TAB> selector. register ( self, selectors. EVENT_READ ) <TAB> <TAB> selector. register ( sys. stdin, selectors. EVENT_READ ) <TAB> <TAB> while True : <TAB> <TAB> <TAB> for key, events in selector. select ( ) : <TAB> <TAB> <TAB> <TAB> if key. fileobj is self : <TAB> <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> text = self. read_eager ( ) <TAB> <TAB> <TAB> <TAB> <TAB> except EOFError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> print ( ""*** Connection closed by remote host ***"" ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> <TAB> <TAB> if text : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> sys. stdout. write ( text. decode ( ""ascii"" ) ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> sys. stdout. flush ( ) <TAB> <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> line = sys. stdin. readline ( ). encode ( ""ascii"" ) <TAB> <TAB> <TAB> <TAB> <TAB> if not line : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> <TAB> <TAB> self. write ( line )",False,key.fileobj is sys.stdin,sys.stdin.isatty(),0.6526926755905151
|
||
|
3179,"def post_config_hook ( self ) : <TAB> <TAB> self. ipc = getattr ( self, ""ipc"", """" ) <TAB> if self. ipc in [ """", ""i3ipc"" ] : <TAB> <TAB> try : <TAB> <TAB> <TAB> from i3ipc import Connection <TAB> <TAB> <TAB> self. ipc = ""i3ipc"" <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise <TAB> self. ipc = ( self. ipc or self. py3. get_wm_msg ( ) ). replace ( ""-"", """" ) <TAB> if self. ipc in [ ""i3ipc"" ] : <TAB> <TAB> self. backend = I3ipc ( self ) <TAB> elif self. ipc in [ ""i3msg"", ""swaymsg"" ] : <TAB> <TAB> self. backend = Msg ( self ) <TAB> else : <TAB> <TAB> raise Exception ( STRING_ERROR. format ( self. ipc ) ) <TAB> self. thresholds_init = self. py3. get_color_names_list ( self. format )",False,self.ipc,self.ipc not in Connection.get_wm_keys(),0.6687798500061035
|
||
|
3180,def is_sorted ( stack ) : <TAB> storage_stack = [ ] <TAB> for i in range ( len ( stack ) ) : <TAB> <TAB> if len ( stack ) == 0 : <TAB> <TAB> <TAB> break <TAB> <TAB> first_val = stack. pop ( ) <TAB> <TAB> if len ( stack ) == 0 : <TAB> <TAB> <TAB> break <TAB> <TAB> second_val = stack. pop ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return False <TAB> <TAB> storage_stack. append ( first_val ) <TAB> <TAB> stack. append ( second_val ) <TAB> <TAB> for i in range ( len ( storage_stack ) ) : <TAB> <TAB> stack. append ( storage_stack. pop ( ) ) <TAB> return True,False,first_val < second_val,len(storage_stack) == 0 and first_val > second_val,0.6546143293380737
|
||
|
3181,"def run_async ( self, nuke_cursors ) : <TAB> <TAB> interface_type = self. view. settings ( ). get ( ""git_savvy.interface"" ) <TAB> for cls in subclasses : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> vid = self. view. id ( ) <TAB> <TAB> <TAB> interface = interfaces. get ( vid, None ) <TAB> <TAB> <TAB> if not interface : <TAB> <TAB> <TAB> <TAB> interface = interfaces [ vid ] = cls ( view = self. view ) <TAB> <TAB> <TAB> interface. render ( nuke_cursors = nuke_cursors ) <TAB> <TAB> <TAB> break",False,cls.interface_type == interface_type,interface_type == 'git_savvy.interface',0.6562165021896362
|
||
|
3182,"def _learn_rate_adjust ( self ) : <TAB> if self. learn_rate_decays == 1.0 : <TAB> <TAB> return <TAB> learn_rate_decays = self. _vp ( self. learn_rate_decays ) <TAB> learn_rate_minimums = self. _vp ( self. learn_rate_minimums ) <TAB> for index, decay in enumerate ( learn_rate_decays ) : <TAB> <TAB> new_learn_rate = self. net_. learnRates [ index ] * decay <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. net_. learnRates [ index ] = new_learn_rate <TAB> if self. verbose >= 2 : <TAB> <TAB> print ( ""Learn rates: {}"". format ( self. net_. learnRates ) )",False,new_learn_rate >= learn_rate_minimums[index],self.verbose >= 1,0.6506271362304688
|
||
|
3183,"def PyJsHoisted_BinaryExpression_ ( node, parent, this, arguments, var = var ) : <TAB> var = Scope ( <TAB> <TAB> { u""node"" : node, u""this"" : this, u""arguments"" : arguments, u""parent"" : parent }, var <TAB> ) <TAB> var. registers ( [ u""node"", u""parent"" ] ) <TAB> if PyJsStrictEq ( var. get ( u""node"" ). get ( u""operator"" ), Js ( u""in"" ) ) : <TAB> <TAB> if var. get ( u""t"" ). callprop ( u""isVariableDeclarator"", var. get ( u""parent"" ) ) : <TAB> <TAB> <TAB> return var. get ( u""true"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return var. get ( u""true"" ) <TAB> return Js ( False )",False,"var.get(u't').callprop(u'isFor', var.get(u'parent'))",var.get(u't'),0.6501477956771851
|
||
|
3184,"def feed ( self, code ) : <TAB> x = """" <TAB> if code == 256 : <TAB> <TAB> self. table = [ chr ( c ) for c in xrange ( 256 ) ] <TAB> <TAB> self. table. append ( None ) <TAB> <TAB> self. table. append ( None ) <TAB> <TAB> self. prevbuf = """" <TAB> <TAB> self. nbits = 9 <TAB> elif code == 257 : <TAB> <TAB> pass <TAB> elif not self. prevbuf : <TAB> <TAB> x = self. prevbuf = self. table [ code ] <TAB> else : <TAB> <TAB> if code < len ( self. table ) : <TAB> <TAB> <TAB> x = self. table [ code ] <TAB> <TAB> <TAB> self. table. append ( self. prevbuf + x [ 0 ] ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. table. append ( self. prevbuf + self. prevbuf [ 0 ] ) <TAB> <TAB> <TAB> x = self. table [ code ] <TAB> <TAB> l = len ( self. table ) <TAB> <TAB> if l == 511 : <TAB> <TAB> <TAB> self. nbits = 10 <TAB> <TAB> elif l == 1023 : <TAB> <TAB> <TAB> self. nbits = 11 <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> self. nbits = 12 <TAB> <TAB> self. prevbuf = x <TAB> return x",False,l == 2047,l == 9,0.6822099685668945
|
||
|
3185,"def string_type_request_headers ( req ) : <TAB> request_headers = { } <TAB> if not isinstance ( req, DummyRequest ) : <TAB> <TAB> request_headers = { <TAB> <TAB> <TAB> k : v <TAB> <TAB> <TAB> for k, v in get_headers_from_request ( req ). items ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> } <TAB> return request_headers",False,"isinstance(v, basestring)",len(request_headers) > 0,0.6571589708328247
|
||
|
3186,"def check_grants ( self, acl ) : <TAB> owner = acl [ ""Owner"" ] [ ""ID"" ] <TAB> found = [ ] <TAB> for grant in acl. get ( ""Grants"", ( ) ) : <TAB> <TAB> grantee = grant [ ""Grantee"" ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> elif ""URI"" in grantee : <TAB> <TAB> <TAB> if self. data [ ""allow-log"" ] and grantee [ ""URI"" ] == Groups. LogDelivery : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> found. append ( grant ) <TAB> <TAB> elif ""ID"" in grantee : <TAB> <TAB> <TAB> if ""*"" in self. whitelist_accounts : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if grantee [ ""ID"" ] not in self. whitelist_accounts : <TAB> <TAB> <TAB> <TAB> found. append ( grant ) <TAB> <TAB> else : <TAB> <TAB> <TAB> log. warning ( ""unknown grant %s"", grant ) <TAB> return found",False,'ID' in grantee and grantee['ID'] == owner,owner == grantee,0.6610720157623291
|
||
|
3187,"def processMessage ( self, message ) : <TAB> """"""Parse a message and post it as a metric."""""" <TAB> if self. factory. verbose : <TAB> <TAB> log. listener ( ""Message received: %s"" % ( message, ) ) <TAB> metric = message. routing_key <TAB> for line in message. content. body. split ( ""\n"" ) : <TAB> <TAB> line = line. strip ( ) <TAB> <TAB> if not line : <TAB> <TAB> <TAB> continue <TAB> <TAB> try : <TAB> <TAB> <TAB> if settings. get ( ""AMQP_METRIC_NAME_IN_BODY"", False ) : <TAB> <TAB> <TAB> <TAB> metric, value, timestamp = line. split ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> value, timestamp = line. split ( ) <TAB> <TAB> <TAB> datapoint = ( float ( timestamp ), float ( value ) ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> log. listener ( ""invalid message line: %s"" % ( line, ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> events. metricReceived ( metric, datapoint ) <TAB> <TAB> if self. factory. verbose : <TAB> <TAB> <TAB> log. listener ( <TAB> <TAB> <TAB> <TAB> ""Metric posted: %s %s %s"" <TAB> <TAB> <TAB> <TAB> % ( <TAB> <TAB> <TAB> <TAB> <TAB> metric, <TAB> <TAB> <TAB> <TAB> <TAB> value, <TAB> <TAB> <TAB> <TAB> <TAB> timestamp, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> )",False,datapoint[1] != datapoint[1],datadata[0] == '',0.6679907441139221
|
||
|
3188,"def save_params ( self ) : <TAB> if self. _save_controller : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> os. makedirs ( self. _save_controller ) <TAB> <TAB> output_dir = self. _save_controller <TAB> else : <TAB> <TAB> if not os. path. exists ( ""./.rlnas_controller"" ) : <TAB> <TAB> <TAB> os. makedirs ( ""./.rlnas_controller"" ) <TAB> <TAB> output_dir = ""./.rlnas_controller"" <TAB> with open ( os. path. join ( output_dir, ""rlnas.params"" ), ""wb"" ) as f : <TAB> <TAB> pickle. dump ( self. _params_dict, f ) <TAB> _logger. debug ( ""Save params done"" )",True,not os.path.exists(self._save_controller),not os.path.exists(self._save_controller),0.6502470970153809
|
||
|
3189,"def build ( self, hp, inputs = None ) : <TAB> inputs = nest. flatten ( inputs ) <TAB> utils. validate_num_inputs ( inputs, 1 ) <TAB> input_node = inputs [ 0 ] <TAB> output_node = input_node <TAB> output_node = reduction. Flatten ( ). build ( hp, output_node ) <TAB> use_batchnorm = self. use_batchnorm <TAB> if use_batchnorm is None : <TAB> <TAB> use_batchnorm = hp. Boolean ( ""use_batchnorm"", default = False ) <TAB> for i in range ( utils. add_to_hp ( self. num_layers, hp ) ) : <TAB> <TAB> units = utils. add_to_hp ( self. num_units, hp, ""units_{i}"". format ( i = i ) ) <TAB> <TAB> output_node = layers. Dense ( units ) ( output_node ) <TAB> <TAB> if use_batchnorm : <TAB> <TAB> <TAB> output_node = layers. BatchNormalization ( ) ( output_node ) <TAB> <TAB> output_node = layers. ReLU ( ) ( output_node ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> output_node = layers. Dropout ( utils. add_to_hp ( self. dropout, hp ) ) ( output_node ) <TAB> return output_node",False,"utils.add_to_hp(self.dropout, hp) > 0",self.dropout is not None,0.6451456546783447
|
||
|
3190,"def get_multi ( self, keys, index = None ) : <TAB> if index is not None and index not in self. _indexes : <TAB> <TAB> raise ValueError ( ""Index {} does not exist"". format ( index ) ) <TAB> with self. _lmdb. begin ( ) as txn : <TAB> <TAB> result = [ ] <TAB> <TAB> cursor = txn. cursor ( self. _main_db ) <TAB> <TAB> index_cursor = None <TAB> <TAB> if index is not None : <TAB> <TAB> <TAB> index_db = self. _indexes [ index ] [ 0 ] <TAB> <TAB> <TAB> index_cursor = txn. cursor ( index_db ) <TAB> <TAB> for key in keys : <TAB> <TAB> <TAB> read_key = key. encode ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if index_cursor : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> read_key = index_cursor. get ( read_key ) <TAB> <TAB> <TAB> <TAB> except lmdb. BadValsizeError : <TAB> <TAB> <TAB> <TAB> <TAB> raise KeyError ( ""Invalid key: %s"" % read_key ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> packed = cursor. get ( read_key ) <TAB> <TAB> <TAB> except lmdb. BadValsizeError : <TAB> <TAB> <TAB> <TAB> raise KeyError ( ""Invalid key: %s"" % read_key ) <TAB> <TAB> <TAB> if packed is not None : <TAB> <TAB> <TAB> <TAB> result. append ( ( read_key. decode ( ), self. _deserializer ( packed ) ) ) <TAB> <TAB> <TAB> elif index_cursor : <TAB> <TAB> <TAB> <TAB> raise IndexOutOfSyncError ( ""Index is out of sync for key",False,not read_key,read_key is None,0.6586360931396484
|
||
|
3191,"def get_parameters ( model, keys = None, mode = ""include"" ) : <TAB> if keys is None : <TAB> <TAB> for name, param in model. named_parameters ( ) : <TAB> <TAB> <TAB> yield param <TAB> elif mode == ""include"" : <TAB> <TAB> for name, param in model. named_parameters ( ) : <TAB> <TAB> <TAB> flag = False <TAB> <TAB> <TAB> for key in keys : <TAB> <TAB> <TAB> <TAB> if key in name : <TAB> <TAB> <TAB> <TAB> <TAB> flag = True <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> yield param <TAB> elif mode == ""exclude"" : <TAB> <TAB> for name, param in model. named_parameters ( ) : <TAB> <TAB> <TAB> flag = True <TAB> <TAB> <TAB> for key in keys : <TAB> <TAB> <TAB> <TAB> if key in name : <TAB> <TAB> <TAB> <TAB> <TAB> flag = False <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> yield param <TAB> else : <TAB> <TAB> raise ValueError ( ""do not support: %s"" % mode )",True,flag,flag,0.6853513121604919
|
||
|
3192,"def convert_port_bindings ( port_bindings ) : <TAB> result = { } <TAB> for k, v in six. iteritems ( port_bindings ) : <TAB> <TAB> key = str ( k ) <TAB> <TAB> if ""/"" not in key : <TAB> <TAB> <TAB> key += ""/tcp"" <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> result [ key ] = [ _convert_port_binding ( binding ) for binding in v ] <TAB> <TAB> else : <TAB> <TAB> <TAB> result [ key ] = [ _convert_port_binding ( v ) ] <TAB> return result",True,"isinstance(v, list)","isinstance(v, list)",0.6585569381713867
|
||
|
3193,"def expand_url ( self, url, base_url, scoped = False, vocab_term = False ) : <TAB> if url in ( ""@id"", ""@type"" ) : <TAB> <TAB> return url <TAB> if vocab_term and url in self. vocab : <TAB> <TAB> return url <TAB> if self. vocab and "":"" in url : <TAB> <TAB> prefix = url. split ( "":"" ) [ 0 ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> url = self. vocab [ prefix ] + url [ len ( prefix ) + 1 : ] <TAB> split = urlparse. urlsplit ( url ) <TAB> if split. scheme or url. startswith ( ""$("" ) or url. startswith ( ""${"" ) : <TAB> <TAB> pass <TAB> elif scoped and not split. fragment : <TAB> <TAB> splitbase = urlparse. urlsplit ( base_url ) <TAB> <TAB> frg = """" <TAB> <TAB> if splitbase. fragment : <TAB> <TAB> <TAB> frg = splitbase. fragment + ""/"" + split. path <TAB> <TAB> else : <TAB> <TAB> <TAB> frg = split. path <TAB> <TAB> url = urlparse. urlunsplit ( <TAB> <TAB> <TAB> ( splitbase. scheme, splitbase. netloc, splitbase. path, splitbase. query, frg ) <TAB> <TAB> ) <TAB> else : <TAB> <TAB> url = urlparse. urljoin ( base_url, url ) <TAB> if vocab_term and url in self. rvocab : <TAB> <TAB> return self. rvocab [ url ] <TAB> else : <TAB> <TAB> return url",True,prefix in self.vocab,prefix in self.vocab,0.667580246925354
|
||
|
3194,"def target_function ( self, running, data ) : <TAB> while running. is_set ( ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> username, password = data. next ( ) <TAB> <TAB> except StopIteration : <TAB> <TAB> <TAB> break <TAB> <TAB> else : <TAB> <TAB> <TAB> ftp_client = self. ftp_create ( ) <TAB> <TAB> <TAB> if ftp_client. connect ( retries = 3 ) is None : <TAB> <TAB> <TAB> <TAB> print_error ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Too many connections problems. Quiting..."", verbose = self. verbosity <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> if ftp_client. login ( username, password ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> running. clear ( ) <TAB> <TAB> <TAB> <TAB> self. credentials. append ( <TAB> <TAB> <TAB> <TAB> <TAB> ( self. target, self. port, self. target_protocol, username, password ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ftp_client. close ( )",False,self.stop_on_success,running.is_set(),0.6515450477600098
|
||
|
3195,"def jobs ( self ) : <TAB> <TAB> total_processed = 0 <TAB> for jobEntity in self. jobItems. query_entities ( ) : <TAB> <TAB> <TAB> <TAB> yield AzureJob. fromEntity ( jobEntity ) <TAB> <TAB> total_processed += 1 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> logger. debug ( ""Processed %d total jobs"" % total_processed ) <TAB> logger. debug ( ""Processed %d total jobs"" % total_processed )",False,total_processed % 1000 == 0,total_processed > 0,0.6732910871505737
|
||
|
3196,"def save ( self, force = False ) : <TAB> if not force : <TAB> <TAB> if not self. need_save : <TAB> <TAB> <TAB> return <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return <TAB> with self. lock : <TAB> <TAB> with open ( self. file_path, ""w"" ) as fd : <TAB> <TAB> <TAB> for ip in self. cache : <TAB> <TAB> <TAB> <TAB> record = self. cache [ ip ] <TAB> <TAB> <TAB> <TAB> rule = record [ ""r"" ] <TAB> <TAB> <TAB> <TAB> connect_time = record [ ""c"" ] <TAB> <TAB> <TAB> <TAB> update_time = record [ ""update"" ] <TAB> <TAB> <TAB> <TAB> fd. write ( ""%s %s %d %d\n"" % ( ip, rule, connect_time, update_time ) ) <TAB> self. last_save_time = time. time ( ) <TAB> self. need_save = False",False,time.time() - self.last_save_time < 10,time.time() - self.last_save_time > self.file_path,0.6593494415283203
|
||
|
3197,"def PrintColGroup ( col_names, schema ) : <TAB> """"""Print HTML colgroup element, used for JavaScript sorting."""""" <TAB> print ( "" <colgroup>"" ) <TAB> for i, col in enumerate ( col_names ) : <TAB> <TAB> if col. endswith ( ""_HREF"" ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> css_class = ""number"" <TAB> <TAB> else : <TAB> <TAB> <TAB> css_class = ""case-insensitive"" <TAB> <TAB> <TAB> <TAB> print (' <col id=""{}"" type=""{}"" />'. format ( col, css_class ) ) <TAB> print ( "" </colgroup>"" )",False,schema.IsNumeric(col),i == len(col_names) - 1,0.6530808210372925
|
||
|
3198,"def filterTokenLocation ( ) : <TAB> i = None <TAB> entry = None <TAB> token = None <TAB> tokens = [ ] <TAB> i = 0 <TAB> while 1 : <TAB> <TAB> if not ( i < len ( extra. tokens ) ) : <TAB> <TAB> <TAB> break <TAB> <TAB> entry = extra. tokens [ i ] <TAB> <TAB> token = jsdict ( <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> ""type"" : entry. type, <TAB> <TAB> <TAB> <TAB> ""value"" : entry. value, <TAB> <TAB> <TAB> } <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> token. range = entry. range <TAB> <TAB> if extra. loc : <TAB> <TAB> <TAB> token. loc = entry. loc <TAB> <TAB> tokens. append ( token ) <TAB> <TAB> i += 1 <TAB> extra. tokens = tokens",False,extra.range,entry and entry.range,0.6710027456283569
|
||
|
3199,"def visit_Import ( self, node ) : <TAB> modify_stmt = False <TAB> for alias in node. names : <TAB> <TAB> name = alias. name. split ( ""."" ) <TAB> <TAB> for p in self. vendorized_packages : <TAB> <TAB> <TAB> if name [ 0 ] == p : <TAB> <TAB> <TAB> <TAB> modify_stmt = True <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> break <TAB> if<mask> : <TAB> <TAB> import_changes = _relpkg_import ( self. pkg_parts ) <TAB> <TAB> import_stmt, offset_start, offset_end = self. extract_source ( node ) <TAB> <TAB> ts = self. transformed_source <TAB> <TAB> ts_prefix = ts [ : offset_start + self. offset ] <TAB> <TAB> ts_postfix = ts [ offset_end + self. offset : ] <TAB> <TAB> inject = ""from "" + import_changes + "" "" <TAB> <TAB> self. offset += len ( inject ) <TAB> <TAB> for alias in node. names : <TAB> <TAB> <TAB> name = alias. name. split ( ""."" ) <TAB> <TAB> <TAB> if len ( name ) > 1 : <TAB> <TAB> <TAB> <TAB> import_stmt = import_stmt. replace ( alias. name, name [ 0 ] ) <TAB> <TAB> <TAB> <TAB> self. offset += - len ( alias. name ) + len ( name [ 0 ] ) <TAB> <TAB> self. transformed_source = ts_prefix + inject + import_stmt + ts_postfix",True,modify_stmt,modify_stmt,0.6818588972091675
|
||
|
3200,"def file_counts_by_category ( self ) : <TAB> artifact_files = 0 <TAB> wandb_files = 0 <TAB> media_files = 0 <TAB> other_files = 0 <TAB> <TAB> <TAB> with self. _lock : <TAB> <TAB> file_stats = list ( self. _stats. items ( ) ) <TAB> for save_name, stats in file_stats : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> artifact_files += 1 <TAB> <TAB> elif wandb. wandb_lib. filenames. is_wandb_file ( save_name ) : <TAB> <TAB> <TAB> wandb_files += 1 <TAB> <TAB> elif save_name. startswith ( ""media"" ) : <TAB> <TAB> <TAB> media_files += 1 <TAB> <TAB> else : <TAB> <TAB> <TAB> other_files += 1 <TAB> return { <TAB> <TAB> ""artifact"" : artifact_files, <TAB> <TAB> ""wandb"" : wandb_files, <TAB> <TAB> ""media"" : media_files, <TAB> <TAB> ""other"" : other_files, <TAB> }",False,stats['artifact_file'],save_name.startswith(artifacts_name),0.6583110094070435
|
||
|
3201,"def _make_surrounding_transparent ( self, building ) : <TAB> """"""Makes the surrounding of building_position transparent"""""" <TAB> world_contains = self. session. world. map_dimensions. contains_without_border <TAB> for coord in building. position. get_radius_coordinates ( <TAB> <TAB> self. nearby_objects_radius, include_self = True <TAB> ) : <TAB> <TAB> p = Point ( * coord ) <TAB> <TAB> if not world_contains ( p ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> tile = self. session. world. get_tile ( p ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> inst = tile. object. fife_instance <TAB> <TAB> <TAB> inst. get2dGfxVisual ( ). setTransparency ( BUILDINGS. TRANSPARENCY_VALUE ) <TAB> <TAB> <TAB> self. _transparent_instances. add ( weakref. ref ( inst ) )",False,tile.object is not None and tile.object.buildable_upon,tile.object and tile.object.fife_instance,0.6533148288726807
|
||
|
3202,"def validateName ( topicName ) : <TAB> """"""Raise TopicNameError if nameTuple not valid as topic name."""""" <TAB> topicNameTuple = tupleize ( topicName ) <TAB> if not topicNameTuple : <TAB> <TAB> reason = ""name tuple must have at least one item!"" <TAB> <TAB> raise TopicNameError ( None, reason ) <TAB> class topic : <TAB> <TAB> pass <TAB> for subname in topicNameTuple : <TAB> <TAB> if not subname : <TAB> <TAB> <TAB> reason = ""can't contain empty string or None"" <TAB> <TAB> <TAB> raise TopicNameError ( topicNameTuple, reason ) <TAB> <TAB> if subname. startswith ( UNDERSCORE ) : <TAB> <TAB> <TAB> reason ='must not start with ""%s""' % UNDERSCORE <TAB> <TAB> <TAB> raise TopicNameError ( topicNameTuple, reason ) <TAB> <TAB> if subname == ALL_TOPICS : <TAB> <TAB> <TAB> reason ='string ""%s"" is reserved for root topic' % ALL_TOPICS <TAB> <TAB> <TAB> raise TopicNameError ( topicNameTuple, reason ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> reason = 'element #%s (""%s"") has invalid characters' % ( <TAB> <TAB> <TAB> <TAB> 1 + list ( topicNameTuple ). index ( subname ), <TAB> <TAB> <TAB> <TAB> subname, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> raise TopicNameError ( topicNameTuple, reason )",False,_validNameRE.match(subname) is None,not validName(subname),0.6495822668075562
|
||
|
3203,"def init_with_context ( self, context ) : <TAB> app_list = get_app_list ( context ) <TAB> app_to_remove = [ ] <TAB> for app in app_list : <TAB> <TAB> app_name = app. get ( ""app_label"", app. get ( ""name"", """" ) ) <TAB> <TAB> app [ ""models"" ] = filter ( <TAB> <TAB> <TAB> lambda model : self. models is None <TAB> <TAB> <TAB> or ( ""%s.%s"" % ( app_name, model [ ""object_name"" ] ) ) in self. models <TAB> <TAB> <TAB> or ( ""%s.*"" % app_name ) in self. models, <TAB> <TAB> <TAB> app [ ""models"" ], <TAB> <TAB> ) <TAB> <TAB> app [ ""models"" ] = filter ( <TAB> <TAB> <TAB> lambda model : self. exclude is None <TAB> <TAB> <TAB> or ( <TAB> <TAB> <TAB> <TAB> ( ""%s.%s"" % ( app_name, model [ ""object_name"" ] ) ) not in self. exclude <TAB> <TAB> <TAB> <TAB> and ( ""%s.*"" % app_name ) not in self. exclude <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> app [ ""models"" ], <TAB> <TAB> ) <TAB> <TAB> app [ ""models"" ] = list ( app [ ""models"" ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> app_to_remove. append ( app ) <TAB> for app in app_to_remove : <TAB> <TAB> app_list. remove ( app ) <TAB> self. children = app_list",False,self.hide_empty and len(list(app['models'])) == 0,len(app_to_remove) > 0,0.6512490510940552
|
||
|
3204,"def extract_completions_from_view ( <TAB> self, view, regex, re_flags, point, current_view, seen ) : <TAB> regions = sorted ( <TAB> <TAB> view. find_all ( regex, re_flags ), key = lambda r : abs ( point - r. begin ( ) ) <TAB> ) <TAB> results = [ ] <TAB> is_current_view = ( <TAB> <TAB> view == current_view or view. buffer_id ( ) == current_view. buffer_id ( ) <TAB> ) <TAB> for region in regions : <TAB> <TAB> if is_current_view and region. contains ( point ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> word = view. substr ( region ) <TAB> <TAB> <TAB> if word not in seen : <TAB> <TAB> <TAB> <TAB> results. append ( word ) <TAB> <TAB> <TAB> <TAB> seen. add ( word ) <TAB> return results",False,MIN_AUTO_COMPLETE_WORD_SIZE <= region.size() <= MAX_AUTO_COMPLETE_WORD_SIZE,region.startswith(view.substr(region)),0.6534420251846313
|
||
|
3205,"def _search_for_tags ( self ) : <TAB> unique_tags = utils. NormalizedDict ( ) <TAB> self. _tags = utils. NormalizedDict ( ) <TAB> self. _test_cases = [ ] <TAB> for test in self. frame. _controller. all_testcases ( ) : <TAB> <TAB> self. _test_cases. append ( test ) <TAB> <TAB> for tag in test. tags : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> tag_name = str ( tag ) <TAB> <TAB> <TAB> if tag_name in unique_tags : <TAB> <TAB> <TAB> <TAB> unique_tags [ tag_name ]. append ( test ) <TAB> <TAB> <TAB> <TAB> self. _tags [ tag_name ]. append ( tag ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> unique_tags [ tag_name ] = [ test ] <TAB> <TAB> <TAB> <TAB> self. _tags [ tag_name ] = [ tag ] <TAB> isreversed = self. sort_state [ 1 ]!= 1 <TAB> self. total_test_cases = len ( self. _test_cases ) <TAB> self. _results = sorted ( <TAB> <TAB> unique_tags. items ( ), key = lambda item : item [ 0 ]. lower ( ), reverse = isreversed <TAB> )",False,tag.is_empty() or len(str(tag).strip()) == 0,tag == 'TAB > <TAB > > ',0.6495128870010376
|
||
|
3206,"def settings_edit ( request, response_format = ""html"" ) : <TAB> ""Settings"" <TAB> if not request. user. profile. is_admin ( ""treeio.services"" ) : <TAB> <TAB> return user_denied ( <TAB> <TAB> <TAB> request, <TAB> <TAB> <TAB> message = ""You don't have administrator access to the Service Support module"", <TAB> <TAB> ) <TAB> if request. POST : <TAB> <TAB> if ""cancel"" not in request. POST : <TAB> <TAB> <TAB> form = SettingsForm ( request. user. profile, request. POST ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> form. save ( ) <TAB> <TAB> <TAB> <TAB> return HttpResponseRedirect ( reverse ( ""services_settings_view"" ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return HttpResponseRedirect ( reverse ( ""services_settings_view"" ) ) <TAB> else : <TAB> <TAB> form = SettingsForm ( request. user. profile ) <TAB> context = _get_default_context ( request ) <TAB> context. update ( { ""form"" : form } ) <TAB> return render_to_response ( <TAB> <TAB> ""services/settings_edit"", <TAB> <TAB> context, <TAB> <TAB> context_instance = RequestContext ( request ), <TAB> <TAB> response_format = response_format, <TAB> )",True,form.is_valid(),form.is_valid(),0.6509705781936646
|
||
|
3207,"def prepare ( self ) : <TAB> info = VideoInfo ( self. name ) <TAB> self. vid = match1 ( self. url, ""video_id=(\d+)"", ""#(\d{5,})"", ""(\d{5,})\.swf"" ) <TAB> if not self. vid : <TAB> <TAB> html = get_content ( self. url ) <TAB> <TAB> self. vid = match1 ( <TAB> <TAB> <TAB> html, ""video_id:'([^']+)"", ""SINA_TEXT_PAGE_INFO[\s\S]+?video_id:?(\d+)"" <TAB> <TAB> ) <TAB> assert self. vid, ""can't get vid"" <TAB> api_url = ""http://s.video.sina.com.cn/video/h5play?video_id={}"". format ( self. vid ) <TAB> data = json. loads ( get_content ( api_url ) ) [ ""data"" ] <TAB> info. title = data [ ""title"" ] <TAB> for t in [ ""mp4"", ""3gp"", ""flv"" ] : <TAB> <TAB> if t in data [ ""videos"" ] : <TAB> <TAB> <TAB> video_info = data [ ""videos"" ] [ t ] <TAB> <TAB> <TAB> break <TAB> for profile in video_info : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> v = video_info [ profile ] <TAB> <TAB> <TAB> tp = v [ ""type"" ] <TAB> <TAB> <TAB> url = v [ ""file_api"" ] + ""?vid="" + v [ ""file_id"" ] <TAB> <TAB> <TAB> r_url = get_realurl ( url ) <TAB> <TAB> <TAB> info. stream_types. append ( profile ) <TAB> <TAB> <TAB> info. streams [ profile ] = { <TAB> <TAB> <TAB> <TAB> ""container"" : tp, <TAB> <TAB> <TAB> <TAB> ""video_profile"" : profile, <TAB> <TAB> <TAB> <TAB> ""src"" : [",False,not profile in info.stream_types,profile in video_info,0.6532030701637268
|
||
|
3208,"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<mask> : <TAB> <TAB> <TAB> break <TAB> <TAB> if fid == 1 : <TAB> <TAB> <TAB> if ftype == TType. STRING : <TAB> <TAB> <TAB> <TAB> self. username = 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.STOP,fid == 0,0.6583912372589111
|
||
|
3209,"def run ( self ) : <TAB> for k, v in iteritems ( self. objs ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> if v [ ""_class"" ] == ""User"" : <TAB> <TAB> <TAB> if v [ ""email"" ] == """" : <TAB> <TAB> <TAB> <TAB> v [ ""email"" ] = None <TAB> <TAB> <TAB> if v [ ""ip"" ] == ""0.0.0.0"" : <TAB> <TAB> <TAB> <TAB> v [ ""ip"" ] = None <TAB> return self. objs",False,k.startswith('_'),k == 'templates',0.648651659488678
|
||
|
3210,"def orderUp ( self, items ) : <TAB> sel = [ ] <TAB> undoinfo = [ ] <TAB> for bid, lid in items : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> undoinfo. append ( self. orderUpLineUndo ( bid, lid ) ) <TAB> <TAB> <TAB> sel. append ( ( bid, lid - 1 ) ) <TAB> <TAB> elif lid is None : <TAB> <TAB> <TAB> undoinfo. append ( self. orderUpBlockUndo ( bid ) ) <TAB> <TAB> <TAB> if bid == 0 : <TAB> <TAB> <TAB> <TAB> return items <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> sel. append ( ( bid - 1, None ) ) <TAB> self. addUndo ( undoinfo, ""Move Up"" ) <TAB> return sel",False,"isinstance(lid, int)",bid == 0,0.6493263244628906
|
||
|
3211,"def value_from_datadict ( self, data, files, name ) : <TAB> <TAB> h = data. get ( self. hour_field % name, 0 ) <TAB> m = data. get ( self. minute_field % name, 0 ) <TAB> meridiem = data. get ( self. meridiem_field % name, None ) <TAB> <TAB> if meridiem is not None : <TAB> <TAB> if meridiem. lower ( ). startswith ( ""p"" ) and int ( h )!= 12 : <TAB> <TAB> <TAB> h = ( int ( h ) + 12 ) % 24 <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> h = 0 <TAB> if ( int ( h ) == 0 or h ) and m and s : <TAB> <TAB> return ""%s:%s:%s"" % ( h, m, s ) <TAB> return data. get ( name, None )",False,meridiem.lower().startswith('a') and int(h) == 12,h == 0 and m,0.6493932604789734
|
||
|
3212,"def _merge_knowledge ( self, knowledge ) : <TAB> for k, tensors in list ( knowledge. items ( ) ) : <TAB> <TAB> if len ( tensors ) == 0 : <TAB> <TAB> <TAB> del knowledge [ k ] <TAB> <TAB> elif len ( tensors ) == 1 : <TAB> <TAB> <TAB> knowledge [ k ] = tensors [ 0 ] <TAB> <TAB> else : <TAB> <TAB> <TAB> result = 0 <TAB> <TAB> <TAB> for tensor in tensors : <TAB> <TAB> <TAB> <TAB> result += tensor <TAB> <TAB> <TAB> if self. _merge_strategy [ k ] == ""sum"" : <TAB> <TAB> <TAB> <TAB> knowledge [ k ] = result <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> knowledge [ k ] = result / len ( tensors ) <TAB> <TAB> <TAB> <TAB> tgt_dtype = self. _knowledge_desc [ k ] [ ""dtype"" ] <TAB> <TAB> if str ( knowledge [ k ]. dtype )!= tgt_dtype : <TAB> <TAB> <TAB> knowledge [ k ] = knowledge [ k ]. astype ( tgt_dtype ) <TAB> return knowledge",False,self._merge_strategy[k] == 'mean',self._merge_strategy[k] == 'sum',0.6594252586364746
|
||
|
3213,"def decorated_function ( * args, ** kwargs ) : <TAB> <TAB> m = kwargs. pop if pop_exception_fields else kwargs. get <TAB> exception_values = { <TAB> <TAB> ""index"" : m ( ""index"" ), <TAB> <TAB> ""account"" : m ( ""account_name"", None ), <TAB> <TAB> ""exception_record_region"" : m ( ""exception_record_region"", None ), <TAB> <TAB> ""name"" : m ( ""name"", None ), <TAB> <TAB> ""exception_map"" : m ( ""exception_map"", { } ), <TAB> } <TAB> try : <TAB> <TAB> return f ( * args, ** kwargs ) <TAB> except Exception as e : <TAB> <TAB> if sentry : <TAB> <TAB> <TAB> sentry. captureException ( ) <TAB> <TAB> index = exception_values [ ""index"" ] <TAB> <TAB> account = exception_values [ ""account"" ] <TAB> <TAB> <TAB> <TAB> region = exception_values [ ""exception_record_region"" ] or kwargs. get ( ""region"" ) <TAB> <TAB> name = exception_values [ ""name"" ] <TAB> <TAB> exception_map = exception_values [ ""exception_map"" ] <TAB> <TAB> exc = BotoConnectionIssue ( str ( e ), index, account, name ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> location = ( index, account, region, name ) <TAB> <TAB> elif region : <TAB> <TAB> <TAB> location = ( index, account, region ) <TAB> <TAB> elif account : <TAB> <TAB> <TAB> location = ( index, account ) <TAB> <TAB> else : <TAB> <TAB> <TAB> location = ( index, ) <TAB> <TAB> exception_map [ location ] = exc <TAB> <TAB> <TAB> <TAB> store_exception ( source = source, location = location, exception = e )",False,name,exception_map,0.6836172342300415
|
||
|
3214,"def _match_show ( self, show, identifier ) : <TAB> <TAB> default_season = None <TAB> if ""default_season"" in show. parameters : <TAB> <TAB> default_season = show. parameters [ ""default_season"" ] <TAB> <TAB> if default_season!= ""a"" : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> default_season = try_convert ( default_season, int ) <TAB> <TAB> <TAB> if default_season is None : <TAB> <TAB> <TAB> <TAB> log. warn ( <TAB> <TAB> <TAB> <TAB> <TAB> 'Invalid value provided for the ""default_season"" parameter: %r', <TAB> <TAB> <TAB> <TAB> <TAB> show. parameters [ ""default_season"" ], <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> return None <TAB> <TAB> season_num = identifier. season_num <TAB> if season_num is None or default_season is None or default_season == ""a"" : <TAB> <TAB> season_num = default_season <TAB> elif season_num > 0 : <TAB> <TAB> season_num = default_season + ( season_num - 1 ) <TAB> <TAB> episode_num = identifier. episode_num <TAB> if ""episode_offset"" in show. parameters : <TAB> <TAB> episode_num += int ( show. parameters [ ""episode_offset"" ] ) <TAB> <TAB> if season_num!= ""a"" : <TAB> <TAB> match = EpisodeMatch ( <TAB> <TAB> <TAB> self. _get_identifiers ( show ), season_num = season_num, episode_num = episode_num <TAB> <TAB> ) <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise AbsoluteNumberRequiredError ( <TAB> <TAB> <TAB> <TAB> ""Unable to match %r, an absolute number is required"" % identifier <TAB> <TAB> <TAB> ) <TAB> <TAB> match = EpisodeMatch ( <TAB> <TAB",False,identifier.absolute_num is None,identifier.has_absolute_number(),0.6543298959732056
|
||
|
3215,"def _load_module ( self ) : <TAB> spec = self. default_module_spec <TAB> module_identifier = self. module_identifier <TAB> if module_identifier : <TAB> <TAB> impls = self. get_module_implementation_map ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ModuleNotFound ( <TAB> <TAB> <TAB> <TAB> ""Invalid module identifier %r in %s"" <TAB> <TAB> <TAB> <TAB> % ( module_identifier, force_ascii ( repr ( self ) ) ) <TAB> <TAB> <TAB> ) <TAB> <TAB> spec = impls [ module_identifier ] <TAB> cls = load ( <TAB> <TAB> spec, context_explanation = ""Loading module for %s"" % force_ascii ( repr ( self ) ) <TAB> ) <TAB> options = getattr ( self, self. module_options_field, None ) or { } <TAB> return cls ( self, options )",True,module_identifier not in impls,module_identifier not in impls,0.6659382581710815
|
||
|
3216,"def _validate_action_like_for_prefixes ( self, key ) : <TAB> for statement in self. _statements : <TAB> <TAB> if key in statement : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. _validate_action_prefix ( statement [ key ] ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> for action in statement [ key ] : <TAB> <TAB> <TAB> <TAB> <TAB> self. _validate_action_prefix ( action )",False,"isinstance(statement[key], string_types)","isinstance(statement[key], list)",0.6505589485168457
|
||
|
3217,"def handle_side ( split_cls, is_before, amount, trying_other_side = False ) : <TAB> ""Increase weights on one side. (top/left/right/bottom)."" <TAB> if amount : <TAB> <TAB> split, child = find_split_and_child ( split_cls, is_before ) <TAB> <TAB> if split : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> neighbour_index = split. index ( child ) + ( - 1 if is_before else 1 ) <TAB> <TAB> <TAB> neighbour_child = split [ neighbour_index ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> split. weights [ child ] += amount <TAB> <TAB> <TAB> split. weights [ neighbour_child ] -= amount <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for k, value in split. weights. items ( ) : <TAB> <TAB> <TAB> <TAB> if value < 1 : <TAB> <TAB> <TAB> <TAB> <TAB> split. weights [ k ] = 1 <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> handle_side ( split_cls, not is_before, - amount, trying_other_side = True )",False,not trying_other_side,trying_other_side,0.6483529806137085
|
||
|
3218,"def checker ( expected_events ) : <TAB> self. assertTrue ( handler_called, ""Handler should have been called"" ) <TAB> for ( e_task_id, e_subtask_id, e_op ) in expected_events [ : : - 1 ] : <TAB> <TAB> sender, signal, event, task_id, subtask_id, op = params. pop ( ) <TAB> <TAB> self. assertEqual ( event, ""task_status_updated"", ""Bad event"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. assertEqual ( task_id, e_task_id, ""wrong task"" ) <TAB> <TAB> if e_subtask_id : <TAB> <TAB> <TAB> self. assertIsNotNone ( subtask_id, ""No subtask_id"" ) <TAB> <TAB> <TAB> self. assertEqual ( subtask_id, e_subtask_id, ""Bad subtask_id"" ) <TAB> <TAB> if e_op : <TAB> <TAB> <TAB> self. assertIsNotNone ( op, ""No operation"" ) <TAB> <TAB> <TAB> self. assertEqual ( op, e_op, ""Bad operation"" )",True,e_task_id,e_task_id,0.6649091839790344
|
||
|
3219,"def handle_event ( self, fileno = None, events = None ) : <TAB> if self. _state == RUN : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _it = self. _process_result ( 0 ) <TAB> <TAB> try : <TAB> <TAB> <TAB> next ( self. _it ) <TAB> <TAB> except ( StopIteration, CoroStop ) : <TAB> <TAB> <TAB> self. _it = None",False,self._it is None,self.has_result(),0.6617438793182373
|
||
|
3220,"def _process_async_callback ( <TAB> self, callback_results : AsyncGeneratorType, response : Response = None ) : <TAB> try : <TAB> <TAB> async for callback_result in callback_results : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> await self. _process_async_callback ( callback_result ) <TAB> <TAB> <TAB> elif isinstance ( callback_result, Request ) : <TAB> <TAB> <TAB> <TAB> self. request_queue. put_nowait ( <TAB> <TAB> <TAB> <TAB> <TAB> self. handle_request ( request = callback_result ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> elif isinstance ( callback_result, typing. Coroutine ) : <TAB> <TAB> <TAB> <TAB> self. request_queue. put_nowait ( <TAB> <TAB> <TAB> <TAB> <TAB> self. handle_callback ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> aws_callback = callback_result, response = response <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> elif isinstance ( callback_result, Item ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> await self. process_item ( callback_result ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> await self. process_callback_result ( callback_result = callback_result ) <TAB> except NothingMatchedError as e : <TAB> <TAB> error_info = f""<Field: {str(e).lower()}"" + f"", error url: {response.url}>"" <TAB> <TAB> self. logger. exception ( error_info ) <TAB> except Exception as e : <TAB> <TAB> self. logger. exception ( e )",False,"isinstance(callback_result, AsyncGeneratorType)","isinstance(callback_result, asyncio.futures.Future)",0.6544405221939087
|
||
|
3221,"def make_course_schedule_test_record ( ** args ) : <TAB> args = frappe. _dict ( args ) <TAB> course_schedule = frappe. new_doc ( ""Course Schedule"" ) <TAB> course_schedule. student_group = ( <TAB> <TAB> args. student_group or ""Course-TC101-2014-2015 (_Test Academic Term)"" <TAB> ) <TAB> course_schedule. course = args. course or ""TC101"" <TAB> course_schedule. instructor = args. instructor or ""_Test Instructor"" <TAB> course_schedule. room = args. room or frappe. get_all ( ""Room"" ) [ 0 ]. name <TAB> course_schedule. schedule_date = args. schedule_date or today ( ) <TAB> course_schedule. from_time = args. from_time or to_timedelta ( ""01:00:00"" ) <TAB> course_schedule. to_time = ( <TAB> <TAB> args. to_time or course_schedule. from_time + datetime. timedelta ( hours = 1 ) <TAB> ) <TAB> if not args. do_not_save : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> while True : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> course_schedule. save ( ) <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> except OverlapError : <TAB> <TAB> <TAB> <TAB> <TAB> course_schedule. from_time = ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> course_schedule. from_time + datetime. timedelta ( minutes = 10 ) <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> course_schedule. to_time = ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> course_schedule. from_time + datetime. timedelta ( hours = 1 ) <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB",False,args.simulate,args.to_time,0.6675100922584534
|
||
|
3222,"def _get_member_pairs ( self, cls, inst, tags ) : <TAB> old_len = len ( tags ) <TAB> tags = tags | { id ( inst ) } <TAB> assert len ( tags ) > old_len, ""Offending instance: %r"" % inst <TAB> for k, v in self. sort_fields ( cls ) : <TAB> <TAB> subattr = self. get_cls_attrs ( v ) <TAB> <TAB> if subattr. exc : <TAB> <TAB> <TAB> continue <TAB> <TAB> try : <TAB> <TAB> <TAB> subinst = getattr ( inst, k, None ) <TAB> <TAB> <TAB> <TAB> except Exception as e : <TAB> <TAB> <TAB> logger. error ( ""Error getting %r: %r"" % ( k, e ) ) <TAB> <TAB> <TAB> subinst = None <TAB> <TAB> if subinst is None : <TAB> <TAB> <TAB> subinst = subattr. default <TAB> <TAB> else : <TAB> <TAB> <TAB> if id ( subinst ) in tags : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> logger. debug ( ""%s%r%r"", "" "" * len ( tags ), k, v ) <TAB> <TAB> val = self. _object_to_doc ( v, subinst, tags ) <TAB> <TAB> min_o = subattr. min_occurs <TAB> <TAB> complex_as = self. get_complex_as ( subattr ) <TAB> <TAB> if val is not None or min_o > 0 or complex_as is list : <TAB> <TAB> <TAB> sub_name = subattr. sub_name <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> sub_name = k <TAB> <TAB> <TAB> yield ( sub_name, val )",True,sub_name is None,sub_name is None,0.6572946310043335
|
||
|
3223,"def toEncodedString ( s, encoding = ""utf-8"", reportErrors = False ) : <TAB> if encoding is None : <TAB> <TAB> encoding = ""utf-8"" <TAB> if isUnicode ( s ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> s = s. encode ( encoding, ""strict"" ) <TAB> <TAB> except UnicodeError : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> reportBadChars ( s, encoding ) <TAB> <TAB> <TAB> s = s. encode ( encoding, ""replace"" ) <TAB> return s",True,reportErrors,reportErrors,0.670697808265686
|
||
|
3224,"def extract_file ( tgz, tarinfo, dst_path, buffer_size = 10 << 20, log_function = None ) : <TAB> """"""Extracts 'tarinfo' from 'tgz' and writes to 'dst_path'."""""" <TAB> src = tgz. extractfile ( tarinfo ) <TAB> if src is None : <TAB> <TAB> return <TAB> dst = tf. compat. v1. gfile. GFile ( dst_path, ""wb"" ) <TAB> while 1 : <TAB> <TAB> buf = src. read ( buffer_size ) <TAB> <TAB> if not buf : <TAB> <TAB> <TAB> break <TAB> <TAB> dst. write ( buf ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> log_function ( len ( buf ) ) <TAB> dst. close ( ) <TAB> src. close ( )",False,log_function is not None,log_function,0.6535816192626953
|
||
|
3225,"def _handle_Call ( self, stmt_idx : int, stmt : Call, block : Block ) : <TAB> if stmt. args : <TAB> <TAB> i = 0 <TAB> <TAB> new_exprs = [ ] <TAB> <TAB> while i < len ( stmt. args ) : <TAB> <TAB> <TAB> arg = stmt. args [ i ] <TAB> <TAB> <TAB> new_expr = self. _handle_expr ( i, arg, stmt_idx, stmt, block ) <TAB> <TAB> <TAB> new_exprs. append ( new_expr ) <TAB> <TAB> <TAB> i += 1 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> new_args = [ <TAB> <TAB> <TAB> <TAB> ( new_arg if new_arg is not None else old_arg ) <TAB> <TAB> <TAB> <TAB> for new_arg, old_arg in zip ( new_exprs, stmt. args ) <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> new_stmt = Call ( <TAB> <TAB> <TAB> <TAB> stmt. idx, <TAB> <TAB> <TAB> <TAB> stmt. target, <TAB> <TAB> <TAB> <TAB> calling_convention = stmt. calling_convention, <TAB> <TAB> <TAB> <TAB> prototype = stmt. prototype, <TAB> <TAB> <TAB> <TAB> args = new_args, <TAB> <TAB> <TAB> <TAB> ret_expr = stmt. ret_expr, <TAB> <TAB> <TAB> <TAB> ** stmt. tags <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> return new_stmt <TAB> return None",False,any((expr is not None for expr in new_exprs)),len(new_exprs) > 0,0.6578378081321716
|
||
|
3226,"def cascade ( self, event = None ) : <TAB> """"""Cascade all Leo windows."""""" <TAB> x, y, delta = 50, 50, 50 <TAB> for frame in g. app. windowList : <TAB> <TAB> w = frame and frame. top <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> r = w. geometry ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> w. setGeometry ( QtCore. QRect ( x, y, r. width ( ), r. height ( ) ) ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> x += 30 <TAB> <TAB> <TAB> y += 30 <TAB> <TAB> <TAB> if x > 200 : <TAB> <TAB> <TAB> <TAB> x = 10 + delta <TAB> <TAB> <TAB> <TAB> y = 40 + delta <TAB> <TAB> <TAB> <TAB> delta += 10",False,w,w and w.type() == QtCore.QEvent.Cascade,0.7161666750907898
|
||
|
3227,"def extract_comments ( directory ) : <TAB> for parent, dir_names, file_names in os. walk ( directory ) : <TAB> <TAB> for file_name in file_names : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> doc = get_comments_str ( os. path. join ( parent, file_name ) ) <TAB> <TAB> <TAB> <TAB> directory_out = os. path. join ( ""docs"", parent. replace ( directory, """" ) ) <TAB> <TAB> <TAB> <TAB> if not os. path. exists ( directory_out ) : <TAB> <TAB> <TAB> <TAB> <TAB> os. makedirs ( directory_out ) <TAB> <TAB> <TAB> <TAB> output_file = open ( <TAB> <TAB> <TAB> <TAB> <TAB> os. path. join ( directory_out, file_name [ : - 3 ] + "".md"" ), ""w"" <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> output_file. write ( doc ) <TAB> <TAB> <TAB> <TAB> output_file. close ( )",False,os.path.splitext(file_name)[1] == '.py' and file_name != '__init__.py',file_name.endswith('.md'),0.6516644954681396
|
||
|
3228,"def __init__ ( self, artifact_uri, client = None ) : <TAB> self. uri = artifact_uri <TAB> parsed = urllib. parse. urlparse ( artifact_uri ) <TAB> self. config = { <TAB> <TAB> ""host"" : parsed. hostname, <TAB> <TAB> ""port"" : parsed. port, <TAB> <TAB> ""username"" : parsed. username, <TAB> <TAB> ""password"" : parsed. password, <TAB> } <TAB> self. path = parsed. path <TAB> if client : <TAB> <TAB> self. sftp = client <TAB> else : <TAB> <TAB> import pysftp <TAB> <TAB> import paramiko <TAB> <TAB> if self. config [ ""host"" ] is None : <TAB> <TAB> <TAB> self. config [ ""host"" ] = ""localhost"" <TAB> <TAB> ssh_config = paramiko. SSHConfig ( ) <TAB> <TAB> user_config_file = os. path. expanduser ( ""~/.ssh/config"" ) <TAB> <TAB> if os. path. exists ( user_config_file ) : <TAB> <TAB> <TAB> with open ( user_config_file ) as f : <TAB> <TAB> <TAB> <TAB> ssh_config. parse ( f ) <TAB> <TAB> user_config = ssh_config. lookup ( self. config [ ""host"" ] ) <TAB> <TAB> if ""hostname"" in user_config : <TAB> <TAB> <TAB> self. config [ ""host"" ] = user_config [ ""hostname"" ] <TAB> <TAB> if self. config. get ( ""username"", None ) is None and ""user"" in user_config : <TAB> <TAB> <TAB> self. config [ ""username"" ] = user_config [ ""user"" ] <TAB> <TAB> if self. config. get ( ""port"", None ) is None : <TAB> <TAB> <TAB> if ""port"" in user_config : <TAB> <TAB> <TAB> <TAB> self. config [ ""port"" ] = int ( user_config [ ""port"" ] ) <TAB> <TAB> <TAB> else : <TAB> <",False,'identityfile' in user_config,self.uri is None,0.651397168636322
|
||
|
3229,"def _check_exe ( self, app_data, folder, name, exact, discovered, env ) : <TAB> exe_path = os. path. join ( folder, name ) <TAB> if not os. path. exists ( exe_path ) : <TAB> <TAB> return None <TAB> info = self. from_exe ( <TAB> <TAB> exe_path, app_data, resolve_to_host = False, raise_on_error = False, env = env <TAB> ) <TAB> if info is None : <TAB> <TAB> return None <TAB> for item in [ ""implementation"", ""architecture"", ""version_info"" ] : <TAB> <TAB> found = getattr ( info, item ) <TAB> <TAB> searched = getattr ( self, item ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if item == ""version_info"" : <TAB> <TAB> <TAB> <TAB> found, searched = ""."". join ( str ( i ) for i in found ), ""."". join ( <TAB> <TAB> <TAB> <TAB> <TAB> str ( i ) for i in searched <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> executable = info. executable <TAB> <TAB> <TAB> logging. debug ( <TAB> <TAB> <TAB> <TAB> ""refused interpreter %s because %s differs %s!= %s"", <TAB> <TAB> <TAB> <TAB> executable, <TAB> <TAB> <TAB> <TAB> item, <TAB> <TAB> <TAB> <TAB> found, <TAB> <TAB> <TAB> <TAB> searched, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if exact is False : <TAB> <TAB> <TAB> <TAB> discovered. append ( info ) <TAB> <TAB> <TAB> break <TAB> else : <TAB> <TAB> return info <TAB> return None",False,found != searched,found,0.673133373260498
|
||
|
3230,"def net_arch ( input, return_mid_layer = False, return_block = None ) : <TAB> mid_layer = dict ( ) <TAB> layer_count = 0 <TAB> for i, layer_setting in enumerate ( self. bottleneck_params_list ) : <TAB> <TAB> filter_num1, filter_num2, stride, kernel_size = layer_setting <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> layer_count += 1 <TAB> <TAB> if check_points ( ( layer_count - 1 ), return_block ) : <TAB> <TAB> <TAB> mid_layer [ layer_count - 1 ] = input <TAB> <TAB> input = self. _depthwise_separable ( <TAB> <TAB> <TAB> input = input, <TAB> <TAB> <TAB> num_filters1 = filter_num1, <TAB> <TAB> <TAB> num_filters2 = filter_num2, <TAB> <TAB> <TAB> stride = stride, <TAB> <TAB> <TAB> scale = self. scale, <TAB> <TAB> <TAB> kernel_size = int ( kernel_size ), <TAB> <TAB> <TAB> name = ""mobilenetv1_{}"". format ( str ( i + 1 ) ), <TAB> <TAB> ) <TAB> if return_mid_layer : <TAB> <TAB> return input, mid_layer <TAB> else : <TAB> <TAB> return ( input, )",False,stride == 2,stride != -1,0.6794700622558594
|
||
|
3231,"def _ensure_cluster_exists ( self, context, service ) : <TAB> if self. cluster : <TAB> <TAB> try : <TAB> <TAB> <TAB> cluster = objects. Cluster. get_by_id ( <TAB> <TAB> <TAB> <TAB> context, None, name = self. cluster, binary = self. binary <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> error_states = ( <TAB> <TAB> <TAB> <TAB> fields. ReplicationStatus. ERROR, <TAB> <TAB> <TAB> <TAB> fields. ReplicationStatus. FAILOVER_ERROR, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if service. replication_status not in error_states : <TAB> <TAB> <TAB> <TAB> for attr in ( ""replication_status"", ""active_backend_id"", ""frozen"" ) : <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> setattr ( service, attr, getattr ( cluster, attr ) ) <TAB> <TAB> except exception. ClusterNotFound : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> cluster = objects. Cluster ( <TAB> <TAB> <TAB> <TAB> context = context, <TAB> <TAB> <TAB> <TAB> name = self. cluster, <TAB> <TAB> <TAB> <TAB> binary = self. binary, <TAB> <TAB> <TAB> <TAB> disabled = service. disabled, <TAB> <TAB> <TAB> <TAB> replication_status = service. replication_status, <TAB> <TAB> <TAB> <TAB> active_backend_id = service. active_backend_id, <TAB> <TAB> <TAB> <TAB> frozen = service. frozen, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> cluster. create ( ) <TAB>",False,"getattr(service, attr) != getattr(cluster, attr)","hasattr(service, attr)",0.6455761194229126
|
||
|
3232,"def write_html ( self, html ) : <TAB> <TAB> html = html. replace ( ""\n"", "" "" ) <TAB> a = re. split ( ""<(.*?)>"", html ) <TAB> for i, e in enumerate ( a ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if self. href : <TAB> <TAB> <TAB> <TAB> self. put_link ( self. href, e ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. write ( 5, e ) <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if e [ 0 ] == ""/"" : <TAB> <TAB> <TAB> <TAB> self. close_tag ( e [ 1 : ]. upper ( ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> attr = { } <TAB> <TAB> <TAB> <TAB> a2 = e. split ( "" "" ) <TAB> <TAB> <TAB> <TAB> tag = a2. pop ( 0 ). upper ( ) <TAB> <TAB> <TAB> <TAB> for v in a2 : <TAB> <TAB> <TAB> <TAB> <TAB> a3 = re. findall ( """"""^([^=]*)=[""']?([^""']*)[""']?"""""", v ) [ 0 ] <TAB> <TAB> <TAB> <TAB> <TAB> if a3 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> attr [ a3 [ 0 ]. upper ( ) ] = a3 [ 1 ] <TAB> <TAB> <TAB> <TAB> self. open_tag ( tag, attr )",True,i % 2 == 0,i % 2 == 0,0.6727467179298401
|
||
|
3233,"def delete_doc ( elastic_document_id, node, index = None, category = None ) : <TAB> index = index or INDEX <TAB> if not category : <TAB> <TAB> if isinstance ( node, Preprint ) : <TAB> <TAB> <TAB> category = ""preprint"" <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> category = ""registration"" <TAB> <TAB> else : <TAB> <TAB> <TAB> category = node. project_or_component <TAB> client ( ). delete ( <TAB> <TAB> index = index, <TAB> <TAB> doc_type = category, <TAB> <TAB> id = elastic_document_id, <TAB> <TAB> refresh = True, <TAB> <TAB> ignore = [ 404 ], <TAB> )",False,node.is_registration,"isinstance(node, registration)",0.6634782552719116
|
||
|
3234,"def import_files ( self, files ) : <TAB> """"""Import a list of MORE (.csv) files."""""" <TAB> c = self. c <TAB> if files : <TAB> <TAB> changed = False <TAB> <TAB> self. tab_width = c. getTabWidth ( c. p ) <TAB> <TAB> for fileName in files : <TAB> <TAB> <TAB> g. setGlobalOpenDir ( fileName ) <TAB> <TAB> <TAB> p = self. import_file ( fileName ) <TAB> <TAB> <TAB> if p : <TAB> <TAB> <TAB> <TAB> p. contract ( ) <TAB> <TAB> <TAB> <TAB> p. setDirty ( ) <TAB> <TAB> <TAB> <TAB> c. setChanged ( True ) <TAB> <TAB> <TAB> <TAB> changed = True <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> c. redraw ( p )",True,changed,changed,0.6894515156745911
|
||
|
3235,"def __hierarchyViewKeyPress ( hierarchyView, event ) : <TAB> if event == __editSourceKeyPress : <TAB> <TAB> selectedPath = __hierarchyViewSelectedPath ( hierarchyView ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> __editSourceNode ( <TAB> <TAB> <TAB> <TAB> hierarchyView. getContext ( ), hierarchyView. scene ( ), selectedPath <TAB> <TAB> <TAB> ) <TAB> <TAB> return True <TAB> elif event == __editTweaksKeyPress : <TAB> <TAB> selectedPath = __hierarchyViewSelectedPath ( hierarchyView ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> __editTweaksNode ( <TAB> <TAB> <TAB> <TAB> hierarchyView. getContext ( ), hierarchyView. scene ( ), selectedPath <TAB> <TAB> <TAB> ) <TAB> <TAB> return True",True,selectedPath is not None,selectedPath is not None,0.6640335321426392
|
||
|
3236,"def _read_fixed_body ( <TAB> self, content_length : int, delegate : httputil. HTTPMessageDelegate ) -> None : <TAB> while content_length > 0 : <TAB> <TAB> body = await self. stream. read_bytes ( <TAB> <TAB> <TAB> min ( self. params. chunk_size, content_length ), partial = True <TAB> <TAB> ) <TAB> <TAB> content_length -= len ( body ) <TAB> <TAB> if not self. _write_finished or self. is_client : <TAB> <TAB> <TAB> with _ExceptionLoggingContext ( app_log ) : <TAB> <TAB> <TAB> <TAB> ret = delegate. data_received ( body ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> await ret",True,ret is not None,ret is not None,0.6605342626571655
|
||
|
3237,"def __init__ ( <TAB> self, num_layers = 12, out_filters = 24, in_channels = 3, num_classes = 10, dropout_rate = 0.0 ) : <TAB> super ( ). __init__ ( ) <TAB> self. num_layers = num_layers <TAB> self. num_classes = num_classes <TAB> self. out_filters = out_filters <TAB> self. stem = nn. Sequential ( <TAB> <TAB> nn. Conv2d ( in_channels, out_filters, 3, 1, 1, bias = False ), <TAB> <TAB> nn. BatchNorm2d ( out_filters ), <TAB> ) <TAB> pool_distance = self. num_layers // 3 <TAB> self. pool_layers_idx = [ pool_distance - 1, 2 * pool_distance - 1 ] <TAB> self. dropout_rate = dropout_rate <TAB> self. dropout = nn. Dropout ( self. dropout_rate ) <TAB> self. layers = nn. ModuleList ( ) <TAB> self. pool_layers = nn. ModuleList ( ) <TAB> labels = [ ] <TAB> for layer_id in range ( self. num_layers ) : <TAB> <TAB> labels. append ( ""layer_{}"". format ( layer_id ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. pool_layers. append ( <TAB> <TAB> <TAB> <TAB> FactorizedReduce ( self. out_filters, self. out_filters ) <TAB> <TAB> <TAB> ) <TAB> <TAB> self. layers. append ( <TAB> <TAB> <TAB> ENASMacroLayer ( labels [ - 1 ], labels [ : - 1 ], self. out_filters, self. out_filters ) <TAB> <TAB> ) <TAB> self. gap = nn. AdaptiveAvgPool2d ( 1 ) <TAB> self. dense = nn. Linear ( self. out_filters, self. num_classes )",False,layer_id in self.pool_layers_idx,self.num_classes > 0,0.6505498886108398
|
||
|
3238,"def validate ( self, value ) : <TAB> if value. grid_id is not None : <TAB> <TAB> if not isinstance ( value, self. proxy_class ) : <TAB> <TAB> <TAB> self. error ( ""FileField only accepts GridFSProxy values"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. error ( ""Invalid GridFSProxy value"" )",False,"not isinstance(value.grid_id, ObjectId)",value.grid_id != value.grid_id,0.6512499451637268
|
||
|
3239,"def free_tileable_data ( self, tileable_key, skip_chunk_keys = None, wait = False ) : <TAB> tileable = self. _get_tileable_by_key ( tileable_key ) <TAB> futures = [ ] <TAB> for chunk in tileable. chunks : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> if isinstance ( chunk. op, Fetch ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> futures. append ( <TAB> <TAB> <TAB> self. _get_operand_ref ( chunk. op. key ). free_data ( <TAB> <TAB> <TAB> <TAB> check = False, _tell = not wait, _wait = False <TAB> <TAB> <TAB> ) <TAB> <TAB> ) <TAB> logger. debug ( <TAB> <TAB> ""Free tileable data: %s, chunk keys: %r"", <TAB> <TAB> tileable_key, <TAB> <TAB> [ c. key for c in tileable. chunks ], <TAB> ) <TAB> [ f. result ( ) for f in futures ]",False,skip_chunk_keys is not None and chunk.key in skip_chunk_keys,skip_chunk_keys and chunk.chunk_key in chunk.keys,0.6489095687866211
|
||
|
3240,"def optimize ( self, graph : Graph ) -> Tuple [ Graph, bool ] : <TAB> flag_changed = False <TAB> for op in traverse. filter_nodes ( traverse. listup_operators ( graph ), Linear ) : <TAB> <TAB> x = op. inputs [ ""x"" ] <TAB> <TAB> w = op. inputs [ ""w"" ] <TAB> <TAB> y = op. outputs [ ""y"" ] <TAB> <TAB> flag_changed = True <TAB> <TAB> op. remove_all ( ) <TAB> <TAB> a_filter = Axis ( ) <TAB> <TAB> if x. ndim == 2 : <TAB> <TAB> <TAB> ( w, ) = ReinterpretAxis ( <TAB> <TAB> <TAB> <TAB> None, in_order = OrderNC, out_order = Order ( [ Axis. C, a_filter ] ) <TAB> <TAB> <TAB> ) ( w ) <TAB> <TAB> <TAB> ( new_y, ) = Tensordot ( None, axes = [ Axis. C, a_filter ] ) ( x, w ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> ( w, ) = ReinterpretAxis ( <TAB> <TAB> <TAB> <TAB> None, <TAB> <TAB> <TAB> <TAB> in_order = OrderNHWC, <TAB> <TAB> <TAB> <TAB> out_order = Order ( [ Axis. C, Axis. H, Axis. W, a_filter ] ), <TAB> <TAB> <TAB> ) ( w ) <TAB> <TAB> <TAB> ( new_y, ) = Tensordot ( <TAB> <TAB> <TAB> <TAB> None, axes = [ [ Axis. H, Axis. W, Axis. C ], [ Axis. H, Axis. W, a_filter ] ] <TAB> <TAB> <TAB> ) ( x, w ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise NotImplementedError <TAB> <TAB> OptimizeRule. replace_variable ( graph, new_y. transpose_like ( y ), y ) <TAB> return graph, flag_changed",False,x.ndim == 4,y.ndim == 3,0.6635209321975708
|
||
|
3241,"def merge_polygons ( gPOLYGONS ) : <TAB> <TAB> print ( "" Start merge lines 2"" ) <TAB> for poly1 in gPOLYGONS : <TAB> <TAB> if poly1. delete : <TAB> <TAB> <TAB> continue <TAB> <TAB> tmp_points1 = poly1. points <TAB> <TAB> for poly2 in gPOLYGONS : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> tmp_points2 = poly2. points <TAB> <TAB> <TAB> dist1 = calc_dist ( <TAB> <TAB> <TAB> <TAB> tmp_points1 [ 0 ], <TAB> <TAB> <TAB> <TAB> tmp_points1 [ 1 ], <TAB> <TAB> <TAB> <TAB> tmp_points2 [ len ( tmp_points2 ) - 2 ], <TAB> <TAB> <TAB> <TAB> tmp_points2 [ - 1 ], <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> dist2 = calc_dist ( <TAB> <TAB> <TAB> <TAB> tmp_points1 [ len ( tmp_points1 ) - 2 ], <TAB> <TAB> <TAB> <TAB> tmp_points1 [ - 1 ], <TAB> <TAB> <TAB> <TAB> tmp_points2 [ 0 ], <TAB> <TAB> <TAB> <TAB> tmp_points2 [ 1 ], <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if dist2 < TINY : <TAB> <TAB> <TAB> <TAB> del tmp_points2 [ 0 : 2 ] <TAB> <TAB> <TAB> <TAB> tmp_points1 = tmp_points1 + tmp_points2 <TAB> <TAB> <TAB> <TAB> poly2. delete = 1 <TAB> <TAB> <TAB> elif dist1 < TINY and dist2 > TINY : <TAB> <TAB> <TAB> <TAB> tmp_points2. pop ( ) <TAB> <TAB> <TAB> <TAB> tmp_points2. pop",False,poly2.delete or poly1 == poly2,poly2.delete,0.6651265025138855
|
||
|
3242,"def represent_mapping ( self, tag, mapping, flow_style = None ) : <TAB> value = [ ] <TAB> node = MappingNode ( tag, value, flow_style = flow_style ) <TAB> if self. alias_key is not None : <TAB> <TAB> self. represented_objects [ self. alias_key ] = node <TAB> best_style = True <TAB> if hasattr ( mapping, ""items"" ) : <TAB> <TAB> mapping = list ( mapping. items ( ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> mapping = sorted ( mapping ) <TAB> <TAB> <TAB> except TypeError : <TAB> <TAB> <TAB> <TAB> pass <TAB> for item_key, item_value in mapping : <TAB> <TAB> node_key = self. represent_data ( item_key ) <TAB> <TAB> node_value = self. represent_data ( item_value ) <TAB> <TAB> if not ( isinstance ( node_key, ScalarNode ) and not node_key. style ) : <TAB> <TAB> <TAB> best_style = False <TAB> <TAB> if not ( isinstance ( node_value, ScalarNode ) and not node_value. style ) : <TAB> <TAB> <TAB> best_style = False <TAB> <TAB> value. append ( ( node_key, node_value ) ) <TAB> if flow_style is None : <TAB> <TAB> if self. default_flow_style is not None : <TAB> <TAB> <TAB> node. flow_style = self. default_flow_style <TAB> <TAB> else : <TAB> <TAB> <TAB> node. flow_style = best_style <TAB> return node",False,self.sort_keys,len(mapping) > 0,0.6560173630714417
|
||
|
3243,"def cleanBuildDir ( self ) : <TAB> log. debug ( ""========== cleanBuildDir()"" ) <TAB> log. info ( ""Cleaning build and output directories"" ) <TAB> if ( <TAB> <TAB> sys. platform == ""win32"" <TAB> ) : <TAB> <TAB> MY_EXCEPTION = WindowsError <TAB> elif sys. platform == ""linux2"" : <TAB> <TAB> MY_EXCEPTION = OSError <TAB> if os. path. exists ( self. build_root ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> log. info ( ""removing directory: %s"" % self. build_root ) <TAB> <TAB> <TAB> shutil. rmtree ( self. build_root ) <TAB> <TAB> except MY_EXCEPTION as e : <TAB> <TAB> <TAB> log. error ( e ) <TAB> for file in [ ""gramps-%s.exe"" % self. gramps_version ] : <TAB> <TAB> fname = os. path. join ( self. out_dir, file ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> log. info ( ""removing file: %s"" % fname ) <TAB> <TAB> <TAB> <TAB> os. remove ( fname ) <TAB> <TAB> <TAB> except MY_EXCEPTION as e : <TAB> <TAB> <TAB> <TAB> log. error ( e )",False,os.path.isfile(fname),os.path.exists(fname),0.6469919681549072
|
||
|
3244,"def open_binary ( package : Package, resource : Resource ) -> BinaryIO : <TAB> """"""Return a file-like object opened for binary reading of the resource."""""" <TAB> resource = _normalize_path ( resource ) <TAB> package = _get_package ( package ) <TAB> reader = _get_resource_reader ( package ) <TAB> if reader is not None : <TAB> <TAB> return reader. open_resource ( resource ) <TAB> absolute_package_path = os. path. abspath ( <TAB> <TAB> package. __spec__. origin or ""non-existent file"" <TAB> ) <TAB> package_path = os. path. dirname ( absolute_package_path ) <TAB> full_path = os. path. join ( package_path, resource ) <TAB> try : <TAB> <TAB> return open ( full_path, mode = ""rb"" ) <TAB> except OSError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> loader = cast ( ResourceLoader, package. __spec__. loader ) <TAB> <TAB> data = None <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> with suppress ( OSError ) : <TAB> <TAB> <TAB> <TAB> data = loader. get_data ( full_path ) <TAB> <TAB> if data is None : <TAB> <TAB> <TAB> package_name = package. __spec__. name <TAB> <TAB> <TAB> message = ""{!r} resource not found in {!r}"". format ( resource, package_name ) <TAB> <TAB> <TAB> raise FileNotFoundError ( message ) <TAB> <TAB> return BytesIO ( data )",False,"hasattr(package.__spec__.loader, 'get_data')",loader is not None,0.6472967863082886
|
||
|
3245,"def _gridconvvalue ( self, value ) : <TAB> if isinstance ( value, ( str, _tkinter. Tcl_Obj ) ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> svalue = str ( value ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return None <TAB> <TAB> <TAB> elif ""."" in svalue : <TAB> <TAB> <TAB> <TAB> return getdouble ( svalue ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> return getint ( svalue ) <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> pass <TAB> return value",False,not svalue,'.' not in svalue,0.6827706098556519
|
||
|
3246,"def add_peer_to_blob ( self, contact : ""KademliaPeer"", key : bytes ) -> None : <TAB> now = self. loop. time ( ) <TAB> if key in self. _data_store : <TAB> <TAB> current = list ( filter ( lambda x : x [ 0 ] == contact, self. _data_store [ key ] ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _data_store [ key ] [ self. _data_store [ key ]. index ( current [ 0 ] ) ] = ( <TAB> <TAB> <TAB> <TAB> contact, <TAB> <TAB> <TAB> <TAB> now, <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. _data_store [ key ]. append ( ( contact, now ) ) <TAB> else : <TAB> <TAB> self. _data_store [ key ] = [ ( contact, now ) ]",False,len(current) > 0,current,0.6542009711265564
|
||
|
3247,"def hive_partitioning ( self, value ) : <TAB> if value is not None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> value = value. to_api_repr ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise TypeError ( ""Expected a HivePartitioningOptions instance or None."" ) <TAB> self. _set_sub_prop ( ""hivePartitioningOptions"", value )",True,"isinstance(value, HivePartitioningOptions)","isinstance(value, HivePartitioningOptions)",0.6592434644699097
|
||
|
3248,"def _get_data_versions ( data ) : <TAB> """"""Retrieve CSV file with version information for reference data."""""" <TAB> genome_dir = install. get_genome_dir ( <TAB> <TAB> data [ ""genome_build"" ], data [ ""dirs"" ]. get ( ""galaxy"" ), data <TAB> ) <TAB> if genome_dir : <TAB> <TAB> version_file = os. path. join ( genome_dir, ""versions.csv"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return version_file <TAB> return None",False,version_file and os.path.exists(version_file),os.path.exists(version_file),0.6489930152893066
|
||
|
3249,"def custom_db_creator ( self, number_of_rows, pipe, custom ) : <TAB> try : <TAB> <TAB> custom_d = faker_options_container ( ) <TAB> <TAB> for c in custom : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> logger. warning ( <TAB> <TAB> <TAB> <TAB> <TAB> ""fake2db found valid custom key provided: %s"" % c, extra = d <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> logger. error ( <TAB> <TAB> <TAB> <TAB> <TAB> ""fake2db does not support the custom key you provided."", extra = d <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> sys. exit ( 1 ) <TAB> <TAB> for i in range ( 0, number_of_rows ) : <TAB> <TAB> <TAB> dict_c = { } <TAB> <TAB> <TAB> for c in custom : <TAB> <TAB> <TAB> <TAB> dict_c [ c ] = getattr ( self. faker, c ) ( ) <TAB> <TAB> <TAB> pipe. hmset ( ""custom:%s"" % i, dict_c ) <TAB> <TAB> pipe. execute ( ) <TAB> <TAB> logger. warning ( ""custom Commits are successful after write job!"", extra = d ) <TAB> except Exception as e : <TAB> <TAB> logger. error ( e, extra = d )",False,custom_d.get(c),c in custom_d,0.6497542858123779
|
||
|
3250,"def _fill_pages ( self ) : <TAB> page_id = 1 <TAB> started_dt = self. created_at <TAB> current_page = self. _empty_page ( page_id, started_dt ) <TAB> first_page = True <TAB> self. pages = [ current_page ] <TAB> for idx, ev in enumerate ( self. events ) : <TAB> <TAB> if ev. type == HAR_TIMING : <TAB> <TAB> <TAB> name = ev. data [ ""name"" ] <TAB> <TAB> <TAB> time = get_duration ( started_dt, ev. data [ ""time"" ] ) <TAB> <TAB> <TAB> current_page [ ""pageTimings"" ] [ name ] = time <TAB> <TAB> elif ev. type == HAR_TITLE_CHANGED : <TAB> <TAB> <TAB> current_page [ ""title"" ] = ev. data <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> ev. data [ ""pageref"" ] = str ( page_id ) <TAB> <TAB> elif ev. type == HAR_URL_CHANGED : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> cause_ev = self. _prev_entry ( ev. data, idx ) <TAB> <TAB> <TAB> if first_page : <TAB> <TAB> <TAB> <TAB> first_page = False <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> page_id += 1 <TAB> <TAB> <TAB> <TAB> if cause_ev is None : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> started_dt = self. created_at <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> started_dt = cause_ev. data [ ""_tmp"" ] [ ""start_time"" ] <TAB> <TAB",False,ev.type == HAR_ENTRY,ev.type == HAR_pageref_CHANGED,0.6669262051582336
|
||
|
3251,"def cleanup ( ) : <TAB> gscript. message ( _ ( ""Erasing temporary files..."" ) ) <TAB> for temp_map, maptype in temp_maps : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> gscript. run_command ( <TAB> <TAB> <TAB> <TAB> ""g.remove"", flags = ""f"", type = maptype, name = temp_map, quiet = True <TAB> <TAB> <TAB> )",False,"gscript.find_file(temp_map, element=maptype)['name']",maptype,0.6458215713500977
|
||
|
3252,"def specialize_parent_vtable ( cls : ClassIR, parent : ClassIR ) -> VTableEntries : <TAB> """"""Generate the part of a vtable corresponding to a parent class or trait"""""" <TAB> updated = [ ] <TAB> for entry in parent. vtable_entries : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> orig_parent_method = entry. cls. get_method ( entry. name ) <TAB> <TAB> assert orig_parent_method <TAB> <TAB> method_cls = cls. get_method_and_class ( entry. name ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> child_method, defining_cls = method_cls <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if ( <TAB> <TAB> <TAB> <TAB> is_same_method_signature ( orig_parent_method. sig, child_method. sig ) <TAB> <TAB> <TAB> <TAB> or orig_parent_method. name == ""__init__"" <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> entry = VTableMethod ( <TAB> <TAB> <TAB> <TAB> <TAB> entry. cls, entry. name, child_method, entry. shadow_method <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> entry = VTableMethod ( <TAB> <TAB> <TAB> <TAB> <TAB> entry. cls, <TAB> <TAB> <TAB> <TAB> <TAB> entry. name, <TAB> <TAB> <TAB> <TAB> <TAB> defining_cls. glue_methods [ ( entry. cls, entry. name ) ], <TAB> <TAB> <TAB> <TAB> <TAB> entry. shadow_method, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> updated. append ( entry ) <TAB> return updated",False,method_cls,method_cls is not None,0.6800519824028015
|
||
|
3253,"def ensure_tuple_of_str ( <TAB> info_file : Path, key_name : str, value : Union [ Any, UseDefault ] ) -> Tuple [ str,... ] : <TAB> default : Tuple [ str,... ] = ( ) <TAB> if value is USE_DEFAULT : <TAB> <TAB> return default <TAB> if not isinstance ( value, list ) : <TAB> <TAB> log. warning ( <TAB> <TAB> <TAB> ""Invalid value of '%s' key (expected list, got %s)"" <TAB> <TAB> <TAB> "" in JSON information file at path: %s"", <TAB> <TAB> <TAB> key_name, <TAB> <TAB> <TAB> type ( value ). __name__, <TAB> <TAB> <TAB> info_file, <TAB> <TAB> ) <TAB> <TAB> return default <TAB> for item in value : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> log. warning ( <TAB> <TAB> <TAB> <TAB> ""Invalid item in '%s' list (expected str, got %s)"" <TAB> <TAB> <TAB> <TAB> "" in JSON information file at path: %s"", <TAB> <TAB> <TAB> <TAB> key_name, <TAB> <TAB> <TAB> <TAB> type ( item ). __name__, <TAB> <TAB> <TAB> <TAB> info_file, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> return default <TAB> return tuple ( value )",False,"not isinstance(item, str)","isinstance(item, str)",0.6519392728805542
|
||
|
3254,"def process_manifest ( manifest ) : <TAB> try : <TAB> <TAB> common. manifest = os. path. abspath ( str ( manifest ). strip ( ) ) <TAB> <TAB> common. manifest = re. sub ( ""\\\\\s"", "" "", common. manifest ) <TAB> <TAB> common. xmldoc = minidom. parse ( common. manifest ) <TAB> <TAB> common. logger. info ( common. xmldoc. toprettyxml ( ) ) <TAB> <TAB> report. write_manifest ( common. xmldoc ) <TAB> except Exception as e : <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ap = axmlprinter. AXMLPrinter ( open ( common. manifest, ""rb"" ). read ( ) ) <TAB> <TAB> <TAB> common. xmldoc = minidom. parseString ( ap. getBuff ( ) ) <TAB> <TAB> <TAB> common. logger. info ( common. xmldoc. toxml ( ) ) <TAB> <TAB> <TAB> report. write_manifest ( common. xmldoc. toprettyxml ( ) ) <TAB> <TAB> except Exception as e : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> common. logger. error ( <TAB> <TAB> <TAB> <TAB> <TAB> str ( e ) <TAB> <TAB> <TAB> <TAB> <TAB> + ""\r\nThat didnt work. Try providing an absolute path to the file"" <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> exit ( ) <TAB> <TAB> <TAB> common. logger. error ( <TAB> <TAB> <TAB> <TAB> str ( e ) <TAB> <TAB> <TAB> <TAB> + ""\r\nThat didnt work. Try providing an absolute path to the file\n"" <TAB> <TAB> <TAB> )",False,not common.interactive_mode,e.__class__.__name__!= 'TAB > <TAB > <TAB > <TAB > <TAB > <TAB > <TAB > >,0.6526157259941101
|
||
|
3255,"def test_model_trainable_and_decodable ( module, model_dict ) : <TAB> args = make_arg ( ** model_dict ) <TAB> if<mask> : <TAB> <TAB> batch = prepare_inputs ( ""pytorch"" ) <TAB> <TAB> m = th_asr <TAB> else : <TAB> <TAB> batch = prepare_inputs ( ""chainer"" ) <TAB> <TAB> m = ch_asr <TAB> model = m. E2E ( 10, 5, args ) <TAB> loss = model ( * batch ) <TAB> if isinstance ( loss, tuple ) : <TAB> <TAB> <TAB> <TAB> loss [ 0 ]. backward ( ) <TAB> else : <TAB> <TAB> loss. backward ( ) <TAB> with torch. no_grad ( ), chainer. no_backprop_mode ( ) : <TAB> <TAB> in_data = np. random. randn ( 10, 10 ) <TAB> <TAB> model. recognize ( in_data, args, args. char_list ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> batch_in_data = [ np. random. randn ( 10, 10 ), np. random. randn ( 5, 10 ) ] <TAB> <TAB> <TAB> model. recognize_batch ( <TAB> <TAB> <TAB> <TAB> batch_in_data, args, args. char_list <TAB> <TAB> <TAB> )",False,'pytorch' in module,"isinstance(model, nn.Module)",0.6552176475524902
|
||
|
3256,"def _parse_tags ( self, buffer ) : <TAB> tag_context = tag_map_module. TagMap ( ) <TAB> limit = len ( buffer ) <TAB> total_chars = 0 <TAB> i = 1 <TAB> while i < limit : <TAB> <TAB> field_id = buffer [ i ] if six. PY3 else ord ( buffer [ i ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> i += 1 <TAB> <TAB> <TAB> key = self. _decode_string ( buffer, i ) <TAB> <TAB> <TAB> i += len ( key ) <TAB> <TAB> <TAB> total_chars += len ( key ) <TAB> <TAB> <TAB> i += 1 <TAB> <TAB> <TAB> val = self. _decode_string ( buffer, i ) <TAB> <TAB> <TAB> i += len ( val ) <TAB> <TAB> <TAB> total_chars += len ( val ) <TAB> <TAB> <TAB> i += 1 <TAB> <TAB> <TAB> if total_chars > TAG_MAP_SERIALIZED_SIZE_LIMIT : <TAB> <TAB> <TAB> <TAB> logging. warning ( ""Size of the tag context exceeds maximum"" ) <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> tag_context. insert ( str ( key ), str ( val ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> break <TAB> return tag_context",False,field_id == TAG_FIELD_ID,field_id == TAB_TAG_NONE,0.658476710319519
|
||
|
3257,"def create_trie_tree ( self, pieces_dir ) : <TAB> print ( ""sp_prob = {}"". format ( self. sp_prob ) ) <TAB> print ( ""pieces_threshold = {}"". format ( self. pieces_threshold ) ) <TAB> if pieces_dir is not None : <TAB> <TAB> self. trie = TrieTree ( ) <TAB> <TAB> pieces_files = [ pieces_dir ] <TAB> <TAB> for token in self. vocab_words : <TAB> <TAB> <TAB> self. trie. add ( [ token ] ) <TAB> <TAB> for piece_file in pieces_files : <TAB> <TAB> <TAB> print ( ""Load piece file: {}"". format ( piece_file ) ) <TAB> <TAB> <TAB> with open ( piece_file, mode = ""r"", encoding = ""utf-8"" ) as reader : <TAB> <TAB> <TAB> <TAB> for line in reader : <TAB> <TAB> <TAB> <TAB> <TAB> parts = line. split ( ""\t"" ) <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> <TAB> <TAB> tokens = [ ] <TAB> <TAB> <TAB> <TAB> <TAB> for part in parts [ : - 1 ] : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> tokens. extend ( part. split ( "" "" ) ) <TAB> <TAB> <TAB> <TAB> <TAB> self. trie. add ( tokens )",False,int(parts[-1]) < self.pieces_threshold,len(parts) > 0,0.6517353653907776
|
||
|
3258,"def _calculate_target_dimensions ( self ) : <TAB> source_width, source_height = self. engine. size <TAB> source_width = float ( source_width ) <TAB> source_height = float ( source_height ) <TAB> if not self. context. request. width and not self. context. request. height : <TAB> <TAB> self. target_width = source_width <TAB> <TAB> self. target_height = source_height <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if self. context. request. width == ""orig"" : <TAB> <TAB> <TAB> <TAB> self. target_width = source_width <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. target_width = float ( self. context. request. width ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. target_width = self. engine. get_proportional_width ( <TAB> <TAB> <TAB> <TAB> self. context. request. height <TAB> <TAB> <TAB> ) <TAB> <TAB> if self. context. request. height : <TAB> <TAB> <TAB> if self. context. request. height == ""orig"" : <TAB> <TAB> <TAB> <TAB> self. target_height = source_height <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. target_height = float ( self. context. request. height ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. target_height = self. engine. get_proportional_height ( <TAB> <TAB> <TAB> <TAB> self. context. request. width <TAB> <TAB> <TAB> )",False,self.context.request.width,self.engine.size < TAB > 0,0.6530090570449829
|
||
|
3259,"def ValidateConfigs ( self, configs ) : <TAB> test_filter_map = copy. deepcopy ( config_lib. ConfigFilter. classes_by_name ) <TAB> for filter_name in self. disabled_filters : <TAB> <TAB> test_filter_map [ filter_name ] = config_lib. ConfigFilter <TAB> with utils. Stubber ( config_lib. ConfigFilter, ""classes_by_name"", test_filter_map ) : <TAB> <TAB> for config_file in configs : <TAB> <TAB> <TAB> errors = self. ValidateConfig ( config_file ) <TAB> <TAB> <TAB> for exception in self. exceptions : <TAB> <TAB> <TAB> <TAB> errors. pop ( exception, None ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> logging. info ( ""Validation of %s returned errors:"", config_file ) <TAB> <TAB> <TAB> <TAB> for config_entry, error in errors. items ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> logging. info ( ""%s:"", config_entry ) <TAB> <TAB> <TAB> <TAB> <TAB> logging. info ( ""%s"", error ) <TAB> <TAB> <TAB> <TAB> self. fail ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Validation of %s returned errors: %s"" % ( config_file, errors ) <TAB> <TAB> <TAB> <TAB> )",True,errors,errors,0.6859331130981445
|
||
|
3260,"def push_monitoring_data ( <TAB> self, jobno, upload_token, send_data, interrupted_event, trace = False ) : <TAB> if send_data : <TAB> <TAB> addr = ""api/monitoring/receiver/push?job_id=%s&upload_token=%s"" % ( <TAB> <TAB> <TAB> jobno, <TAB> <TAB> <TAB> upload_token, <TAB> <TAB> ) <TAB> <TAB> api_timeouts = self. api_timeouts ( ) <TAB> <TAB> while not interrupted_event. is_set ( ) : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> res = self. __make_writer_request ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> params = { <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""jobno"" : jobno, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""upload_token"" : upload_token, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> }, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> json = { <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""monitoring"" : send_data, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> }, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> trace = trace, <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> logger. debug ( ""Writer response: %s"", res. text ) <TAB> <TAB> <TAB> <TAB> <TAB> return res. json ( ) [ ""success"" ] <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> res = self. __post_raw ( <TAB> <TAB> <TAB> <TAB> <TAB",False,self.writer_url,trace,0.6585288047790527
|
||
|
3261,"def setInput ( self, * argv ) : <TAB> <TAB> <TAB> <TAB> if not argv : <TAB> <TAB> import sys <TAB> <TAB> self. setInput ( sys. stdin ) <TAB> <TAB> return <TAB> <TAB> arg1 = argv [ 0 ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if is_string_type ( arg1 ) : <TAB> <TAB> f = open ( arg1, ""rb"" ) <TAB> <TAB> self. setInput ( f ) <TAB> <TAB> self. setFilename ( arg1 ) <TAB> <TAB> return <TAB> <TAB> <TAB> <TAB> <TAB> if isinstance ( arg1, file ) : <TAB> <TAB> self. setInput ( CharBuffer ( arg1 ) ) <TAB> <TAB> return <TAB> <TAB> <TAB> <TAB> if isinstance ( arg1, LexerSharedInputState ) : <TAB> <TAB> self. inputState = arg1 <TAB> <TAB> return <TAB> <TAB> <TAB> <TAB> <TAB> if isinstance ( arg1, InputBuffer ) : <TAB> <TAB> self. setInput ( LexerSharedInputState ( arg1 ) ) <TAB> <TAB> return <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> rd = Reader ( arg1 ) <TAB> <TAB> <TAB> cb = CharBuffer ( rd ) <TAB> <TAB> <TAB> ss = LexerSharedInputState ( cb ) <TAB> <TAB> <TAB> self. inputState = ss <TAB> <TAB> return <TAB> except : <TAB> <TAB> pass <TAB> <TAB> <TAB> raise TypeError ( argv )",False,arg1.read,"hasattr(arg1, '__iter__')",0.6696570515632629
|
||
|
3262,"def replaceWholeText ( self, content ) : <TAB> <TAB> <TAB> parent = self. parentNode <TAB> n = self. previousSibling <TAB> while n is not None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> next = n. previousSibling <TAB> <TAB> <TAB> parent. removeChild ( n ) <TAB> <TAB> <TAB> n = next <TAB> <TAB> else : <TAB> <TAB> <TAB> break <TAB> n = self. nextSibling <TAB> if not content : <TAB> <TAB> parent. removeChild ( self ) <TAB> while n is not None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> next = n. nextSibling <TAB> <TAB> <TAB> parent. removeChild ( n ) <TAB> <TAB> <TAB> n = next <TAB> <TAB> else : <TAB> <TAB> <TAB> break <TAB> if content : <TAB> <TAB> d = self. __dict__ <TAB> <TAB> d [ ""data"" ] = content <TAB> <TAB> d [ ""nodeValue"" ] = content <TAB> <TAB> return self <TAB> else : <TAB> <TAB> return None",False,"n.nodeType in (Node.TEXT_NODE, Node.CDATA_SECTION_NODE)",n.parentNode,0.654304027557373
|
||
|
3263,"def PyJs_anonymous_1675_ ( object, names, this, arguments, var = var ) : <TAB> var = Scope ( <TAB> <TAB> { u""this"" : this, u""object"" : object, u""names"" : names, u""arguments"" : arguments }, <TAB> <TAB> var, <TAB> ) <TAB> var. registers ( [ u""i"", u""object"", u""O"", u""result"", u""key"", u""names"" ] ) <TAB> var. put ( u""O"", var. get ( u""toIObject"" ) ( var. get ( u""object"" ) ) ) <TAB> var. put ( u""i"", Js ( 0.0 ) ) <TAB> var. put ( u""result"", Js ( [ ] ) ) <TAB> for PyJsTemp in var. get ( u""O"" ) : <TAB> <TAB> var. put ( u""key"", PyJsTemp ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> ( <TAB> <TAB> <TAB> <TAB> var. get ( u""has"" ) ( var. get ( u""O"" ), var. get ( u""key"" ) ) <TAB> <TAB> <TAB> <TAB> and var. get ( u""result"" ). callprop ( u""push"", var. get ( u""key"" ) ) <TAB> <TAB> <TAB> ) <TAB> while var. get ( u""names"" ). get ( u""length"" ) > var. get ( u""i"" ) : <TAB> <TAB> if var. get ( u""has"" ) ( <TAB> <TAB> <TAB> var. get ( u""O"" ), <TAB> <TAB> <TAB> var. put ( <TAB> <TAB> <TAB> <TAB> u""key"", <TAB> <TAB> <TAB> <TAB> var. get ( u""names"" ). get ( <TAB> <TAB> <TAB> <TAB> <TAB> ( var. put ( u""i"", Js ( var. get ( u""i"" ). to_number ( ) ) + Js ( 1 ) ) -",False,var.get(u'key') != var.get(u'IE_PROTO'),PYJsTemp,0.6503980755805969
|
||
|
3264,"def forward ( self, fw_x, bw_x ) : <TAB> final_outs = [ ] <TAB> lstm_outs = [ ] <TAB> for x, layers in zip ( [ fw_x, bw_x ], self. _lstm_layers ) : <TAB> <TAB> batch_size = x. shape [ 0 ] <TAB> <TAB> outs = [ ] <TAB> <TAB> for i, dic in enumerate ( layers ) : <TAB> <TAB> <TAB> lstm = dic [ ""lstm"" ] <TAB> <TAB> <TAB> hidden_state = dic [ ""hidden_state"" ] [ :, : batch_size, : ] <TAB> <TAB> <TAB> cell_state = dic [ ""cell_state"" ] [ :, : batch_size, : ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> x = self. _dropout_layer ( x ) <TAB> <TAB> <TAB> x, ( hidden_state, cell_state ) = lstm ( x, ( hidden_state, cell_state ) ) <TAB> <TAB> <TAB> hidden_state = hidden_state. detach ( ) <TAB> <TAB> <TAB> cell_state = cell_state. detach ( ) <TAB> <TAB> <TAB> dic [ ""hidden_state"" ] [ :, : batch_size, : ] = hidden_state <TAB> <TAB> <TAB> dic [ ""cell_state"" ] [ :, : batch_size, : ] = cell_state <TAB> <TAB> <TAB> outs. append ( x ) <TAB> <TAB> lstm_outs. append ( outs ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> x = self. _dropout_layer ( x ) <TAB> <TAB> final_outs. append ( x ) <TAB> if self. _task == ""pre-train"" : <TAB> <TAB> return final_outs <TAB> else : <TAB> <TAB> return lstm_outs",False,self._dropout,self._task == 'dropout',0.675731360912323
|
||
|
3265,"def _update_read ( self ) : <TAB> """"""Update state when there is read event"""""" <TAB> try : <TAB> <TAB> msg = bytes ( self. _sock. recv ( 4096 ) ) <TAB> <TAB> if msg : <TAB> <TAB> <TAB> self. on_message ( msg ) <TAB> <TAB> <TAB> return True <TAB> <TAB> <TAB> <TAB> self. close ( ) <TAB> except socket. error as err : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> pass <TAB> <TAB> else : <TAB> <TAB> <TAB> self. on_error ( err ) <TAB> return False",False,"err.args[0] in (errno.EAGAIN, errno.EWOULDBLOCK)","err.args[0] in [ECONN, ECONN, ESHUTDOWN]",0.6544532775878906
|
||
|
3266,"def handle_noargs ( self, ** options ) : <TAB> self. style = color_style ( ) <TAB> print ( ""Running Django's own validation:"" ) <TAB> self. validate ( display_num_errors = True ) <TAB> for model in loading. get_models ( ) : <TAB> <TAB> if hasattr ( model, ""_create_content_base"" ) : <TAB> <TAB> <TAB> self. validate_base_model ( model ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. validate_content_type ( model )",False,"hasattr(model, '_feincms_content_models')","hasattr(model, '_create_content_type')",0.6476650238037109
|
||
|
3267,"def _expand_deps_java_generation ( self ) : <TAB> """"""Ensure that all multilingual dependencies such as proto_library generate java code."""""" <TAB> queue = collections. deque ( self. deps ) <TAB> keys = set ( ) <TAB> while queue : <TAB> <TAB> k = queue. popleft ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> keys. add ( k ) <TAB> <TAB> <TAB> dep = self. target_database [ k ] <TAB> <TAB> <TAB> if ""generate_java"" in dep. attr : <TAB> <TAB> <TAB> <TAB> dep. attr [ ""generate_java"" ] = True <TAB> <TAB> <TAB> <TAB> queue. extend ( dep. deps )",False,k not in keys,k in keys,0.6712773442268372
|
||
|
3268,"def __init__ ( self, * args, ** kwargs ) : <TAB> if len ( args ) == 1 : <TAB> <TAB> arg = args [ 0 ] <TAB> <TAB> if isinstance ( arg, string_types ) : <TAB> <TAB> <TAB> self. client = kwargs. pop ( ""client_cls"", Client ) ( dsn = arg, ** kwargs ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> self. client = arg <TAB> <TAB> else : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""The first argument to %s must be either a Client instance or a DSN, got %r instead."" <TAB> <TAB> <TAB> <TAB> % ( <TAB> <TAB> <TAB> <TAB> <TAB> self. __class__. __name__, <TAB> <TAB> <TAB> <TAB> <TAB> arg, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> args = [ ] <TAB> else : <TAB> <TAB> try : <TAB> <TAB> <TAB> self. client = kwargs. pop ( ""client"" ) <TAB> <TAB> except KeyError : <TAB> <TAB> <TAB> raise TypeError ( ""Expected keyword argument for SentryHandler: client"" ) <TAB> super ( SentryHandler, self ). __init__ ( * args, ** kwargs )",False,"isinstance(arg, Client)","isinstance(arg, DSN)",0.6618759036064148
|
||
|
3269,"def event_detail_view ( request, event_id ) : <TAB> event = get_object_or_404 ( Event, pk = event_id ) <TAB> if ( <TAB> <TAB> not ( <TAB> <TAB> <TAB> request. user. role == ""ADMIN"" <TAB> <TAB> <TAB> or request. user. is_superuser <TAB> <TAB> <TAB> or event. created_by == request. user <TAB> <TAB> <TAB> or request. user in event. assigned_to. all ( ) <TAB> <TAB> ) <TAB> <TAB> or request. company!= event. company <TAB> ) : <TAB> <TAB> raise PermissionDenied <TAB> if request. method == ""GET"" : <TAB> <TAB> context = { } <TAB> <TAB> context [ ""event"" ] = event <TAB> <TAB> context [ ""attachments"" ] = event. events_attachment. all ( ) <TAB> <TAB> context [ ""comments"" ] = event. events_comments. all ( ) <TAB> <TAB> if request. user. is_superuser or request. user. role == ""ADMIN"" : <TAB> <TAB> <TAB> context [ ""users_mention"" ] = list ( <TAB> <TAB> <TAB> <TAB> User. objects. filter ( is_active = True, company = request. company ). values ( <TAB> <TAB> <TAB> <TAB> <TAB> ""username"" <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> context [ ""users_mention"" ] = [ { ""username"" : event. created_by. username } ] <TAB> <TAB> else : <TAB> <TAB> <TAB> context [ ""users_mention"" ] = list ( event. assigned_to. all ( ). values ( ""username"" ) ) <TAB> <TAB> return render ( request, ""event_detail.html"", context )",False,request.user != event.created_by,event.created_by,0.651321291923523
|
||
|
3270,"def _save ( self, force = False ) : <TAB> if not self. _dirty and not force : <TAB> <TAB> return <TAB> data = { } <TAB> for name, user in self. _users. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> data [ name ] = { <TAB> <TAB> <TAB> ""password"" : user. _passwordHash, <TAB> <TAB> <TAB> ""active"" : user. _active, <TAB> <TAB> <TAB> ""groups"" : self. _from_groups ( * user. _groups ), <TAB> <TAB> <TAB> ""permissions"" : self. _from_permissions ( * user. _permissions ), <TAB> <TAB> <TAB> ""apikey"" : user. _apikey, <TAB> <TAB> <TAB> ""settings"" : user. _settings, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""roles"" : user. _roles, <TAB> <TAB> } <TAB> with atomic_write ( <TAB> <TAB> self. _userfile, mode = ""wt"", permissions = 0o600, max_permissions = 0o666 <TAB> ) as f : <TAB> <TAB> yaml. safe_dump ( data, f, default_flow_style = False, indent = 4, allow_unicode = True ) <TAB> <TAB> self. _dirty = False <TAB> self. _load ( )",False,"not user or not isinstance(user, User)",self.has_tab(name),0.648919403553009
|
||
|
3271,"def run ( self ) : <TAB> try : <TAB> <TAB> self. read_sock. setblocking ( 0 ) <TAB> <TAB> while True : <TAB> <TAB> <TAB> data = """" <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> data += self. read_sock. recv ( 1000000 ) <TAB> <TAB> <TAB> <TAB> if not data : <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> except Exception as e : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> if not data : <TAB> <TAB> <TAB> <TAB> <TAB> time. sleep ( 0.05 ) <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> self. write_sock. sendall ( data ) <TAB> except Exception as e : <TAB> <TAB> logging. debug ( ""error in socket piper: %s"", traceback. format_exc ( ) ) <TAB> finally : <TAB> <TAB> try : <TAB> <TAB> <TAB> self. write_sock. shutdown ( socket. SHUT_RDWR ) <TAB> <TAB> except : <TAB> <TAB> <TAB> pass <TAB> <TAB> try : <TAB> <TAB> <TAB> self. write_sock. close ( ) <TAB> <TAB> except : <TAB> <TAB> <TAB> pass <TAB> <TAB> try : <TAB> <TAB> <TAB> self. read_sock. shutdown ( socket. SHUT_RDWR ) <TAB> <TAB> except : <TAB> <TAB> <TAB> pass <TAB> <TAB> try : <TAB> <TAB> <TAB> self. read_sock. close ( ) <TAB> <TAB> except : <TAB> <TAB> <TAB> pass <TAB> logging. debug ( ""piper finished"" )",False,e[0] == 9,e.args.TAB > 0,0.6623597145080566
|
||
|
3272,"def casper_tests_from_citree ( citree ) : <TAB> import ciElementTree as ET <TAB> from codeintel2. tree import pretty_tree_from_tree <TAB> <TAB> <TAB> for blob in citree [ 0 ] : <TAB> <TAB> <TAB> <TAB> for class_elem in blob : <TAB> <TAB> <TAB> if not is_casper_testcase_subclass ( class_elem ) : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for func_elem in class_elem : <TAB> <TAB> <TAB> <TAB> if func_elem. get ( ""ilk"" )!= ""function"" : <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> if ""__ctor__"" in func_elem. get ( ""attributes"", """" ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> raw_tags = func_elem. get ( ""tags"", """" ). strip ( ) <TAB> <TAB> <TAB> <TAB> if raw_tags : <TAB> <TAB> <TAB> <TAB> <TAB> tags = re. split ( ""[,\s]+"", raw_tags ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> tags = None <TAB> <TAB> <TAB> <TAB> yield CasperTest ( <TAB> <TAB> <TAB> <TAB> <TAB> normpath ( blob. get ( ""src"" ) ), <TAB> <TAB> <TAB> <TAB> <TAB> class_elem. get ( ""name"" ), <TAB> <TAB> <TAB> <TAB> <TAB> func_elem. get ( ""name"" ), <TAB> <TAB",False,not func_elem.get('name').startswith('test_'),func_elem.get('attributes') is None,0.6534276008605957
|
||
|
3273,"def process_image ( sample, mode, color_jitter, rotate ) : <TAB> img_path = sample [ 0 ] <TAB> try : <TAB> <TAB> img = Image. open ( img_path ) <TAB> except : <TAB> <TAB> print ( img_path, ""not exists!"" ) <TAB> <TAB> return None <TAB> if mode == ""train"" : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> img = rotate_image ( img ) <TAB> <TAB> img = random_crop ( img, DATA_DIM ) <TAB> else : <TAB> <TAB> img = resize_short ( img, target_size = 256 ) <TAB> <TAB> img = crop_image ( img, target_size = DATA_DIM, center = True ) <TAB> if mode == ""train"" : <TAB> <TAB> if color_jitter : <TAB> <TAB> <TAB> img = distort_color ( img ) <TAB> <TAB> if np. random. randint ( 0, 2 ) == 1 : <TAB> <TAB> <TAB> img = img. transpose ( Image. FLIP_LEFT_RIGHT ) <TAB> if img. mode!= ""RGB"" : <TAB> <TAB> img = img. convert ( ""RGB"" ) <TAB> img = np. array ( img ). astype ( ""float32"" ). transpose ( ( 2, 0, 1 ) ) / 255 <TAB> img -= img_mean <TAB> img /= img_std <TAB> if mode == ""train"" or mode == ""val"" : <TAB> <TAB> return img, sample [ 1 ] <TAB> elif mode == ""test"" : <TAB> <TAB> return [ img ]",True,rotate,rotate,0.6786314845085144
|
||
|
3274,"def from_cfn_params ( self, cfn_params ) : <TAB> """"""Initialize param value by parsing CFN input only if the scheduler is awsbatch."""""" <TAB> cfn_converter = self. definition. get ( ""cfn_param_mapping"", None ) <TAB> if cfn_converter and cfn_params : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. value = int ( float ( get_cfn_param ( cfn_params, cfn_converter ) ) ) <TAB> return self",False,"get_cfn_param(cfn_params, 'Scheduler') == 'awsbatch'",self.is_awsbatch,0.6503016352653503
|
||
|
3275,"def get_lowest_wall_time ( jsons ) : <TAB> lowest_wall = None <TAB> for j in jsons : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> lowest_wall = j [ ""wall_time"" ] <TAB> <TAB> if lowest_wall > j [ ""wall_time"" ] : <TAB> <TAB> <TAB> lowest_wall = j [ ""wall_time"" ] <TAB> return lowest_wall",False,lowest_wall is None,j.get('wall_time'),0.6615209579467773
|
||
|
3276,"def __hexToBin ( self, myHex ) : <TAB> binOfHex = """" <TAB> for element in myHex : <TAB> <TAB> element = element. upper ( ) <TAB> <TAB> if element == ""F"" : <TAB> <TAB> <TAB> binOfHex = binOfHex + ""1111"" <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> binOfHex = binOfHex + ""1110"" <TAB> <TAB> elif element == ""D"" : <TAB> <TAB> <TAB> binOfHex = binOfHex + ""1101"" <TAB> <TAB> elif element == ""C"" : <TAB> <TAB> <TAB> binOfHex = binOfHex + ""1100"" <TAB> <TAB> elif element == ""B"" : <TAB> <TAB> <TAB> binOfHex = binOfHex + ""1011"" <TAB> <TAB> elif element == ""A"" : <TAB> <TAB> <TAB> binOfHex = binOfHex + ""1010"" <TAB> <TAB> elif element == ""9"" : <TAB> <TAB> <TAB> binOfHex = binOfHex + ""1001"" <TAB> <TAB> elif element == ""8"" : <TAB> <TAB> <TAB> binOfHex = binOfHex + ""1000"" <TAB> <TAB> elif element == ""7"" : <TAB> <TAB> <TAB> binOfHex = binOfHex + ""0111"" <TAB> <TAB> elif element == ""6"" : <TAB> <TAB> <TAB> binOfHex = binOfHex + ""0110"" <TAB> <TAB> elif element == ""5"" : <TAB> <TAB> <TAB> binOfHex = binOfHex + ""0101"" <TAB> <TAB> elif element == ""4"" : <TAB> <TAB> <TAB> binOfHex = binOfHex + ""0100"" <TAB> <TAB> elif element == ""3"" : <TAB> <TAB> <TAB> binOfHex = binOfHex + ""0011"" <TAB> <TAB> elif element == ""2"" : <TAB> <TAB> <TAB> binOfHex = binOfHex + ""00",False,element == 'E',element == 'F2',0.6542826890945435
|
||
|
3277,"def __repr__ ( self ) : <TAB> r = super ( ). __repr__ ( ) <TAB> if self. __args__ is not None or self. __result__ is not None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> args_r = ""..."" <TAB> <TAB> else : <TAB> <TAB> <TAB> args_r = ""[%s]"" % "", "". join ( _type_repr ( t ) for t in self. __args__ ) <TAB> <TAB> r += ""[%s, %s]"" % ( args_r, _type_repr ( self. __result__ ) ) <TAB> return r",False,self.__args__ is Ellipsis,len(self.__args__) < TAB > 10,0.6676801443099976
|
||
|
3278,"def compress ( self, data_list ) : <TAB> if len ( data_list ) == 2 : <TAB> <TAB> value, lookup_expr = data_list <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if lookup_expr not in EMPTY_VALUES : <TAB> <TAB> <TAB> <TAB> return Lookup ( value = value, lookup_expr = lookup_expr ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> raise forms. ValidationError ( <TAB> <TAB> <TAB> <TAB> <TAB> self. error_messages [ ""lookup_required"" ], code = ""lookup_required"" <TAB> <TAB> <TAB> <TAB> ) <TAB> return None",False,value not in EMPTY_VALUES,value,0.6652132868766785
|
||
|
3279,"def _interleave_dataset_results_and_tensors ( dataset_results, flat_run_tensors ) : <TAB> flattened_results = [ ] <TAB> for idx in range ( len ( dataset_results ) + len ( flat_run_tensors ) ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> flattened_results. append ( dataset_results [ idx ] ) <TAB> <TAB> else : <TAB> <TAB> <TAB> flattened_results. append ( flat_run_tensors. pop ( 0 ) ) <TAB> return flattened_results",False,dataset_results.get(idx),len(dataset_results) > idx,0.649058997631073
|
||
|
3280,"def get_gpus_bus_ids ( notation_fix = True ) : <TAB> logger = get_logger ( ) <TAB> bus_ids = { } <TAB> for manufacturer, vendor_id in VENDOR_IDS. items ( ) : <TAB> <TAB> ids_list = _search_bus_ids ( <TAB> <TAB> <TAB> match_pci_class = GPU_PCI_CLASS_PATTERN, <TAB> <TAB> <TAB> match_vendor_id = vendor_id, <TAB> <TAB> <TAB> notation_fix = notation_fix, <TAB> <TAB> ) <TAB> <TAB> if len ( ids_list ) > 1 : <TAB> <TAB> <TAB> logger. warning ( <TAB> <TAB> <TAB> <TAB> f""Multiple {manufacturer} GPUs found! Picking the first enumerated one."" <TAB> <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> bus_ids [ manufacturer ] = ids_list [ 0 ] <TAB> if ""intel"" in bus_ids and ""amd"" in bus_ids : <TAB> <TAB> logger. warning ( ""Found both an Intel and an AMD GPU. Defaulting to Intel."" ) <TAB> <TAB> del bus_ids [ ""amd"" ] <TAB> if not ( ""intel"" in bus_ids or ""amd"" in bus_ids ) : <TAB> <TAB> raise PCIError ( ""Cannot find the integrated GPU. Is this an Optimus system?"" ) <TAB> return bus_ids",False,len(ids_list) > 0,manufacturer in bus_ids,0.654262900352478
|
||
|
3281,"def processCoords ( coords ) : <TAB> newcoords = deque ( ) <TAB> for ( x, y, z ) in coords : <TAB> <TAB> for _dir, offsets in faceDirections : <TAB> <TAB> <TAB> if _dir == FaceYIncreasing : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> dx, dy, dz = offsets <TAB> <TAB> <TAB> p = ( x + dx, y + dy, z + dz ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> nx, ny, nz = p <TAB> <TAB> <TAB> if level. blockAt ( nx, ny, nz ) == 0 : <TAB> <TAB> <TAB> <TAB> level. setBlockAt ( nx, ny, nz, waterID ) <TAB> <TAB> <TAB> <TAB> newcoords. append ( p ) <TAB> return newcoords",False,p not in box,p == None,0.6739051342010498
|
||
|
3282,"def test_float_round_tripping ( self ) : <TAB> dtypes = set ( <TAB> <TAB> f <TAB> <TAB> for f in np. typeDict. values ( ) <TAB> <TAB> if ( np. issubdtype ( f, np. floating ) or np. issubdtype ( f, np. complexfloating ) ) <TAB> ) <TAB> if platform. machine ( ) in UNSUPPORTED_LONG_DOUBLE : <TAB> <TAB> dtype_dset_map = { <TAB> <TAB> <TAB> str ( j ) : d <TAB> <TAB> <TAB> for j, d in enumerate ( dtypes ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> } <TAB> else : <TAB> <TAB> dtype_dset_map = { str ( j ) : d for j, d in enumerate ( dtypes ) } <TAB> fname = self. mktemp ( ) <TAB> with h5py. File ( fname, ""w"" ) as f : <TAB> <TAB> for n, d in dtype_dset_map. items ( ) : <TAB> <TAB> <TAB> data = np. arange ( 10, dtype = d ) <TAB> <TAB> <TAB> f. create_dataset ( n, data = data ) <TAB> with h5py. File ( fname, ""r"" ) as f : <TAB> <TAB> for n, d in dtype_dset_map. items ( ) : <TAB> <TAB> <TAB> ldata = f [ n ] [ : ] <TAB> <TAB> <TAB> self. assertEqual ( ldata. dtype, d )",False,"d not in (np.float128, np.complex256)",ddtype.dtype == np.float32,0.6530990600585938
|
||
|
3283,"def PreprocessConditionalStatement ( self, IfList, ReplacedLine ) : <TAB> while self : <TAB> <TAB> if self. __Token : <TAB> <TAB> <TAB> x = 1 <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> if self <= 2 : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> RegionSizeGuid = 3 <TAB> <TAB> <TAB> if not RegionSizeGuid : <TAB> <TAB> <TAB> <TAB> RegionLayoutLine = 5 <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> RegionLayoutLine = self. CurrentLineNumber <TAB> return 1",False,not IfList,self == 1,0.6742633581161499
|
||
|
3284,"def __bind_events ( self, e ) : <TAB> if e. GetKeyCode ( ) == 13 : <TAB> <TAB> self. index = len ( self. history ) - 1 <TAB> <TAB> self. value = self. textctrl. GetValue ( ) <TAB> <TAB> ln = self. get_last_line ( ) <TAB> <TAB> ln = ln. strip ( ) <TAB> <TAB> if ln not in self. history : <TAB> <TAB> <TAB> self. history. append ( ln ) <TAB> <TAB> self. index += 1 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> import shlex <TAB> <TAB> <TAB> cmd = shlex. split ( ln ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> retvalue = self. _interp. onecmd ( cmd ) <TAB> <TAB> <TAB> if retvalue : <TAB> <TAB> <TAB> <TAB> self. textctrl. WriteText ( ""\n"" ) <TAB> <TAB> <TAB> <TAB> self. textctrl. AppendText ( retvalue ) <TAB> <TAB> self. textctrl. WriteText ( ""\n"" ) <TAB> <TAB> self. textctrl. WriteText ( self. prompt ) <TAB> <TAB> elif e. GetKeyCode ( ) == 317 : <TAB> <TAB> self. index += 1 <TAB> <TAB> if self. index >= len ( self. history ) : <TAB> <TAB> <TAB> self. index = len ( self. history ) - 1 <TAB> <TAB> self. textctrl. WriteText ( ""\n"" ) <TAB> <TAB> self. textctrl. WriteText ( self. prompt ) <TAB> <TAB> self. textctrl. WriteText ( self. history [ self. index ] ) <TAB> <TAB> elif e. GetKeyCode ( ) == 315 : <TAB> <TAB> self. index -= 1 <TAB> <TAB> if self. index < 0 : <TAB> <TAB> <TAB> self. index = 0 <TAB> <TAB> self. textctrl. WriteText ( ""\n"" ) <TAB> <TAB> self. textctrl. WriteText ( self",True,ln,ln,0.6897852420806885
|
||
|
3285,"def tempFailureRetry ( func, * args, ** kwargs ) : <TAB> while True : <TAB> <TAB> try : <TAB> <TAB> <TAB> return func ( * args, ** kwargs ) <TAB> <TAB> except ( os. error, IOError ) as ex : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> raise",False,ex.errno == errno.EINTR,ex.args[0] in _STD_ERROR_ARGS,0.6507569551467896
|
||
|
3286,"def validate_with_previous_doc ( self, ref ) : <TAB> self. exclude_fields = [ ""conversion_factor"", ""uom"" ] if self. get ( ""is_return"" ) else [ ] <TAB> for key, val in ref. items ( ) : <TAB> <TAB> is_child = val. get ( ""is_child_table"" ) <TAB> <TAB> ref_doc = { } <TAB> <TAB> item_ref_dn = [ ] <TAB> <TAB> for d in self. get_all_children ( self. doctype + "" Item"" ) : <TAB> <TAB> <TAB> ref_dn = d. get ( val [ ""ref_dn_field"" ] ) <TAB> <TAB> <TAB> if ref_dn : <TAB> <TAB> <TAB> <TAB> if is_child : <TAB> <TAB> <TAB> <TAB> <TAB> self. compare_values ( { key : [ ref_dn ] }, val [ ""compare_fields"" ], d ) <TAB> <TAB> <TAB> <TAB> <TAB> if ref_dn not in item_ref_dn : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> item_ref_dn. append ( ref_dn ) <TAB> <TAB> <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> frappe. throw ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> _ ( ""Duplicate row {0} with same {1}"" ). format ( d. idx, key ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> elif ref_dn : <TAB> <TAB> <TAB> <TAB> <TAB> ref_doc. setdefault ( key, [ ] ) <TAB> <TAB> <TAB> <TAB> <TAB> if ref_dn not in ref_doc [ key ] : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ref_doc [ key ]. append ( ref_dn ) <TAB> <TAB> if ref",False,not val.get('allow_duplicate_prev_row_id'),d.idx > len(ref_doc),0.6495885252952576
|
||
|
3287,"def product_edit ( request, product_id, response_format = ""html"" ) : <TAB> ""Product edit"" <TAB> product = get_object_or_404 ( Product, pk = product_id ) <TAB> if not request. user. profile. has_permission ( <TAB> <TAB> product, mode = ""w"" <TAB> ) and not request. user. profile. is_admin ( ""treeio.sales"" ) : <TAB> <TAB> return user_denied ( <TAB> <TAB> <TAB> request, ""You don't have access to this Product"", response_format <TAB> <TAB> ) <TAB> if request. POST : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> form = ProductForm ( <TAB> <TAB> <TAB> <TAB> request. user. profile, None, request. POST, instance = product <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if form. is_valid ( ) : <TAB> <TAB> <TAB> <TAB> product = form. save ( ) <TAB> <TAB> <TAB> <TAB> return HttpResponseRedirect ( <TAB> <TAB> <TAB> <TAB> <TAB> reverse ( ""sales_product_view"", args = [ product. id ] ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return HttpResponseRedirect ( <TAB> <TAB> <TAB> <TAB> reverse ( ""sales_product_view"", args = [ product. id ] ) <TAB> <TAB> <TAB> ) <TAB> else : <TAB> <TAB> form = ProductForm ( request. user. profile, None, instance = product ) <TAB> all_products = Object. filter_by_request ( <TAB> <TAB> request, Product. objects. filter ( parent__isnull = True ) <TAB> ) <TAB> return render_to_response ( <TAB> <TAB> ""sales/product_edit"", <TAB> <TAB> { ""form"" : form, ""product"" : product, ""products"" : all_products }, <TAB> <TAB> context_instance = RequestContext ( request ), <",False,'cancel' not in request.POST,product.id,0.6636199951171875
|
||
|
3288,"def get_db_prep_lookup ( self, lookup_type, value, connection, prepared = False ) : <TAB> if not prepared : <TAB> <TAB> value = self. get_prep_lookup ( lookup_type, value ) <TAB> if hasattr ( value, ""get_compiler"" ) : <TAB> <TAB> value = value. get_compiler ( connection = connection ) <TAB> if hasattr ( value, ""as_sql"" ) or hasattr ( value, ""_as_sql"" ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return value <TAB> <TAB> if hasattr ( value, ""as_sql"" ) : <TAB> <TAB> <TAB> sql, params = value. as_sql ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> sql, params = value. _as_sql ( connection = connection ) <TAB> <TAB> return QueryWrapper ( ( ""(%s)"" % sql ), params ) <TAB> <TAB> <TAB> <TAB> <TAB> if lookup_type in [ ""exact"", ""gt"", ""lt"", ""gte"", ""lte"" ] : <TAB> <TAB> return [ <TAB> <TAB> <TAB> self. _pk_trace ( <TAB> <TAB> <TAB> <TAB> value, <TAB> <TAB> <TAB> <TAB> ""get_db_prep_lookup"", <TAB> <TAB> <TAB> <TAB> lookup_type, <TAB> <TAB> <TAB> <TAB> connection = connection, <TAB> <TAB> <TAB> <TAB> prepared = prepared, <TAB> <TAB> <TAB> ) <TAB> <TAB> ] <TAB> if lookup_type in ( ""range"", ""in"" ) : <TAB> <TAB> return [ <TAB> <TAB> <TAB> self. _pk_trace ( <TAB> <TAB> <TAB> <TAB> v, <TAB> <TAB> <TAB> <TAB> ""get_db_prep_lookup"", <TAB> <TAB> <TAB> <TAB> lookup_type, <TAB> <TAB> <TAB> <TAB> connection =",False,"hasattr(value, 'relabel_aliases')",lookup_type == 'string',0.6467536687850952
|
||
|
3289,"def PyJs_anonymous_1228_ ( loc, this, arguments, var = var ) : <TAB> var = Scope ( { u""this"" : this, u""loc"" : loc, u""arguments"" : arguments }, var ) <TAB> var. registers ( [ u""loc"" ] ) <TAB> if var. get ( u""loc"" ) : <TAB> <TAB> var. get ( u""t"" ). callprop ( u""assertLiteral"", var. get ( u""loc"" ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> var. get ( u""loc"" ). put ( <TAB> <TAB> <TAB> <TAB> u""value"", var. get ( u""this"" ). get ( u""listing"" ). get ( u""length"" ) <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> var. get ( u""_assert2"" ). get ( u""default"" ). callprop ( <TAB> <TAB> <TAB> <TAB> u""strictEqual"", <TAB> <TAB> <TAB> <TAB> var. get ( u""loc"" ). get ( u""value"" ), <TAB> <TAB> <TAB> <TAB> var. get ( u""this"" ). get ( u""listing"" ). get ( u""length"" ), <TAB> <TAB> <TAB> ) <TAB> else : <TAB> <TAB> var. put ( u""loc"", var. get ( u""this"" ). callprop ( u""getUnmarkedCurrentLoc"" ) ) <TAB> var. get ( u""this"" ). callprop ( <TAB> <TAB> u""emitAssign"", <TAB> <TAB> var. get ( u""this"" ). callprop ( u""contextProperty"", Js ( u""prev"" ) ), <TAB> <TAB> var. get ( u""loc"" ), <TAB> )",False,"PyJsStrictEq(var.get(u'loc').get(u'value'), -Js(1.0))",u'this' in var,0.6516244411468506
|
||
|
3290,"def __adjacentSearchResultDisplayIndex ( self, currentDisplayIndex, previous ) : <TAB> displayIsSearchModel = currentDisplayIndex. model ( ) == self. __searchModel <TAB> if displayIsSearchModel : <TAB> <TAB> currentResult = currentDisplayIndex <TAB> else : <TAB> <TAB> currentResult = self. __searchModel. mapFromSource ( currentDisplayIndex ) <TAB> result = None <TAB> if currentResult. isValid ( ) : <TAB> <TAB> <TAB> <TAB> currentRow = currentResult. row ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if currentRow > 0 : <TAB> <TAB> <TAB> <TAB> result = currentResult. sibling ( currentRow - 1, 0 ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if currentRow < currentResult. model ( ). rowCount ( ) - 1 : <TAB> <TAB> <TAB> <TAB> result = currentResult. sibling ( currentRow + 1, 0 ) <TAB> else : <TAB> <TAB> <TAB> <TAB> result = self. __findNearestSearchResult ( currentDisplayIndex, previous ) <TAB> if result is not None : <TAB> <TAB> return ( <TAB> <TAB> <TAB> result if displayIsSearchModel else self. __searchModel. mapToSource ( result ) <TAB> <TAB> )",False,previous,currentResult.isValid(),0.6793214082717896
|
||
|
3291,"def format_callback ( obj ) : <TAB> has_admin = obj. __class__ in admin_site. _registry <TAB> opts = obj. _meta <TAB> no_edit_link = ""%s: %s"" % ( capfirst ( opts. verbose_name ), force_str ( obj ) ) <TAB> if has_admin : <TAB> <TAB> try : <TAB> <TAB> <TAB> admin_url = reverse ( <TAB> <TAB> <TAB> <TAB> ""%s:%s_%s_change"" % ( admin_site. name, opts. app_label, opts. model_name ), <TAB> <TAB> <TAB> <TAB> None, <TAB> <TAB> <TAB> <TAB> ( quote ( obj. _get_pk_val ( ) ), ), <TAB> <TAB> <TAB> ) <TAB> <TAB> except NoReverseMatch : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return no_edit_link <TAB> <TAB> p = ""%s.%s"" % ( opts. app_label, get_permission_codename ( ""delete"", opts ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> perms_needed. add ( opts. verbose_name ) <TAB> <TAB> <TAB> <TAB> return format_html ( <TAB> <TAB> <TAB> '{}: <a href=""{}"">{}</a>', capfirst ( opts. verbose_name ), admin_url, obj <TAB> <TAB> ) <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return no_edit_link",False,not user.has_perm(p),has_admin_url,0.648822546005249
|
||
|
3292,"def _find_existing_ade ( vm, use_instance_view = False, ade_ext_info = None ) : <TAB> if not ade_ext_info : <TAB> <TAB> ade_ext_info = ( <TAB> <TAB> <TAB> vm_extension_info [ ""Linux"" ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> else vm_extension_info [ ""Windows"" ] <TAB> <TAB> ) <TAB> if use_instance_view : <TAB> <TAB> exts = vm. instance_view. extensions or [ ] <TAB> <TAB> r = next ( <TAB> <TAB> <TAB> ( <TAB> <TAB> <TAB> <TAB> e <TAB> <TAB> <TAB> <TAB> for e in exts <TAB> <TAB> <TAB> <TAB> if e. type <TAB> <TAB> <TAB> <TAB> and e. type. lower ( ). startswith ( ade_ext_info [ ""publisher"" ]. lower ( ) ) <TAB> <TAB> <TAB> <TAB> and e. name. lower ( ) == ade_ext_info [ ""name"" ]. lower ( ) <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> None, <TAB> <TAB> ) <TAB> else : <TAB> <TAB> exts = vm. resources or [ ] <TAB> <TAB> r = next ( <TAB> <TAB> <TAB> ( <TAB> <TAB> <TAB> <TAB> e <TAB> <TAB> <TAB> <TAB> for e in exts <TAB> <TAB> <TAB> <TAB> if ( <TAB> <TAB> <TAB> <TAB> <TAB> e. publisher. lower ( ) == ade_ext_info [ ""publisher"" ]. lower ( ) <TAB> <TAB> <TAB> <TAB> <TAB> and e. type_properties_type. lower ( ) == ade_ext_info [ ""name"" ]. lower ( ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> None, <TAB>",False,_is_linux_os(vm),vm_extension_info is None,0.6548373699188232
|
||
|
3293,"def __randomize_interval_task ( self ) : <TAB> for job in self. aps_scheduler. get_jobs ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. aps_scheduler. modify_job ( <TAB> <TAB> <TAB> <TAB> job. id, <TAB> <TAB> <TAB> <TAB> next_run_time = datetime. now ( ) <TAB> <TAB> <TAB> <TAB> + timedelta ( <TAB> <TAB> <TAB> <TAB> <TAB> seconds = randrange ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> job. trigger. interval. total_seconds ( ) * 0.75, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> job. trigger. interval. total_seconds ( ), <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> )",False,"isinstance(job.trigger, IntervalTrigger)",job.id == 'TAB > 0,0.6537548303604126
|
||
|
3294,"def gather_notice_files ( install_dir ) : <TAB> """"""Gathers all NOTICE files to a common NOTICE_FILES directory."""""" <TAB> common_notices_dir = utils. NOTICE_FILES_DIR_PATH <TAB> logging. info ( <TAB> <TAB> ""Creating {} directory to gather all NOTICE files..."". format ( common_notices_dir ) <TAB> ) <TAB> os. makedirs ( common_notices_dir ) <TAB> for arch in utils. get_snapshot_archs ( install_dir ) : <TAB> <TAB> notices_dir_per_arch = os. path. join ( arch, utils. NOTICE_FILES_DIR_NAME ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> for notice_file in glob. glob ( ""{}/*.txt"". format ( notices_dir_per_arch ) ) : <TAB> <TAB> <TAB> <TAB> if not os. path. isfile ( <TAB> <TAB> <TAB> <TAB> <TAB> os. path. join ( common_notices_dir, os. path. basename ( notice_file ) ) <TAB> <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> <TAB> shutil. copy ( notice_file, common_notices_dir ) <TAB> <TAB> <TAB> shutil. rmtree ( notices_dir_per_arch )",True,os.path.isdir(notices_dir_per_arch),os.path.isdir(notices_dir_per_arch),0.6434512734413147
|
||
|
3295,"def post ( self, request, * args, ** kwargs ) : <TAB> if request. POST. get ( ""action"" ) == ""delete"" : <TAB> <TAB> return render ( <TAB> <TAB> <TAB> request, <TAB> <TAB> <TAB> ""pretixcontrol/vouchers/delete_bulk.html"", <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> ""allowed"" : self. objects. filter ( redeemed = 0 ), <TAB> <TAB> <TAB> <TAB> ""forbidden"" : self. objects. exclude ( redeemed = 0 ), <TAB> <TAB> <TAB> }, <TAB> <TAB> ) <TAB> elif request. POST. get ( ""action"" ) == ""delete_confirm"" : <TAB> <TAB> for obj in self. objects : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> obj. log_action ( ""pretix.voucher.deleted"", user = self. request. user ) <TAB> <TAB> <TAB> <TAB> OrderPosition. objects. filter ( addon_to__voucher = obj ). delete ( ) <TAB> <TAB> <TAB> <TAB> obj. cartposition_set. all ( ). delete ( ) <TAB> <TAB> <TAB> <TAB> obj. delete ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> obj. log_action ( <TAB> <TAB> <TAB> <TAB> <TAB> ""pretix.voucher.changed"", <TAB> <TAB> <TAB> <TAB> <TAB> user = self. request. user, <TAB> <TAB> <TAB> <TAB> <TAB> data = { <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""max_usages"" : min ( obj. redeemed, obj. max_usages ), <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""bulk"" : True, <TAB> <TAB> <TAB> <TAB> <TAB> }, <TAB> <TAB> <TAB> <TAB>",False,obj.allow_delete(),obj.user,0.655838131904602
|
||
|
3296,"def __call__ ( self, value, clip = None ) : <TAB> if clip is None : <TAB> <TAB> clip = self. clip <TAB> if cbook. iterable ( value ) : <TAB> <TAB> vtype = ""array"" <TAB> <TAB> val = ma. asarray ( value ). astype ( np. float ) <TAB> else : <TAB> <TAB> vtype = ""scalar"" <TAB> <TAB> val = ma. array ( [ value ] ). astype ( np. float ) <TAB> self. autoscale_None ( val ) <TAB> vmin, vmax = self. vmin, self. vmax <TAB> if vmin > vmax : <TAB> <TAB> raise ValueError ( ""minvalue must be less than or equal to maxvalue"" ) <TAB> elif vmin <= 0 : <TAB> <TAB> raise ValueError ( ""values must all be positive"" ) <TAB> elif vmin == vmax : <TAB> <TAB> return 0.0 * val <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> mask = ma. getmask ( val ) <TAB> <TAB> <TAB> val = ma. array ( np. clip ( val. filled ( vmax ), vmin, vmax ), mask = mask ) <TAB> <TAB> result = ( ma. log ( val ) - np. log ( vmin ) ) / ( np. log ( vmax ) - np. log ( vmin ) ) <TAB> if vtype == ""scalar"" : <TAB> <TAB> result = result [ 0 ] <TAB> return result",True,clip,clip,0.6825778484344482
|
||
|
3297,"def get_custom_config ( ) : <TAB> filename = ""custom_config.yml"" <TAB> global_defaults_file = os. path. join ( <TAB> <TAB> get_manim_dir ( ), ""manimlib"", ""default_config.yml"" <TAB> ) <TAB> if os. path. exists ( global_defaults_file ) : <TAB> <TAB> with open ( global_defaults_file, ""r"" ) as file : <TAB> <TAB> <TAB> config = yaml. safe_load ( file ) <TAB> <TAB> if os. path. exists ( filename ) : <TAB> <TAB> <TAB> with open ( filename, ""r"" ) as file : <TAB> <TAB> <TAB> <TAB> local_defaults = yaml. safe_load ( file ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> config = merge_dicts_recursively ( <TAB> <TAB> <TAB> <TAB> <TAB> config, <TAB> <TAB> <TAB> <TAB> <TAB> local_defaults, <TAB> <TAB> <TAB> <TAB> ) <TAB> else : <TAB> <TAB> with open ( filename, ""r"" ) as file : <TAB> <TAB> <TAB> config = yaml. safe_load ( file ) <TAB> return config",True,local_defaults,local_defaults,0.6664410829544067
|
||
|
3298,"def forward ( <TAB> self, x : ComplexTensor, ilens : Union [ torch. LongTensor, numpy. ndarray, List [ int ] ] ) -> Tuple [ ComplexTensor, torch. LongTensor, Optional [ ComplexTensor ] ] : <TAB> assert len ( x ) == len ( ilens ), ( len ( x ), len ( ilens ) ) <TAB> <TAB> if x. dim ( ) not in ( 3, 4 ) : <TAB> <TAB> raise ValueError ( f""Input dim must be 3 or 4: {x.dim()}"" ) <TAB> if not torch. is_tensor ( ilens ) : <TAB> <TAB> ilens = torch. from_numpy ( numpy. asarray ( ilens ) ). to ( x. device ) <TAB> mask = None <TAB> h = x <TAB> if h. dim ( ) == 4 : <TAB> <TAB> if self. training : <TAB> <TAB> <TAB> choices = [ ( False, False ) ] if not self. use_frontend_for_all else [ ] <TAB> <TAB> <TAB> if self. use_wpe : <TAB> <TAB> <TAB> <TAB> choices. append ( ( True, False ) ) <TAB> <TAB> <TAB> if self. use_beamformer : <TAB> <TAB> <TAB> <TAB> choices. append ( ( False, True ) ) <TAB> <TAB> <TAB> use_wpe, use_beamformer = choices [ numpy. random. randint ( len ( choices ) ) ] <TAB> <TAB> else : <TAB> <TAB> <TAB> use_wpe = self. use_wpe <TAB> <TAB> <TAB> use_beamformer = self. use_beamformer <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> h, ilens, mask = self. wpe ( h, ilens ) <TAB> <TAB> <TAB> <TAB> if use_beamformer : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> h, ilens, mask = self. beamformer ( h, ilens ) <TAB> return h, ilens, mask",True,use_wpe,use_wpe,0.6581981182098389
|
||
|
3299,"def _configured_ploidy ( items ) : <TAB> ploidies = collections. defaultdict ( set ) <TAB> for data in items : <TAB> <TAB> ploidy = dd. get_ploidy ( data ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> for k, v in ploidy. items ( ) : <TAB> <TAB> <TAB> <TAB> ploidies [ k ]. add ( v ) <TAB> <TAB> else : <TAB> <TAB> <TAB> ploidies [ ""default"" ]. add ( ploidy ) <TAB> out = { } <TAB> for k, vs in ploidies. items ( ) : <TAB> <TAB> assert len ( vs ) == 1, ""Multiple ploidies set for group calling: %s %s"" % ( <TAB> <TAB> <TAB> k, <TAB> <TAB> <TAB> list ( vs ), <TAB> <TAB> ) <TAB> <TAB> out [ k ] = vs. pop ( ) <TAB> return out",False,"isinstance(ploidy, dict)",ploidy,0.6658090353012085
|
||
|
3300,"def its_value_condition_contain ( _step_obj, condition, value, _stash = EmptyStash ) : <TAB> match = _step_obj. context. match <TAB> seek_value_in_dict = match. seek_value_in_dict <TAB> if condition not in ( ""must"", ""must not"" ) : <TAB> <TAB> raise TerraformComplianceNotImplemented ( <TAB> <TAB> <TAB> ""Condition should be one of: `must`, `must not`"" <TAB> <TAB> ) <TAB> values = _step_obj. context. stash if _stash is EmptyStash else _stash <TAB> <TAB> if<mask> : <TAB> <TAB> for elem in values : <TAB> <TAB> <TAB> values = its_value_condition_contain ( _step_obj, condition, value, elem ) <TAB> if isinstance ( values, ( int, bool, str, float ) ) : <TAB> <TAB> values = dict ( <TAB> <TAB> <TAB> values = values, <TAB> <TAB> <TAB> address = _step_obj. context. address <TAB> <TAB> <TAB> if hasattr ( _step_obj. context, ""address"" ) <TAB> <TAB> <TAB> else _step_obj. context. addresses, <TAB> <TAB> ) <TAB> found_values = seek_value_in_dict ( value, values ) <TAB> condition = condition == ""must"" <TAB> if condition and not found_values : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> objects = [ ] <TAB> <TAB> <TAB> for elem in values : <TAB> <TAB> <TAB> <TAB> objects. append ( elem. get ( ""address"", ""???"" ) ) <TAB> <TAB> <TAB> objects = "", "". join ( objects ) <TAB> <TAB> else : <TAB> <TAB> <TAB> objects = values. get ( ""address"" ) <TAB> <TAB> Error ( _step_obj, ""{} could not found in {}."". format ( value, objects ) ) <TAB> elif not condition and found_values : <TAB> <TAB> Error ( <TAB> <TAB> <TAB> _step",False,"isinstance(values, list)","isinstance(values, dict)",0.649848461151123
|
||
|
3301,"def get_non_mlt_editable_properties ( clip, filter_object, filter_index ) : <TAB> editable_properties = [ ] <TAB> for i in range ( 0, len ( filter_object. non_mlt_properties ) ) : <TAB> <TAB> prop = filter_object. non_mlt_properties [ i ] <TAB> <TAB> p_name, p_value, p_type = prop <TAB> <TAB> try : <TAB> <TAB> <TAB> args_str = filter_object. info. property_args [ p_name ] <TAB> <TAB> except : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> args_str = ""editor=no_editor"" <TAB> <TAB> <TAB> <TAB> filter_object. info. property_args [ p_name ] = args_str <TAB> <TAB> ep = NonMltEditableProperty ( prop, args_str, clip, filter_index, i ) <TAB> <TAB> editable_properties. append ( ep ) <TAB> return editable_properties",False,p_name == 'mask_type',not args_str,0.6538785696029663
|
||
|
3302,"def reader ( ) : <TAB> src_dict, trg_dict = __read_to_dict ( tar_file, dict_size ) <TAB> with tarfile. open ( tar_file, mode = ""r"" ) as f : <TAB> <TAB> names = [ <TAB> <TAB> <TAB> each_item. name for each_item in f if each_item. name. endswith ( file_name ) <TAB> <TAB> ] <TAB> <TAB> for name in names : <TAB> <TAB> <TAB> for line in f. extractfile ( name ) : <TAB> <TAB> <TAB> <TAB> line = cpt. to_text ( line ) <TAB> <TAB> <TAB> <TAB> line_split = line. strip ( ). split ( ""\t"" ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> src_seq = line_split [ 0 ] <TAB> <TAB> <TAB> <TAB> src_words = src_seq. split ( ) <TAB> <TAB> <TAB> <TAB> src_ids = [ <TAB> <TAB> <TAB> <TAB> <TAB> src_dict. get ( w, UNK_IDX ) for w in [ START ] + src_words + [ END ] <TAB> <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> <TAB> trg_seq = line_split [ 1 ] <TAB> <TAB> <TAB> <TAB> trg_words = trg_seq. split ( ) <TAB> <TAB> <TAB> <TAB> trg_ids = [ trg_dict. get ( w, UNK_IDX ) for w in trg_words ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if len ( src_ids ) > 80 or len ( trg_ids ) > 80 : <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> trg_ids_next = trg_ids + [ trg_dict [ END ] ] <TAB> <TAB> <TAB>",False,len(line_split) != 2,len(src_split) > 10,0.657602071762085
|
||
|
3303,"def writer ( stream, items ) : <TAB> sep = """" <TAB> for item in items : <TAB> <TAB> stream. write ( sep ) <TAB> <TAB> sep = "" "" <TAB> <TAB> if not isinstance ( item, str ) : <TAB> <TAB> <TAB> item = str ( item ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if not isinstance ( item, unicode ) : <TAB> <TAB> <TAB> <TAB> item = str ( item ) <TAB> <TAB> stream. write ( item ) <TAB> stream. write ( ""\n"" )",False,not PY3K,"item, str)",0.6731764078140259
|
||
|
3304,"def _saveParticipants ( course, participants, role ) : <TAB> jcount = len ( participants ) <TAB> course [ role ] = jcount <TAB> display. add_titles_to_csv_file ( [ role ], titles ) <TAB> if countsOnly : <TAB> <TAB> return <TAB> j = 0 <TAB> for member in participants : <TAB> <TAB> memberTitles = [ ] <TAB> <TAB> prefix = f""{role}.{j}."" <TAB> <TAB> profile = member [ ""profile"" ] <TAB> <TAB> emailAddress = profile. get ( ""emailAddress"" ) <TAB> <TAB> if emailAddress : <TAB> <TAB> <TAB> memberTitle = prefix + ""emailAddress"" <TAB> <TAB> <TAB> course [ memberTitle ] = emailAddress <TAB> <TAB> <TAB> memberTitles. append ( memberTitle ) <TAB> <TAB> memberId = profile. get ( ""id"" ) <TAB> <TAB> if memberId : <TAB> <TAB> <TAB> memberTitle = prefix + ""id"" <TAB> <TAB> <TAB> course [ memberTitle ] = memberId <TAB> <TAB> <TAB> memberTitles. append ( memberTitle ) <TAB> <TAB> fullName = profile. get ( ""name"", { } ). get ( ""fullName"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> memberTitle = prefix + ""name.fullName"" <TAB> <TAB> <TAB> course [ memberTitle ] = fullName <TAB> <TAB> <TAB> memberTitles. append ( memberTitle ) <TAB> <TAB> display. add_titles_to_csv_file ( memberTitles, titles ) <TAB> <TAB> j += 1",True,fullName,fullName,0.6752200126647949
|
||
|
3305,"def validate_cluster_resource_group ( cmd, namespace ) : <TAB> if namespace. cluster_resource_group is not None : <TAB> <TAB> client = get_mgmt_service_client ( <TAB> <TAB> <TAB> cmd. cli_ctx, ResourceType. MGMT_RESOURCE_RESOURCES <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise InvalidArgumentValueError ( <TAB> <TAB> <TAB> <TAB> ""Invalid --cluster-resource-group '%s': resource group must not exist."" <TAB> <TAB> <TAB> <TAB> % namespace. cluster_resource_group <TAB> <TAB> <TAB> )",False,client.resource_groups.check_existence(namespace.cluster_resource_group),not client.has_resource(namespace.cluster_resource_group),0.6505018472671509
|
||
|
3306,"def runTest ( self ) : <TAB> """"""This function will update added cast."""""" <TAB> self. server_id = self. database_info [ ""server_id"" ] <TAB> self. db_id = self. database_info [ ""db_id"" ] <TAB> db_con = database_utils. connect_database ( <TAB> <TAB> self, utils. SERVER_GROUP, self. server_id, self. db_id <TAB> ) <TAB> if not db_con [ ""info"" ] == ""Database connected."" : <TAB> <TAB> raise Exception ( ""Could not connect to database."" ) <TAB> connection = utils. get_db_connection ( <TAB> <TAB> self. server [ ""db"" ], <TAB> <TAB> self. server [ ""username"" ], <TAB> <TAB> self. server [ ""db_password"" ], <TAB> <TAB> self. server [ ""host"" ], <TAB> <TAB> self. server [ ""port"" ], <TAB> ) <TAB> casts_exists = cast_utils. verify_cast ( <TAB> <TAB> connection, self. source_type, self. target_type <TAB> ) <TAB> if not casts_exists : <TAB> <TAB> raise Exception ( ""Could not find cast."" ) <TAB> self. data [ ""id"" ] = self. cast_id <TAB> if self. is_positive_test : <TAB> <TAB> response = cast_utils. api_update_cast ( self ) <TAB> <TAB> cast_utils. assert_status_code ( self, response ) <TAB> else : <TAB> <TAB> if self. mocking_required : <TAB> <TAB> <TAB> with patch ( <TAB> <TAB> <TAB> <TAB> self. mock_data [ ""function_name"" ], <TAB> <TAB> <TAB> <TAB> side_effect = [ eval ( self. mock_data [ ""return_value"" ] ) ], <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> response = cast_utils. api_update_cast ( self ) <TAB> <TAB> <TAB> <TAB> cast_utils",False,len(self.data) == 1,self.data is not None,0.6519365310668945
|
||
|
3307,"def __on_mapping_response_cb ( self, iocb : IOCB ) : <TAB> try : <TAB> <TAB> if self. requests_in_progress. get ( iocb ) is not None : <TAB> <TAB> <TAB> log. debug ( iocb ) <TAB> <TAB> <TAB> log. debug ( self. requests_in_progress [ iocb ] ) <TAB> <TAB> <TAB> if iocb. ioResponse : <TAB> <TAB> <TAB> <TAB> apdu = iocb. ioResponse <TAB> <TAB> <TAB> <TAB> value = self. __property_value_from_apdu ( apdu ) <TAB> <TAB> <TAB> <TAB> callback_params = self. requests_in_progress [ iocb ] <TAB> <TAB> <TAB> <TAB> if callback_params. get ( ""callback"" ) is not None : <TAB> <TAB> <TAB> <TAB> <TAB> self. __general_cb ( iocb, callback_params, value ) <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> log. exception ( iocb. ioError ) <TAB> except Exception as e : <TAB> <TAB> log. exception ( e ) <TAB> if self. requests_in_progress. get ( iocb ) is not None : <TAB> <TAB> del self. requests_in_progress [ iocb ]",False,iocb.ioError,self.ioError,0.6684669256210327
|
||
|
3308,"def prepare_run ( self, workspace ) : <TAB> """"""Initialize graph files"""""" <TAB> if not self. wants_objskeleton_graph : <TAB> <TAB> return True <TAB> edge_files = set ( ) <TAB> vertex_files = set ( ) <TAB> m = workspace. measurements <TAB> assert isinstance ( m, Measurements ) <TAB> for image_number in m. get_image_numbers ( ) : <TAB> <TAB> edge_path, vertex_path = self. get_graph_file_paths ( m, image_number ) <TAB> <TAB> edge_files. add ( edge_path ) <TAB> <TAB> vertex_files. add ( vertex_path ) <TAB> for file_path, header in ( <TAB> <TAB> ( edge_path, self. edge_file_columns ), <TAB> <TAB> ( vertex_path, self. vertex_file_columns ), <TAB> ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> import wx <TAB> <TAB> <TAB> if ( <TAB> <TAB> <TAB> <TAB> wx. MessageBox ( <TAB> <TAB> <TAB> <TAB> <TAB> ""%s already exists. Do you want to overwrite it?"" % file_path, <TAB> <TAB> <TAB> <TAB> <TAB> ""Warning: overwriting file"", <TAB> <TAB> <TAB> <TAB> <TAB> style = wx. YES_NO, <TAB> <TAB> <TAB> <TAB> <TAB> parent = workspace. frame, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB>!= wx. YES <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> return False <TAB> <TAB> <TAB> os. remove ( file_path ) <TAB> <TAB> fd = open ( file_path, ""wt"" ) <TAB> <TAB> header = "","". join ( header ) <TAB> <TAB> fd. write ( header + ""\n"" ) <TAB> <TAB> fd. close ( ) <TAB> return True",False,os.path.exists(file_path),file_path,0.6503143310546875
|
||
|
3309,"def _code ( file_path, line_num, end_line_num = None ) : <TAB> line_num = int ( line_num ) <TAB> if not end_line_num : <TAB> <TAB> end_line_num = line_num <TAB> end_line_num = int ( end_line_num ) <TAB> actual_line = [ ] <TAB> lines = """" <TAB> with open ( file_path, ""r"" ) as f : <TAB> <TAB> r = range ( max ( 0, line_num - 10 ), line_num + 10 ) <TAB> <TAB> for i, line in enumerate ( f ) : <TAB> <TAB> <TAB> if i in r : <TAB> <TAB> <TAB> <TAB> lines += line <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> actual_line. append ( line ) <TAB> code = lines. split ( ""\n"" ) <TAB> return actual_line, code",False,"i + 1 in range(line_num, end_line_num + 1)",end_line_num is not None and i + 10 in end_line_num,0.6498064994812012
|
||
|
3310,"def get_class_parameters ( kwarg ) : <TAB> ret = { ""attrs"" : [ ] } <TAB> for key in ( ""rsc"", ""fsc"", ""usc"" ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> ret [ ""attrs"" ]. append ( <TAB> <TAB> <TAB> <TAB> [ <TAB> <TAB> <TAB> <TAB> <TAB> ""TCA_HFSC_%s"" % key. upper ( ), <TAB> <TAB> <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""m1"" : get_rate ( kwarg [ key ]. get ( ""m1"", 0 ) ), <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""d"" : get_time ( kwarg [ key ]. get ( ""d"", 0 ) ), <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""m2"" : get_rate ( kwarg [ key ]. get ( ""m2"", 0 ) ), <TAB> <TAB> <TAB> <TAB> <TAB> }, <TAB> <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> ) <TAB> return ret",False,key in kwarg,kwarg[key],0.6798926591873169
|
||
|
3311,"def run ( self, args ) : <TAB> if args. action == ""start"" : <TAB> <TAB> if not self. client. conn. modules [ ""sudo_alias"" ]. sudo_alias_start ( ) : <TAB> <TAB> <TAB> self. error ( ""the alias already exists"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. success ( <TAB> <TAB> <TAB> <TAB> ""the alias has been created. Waiting for a user to run a sudo command..."" <TAB> <TAB> <TAB> ) <TAB> elif args. action == ""dump"" : <TAB> <TAB> data = self. client. conn. modules [ ""sudo_alias"" ]. sudo_alias_dump ( ) <TAB> <TAB> if not data : <TAB> <TAB> <TAB> self. error ( ""nothing find, be patient!"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. success ( ""Sudo password found: %s"" % data ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> username = data. split ( ""/"" ) [ 0 ] <TAB> <TAB> <TAB> password = data. replace ( username, """" ) [ 1 : ] <TAB> <TAB> <TAB> db = Credentials ( client = self. client. short_name ( ), config = self. config ) <TAB> <TAB> <TAB> db. add ( <TAB> <TAB> <TAB> <TAB> [ <TAB> <TAB> <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""Login"" : username, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""password"" : password, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""CredType"" : ""plaintext"", <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""Category"" : ""System password"", <TAB> <TAB> <TAB> <TAB> <TAB> } <TAB> <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> ) <TAB> <TAB>",False,not self.client.conn.modules['sudo_alias'].sudo_alias_stop(),args.action == 'run',0.6511640548706055
|
||
|
3312,"def parse_grammar ( doc, file, line ) : <TAB> grammar = [ ] <TAB> <TAB> pstrings = doc. splitlines ( ) <TAB> lastp = None <TAB> dline = line <TAB> for ps in pstrings : <TAB> <TAB> dline += 1 <TAB> <TAB> p = ps. split ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> try : <TAB> <TAB> <TAB> if p [ 0 ] == ""|"" : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if not lastp : <TAB> <TAB> <TAB> <TAB> <TAB> raise SyntaxError ( ""%s:%d: Misplaced '|'"" % ( file, dline ) ) <TAB> <TAB> <TAB> <TAB> prodname = lastp <TAB> <TAB> <TAB> <TAB> syms = p [ 1 : ] <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> prodname = p [ 0 ] <TAB> <TAB> <TAB> <TAB> lastp = prodname <TAB> <TAB> <TAB> <TAB> syms = p [ 2 : ] <TAB> <TAB> <TAB> <TAB> assign = p [ 1 ] <TAB> <TAB> <TAB> <TAB> if assign!= "":"" and assign!= ""::="" : <TAB> <TAB> <TAB> <TAB> <TAB> raise SyntaxError ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""%s:%d: Syntax error. Expected ':'"" % ( file, dline ) <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> grammar. append ( ( file, dline, prodname, syms ) ) <TAB> <TAB> except SyntaxError : <TAB> <TAB> <TAB> raise <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> raise SyntaxError ( <TAB> <TAB> <TAB> <TAB> ""%s:%d: Syntax error in rule %r"" % ( file, dline, ps. strip ( ) ) <TAB> <TAB> <TAB",False,not p,len(p) == 0,0.683246910572052
|
||
|
3313,"def TurnIntIntoStrInDict ( the_dict ) : <TAB> """"""Given dict the_dict, recursively converts all integers into strings."""""" <TAB> <TAB> <TAB> for k, v in the_dict. items ( ) : <TAB> <TAB> if isinstance ( v, int ) : <TAB> <TAB> <TAB> v = str ( v ) <TAB> <TAB> <TAB> the_dict [ k ] = v <TAB> <TAB> elif isinstance ( v, dict ) : <TAB> <TAB> <TAB> TurnIntIntoStrInDict ( v ) <TAB> <TAB> elif isinstance ( v, list ) : <TAB> <TAB> <TAB> TurnIntIntoStrInList ( v ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> the_dict [ str ( k ) ] = v <TAB> <TAB> <TAB> del the_dict [ k ]",False,"isinstance(k, int)",k in the_dict,0.6555712223052979
|
||
|
3314,"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. STRING : <TAB> <TAB> <TAB> <TAB> self. dbname = iprot. readString ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif fid == 2 : <TAB> <TAB> <TAB> if ftype == TType. STRING : <TAB> <TAB> <TAB> <TAB> self. name = 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. deleteData = iprot. readBool ( ) <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.BOOL,deleteData is not None,0.6621590852737427
|
||
|
3315,"def _extract_resource ( self, manager, zip_path ) : <TAB> if zip_path in self. _index ( ) : <TAB> <TAB> for name in self. _index ( ) [ zip_path ] : <TAB> <TAB> <TAB> last = self. _extract_resource ( manager, os. path. join ( zip_path, name ) ) <TAB> <TAB> <TAB> <TAB> return os. path. dirname ( last ) <TAB> timestamp, size = self. _get_date_and_size ( self. zipinfo [ zip_path ] ) <TAB> if not WRITE_SUPPORT : <TAB> <TAB> raise IOError ( <TAB> <TAB> <TAB> '""os.rename"" and ""os.unlink"" are not supported'""on this platform"" <TAB> <TAB> ) <TAB> try : <TAB> <TAB> real_path = manager. get_cache_path ( self. egg_name, self. _parts ( zip_path ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return real_path <TAB> <TAB> outf, tmpnam = _mkstemp ( <TAB> <TAB> <TAB> "".$extract"", <TAB> <TAB> <TAB> dir = os. path. dirname ( real_path ), <TAB> <TAB> ) <TAB> <TAB> os. write ( outf, self. loader. get_data ( zip_path ) ) <TAB> <TAB> os. close ( outf ) <TAB> <TAB> utime ( tmpnam, ( timestamp, timestamp ) ) <TAB> <TAB> manager. postprocess ( tmpnam, real_path ) <TAB> <TAB> try : <TAB> <TAB> <TAB> rename ( tmpnam, real_path ) <TAB> <TAB> except os. error : <TAB> <TAB> <TAB> if os. path. isfile ( real_path ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return real_path <TAB>",False,"self._is_current(real_path, zip_path)",self.zip_mode,0.6458537578582764
|
||
|
3316,"def update_remote_branch ( self, validate = False, retry = True ) : <TAB> """"""Pull from remote repository."""""" <TAB> <TAB> self. log_info ( ""updating repository"" ) <TAB> try : <TAB> <TAB> with self. repository. lock : <TAB> <TAB> <TAB> start = time. time ( ) <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> previous = self. repository. last_remote_revision <TAB> <TAB> <TAB> except RepositoryException : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> previous = """" <TAB> <TAB> <TAB> self. repository. update_remote ( ) <TAB> <TAB> <TAB> timediff = time. time ( ) - start <TAB> <TAB> <TAB> self. log_info ( ""update took %.2f seconds"", timediff ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. log_info ( <TAB> <TAB> <TAB> <TAB> <TAB> ""repository updated from %s to %s"", <TAB> <TAB> <TAB> <TAB> <TAB> previous, <TAB> <TAB> <TAB> <TAB> <TAB> self. repository. last_remote_revision, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> for line in self. repository. last_output. splitlines ( ) : <TAB> <TAB> <TAB> <TAB> self. log_debug ( ""update: %s"", line ) <TAB> <TAB> <TAB> if self. id : <TAB> <TAB> <TAB> <TAB> self. delete_alert ( ""UpdateFailure"" ) <TAB> <TAB> return True <TAB> except RepositoryException as error : <TAB> <TAB> report_error ( cause = ""Could not update the repository"" ) <TAB> <TAB> error_text = self. error_text ( error ) <TAB> <TAB> if validate : <TAB> <TAB> <TAB> self. handle_update_error ( error_text, retry ) <TAB> <TAB> <TAB>",False,previous,self.repository.last_output,0.681508481502533
|
||
|
3317,"def _get_cuda_include ( ) : <TAB> include_list = [ ] <TAB> cuda_path = os. environ. get ( ""CUDA_PATH"" ) <TAB> if cuda_path : <TAB> <TAB> include_list. append ( ""%s/include"" % cuda_path ) <TAB> <TAB> include_list. append ( ""%s/samples/common/inc"" % cuda_path ) <TAB> <TAB> return include_list <TAB> returncode, stdout, stderr = ToolChain. _execute ( ""nvcc --version"" ) <TAB> if returncode == 0 : <TAB> <TAB> version_line = stdout. splitlines ( True ) [ - 1 ] <TAB> <TAB> version = version_line. split ( ) [ 4 ] <TAB> <TAB> version = version. replace ( "","", """" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> include_list. append ( ""/usr/local/cuda-%s/include"" % version ) <TAB> <TAB> <TAB> include_list. append ( ""/usr/local/cuda-%s/samples/common/inc"" % version ) <TAB> <TAB> <TAB> return include_list <TAB> return [ ]",False,os.path.isdir('/usr/local/cuda-%s' % version),version,0.6493412256240845
|
||
|
3318,"def update ( self, other ) : <TAB> <TAB> """"""Update this set from other LimitedSet, dict or iterable."""""" <TAB> if not other : <TAB> <TAB> return <TAB> if isinstance ( other, LimitedSet ) : <TAB> <TAB> self. _data. update ( other. _data ) <TAB> <TAB> self. _refresh_heap ( ) <TAB> <TAB> self. purge ( ) <TAB> elif isinstance ( other, dict ) : <TAB> <TAB> <TAB> <TAB> for key, inserted in items ( other ) : <TAB> <TAB> <TAB> if isinstance ( inserted, ( tuple, list ) ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> inserted = inserted [ 0 ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Expecting float timestamp, got type "" <TAB> <TAB> <TAB> <TAB> <TAB> ""{0!r} with value: {1}"". format ( type ( inserted ), inserted ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> self. add ( key, inserted ) <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for obj in other : <TAB> <TAB> <TAB> self. add ( obj )",False,"not isinstance(inserted, float)","isinstance(inserted, float) or not isinstance(inserted, int)",0.6548112630844116
|
||
|
3319,"def options_to_metadata ( self, options ) : <TAB> self. cell_metadata_json = self. cell_metadata_json or is_json_metadata ( options ) <TAB> title, metadata = text_to_metadata ( options, allow_title = True ) <TAB> <TAB> for cell_type in [ ""markdown"", ""raw"", ""md"" ] : <TAB> <TAB> code = ""[{}]"". format ( cell_type ) <TAB> <TAB> if code in title : <TAB> <TAB> <TAB> title = title. replace ( code, """" ). strip ( ) <TAB> <TAB> <TAB> metadata [ ""cell_type"" ] = cell_type <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> metadata [ ""region_name"" ] = cell_type <TAB> <TAB> <TAB> <TAB> metadata [ ""cell_type"" ] = ""markdown"" <TAB> <TAB> <TAB> break <TAB> <TAB> cell_depth = 0 <TAB> while title. startswith ( ""%"" ) : <TAB> <TAB> cell_depth += 1 <TAB> <TAB> title = title [ 1 : ] <TAB> if cell_depth : <TAB> <TAB> metadata [ ""cell_depth"" ] = cell_depth <TAB> <TAB> title = title. strip ( ) <TAB> if title : <TAB> <TAB> metadata [ ""title"" ] = title <TAB> return None, metadata",False,cell_type == 'md',region_name,0.6558339595794678
|
||
|
3320,"def __init__ ( self, mw, parent = None ) : <TAB> self. parent = parent or mw <TAB> self. mw = mw <TAB> self. col = mw. col <TAB> QDialog. __init__ ( self, self. parent, Qt. Window ) <TAB> self. model = None <TAB> self. dialog = aqt. forms. addmodel. Ui_Dialog ( ) <TAB> self. dialog. setupUi ( self ) <TAB> <TAB> self. models = [ ] <TAB> for ( name, func ) in stdmodels. models : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> name = name ( ) <TAB> <TAB> item = QListWidgetItem ( _ ( ""Add: %s"" ) % name ) <TAB> <TAB> self. dialog. models. addItem ( item ) <TAB> <TAB> self. models. append ( ( True, func ) ) <TAB> <TAB> for m in sorted ( self. col. models. all ( ), key = itemgetter ( ""name"" ) ) : <TAB> <TAB> item = QListWidgetItem ( _ ( ""Clone: %s"" ) % m [ ""name"" ] ) <TAB> <TAB> self. dialog. models. addItem ( item ) <TAB> <TAB> self. models. append ( ( False, m ) ) <TAB> self. dialog. models. setCurrentRow ( 0 ) <TAB> <TAB> s = QShortcut ( QKeySequence ( ""Return"" ), self ) <TAB> self. connect ( s, SIGNAL ( ""activated()"" ), self. accept ) <TAB> <TAB> self. connect ( self. dialog. buttonBox, SIGNAL ( ""helpRequested()"" ), self. onHelp )",False,callable(name),func,0.65920090675354
|
||
|
3321,"def create ( cls, source_data, _factory_fields = None ) : <TAB> if isinstance ( source_data, cls ) : <TAB> <TAB> return source_data <TAB> <TAB> <TAB> key_types = get_types ( cls. _checked_key_types ) <TAB> checked_key_type = next ( ( t for t in key_types if issubclass ( t, CheckedType ) ), None ) <TAB> value_types = get_types ( cls. _checked_value_types ) <TAB> checked_value_type = next ( <TAB> <TAB> ( t for t in value_types if issubclass ( t, CheckedType ) ), None <TAB> ) <TAB> if checked_key_type or checked_value_type : <TAB> <TAB> return cls ( <TAB> <TAB> <TAB> dict ( <TAB> <TAB> <TAB> <TAB> ( <TAB> <TAB> <TAB> <TAB> <TAB> checked_key_type. create ( key ) <TAB> <TAB> <TAB> <TAB> <TAB> if checked_key_type <TAB> <TAB> <TAB> <TAB> <TAB> and not any ( isinstance ( key, t ) for t in key_types ) <TAB> <TAB> <TAB> <TAB> <TAB> else key, <TAB> <TAB> <TAB> <TAB> <TAB> checked_value_type. create ( value ) <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> and not any ( isinstance ( value, t ) for t in value_types ) <TAB> <TAB> <TAB> <TAB> <TAB> else value, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> for key, value in source_data. items ( ) <TAB> <TAB> <TAB> ) <TAB> <TAB> ) <TAB> return cls ( source_data )",False,checked_value_type,value_types,0.657126247882843
|
||
|
3322,"def terminate ( self ) : <TAB> if self. returncode is None : <TAB> <TAB> try : <TAB> <TAB> <TAB> os. kill ( self. pid, TERM_SIGNAL ) <TAB> <TAB> except OSError as exc : <TAB> <TAB> <TAB> if getattr ( exc, ""errno"", None )!= errno. ESRCH : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> raise",False,self.wait(timeout=0.1) is None,"getattr(exc, 'error', None) != errno.ENOENT",0.6501256823539734
|
||
|
3323,"def handleHover ( self, event ) : <TAB> if self. trackinghover and not self. draggingWidgets and not self. draggingMarquee : <TAB> <TAB> for widget in self. widgets : <TAB> <TAB> <TAB> if widget. getPixelRect ( ). Contains ( event. GetPosition ( ) ) : <TAB> <TAB> <TAB> <TAB> if widget!= self. tooltipplace : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. tooltiptimer. Stop ( ) <TAB> <TAB> <TAB> <TAB> <TAB> self. tooltiptimer. Start ( 800, wx. TIMER_ONE_SHOT ) <TAB> <TAB> <TAB> <TAB> <TAB> self. tooltipplace = widget <TAB> <TAB> <TAB> <TAB> <TAB> if self. tooltipobj : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if isinstance ( self. tooltipobj, wx. TipWindow ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. tooltipobj. Close ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> except : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. tooltipobj = None <TAB> <TAB> <TAB> <TAB> return <TAB> self. tooltiptimer. Stop ( ) <TAB> self. tooltipplace = None <TAB> if self. tooltipobj : <TAB> <TAB> if isinstance ( self. tooltipobj, wx. TipWindow ) : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> self. tooltipobj. Close ( ) <TAB> <TAB> <TAB> except : <TAB> <TAB> <TAB> <",False,self.tooltiptimer.IsRunning(),self.tooltiptimer,0.6561224460601807
|
||
|
3324,"def resolve_account ( self, account_name ) : <TAB> account = None <TAB> if isinstance ( account_name, ( int, float ) ) : <TAB> <TAB> acc_id = int ( account_name ) <TAB> <TAB> self. log. debug ( ""Treating account name as ID: %s"", acc_id ) <TAB> <TAB> account = self. user. accounts ( ident = acc_id ). first ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise TaurusConfigError ( ""BlazeMeter account not found by ID: %s"" % acc_id ) <TAB> elif account_name : <TAB> <TAB> account = self. user. accounts ( name = account_name ). first ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise TaurusConfigError ( <TAB> <TAB> <TAB> <TAB> ""BlazeMeter account not found by name: %s"" % account_name <TAB> <TAB> <TAB> ) <TAB> if account : <TAB> <TAB> return account <TAB> self. user. fetch ( ) <TAB> account = self. user. accounts ( ident = self. user [ ""defaultProject"" ] [ ""accountId"" ] ). first ( ) <TAB> self. log. debug ( ""Using default account: %s"", account ) <TAB> return account",True,not account,not account,0.6969590783119202
|
||
|
3325,"def to_tree ( self, tagname = None, value = None, namespace = None ) : <TAB> namespace = getattr ( self, ""namespace"", namespace ) <TAB> if value is not None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> tagname = ""{%s}%s"" % ( namespace, tagname ) <TAB> <TAB> el = Element ( tagname ) <TAB> <TAB> el. text = safe_string ( value ) <TAB> <TAB> return el",False,namespace is not None,tagname is not None,0.6685054302215576
|
||
|
3326,"def publish ( request, user_id = None ) : <TAB> initial = None <TAB> if user_id : <TAB> <TAB> user_to = get_object_or_404 ( User, pk = user_id ) <TAB> <TAB> initial = { ""users"" : [ user_to. st. nickname ] } <TAB> user = request. user <TAB> tform = TopicForPrivateForm ( user = user, data = post_data ( request ) ) <TAB> cform = CommentForm ( user = user, data = post_data ( request ) ) <TAB> tpform = TopicPrivateManyForm ( user = user, data = post_data ( request ), initial = initial ) <TAB> if ( <TAB> <TAB> is_post ( request ) <TAB> <TAB> and all ( [ tform. is_valid ( ), cform. is_valid ( ), tpform. is_valid ( ) ] ) <TAB> <TAB> and not request. is_limited ( ) <TAB> ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return redirect ( <TAB> <TAB> <TAB> <TAB> request. POST. get ( ""next"", None ) or tform. category. get_absolute_url ( ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> topic = tform. save ( ) <TAB> <TAB> cform. topic = topic <TAB> <TAB> comment = cform. save ( ) <TAB> <TAB> comment_posted ( comment = comment, mentions = None ) <TAB> <TAB> tpform. topic = topic <TAB> <TAB> tpform. save_m2m ( ) <TAB> <TAB> TopicNotification. bulk_create ( users = tpform. get_users ( ), comment = comment ) <TAB> <TAB> return redirect ( topic. get_absolute_url ( ) ) <TAB> return render ( <TAB> <TAB> request = request, <TAB> <TAB> template_name = ""spirit/topic/private/publish.html"", <TAB> <TAB> context = { ""tform"" : tform, ""cform"" : cform, ""tpform"" : tp",False,not user.st.update_post_hash(tform.get_topic_hash()),tform.is_valid(),0.6456319093704224
|
||
|
3327,"def __init__ ( self, * args, ** keywords ) : <TAB> super ( ). __init__ ( ) <TAB> self. leftMargin = None <TAB> self. rightMargin = None <TAB> <TAB> <TAB> self. distance = None <TAB> self. topDistance = None <TAB> <TAB> self. isNew = None <TAB> for key in keywords : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. leftMargin = keywords [ key ] <TAB> <TAB> elif key. lower ( ) == ""rightmargin"" : <TAB> <TAB> <TAB> self. rightMargin = keywords [ key ] <TAB> <TAB> elif key. lower ( ) == ""distance"" : <TAB> <TAB> <TAB> self. distance = keywords [ key ] <TAB> <TAB> elif key. lower ( ) == ""topdistance"" : <TAB> <TAB> <TAB> self. topDistance = keywords [ key ] <TAB> <TAB> elif key. lower ( ) == ""isnew"" : <TAB> <TAB> <TAB> self. isNew = keywords [ key ]",True,key.lower() == 'leftmargin',key.lower() == 'leftmargin',0.6590834259986877
|
||
|
3328,"def insert_general_char ( self, ch ) : <TAB> k, w = self. k, self. w <TAB> if g. isWordChar ( ch ) : <TAB> <TAB> self. insert_string ( ch ) <TAB> <TAB> common_prefix, prefix, aList = self. compute_completion_list ( ) <TAB> <TAB> if not aList : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. do_backspace ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> elif self. auto_tab and len ( common_prefix ) > len ( prefix ) : <TAB> <TAB> <TAB> extend = common_prefix [ len ( prefix ) : ] <TAB> <TAB> <TAB> ins = w. getInsertPoint ( ) <TAB> <TAB> <TAB> w. insert ( ins, extend ) <TAB> else : <TAB> <TAB> if ch == ""("" and k. enable_calltips : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. calltip ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. insert_string ( ch ) <TAB> <TAB> <TAB> self. exit ( )",False,self.forbid_invalid,prefix,0.6524679064750671
|
||
|
3329,"def _process_write_backlog ( self ) : <TAB> <TAB> if self. _transport is None : <TAB> <TAB> return <TAB> try : <TAB> <TAB> for i in range ( len ( self. _write_backlog ) ) : <TAB> <TAB> <TAB> data, offset = self. _write_backlog [ 0 ] <TAB> <TAB> <TAB> if data : <TAB> <TAB> <TAB> <TAB> ssldata, offset = self. _sslpipe. feed_appdata ( data, offset ) <TAB> <TAB> <TAB> elif offset : <TAB> <TAB> <TAB> <TAB> ssldata = self. _sslpipe. do_handshake ( self. _on_handshake_complete ) <TAB> <TAB> <TAB> <TAB> offset = 1 <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> ssldata = self. _sslpipe. shutdown ( self. _finalize ) <TAB> <TAB> <TAB> <TAB> offset = 1 <TAB> <TAB> <TAB> for chunk in ssldata : <TAB> <TAB> <TAB> <TAB> self. _transport. write ( chunk ) <TAB> <TAB> <TAB> if offset < len ( data ) : <TAB> <TAB> <TAB> <TAB> self. _write_backlog [ 0 ] = ( data, offset ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> assert self. _sslpipe. need_ssldata <TAB> <TAB> <TAB> <TAB> if self. _transport. _paused : <TAB> <TAB> <TAB> <TAB> <TAB> self. _transport. resume_reading ( ) <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> del self. _write_backlog [ 0 ] <TAB> <TAB> <TAB> self. _write_buffer_size -= len ( data ) <TAB> except BaseException as exc : <TAB> <TAB> if<mask> :",False,self._in_handshake,"exc.args[0] in [E, T]",0.6574366092681885
|
||
|
3330,"def visit ( stmt ) : <TAB> """"""Collect information about VTCM buffers and their alignments."""""" <TAB> if isinstance ( stmt, tvm. tir. AttrStmt ) : <TAB> <TAB> if stmt. attr_key == ""storage_scope"" and stmt. value == ""local.vtcm"" : <TAB> <TAB> <TAB> vtcm_buffers. append ( stmt. node ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> if not stmt. node in alignments : <TAB> <TAB> <TAB> <TAB> alignments [ stmt. node ] = [ ] <TAB> <TAB> <TAB> alignments [ stmt. node ]. append ( stmt. value )",False,stmt.attr_key == 'storage_alignment',stmt.attr_key == 'tvm_buffer' and stmt.value == 'local. alignments',0.6511671543121338
|
||
|
3331,"def verify_relative_valid_path ( root, path ) : <TAB> if len ( path ) < 1 : <TAB> <TAB> raise PackagerError ( ""Empty chown path"" ) <TAB> checkpath = root <TAB> parts = path. split ( os. sep ) <TAB> for part in parts : <TAB> <TAB> if part in ( ""."", "".."" ) : <TAB> <TAB> <TAB> raise PackagerError ( "". and.. is not allowed in chown path"" ) <TAB> <TAB> checkpath = os. path. join ( checkpath, part ) <TAB> <TAB> relpath = checkpath [ len ( root ) + 1 : ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise PackagerError ( f""chown path {relpath} does not exist"" ) <TAB> <TAB> if os. path. islink ( checkpath ) : <TAB> <TAB> <TAB> raise PackagerError ( f""chown path {relpath} is a soft link"" )",False,not os.path.exists(checkpath),not os.path.exists(relpath),0.6449614763259888
|
||
|
3332,"def get_macho ( self, exe_address ) : <TAB> proc_as = self. get_process_address_space ( ) <TAB> m = obj. Object ( ""macho_header"", offset = exe_address, vm = proc_as ) <TAB> buffer = """" <TAB> for seg in m. segments ( ) : <TAB> <TAB> if str ( seg. segname ) == ""__PAGEZERO"" : <TAB> <TAB> <TAB> continue <TAB> <TAB> if seg. vmsize == 0 or seg. vmsize > 100000000 : <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> cur = seg. vmaddr <TAB> <TAB> end = seg. vmaddr + seg. vmsize <TAB> <TAB> while cur < end : <TAB> <TAB> <TAB> buffer = buffer + proc_as. zread ( cur, 4096 ) <TAB> <TAB> <TAB> cur = cur + 4096 <TAB> return buffer",False,str(seg.segname) == '__LINKEDIT' and seg.vmsize > 20000000,seg.vmaddr == 0,0.6612439155578613
|
||
|
3333,"def mock_endpoints ( self ) : <TAB> for framework in self. get_directories ( self. mock_dir ) : <TAB> <TAB> if framework in [ ""nessus"", ""tenable"" ] : <TAB> <TAB> <TAB> self. create_nessus_resource ( framework ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> self. qualys_vuln_path = self. mock_dir + ""/"" + framework <TAB> <TAB> <TAB> self. create_qualys_vuln_resource ( framework ) <TAB> httpretty. enable ( )",False,framework == 'qualys_vuln',framework in ['qualys'],0.6622102856636047
|
||
|
3334,"def _handle_unsubscribe ( self, web_sock ) : <TAB> index = None <TAB> with await self. _subscriber_lock : <TAB> <TAB> for i, ( subscriber_web_sock, _ ) in enumerate ( self. _subscribers ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> index = i <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> if index is not None : <TAB> <TAB> <TAB> del self. _subscribers [ index ] <TAB> <TAB> if not self. _subscribers : <TAB> <TAB> <TAB> asyncio. ensure_future ( self. _unregister_subscriptions ( ) )",True,subscriber_web_sock == web_sock,subscriber_web_sock == web_sock,0.6525733470916748
|
||
|
3335,"def init_db ( self ) : <TAB> """"""Create the database connection"""""" <TAB> urlinfo = urlparse ( self. db_url ) <TAB> if urlinfo. password : <TAB> <TAB> <TAB> <TAB> urlinfo = urlinfo. _replace ( <TAB> <TAB> <TAB> netloc = ""{}:[redacted]@{}:{}"". format ( <TAB> <TAB> <TAB> <TAB> urlinfo. username, urlinfo. hostname, urlinfo. port <TAB> <TAB> <TAB> ) <TAB> <TAB> ) <TAB> <TAB> db_log_url = urlinfo. geturl ( ) <TAB> else : <TAB> <TAB> db_log_url = self. db_url <TAB> self. log. debug ( ""Connecting to db: %s"", db_log_url ) <TAB> if self. upgrade_db : <TAB> <TAB> dbutil. upgrade_if_needed ( self. db_url, log = self. log ) <TAB> try : <TAB> <TAB> self. session_factory = orm. new_session_factory ( <TAB> <TAB> <TAB> self. db_url, reset = self. reset_db, echo = self. debug_db, ** self. db_kwargs <TAB> <TAB> ) <TAB> <TAB> self. db = self. session_factory ( ) <TAB> except OperationalError as e : <TAB> <TAB> self. log. error ( ""Failed to connect to db: %s"", db_log_url ) <TAB> <TAB> self. log. debug ( ""Database error was:"", exc_info = True ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _check_db_path ( self. db_url. split ( "":///"", 1 ) [ 1 ] ) <TAB> <TAB> self. log. critical ( <TAB> <TAB> <TAB> ""\n"". join ( <TAB> <TAB> <TAB> <TAB> [ <TAB> <TAB> <TAB> <TAB> <TAB> ""If you recently upgraded JupyterHub, try running"", <TAB> <TAB> <TAB> <TAB> <TAB> "" jupyter",False,self.db_url.startswith('sqlite:///'),self.db_url,0.6489421725273132
|
||
|
3336,"def _eject ( self, bot ) : <TAB> cls = self. __class__ <TAB> try : <TAB> <TAB> for command in self. __cog_commands__ : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> bot. remove_command ( command. name ) <TAB> <TAB> for _, method_name in self. __cog_listeners__ : <TAB> <TAB> <TAB> bot. remove_listener ( getattr ( self, method_name ) ) <TAB> <TAB> if cls. bot_check is not Cog. bot_check : <TAB> <TAB> <TAB> bot. remove_check ( self. bot_check ) <TAB> <TAB> if cls. bot_check_once is not Cog. bot_check_once : <TAB> <TAB> <TAB> bot. remove_check ( self. bot_check_once, call_once = True ) <TAB> finally : <TAB> <TAB> try : <TAB> <TAB> <TAB> self. cog_unload ( ) <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> pass",False,command.parent is None,cls.command,0.6594132781028748
|
||
|
3337,"def get_test ( self, node, name = None ) : <TAB> <TAB> if isinstance ( node, Node ) : <TAB> <TAB> t = type_repr ( node. type ) <TAB> <TAB> if t in [ ""and_test"", ""or_test"", ""not_test"" ] : <TAB> <TAB> <TAB> if name is None : <TAB> <TAB> <TAB> <TAB> return getattr ( self, ""node_%s"" % t ) ( node, True ) <TAB> <TAB> <TAB> return getattr ( self, ""node_%s"" % t ) ( node, name = name ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> test = self. dispatch ( node ) <TAB> <TAB> <TAB> if name is None : <TAB> <TAB> <TAB> <TAB> return ""%s.valueOf()"" % test <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> return ""(%s=%s).valueOf()"" % ( name, test ) <TAB> test = self. dispatch ( node ) <TAB> if name is None : <TAB> <TAB> return ""%s(%s)"" % ( self. jsvars [ ""booljs"" ], test ) <TAB> return ""%s(%s=%s)"" % ( self. jsvars [ ""booljs"" ], name, test )",False,t in ['comparison'],node is None,0.6568170785903931
|
||
|
3338,def close ( self ) : <TAB> self. connected = False <TAB> self. accepting = False <TAB> self. connecting = False <TAB> self. del_channel ( ) <TAB> if self. socket is not None : <TAB> <TAB> try : <TAB> <TAB> <TAB> self. socket. close ( ) <TAB> <TAB> except socket. error as why : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise,False,"why.args[0] not in (ENOTCONN, EBADF)","why.args[0] not in [ECONN, ECONNABORTED, ESHUTDOWN]",0.6510289907455444
|
||
|
3339,"def __init__ ( self, sheet, address ) : <TAB> self. sheet = sheet <TAB> if isinstance ( address, tuple ) : <TAB> <TAB> self. _coords = address <TAB> <TAB> row, col, nrows, ncols = address <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. xl = sheet. xl. cells [ <TAB> <TAB> <TAB> <TAB> ""%s:%s"" <TAB> <TAB> <TAB> <TAB> % ( <TAB> <TAB> <TAB> <TAB> <TAB> sheet. xl. rows [ row ]. columns [ col ]. get_address ( ), <TAB> <TAB> <TAB> <TAB> <TAB> sheet. xl. rows [ row + nrows - 1 ] <TAB> <TAB> <TAB> <TAB> <TAB>. columns [ col + ncols - 1 ] <TAB> <TAB> <TAB> <TAB> <TAB>. get_address ( ), <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ] <TAB> <TAB> else : <TAB> <TAB> <TAB> self. xl = None <TAB> else : <TAB> <TAB> self. xl = sheet. xl. cells [ address ] <TAB> <TAB> self. _coords = None",False,nrows and ncols,sheet.xl is not None,0.6848134398460388
|
||
|
3340,"def collect_apps_with_shared_uid ( product_out, module_paths ) : <TAB> """"""Collect apps with shared UID."""""" <TAB> apps_dir = os. path. join ( product_out, ""obj"", ""APPS"" ) <TAB> result = [ ] <TAB> for app_dir_name in os. listdir ( apps_dir ) : <TAB> <TAB> app_name = re. sub ( ""_intermediates$"", """", app_dir_name ) <TAB> <TAB> app_dir = os. path. join ( apps_dir, app_dir_name ) <TAB> <TAB> apk_file = os. path. join ( app_dir, ""package.apk"" ) <TAB> <TAB> if not os. path. exists ( apk_file ) : <TAB> <TAB> <TAB> print ( ""error: Failed to find:"", apk_file, file = sys. stderr ) <TAB> <TAB> <TAB> continue <TAB> <TAB> apk_unpacked = os. path. join ( app_dir, ""package"" ) <TAB> <TAB> if not os. path. exists ( apk_unpacked ) : <TAB> <TAB> <TAB> ret = subprocess. call ( [ ""apktool"", ""d"", ""package.apk"" ], cwd = app_dir ) <TAB> <TAB> <TAB> if ret!= 0 : <TAB> <TAB> <TAB> <TAB> print ( ""error: Failed to unpack:"", apk_file, file = sys. stderr ) <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> manifest_file = os. path. join ( apk_unpacked, ""AndroidManifest.xml"" ) <TAB> <TAB> if not os. path. exists ( manifest_file ) : <TAB> <TAB> <TAB> print ( ""error: Failed to find:"", manifest_file, file = sys. stderr ) <TAB> <TAB> <TAB> continue <TAB> <TAB> shared_uid = find_shared_uid ( manifest_file ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> result. append ( <TAB>",False,not shared_uid,shared_uid is None,0.6589922904968262
|
||
|
3341,"def __init__ ( self, initial = None ) : <TAB> if babel is None : <TAB> <TAB> raise ImproperlyConfigured ( <TAB> <TAB> <TAB> ""The PhonePrefixSelect widget requires the babel package be installed."" <TAB> <TAB> ) <TAB> choices = [ ( """", ""---------"" ) ] <TAB> language = translation. get_language ( ) or settings. LANGUAGE_CODE <TAB> locale = babel. Locale ( translation. to_locale ( language ) ) <TAB> if not initial : <TAB> <TAB> region = getattr ( settings, ""PHONENUMBER_DEFAULT_REGION"", None ) <TAB> <TAB> initial = region <TAB> for prefix, values in _COUNTRY_CODE_TO_REGION_CODE. items ( ) : <TAB> <TAB> prefix = ""+%d"" % prefix <TAB> <TAB> if initial and initial in values : <TAB> <TAB> <TAB> self. initial = prefix <TAB> <TAB> for country_code in values : <TAB> <TAB> <TAB> country_name = locale. territories. get ( country_code ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> choices. append ( ( prefix, ""{} {}"". format ( country_name, prefix ) ) ) <TAB> super ( ). __init__ ( choices = sorted ( choices, key = lambda item : item [ 1 ] ) )",True,country_name,country_name,0.6658515930175781
|
||
|
3342,"def test_reindex_registration_share ( self ) : <TAB> count = AdminLogEntry. objects. count ( ) <TAB> view = NodeReindexShare ( ) <TAB> view = setup_log_view ( view, self. request, guid = self. registration. _id ) <TAB> with mock. patch ( ""api.share.utils.settings.SHARE_ENABLED"", True ) : <TAB> <TAB> with mock. patch ( ""api.share.utils.settings.SHARE_API_TOKEN"", ""mock-api-token"" ) : <TAB> <TAB> <TAB> with responses. RequestsMock ( assert_all_requests_are_fired = True ) as rsps : <TAB> <TAB> <TAB> <TAB> rsps. add ( responses. POST, ""https://share.osf.io/api/v2/normalizeddata/"" ) <TAB> <TAB> <TAB> <TAB> view. delete ( self. request ) <TAB> <TAB> <TAB> <TAB> data = json. loads ( rsps. calls [ - 1 ]. request. body. decode ( ) ) <TAB> <TAB> <TAB> <TAB> assert any ( <TAB> <TAB> <TAB> <TAB> <TAB> graph <TAB> <TAB> <TAB> <TAB> <TAB> for graph in data [ ""data"" ] [ ""attributes"" ] [ ""data"" ] [ ""@graph"" ] <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> == self. registration. provider. share_publish_type. lower ( ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> nt. assert_equal ( AdminLogEntry. objects. count ( ), count + 1 )",False,graph['@type'],self.registration.provider and self.registration.provider.share_publish_type,0.65819251537323
|
||
|
3343,"def process ( fn ) : <TAB> idmap = { } <TAB> with open ( fn, ""rU"" ) as f : <TAB> <TAB> lines = [ l. rstrip ( ""\n"" ) for l in f. readlines ( ) ] <TAB> <TAB> annotations = [ ] <TAB> <TAB> for i, l in enumerate ( lines ) : <TAB> <TAB> <TAB> annotations. append ( parse ( l, i + 1 ) ) <TAB> <TAB> if DEBUG : <TAB> <TAB> <TAB> for i, a in enumerate ( annotations ) : <TAB> <TAB> <TAB> <TAB> assert lines [ i ] == str ( a ), ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Cross-check failed:\n "" <TAB> <TAB> <TAB> <TAB> <TAB> + '""%s""' % lines [ i ] <TAB> <TAB> <TAB> <TAB> <TAB> + ""!=\n "" <TAB> <TAB> <TAB> <TAB> <TAB> + '""%s""' % str ( a ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> idmap = { } <TAB> <TAB> next_free = { } <TAB> <TAB> <TAB> <TAB> idmap [ ""*"" ] = ""*"" <TAB> <TAB> for i, a in enumerate ( annotations ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> assert a. id_ not in idmap, ""Dup ID on line %d: %s"" % ( i, l ) <TAB> <TAB> <TAB> prefix = a. id_ [ 0 ] <TAB> <TAB> <TAB> seq = next_free. get ( prefix, 1 ) <TAB> <TAB> <TAB> idmap [ a. id_ ] = prefix + str ( seq ) <TAB> <TAB> <TAB> next_free [ prefix ] = seq + 1 <TAB> <TAB> for i, a in enumerate ( annotations ) : <TAB> <TAB> <TAB> a. map_ids ( idmap ) <TAB> <TAB> <TAB> print ( a",False,a.id_ == '*',a.id_ is None,0.659369707107544
|
||
|
3344,"def plot3D ( data, fig, ax ) : <TAB> n = len ( data ) <TAB> for i in range ( n ) : <TAB> <TAB> ikwargs = kwargs_list [ i ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> ax. plot ( data [ i ] [ :, 0 ], data [ i ] [ :, 1 ], data [ i ] [ :, 2 ], ** ikwargs ) <TAB> <TAB> else : <TAB> <TAB> <TAB> ax. plot ( data [ i ] [ :, 0 ], data [ i ] [ :, 1 ], data [ i ] [ :, 2 ], fmt [ i ], ** ikwargs ) <TAB> return fig, ax, data",False,fmt is None,fmt[i] == 'c',0.6687767505645752
|
||
|
3345,"def __getattr__ ( self, key ) : <TAB> for tag in self. tag. children : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> if ""name"" in tag. attrs and tag. attrs [ ""name"" ] in ( key, ) : <TAB> <TAB> <TAB> from thug. DOM. W3C. Core. DOMImplementation import DOMImplementation <TAB> <TAB> <TAB> return DOMImplementation. createHTMLElement ( self. doc, tag ) <TAB> raise AttributeError",False,"tag.name not in ('input',)",tag.type != 'HTMLElement',0.6533414721488953
|
||
|
3346,"def add ( request ) : <TAB> form_type = ""servers"" <TAB> if request. method == ""POST"" : <TAB> <TAB> form = BookMarkForm ( request. POST ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> form_type = form. save ( ) <TAB> <TAB> <TAB> messages. add_message ( request, messages. INFO, ""Bookmark created"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> messages. add_message ( request, messages. INFO, form. errors ) <TAB> <TAB> if form_type == ""server"" : <TAB> <TAB> <TAB> url = reverse ( ""servers"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> url = reverse ( ""metrics"" ) <TAB> <TAB> return redirect ( url ) <TAB> else : <TAB> <TAB> return redirect ( reverse ( ""servers"" ) )",False,form.is_valid(),not form.is_valid(),0.6504781246185303
|
||
|
3347,"def computeMachineName ( self ) : <TAB> """"""Return the name of the current machine, i.e, HOSTNAME."""""" <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> import os <TAB> <TAB> name = os. getenv ( ""HOSTNAME"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> name = os. getenv ( ""COMPUTERNAME"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> import socket <TAB> <TAB> <TAB> name = socket. gethostname ( ) <TAB> except Exception : <TAB> <TAB> name = """" <TAB> return name",False,not name,os.gethostname() is None,0.6866253614425659
|
||
|
3348,"def locate_exe_dir ( d, check = True ) : <TAB> exe_dir = os. path. join ( d, ""Scripts"" ) if ON_WINDOWS else os. path. join ( d, ""bin"" ) <TAB> if not os. path. isdir ( exe_dir ) : <TAB> <TAB> if ON_WINDOWS : <TAB> <TAB> <TAB> bin_dir = os. path. join ( d, ""bin"" ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return bin_dir <TAB> <TAB> if check : <TAB> <TAB> <TAB> raise InvalidVirtualEnv ( ""Unable to locate executables directory."" ) <TAB> return exe_dir",True,os.path.isdir(bin_dir),os.path.isdir(bin_dir),0.6477079391479492
|
||
|
3349,"def update_tags_from_config ( self, to_update, config ) : <TAB> tags = to_update. get ( ""tags"", [ ] ) <TAB> if ""strategy"" in config : <TAB> <TAB> tags. append ( ""{0}_strategy"". format ( config [ ""strategy"" ] ) ) <TAB> if ""complexity"" in config : <TAB> <TAB> tags. append ( ""{0}_complexity"". format ( config [ ""complexity"" ] ) ) <TAB> if ""disruption"" in config : <TAB> <TAB> tags. append ( ""{0}_disruption"". format ( config [ ""disruption"" ] ) ) <TAB> if ""reboot"" in config : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> reboot_tag = ""reboot_required"" <TAB> <TAB> else : <TAB> <TAB> <TAB> reboot_tag = ""no_reboot_needed"" <TAB> <TAB> tags. append ( reboot_tag ) <TAB> to_update [ ""tags"" ] = sorted ( tags )",False,config['reboot'] == 'true',reboot_required is True,0.6523723602294922
|
||
|
3350,"def _get_items ( <TAB> self, <TAB> partition_id, <TAB> start, <TAB> now_ts, <TAB> queue, <TAB> max_requests_per_host, <TAB> max_host_items, <TAB> count, <TAB> max_n_requests, <TAB> to_remove, ) : <TAB> for data in self. _redis. zrevrange ( <TAB> <TAB> partition_id, start = start, end = max_n_requests + start <TAB> ) : <TAB> <TAB> start += 1 <TAB> <TAB> item = unpackb ( data, use_list = False ) <TAB> <TAB> timestamp, fprint, host_crc32, _, score = item <TAB> <TAB> if timestamp > now_ts : <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> queue [ host_crc32 ] = [ ] <TAB> <TAB> if ( <TAB> <TAB> <TAB> max_requests_per_host is not None <TAB> <TAB> <TAB> and len ( queue [ host_crc32 ] ) >= max_requests_per_host <TAB> <TAB> ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> queue [ host_crc32 ]. append ( item ) <TAB> <TAB> if len ( queue [ host_crc32 ] ) > max_host_items : <TAB> <TAB> <TAB> max_host_items = len ( queue [ host_crc32 ] ) <TAB> <TAB> count += 1 <TAB> <TAB> to_remove. append ( data ) <TAB> <TAB> if count >= max_n_requests : <TAB> <TAB> <TAB> break <TAB> return start, count, max_host_items",True,host_crc32 not in queue,host_crc32 not in queue,0.664723813533783
|
||
|
3351,"def next ( self ) : <TAB> """"""Special paging functionality"""""" <TAB> if self. iter == None : <TAB> <TAB> self. iter = iter ( self. objs ) <TAB> try : <TAB> <TAB> return self. iter. next ( ) <TAB> except StopIteration : <TAB> <TAB> self. iter = None <TAB> <TAB> self. objs = [ ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. page += 1 <TAB> <TAB> <TAB> self. _connection. get_response ( self. action, self. params, self. page, self ) <TAB> <TAB> <TAB> return self. next ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise",False,int(self.page) < int(self.total_pages),self.page >= 0,0.6500411033630371
|
||
|
3352,"def _read_dimensions ( self, * dimnames, ** kwargs ) : <TAB> path = kwargs. get ( ""path"", ""/"" ) <TAB> try : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return [ self. rootgrp. dimensions [ dname ] for dname in dimnames ] <TAB> <TAB> group = self. path2group [ path ] <TAB> <TAB> return [ group. dimensions [ dname ] for dname in dimnames ] <TAB> except KeyError : <TAB> <TAB> raise self. Error ( <TAB> <TAB> <TAB> ""In file %s:\nError while reading dimensions: `%s` with kwargs: `%s`"" <TAB> <TAB> <TAB> % ( self. path, dimnames, kwargs ) <TAB> <TAB> )",False,path == '/',path in self.rootgrp,0.6823363304138184
|
||
|
3353,"def _getIdOrKeyword ( self, first = None ) : <TAB> <TAB> quotedId = False <TAB> first = first or self. _getChar ( ) <TAB> if first is SyntaxToken. EOF or not self. _startsId ( first ) : <TAB> <TAB> raise Exception ( ""Internal: getting Id or keyword?"" ) <TAB> if first == ""\\"" : <TAB> <TAB> quotedId = True <TAB> <TAB> res = self. _getChar ( ) <TAB> <TAB> if res is SyntaxToken. EOF : <TAB> <TAB> <TAB> raise Exception ( ""Unexpected EOF when getting Id."" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise Exception ( <TAB> <TAB> <TAB> <TAB> ""Don't support quoted Ids that have "" + ""non Id constituent characters."" <TAB> <TAB> <TAB> ) <TAB> else : <TAB> <TAB> res = first <TAB> <TAB> c = self. _peekChar ( ) <TAB> while ( c is not SyntaxToken. EOF ) and ( not self. _isIdTerminator ( c ) ) : <TAB> <TAB> res = res + c <TAB> <TAB> self. _getChar ( ) <TAB> <TAB> c = self. _peekChar ( ) <TAB> return self. _makeIdOrKeywordToken ( res, quotedId )",False,not self._startsId(first),quotedId,0.6540127992630005
|
||
|
3354,"def find_multiple_stats ( stats, name, _found = None, _on_found = None ) : <TAB> if _found is None : <TAB> <TAB> _found = [ ] <TAB> for child_stats in stats : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> _found. append ( child_stats ) <TAB> <TAB> <TAB> if callable ( _on_found ) : <TAB> <TAB> <TAB> <TAB> _on_found ( _found ) <TAB> <TAB> find_multiple_stats ( child_stats, name, _found ) <TAB> return _found",False,child_stats.name == name,child_stats['name'] == name,0.6564910411834717
|
||
|
3355,"def render ( self, context ) : <TAB> if ""forloop"" in context and self. _id not in context [ ""forloop"" ] : <TAB> <TAB> self. _last_seen = None <TAB> <TAB> context [ ""forloop"" ] [ self. _id ] = 1 <TAB> try : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> compare_to = [ var. resolve ( context, True ) for var in self. _varlist ] <TAB> <TAB> else : <TAB> <TAB> <TAB> compare_to = self. nodelist_true. render ( context ) <TAB> except VariableDoesNotExist : <TAB> <TAB> compare_to = None <TAB> if compare_to!= self. _last_seen : <TAB> <TAB> self. _last_seen = compare_to <TAB> <TAB> content = self. nodelist_true. render ( context ) <TAB> <TAB> return content <TAB> elif self. nodelist_false : <TAB> <TAB> return self. nodelist_false. render ( context ) <TAB> return """"",True,self._varlist,self._varlist,0.6632516980171204
|
||
|
3356,"def _generate_lb_id_list_from_names_or_ids ( cli_ctx, namespace, prop, child_type ) : <TAB> from msrestazure. tools import is_valid_resource_id <TAB> raw = getattr ( namespace, prop ) <TAB> if not raw : <TAB> <TAB> return <TAB> raw = raw if isinstance ( raw, list ) else [ raw ] <TAB> result = [ ] <TAB> for item in raw : <TAB> <TAB> if is_valid_resource_id ( item ) : <TAB> <TAB> <TAB> result. append ( { ""id"" : item } ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise CLIError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Unable to process {}. Please supply a well-formed ID or "" <TAB> <TAB> <TAB> <TAB> <TAB> ""--lb-name."". format ( item ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> result. append ( <TAB> <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> <TAB> ""id"" : _generate_lb_subproperty_id ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> cli_ctx, namespace, child_type, item <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> } <TAB> <TAB> <TAB> ) <TAB> setattr ( namespace, prop, result )",False,not namespace.load_balancer_name,item not in cli_ctx.lb_names,0.6547888517379761
|
||
|
3357,"def get_extension_page_chrome ( driver ) : <TAB> chrome_profile = Path ( driver. capabilities [ ""chrome"" ] [ ""userDataDir"" ] ) <TAB> prefs_file = chrome_profile / ""Default/Preferences"" <TAB> <TAB> <TAB> <TAB> prefs = None <TAB> addon_id = None <TAB> for _ in range ( 30 ) : <TAB> <TAB> sleep ( 0.5 ) <TAB> <TAB> if not prefs_file. exists ( ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> prefs = json. loads ( prefs_file. read_text ( ) ) <TAB> <TAB> settings = prefs. get ( ""extensions"", { } ). get ( ""settings"", None ) <TAB> <TAB> if settings is None : <TAB> <TAB> <TAB> continue <TAB> <TAB> addon_ids = [ <TAB> <TAB> <TAB> k for k, v in settings. items ( ) if Path ( v [ ""path"" ] ). name == f""extension_{k}"" <TAB> <TAB> ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> print ( ""addon_ids is none"" ) <TAB> <TAB> <TAB> continue <TAB> <TAB> [ addon_id ] = addon_ids <TAB> assert addon_id is not None <TAB> assert prefs is not None <TAB> return f""chrome-extension://{addon_id}""",False,len(addon_ids) == 0,not addon_ids,0.6569523811340332
|
||
|
3358,"def test_batch_compute_node_user ( self, batch_pool, ** kwargs ) : <TAB> client = self. create_sharedkey_client ( ** kwargs ) <TAB> nodes = list ( client. compute_node. list ( batch_pool. name ) ) <TAB> while self. is_live and any ( <TAB> <TAB> [ n for n in nodes if n. state!= models. ComputeNodeState. idle ] <TAB> ) : <TAB> <TAB> time. sleep ( 10 ) <TAB> <TAB> nodes = list ( client. compute_node. list ( batch_pool. name ) ) <TAB> <TAB> user_name = ""BatchPythonSDKUser"" <TAB> nodes = list ( client. compute_node. list ( batch_pool. name ) ) <TAB> user = models. ComputeNodeUser ( <TAB> <TAB> name = user_name, password = ""kt#_gahr!@aGERDXA"", is_admin = False <TAB> ) <TAB> response = client. compute_node. add_user ( batch_pool. name, nodes [ 0 ]. id, user ) <TAB> self. assertIsNone ( response ) <TAB> <TAB> user = models. NodeUpdateUserParameter ( password = ""liilef#$DdRGSa_ewkjh"" ) <TAB> response = client. compute_node. update_user ( <TAB> <TAB> batch_pool. name, nodes [ 0 ]. id, user_name, user <TAB> ) <TAB> self. assertIsNone ( response ) <TAB> <TAB> file_length = 0 <TAB> with io. BytesIO ( ) as file_handle : <TAB> <TAB> response = client. compute_node. get_remote_desktop ( batch_pool. name, nodes [ 0 ]. id ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> for data in response : <TAB> <TAB> <TAB> <TAB> file_length += len ( data ) <TAB> self. assertTrue ( file_length > 0 ) <TAB> <TAB> response = client. compute_node. delete_user ( batch_pool. name, nodes [ 0 ]. id, user_name ) <TAB> self. assert",True,response,response,0.6791988611221313
|
||
|
3359,"def merge_with_dict ( self, new_offset_dict ) : <TAB> if not new_offset_dict : <TAB> <TAB> return <TAB> keys = list ( new_offset_dict. keys ( ) ) <TAB> keys. sort ( ) <TAB> identifier2 = keys. pop ( 0 ) <TAB> result_offsets = OffsetList ( fmt = self. fmt ) <TAB> offsets1 = enumerate ( self. get_offsets ( ) ) <TAB> try : <TAB> <TAB> index1, offset1 = next ( offsets1 ) <TAB> <TAB> identifier1 = self. get_identifier_by_offset ( offset1 ) <TAB> except StopIteration : <TAB> <TAB> offset1 = None <TAB> <TAB> identifier1 = None <TAB> <TAB> index1 = 0 <TAB> while True : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. file = result_offsets. file <TAB> <TAB> <TAB> return <TAB> <TAB> elif identifier1 is None or ( identifier2 and identifier2 < identifier1 ) : <TAB> <TAB> <TAB> result_offsets. add_offset ( new_offset_dict [ identifier2 ] ) <TAB> <TAB> <TAB> if keys : <TAB> <TAB> <TAB> <TAB> identifier2 = keys. pop ( 0 ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> identifier2 = None <TAB> <TAB> elif identifier2 is None : <TAB> <TAB> <TAB> result_offsets. file. seek ( result_offsets. file_size ) <TAB> <TAB> <TAB> self. file. seek ( index1 * self. fmt_size ) <TAB> <TAB> <TAB> result_offsets. file. write ( self. file. read ( ) ) <TAB> <TAB> <TAB> identifier1 = None <TAB> <TAB> <TAB> offset1 = None <TAB> <TAB> else : <TAB> <TAB> <TAB> result_offsets. add_offset ( offset1 ) <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> index1, offset1 = next ( offsets1 )",False,identifier1 is None and identifier2 is None,self.has_tab(),0.6543125510215759
|
||
|
3360,def condition ( self ) : <TAB> if self. __condition is None : <TAB> <TAB> if len ( self. flat_conditions ) == 1 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. __condition = self. flat_conditions [ 0 ] <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. __condition = lambda _ : True <TAB> <TAB> else : <TAB> <TAB> <TAB> self. __condition = lambda x : all ( cond ( x ) for cond in self. flat_conditions ) <TAB> return self. __condition,False,len(self.flat_conditions) == 0,len(self.flat_conditions) > 2,0.6558386087417603
|
||
|
3361,"def execute ( ) : <TAB> for doctype in [ ""Expense Claim"", ""Leave Application"" ] : <TAB> <TAB> active_workflow = get_workflow_name ( doctype ) <TAB> <TAB> if not active_workflow : <TAB> <TAB> <TAB> continue <TAB> <TAB> workflow_states = frappe. get_all ( <TAB> <TAB> <TAB> ""Workflow Document State"", <TAB> <TAB> <TAB> filters = [ [ ""parent"", ""="", active_workflow ] ], <TAB> <TAB> <TAB> fields = [ ""*"" ], <TAB> <TAB> ) <TAB> <TAB> for state in workflow_states : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> status_field = ""approval_status"" if doctype == ""Expense Claim"" else ""status"" <TAB> <TAB> <TAB> frappe. set_value ( <TAB> <TAB> <TAB> <TAB> ""Workflow Document State"", state. name, ""update_field"", status_field <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> frappe. set_value ( <TAB> <TAB> <TAB> <TAB> ""Workflow Document State"", state. name, ""update_value"", state. state <TAB> <TAB> <TAB> )",False,state.update_field,state.state == 'Leave Application',0.65739905834198
|
||
|
3362,"def _calculate_runtimes ( states ) : <TAB> results = { ""runtime"" : 0.00, ""num_failed_states"" : 0, ""num_passed_states"" : 0 } <TAB> for state, resultset in states. items ( ) : <TAB> <TAB> if isinstance ( resultset, dict ) and ""duration"" in resultset : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> results [ ""num_passed_states"" ] += 1 <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> results [ ""num_failed_states"" ] += 1 <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> results [ ""runtime"" ] += resultset [ ""duration"" ] <TAB> log. debug ( ""Parsed state metrics: {}"". format ( results ) ) <TAB> return results",False,resultset['result'],'num_failed_states' in results,0.6628532409667969
|
||
|
3363,"def _info ( self, userlist ) : <TAB> for strng in userlist : <TAB> <TAB> group_matched = False <TAB> <TAB> for env in self. base. comps. environments_by_pattern ( strng ) : <TAB> <TAB> <TAB> self. output. display_groups_in_environment ( env ) <TAB> <TAB> <TAB> group_matched = True <TAB> <TAB> for group in self. base. comps. groups_by_pattern ( strng ) : <TAB> <TAB> <TAB> self. output. display_pkgs_in_groups ( group ) <TAB> <TAB> <TAB> group_matched = True <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> logger. error ( _ ( ""Warning: Group %s does not exist."" ), strng ) <TAB> return 0, [ ]",False,not group_matched,group_matched and (not group_matched),0.6588108539581299
|
||
|
3364,"def calculate ( self ) : <TAB> common. set_plugin_members ( self ) <TAB> if self. _config. TASK : <TAB> <TAB> task_addr = self. _config. TASK <TAB> <TAB> try : <TAB> <TAB> <TAB> task_addr = int ( task_addr, 16 ) <TAB> <TAB> except TypeError : <TAB> <TAB> <TAB> debug. error ( ""Invalid task address given. Must be address in hex."" ) <TAB> <TAB> yield obj. Object ( ""proc"", offset = task_addr, vm = self. addr_space ) <TAB> else : <TAB> <TAB> pidlist = None <TAB> <TAB> try : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> pidlist = [ int ( p ) for p in self. _config. PID. split ( "","" ) ] <TAB> <TAB> except : <TAB> <TAB> <TAB> pass <TAB> <TAB> for proc in self. allprocs ( ) : <TAB> <TAB> <TAB> if not pidlist or proc. p_pid in pidlist : <TAB> <TAB> <TAB> <TAB> yield proc",False,self._config.PID,self.has_pid,0.664911150932312
|
||
|
3365,"def _expand_datetime ( start, value ) : <TAB> if not isinstance ( start, datetime ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> end = start + timedelta ( days = 1 ) <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> time = value. split ( ""T"" ) [ 1 ] <TAB> <TAB> time_without_offset = re. sub ( ""[+-].+"", """", time ) <TAB> <TAB> num_separators = time_without_offset. count ( "":"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> end = start + timedelta ( hours = 1 ) <TAB> <TAB> elif num_separators == 1 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> end = start + timedelta ( minutes = 1 ) <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> end = start + timedelta ( seconds = 1 ) <TAB> return end",True,num_separators == 0,num_separators == 0,0.6670196652412415
|
||
|
3366,"def task_loop ( ) : <TAB> """"""Executes tasks indefinitely."""""" <TAB> <TAB> from bot. tasks import commands <TAB> clean_exit = False <TAB> while True : <TAB> <TAB> stacktrace = """" <TAB> <TAB> exception_occurred = False <TAB> <TAB> task = None <TAB> <TAB> <TAB> <TAB> environment. reset_environment ( ) <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> update_task. run ( ) <TAB> <TAB> <TAB> update_task. track_revision ( ) <TAB> <TAB> <TAB> task = tasks. get_task ( ) <TAB> <TAB> <TAB> if not task : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> with _Monitor ( task ) : <TAB> <TAB> <TAB> <TAB> with task. lease ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> commands. process_command ( task ) <TAB> <TAB> except SystemExit as e : <TAB> <TAB> <TAB> exception_occurred = True <TAB> <TAB> <TAB> clean_exit = e. code == 0 <TAB> <TAB> <TAB> if not clean_exit and not isinstance ( e, untrusted. HostException ) : <TAB> <TAB> <TAB> <TAB> logs. log_error ( ""SystemExit occurred while working on task."" ) <TAB> <TAB> <TAB> stacktrace = traceback. format_exc ( ) <TAB> <TAB> except commands. AlreadyRunningError : <TAB> <TAB> <TAB> exception_occurred = False <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> logs. log_error ( ""Error occurred while working on task."" ) <TAB> <TAB> <TAB> exception_occurred = True <TAB> <TAB> <TAB> stacktrace = traceback. format_exc ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> failure_wait_interval = environment. get_value (",True,exception_occurred,exception_occurred,0.6609271764755249
|
||
|
3367,"def get_ldset ( self, ldsets ) : <TAB> ldset = None <TAB> if self. _properties [ ""ldset_name"" ] == """" : <TAB> <TAB> nldset = len ( ldsets ) <TAB> <TAB> if nldset == 0 : <TAB> <TAB> <TAB> msg = _ ( ""Logical Disk Set could not be found."" ) <TAB> <TAB> <TAB> raise exception. NotFound ( msg ) <TAB> <TAB> else : <TAB> <TAB> <TAB> ldset = None <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> msg = ( <TAB> <TAB> <TAB> <TAB> _ ( ""Logical Disk Set `%s` could not be found."" ) <TAB> <TAB> <TAB> <TAB> % self. _properties [ ""ldset_name"" ] <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> raise exception. NotFound ( msg ) <TAB> <TAB> ldset = ldsets [ self. _properties [ ""ldset_name"" ] ] <TAB> return ldset",False,self._properties['ldset_name'] not in ldsets,nldset == 0,0.6567139625549316
|
||
|
3368,"def get_items ( self, paths ) : <TAB> items = [ ] <TAB> for path in paths : <TAB> <TAB> item = self. get_value ( self. get_iter ( path ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return [ i for i in self. itervalues ( ) if i. album is not None ] <TAB> <TAB> items. append ( item ) <TAB> return items",False,item.album is None,item is None,0.6609986424446106
|
||
|
3369,"def loadHandler ( self, human, values, strict ) : <TAB> if values [ 0 ] == ""status"" : <TAB> <TAB> return <TAB> if self. _filecache is None : <TAB> <TAB> <TAB> <TAB> self. loadCache ( ) <TAB> <TAB> self. updateFileCache ( self. getSearchPaths ( ), self. getFileExtensions ( ), True ) <TAB> if values [ 0 ] == self. getSaveName ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> name = values [ 1 ] <TAB> <TAB> <TAB> uuid = values [ 2 ] <TAB> <TAB> <TAB> proxyFile = self. findProxyByUuid ( uuid ) <TAB> <TAB> <TAB> if not proxyFile : <TAB> <TAB> <TAB> <TAB> if strict : <TAB> <TAB> <TAB> <TAB> <TAB> raise RuntimeError ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""%s library could not load %s proxy with UUID %s, file not found."" <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> % ( self. proxyName, name, uuid ) <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> log. warning ( <TAB> <TAB> <TAB> <TAB> <TAB> ""%s library could not load %s proxy with UUID %s, file not found."", <TAB> <TAB> <TAB> <TAB> <TAB> self. proxyName, <TAB> <TAB> <TAB> <TAB> <TAB> name, <TAB> <TAB> <TAB> <TAB> <TAB> uuid, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> self. selectProxy ( proxyFile ) <TAB> <TAB> else : <TAB> <TAB> <TAB> filename = values [ 1 ] <TAB> <TAB> <TAB> log. error ( <TAB> <TAB> <TAB> <TAB> ""Not loading %s %s. Loading proxies from filename is no longer supported, they need",False,len(values) >= 3,len(values) == 3,0.6611036658287048
|
||
|
3370,"def urlquote ( * args, ** kwargs ) : <TAB> new_kwargs = dict ( kwargs ) <TAB> if not PY3 : <TAB> <TAB> new_kwargs = dict ( kwargs ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> del new_kwargs [ ""encoding"" ] <TAB> <TAB> if ""errors"" in kwargs : <TAB> <TAB> <TAB> del new_kwargs [ ""errors"" ] <TAB> return quote ( * args, ** new_kwargs )",False,'encoding' in new_kwargs,'encoding' in kwargs,0.6567065715789795
|
||
|
3371,"def gettz ( name ) : <TAB> tzinfo = None <TAB> if ZONEINFOFILE : <TAB> <TAB> for cachedname, tzinfo in CACHE : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> else : <TAB> <TAB> <TAB> tf = TarFile. open ( ZONEINFOFILE ) <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> zonefile = tf. extractfile ( name ) <TAB> <TAB> <TAB> except KeyError : <TAB> <TAB> <TAB> <TAB> tzinfo = None <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> tzinfo = tzfile ( zonefile ) <TAB> <TAB> <TAB> tf. close ( ) <TAB> <TAB> <TAB> CACHE. insert ( 0, ( name, tzinfo ) ) <TAB> <TAB> <TAB> del CACHE [ CACHESIZE : ] <TAB> return tzinfo",True,cachedname == name,cachedname == name,0.6681300401687622
|
||
|
3372,"def mkdir ( self, mode = 0o777, parents = False, exist_ok = False ) : <TAB> if self. _closed : <TAB> <TAB> self. _raise_closed ( ) <TAB> if not parents : <TAB> <TAB> try : <TAB> <TAB> <TAB> self. _accessor. mkdir ( self, mode ) <TAB> <TAB> except FileExistsError : <TAB> <TAB> <TAB> if not exist_ok or not self. is_dir ( ) : <TAB> <TAB> <TAB> <TAB> raise <TAB> else : <TAB> <TAB> try : <TAB> <TAB> <TAB> self. _accessor. mkdir ( self, mode ) <TAB> <TAB> except FileExistsError : <TAB> <TAB> <TAB> if not exist_ok or not self. is_dir ( ) : <TAB> <TAB> <TAB> <TAB> raise <TAB> <TAB> except OSError as e : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise <TAB> <TAB> <TAB> self. parent. mkdir ( parents = True ) <TAB> <TAB> <TAB> self. _accessor. mkdir ( self, mode )",False,e.errno != ENOENT,e.args[0] in _NO_ERROR,0.6753710508346558
|
||
|
3373,"def is_valid ( self ) : <TAB> """"""Determines whether file is valid for this reader"""""" <TAB> blocklist = self. open ( ) <TAB> valid = True <TAB> for line in blocklist : <TAB> <TAB> line = decode_bytes ( line ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> ( start, end ) = self. parse ( line ) <TAB> <TAB> <TAB> <TAB> if not re. match ( r""^(\d{1,3}\.){4}$"", start + ""."" ) or not re. match ( <TAB> <TAB> <TAB> <TAB> <TAB> r""^(\d{1,3}\.){4}$"", end + ""."" <TAB> <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> <TAB> valid = False <TAB> <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> <TAB> valid = False <TAB> <TAB> <TAB> break <TAB> blocklist. close ( ) <TAB> return valid",False,not self.is_ignored(line),len(line) > 0,0.6494336724281311
|
||
|
3374,"def main ( ) : <TAB> ht = khmer. Nodegraph ( K, 1, 1 ) <TAB> x = [ 0 ] * 255 <TAB> y = [ 0 ] * 255 <TAB> ht. load_stop_tags ( sys. argv [ 1 ] ) <TAB> for n, record in enumerate ( screed. open ( sys. argv [ 2 ] ) ) : <TAB> <TAB> if n % 10000 == 0 : <TAB> <TAB> <TAB> sys. stderr. write ( ""... %d\n"" % n ) <TAB> <TAB> s, p = ht. trim_on_stoptags ( record. sequence ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> if p == 0 : <TAB> <TAB> <TAB> p = 31 <TAB> <TAB> else : <TAB> <TAB> <TAB> p += 1 <TAB> <TAB> x [ p ] += 1 <TAB> <TAB> y [ len ( record. sequence ) ] += 1 <TAB> for i, ( n, m ) in enumerate ( zip ( x, y ) ) : <TAB> <TAB> if m : <TAB> <TAB> <TAB> print ( ""%d,%d,%d"" % ( i, n, m ) )",False,len(s) == len(record.sequence),s,0.6501699686050415
|
||
|
3375,"def _set_autocomplete ( self, notebook ) : <TAB> if notebook : <TAB> <TAB> try : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> notebook = NotebookInfo ( notebook ) <TAB> <TAB> <TAB> obj, x = build_notebook ( notebook ) <TAB> <TAB> <TAB> self. form. widgets [ ""namespace"" ]. notebook = obj <TAB> <TAB> <TAB> self. form. widgets [ ""page"" ]. notebook = obj <TAB> <TAB> <TAB> logger. debug ( ""Notebook for autocomplete: %s (%s)"", obj, notebook ) <TAB> <TAB> except : <TAB> <TAB> <TAB> logger. exception ( ""Could not set notebook: %s"", notebook ) <TAB> else : <TAB> <TAB> self. form. widgets [ ""namespace"" ]. notebook = None <TAB> <TAB> self. form. widgets [ ""page"" ]. notebook = None <TAB> <TAB> logger. debug ( ""Notebook for autocomplete unset"" )",False,"isinstance(notebook, str)",'namespace' not in self.form.widgets,0.6593209505081177
|
||
|
3376,"def _addTab ( self, name, label, idx = None ) : <TAB> label = getLanguageString ( label ) <TAB> tab = Tab ( self, name, label ) <TAB> tab. idx = self. _makeTab ( tab, idx ) <TAB> if idx!= None : <TAB> <TAB> <TAB> <TAB> newIdxList = { } <TAB> <TAB> for tIdx, t in list ( self. _tabs_by_idx. items ( ) ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> t. idx += 1 <TAB> <TAB> <TAB> newIdxList [ t. idx ] = t <TAB> <TAB> self. _tabs_by_idx = newIdxList <TAB> self. _tabs_by_idx [ tab. idx ] = tab <TAB> self. _tabs_by_name [ tab. name ] = tab <TAB> return tab",False,int(tIdx) >= idx,t != None,0.6570781469345093
|
||
|
3377,"def _work_path_to_rel_final_path ( path, upload_path_mapping, upload_base_dir ) : <TAB> """"""Check if `path` is a work-rooted path, and convert to a relative final-rooted path"""""" <TAB> if not path or not isinstance ( path, str ) : <TAB> <TAB> return path <TAB> upload_path = None <TAB> <TAB> <TAB> if upload_path_mapping. get ( path ) is not None and os. path. isfile ( path ) : <TAB> <TAB> upload_path = upload_path_mapping [ path ] <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> paths_to_check = [ key for key in upload_path_mapping if path. startswith ( key ) ] <TAB> <TAB> if paths_to_check : <TAB> <TAB> <TAB> for work_path in paths_to_check : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> final_path = upload_path_mapping [ work_path ] <TAB> <TAB> <TAB> <TAB> <TAB> upload_path = path. replace ( work_path, final_path ) <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> if upload_path is not None : <TAB> <TAB> return os. path. relpath ( upload_path, upload_base_dir ) <TAB> else : <TAB> <TAB> return None",False,os.path.isdir(work_path),work_path in upload_path_mapping,0.6445783376693726
|
||
|
3378,"def hexcmp ( x, y ) : <TAB> try : <TAB> <TAB> a = int ( x, 16 ) <TAB> <TAB> b = int ( y, 16 ) <TAB> <TAB> if a < b : <TAB> <TAB> <TAB> return - 1 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return 1 <TAB> <TAB> return 0 <TAB> except : <TAB> <TAB> return cmp ( x, y )",False,a > b,y < a,0.6758520007133484
|
||
|
3379,"def get_form_context ( self, value, prefix = """", errors = None ) : <TAB> if errors : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> raise TypeError ( <TAB> <TAB> <TAB> <TAB> ""StructBlock.render_form unexpectedly received multiple errors"" <TAB> <TAB> <TAB> ) <TAB> <TAB> error_dict = errors. as_data ( ) [ 0 ]. params <TAB> else : <TAB> <TAB> error_dict = { } <TAB> bound_child_blocks = collections. OrderedDict ( <TAB> <TAB> [ <TAB> <TAB> <TAB> ( <TAB> <TAB> <TAB> <TAB> name, <TAB> <TAB> <TAB> <TAB> block. bind ( <TAB> <TAB> <TAB> <TAB> <TAB> value. get ( name, block. get_default ( ) ), <TAB> <TAB> <TAB> <TAB> <TAB> prefix = ""%s-%s"" % ( prefix, name ), <TAB> <TAB> <TAB> <TAB> <TAB> errors = error_dict. get ( name ), <TAB> <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> for name, block in self. child_blocks. items ( ) <TAB> <TAB> ] <TAB> ) <TAB> return { <TAB> <TAB> ""children"" : bound_child_blocks, <TAB> <TAB> ""help_text"" : getattr ( self. meta, ""help_text"", None ), <TAB> <TAB> ""classname"" : self. meta. form_classname, <TAB> <TAB> ""block_definition"" : self, <TAB> <TAB> ""prefix"" : prefix, <TAB> }",True,len(errors) > 1,len(errors) > 1,0.6576933264732361
|
||
|
3380,"def data ( self, index, role = Qt. DisplayRole ) : <TAB> """"""Cell content"""""" <TAB> if not index. isValid ( ) : <TAB> <TAB> return to_qvariant ( ) <TAB> value = self. get_value ( index ) <TAB> if index. column ( ) == 3 and self. remote : <TAB> <TAB> value = value [ ""view"" ] <TAB> display = value_to_display ( <TAB> <TAB> value, <TAB> <TAB> truncate = index. column ( ) == 3 and self. truncate, <TAB> <TAB> minmax = self. minmax, <TAB> <TAB> collvalue = self. collvalue or index. column ( )!= 3, <TAB> ) <TAB> if role == Qt. DisplayRole : <TAB> <TAB> return to_qvariant ( display ) <TAB> elif role == Qt. EditRole : <TAB> <TAB> return to_qvariant ( value_to_display ( value ) ) <TAB> elif role == Qt. TextAlignmentRole : <TAB> <TAB> if index. column ( ) == 3 : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return to_qvariant ( int ( Qt. AlignLeft | Qt. AlignVCenter ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> return to_qvariant ( int ( Qt. AlignLeft | Qt. AlignTop ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return to_qvariant ( int ( Qt. AlignLeft | Qt. AlignVCenter ) ) <TAB> elif role == Qt. BackgroundColorRole : <TAB> <TAB> return to_qvariant ( self. get_bgcolor ( index ) ) <TAB> elif role == Qt. FontRole : <TAB> <TAB> if index. column ( ) < 3 : <TAB> <TAB> <TAB> return to_qvariant ( get_font ( ""dicteditor_header"" ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return to_qvariant ( get_font ( ""dicteditor"" ) ) <TAB> return to_qvariant ( )",False,len(display.splitlines()) < 3,self.align_left,0.6496597528457642
|
||
|
3381,"def set_selected_strips_proxies ( self, context ) : <TAB> proxy_sizes = [ ""25"", ""50"", ""75"", ""100"" ] <TAB> use_proxy = False <TAB> prefs = get_preferences ( context ) <TAB> for size in proxy_sizes : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> use_proxy = True <TAB> <TAB> <TAB> break <TAB> if not use_proxy : <TAB> <TAB> return <TAB> for s in [ s for s in context. selected_sequences if s. type in [ ""MOVIE"", ""IMAGE"" ] ] : <TAB> <TAB> s. use_proxy = True <TAB> <TAB> s. proxy. build_25 = prefs. proxy_25 <TAB> <TAB> s. proxy. build_50 = prefs. proxy_50 <TAB> <TAB> s. proxy. build_75 = prefs. proxy_75 <TAB> <TAB> s. proxy. build_100 = prefs. proxy_100",False,"hasattr(prefs, 'proxy_' + size)",size in context.selected_sequences,0.648491621017456
|
||
|
3382,"def print_list ( structure, action, indentation ) : <TAB> retstr = """" <TAB> for value in structure : <TAB> <TAB> brackets = form_brackets ( value, indentation ) <TAB> <TAB> new_value = u"""" <TAB> <TAB> if type ( value ) in [ str, unicode, int, float ] : <TAB> <TAB> <TAB> new_value = escape ( value ) <TAB> <TAB> elif type ( value ) in [ bool, type ( None ) ] : <TAB> <TAB> <TAB> new_value = json. dumps ( value ) <TAB> <TAB> elif type ( value ) is dict : <TAB> <TAB> <TAB> new_value = print_dict ( value, action, indentation + 1 ) <TAB> <TAB> elif type ( value ) is list : <TAB> <TAB> <TAB> new_value = print_list ( value, action, indentation + 1 ) <TAB> <TAB> else : <TAB> <TAB> <TAB> print ( ""print_list - Unexpected type {}"". format ( type ( value ) ) ) <TAB> <TAB> content = u""{3}{1}{0}{2},"". format ( <TAB> <TAB> <TAB> new_value, brackets [ ""open"" ], brackets [ ""close"" ], i ( indentation ) <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> retstr += same ( content ) <TAB> <TAB> elif action is ""deleted"" : <TAB> <TAB> <TAB> retstr += deleted ( content ) <TAB> <TAB> elif action is ""added"" : <TAB> <TAB> <TAB> retstr += added ( content ) <TAB> return remove_last_comma ( retstr )",True,action is 'same',action is 'same',0.6558209657669067
|
||
|
3383,"def get_next_url ( self ) : <TAB> if ""next"" in self. request. GET and is_safe_url ( <TAB> <TAB> self. request. GET. get ( ""next"" ), allowed_hosts = None <TAB> ) : <TAB> <TAB> u = self. request. GET. get ( ""next"" ) <TAB> else : <TAB> <TAB> kwargs = { } <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> kwargs [ ""cart_namespace"" ] = self. kwargs [ ""cart_namespace"" ] <TAB> <TAB> u = eventreverse ( self. request. event, ""presale:event.index"", kwargs = kwargs ) <TAB> if ""?"" in u : <TAB> <TAB> u += ""&require_cookie=true"" <TAB> else : <TAB> <TAB> u += ""?require_cookie=true"" <TAB> disclose_cart_id = ( <TAB> <TAB> ""iframe"" in self. request. GET <TAB> <TAB> or settings. SESSION_COOKIE_NAME not in self. request. COOKIES <TAB> ) and self. kwargs. get ( ""cart_namespace"" ) <TAB> if disclose_cart_id : <TAB> <TAB> cart_id = get_or_create_cart_id ( self. request ) <TAB> <TAB> u += ""&cart_id={}"". format ( cart_id ) <TAB> return u",True,'cart_namespace' in self.kwargs,'cart_namespace' in self.kwargs,0.663231372833252
|
||
|
3384,"def _get_failed_phase ( self, index = None ) : <TAB> <TAB> prepend_abort_reason = False <TAB> fails = self. failed_phase_list <TAB> st = self. phase_stack [ - 1 ]. status <TAB> if st in ( SolverStatus. failed, SolverStatus. cyclic ) : <TAB> <TAB> fails = fails + self. phase_stack [ - 1 : ] <TAB> if index is None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> index = - 1 <TAB> <TAB> elif self. callback_return == SolverCallbackReturn. fail : <TAB> <TAB> <TAB> prepend_abort_reason = True <TAB> <TAB> <TAB> index = - 1 <TAB> <TAB> else : <TAB> <TAB> <TAB> index = 0 <TAB> try : <TAB> <TAB> phase = fails [ index ] <TAB> except IndexError : <TAB> <TAB> raise IndexError ( ""failure index out of range"" ) <TAB> fail_description = phase. failure_reason. description ( ) <TAB> if prepend_abort_reason and self. abort_reason : <TAB> <TAB> fail_description = ""%s:\n%s"" % ( self. abort_reason, fail_description ) <TAB> return phase, fail_description",False,st == SolverStatus.cyclic,self.callback_return == SolverCallbackReturn.valid,0.662556529045105
|
||
|
3385,"def train_step ( <TAB> self, sample, model, criterion, optimizer, update_num, ignore_grad = False ) : <TAB> agg_loss, agg_sample_size, agg_logging_output = super ( ). train_step ( <TAB> <TAB> sample, model, criterion, optimizer, update_num, ignore_grad <TAB> ) <TAB> <TAB> if hasattr ( self, ""sparsity_loss"" ) and self. sparsity_loss. is_valid ( update_num ) : <TAB> <TAB> sparsity_loss = 0 <TAB> <TAB> if self. encoder_latent_layer : <TAB> <TAB> <TAB> sparsity_loss += self. sparsity_loss ( <TAB> <TAB> <TAB> <TAB> next ( iter ( model. models. values ( ) ) ). encoder. layer_select. layer_samples, <TAB> <TAB> <TAB> <TAB> update_num, <TAB> <TAB> <TAB> <TAB> agg_sample_size, <TAB> <TAB> <TAB> ) <TAB> <TAB> if self. decoder_latent_layer : <TAB> <TAB> <TAB> sparsity_loss += self. sparsity_loss ( <TAB> <TAB> <TAB> <TAB> next ( iter ( model. models. values ( ) ) ). decoder. layer_select. layer_samples, <TAB> <TAB> <TAB> <TAB> update_num, <TAB> <TAB> <TAB> <TAB> agg_sample_size, <TAB> <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> optimizer. backward ( sparsity_loss ) <TAB> return agg_loss, agg_sample_size, agg_logging_output",False,sparsity_loss > 0,ignore_grad,0.6623136401176453
|
||
|
3386,"def __main__ ( ) : <TAB> <TAB> input_file = sys. argv. pop ( 1 ) <TAB> output_file = sys. argv. pop ( 1 ) <TAB> species = maf_utilities. parse_species_option ( sys. argv. pop ( 1 ) ) <TAB> try : <TAB> <TAB> maf_writer = bx. align. maf. Writer ( open ( output_file, ""w"" ) ) <TAB> except Exception : <TAB> <TAB> print ( sys. stderr, ""Unable to open output file"" ) <TAB> <TAB> sys. exit ( ) <TAB> try : <TAB> <TAB> count = 0 <TAB> <TAB> for count, maf in enumerate ( bx. align. maf. Reader ( open ( input_file ) ) ) : <TAB> <TAB> <TAB> maf = maf. reverse_complement ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> maf = maf. limit_to_species ( species ) <TAB> <TAB> <TAB> maf_writer. write ( maf ) <TAB> except Exception : <TAB> <TAB> print ( ""Your MAF file appears to be malformed."", file = sys. stderr ) <TAB> <TAB> sys. exit ( ) <TAB> print ( ""%i regions were reverse complemented."" % count ) <TAB> maf_writer. close ( )",False,species,species is not None,0.7090811729431152
|
||
|
3387,"def make_team_name_unique ( ) : <TAB> participant_team_list = [ ] <TAB> host_team_list = [ ] <TAB> participant_team_iter = 1 <TAB> participant_teams = ParticipantTeam. objects. all ( ) <TAB> try : <TAB> <TAB> for participant_team in participant_teams : <TAB> <TAB> <TAB> if participant_team. team_name in participant_team_list : <TAB> <TAB> <TAB> <TAB> participant_team. team_name = ""{0}_{1}"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> participant_team. team_name, participant_team_iter <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> participant_team. save ( ) <TAB> <TAB> <TAB> <TAB> participant_team_iter = participant_team_iter + 1 <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> participant_team_list. append ( participant_team. team_name ) <TAB> except Exception as e : <TAB> <TAB> print ( e ) <TAB> host_team_iter = 1 <TAB> host_teams = ChallengeHostTeam. objects. all ( ) <TAB> try : <TAB> <TAB> for host_team in host_teams : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> host_team. team_name = ""{0}_{1}"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> host_team. team_name, host_team_iter <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> host_team. save ( ) <TAB> <TAB> <TAB> <TAB> host_team_iter = host_team_iter + 1 <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> host_team_list. append ( host_team. team_name ) <TAB> except Exception as e : <TAB> <TAB> print ( e )",False,host_team.team_name in host_team_list,host_team.team_name,0.6475498676300049
|
||
|
3388,"def __setitem__ ( self, key, val ) : <TAB> if isinstance ( key, str ) : <TAB> <TAB> key = key. encode ( ""utf-8"" ) <TAB> elif not isinstance ( key, ( bytes, bytearray ) ) : <TAB> <TAB> raise TypeError ( ""keys must be bytes or strings"" ) <TAB> if isinstance ( val, str ) : <TAB> <TAB> val = val. encode ( ""utf-8"" ) <TAB> elif not isinstance ( val, ( bytes, bytearray ) ) : <TAB> <TAB> raise TypeError ( ""values must be bytes or strings"" ) <TAB> self. _verify_open ( ) <TAB> if key not in self. _index : <TAB> <TAB> self. _addkey ( key, self. _addval ( val ) ) <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> pos, siz = self. _index [ key ] <TAB> <TAB> oldblocks = ( siz + _BLOCKSIZE - 1 ) // _BLOCKSIZE <TAB> <TAB> newblocks = ( len ( val ) + _BLOCKSIZE - 1 ) // _BLOCKSIZE <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _index [ key ] = self. _setval ( pos, val ) <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _index [ key ] = self. _addval ( val )",False,newblocks <= oldblocks,newblocks > 0,0.6795023679733276
|
||
|
3389,"def trace ( self, ee, rname ) : <TAB> print ( type ( self ) ) <TAB> self. traceIndent ( ) <TAB> guess = """" <TAB> if self. inputState. guessing > 0 : <TAB> <TAB> guess = "" [guessing]"" <TAB> print ( ( ee + rname + guess ) ) <TAB> for i in xrange ( 1, self. k + 1 ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> print ( "", "" ) <TAB> <TAB> if self. LT ( i ) : <TAB> <TAB> <TAB> v = self. LT ( i ). getText ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> v = ""null"" <TAB> <TAB> print ( ""LA(%s) == %s"" % ( i, v ) ) <TAB> print ( ""\n"" )",False,i != 1,self.inputState.failures > 0,0.6773583889007568
|
||
|
3390,"def flush_condensed_events ( single = False ) : <TAB> while True : <TAB> <TAB> if not single : <TAB> <TAB> <TAB> time. sleep ( CONDENSED_EVENTS_FLUSH_PERIOD ) <TAB> <TAB> with _condensing_lock : <TAB> <TAB> <TAB> for key in _condensed_events : <TAB> <TAB> <TAB> <TAB> condensed = False <TAB> <TAB> <TAB> <TAB> events = _condensed_events [ key ] <TAB> <TAB> <TAB> <TAB> first_event = events [ 0 ] <TAB> <TAB> <TAB> <TAB> condensed_event = [ _ for _ in first_event ] <TAB> <TAB> <TAB> <TAB> for i in xrange ( 1, len ( events ) ) : <TAB> <TAB> <TAB> <TAB> <TAB> current_event = events [ i ] <TAB> <TAB> <TAB> <TAB> <TAB> for j in xrange ( 3, 7 ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if current_event [ j ]!= condensed_event [ j ] : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> condensed = True <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> condensed_event [ j ] = set ( ( condensed_event [ j ], ) ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> condensed_event [ j ]. add ( current_event [ j ] ) <TAB> <TAB> <TAB> <TAB> if condensed : <TAB> <TAB> <TAB> <TAB> <TAB> for i in xrange ( len ( condensed_event ) ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if isinstance ( condensed_event [ i ], set ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> condensed_event",False,"not isinstance(condensed_event[j], set)","isinstance(condensed_event, set)",0.6654090881347656
|
||
|
3391,"def promote ( self, wait_seconds, task, on_success = None, access_is_restricted = False ) : <TAB> if self. role == ""master"" : <TAB> <TAB> return True <TAB> ret = self. _pre_promote ( ) <TAB> with task : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return False <TAB> <TAB> task. complete ( ret ) <TAB> if ret is False : <TAB> <TAB> return False <TAB> if self. cancellable. is_cancelled : <TAB> <TAB> logger. info ( ""PostgreSQL promote cancelled."" ) <TAB> <TAB> return False <TAB> ret = self. pg_ctl ( ""promote"", ""-W"" ) <TAB> if ret : <TAB> <TAB> self. set_role ( ""master"" ) <TAB> <TAB> if on_success is not None : <TAB> <TAB> <TAB> on_success ( ) <TAB> <TAB> if not access_is_restricted : <TAB> <TAB> <TAB> self. call_nowait ( ACTION_ON_ROLE_CHANGE ) <TAB> <TAB> ret = self. _wait_promote ( wait_seconds ) <TAB> return ret",False,task.is_cancelled,task.cancelled(),0.6602706909179688
|
||
|
3392,"def genLoopPackets ( self ) : <TAB> """"""Generator function that continuously returns loop packets"""""" <TAB> <TAB> <TAB> for _packet in self. genPackets ( ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> _packet_type = _packet [ 1 ] <TAB> <TAB> <TAB> if _packet_type in WMR100. _dispatch_dict : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> _raw = WMR100. _dispatch_dict [ _packet_type ] ( self, _packet ) <TAB> <TAB> <TAB> <TAB> if _raw is not None : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> _record = dict ( ) <TAB> <TAB> <TAB> <TAB> <TAB> for k in self. sensor_map : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if self. sensor_map [ k ] in _raw : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> _record [ k ] = _raw [ self. sensor_map [ k ] ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for k in [ ""dateTime"", ""usUnits"" ] : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> _record [ k ] = _raw [ k ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> yield _record <TAB> <TAB> except IndexError : <TAB> <TAB> <TAB> log. error ( ""Malformed packet: %s"" % _packet )",False,_record,self.timestamp_time is not None,0.6737760305404663
|
||
|
3393,"def __call__ ( self, target ) : <TAB> securities = target. temp [ ""selected"" ] <TAB> <TAB> target_risk = np. array ( [ self. _get_target_risk ( target, m ) for m in self. measures ] ) <TAB> if self. strategy is not None : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> target_risk += np. array ( <TAB> <TAB> <TAB> [ self. _get_target_risk ( strategy, m ) for m in self. measures ] <TAB> <TAB> ) <TAB> <TAB> target_risk = target_risk. reshape ( len ( self. measures ), 1 ) <TAB> <TAB> data = [ ] <TAB> for m in self. measures : <TAB> <TAB> d = target. get_data ( ""unit_risk"" ). get ( m ) <TAB> <TAB> if d is None : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""unit_risk for %s not present in temp on %s"" <TAB> <TAB> <TAB> <TAB> % ( self. measure, target. name ) <TAB> <TAB> <TAB> ) <TAB> <TAB> i = d. index. get_loc ( target. now ) <TAB> <TAB> data. append ( ( i, d ) ) <TAB> hedge_risk = np. array ( <TAB> <TAB> [ [ _get_unit_risk ( s, d, i ) for ( i, d ) in data ] for s in securities ] <TAB> ) <TAB> <TAB> if self. pseudo : <TAB> <TAB> inv = np. linalg. pinv ( hedge_risk ). T <TAB> else : <TAB> <TAB> inv = np. linalg. inv ( hedge_risk ). T <TAB> notionals = np. matmul ( inv, - target_risk ). flatten ( ) <TAB> <TAB> for notional, security in zip ( notionals, securities ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <",False,np.isnan(notional) and self.throw_nan,target.now - notional > 0.0,0.6503806114196777
|
||
|
3394,"def __getitem__ ( self, parameters ) : <TAB> if self. _name in ( ""ClassVar"", ""Final"" ) : <TAB> <TAB> item = _type_check ( parameters, f""{self._name} accepts only single type."" ) <TAB> <TAB> return _GenericAlias ( self, ( item, ) ) <TAB> if self. _name == ""Union"" : <TAB> <TAB> if parameters == ( ) : <TAB> <TAB> <TAB> raise TypeError ( ""Cannot take a Union of no types."" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> parameters = ( parameters, ) <TAB> <TAB> msg = ""Union[arg,...]: each arg must be a type."" <TAB> <TAB> parameters = tuple ( _type_check ( p, msg ) for p in parameters ) <TAB> <TAB> parameters = _remove_dups_flatten ( parameters ) <TAB> <TAB> if len ( parameters ) == 1 : <TAB> <TAB> <TAB> return parameters [ 0 ] <TAB> <TAB> return _GenericAlias ( self, parameters ) <TAB> if self. _name == ""Optional"" : <TAB> <TAB> arg = _type_check ( parameters, ""Optional[t] requires a single type."" ) <TAB> <TAB> return Union [ arg, type ( None ) ] <TAB> if self. _name == ""Literal"" : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return _GenericAlias ( self, parameters ) <TAB> raise TypeError ( f""{self} is not subscriptable"" )",False,"not isinstance(parameters, tuple)","isinstance(parameters, tuple)",0.6518985033035278
|
||
|
3395,"def increaseToolReach ( self ) : <TAB> if self. draggingFace is not None : <TAB> <TAB> d = ( 1, - 1 ) [ self. draggingFace & 1 ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> d = - d <TAB> <TAB> self. draggingY += d <TAB> <TAB> x, y, z = self. editor. mainViewport. cameraPosition <TAB> <TAB> pos = [ x, y, z ] <TAB> <TAB> pos [ self. draggingFace >> 1 ] += d <TAB> <TAB> self. editor. mainViewport. cameraPosition = tuple ( pos ) <TAB> else : <TAB> <TAB> self. cloneCameraDistance = self. editor. _incrementReach ( self. cloneCameraDistance ) <TAB> return True",False,self.draggingFace >> 1 != 1,d > 0,0.6574386954307556
|
||
|
3396,"def verify ( self, ** kwargs ) : <TAB> if ""initiate_login_uri"" in self and not self [ ""initiate_login_uri"" ]. startswith ( <TAB> <TAB> ""https:"" <TAB> ) : <TAB> <TAB> raise RegistrationError ( ""initiate_login_uri is not https"" ) <TAB> if ""redirect_uris"" in self : <TAB> <TAB> for uri in self [ ""redirect_uris"" ] : <TAB> <TAB> <TAB> if urlparse ( uri ). fragment : <TAB> <TAB> <TAB> <TAB> raise InvalidRedirectUri ( ""redirect_uri contains fragment: %s"" % uri ) <TAB> for uri in [ ""client_uri"", ""logo_uri"", ""tos_uri"", ""policy_uri"" ] : <TAB> <TAB> if uri in self : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> resp = requests. request ( <TAB> <TAB> <TAB> <TAB> <TAB> ""GET"", str ( self [ uri ] ), allow_redirects = True, verify = False <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> except requests. ConnectionError : <TAB> <TAB> <TAB> <TAB> raise MissingPage ( self [ uri ] ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise MissingPage ( self [ uri ] ) <TAB> try : <TAB> <TAB> ss = self [ ""software_statement"" ] <TAB> except KeyError : <TAB> <TAB> pass <TAB> else : <TAB> <TAB> _ss = [ ] <TAB> <TAB> for _s in ss : <TAB> <TAB> <TAB> _ss. append ( unpack_software_statement ( _s, """", kwargs [ ""keyjar"" ] ) ) <TAB> <TAB> self [ ""__software_statement"" ] = _ss <TAB> return super ( RegistrationRequest, self ). verify ( ** kwargs )",False,resp.status_code not in SUCCESSFUL,uri not in self,0.6549075841903687
|
||
|
3397,"def build_lritems ( self ) : <TAB> for p in self. Productions : <TAB> <TAB> lastlri = p <TAB> <TAB> i = 0 <TAB> <TAB> lr_items = [ ] <TAB> <TAB> while True : <TAB> <TAB> <TAB> if i > len ( p ) : <TAB> <TAB> <TAB> <TAB> lri = None <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> lri = LRItem ( p, i ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> lri. lr_after = self. Prodnames [ lri. prod [ i + 1 ] ] <TAB> <TAB> <TAB> <TAB> except ( IndexError, KeyError ) : <TAB> <TAB> <TAB> <TAB> <TAB> lri. lr_after = [ ] <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> lri. lr_before = lri. prod [ i - 1 ] <TAB> <TAB> <TAB> <TAB> except IndexError : <TAB> <TAB> <TAB> <TAB> <TAB> lri. lr_before = None <TAB> <TAB> <TAB> lastlri. lr_next = lri <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> lr_items. append ( lri ) <TAB> <TAB> <TAB> lastlri = lri <TAB> <TAB> <TAB> i += 1 <TAB> <TAB> p. lr_items = lr_items",False,not lri,lri is None,0.6717793345451355
|
||
|
3398,"def gen_api ( cw, ty ) : <TAB> if ty. name in [ ""BigInteger"", ""Complex"" ] : <TAB> <TAB> return <TAB> cw. writeline ( ) <TAB> cw. write ( ""// Public API - Numerics"" ) <TAB> write_property ( cw, ty, ""real"" ) <TAB> write_property ( cw, ty, ""imag"", const = ""0"" ) <TAB> cw. write ( simple_identity_method, type = ty. name, method_name = ""conjugate"" ) <TAB> if ty. is_float : <TAB> <TAB> pass <TAB> else : <TAB> <TAB> write_property ( cw, ty, ""numerator"" ) <TAB> <TAB> write_property ( cw, ty, ""denominator"", const = ""1"" ) <TAB> <TAB> if ty. name!= ""Int32"" : <TAB> <TAB> <TAB> cw. enter_block ( ""public static string __hex__(%s value)"" % ty. name ) <TAB> <TAB> <TAB> cw. write ( ""return BigIntegerOps.__hex__(value);"" ) <TAB> <TAB> <TAB> cw. exit_block ( ) <TAB> <TAB> cast = ""(int)"" <TAB> <TAB> counter = ""BitLength"" <TAB> <TAB> if ty. size >= 4294967296 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> cast = """" <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> counter += ""Unsigned"" <TAB> <TAB> cw. enter_block ( ""public static int bit_length(%s value)"" % ty. name ) <TAB> <TAB> cw. write ( ""return MathUtils.%s(%svalue);"" % ( counter, cast ) ) <TAB> <TAB> cw. exit_block ( )",False,not ty.is_signed,ty.name != 'Int64',0.659991979598999
|
||
|
3399,"def inner ( ) : <TAB> if action in ( ""permissions-debug"", ""debug-menu"" ) : <TAB> <TAB> if actor and actor. get ( ""id"" ) == ""root"" : <TAB> <TAB> <TAB> return True <TAB> elif action == ""view-instance"" : <TAB> <TAB> allow = datasette. metadata ( ""allow"" ) <TAB> <TAB> if allow is not None : <TAB> <TAB> <TAB> return actor_matches_allow ( actor, allow ) <TAB> elif action == ""view-database"" : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return False <TAB> <TAB> database_allow = datasette. metadata ( ""allow"", database = resource ) <TAB> <TAB> if database_allow is None : <TAB> <TAB> <TAB> return None <TAB> <TAB> return actor_matches_allow ( actor, database_allow ) <TAB> elif action == ""view-table"" : <TAB> <TAB> database, table = resource <TAB> <TAB> tables = datasette. metadata ( ""tables"", database = database ) or { } <TAB> <TAB> table_allow = ( tables. get ( table ) or { } ). get ( ""allow"" ) <TAB> <TAB> if table_allow is None : <TAB> <TAB> <TAB> return None <TAB> <TAB> return actor_matches_allow ( actor, table_allow ) <TAB> elif action == ""view-query"" : <TAB> <TAB> <TAB> <TAB> database, query_name = resource <TAB> <TAB> query = await datasette. get_canned_query ( database, query_name, actor ) <TAB> <TAB> assert query is not None <TAB> <TAB> allow = query. get ( ""allow"" ) <TAB> <TAB> if allow is None : <TAB> <TAB> <TAB> return None <TAB> <TAB> return actor_matches_allow ( actor, allow ) <TAB> elif action == ""execute-sql"" : <TAB> <TAB> <TAB> <TAB> database_allow_sql = datasette. metadata ( ""allow_sql"", database = resource ) <TAB> <TAB>",False,resource == '_internal' and (actor is None or actor.get('id') != 'root'),database_allow is None,0.6554476022720337
|
||
|
3400,"def parse_datatypes ( f ) : <TAB> dt = set ( ) <TAB> for line in f : <TAB> <TAB> if ""<sect1"" in line : <TAB> <TAB> <TAB> break <TAB> <TAB> if ""<entry><type>"" not in line : <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> line = re. sub ( ""<replaceable>[^<]+</replaceable>"", """", line ) <TAB> <TAB> line = re. sub ( ""<[^>]+>"", """", line ) <TAB> <TAB> <TAB> <TAB> for tmp in [ <TAB> <TAB> <TAB> t for tmp in line. split ( ""["" ) for t in tmp. split ( ""]"" ) if ""("" not in t <TAB> <TAB> ] : <TAB> <TAB> <TAB> for t in tmp. split ( "","" ) : <TAB> <TAB> <TAB> <TAB> t = t. strip ( ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> dt. add ( "" "". join ( t. split ( ) ) ) <TAB> dt = list ( dt ) <TAB> dt. sort ( ) <TAB> return dt",False,not t,t.startswith(r),0.6941788196563721
|
||
|
3401,"def get_vif_ports ( self ) : <TAB> edge_ports = [ ] <TAB> port_names = self. get_port_name_list ( ) <TAB> for name in port_names : <TAB> <TAB> external_ids = self. db_get_map ( ""Interface"", name, ""external_ids"" ) <TAB> <TAB> ofport = self. db_get_val ( ""Interface"", name, ""ofport"" ) <TAB> <TAB> if ""iface-id"" in external_ids and ""attached-mac"" in external_ids : <TAB> <TAB> <TAB> p = VifPort ( <TAB> <TAB> <TAB> <TAB> name, <TAB> <TAB> <TAB> <TAB> ofport, <TAB> <TAB> <TAB> <TAB> external_ids [ ""iface-id"" ], <TAB> <TAB> <TAB> <TAB> external_ids [ ""attached-mac"" ], <TAB> <TAB> <TAB> <TAB> self, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> edge_ports. append ( p ) <TAB> <TAB> elif ""xs-vif-uuid"" in external_ids and ""attached-mac"" in external_ids : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB><mask> : <TAB> <TAB> <TAB> p = VifPort ( name, ofport, iface_id, external_ids [ ""attached-mac"" ], self ) <TAB> <TAB> <TAB> edge_ports. append ( p ) <TAB> return edge_ports",False,iface_id = self.get_xapi_iface_id(external_ids['xs-vif-uuid']),ofport in external_ids,0.6463837623596191
|
||
|
3402,"def convertstore ( self, inputfile, duplicatestyle = ""msgctxt"" ) : <TAB> """"""Converts a.xliff file to.po format"""""" <TAB> <TAB> <TAB> <TAB> if not isinstance ( inputfile, ( file, wStringIO. StringIO ) ) : <TAB> <TAB> inputfile = str ( inputfile ) <TAB> XliffFile = xliff. xlifffile. parsestring ( inputfile ) <TAB> thetargetfile = po. pofile ( ) <TAB> targetheader = thetargetfile. header ( ) <TAB> <TAB> for transunit in XliffFile. units : <TAB> <TAB> if transunit. isheader ( ) : <TAB> <TAB> <TAB> thetargetfile. updateheader ( add = True, ** XliffFile. parseheader ( ) ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> targetheader. addnote ( <TAB> <TAB> <TAB> <TAB> <TAB> transunit. getnotes ( ""translator"" ), <TAB> <TAB> <TAB> <TAB> <TAB> origin = ""translator"", <TAB> <TAB> <TAB> <TAB> <TAB> position = ""replace"", <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if transunit. getnotes ( ""developer"" ) : <TAB> <TAB> <TAB> <TAB> targetheader. addnote ( <TAB> <TAB> <TAB> <TAB> <TAB> transunit. getnotes ( ""developer"" ), <TAB> <TAB> <TAB> <TAB> <TAB> origin = ""developer"", <TAB> <TAB> <TAB> <TAB> <TAB> position = ""replace"", <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> targetheader. markfuzzy ( transunit. isfuzzy ( ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> thepo = self. converttransunit ( transunit ) <TAB> <TAB> thetargetfile. addunit ( thepo ) <TAB> thetargetfile. removeduplicates ( duplicat",False,transunit.getnotes('translator'),tweakat == 'msgctxt',0.6482422947883606
|
||
|
3403,"def test_cleanup_params ( self, body, rpc_mock ) : <TAB> res = self. _get_resp_post ( body ) <TAB> self. assertEqual ( http_client. ACCEPTED, res. status_code ) <TAB> rpc_mock. assert_called_once_with ( self. context, mock. ANY ) <TAB> cleanup_request = rpc_mock. call_args [ 0 ] [ 1 ] <TAB> for key, value in body. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if value is not None : <TAB> <TAB> <TAB> <TAB> value = value == ""true"" <TAB> <TAB> self. assertEqual ( value, getattr ( cleanup_request, key ) ) <TAB> self. assertEqual ( self. _expected_services ( * SERVICES ), res. json )",False,"key in ('disabled', 'is_up')",key in cleanup_request,0.6485511660575867
|
||
|
3404,"def readNextEndLine ( self, stream ) : <TAB> debug = False <TAB> if debug : <TAB> <TAB> print ( "">>readNextEndLine"" ) <TAB> line = b_ ( """" ) <TAB> while True : <TAB> <TAB> <TAB> <TAB> if stream. tell ( ) == 0 : <TAB> <TAB> <TAB> raise utils. PdfReadError ( ""Could not read malformed PDF file"" ) <TAB> <TAB> x = stream. read ( 1 ) <TAB> <TAB> if debug : <TAB> <TAB> <TAB> print ( ( "" x:"", x, ""%x"" % ord ( x ) ) ) <TAB> <TAB> if stream. tell ( ) < 2 : <TAB> <TAB> <TAB> raise utils. PdfReadError ( ""EOL marker not found"" ) <TAB> <TAB> stream. seek ( - 2, 1 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> crlf = False <TAB> <TAB> <TAB> while x == b_ ( ""\n"" ) or x == b_ ( ""\r"" ) : <TAB> <TAB> <TAB> <TAB> if debug : <TAB> <TAB> <TAB> <TAB> <TAB> if ord ( x ) == 0x0D : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> print ( "" x is CR 0D"" ) <TAB> <TAB> <TAB> <TAB> <TAB> elif ord ( x ) == 0x0A : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> print ( "" x is LF 0A"" ) <TAB> <TAB> <TAB> <TAB> x = stream. read ( 1 ) <TAB> <TAB> <TAB> <TAB> if x == b_ ( ""\n"" ) or x == b_ ( ""\r"" ) : <TAB> <TAB> <TAB> <TAB> <TAB> stream. seek ( - 1, 1 ) <TAB> <TAB> <TAB> <TAB> <TAB> crlf = True <TAB> <TAB> <TAB> <TAB> if stream. tell ( ) < 2 : <TAB> <TAB> <TAB> <",False,x == b_('\n') or x == b_('\r'),debug,0.6482366323471069
|
||
|
3405,def __del__ ( self ) : <TAB> if self. _auto_created_session : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> asyncio. get_event_loop ( ). run_until_complete ( self. _session. close ( ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. _session. close ( ),False,asyncio.iscoroutinefunction(self._session.close),"isinstance(self._session, asyncio.futures.Future)",0.6519491672515869
|
||
|
3406,"def visit_Options ( self, node : qlast. Options ) -> None : <TAB> for i, opt in enumerate ( node. options. values ( ) ) : <TAB> <TAB> if i > 0 : <TAB> <TAB> <TAB> self. write ( "" "" ) <TAB> <TAB> self. write ( opt. name ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. write ( f"" {opt.val}"" )",False,"not isinstance(opt, qlast.Flag)",i > 0,0.6531748175621033
|
||
|
3407,"def p ( node_cur, depth ) : <TAB> for k in node_cur : <TAB> <TAB> k2 = str ( k ). replace ( '""', '\\""' ) <TAB> <TAB> spc = "" "" * depth <TAB> <TAB> if k == ""__rulesets"" : <TAB> <TAB> <TAB> print ( f'{spc}""{k2}"":[""... ({len(node_cur[k])})""],' ) <TAB> <TAB> elif k == ""__selectors"" : <TAB> <TAB> <TAB> v = str ( node_cur [ k ] ). replace ( '""', '\\""' ) <TAB> <TAB> <TAB> print ( f'{spc}""{k2}"":""{v}"",' ) <TAB> <TAB> elif k == ""__parent"" : <TAB> <TAB> <TAB> pass <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> pass <TAB> <TAB> else : <TAB> <TAB> <TAB> print ( f'{spc}""{k2}"":{{' ) <TAB> <TAB> <TAB> p ( node_cur [ k ], depth + 1 ) <TAB> <TAB> <TAB> print ( f""{spc}}},"" )",False,k == '__uid',k == '__chain',0.6686413288116455
|
||
|
3408,"def perform ( self, node, inp, out ) : <TAB> indices, dims = inp <TAB> res = np. unravel_index ( indices, dims ) <TAB> assert len ( res ) == len ( out ) <TAB> for i in xrange ( len ( out ) ) : <TAB> <TAB> ret = theano. _asarray ( res [ i ], node. outputs [ 0 ]. dtype ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ret = ret. copy ( ) <TAB> <TAB> out [ i ] [ 0 ] = ret",False,ret.base is not None,ret is not None,0.6562170386314392
|
||
|
3409,"def recv_some ( p, t = 0.1, e = 1, tr = 5, stderr = 0 ) : <TAB> if tr < 1 : <TAB> <TAB> tr = 1 <TAB> x = time. time ( ) + t <TAB> y = [ ] <TAB> r = """" <TAB> if stderr : <TAB> <TAB> pr = p. recv_err <TAB> else : <TAB> <TAB> pr = p. recv <TAB> while time. time ( ) < x or r : <TAB> <TAB> r = pr ( ) <TAB> <TAB> if r is None : <TAB> <TAB> <TAB> break <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> y. append ( r ) <TAB> <TAB> else : <TAB> <TAB> <TAB> time. sleep ( max ( ( x - time. time ( ) ) / tr, 0 ) ) <TAB> return b"""". join ( y )",False,r,e > r,0.6912168264389038
|
||
|
3410,"def _resolve_header ( self, info, definitions, parts ) : <TAB> name = etree. QName ( self. nsmap [ ""soap-env"" ], ""Header"" ) <TAB> container = xsd. All ( consume_other = True ) <TAB> if not info : <TAB> <TAB> return xsd. Element ( name, xsd. ComplexType ( container ) ) <TAB> for item in info : <TAB> <TAB> message_name = item [ ""message"" ]. text <TAB> <TAB> part_name = item [ ""part"" ] <TAB> <TAB> message = definitions. get ( ""messages"", message_name ) <TAB> <TAB> if message == self. abstract and part_name in parts : <TAB> <TAB> <TAB> del parts [ part_name ] <TAB> <TAB> part = message. parts [ part_name ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> element = part. element. clone ( ) <TAB> <TAB> <TAB> element. attr_name = part_name <TAB> <TAB> else : <TAB> <TAB> <TAB> element = xsd. Element ( part_name, part. type ) <TAB> <TAB> container. append ( element ) <TAB> return xsd. Element ( name, xsd. ComplexType ( container ) )",True,part.element,part.element,0.6580848693847656
|
||
|
3411,"def transform_import ( builder : IRBuilder, node : Import ) -> None : <TAB> if node. is_mypy_only : <TAB> <TAB> return <TAB> globals = builder. load_globals_dict ( ) <TAB> for node_id, as_name in node. ids : <TAB> <TAB> builder. gen_import ( node_id, node. line ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> name = as_name <TAB> <TAB> <TAB> base = node_id <TAB> <TAB> else : <TAB> <TAB> <TAB> base = name = node_id. split ( ""."" ) [ 0 ] <TAB> <TAB> <TAB> <TAB> mod_dict = builder. call_c ( get_module_dict_op, [ ], node. line ) <TAB> <TAB> <TAB> <TAB> obj = builder. call_c ( <TAB> <TAB> <TAB> dict_get_item_op, [ mod_dict, builder. load_static_unicode ( base ) ], node. line <TAB> <TAB> ) <TAB> <TAB> builder. gen_method_call ( <TAB> <TAB> <TAB> globals, <TAB> <TAB> <TAB> ""__setitem__"", <TAB> <TAB> <TAB> [ builder. load_static_unicode ( name ), obj ], <TAB> <TAB> <TAB> result_type = None, <TAB> <TAB> <TAB> line = node. line, <TAB> <TAB> )",True,as_name,as_name,0.6701652407646179
|
||
|
3412,"def poll ( self, timeout ) : <TAB> if timeout < 0 : <TAB> <TAB> timeout = None <TAB> events = self. _kqueue. control ( None, KqueueLoop. MAX_EVENTS, timeout ) <TAB> results = defaultdict ( lambda : POLL_NULL ) <TAB> for e in events : <TAB> <TAB> fd = e. ident <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> results [ fd ] |= POLL_IN <TAB> <TAB> elif e. filter == select. KQ_FILTER_WRITE : <TAB> <TAB> <TAB> results [ fd ] |= POLL_OUT <TAB> return results. items ( )",True,e.filter == select.KQ_FILTER_READ,e.filter == select.KQ_FILTER_READ,0.6578371524810791
|
||
|
3413,"def do_put ( self, s ) : <TAB> try : <TAB> <TAB> params = s. split ( "" "" ) <TAB> <TAB> if len ( params ) > 1 : <TAB> <TAB> <TAB> src_path = params [ 0 ] <TAB> <TAB> <TAB> dst_path = params [ 1 ] <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> src_path = params [ 0 ] <TAB> <TAB> <TAB> dst_path = """" <TAB> <TAB> src_file = os. path. basename ( src_path ) <TAB> <TAB> fh = open ( src_path, ""rb"" ) <TAB> <TAB> dst_path = string. replace ( dst_path, ""/"", ""\\"" ) <TAB> <TAB> pathname = ntpath. join ( ntpath. join ( self. __pwd, dst_path ), src_file ) <TAB> <TAB> drive, tail = ntpath. splitdrive ( pathname ) <TAB> <TAB> logging. info ( ""Uploading %s to %s"" % ( src_file, pathname ) ) <TAB> <TAB> self. __transferClient. putFile ( drive [ : - 1 ] + ""$"", tail, fh. read ) <TAB> <TAB> fh. close ( ) <TAB> except Exception as e : <TAB> <TAB> logging. critical ( str ( e ) ) <TAB> <TAB> pass",False,len(params) == 1,len(params) > 0,0.6605364084243774
|
||
|
3414,"def update_vars ( state1, state2 ) : <TAB> ops = [ ] <TAB> for name in state1. _fields : <TAB> <TAB> state1_vs = getattr ( state1, name ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> ops += [ <TAB> <TAB> <TAB> <TAB> tf. assign ( _v1, _v2 ) <TAB> <TAB> <TAB> <TAB> for _v1, _v2 in zip ( state1_vs, getattr ( state2, name ) ) <TAB> <TAB> <TAB> ] <TAB> <TAB> else : <TAB> <TAB> <TAB> ops += [ tf. assign ( state1_vs, getattr ( state2, name ) ) ] <TAB> return tf. group ( * ops )",False,"isinstance(state1_vs, list)","isinstance(state1_vs, dict)",0.6493253707885742
|
||
|
3415,"def derive ( self, key_material ) : <TAB> if self. _used : <TAB> <TAB> raise AlreadyFinalized <TAB> utils. _check_byteslike ( ""key_material"", key_material ) <TAB> self. _used = True <TAB> <TAB> rounds = - ( - self. _length // self. _algorithm. digest_size ) <TAB> output = [ b"""" ] <TAB> <TAB> <TAB> <TAB> <TAB> r_bin = utils. int_to_bytes ( 1, self. _rlen ) <TAB> if rounds > pow ( 2, len ( r_bin ) * 8 ) - 1 : <TAB> <TAB> raise ValueError ( ""There are too many iterations."" ) <TAB> for i in range ( 1, rounds + 1 ) : <TAB> <TAB> h = hmac. HMAC ( key_material, self. _algorithm, backend = self. _backend ) <TAB> <TAB> counter = utils. int_to_bytes ( i, self. _rlen ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> h. update ( counter ) <TAB> <TAB> h. update ( self. _generate_fixed_input ( ) ) <TAB> <TAB> if self. _location == CounterLocation. AfterFixed : <TAB> <TAB> <TAB> h. update ( counter ) <TAB> <TAB> output. append ( h. finalize ( ) ) <TAB> return b"""". join ( output ) [ : self. _length ]",False,self._location == CounterLocation.BeforeFixed,self._location == CounterLocation.New,0.6579575538635254
|
||
|
3416,"def will_evm_execute_instruction_callback ( self, state, instruction, arguments ) : <TAB> world = state. platform <TAB> mnemonic = instruction. semantics <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if mnemonic == ""DELEGATECALL"" : <TAB> <TAB> gas, address, in_offset, in_size, out_offset, out_size = arguments <TAB> <TAB> if issymbolic ( address ) : <TAB> <TAB> <TAB> possible_addresses = state. solve_n ( address, 2 ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. add_finding_here ( state, ""Delegatecall to user controlled address"" ) <TAB> <TAB> in_offset = self. _to_constant ( in_offset ) <TAB> <TAB> in_size = self. _to_constant ( in_size ) <TAB> <TAB> calldata = world. current_vm. read_buffer ( in_offset, in_size ) <TAB> <TAB> func_id = calldata [ : 4 ] <TAB> <TAB> if issymbolic ( func_id ) : <TAB> <TAB> <TAB> possible_func_ids = state. solve_n ( func_id, 2 ) <TAB> <TAB> <TAB> if len ( possible_func_ids ) > 1 : <TAB> <TAB> <TAB> <TAB> self. add_finding_here ( state, ""Delegatecall to user controlled function"" )",True,len(possible_addresses) > 1,len(possible_addresses) > 1,0.6517108678817749
|
||
|
3417,"def eval ( self, mgr ) : <TAB> self. ctlr. set_desc ( ""subimports of '%s'"" % self. prefix ) <TAB> cwd = dirname ( self. buf. path ) <TAB> <TAB> <TAB> subimports = self. import_handler. findSubImportsOnDisk ( self. prefix, cwd ) <TAB> if subimports : <TAB> <TAB> cplns = [ ] <TAB> <TAB> for subimport in subimports : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> cplns. append ( ( ""directory"", subimport [ : - 1 ] ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> cplns. append ( ( ""module"", subimport ) ) <TAB> <TAB> cplns. sort ( key = lambda c : c [ 1 ]. upper ( ) ) <TAB> <TAB> self. ctlr. set_cplns ( cplns ) <TAB> self. ctlr. done ( ""success"" )",False,subimport[-1] == '/',subimport.endswith('/'),0.6638584136962891
|
||
|
3418,"def generate_extensions ( self, extensions, enums, functions ) : <TAB> f = self. _f_gl <TAB> write = set ( ) <TAB> written = set ( enum. name for enum in enums ) | set ( <TAB> <TAB> function. proto. name for function in functions <TAB> ) <TAB> f. write ( ""# Extensions\n"" ) <TAB> if extensions : <TAB> <TAB> f. write ( ""var\n"" ) <TAB> for ext in extensions : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. write_boolean ( f, ext. name ) <TAB> <TAB> for enum in ext. enums : <TAB> <TAB> <TAB> if not enum. name in written and not enum. group == ""SpecialNumbers"" : <TAB> <TAB> <TAB> <TAB> type = None if enum. group == ""TransformFeedbackTokenNV"" else ""GLenum"" <TAB> <TAB> <TAB> <TAB> self. write_enum ( f, enum. name, enum. value, type ) <TAB> <TAB> <TAB> written. add ( enum. name ) <TAB> <TAB> written. add ( ext. name ) <TAB> <TAB> f. write ( ""\n"" ) <TAB> self. write_functions ( f, write, written, extensions ) <TAB> f. write ( ""\n\n"" )",False,self.spec.NAME == 'gl' and (not ext.name in written),ext.enums,0.6515089273452759
|
||
|
3419,"def load_redis_dict ( self, obj ) : <TAB> new_dict = { } <TAB> redis_type = obj. get ( ""__redis_type"" ) <TAB> exp = None <TAB> for key, value in obj. items ( ) : <TAB> <TAB> if key == ""__redis_type"" : <TAB> <TAB> <TAB> continue <TAB> <TAB> key = key. encode ( ""utf-8"" ) <TAB> <TAB> if redis_type == ""exp"" and isinstance ( value, list ) : <TAB> <TAB> <TAB> if isinstance ( value [ 1 ], int ) : <TAB> <TAB> <TAB> <TAB> exp = datetime. utcfromtimestamp ( value [ 1 ] ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> exp = None <TAB> <TAB> <TAB> value = value [ 0 ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> value = value. encode ( ""utf-8"" ) <TAB> <TAB> elif isinstance ( value, list ) : <TAB> <TAB> <TAB> value = self. load_redis_set ( value ) <TAB> <TAB> elif isinstance ( value, dict ) : <TAB> <TAB> <TAB> value = self. load_redis_dict ( value ) <TAB> <TAB> if redis_type == ""exp"" : <TAB> <TAB> <TAB> new_dict [ key ] = ( value, exp ) <TAB> <TAB> else : <TAB> <TAB> <TAB> new_dict [ key ] = value <TAB> if redis_type == ""zset"" : <TAB> <TAB> redis_dict = _ZSet ( ) <TAB> elif redis_type == ""hash"" : <TAB> <TAB> redis_dict = _Hash ( ) <TAB> elif redis_type == ""exp"" : <TAB> <TAB> redis_dict = _ExpiringDict ( ) <TAB> else : <TAB> <TAB> raise Exception ( ""Invalid redis_dict: "" + str ( redis_type ) ) <TAB> redis_dict. _dict = new_dict <TAB> return redis_dict",True,"isinstance(value, str)","isinstance(value, str)",0.6487959623336792
|
||
|
3420,"def _computeSimilarityMatrix ( self, symbols ) : <TAB> if symbols is None : <TAB> <TAB> raise TypeError ( ""Symbols cannot be None"" ) <TAB> for symbol in symbols : <TAB> <TAB> if not isinstance ( symbol, Symbol ) : <TAB> <TAB> <TAB> raise TypeError ( ""At least one specified symbol is not a valid symbol"" ) <TAB> <TAB> debug = False <TAB> wrapper = WrapperArgsFactory ( ""_libScoreComputation.computeSimilarityMatrix"" ) <TAB> wrapper. typeList [ wrapper. function ] ( symbols ) <TAB> self. _logger. debug ( ""wrapper = {0}"". format ( wrapper ) ) <TAB> ( listScores ) = _libScoreComputation. computeSimilarityMatrix ( <TAB> <TAB> self. internalSlick, self. _cb_executionStatus, self. _isFinish, debug, wrapper <TAB> ) <TAB> <TAB> scores = OrderedDict ( ) <TAB> for ( iuid, juid, score ) in listScores : <TAB> <TAB> if iuid not in list ( scores. keys ( ) ) : <TAB> <TAB> <TAB> scores [ iuid ] = OrderedDict ( ) <TAB> <TAB> if juid not in list ( scores. keys ( ) ) : <TAB> <TAB> <TAB> scores [ juid ] = OrderedDict ( ) <TAB> <TAB> scores [ iuid ] [ juid ] = score <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> scores [ juid ] [ iuid ] = score <TAB> return scores",False,iuid not in list(scores[juid].keys()),juid not in list(scores.keys()),0.6530716419219971
|
||
|
3421,"def new_gwplus_fevent ( self, line ) : <TAB> source = place = note = type = None <TAB> date = self. parse_date ( self. decode ( line [ 6 : ] ) ) <TAB> idx = 0 <TAB> LOG. info ( ( line, fevents_map. get ( line [ 0 : 5 ] ) ) ) <TAB> type = fevents_map. get ( line [ 0 : 5 ] ) <TAB> data = line. split ( ) <TAB> date = self. parse_date ( self. decode ( line [ 6 : ] ) ) <TAB> for part in data : <TAB> <TAB> idx += 1 <TAB> <TAB> if part == ""#p"" : <TAB> <TAB> <TAB> place = self. get_or_create_place ( self. decode ( data [ idx ] ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> source = self. get_or_create_source ( self. decode ( data [ idx ] ) ) <TAB> self. current_event = self. create_event ( type, None, None, None, None ) <TAB> print ( ""new event"", self. current_event. handle ) <TAB> if date : <TAB> <TAB> print ( date ) <TAB> <TAB> self. current_event. set_date_object ( date ) <TAB> if place : <TAB> <TAB> print ( ""place"", place. handle ) <TAB> <TAB> self. current_event. set_place_handle ( place. get_handle ( ) ) <TAB> if source : <TAB> <TAB> print ( ""source"", source. handle ) <TAB> <TAB> self. current_event. add_citation ( source. get_handle ( ) ) <TAB> self. db. commit_event ( self. current_event, self. trans ) <TAB> nev_ref = EventRef ( ) <TAB> nev_ref. set_reference_handle ( self. current_event. get_handle ( ) ) <TAB> self. current_family. add_event_ref ( nev_ref ) <TAB> self. db. commit_family ( self. current_family, self. trans ) <TAB",False,part == '#s',note,0.6571345329284668
|
||
|
3422,"def main_loop ( self, stdout : typing. Any ) -> None : <TAB> while True : <TAB> <TAB> feed = sys. stdin. buffer. raw. read ( 102400 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> if feed == b"""" : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> self. _unpacker. feed ( feed ) <TAB> <TAB> for child_in in self. _unpacker : <TAB> <TAB> <TAB> name = child_in [ ""name"" ] <TAB> <TAB> <TAB> args = child_in [ ""args"" ] <TAB> <TAB> <TAB> queue_id = child_in [ ""queue_id"" ] <TAB> <TAB> <TAB> ret = self. main ( name, args, queue_id ) <TAB> <TAB> <TAB> if ret : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> print ( ret ) <TAB> <TAB> <TAB> <TAB> self. _vim. vars [ ""denite#_ret"" ] = ret",False,feed is None,feed == b'',0.6745461225509644
|
||
|
3423,"def _handle_redirects ( self, response, ** extra ) : <TAB> ""Follows any redirects by requesting responses from the server using GET."" <TAB> response. redirect_chain = [ ] <TAB> while response. status_code in ( 301, 302, 303, 307 ) : <TAB> <TAB> response_url = response. url <TAB> <TAB> redirect_chain = response. redirect_chain <TAB> <TAB> redirect_chain. append ( ( response_url, response. status_code ) ) <TAB> <TAB> url = urlsplit ( response_url ) <TAB> <TAB> if url. scheme : <TAB> <TAB> <TAB> extra [ ""wsgi.url_scheme"" ] = url. scheme <TAB> <TAB> if url. hostname : <TAB> <TAB> <TAB> extra [ ""SERVER_NAME"" ] = url. hostname <TAB> <TAB> if url. port : <TAB> <TAB> <TAB> extra [ ""SERVER_PORT"" ] = str ( url. port ) <TAB> <TAB> <TAB> <TAB> path = url. path <TAB> <TAB> if not path. startswith ( ""/"" ) : <TAB> <TAB> <TAB> path = urljoin ( response. request [ ""PATH_INFO"" ], path ) <TAB> <TAB> response = self. get ( path, QueryDict ( url. query ), follow = False, ** extra ) <TAB> <TAB> response. redirect_chain = redirect_chain <TAB> <TAB> if redirect_chain [ - 1 ] in redirect_chain [ : - 1 ] : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> raise RedirectCycleError ( ""Redirect loop detected."", last_response = response ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> raise RedirectCycleError ( ""Too many redirects."", last_response = response ) <TAB> return response",False,len(redirect_chain) > 20,redirect_chain and last_response != response,0.6565049886703491
|
||
|
3424,"def parse_calendar_eras ( data, calendar ) : <TAB> eras = data. setdefault ( ""eras"", { } ) <TAB> for width in calendar. findall ( ""eras/*"" ) : <TAB> <TAB> width_type = NAME_MAP [ width. tag ] <TAB> <TAB> widths = eras. setdefault ( width_type, { } ) <TAB> <TAB> for elem in width. getiterator ( ) : <TAB> <TAB> <TAB> if elem. tag == ""era"" : <TAB> <TAB> <TAB> <TAB> _import_type_text ( widths, elem, type = int ( elem. attrib. get ( ""type"" ) ) ) <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> eras [ width_type ] = Alias ( <TAB> <TAB> <TAB> <TAB> <TAB> _translate_alias ( [ ""eras"", width_type ], elem. attrib [ ""path"" ] ) <TAB> <TAB> <TAB> <TAB> )",True,elem.tag == 'alias',elem.tag == 'alias',0.6582809686660767
|
||
|
3425,def _refresh ( self ) : <TAB> if not self. refresh_needed ( self. _advisory_refresh_timeout ) : <TAB> <TAB> return <TAB> <TAB> if not self. _refresh_lock. locked ( ) : <TAB> <TAB> async with self. _refresh_lock : <TAB> <TAB> <TAB> if not self. refresh_needed ( self. _advisory_refresh_timeout ) : <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> is_mandatory_refresh = self. refresh_needed ( self. _mandatory_refresh_timeout ) <TAB> <TAB> <TAB> await self. _protected_refresh ( is_mandatory = is_mandatory_refresh ) <TAB> <TAB> <TAB> return <TAB> elif self. refresh_needed ( self. _mandatory_refresh_timeout ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> async with self. _refresh_lock : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> await self. _protected_refresh ( is_mandatory = True ),False,not self.refresh_needed(self._mandatory_refresh_timeout),self.is_mandatory_refresh,0.6511876583099365
|
||
|
3426,"def display ( self, add_comments = False ) : <TAB> """"""Display options in a config file form."""""" <TAB> output = StringIO ( ) <TAB> keys = self. _options. keys ( ) <TAB> keys. sort ( ) <TAB> currentSection = None <TAB> for sect, opt in keys : <TAB> <TAB> if sect!= currentSection : <TAB> <TAB> <TAB> if currentSection is not None : <TAB> <TAB> <TAB> <TAB> output. write ( ""\n"" ) <TAB> <TAB> <TAB> output. write ( ""["" ) <TAB> <TAB> <TAB> output. write ( sect ) <TAB> <TAB> <TAB> output. write ( ""]\n"" ) <TAB> <TAB> <TAB> currentSection = sect <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> doc = self. _options [ sect, opt ]. doc ( ) <TAB> <TAB> <TAB> if not doc : <TAB> <TAB> <TAB> <TAB> doc = ""No information available, sorry."" <TAB> <TAB> <TAB> doc = re. sub ( r""\s+"", "" "", doc ) <TAB> <TAB> <TAB> output. write ( ""\n# %s\n"" % ( ""\n# "". join ( wrap ( doc ) ), ) ) <TAB> <TAB> self. _options [ sect, opt ]. write_config ( output ) <TAB> return output. getvalue ( )",True,add_comments,add_comments,0.672941267490387
|
||
|
3427,"def load_module ( self, name ) : <TAB> module = self. _modules [ name ] <TAB> sys. modules [ name ] = module <TAB> with self. _stack_meter as depth : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> dprint ( ""reloading"", ( ""| "" * depth ) + ""|--"", name ) <TAB> <TAB> try : <TAB> <TAB> <TAB> return module. __loader__. load_module ( name ) <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> if name in sys. modules : <TAB> <TAB> <TAB> <TAB> del sys. modules [ name ] <TAB> <TAB> <TAB> raise",False,self._verbose,depth > 0,0.6751217246055603
|
||
|
3428,"def _load_dataset_parts ( cls, stream, stream_description ) : <TAB> from snips_nlu. dataset. yaml_wrapper import yaml <TAB> intents = [ ] <TAB> entities = [ ] <TAB> for doc in yaml. safe_load_all ( stream ) : <TAB> <TAB> doc_type = doc. get ( ""type"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> entities. append ( Entity. from_yaml ( doc ) ) <TAB> <TAB> elif doc_type == ""intent"" : <TAB> <TAB> <TAB> intents. append ( Intent. from_yaml ( doc ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise DatasetFormatError ( <TAB> <TAB> <TAB> <TAB> ""Invalid 'type' value in YAML file '%s': '%s'"" <TAB> <TAB> <TAB> <TAB> % ( stream_description, doc_type ) <TAB> <TAB> <TAB> ) <TAB> return intents, entities",True,doc_type == 'entity',doc_type == 'entity',0.6603301763534546
|
||
|
3429,"def never ( self, cmd, ident = None ) : <TAB> """"""Stops calling cmd on repeat"""""" <TAB> attr, method = self. get_attr_and_method_name ( cmd ) <TAB> if ident is not None : <TAB> <TAB> cmd = ""{}-{}"". format ( cmd, ident ) <TAB> try : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. previous_patterns [ attr ]. remove ( method ) <TAB> <TAB> <TAB> self. update_pattern_methods ( attr ) <TAB> <TAB> self. repeat_events [ cmd ]. stop ( ) <TAB> <TAB> del self. repeat_events [ cmd ] <TAB> except KeyError : <TAB> <TAB> err = ""Player method '{}' not active"". format ( cmd ) <TAB> <TAB> raise KeyError ( err ) <TAB> return self",False,method in self.previous_patterns[attr],method in self.previous_patterns,0.6531863212585449
|
||
|
3430,"def _set_property ( self, target_widget, pname, value ) : <TAB> if pname == ""text"" : <TAB> <TAB> state = target_widget. cget ( ""state"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> target_widget. configure ( state = tk. NORMAL ) <TAB> <TAB> <TAB> target_widget. insert ( ""0.0"", value ) <TAB> <TAB> <TAB> target_widget. configure ( state = tk. DISABLED ) <TAB> <TAB> else : <TAB> <TAB> <TAB> target_widget. insert ( ""0.0"", value ) <TAB> else : <TAB> <TAB> super ( TKText, self ). _set_property ( target_widget, pname, value )",False,state == tk.DISABLED,state == tk.NORMAL,0.6794330477714539
|
||
|
3431,"def _checkJVMArch ( jvmPath, maxsize = sys. maxsize ) : <TAB> import struct <TAB> IMAGE_FILE_MACHINE_I386 = 332 <TAB> IMAGE_FILE_MACHINE_IA64 = 512 <TAB> IMAGE_FILE_MACHINE_AMD64 = 34404 <TAB> is64 = maxsize > 2 ** 32 <TAB> with open ( jvmPath, ""rb"" ) as f : <TAB> <TAB> s = f. read ( 2 ) <TAB> <TAB> if s!= b""MZ"" : <TAB> <TAB> <TAB> raise JVMNotSupportedException ( ""JVM not valid"" ) <TAB> <TAB> f. seek ( 60 ) <TAB> <TAB> s = f. read ( 4 ) <TAB> <TAB> header_offset = struct. unpack ( ""<L"", s ) [ 0 ] <TAB> <TAB> f. seek ( header_offset + 4 ) <TAB> <TAB> s = f. read ( 2 ) <TAB> <TAB> machine = struct. unpack ( ""<H"", s ) [ 0 ] <TAB> if machine == IMAGE_FILE_MACHINE_I386 : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise JVMNotSupportedException ( <TAB> <TAB> <TAB> <TAB> ""JVM mismatch, python is 64 bit and JVM is 32 bit."" <TAB> <TAB> <TAB> ) <TAB> elif machine == IMAGE_FILE_MACHINE_IA64 or machine == IMAGE_FILE_MACHINE_AMD64 : <TAB> <TAB> if not is64 : <TAB> <TAB> <TAB> raise JVMNotSupportedException ( <TAB> <TAB> <TAB> <TAB> ""JVM mismatch, python is 32 bit and JVM is 64 bit."" <TAB> <TAB> <TAB> ) <TAB> else : <TAB> <TAB> raise JVMNotSupportedException ( ""Unable to determine JVM Type"" )",False,is64,not is64,0.6750110387802124
|
||
|
3432,"def startElement ( self, name, attrs, connection ) : <TAB> if name == ""Parameter"" : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self [ self. _current_param. name ] = self. _current_param <TAB> <TAB> self. _current_param = Parameter ( self ) <TAB> <TAB> return self. _current_param",True,self._current_param,self._current_param,0.6663903594017029
|
||
|
3433,"def update_vt_result ( ) : <TAB> hash = request. args. get ( ""hash"" ) <TAB> params = { ""apikey"" : vt_auth, ""resource"" : hash } <TAB> response = requests. get ( <TAB> <TAB> ""https://www.virustotal.com/vtapi/v2/file/report"", params = params <TAB> ) <TAB> if response. status_code == 200 : <TAB> <TAB> json_response = response. json ( ) <TAB> <TAB> response_code = json_response [ ""response_code"" ] <TAB> <TAB> <TAB> <TAB> if response_code == 1 : <TAB> <TAB> <TAB> total = json_response [ ""total"" ] <TAB> <TAB> <TAB> positive = json_response [ ""positives"" ] <TAB> <TAB> <TAB> b64_vt_report = ""Detection {}/{}"". format ( positive, total ) <TAB> <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> b64_vt_report = ""No report found"" <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> <TAB> elif response_code == - 2 : <TAB> <TAB> <TAB> b64_vt_report = ""File in queue"" <TAB> <TAB> <TAB> pass <TAB> <TAB> r_serv_metadata. hset ( ""metadata_hash:"" + hash, ""vt_report"", b64_vt_report ) <TAB> <TAB> return jsonify ( hash = hash, report_vt = b64_vt_report ) <TAB> elif response. status_code == 403 : <TAB> <TAB> Flask_config. vt_enabled = False <TAB> <TAB> print ( <TAB> <TAB> <TAB> ""Virustotal key is incorrect (e.g. for public API not for virustotal intelligence), authentication failed or reaching limits."" <TAB> <TAB> ) <TAB> <TAB> return jsonify ( ) <TAB> else : <TAB> <TAB> <TAB> <TAB> return jsonify ( )",False,response_code == 0,response_code == -1,0.6617404818534851
|
||
|
3434,"def _related ( self ) : <TAB> if self. __related is None : <TAB> <TAB> if not ( self. lemma ( ) and self. pos ( ) and self. morpho ( ) ) : <TAB> <TAB> <TAB> results = requests. get ( <TAB> <TAB> <TAB> <TAB> f""{self._wordnet_corpus_reader.host()}/api/uri/{self.uri()}/relations/?format=json"", <TAB> <TAB> <TAB> <TAB> timeout = ( 30.0, 90.0 ), <TAB> <TAB> <TAB> ). json ( ) [ ""results"" ] <TAB> <TAB> else : <TAB> <TAB> <TAB> results = requests. get ( <TAB> <TAB> <TAB> <TAB> f""{self._wordnet_corpus_reader.host()}/api/lemmas/{self.lemma()}/{self.pos() if self.pos() else '*'}"" <TAB> <TAB> <TAB> <TAB> f""/{self.morpho() if self.morpho() else '*'}/relations/?format=json"", <TAB> <TAB> <TAB> <TAB> timeout = ( 30.0, 90.0 ), <TAB> <TAB> <TAB> ). json ( ) [ ""results"" ] <TAB> <TAB> if len ( results ) > 1 : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> ambiguous = [ <TAB> <TAB> <TAB> <TAB> <TAB> f""{result['lemma']['lemma']} ({result['lemma']['morpho']})"" <TAB> <TAB> <TAB> <TAB> <TAB> for result in results <TAB> <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> <TAB> raise WordNetError ( f""can't disambiguate {', '.join(ambiguous)}"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. __related = results [ 0 ] [ ""relations"" ] <TAB> return self. __related",False,not self._wordnet_corpus_reader._ignore_errors,self.timeout > 0,0.6556061506271362
|
||
|
3435,"def ostree_repo ( ) : <TAB> check_prerequesite [ ""ostree-repo"" ] = True <TAB> if not check_prerequesite [ ""start-docker"" ] : <TAB> <TAB> CheckTools. start_docker ( ) <TAB> if constants. currentArch == ""x86_64"" : <TAB> <TAB> ph_docker_image = ""vmware/photon-build:rpm-ostree-3.0"" <TAB> else : <TAB> <TAB> ph_docker_image = ""vmware/photon-build:rpm-ostree-aarch64-3.0"" <TAB> if not os. path. isfile ( os. path. join ( Build_Config. stagePath, ""ostree-repo.tar.gz"" ) ) : <TAB> <TAB> process = subprocess. Popen ( <TAB> <TAB> <TAB> [ <TAB> <TAB> <TAB> <TAB> curDir + ""/support/image-builder/ostree-tools/make-ostree-image.sh"", <TAB> <TAB> <TAB> <TAB> curDir, <TAB> <TAB> <TAB> <TAB> Build_Config. stagePath, <TAB> <TAB> <TAB> <TAB> ph_docker_image, <TAB> <TAB> <TAB> ] <TAB> <TAB> ) <TAB> <TAB> retval = process. wait ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> print ( ""Not able to execute make-ostree-image.sh"" ) <TAB> else : <TAB> <TAB> print ( ""Creating OSTree repo from local RPMs in ostree-repo.tar.gz..."" )",True,retval != 0,retval != 0,0.6737914085388184
|
||
|
3436,"def validate_login_form ( self ) : <TAB> form = self. get_login_form ( bind_data = True ) <TAB> if form. is_valid ( ) : <TAB> <TAB> user = form. get_user ( ) <TAB> <TAB> <TAB> <TAB> old_session_key = self. request. session. session_key <TAB> <TAB> auth_login ( self. request, form. get_user ( ) ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> signals. user_logged_in. send_robust ( <TAB> <TAB> <TAB> sender = self, <TAB> <TAB> <TAB> request = self. request, <TAB> <TAB> <TAB> user = user, <TAB> <TAB> <TAB> old_session_key = old_session_key, <TAB> <TAB> ) <TAB> <TAB> msg = self. get_login_success_message ( form ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> messages. success ( self. request, msg ) <TAB> <TAB> return redirect ( self. get_login_success_url ( form ) ) <TAB> ctx = self. get_context_data ( login_form = form ) <TAB> return self. render_to_response ( ctx )",True,msg,msg,0.6933943033218384
|
||
|
3437,"def set_plugin ( self, plugin ) : <TAB> label = self. desc <TAB> if plugin is None : <TAB> <TAB> label. set_markup ( """" ) <TAB> else : <TAB> <TAB> name = util. escape ( plugin. name ) <TAB> <TAB> text = ""<big><b>%s</b></big>"" % name <TAB> <TAB> if plugin. description : <TAB> <TAB> <TAB> text += ""<span font='4'>\n\n</span>"" <TAB> <TAB> <TAB> text += plugin. description <TAB> <TAB> label. set_markup ( text ) <TAB> <TAB> label. connect ( ""activate-link"", show_uri ) <TAB> frame = self. prefs <TAB> if frame. get_child ( ) : <TAB> <TAB> frame. get_child ( ). destroy ( ) <TAB> if plugin is not None : <TAB> <TAB> instance_or_cls = plugin. get_instance ( ) or plugin. cls <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> prefs = instance_or_cls. PluginPreferences ( self ) <TAB> <TAB> <TAB> except : <TAB> <TAB> <TAB> <TAB> util. print_exc ( ) <TAB> <TAB> <TAB> <TAB> frame. hide ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> if isinstance ( prefs, Gtk. Window ) : <TAB> <TAB> <TAB> <TAB> <TAB> b = Button ( _ ( ""_Preferences"" ), Icons. PREFERENCES_SYSTEM ) <TAB> <TAB> <TAB> <TAB> <TAB> connect_obj ( b, ""clicked"", Gtk. Window. show, prefs ) <TAB> <TAB> <TAB> <TAB> <TAB> connect_obj ( b, ""destroy"", Gtk. Window. destroy, prefs ) <TAB> <TAB> <TAB> <TAB> <TAB> frame. add ( b ) <TAB> <TAB> <TAB> <TAB> <TAB> frame. get_child ( ). set_border_width",False,"plugin and hasattr(instance_or_cls, 'PluginPreferences')",instance_or_cls is not None,0.64909827709198
|
||
|
3438,"def unpack ( self, i ) : <TAB> o, p = b"""", 0 <TAB> while p < len ( i ) : <TAB> <TAB> <TAB> <TAB> c = ord ( i [ p : p + 1 ] ) <TAB> <TAB> p += 1 <TAB> <TAB> if c >= 1 and c <= 8 : <TAB> <TAB> <TAB> o += i [ p : p + c ] <TAB> <TAB> <TAB> p += c <TAB> <TAB> elif c < 128 : <TAB> <TAB> <TAB> o += bchr ( c ) <TAB> <TAB> elif c >= 192 : <TAB> <TAB> <TAB> o += b"" "" + bchr ( c ^ 128 ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if p < len ( i ) : <TAB> <TAB> <TAB> <TAB> c = ( c << 8 ) | ord ( i [ p : p + 1 ] ) <TAB> <TAB> <TAB> <TAB> p += 1 <TAB> <TAB> <TAB> <TAB> m = ( c >> 3 ) & 0x07FF <TAB> <TAB> <TAB> <TAB> n = ( c & 7 ) + 3 <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> o += o [ - m : n - m ] <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> for _ in range ( n ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if m == 1 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> o += o [ - m : ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> o += o [ - m : - m + 1 ] <TAB> return o",False,m > n,n > 0,0.6869404315948486
|
||
|
3439,"def _git_dirty_working_directory ( q, include_untracked ) : <TAB> try : <TAB> <TAB> cmd = [ ""git"", ""status"", ""--porcelain"" ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> cmd += [ ""--untracked-files=normal"" ] <TAB> <TAB> else : <TAB> <TAB> <TAB> cmd += [ ""--untracked-files=no"" ] <TAB> <TAB> status = _run_git_cmd ( cmd ) <TAB> <TAB> if status is not None : <TAB> <TAB> <TAB> q. put ( bool ( status ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> q. put ( None ) <TAB> except ( subprocess. CalledProcessError, OSError, FileNotFoundError ) : <TAB> <TAB> q. put ( None )",True,include_untracked,include_untracked,0.6702902317047119
|
||
|
3440,"def get ( self, key, group = None, locale = False, type = ""string"", list = False, strict = False ) : <TAB> <TAB> if not group : <TAB> <TAB> group = self. defaultGroup <TAB> <TAB> if ( group in self. content ) and ( key in self. content [ group ] ) : <TAB> <TAB> if locale : <TAB> <TAB> <TAB> value = self. content [ group ] [ self. __addLocale ( key, group ) ] <TAB> <TAB> else : <TAB> <TAB> <TAB> value = self. content [ group ] [ key ] <TAB> else : <TAB> <TAB> if strict or debug : <TAB> <TAB> <TAB> if group not in self. content : <TAB> <TAB> <TAB> <TAB> raise NoGroupError ( group, self. filename ) <TAB> <TAB> <TAB> elif key not in self. content [ group ] : <TAB> <TAB> <TAB> <TAB> raise NoKeyError ( key, group, self. filename ) <TAB> <TAB> else : <TAB> <TAB> <TAB> value = """" <TAB> if list == True : <TAB> <TAB> values = self. getList ( value ) <TAB> <TAB> result = [ ] <TAB> else : <TAB> <TAB> values = [ value ] <TAB> for value in values : <TAB> <TAB> if type == ""boolean"" : <TAB> <TAB> <TAB> value = self. __getBoolean ( value ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> value = int ( value ) <TAB> <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> <TAB> value = 0 <TAB> <TAB> elif type == ""numeric"" : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> value = float ( value ) <TAB> <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> <TAB> value = 0.0 <TAB> <TAB> elif type == ""regex"" : <TAB> <TAB> <TAB",False,type == 'integer',type == 'string',0.6634034514427185
|
||
|
3441,"def initial_type ( <TAB> name, <TAB> input, <TAB> op_type, <TAB> fan_out, <TAB> init = ""normal"", <TAB> use_bias = False, <TAB> filter_size = 0, <TAB> stddev = 0.02, ) : <TAB> if init == ""kaiming"" : <TAB> <TAB> if op_type == ""conv"" : <TAB> <TAB> <TAB> fan_in = input. shape [ 1 ] * filter_size * filter_size <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> fan_in = fan_out * filter_size * filter_size <TAB> <TAB> else : <TAB> <TAB> <TAB> if len ( input. shape ) > 2 : <TAB> <TAB> <TAB> <TAB> fan_in = input. shape [ 1 ] * input. shape [ 2 ] * input. shape [ 3 ] <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> fan_in = input. shape [ 1 ] <TAB> <TAB> bound = 1 / math. sqrt ( fan_in ) <TAB> <TAB> param_attr = fluid. ParamAttr ( <TAB> <TAB> <TAB> name = name + ""_w"", <TAB> <TAB> <TAB> initializer = fluid. initializer. Uniform ( low = - bound, high = bound ), <TAB> <TAB> ) <TAB> <TAB> if use_bias == True : <TAB> <TAB> <TAB> bias_attr = fluid. ParamAttr ( <TAB> <TAB> <TAB> <TAB> name = name + ""_b"", <TAB> <TAB> <TAB> <TAB> initializer = fluid. initializer. Uniform ( low = - bound, high = bound ), <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> bias_attr = False <TAB> else : <TAB> <TAB> param_attr = fluid. ParamAttr ( <TAB> <TAB> <TAB> name = name + ""_w"", <TAB> <TAB> <TAB> initializer = fluid. initializer. NormalInitializer ( loc = 0.0,",False,op_type == 'deconv',op_type == 'fan_out',0.6565966606140137
|
||
|
3442,"def write_safety_flag ( egg_dir, safe ) : <TAB> <TAB> for flag, fn in safety_flags. items ( ) : <TAB> <TAB> fn = os. path. join ( egg_dir, fn ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if safe is None or bool ( safe )!= flag : <TAB> <TAB> <TAB> <TAB> os. unlink ( fn ) <TAB> <TAB> elif safe is not None and bool ( safe ) == flag : <TAB> <TAB> <TAB> f = open ( fn, ""wt"" ) <TAB> <TAB> <TAB> f. write ( ""\n"" ) <TAB> <TAB> <TAB> f. close ( )",True,os.path.exists(fn),os.path.exists(fn),0.6480686664581299
|
||
|
3443,"def forward ( self, inputs ) : <TAB> self. retain_inputs ( ( 0, ) ) <TAB> x, W = inputs <TAB> self. _w_shape = W. shape <TAB> if not type_check. same_types ( * inputs ) : <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> ""numpy and cupy must not be used together\n"" <TAB> <TAB> <TAB> ""type(W): {0}, type(x): {1}"". format ( type ( W ), type ( x ) ) <TAB> <TAB> ) <TAB> xp = cuda. get_array_module ( * inputs ) <TAB> if chainer. is_debug ( ) : <TAB> <TAB> valid_x = xp. logical_and ( 0 <= x, x < len ( W ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> valid_x = xp. logical_or ( valid_x, x == self. ignore_label ) <TAB> <TAB> if not valid_x. all ( ) : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""Each not ignored `x` value need to satisfy"" ""`0 <= x < len(W)`"" <TAB> <TAB> <TAB> ) <TAB> if<mask> : <TAB> <TAB> mask = x == self. ignore_label <TAB> <TAB> return ( xp. where ( mask [..., None ], 0, W [ xp. where ( mask, 0, x ) ] ), ) <TAB> return ( W [ x ], )",True,self.ignore_label is not None,self.ignore_label is not None,0.6508135199546814
|
||
|
3444,"def seek ( self, index, whence = WHENCE_ABSOLUTE ) : <TAB> num_bytes_to_ff = 0 <TAB> if whence == WHENCE_ABSOLUTE : <TAB> <TAB> if index < self. _cursor_position : <TAB> <TAB> <TAB> raise IOError ( ""Cannot seek backwards"" ) <TAB> <TAB> num_bytes_to_ff = index - self. _cursor_position <TAB> elif whence == WHENCE_RELATIVE : <TAB> <TAB> if index < 0 : <TAB> <TAB> <TAB> raise IOError ( ""Cannnot seek backwards"" ) <TAB> <TAB> num_bytes_to_ff = index <TAB> elif whence == WHENCE_RELATIVE_END : <TAB> <TAB> raise IOError ( ""Stream does not have a known end point"" ) <TAB> bytes_forward = num_bytes_to_ff <TAB> while num_bytes_to_ff > 0 : <TAB> <TAB> buf = self. _fileobj. read ( num_bytes_to_ff ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise IOError ( ""Seek past end of file"" ) <TAB> <TAB> num_bytes_to_ff -= len ( buf ) <TAB> self. _cursor_position += bytes_forward <TAB> return bytes_forward",False,not buf,len(buf) < TAB > num_bytes_to_ff,0.6798411011695862
|
||
|
3445,"def delete_byfilter ( userId, remove = True, session = None, ** dbfilter ) : <TAB> if not session : <TAB> <TAB> session = db. Session <TAB> ret = False <TAB> results = session. query ( ObjectStorageMetadata ). filter_by ( ** dbfilter ) <TAB> if results : <TAB> <TAB> for result in results : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> session. delete ( result ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> result. update ( <TAB> <TAB> <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""record_state_key"" : ""to_delete"", <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""record_state_val"" : str ( time. time ( ) ), <TAB> <TAB> <TAB> <TAB> <TAB> } <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ret = True <TAB> return ret",True,remove,remove,0.6937353610992432
|
||
|
3446,"def L_op ( self, inputs, outputs, gout ) : <TAB> ( x, ) = inputs <TAB> ( gz, ) = gout <TAB> if x. type in complex_types : <TAB> <TAB> raise NotImplementedError ( ) <TAB> if outputs [ 0 ]. type in discrete_types : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return [ x. zeros_like ( dtype = theano. config. floatX ) ] <TAB> <TAB> else : <TAB> <TAB> <TAB> return [ x. zeros_like ( ) ] <TAB> return ( gz * sinh ( x ), )",True,x.type in discrete_types,x.type in discrete_types,0.6547557711601257
|
||
|
3447,"def split_port ( port ) : <TAB> if hasattr ( port, ""legacy_repr"" ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> port = port. legacy_repr ( ) <TAB> port = str ( port ) <TAB> match = PORT_SPEC. match ( port ) <TAB> if match is None : <TAB> <TAB> _raise_invalid_port ( port ) <TAB> parts = match. groupdict ( ) <TAB> host = parts [ ""host"" ] <TAB> proto = parts [ ""proto"" ] or """" <TAB> internal = port_range ( parts [ ""int"" ], parts [ ""int_end"" ], proto ) <TAB> external = port_range ( parts [ ""ext"" ], parts [ ""ext_end"" ], """", len ( internal ) == 1 ) <TAB> if host is None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( ""Port ranges don't match in length"" ) <TAB> <TAB> return internal, external <TAB> else : <TAB> <TAB> if not external : <TAB> <TAB> <TAB> external = [ None ] * len ( internal ) <TAB> <TAB> elif len ( internal )!= len ( external ) : <TAB> <TAB> <TAB> raise ValueError ( ""Port ranges don't match in length"" ) <TAB> <TAB> return internal, [ ( host, ext_port ) for ext_port in external ]",False,external is not None and len(internal) != len(external),len(internal) != len(internal),0.6476984024047852
|
||
|
3448,"def _find_closing_brace ( string, start_pos ) : <TAB> """"""Finds the corresponding closing brace after start_pos."""""" <TAB> bracks_open = 1 <TAB> for idx, char in enumerate ( string [ start_pos : ] ) : <TAB> <TAB> if char == ""("" : <TAB> <TAB> <TAB> if string [ idx + start_pos - 1 ]!= ""\\"" : <TAB> <TAB> <TAB> <TAB> bracks_open += 1 <TAB> <TAB> elif char == "")"" : <TAB> <TAB> <TAB> if string [ idx + start_pos - 1 ]!= ""\\"" : <TAB> <TAB> <TAB> <TAB> bracks_open -= 1 <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return start_pos + idx + 1",False,not bracks_open,bracks_open == 0,0.6672619581222534
|
||
|
3449,"def __init__ ( self ) : <TAB> <TAB> super ( MultiqcModule, self ). __init__ ( <TAB> <TAB> name = ""pycoQC"", <TAB> <TAB> anchor = ""pycoqc"", <TAB> <TAB> href = ""https://a-slide.github.io/pycoQC/"", <TAB> <TAB> info = ""computes metrics and generates interactive QC plots for Oxford Nanopore technologies sequencing data"", <TAB> ) <TAB> self. pycoqc_data = { } <TAB> for f in self. find_log_files ( ""pycoqc"" ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> log. debug ( <TAB> <TAB> <TAB> <TAB> ""Duplicate sample name found in {}! Overwriting: {}"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> f [ ""fn"" ], f [ ""s_name"" ] <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> data = self. load_data ( f [ ""f"" ] ) <TAB> <TAB> <TAB> <TAB> if data : <TAB> <TAB> <TAB> self. pycoqc_data [ f [ ""s_name"" ] ] = data <TAB> self. pycoqc_data = self. ignore_samples ( self. pycoqc_data ) <TAB> <TAB> if len ( self. pycoqc_data ) == 0 : <TAB> <TAB> raise UserWarning <TAB> log. info ( ""Found {} reports"". format ( len ( self. pycoqc_data ) ) ) <TAB> self. parse_data ( ) <TAB> self. make_general_stats ( ) <TAB> self. make_pycoqc_table ( ) <TAB> self. read_base_count_plot ( ) <TAB> <TAB> if self. read_length_plot_data [ 0 ] : <TAB> <TAB> self. read_length_plot ( ) <TAB> if self. quality_plot_data [ 0 ] : <TAB> <TAB> self. make_quality_",False,f['s_name'] in self.pycoqc_data,f[0],0.6537280082702637
|
||
|
3450,"def _parse_search_space ( <TAB> self, module, root = None, prefix = """", memo = None, nested_detection = None ) : <TAB> if memo is None : <TAB> <TAB> memo = set ( ) <TAB> if root is None : <TAB> <TAB> root = StructuredMutableTreeNode ( None ) <TAB> if module not in memo : <TAB> <TAB> memo. add ( module ) <TAB> <TAB> if isinstance ( module, Mutable ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise RuntimeError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Cannot have nested search space. Error at {} in {}"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> module, nested_detection <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> module. name = prefix <TAB> <TAB> <TAB> module. set_mutator ( self ) <TAB> <TAB> <TAB> root = root. add_child ( module ) <TAB> <TAB> <TAB> if not isinstance ( module, MutableScope ) : <TAB> <TAB> <TAB> <TAB> nested_detection = module <TAB> <TAB> <TAB> if isinstance ( module, InputChoice ) : <TAB> <TAB> <TAB> <TAB> for k in module. choose_from : <TAB> <TAB> <TAB> <TAB> <TAB> if k!= InputChoice. NO_KEY and k not in [ <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> m. key for m in memo if isinstance ( m, Mutable ) <TAB> <TAB> <TAB> <TAB> <TAB> ] : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> raise RuntimeError ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""'{}' required by '{}' not found in keys that appeared before, and is not NO_KEY."". format ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB",False,nested_detection is not None,nested_detection,0.6590631008148193
|
||
|
3451,"def handle ( self, * args, ** options ) : <TAB> if options [ ""list_samples"" ] : <TAB> <TAB> self. stdout. write ( ""Samples:"" ) <TAB> <TAB> for sample in Sample. objects. iterator ( ) : <TAB> <TAB> <TAB> self. stdout. write ( ""%s: %.1f%%"" % ( sample. name, sample. percent ) ) <TAB> <TAB> self. stdout. write ( """" ) <TAB> <TAB> return <TAB> sample_name = options [ ""name"" ] <TAB> percent = options [ ""percent"" ] <TAB> if not ( sample_name and percent ) : <TAB> <TAB> raise CommandError ( ""You need to specify a sample name and percentage."" ) <TAB> try : <TAB> <TAB> percent = float ( percent ) <TAB> <TAB> if not ( 0.0 <= percent <= 100.0 ) : <TAB> <TAB> <TAB> raise ValueError ( ) <TAB> except ValueError : <TAB> <TAB> raise CommandError ( ""You need to enter a valid percentage value."" ) <TAB> if options [ ""create"" ] : <TAB> <TAB> sample, created = Sample. objects. get_or_create ( <TAB> <TAB> <TAB> name = sample_name, defaults = { ""percent"" : 0 } <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. stdout. write ( ""Creating sample: %s"" % sample_name ) <TAB> else : <TAB> <TAB> try : <TAB> <TAB> <TAB> sample = Sample. objects. get ( name = sample_name ) <TAB> <TAB> except Sample. DoesNotExist : <TAB> <TAB> <TAB> raise CommandError ( ""This sample does not exist."" ) <TAB> sample. percent = percent <TAB> sample. save ( )",True,created,created,0.6821338534355164
|
||
|
3452,"def calculateObjectSizeOffsets ( ) : <TAB> size = 0.0 <TAB> if getProfileSetting ( ""platform_adhesion"" ) == ""Brim"" : <TAB> <TAB> size += getProfileSettingFloat ( ""brim_line_count"" ) * calculateEdgeWidth ( ) <TAB> elif getProfileSetting ( ""platform_adhesion"" ) == ""Raft"" : <TAB> <TAB> pass <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> size += getProfileSettingFloat ( <TAB> <TAB> <TAB> <TAB> ""skirt_line_count"" <TAB> <TAB> <TAB> ) * calculateEdgeWidth ( ) + getProfileSettingFloat ( ""skirt_gap"" ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return [ size, size ]",False,getProfileSettingFloat('skirt_line_count') > 0,getProfileSetting('platform_skirt_gap') is not None,0.668321430683136
|
||
|
3453,"def __call__ ( self ) : <TAB> """"""Return the babel call with correct options and settings"""""" <TAB> languages = sorted ( self. otherlanguages. keys ( ) ) <TAB> languages. append ( self. language or ""english"" ) <TAB> self. setup = [ r""\usepackage[%s]{babel}"" % "","". join ( languages ) ] <TAB> <TAB> shorthands = [ ] <TAB> for c in """". join ( [ self. active_chars. get ( l, """" ) for l in languages ] ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> shorthands. append ( c ) <TAB> if shorthands : <TAB> <TAB> self. setup. append ( r""\AtBeginDocument{\shorthandoff{%s}}"" % """". join ( shorthands ) ) <TAB> <TAB> if ""galician"" in languages : <TAB> <TAB> self. setup. append ( r""\deactivatetilden % restore ~ in Galician"" ) <TAB> if ""estonian"" in languages : <TAB> <TAB> self. setup. extend ( <TAB> <TAB> <TAB> [ <TAB> <TAB> <TAB> <TAB> r""\makeatletter"", <TAB> <TAB> <TAB> <TAB> r"" \addto\extrasestonian{\bbl@deactivate{~}}"", <TAB> <TAB> <TAB> <TAB> r""\makeatother"", <TAB> <TAB> <TAB> ] <TAB> <TAB> ) <TAB> if ""basque"" in languages : <TAB> <TAB> self. setup. extend ( <TAB> <TAB> <TAB> [ <TAB> <TAB> <TAB> <TAB> r""\makeatletter"", <TAB> <TAB> <TAB> <TAB> r"" \addto\extrasbasque{\bbl@deactivate{~}}"", <TAB> <TAB> <TAB> <TAB> r""\makeatother"", <TAB> <TAB> <TAB> ] <TAB> <TAB> ) <TAB> if languages [ - 1 ] == ""english"" and ""french"" in self. otherlanguages. keys ( ) : <TAB> <",False,c not in shorthands,c in shorthands,0.6710189580917358
|
||
|
3454,"def handle ( _name, cfg, _cloud, log, _args ) : <TAB> if ""growpart"" not in cfg : <TAB> <TAB> log. debug ( ""No 'growpart' entry in cfg. Using default: %s"" % DEFAULT_CONFIG ) <TAB> <TAB> cfg [ ""growpart"" ] = DEFAULT_CONFIG <TAB> mycfg = cfg. get ( ""growpart"" ) <TAB> if not isinstance ( mycfg, dict ) : <TAB> <TAB> log. warning ( ""'growpart' in config was not a dict"" ) <TAB> <TAB> return <TAB> mode = mycfg. get ( ""mode"", ""auto"" ) <TAB> if util. is_false ( mode ) : <TAB> <TAB> log. debug ( ""growpart disabled: mode=%s"" % mode ) <TAB> <TAB> return <TAB> if util. is_false ( mycfg. get ( ""ignore_growroot_disabled"", False ) ) : <TAB> <TAB> if os. path. isfile ( ""/etc/growroot-disabled"" ) : <TAB> <TAB> <TAB> log. debug ( ""growpart disabled: /etc/growroot-disabled exists"" ) <TAB> <TAB> <TAB> log. debug ( ""use ignore_growroot_disabled to ignore"" ) <TAB> <TAB> <TAB> return <TAB> devices = util. get_cfg_option_list ( mycfg, ""devices"", [ ""/"" ] ) <TAB> if not len ( devices ) : <TAB> <TAB> log. debug ( ""growpart: empty device list"" ) <TAB> <TAB> return <TAB> try : <TAB> <TAB> resizer = resizer_factory ( mode ) <TAB> except ( ValueError, TypeError ) as e : <TAB> <TAB> log. debug ( ""growpart unable to find resizer for '%s': %s"" % ( mode, e ) ) <TAB> <TAB> if mode!= ""auto"" : <TAB> <TAB> <TAB> raise e <TAB> <TAB> return <TAB> resized = util. log_time ( <TAB> <TAB> logfunc = log. debug, <TAB> <TAB>",False,action == RESIZE.CHANGED,_cloud.get_option_name() == 'get-device-list',0.6548984050750732
|
||
|
3455,"def checkIfSessionCodeExists ( self, sessionCode ) : <TAB> if self. emrtFile : <TAB> <TAB> sessionsForExperiment = ( <TAB> <TAB> <TAB> self. emrtFile. root. data_collection. session_meta_data. where ( <TAB> <TAB> <TAB> <TAB> ""experiment_id == %d"" % ( self. active_experiment_id, ) <TAB> <TAB> <TAB> ) <TAB> <TAB> ) <TAB> <TAB> sessionCodeMatch = [ <TAB> <TAB> <TAB> sess for sess in sessionsForExperiment if sess [ ""code"" ] == sessionCode <TAB> <TAB> ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return True <TAB> <TAB> return False",False,len(sessionCodeMatch) > 0,sessionCodeMatch,0.6583895683288574
|
||
|
3456,"def handleState ( self, state ) : <TAB> position, paused, doSeek, setBy = None, None, None, None <TAB> messageAge = 0 <TAB> if not self. hadFirstStateUpdate : <TAB> <TAB> self. hadFirstStateUpdate = True <TAB> if ""ignoringOnTheFly"" in state : <TAB> <TAB> ignore = state [ ""ignoringOnTheFly"" ] <TAB> <TAB> if ""server"" in ignore : <TAB> <TAB> <TAB> self. serverIgnoringOnTheFly = ignore [ ""server"" ] <TAB> <TAB> <TAB> self. clientIgnoringOnTheFly = 0 <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> if ( ignore [ ""client"" ] ) == self. clientIgnoringOnTheFly : <TAB> <TAB> <TAB> <TAB> self. clientIgnoringOnTheFly = 0 <TAB> if ""playstate"" in state : <TAB> <TAB> position, paused, doSeek, setBy = self. _extractStatePlaystateArguments ( state ) <TAB> if ""ping"" in state : <TAB> <TAB> messageAge, latencyCalculation = self. _handleStatePing ( state ) <TAB> if position is not None and paused is not None and not self. clientIgnoringOnTheFly : <TAB> <TAB> self. _client. updateGlobalState ( position, paused, doSeek, setBy, messageAge ) <TAB> position, paused, doSeek, stateChange = self. _client. getLocalState ( ) <TAB> self. sendState ( position, paused, doSeek, latencyCalculation, stateChange )",False,'client' in ignore,ignore.get('client') in ignore,0.6609150171279907
|
||
|
3457,"def test_join_diffs ( db, series_of_diffs, expected ) : <TAB> diffs = [ ] <TAB> for changes in series_of_diffs : <TAB> <TAB> tracker = DBDiffTracker ( ) <TAB> <TAB> for key, val in changes. items ( ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> del tracker [ key ] <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> tracker [ key ] = val <TAB> <TAB> diffs. append ( tracker. diff ( ) ) <TAB> DBDiff. join ( diffs ). apply_to ( db ) <TAB> assert db == expected",True,val is None,val is None,0.6674560308456421
|
||
|
3458,"def _execute ( self, options, args ) : <TAB> if len ( args ) < 1 : <TAB> <TAB> raise CommandError ( _ ( ""Not enough arguments"" ) ) <TAB> <TAB> if options. dry_run : <TAB> <TAB> self. verbose = True <TAB> paths = args <TAB> for path in paths : <TAB> <TAB> song = self. load_song ( path ) <TAB> <TAB> <TAB> <TAB> if options. primary : <TAB> <TAB> <TAB> image = song. get_primary_image ( ) <TAB> <TAB> <TAB> images = [ image ] if image else [ ] <TAB> <TAB> else : <TAB> <TAB> <TAB> images = song. get_images ( ) <TAB> <TAB> self. log ( ""Images for %r: %r"" % ( path, images ) ) <TAB> <TAB> if not images : <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> basename = os. path. basename ( path ) <TAB> <TAB> name = os. path. splitext ( basename ) [ 0 ] <TAB> <TAB> <TAB> <TAB> number_pattern = ""%%0%dd"" % ( max ( 2, len ( images ) - 1 ) ) <TAB> <TAB> for i, image in enumerate ( images ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> extensions = image. extensions <TAB> <TAB> <TAB> ext = extensions [ 0 ] if extensions else "".image"" <TAB> <TAB> <TAB> if options. primary : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> filename = ""%s.%s"" % ( name, ext ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> pattern = ""%s-"" + number_pattern + "".%s"" <TAB> <TAB> <TAB> <TAB> filename = pattern % ( name, i, ext ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> filename =",False,options.destination is not None,options.full,0.6556945443153381
|
||
|
3459,"def include_module ( module ) : <TAB> if not include_these : <TAB> <TAB> return True <TAB> result = False <TAB> for check in include_these : <TAB> <TAB> if ""/*"" in check : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> result = True <TAB> <TAB> else : <TAB> <TAB> <TAB> if ( os. getcwd ( ) + ""/"" + check + "".py"" ) == module : <TAB> <TAB> <TAB> <TAB> result = True <TAB> if result : <TAB> <TAB> print_status ( ""Including module: "" + module ) <TAB> return result",False,check[:-1] in module,module == os.getcwd(),0.6585389375686646
|
||
|
3460,"def _process_ffmpeg_output ( self, * lines ) : <TAB> for line in lines : <TAB> <TAB> <TAB> <TAB> current_time = _ffmpeg_current_regex. search ( line ) <TAB> <TAB> if current_time is not None and self. _parsed_duration!= 0 : <TAB> <TAB> <TAB> current_s = self. _convert_time ( * current_time. groups ( ) ) <TAB> <TAB> <TAB> progress = current_s / float ( self. _parsed_duration ) * 100 <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for callback in _update_callbacks : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> callback. sendRenderProgress ( progress ) <TAB> <TAB> <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> <TAB> <TAB> self. _logger. exception ( ""Exception while pushing render progress"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> duration = _ffmpeg_duration_regex. search ( line ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. _parsed_duration = self. _convert_time ( * duration. groups ( ) )",True,duration is not None,duration is not None,0.6670204997062683
|
||
|
3461,"def parameters_changed ( self ) : <TAB> <TAB> if self. has_uncertain_inputs ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. psi0 = self. kern. psi0 ( self. Z, self. X ) <TAB> <TAB> self. psi1 = self. kern. psi1 ( self. Z, self. X ) <TAB> <TAB> self. psi2 = self. kern. psi2n ( self. Z, self. X ) <TAB> else : <TAB> <TAB> self. psi0 = self. kern. Kdiag ( self. X ) <TAB> <TAB> self. psi1 = self. kern. K ( self. X, self. Z ) <TAB> <TAB> self. psi2 = None <TAB> if self. missing_data : <TAB> <TAB> self. _outer_loop_for_missing_data ( ) <TAB> elif self. stochastics : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. stochastics. do_stochastics ( ) <TAB> <TAB> self. _outer_loop_without_missing_data ( ) <TAB> else : <TAB> <TAB> ( <TAB> <TAB> <TAB> self. posterior, <TAB> <TAB> <TAB> self. _log_marginal_likelihood, <TAB> <TAB> <TAB> self. grad_dict, <TAB> <TAB> ) = self. _inner_parameters_changed ( <TAB> <TAB> <TAB> self. kern, <TAB> <TAB> <TAB> self. X, <TAB> <TAB> <TAB> self. Z, <TAB> <TAB> <TAB> self. likelihood, <TAB> <TAB> <TAB> self. Y_normalized, <TAB> <TAB> <TAB> self. Y_metadata, <TAB> <TAB> ) <TAB> <TAB> self. _outer_values_update ( self. grad_dict ) <TAB> self. _Zgrad = self. Z. gradient. copy ( )",False,self._update_stochastics,self.stochastics.do_stochastics(),0.6696719527244568
|
||
|
3462,"def matches ( self, invocation ) : <TAB> if self. method_name!= invocation. method_name : <TAB> <TAB> return False <TAB> for x, p1 in enumerate ( self. params ) : <TAB> <TAB> <TAB> <TAB> if p1 is Ellipsis : <TAB> <TAB> <TAB> return True <TAB> <TAB> if p1 is matchers. ARGS_SENTINEL : <TAB> <TAB> <TAB> break <TAB> <TAB> try : <TAB> <TAB> <TAB> p2 = invocation. params [ x ] <TAB> <TAB> except IndexError : <TAB> <TAB> <TAB> return False <TAB> <TAB> if not self. compare ( p1, p2 ) : <TAB> <TAB> <TAB> return False <TAB> else : <TAB> <TAB> if len ( self. params )!= len ( invocation. params ) : <TAB> <TAB> <TAB> return False <TAB> for key, p1 in sorted ( <TAB> <TAB> self. named_params. items ( ), <TAB> <TAB> key = lambda k_v : 1 if k_v [ 0 ] is matchers. KWARGS_SENTINEL else 0, <TAB> ) : <TAB> <TAB> if key is matchers. KWARGS_SENTINEL : <TAB> <TAB> <TAB> break <TAB> <TAB> try : <TAB> <TAB> <TAB> p2 = invocation. named_params [ key ] <TAB> <TAB> except KeyError : <TAB> <TAB> <TAB> return False <TAB> <TAB> if not self. compare ( p1, p2 ) : <TAB> <TAB> <TAB> return False <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return False <TAB> return True",False,len(self.named_params) != len(invocation.named_params),"not self.compare(p1, p2)",0.6524553298950195
|
||
|
3463,"def run ( self ) : <TAB> while not self. _stopped : <TAB> <TAB> try : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> test_name = next ( self. pending ) <TAB> <TAB> <TAB> except StopIteration : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> mp_result = self. _runtest ( test_name ) <TAB> <TAB> <TAB> self. output. put ( ( False, mp_result ) ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> except ExitThread : <TAB> <TAB> <TAB> break <TAB> <TAB> except BaseException : <TAB> <TAB> <TAB> self. output. put ( ( True, traceback. format_exc ( ) ) ) <TAB> <TAB> <TAB> break",False,"must_stop(mp_result.result, self.ns)",self._exit_thread is None,0.6532093286514282
|
||
|
3464,"def _dxf_spline ( el ) : <TAB> try : <TAB> <TAB> degree = el. dxf. degree <TAB> <TAB> periodic = el. closed <TAB> <TAB> rational = False <TAB> <TAB> knots_unique = OrderedDict ( ) <TAB> <TAB> for k in el. knots : <TAB> <TAB> <TAB> if k in knots_unique : <TAB> <TAB> <TAB> <TAB> knots_unique [ k ] += 1 <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> knots_unique [ k ] = 1 <TAB> <TAB> <TAB> <TAB> knots = TColStd_Array1OfReal ( 1, len ( knots_unique ) ) <TAB> <TAB> multiplicities = TColStd_Array1OfInteger ( 1, len ( knots_unique ) ) <TAB> <TAB> for i, ( k, m ) in enumerate ( knots_unique. items ( ) ) : <TAB> <TAB> <TAB> knots. SetValue ( i + 1, k ) <TAB> <TAB> <TAB> multiplicities. SetValue ( i + 1, m ) <TAB> <TAB> <TAB> <TAB> if el. weights : <TAB> <TAB> <TAB> rational = True <TAB> <TAB> <TAB> weights = OCP. TColStd. TColStd_Array1OfReal ( 1, len ( el. weights ) ) <TAB> <TAB> <TAB> for i, w in enumerate ( el. weights ) : <TAB> <TAB> <TAB> <TAB> weights. SetValue ( i + 1, w ) <TAB> <TAB> <TAB> <TAB> pts = TColgp_Array1OfPnt ( 1, len ( el. control_points ) ) <TAB> <TAB> for i, p in enumerate ( el. control_points ) : <TAB> <TAB> <TAB> pts. SetValue ( i + 1, gp_Pnt ( * p ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> spline = Geom_BSplineCurve ( <TAB> <TAB> <TAB> <TAB> pts",False,rational,periodic,0.6961888074874878
|
||
|
3465,"def Kdiag ( self, X ) : <TAB> """"""Compute the diagonal of the covariance matrix associated to X."""""" <TAB> vyt = self. variance_Yt <TAB> vyx = self. variance_Yx <TAB> lyt = 1.0 / ( 2 * self. lengthscale_Yt ) <TAB> lyx = 1.0 / ( 2 * self. lengthscale_Yx ) <TAB> a = self. a <TAB> b = self. b <TAB> c = self. c <TAB> <TAB> k1 = ( 2 * lyt ) * vyt * vyx <TAB> <TAB> k2 = ( - 2 * lyx ) * vyt * vyx <TAB> <TAB> k3 = ( 4 * 3 * lyx ** 2 ) * vyt * vyx <TAB> Kdiag = np. zeros ( X. shape [ 0 ] ) <TAB> slices = index_to_slices ( X [ :, - 1 ] ) <TAB> for i, ss1 in enumerate ( slices ) : <TAB> <TAB> for s1 in ss1 : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> Kdiag [ s1 ] += vyt * vyx <TAB> <TAB> <TAB> elif i == 1 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> Kdiag [ s1 ] += ( <TAB> <TAB> <TAB> <TAB> <TAB> b ** 2 * k1 - 2 * a * c * k2 + a ** 2 * k3 + c ** 2 * vyt * vyx <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> raise ValueError ( ""invalid input/output index"" ) <TAB> return Kdiag",True,i == 0,i == 0,0.6789398193359375
|
||
|
3466,"def fake_db_snapshot ( ** updates ) : <TAB> db_snapshot = { <TAB> <TAB> ""id"" : fake. SNAPSHOT_ID, <TAB> <TAB> ""volume_id"" : fake. VOLUME_ID, <TAB> <TAB> ""status"" : c_fields. SnapshotStatus. CREATING, <TAB> <TAB> ""progress"" : ""0%"", <TAB> <TAB> ""volume_size"" : 1, <TAB> <TAB> ""display_name"" : ""fake_name"", <TAB> <TAB> ""display_description"" : ""fake_description"", <TAB> <TAB> ""metadata"" : { }, <TAB> <TAB> ""snapshot_metadata"" : [ ], <TAB> } <TAB> for name, field in snapshot. Snapshot. fields. items ( ) : <TAB> <TAB> if name in db_snapshot : <TAB> <TAB> <TAB> continue <TAB> <TAB> if field. nullable : <TAB> <TAB> <TAB> db_snapshot [ name ] = None <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> db_snapshot [ name ] = field. default <TAB> <TAB> else : <TAB> <TAB> <TAB> raise Exception ( ""fake_db_snapshot needs help with %s"" % name ) <TAB> if updates : <TAB> <TAB> db_snapshot. update ( updates ) <TAB> return db_snapshot",False,field.default != fields.UnspecifiedDefault,field.default,0.6534208059310913
|
||
|
3467,def tearDown ( self ) : <TAB> try : <TAB> <TAB> os. chdir ( self. cwd ) <TAB> <TAB> if self. pythonexe!= sys. executable : <TAB> <TAB> <TAB> os. remove ( self. pythonexe ) <TAB> <TAB> if self. nocgi_path : <TAB> <TAB> <TAB> os. remove ( self. nocgi_path ) <TAB> <TAB> if self. file1_path : <TAB> <TAB> <TAB> os. remove ( self. file1_path ) <TAB> <TAB> if self. file2_path : <TAB> <TAB> <TAB> os. remove ( self. file2_path ) <TAB> <TAB> if self. file3_path : <TAB> <TAB> <TAB> os. remove ( self. file3_path ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> os. remove ( self. file4_path ) <TAB> <TAB> os. rmdir ( self. cgi_child_dir ) <TAB> <TAB> os. rmdir ( self. cgi_dir ) <TAB> <TAB> os. rmdir ( self. parent_dir ) <TAB> finally : <TAB> <TAB> BaseTestCase. tearDown ( self ),True,self.file4_path,self.file4_path,0.6532148718833923
|
||
|
3468,"def visit_Raise ( self, node ) : <TAB> <TAB> self. newline ( ) <TAB> self. write ( ""raise"" ) <TAB> if hasattr ( node, ""exc"" ) and node. exc is not None : <TAB> <TAB> self. write ( "" "" ) <TAB> <TAB> self. visit ( node. exc ) <TAB> <TAB> if node. cause is not None : <TAB> <TAB> <TAB> self. write ( "" from "" ) <TAB> <TAB> <TAB> self. visit ( node. cause ) <TAB> elif hasattr ( node, ""type"" ) and node. type is not None : <TAB> <TAB> self. visit ( node. type ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. write ( "", "" ) <TAB> <TAB> <TAB> self. visit ( node. inst ) <TAB> <TAB> if node. tback is not None : <TAB> <TAB> <TAB> self. write ( "", "" ) <TAB> <TAB> <TAB> self. visit ( node. tback )",True,node.inst is not None,node.inst is not None,0.6572667360305786
|
||
|
3469,"def extractAVI ( self, headers ) : <TAB> audio_index = 1 <TAB> for stream in headers. array ( ""stream"" ) : <TAB> <TAB> if ""stream_hdr/stream_type"" not in stream : <TAB> <TAB> <TAB> continue <TAB> <TAB> stream_type = stream [ ""stream_hdr/stream_type"" ]. value <TAB> <TAB> if stream_type == ""vids"" : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> meta = Metadata ( self ) <TAB> <TAB> <TAB> <TAB> self. extractAVIVideo ( stream [ ""stream_hdr"" ], meta ) <TAB> <TAB> <TAB> <TAB> self. addGroup ( ""video"", meta, ""Video stream"" ) <TAB> <TAB> elif stream_type == ""auds"" : <TAB> <TAB> <TAB> if ""stream_fmt"" in stream : <TAB> <TAB> <TAB> <TAB> meta = Metadata ( self ) <TAB> <TAB> <TAB> <TAB> self. extractAVIAudio ( stream [ ""stream_fmt"" ], meta ) <TAB> <TAB> <TAB> <TAB> self. addGroup ( ""audio[%u]"" % audio_index, meta, ""Audio stream"" ) <TAB> <TAB> <TAB> <TAB> audio_index += 1 <TAB> if ""avi_hdr"" in headers : <TAB> <TAB> self. useAviHeader ( headers [ ""avi_hdr"" ] ) <TAB> <TAB> if self. has ( ""duration"" ) and ""/movie/size"" in headers : <TAB> <TAB> self. bit_rate = ( <TAB> <TAB> <TAB> float ( headers [ ""/movie/size"" ]. value ) <TAB> <TAB> <TAB> * 8 <TAB> <TAB> <TAB> / timedelta2seconds ( self. get ( ""duration"" ) ) <TAB> <TAB> ) <TAB> <TAB> if ""/index"" in headers : <TAB> <TAB> self. comment = _ ( ""Has audio/video index (%s)"" ) % humanFilesize ( <TAB> <TAB> <TAB> headers",True,'stream_hdr' in stream,'stream_hdr' in stream,0.6597448587417603
|
||
|
3470,"def format_crawler_progress ( self, p ) : <TAB> cycletime = p [ ""estimated-time-per-cycle"" ] <TAB> cycletime_s = """" <TAB> if cycletime is not None : <TAB> <TAB> cycletime_s = "" (estimated cycle time %s)"" % abbreviate_time ( cycletime ) <TAB> if p [ ""cycle-in-progress"" ] : <TAB> <TAB> pct = p [ ""cycle-complete-percentage"" ] <TAB> <TAB> soon = p [ ""remaining-sleep-time"" ] <TAB> <TAB> eta = p [ ""estimated-cycle-complete-time-left"" ] <TAB> <TAB> eta_s = """" <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> eta_s = "" (ETA %ds)"" % eta <TAB> <TAB> return [ <TAB> <TAB> <TAB> ""Current crawl %.1f%% complete"" % pct, <TAB> <TAB> <TAB> eta_s, <TAB> <TAB> <TAB> "" (next work in %s)"" % abbreviate_time ( soon ), <TAB> <TAB> <TAB> cycletime_s, <TAB> <TAB> ] <TAB> else : <TAB> <TAB> soon = p [ ""remaining-wait-time"" ] <TAB> <TAB> return [ ""Next crawl in %s"" % abbreviate_time ( soon ), cycletime_s ]",True,eta is not None,eta is not None,0.6695570349693298
|
||
|
3471,"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. clientName = iprot. readString ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif fid == 2 : <TAB> <TAB> <TAB> if ftype == TType. I16 : <TAB> <TAB> <TAB> <TAB> self. edamVersionMajor = iprot. readI16 ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif fid == 3 : <TAB> <TAB> <TAB> if ftype == TType. I16 : <TAB> <TAB> <TAB> <TAB> self. edamVersionMinor = iprot. readI16 ( ) <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,fid == 2,0.6603737473487854
|
||
|
3472,"def _pip_cmd ( pip3_path, args, silent = False ) : <TAB> output = err = None <TAB> if not pip3_path : <TAB> <TAB> sickrage. app. log. warning ( ""No path to pip specified, can't use pip commands"" ) <TAB> <TAB> exit_status = 1 <TAB> <TAB> return output, err, exit_status <TAB> cmd = [ pip3_path ] + args. split ( ) <TAB> try : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> sickrage. app. log. debug ( <TAB> <TAB> <TAB> <TAB> ""Executing "" <TAB> <TAB> <TAB> <TAB> + "" "". join ( cmd ) <TAB> <TAB> <TAB> <TAB> + "" with your shell in "" <TAB> <TAB> <TAB> <TAB> + sickrage. MAIN_DIR <TAB> <TAB> <TAB> ) <TAB> <TAB> p = subprocess. Popen ( <TAB> <TAB> <TAB> cmd, <TAB> <TAB> <TAB> stdin = subprocess. PIPE, <TAB> <TAB> <TAB> stdout = subprocess. PIPE, <TAB> <TAB> <TAB> stderr = subprocess. STDOUT, <TAB> <TAB> <TAB> shell = ( sys. platform == ""win32"" ), <TAB> <TAB> <TAB> cwd = sickrage. MAIN_DIR, <TAB> <TAB> ) <TAB> <TAB> output, err = p. communicate ( ) <TAB> <TAB> exit_status = p. returncode <TAB> except OSError : <TAB> <TAB> sickrage. app. log. info ( ""Command "" + "" "". join ( cmd ) + "" didn't work"" ) <TAB> <TAB> exit_status = 1 <TAB> if exit_status == 0 : <TAB> <TAB> exit_status = 0 <TAB> else : <TAB> <TAB> exit_status = 1 <TAB> if output : <TAB> <TAB> output = ( <TAB> <TAB> <TAB> output. decode ( ""utf-8"", ""ignore"" ). strip ( ) <TAB> <TAB> <TAB> if isinstance",False,not silent,silent,0.683783769607544
|
||
|
3473,"def get_text ( self, nodelist ) : <TAB> """"""Return a string representation of the motif's properties listed on nodelist."""""" <TAB> retlist = [ ] <TAB> for node in nodelist : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> retlist. append ( node. wholeText ) <TAB> <TAB> elif node. hasChildNodes : <TAB> <TAB> <TAB> retlist. append ( self. get_text ( node. childNodes ) ) <TAB> return re. sub ( r""\s+"", "" "", """". join ( retlist ) )",False,node.nodeType == Node.TEXT_NODE,node.wholeText,0.6562210917472839
|
||
|
3474,"def input_data ( self ) : <TAB> gen = self. config. generator <TAB> <TAB> <TAB> if gen and ( not self. config [ ""out"" ] or not self. config [ ""in"" ] ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _run_generator ( gen, args = self. config. generator_args ) <TAB> <TAB> if self. _generated [ 0 ] : <TAB> <TAB> <TAB> return self. _generated [ 0 ] <TAB> <TAB> return ( <TAB> <TAB> self. _normalize ( self. problem. problem_data [ self. config [ ""in"" ] ] ) <TAB> <TAB> if self. config [ ""in"" ] <TAB> <TAB> else b"""" <TAB> )",False,self._generated is None,gen,0.6699816584587097
|
||
|
3475,"def detach_volume ( self, volume ) : <TAB> <TAB> for node in self. list_nodes ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> for disk in node. image : <TAB> <TAB> <TAB> if disk. id == volume. id : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> disk_id = disk. extra [ ""disk_id"" ] <TAB> <TAB> <TAB> <TAB> return self. _do_detach_volume ( node. id, disk_id ) <TAB> return False",False,type(node.image) is not list,node.volume == volume,0.6469871997833252
|
||
|
3476,"def run ( self, iterations ) : <TAB> for i in range ( iterations ) : <TAB> <TAB> taskWorkArea. holdCount = 0 <TAB> <TAB> taskWorkArea. qpktCount = 0 <TAB> <TAB> IdleTask ( I_IDLE, 1, 10000, TaskState ( ). running ( ), IdleTaskRec ( ) ) <TAB> <TAB> wkq = Packet ( None, 0, K_WORK ) <TAB> <TAB> wkq = Packet ( wkq, 0, K_WORK ) <TAB> <TAB> WorkTask ( I_WORK, 1000, wkq, TaskState ( ). waitingWithPacket ( ), WorkerTaskRec ( ) ) <TAB> <TAB> wkq = Packet ( None, I_DEVA, K_DEV ) <TAB> <TAB> wkq = Packet ( wkq, I_DEVA, K_DEV ) <TAB> <TAB> wkq = Packet ( wkq, I_DEVA, K_DEV ) <TAB> <TAB> HandlerTask ( <TAB> <TAB> <TAB> I_HANDLERA, 2000, wkq, TaskState ( ). waitingWithPacket ( ), HandlerTaskRec ( ) <TAB> <TAB> ) <TAB> <TAB> wkq = Packet ( None, I_DEVB, K_DEV ) <TAB> <TAB> wkq = Packet ( wkq, I_DEVB, K_DEV ) <TAB> <TAB> wkq = Packet ( wkq, I_DEVB, K_DEV ) <TAB> <TAB> HandlerTask ( <TAB> <TAB> <TAB> I_HANDLERB, 3000, wkq, TaskState ( ). waitingWithPacket ( ), HandlerTaskRec ( ) <TAB> <TAB> ) <TAB> <TAB> wkq = None <TAB> <TAB> DeviceTask ( I_DEVA, 4000, wkq, TaskState ( ). waiting ( ), DeviceTaskRec ( ) ) <TAB> <TAB> DeviceTask ( I_DEVB, 5000, wkq, TaskState ( ). waiting ( ), DeviceTaskRec ( ) ) <TAB> <TAB> schedule ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> pass <TAB> <TAB> else : <",False,taskWorkArea.holdCount == 9297 and taskWorkArea.qpktCount == 23246,iterations == 1,0.655774712562561
|
||
|
3477,"def _add_widget_dim_constraints ( <TAB> solver, width_grid, height_grid, total_var_w, total_var_h, grid_widgets ) : <TAB> assert total_var_w is not None <TAB> assert total_var_h is not None <TAB> for ws in width_grid : <TAB> <TAB> for w in ws : <TAB> <TAB> <TAB> solver. add_constraint ( w >= 0, strength = REQUIRED ) <TAB> for hs in height_grid : <TAB> <TAB> for h in hs : <TAB> <TAB> <TAB> solver. add_constraint ( h >= 0, strength = REQUIRED ) <TAB> for ( _, val ) in grid_widgets. items ( ) : <TAB> <TAB> ( y, x, ys, xs, widget ) = val <TAB> <TAB> for ws in width_grid [ y : y + ys ] : <TAB> <TAB> <TAB> total_w = np. sum ( ws [ x : x + xs ] ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> solver. add_constraint ( total_w >= widget. width_min, strength = REQUIRED ) <TAB> <TAB> <TAB> if widget. width_max is not None : <TAB> <TAB> <TAB> <TAB> solver. add_constraint ( total_w <= widget. width_max, strength = REQUIRED ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> solver. add_constraint ( total_w <= total_var_w ) <TAB> <TAB> for hs in height_grid [ x : x + xs ] : <TAB> <TAB> <TAB> total_h = np. sum ( hs [ y : y + ys ] ) <TAB> <TAB> <TAB> solver. add_constraint ( total_h >= widget. height_min, strength = REQUIRED ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> solver. add_constraint ( total_h <= widget. height_max, strength = REQUIRED ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> solver. add_constraint",True,widget.height_max is not None,widget.height_max is not None,0.6608605980873108
|
||
|
3478,"def getMassPoisonHtml ( self ) : <TAB> html = '<div style=""position:absolute;left:-100px"">' <TAB> for i in self. app_config : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if self. app_config [ i ]. has_key ( ""tamper_url"" ) and not self. app_config [ i ]. get ( <TAB> <TAB> <TAB> <TAB> ""skip_in_mass_poison"", False <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> html += ( <TAB> <TAB> <TAB> <TAB> <TAB> '<iframe sandbox="""" style=""opacity:0;visibility:hidden"" width=""1"" height=""1"" src=""' <TAB> <TAB> <TAB> <TAB> <TAB> + self. app_config [ i ] [ ""tamper_url"" ] <TAB> <TAB> <TAB> <TAB> <TAB> + '""></iframe>' <TAB> <TAB> <TAB> <TAB> ) <TAB> return html + ""</div>""",False,"isinstance(self.app_config[i], dict)",i in self.app_config,0.6510339975357056
|
||
|
3479,"def compare_detections ( detection1 : dict, detection2 : dict ) -> bool : <TAB> <TAB> if len ( detection1 )!= len ( detection2 ) : <TAB> <TAB> return False <TAB> for named_condition in detection1 : <TAB> <TAB> <TAB> <TAB> if named_condition == ""condition"" : <TAB> <TAB> <TAB> if detection1 [ ""condition"" ]!= detection2 [ ""condition"" ] : <TAB> <TAB> <TAB> <TAB> return False <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> if named_condition not in detection2 : <TAB> <TAB> <TAB> return False <TAB> <TAB> if len ( detection1 [ named_condition ] )!= len ( detection2 [ named_condition ] ) : <TAB> <TAB> <TAB> return False <TAB> <TAB> for condition in detection1 [ named_condition ] : <TAB> <TAB> <TAB> if type ( condition )!= str : <TAB> <TAB> <TAB> <TAB> return False <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return False <TAB> <TAB> <TAB> condition_value1 = detection1 [ named_condition ] [ condition ] <TAB> <TAB> <TAB> condition_value2 = detection2 [ named_condition ] [ condition ] <TAB> <TAB> <TAB> if condition_value1!= condition_value2 : <TAB> <TAB> <TAB> <TAB> return False <TAB> return True",False,condition not in detection2[named_condition],named_condition not in detection1,0.656897783279419
|
||
|
3480,"def move ( self, color ) : <TAB> global TIMESTAMP, MOVES <TAB> TIMESTAMP += 1 <TAB> MOVES += 1 <TAB> self. board. zobrist. update ( self, color ) <TAB> self. color = color <TAB> self. reference = self <TAB> self. ledges = 0 <TAB> self. used = True <TAB> for neighbour in self. neighbours : <TAB> <TAB> neighcolor = neighbour. color <TAB> <TAB> if neighcolor == EMPTY : <TAB> <TAB> <TAB> self. ledges += 1 <TAB> <TAB> else : <TAB> <TAB> <TAB> neighbour_ref = neighbour. find ( update = True ) <TAB> <TAB> <TAB> if neighcolor == color : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> self. ledges += neighbour_ref. ledges <TAB> <TAB> <TAB> <TAB> <TAB> neighbour_ref. reference = self <TAB> <TAB> <TAB> <TAB> self. ledges -= 1 <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> neighbour_ref. ledges -= 1 <TAB> <TAB> <TAB> <TAB> if neighbour_ref. ledges == 0 : <TAB> <TAB> <TAB> <TAB> <TAB> neighbour. remove ( neighbour_ref ) <TAB> self. board. zobrist. add ( )",False,neighbour_ref.reference.pos != self.pos,neighby_ref == EMPTY,0.6536405086517334
|
||
|
3481,"def skip_tactics_or_techniques ( self, src_technics, src_tactics ) : <TAB> tactics = set ( ) <TAB> technics = set ( ) <TAB> local_storage_techniques = { <TAB> <TAB> item [ ""technique_id"" ] : item for item in self. find_technique ( src_technics ) <TAB> } <TAB> for key_id in src_technics : <TAB> <TAB> src_tactic = local_storage_techniques. get ( key_id, { } ). get ( ""tactic"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> src_tactic = set ( src_tactic ) <TAB> <TAB> for item in src_tactics : <TAB> <TAB> <TAB> if item in src_tactic : <TAB> <TAB> <TAB> <TAB> technics. add ( key_id ) <TAB> <TAB> <TAB> <TAB> tactics. add ( item ) <TAB> return sorted ( tactics ), sorted ( technics )",True,not src_tactic,not src_tactic,0.6721090078353882
|
||
|
3482,"def proc_minute ( d ) : <TAB> if expanded [ 0 ] [ 0 ]!= ""*"" : <TAB> <TAB> diff_min = nearest_diff_method ( d. minute, expanded [ 0 ], 60 ) <TAB> <TAB> if diff_min is not None and diff_min!= 0 : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> d += relativedelta ( minutes = diff_min, second = 59 ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> d += relativedelta ( minutes = diff_min, second = 0 ) <TAB> <TAB> <TAB> return True, d <TAB> return False, d",False,is_prev,"isinstance(diff_min, relativedelta)",0.6632629632949829
|
||
|
3483,"def date_to_format ( value, target_format ) : <TAB> """"""Convert date to specified format"""""" <TAB> if target_format == str : <TAB> <TAB> if isinstance ( value, datetime. date ) : <TAB> <TAB> <TAB> ret = value. strftime ( ""%d/%m/%y"" ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> ret = value. strftime ( ""%d/%m/%y"" ) <TAB> <TAB> elif isinstance ( value, datetime. time ) : <TAB> <TAB> <TAB> ret = value. strftime ( ""%H:%M:%S"" ) <TAB> else : <TAB> <TAB> ret = value <TAB> return ret",False,"isinstance(value, datetime.datetime)","isinstance(value, datetime.date)",0.6477208137512207
|
||
|
3484,def wait_til_ready ( cls ) : <TAB> while True : <TAB> <TAB> now = time. time ( ) <TAB> <TAB> next_iteration = now // 1.0 + 1 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> break <TAB> <TAB> else : <TAB> <TAB> <TAB> await cls. _clock. run_til ( next_iteration ) <TAB> <TAB> await asyncio. sleep ( 1.0 ),False,cls.connector.ready,next_iteration == 0,0.6594887971878052
|
||
|
3485,"def execute ( cls, ctx, op ) : <TAB> inputs, device_id, xp = as_same_device ( <TAB> <TAB> [ ctx [ c. key ] for c in op. inputs ], device = op. device, ret_extra = True <TAB> ) <TAB> with device ( device_id ) : <TAB> <TAB> kw = { ""casting"" : op. casting } <TAB> <TAB> inputs_iter = iter ( inputs ) <TAB> <TAB> input = next ( inputs_iter ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> out1 = next ( inputs_iter ) <TAB> <TAB> else : <TAB> <TAB> <TAB> out1 = None <TAB> <TAB> if op. out2 is not None : <TAB> <TAB> <TAB> out2 = next ( inputs_iter ) <TAB> <TAB> else : <TAB> <TAB> <TAB> out2 = None <TAB> <TAB> if op. where is not None : <TAB> <TAB> <TAB> where = kw [ ""where"" ] = next ( inputs_iter ) <TAB> <TAB> else : <TAB> <TAB> <TAB> where = None <TAB> <TAB> kw [ ""order"" ] = op. order <TAB> <TAB> try : <TAB> <TAB> <TAB> args = [ input ] <TAB> <TAB> <TAB> if out1 is not None : <TAB> <TAB> <TAB> <TAB> args. append ( out1. copy ( ) ) <TAB> <TAB> <TAB> if out2 is not None : <TAB> <TAB> <TAB> <TAB> args. append ( out2. copy ( ) ) <TAB> <TAB> <TAB> y1, y2 = xp. modf ( * args, ** kw ) <TAB> <TAB> except TypeError : <TAB> <TAB> <TAB> if where is None : <TAB> <TAB> <TAB> <TAB> raise <TAB> <TAB> <TAB> y1, y2 = xp. modf ( input ) <TAB> <TAB> <TAB> y1, y2 = xp. where ( where, y1, out1 ), xp.",True,op.out1 is not None,op.out1 is not None,0.6578171253204346
|
||
|
3486,"def test_stream_index ( self ) : <TAB> output = av. open ( self. sandboxed ( ""output.mov"" ), ""w"" ) <TAB> vstream = output. add_stream ( ""mpeg4"", 24 ) <TAB> vstream. pix_fmt = ""yuv420p"" <TAB> vstream. width = 320 <TAB> vstream. height = 240 <TAB> astream = output. add_stream ( ""mp2"", 48000 ) <TAB> astream. channels = 2 <TAB> astream. format = ""s16"" <TAB> self. assertEqual ( vstream. index, 0 ) <TAB> self. assertEqual ( astream. index, 1 ) <TAB> vframe = VideoFrame ( 320, 240, ""yuv420p"" ) <TAB> vpacket = vstream. encode ( vframe ) [ 0 ] <TAB> self. assertIs ( vpacket. stream, vstream ) <TAB> self. assertEqual ( vpacket. stream_index, 0 ) <TAB> for i in range ( 10 ) : <TAB> <TAB> aframe = AudioFrame ( ""s16"", ""stereo"", samples = astream. frame_size ) <TAB> <TAB> aframe. rate = 48000 <TAB> <TAB> apackets = astream. encode ( aframe ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> apacket = apackets [ 0 ] <TAB> <TAB> <TAB> break <TAB> self. assertIs ( apacket. stream, astream ) <TAB> self. assertEqual ( apacket. stream_index, 1 )",False,apackets,len(apackets) > 0,0.6742250323295593
|
||
|
3487,"def wait_for_initial_conf ( self, timeout = 1.0 ) : <TAB> logger. info ( ""Waiting for initial configuration"" ) <TAB> cur_timeout = timeout <TAB> <TAB> while not self. new_conf and not self. interrupted : <TAB> <TAB> elapsed, _, _ = self. handleRequests ( cur_timeout ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> cur_timeout -= elapsed <TAB> <TAB> <TAB> if cur_timeout > 0 : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> cur_timeout = timeout <TAB> <TAB> sys. stdout. write ( ""."" ) <TAB> <TAB> sys. stdout. flush ( )",False,elapsed,elapsed > 0,0.6952182650566101
|
||
|
3488,"def MultiReadClientMetadata ( self, client_ids ) : <TAB> """"""Reads ClientMetadata records for a list of clients."""""" <TAB> res = { } <TAB> for client_id in client_ids : <TAB> <TAB> md = self. metadatas. get ( client_id, None ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> res [ client_id ] = rdf_objects. ClientMetadata ( <TAB> <TAB> <TAB> certificate = md. get ( ""certificate"" ), <TAB> <TAB> <TAB> fleetspeak_enabled = md. get ( ""fleetspeak_enabled"" ), <TAB> <TAB> <TAB> first_seen = md. get ( ""first_seen"" ), <TAB> <TAB> <TAB> ping = md. get ( ""ping"" ), <TAB> <TAB> <TAB> clock = md. get ( ""clock"" ), <TAB> <TAB> <TAB> ip = md. get ( ""ip"" ), <TAB> <TAB> <TAB> last_foreman_time = md. get ( ""last_foreman_time"" ), <TAB> <TAB> <TAB> last_crash_timestamp = md. get ( ""last_crash_timestamp"" ), <TAB> <TAB> <TAB> startup_info_timestamp = md. get ( ""startup_info_timestamp"" ), <TAB> <TAB> ) <TAB> return res",True,md is None,md is None,0.6636156439781189
|
||
|
3489,"def get_celery_request_tags ( ** kwargs ) : <TAB> request = kwargs. get ( ""request"" ) <TAB> sender_hostname = ""unknown"" <TAB> sender = kwargs. get ( ""sender"" ) <TAB> if sender : <TAB> <TAB> try : <TAB> <TAB> <TAB> sender_hostname = sender. hostname <TAB> <TAB> except AttributeError : <TAB> <TAB> <TAB> sender_hostname = vars ( sender. request ). get ( ""origin"", ""unknown"" ) <TAB> if request and not isinstance ( <TAB> <TAB> request, Context <TAB> ) : <TAB> <TAB> task_name = request. name <TAB> <TAB> task_id = request. id <TAB> <TAB> receiver_hostname = request. hostname <TAB> else : <TAB> <TAB> try : <TAB> <TAB> <TAB> task_name = sender. name <TAB> <TAB> except AttributeError : <TAB> <TAB> <TAB> task_name = kwargs. pop ( ""name"", """" ) <TAB> <TAB> try : <TAB> <TAB> <TAB> task_id = sender. request. id <TAB> <TAB> except AttributeError : <TAB> <TAB> <TAB> task_id = kwargs. pop ( ""id"", """" ) <TAB> <TAB> try : <TAB> <TAB> <TAB> receiver_hostname = sender. request. hostname <TAB> <TAB> except AttributeError : <TAB> <TAB> <TAB> receiver_hostname = """" <TAB> tags = { <TAB> <TAB> ""task_name"" : task_name, <TAB> <TAB> ""task_id"" : task_id, <TAB> <TAB> ""sender_hostname"" : sender_hostname, <TAB> <TAB> ""receiver_hostname"" : receiver_hostname, <TAB> } <TAB> tags [ ""expired"" ] = kwargs. get ( ""expired"", False ) <TAB> exception = kwargs. get ( ""exception"" ) <TAB> if not exception : <TAB> <TAB> exception = kwargs. get ( ""exc"" ) <TAB> if exception : <TAB> <TAB> tags [ ""error"" ] = repr ( exception ) <TAB> <TAB> if<mask>",False,"isinstance(exception, SoftTimeLimitExceeded)",len(tags) > 0,0.6621091961860657
|
||
|
3490,"def __lt__ ( self, other ) : <TAB> try : <TAB> <TAB> if self == other : <TAB> <TAB> <TAB> return False <TAB> <TAB> for i in range ( len ( self. versions ) ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return True <TAB> <TAB> <TAB> if self. versions [ i ] > other. versions [ i ] : <TAB> <TAB> <TAB> <TAB> return False <TAB> <TAB> if len ( self. versions ) < len ( other. versions ) : <TAB> <TAB> <TAB> return True <TAB> <TAB> if len ( self. versions ) > len ( other. versions ) : <TAB> <TAB> <TAB> return False <TAB> <TAB> <TAB> <TAB> if len ( other. numpart ) > 0 and len ( self. numpart ) == 0 : <TAB> <TAB> <TAB> return False <TAB> <TAB> if len ( self. numpart ) > 0 and len ( other. numpart ) == 0 : <TAB> <TAB> <TAB> return True <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return self. rest < other. rest <TAB> except : <TAB> <TAB> return False",False,self.versions[i] < other.versions[i],self.versions[i] > other.versions[i],0.6519798636436462
|
||
|
3491,"def select ( <TAB> self, tester, do_request, callback = None, select_params = None, byte_range = None ) : <TAB> sql = ""select * from ossobject limit 10"" <TAB> resp_content = b""a,b,c,d,e,f,,n,g,l,o,p"" <TAB> if select_params is not None and ""Json_Type"" in select_params : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> resp_content = b'{contacts:[{""firstName"":""John"", ""lastName"":""Smith""}]}' <TAB> <TAB> else : <TAB> <TAB> <TAB> resp_content = b'{""firstName"":""John"", ""lastName"":""Smith""}' <TAB> output_raw = False <TAB> if ( <TAB> <TAB> select_params is not None <TAB> <TAB> and ""OutputRawData"" in select_params <TAB> <TAB> and select_params [ ""OutputRawData"" ] <TAB> ) : <TAB> <TAB> output_raw = True <TAB> req, resp = make_select_object ( sql, resp_content, select_params, output_raw ) <TAB> req_info = mock_response ( do_request, resp ) <TAB> result = bucket ( ). select_object ( <TAB> <TAB> ""select-test.txt"", sql, callback, select_params, byte_range <TAB> ) <TAB> tester. assertEqual ( result. status, 206 ) <TAB> tester. assertRequest ( req_info, req ) <TAB> if result. status // 100 == 2 : <TAB> <TAB> content = result. read ( ) <TAB> <TAB> tester. assertEqual ( content, resp_content )",False,select_params['Json_Type'] == 'DOCUMENT',contacts,0.6502504348754883
|
||
|
3492,"def PrintFooter ( self ) : <TAB> if self. draw == False : <TAB> <TAB> return <TAB> footer_pos = ( <TAB> <TAB> self. parent. page_height * self. pheight <TAB> <TAB> - self. pfooter_margin <TAB> <TAB> + self. vertical_offset <TAB> ) <TAB> for val in self. parent. footer : <TAB> <TAB> self. SetPrintFont ( val [ ""Font"" ] ) <TAB> <TAB> footer_indent = val [ ""Indent"" ] * self. pwidth <TAB> <TAB> text = val [ ""Text"" ] <TAB> <TAB> ftype = val [ ""Type"" ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> addtext = ""Page "" + str ( self. page ) + "" of "" + str ( self. total_pages ) <TAB> <TAB> elif ftype == ""Page"" : <TAB> <TAB> <TAB> addtext = ""Page "" + str ( self. page ) <TAB> <TAB> elif ftype == ""Num"" : <TAB> <TAB> <TAB> addtext = str ( self. page ) <TAB> <TAB> elif ftype == ""Date"" : <TAB> <TAB> <TAB> addtext = self. GetDate ( ) <TAB> <TAB> elif ftype == ""Date & Time"" : <TAB> <TAB> <TAB> addtext = self. GetDateTime ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> addtext = """" <TAB> <TAB> self. OutTextPageWidth ( <TAB> <TAB> <TAB> text + addtext, footer_pos, val [ ""Align"" ], footer_indent, True <TAB> <TAB> )",False,ftype == 'Pageof',ftype == 'Num',0.6611014604568481
|
||
|
3493,"def test_merge_documents_existing ( self, api_key, endpoint, index_name, ** kwargs ) : <TAB> client = SearchClient ( endpoint, index_name, AzureKeyCredential ( api_key ) ) <TAB> async with client : <TAB> <TAB> results = await client. merge_documents ( <TAB> <TAB> <TAB> [ { ""hotelId"" : ""3"", ""rating"" : 1 }, { ""hotelId"" : ""4"", ""rating"" : 2 } ] <TAB> <TAB> ) <TAB> <TAB> assert len ( results ) == 2 <TAB> <TAB> assert set ( x. status_code for x in results ) == { 200 } <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> time. sleep ( TIME_TO_SLEEP ) <TAB> <TAB> assert await client. get_document_count ( ) == 10 <TAB> <TAB> result = await client. get_document ( key = ""3"" ) <TAB> <TAB> assert result [ ""rating"" ] == 1 <TAB> <TAB> result = await client. get_document ( key = ""4"" ) <TAB> <TAB> assert result [ ""rating"" ] == 2",False,self.is_live,len(results) == 3,0.6547102928161621
|
||
|
3494,"def _getdescriptions ( self, group_pattern, return_all ) : <TAB> line_pat = re. compile ( ""^(?P<group>[^ \t]+)[ \t]+(.*)$"" ) <TAB> <TAB> resp, lines = self. _longcmdstring ( ""LIST NEWSGROUPS "" + group_pattern ) <TAB> if not resp. startswith ( ""215"" ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> resp, lines = self. _longcmdstring ( ""XGTITLE "" + group_pattern ) <TAB> groups = { } <TAB> for raw_line in lines : <TAB> <TAB> match = line_pat. search ( raw_line. strip ( ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> name, desc = match. group ( 1, 2 ) <TAB> <TAB> <TAB> if not return_all : <TAB> <TAB> <TAB> <TAB> return desc <TAB> <TAB> <TAB> groups [ name ] = desc <TAB> if return_all : <TAB> <TAB> return resp, groups <TAB> else : <TAB> <TAB> <TAB> <TAB> return """"",True,match,match,0.6726937294006348
|
||
|
3495,"def isValidDateString ( config_param_name, value, valid_value ) : <TAB> try : <TAB> <TAB> if value == ""DD-MM-YYYY"" : <TAB> <TAB> <TAB> return value <TAB> <TAB> day, month, year = value. split ( ""-"" ) <TAB> <TAB> if int ( day ) < 1 or int ( day ) > 31 : <TAB> <TAB> <TAB> raise DateStringValueError ( config_param_name, value ) <TAB> <TAB> if int ( month ) < 1 or int ( month ) > 12 : <TAB> <TAB> <TAB> raise DateStringValueError ( config_param_name, value ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise DateStringValueError ( config_param_name, value ) <TAB> <TAB> return value <TAB> except Exception : <TAB> <TAB> raise DateStringValueError ( config_param_name, value )",False,int(year) < 1900 or int(year) > 2013,valid_value and value != 'NULL',0.6595080494880676
|
||
|
3496,"def packet ( self, pktid, packet, msg, * args, ** kwargs ) : <TAB> """"""Write a control packet debug log message"""""" <TAB> if self. _debug_level >= 3 : <TAB> <TAB> kwargs. setdefault ( ""extra"", { } ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> kwargs [ ""extra"" ]. update ( context = ""pktid=%d"" % pktid ) <TAB> <TAB> kwargs [ ""extra"" ]. update ( packet = packet ) <TAB> <TAB> self. debug ( msg, * args, ** kwargs )",False,pktid is not None,self._debug_level >= 6,0.6709017157554626
|
||
|
3497,"def _close_cloth ( self, ctx, parent ) : <TAB> rootstack = ctx. protocol. rootstack <TAB> close_until = rootstack. back <TAB> cureltstack = ctx. protocol. eltstack [ close_until ] <TAB> curctxstack = ctx. protocol. ctxstack [ close_until ] <TAB> for elt, elt_ctx in reversed ( tuple ( zip ( cureltstack, curctxstack ) ) ) : <TAB> <TAB> if elt_ctx is not None : <TAB> <TAB> <TAB> self. event_manager. fire_event ( ( ""before_exit"", elt ), ctx, parent ) <TAB> <TAB> <TAB> elt_ctx. __exit__ ( None, None, None ) <TAB> <TAB> <TAB> logger_c. debug ( ""exit %s close"", elt. tag ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> parent. write ( elt. tail ) <TAB> <TAB> for sibl in elt. itersiblings ( preceding = False ) : <TAB> <TAB> <TAB> logger_c. debug ( ""write %s nextsibl"", sibl. tag ) <TAB> <TAB> <TAB> parent. write ( sibl ) <TAB> <TAB> <TAB> if sibl. tail is not None : <TAB> <TAB> <TAB> <TAB> parent. write ( sibl. tail ) <TAB> <TAB> if elt is close_until : <TAB> <TAB> <TAB> logger_c. debug ( ""closed until %r, breaking out"", close_until ) <TAB> <TAB> <TAB> break <TAB> del ctx. protocol. eltstack [ close_until ] <TAB> del ctx. protocol. ctxstack [ close_until ] <TAB> if len ( rootstack ) > 0 : <TAB> <TAB> rootstack. pop ( )",False,elt.tail is not None,parent is not None,0.6612796783447266
|
||
|
3498,"def _get_before_insertion_node ( self ) : <TAB> if self. _nodes_stack. is_empty ( ) : <TAB> <TAB> return None <TAB> line = self. _nodes_stack. parsed_until_line + 1 <TAB> node = self. _new_module. get_last_leaf ( ) <TAB> while True : <TAB> <TAB> parent = node. parent <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> assert node. end_pos [ 0 ] <= line <TAB> <TAB> <TAB> assert node. end_pos [ 1 ] == 0 or ""\n"" in self. _prefix <TAB> <TAB> <TAB> return node <TAB> <TAB> node = parent",False,"parent.type in ('suite', 'file_input')",parent.end_pos is not None and parent.end_pos[1] == line,0.6527286767959595
|
||
|
3499,"def _visit ( self, expr ) : <TAB> if is_scalar_reduction ( expr ) and not has_multiple_bases ( expr ) : <TAB> <TAB> <TAB> <TAB> key = self. _key ( expr ) <TAB> <TAB> if key not in self. memo : <TAB> <TAB> <TAB> agg_expr, name = reduction_to_aggregation ( expr ) <TAB> <TAB> <TAB> self. memo [ key ] = agg_expr, name <TAB> <TAB> <TAB> self. tables. append ( agg_expr ) <TAB> <TAB> else : <TAB> <TAB> <TAB> agg_expr, name = self. memo [ key ] <TAB> <TAB> return agg_expr [ name ] <TAB> elif not isinstance ( expr, ir. Expr ) : <TAB> <TAB> return expr <TAB> node = expr. op ( ) <TAB> subbed_args = [ ] <TAB> for arg in node. args : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> subbed_arg = [ self. _visit ( x ) for x in arg ] <TAB> <TAB> else : <TAB> <TAB> <TAB> subbed_arg = self. _visit ( arg ) <TAB> <TAB> subbed_args. append ( subbed_arg ) <TAB> subbed_node = type ( node ) ( * subbed_args ) <TAB> if isinstance ( expr, ir. ValueExpr ) : <TAB> <TAB> result = expr. _factory ( subbed_node, name = expr. _name ) <TAB> else : <TAB> <TAB> result = expr. _factory ( subbed_node ) <TAB> return result",False,"isinstance(arg, (tuple, list))","isinstance(arg, ir.SubbedArgs)",0.6564469933509827
|
||
|
3500,"def format_outer_frames ( <TAB> context = 5, stack_start = None, stack_end = None, ignore_ipython = True ) : <TAB> LNUM_POS, LINES_POS, INDEX_POS = 2, 4, 5 <TAB> records = inspect. getouterframes ( inspect. currentframe ( ) ) <TAB> output = list ( ) <TAB> for i, ( frame, filename, line_no, func_name, lines, index ) in enumerate ( records ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> better_fn = frame. f_globals. get ( ""__file__"", None ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> filename = better_fn <TAB> <TAB> <TAB> if filename. endswith ( "".pyc"" ) : <TAB> <TAB> <TAB> <TAB> filename = filename [ : - 4 ] + "".py"" <TAB> <TAB> if ignore_ipython : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if os. path. basename ( filename ) in ( <TAB> <TAB> <TAB> <TAB> ""iplib.py"", <TAB> <TAB> <TAB> <TAB> ""py3compat.py"", <TAB> <TAB> <TAB> ) and func_name in ( ""execfile"", ""safe_execfile"", ""runcode"" ) : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> maybe_start = line_no - 1 - context // 2 <TAB> <TAB> start = max ( maybe_start, 0 ) <TAB> <TAB> end = start + context <TAB> <TAB> lines = linecache. getlines ( filename ) [ start : end ] <TAB> <TAB> buf = list ( records [ i ] ) <TAB> <TAB> buf [ LNUM_POS ] = line_no <TAB> <TAB> buf [ INDEX_POS ] = line_no - 1 - start <TAB> <TAB> buf [ LINES_POS ] = lines <TAB> <TAB>",False,"isinstance(better_fn, str)",better_fn,0.6525474786758423
|
||
|
3501,"def copyTokenToRepeater ( s, l, t ) : <TAB> if t : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> rep << t [ 0 ] <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> tflat = _flatten ( t. asList ( ) ) <TAB> <TAB> <TAB> rep << And ( Literal ( tt ) for tt in tflat ) <TAB> else : <TAB> <TAB> rep << Empty ( )",True,len(t) == 1,len(t) == 1,0.6657356023788452
|
||
|
3502,"def _checkout ( self, local_dir ) : <TAB> logger. warning ( <TAB> <TAB> ""The coregen provider is deprecated and will be removed. Consider using a generator for this instead"" <TAB> ) <TAB> script_file = self. config. get ( ""script_file"" ) <TAB> project_file = self. config. get ( ""project_file"" ) <TAB> extra_files = self. config. get ( ""extra_files"" ) <TAB> logger. info ( ""Using Coregen to generate project "" + project_file ) <TAB> if not os. path. isdir ( local_dir ) : <TAB> <TAB> os. makedirs ( local_dir ) <TAB> src_files = [ script_file, project_file ] <TAB> if extra_files : <TAB> <TAB> src_files += extra_files. split ( ) <TAB> for f in src_files : <TAB> <TAB> f_src = os. path. join ( self. core_root, f ) <TAB> <TAB> f_dst = os. path. join ( local_dir, f ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> d_dst = os. path. dirname ( f_dst ) <TAB> <TAB> <TAB> if not os. path. exists ( d_dst ) : <TAB> <TAB> <TAB> <TAB> os. makedirs ( d_dst ) <TAB> <TAB> <TAB> shutil. copyfile ( f_src, f_dst ) <TAB> <TAB> else : <TAB> <TAB> <TAB> logger. error ( ""Cannot find file %s"" % f_src ) <TAB> args = [ ""-r"", ""-b"", script_file, ""-p"", project_file ] <TAB> Launcher ( ""coregen"", args, cwd = local_dir ). run ( )",False,os.path.exists(f_src),os.path.exists(f_dst),0.6492385268211365
|
||
|
3503,"def backward_impl ( self, inputs, outputs, prop_down, accum ) : <TAB> <TAB> <TAB> <TAB> pad_width = self. forward_func. info. args [ ""pad_width"" ] <TAB> mode = self. forward_func. info. args [ ""mode"" ] <TAB> constant_value = self. forward_func. info. args [ ""constant_value"" ] <TAB> <TAB> x0 = inputs [ 0 ]. data <TAB> dy = inputs [ 1 ]. data <TAB> <TAB> dx0 = outputs [ 0 ]. data <TAB> <TAB> g_x0 = inputs [ 0 ]. grad <TAB> g_dy = inputs [ 1 ]. grad <TAB> <TAB> g_dx0 = outputs [ 0 ]. grad <TAB> <TAB> if prop_down [ 1 ] : <TAB> <TAB> g_dy_ = F. pad ( g_dx0, pad_width, mode, constant_value ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> g_dy += g_dy_ <TAB> <TAB> else : <TAB> <TAB> <TAB> g_dy. copy_from ( g_dy_ )",False,accum[1],prop_down[0],0.6616615056991577
|
||
|
3504,"def try_open_completions_event ( self, event = None ) : <TAB> ""(./) Open completion list after pause with no movement."" <TAB> lastchar = self. text. get ( ""insert-1c"" ) <TAB> if lastchar in TRIGGERS : <TAB> <TAB> args = TRY_A if lastchar == ""."" else TRY_F <TAB> <TAB> self. _delayed_completion_index = self. text. index ( ""insert"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. text. after_cancel ( self. _delayed_completion_id ) <TAB> <TAB> self. _delayed_completion_id = self. text. after ( <TAB> <TAB> <TAB> self. popupwait, self. _delayed_open_completions, args <TAB> <TAB> )",False,self._delayed_completion_id is not None,self._delayed_completion_index >= 0,0.6517032384872437
|
||
|
3505,"def log_status_change_thread ( log_queue, request_iterator ) : <TAB> std_handler = StdStreamHandler ( log_queue ) <TAB> current_handler = None <TAB> root_logger = logging. getLogger ( ""ray"" ) <TAB> default_level = root_logger. getEffectiveLevel ( ) <TAB> try : <TAB> <TAB> for req in request_iterator : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> root_logger. setLevel ( default_level ) <TAB> <TAB> <TAB> <TAB> root_logger. removeHandler ( current_handler ) <TAB> <TAB> <TAB> <TAB> std_handler. unregister_global ( ) <TAB> <TAB> <TAB> if not req. enabled : <TAB> <TAB> <TAB> <TAB> current_handler = None <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> current_handler = LogstreamHandler ( log_queue, req. loglevel ) <TAB> <TAB> <TAB> std_handler. register_global ( ) <TAB> <TAB> <TAB> root_logger. addHandler ( current_handler ) <TAB> <TAB> <TAB> root_logger. setLevel ( req. loglevel ) <TAB> except grpc. RpcError as e : <TAB> <TAB> logger. debug ( f""closing log thread "" f""grpc error reading request_iterator: {e}"" ) <TAB> finally : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> root_logger. setLevel ( default_level ) <TAB> <TAB> <TAB> root_logger. removeHandler ( current_handler ) <TAB> <TAB> <TAB> std_handler. unregister_global ( ) <TAB> <TAB> log_queue. put ( None )",False,current_handler is not None,current_handler,0.6581913232803345
|
||
|
3506,"def module_list ( target, fast ) : <TAB> """"""Find the list of modules to be compiled"""""" <TAB> modules = [ ] <TAB> native = native_modules ( target ) <TAB> basedir = os. path. join ( ouroboros_repo_folder ( ), ""ouroboros"" ) <TAB> for name in os. listdir ( basedir ) : <TAB> <TAB> module_name, ext = os. path. splitext ( name ) <TAB> <TAB> if ext == "".py"" or ext == """" and os. path. isdir ( os. path. join ( basedir, name ) ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> if not ( fast and module_name in KNOWN_PROBLEM_MODULES ) : <TAB> <TAB> <TAB> <TAB> <TAB> modules. append ( module_name ) <TAB> return set ( modules )",False,module_name not in IGNORE_MODULES and module_name not in native,native,0.6537770628929138
|
||
|
3507,"def _set_suffix_to_test_databases ( suffix ) : <TAB> from django. conf import settings <TAB> for db_settings in settings. DATABASES. values ( ) : <TAB> <TAB> test_name = db_settings. get ( ""TEST"", { } ). get ( ""NAME"" ) <TAB> <TAB> if not test_name : <TAB> <TAB> <TAB> if db_settings [ ""ENGINE"" ] == ""django.db.backends.sqlite3"" : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> test_name = ""test_{}"". format ( db_settings [ ""NAME"" ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> db_settings. setdefault ( ""TEST"", { } ) <TAB> <TAB> db_settings [ ""TEST"" ] [ ""NAME"" ] = ""{}_{}"". format ( test_name, suffix )",False,test_name == ':memory:',test_name,0.6544523239135742
|
||
|
3508,"def read_line ( self, line ) : <TAB> """"""Read a new line"""""" <TAB> if self. ignore : <TAB> <TAB> return <TAB> <TAB> if ( <TAB> <TAB> not self. is_quoted ( ) <TAB> <TAB> and self. comment is not None <TAB> <TAB> and line. startswith ( self. comment ) <TAB> ) : <TAB> <TAB> return <TAB> self. triple_start = - 1 <TAB> for i, char in enumerate ( line ) : <TAB> <TAB> if char not in [ '""', ""'"" ] : <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> if line [ i - 1 : i ] == ""\\"" : <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. single = None <TAB> <TAB> <TAB> continue <TAB> <TAB> if self. single is not None : <TAB> <TAB> <TAB> continue <TAB> <TAB> if not self. python : <TAB> <TAB> <TAB> continue <TAB> <TAB> if line [ i - 2 : i + 1 ] == 3 * char and i >= self. triple_start + 3 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if self. triple == char : <TAB> <TAB> <TAB> <TAB> self. triple = None <TAB> <TAB> <TAB> <TAB> self. triple_start = i <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if self. triple is not None : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. triple = char <TAB> <TAB> <TAB> self. triple_start = i <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> if self. triple is not None : <TAB> <TAB> <TAB> continue <TAB> <TAB> self. single = char <TAB> <TAB> if self. python : <TAB> <TAB",False,self.single == char,self.ignore,0.6625040173530579
|
||
|
3509,"def _get_job_remap ( self, job ) : <TAB> if job : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> if [ <TAB> <TAB> <TAB> <TAB> <TAB> hda. dependent_jobs <TAB> <TAB> <TAB> <TAB> <TAB> for hda in [ jtod. dataset for jtod in job. output_datasets ] <TAB> <TAB> <TAB> <TAB> <TAB> if hda. dependent_jobs <TAB> <TAB> <TAB> <TAB> ] : <TAB> <TAB> <TAB> <TAB> <TAB> return True <TAB> <TAB> <TAB> <TAB> elif job. output_dataset_collection_instances : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return ""job_produced_collection_elements"" <TAB> <TAB> <TAB> except Exception as exception : <TAB> <TAB> <TAB> <TAB> log. error ( str ( exception ) ) <TAB> return False",False,job.state == job.states.ERROR,self.has_job_dataset_collection_instances,0.6555456519126892
|
||
|
3510,"def leading_whitespace ( self, inputstring ) : <TAB> """"""Get leading whitespace."""""" <TAB> leading_ws = [ ] <TAB> for i, c in enumerate ( inputstring ) : <TAB> <TAB> if c in legal_indent_chars : <TAB> <TAB> <TAB> leading_ws. append ( c ) <TAB> <TAB> else : <TAB> <TAB> <TAB> break <TAB> <TAB> if self. indchar is None : <TAB> <TAB> <TAB> self. indchar = c <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> self. strict_err_or_warn ( ""found mixing of tabs and spaces"", inputstring, i ) <TAB> return """". join ( leading_ws )",False,c != self.indchar,c in legal_indent_chars,0.657207727432251
|
||
|
3511,"def process_static_data ( cls, moves ) : <TAB> ret = { } <TAB> by_type = { } <TAB> by_name = { } <TAB> fast = cls is FastAttacks <TAB> for attack in moves : <TAB> <TAB> attack = Attack ( attack ) if fast else ChargedAttack ( attack ) <TAB> <TAB> ret [ attack. id ] = attack <TAB> <TAB> by_name [ attack. name ] = attack <TAB> <TAB> attack_type = str ( attack. type ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> by_type [ attack_type ] = [ ] <TAB> <TAB> by_type [ attack_type ]. append ( attack ) <TAB> for t in by_type. iterkeys ( ) : <TAB> <TAB> attacks = sorted ( by_type [ t ], key = lambda m : m. dps, reverse = True ) <TAB> <TAB> min_dps = attacks [ - 1 ]. dps <TAB> <TAB> max_dps = attacks [ 0 ]. dps - min_dps <TAB> <TAB> if max_dps > 0.0 : <TAB> <TAB> <TAB> for attack in attacks : <TAB> <TAB> <TAB> <TAB> attack. rate_in_type = ( attack. dps - min_dps ) / max_dps <TAB> <TAB> by_type [ t ] = attacks <TAB> cls. BY_NAME = by_name <TAB> cls. BY_TYPE = by_type <TAB> cls. BY_DPS = sorted ( ret. values ( ), key = lambda m : m. dps, reverse = True ) <TAB> return ret",True,attack_type not in by_type,attack_type not in by_type,0.6561830043792725
|
||
|
3512,"def test_record_quest_from_commands ( play_the_game = False ) : <TAB> M = GameMaker ( ) <TAB> <TAB> commands = [ ""go east"", ""insert ball into chest"" ] <TAB> <TAB> R1 = M. new_room ( ""bedroom"" ) <TAB> R2 = M. new_room ( ""kitchen"" ) <TAB> M. set_player ( R1 ) <TAB> path = M. connect ( R1. east, R2. west ) <TAB> path. door = M. new ( type = ""d"", name = ""wooden door"" ) <TAB> path. door. add_property ( ""open"" ) <TAB> ball = M. new ( type = ""o"", name = ""ball"" ) <TAB> M. inventory. add ( ball ) <TAB> <TAB> chest = M. new ( type = ""c"", name = ""chest"" ) <TAB> chest. add_property ( ""open"" ) <TAB> R2. add ( chest ) <TAB> M. set_quest_from_commands ( commands ) <TAB> game = M. build ( ) <TAB> with make_temp_directory ( prefix = ""test_record_quest_from_commands"" ) as tmpdir : <TAB> <TAB> game_file = _compile_game ( game, folder = tmpdir ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> textworld. play ( game_file ) <TAB> <TAB> else : <TAB> <TAB> <TAB> agent = textworld. agents. WalkthroughAgent ( commands ) <TAB> <TAB> <TAB> textworld. play ( game_file, agent = agent, silent = True )",True,play_the_game,play_the_game,0.6547797918319702
|
||
|
3513,"def _test_markets_exchange ( self, exchange, attempts = 0 ) : <TAB> assets = None <TAB> try : <TAB> <TAB> exchange. init ( ) <TAB> <TAB> <TAB> <TAB> if not exchange. markets : <TAB> <TAB> <TAB> raise ValueError ( ""no markets found"" ) <TAB> <TAB> if not exchange. assets : <TAB> <TAB> <TAB> raise ValueError ( ""no assets derived from markets"" ) <TAB> <TAB> assets = exchange. assets <TAB> except ExchangeRequestError as e : <TAB> <TAB> sleep ( 5 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> handle_exchange_error ( exchange, e ) <TAB> <TAB> else : <TAB> <TAB> <TAB> print ( ""re-trying an exchange request {} {}"". format ( exchange. name, attempts ) ) <TAB> <TAB> <TAB> self. _test_markets_exchange ( exchange, attempts + 1 ) <TAB> except Exception as e : <TAB> <TAB> handle_exchange_error ( exchange, e ) <TAB> return assets",False,attempts > 5,attempts == 0,0.6684436798095703
|
||
|
3514,"def _parse_optical_transition ( elem ) : <TAB> for va in elem. findall ( ""varray"" ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> oscillator_strength = np. array ( _parse_varray ( va ) ) [ <TAB> <TAB> <TAB> <TAB> 0 :, <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> probability_transition = np. array ( _parse_varray ( va ) ) [ 0 :, 1 ] <TAB> return oscillator_strength, probability_transition",False,va.attrib.get('name') == 'opticaltransitions',len(va) > 0,0.6501792669296265
|
||
|
3515,"def close ( self ) : <TAB> if self. _closed : <TAB> <TAB> return <TAB> self. _closed = True <TAB> for proto in self. _pipes. values ( ) : <TAB> <TAB> if proto is None : <TAB> <TAB> <TAB> continue <TAB> <TAB> proto. pipe. close ( ) <TAB> if ( <TAB> <TAB> self. _proc is not None <TAB> <TAB> and <TAB> <TAB> <TAB> <TAB> self. _returncode is None <TAB> <TAB> and <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _proc. poll ( ) is None <TAB> ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> logger. warning ( ""Close running child process: kill %r"", self ) <TAB> <TAB> try : <TAB> <TAB> <TAB> self. _proc. kill ( ) <TAB> <TAB> except ProcessLookupError : <TAB> <TAB> <TAB> pass",False,self._loop.get_debug(),self._proc is not None,0.6547896862030029
|
||
|
3516,"def _toplevelTryFunc ( func, * args, status = status, ** kwargs ) : <TAB> with ThreadProfiler ( threading. current_thread ( ) ) as prof : <TAB> <TAB> t = threading. current_thread ( ) <TAB> <TAB> t. name = func. __name__ <TAB> <TAB> try : <TAB> <TAB> <TAB> t. status = func ( * args, ** kwargs ) <TAB> <TAB> except EscapeException as e : <TAB> <TAB> <TAB> t. status = ""aborted by user"" <TAB> <TAB> <TAB> if status : <TAB> <TAB> <TAB> <TAB> status ( ""%s aborted"" % t. name, priority = 2 ) <TAB> <TAB> except Exception as e : <TAB> <TAB> <TAB> t. exception = e <TAB> <TAB> <TAB> t. status = ""exception"" <TAB> <TAB> <TAB> vd. exceptionCaught ( e ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> t. sheet. currentThreads. remove ( t )",True,t.sheet,t.sheet,0.6659993529319763
|
||
|
3517,"def _errorFields ( <TAB> expression, <TAB> expressionFields, <TAB> expressionFieldsList, <TAB> num = None, <TAB> emptyFields = None, <TAB> suppressOutput = False, ) : <TAB> values = [ ] <TAB> origExpr = None <TAB> threadData = getCurrentThreadData ( ) <TAB> for field in expressionFieldsList : <TAB> <TAB> output = None <TAB> <TAB> if field. startswith ( ""ROWNUM "" ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> if isinstance ( num, int ) : <TAB> <TAB> <TAB> origExpr = expression <TAB> <TAB> <TAB> expression = agent. limitQuery ( <TAB> <TAB> <TAB> <TAB> num, expression, field, expressionFieldsList [ 0 ] <TAB> <TAB> <TAB> ) <TAB> <TAB> if ""ROWNUM"" in expressionFieldsList : <TAB> <TAB> <TAB> expressionReplaced = expression <TAB> <TAB> else : <TAB> <TAB> <TAB> expressionReplaced = expression. replace ( expressionFields, field, 1 ) <TAB> <TAB> output = ( <TAB> <TAB> <TAB> NULL <TAB> <TAB> <TAB> if emptyFields and field in emptyFields <TAB> <TAB> <TAB> else _oneShotErrorUse ( expressionReplaced, field ) <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return None <TAB> <TAB> if not suppressOutput : <TAB> <TAB> <TAB> if kb. fileReadMode and output and output. strip ( ) : <TAB> <TAB> <TAB> <TAB> print <TAB> <TAB> <TAB> elif ( <TAB> <TAB> <TAB> <TAB> output is not None <TAB> <TAB> <TAB> <TAB> and not ( threadData. resumed and kb. suppressResumeInfo ) <TAB> <TAB> <TAB> <TAB> and not ( emptyFields and field in emptyFields ) <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> dataToStdout ( <TAB> <TAB> <TAB> <TAB> <",False,not kb.threadContinue,not origExpr,0.6656907796859741
|
||
|
3518,"def p_load_imm_off ( opval, va, psize = 4 ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> pubwl = ( opval >> 20 ) & 0x1F <TAB> Rn = ( opval >> 16 ) & 0xF <TAB> Rd = ( opval >> 12 ) & 0xF <TAB> imm = opval & 0xFFF <TAB> mnem, opcode = ldr_mnem [ pubwl & 1 ] <TAB> iflags = 0 <TAB> tsize = 4 <TAB> if pubwl & 4 : <TAB> <TAB> iflags = IF_B <TAB> <TAB> tsize = 1 <TAB> if ( pubwl & 0x12 ) == 2 : <TAB> <TAB><mask> : <TAB> if Rd == REG_PC : <TAB> <TAB> iflags |= envi. IF_BRANCH <TAB> if ( opval & 0xFFF0FFF ) == 0x52D0004 : <TAB> <TAB> mnem = ""push"" <TAB> <TAB> olist = ( ArmRegOper ( Rd, va = va ), ) <TAB> elif ( opval & 0xFFF0FFF ) == 0x49D0004 : <TAB> <TAB> mnem = ""pop"" <TAB> <TAB> olist = ( ArmRegOper ( Rd, va = va ), ) <TAB> else : <TAB> <TAB> olist = ( <TAB> <TAB> <TAB> ArmRegOper ( Rd, va = va ), <TAB> <TAB> <TAB> ArmImmOffsetOper ( <TAB> <TAB> <TAB> <TAB> Rn, imm, va, pubwl = pubwl, psize = psize, tsize = tsize <TAB> <TAB> <TAB> ), <TAB> <TAB> ) <TAB> return ( opcode, mnem, olist, iflags, 0 )",False,iflags |= IF_T,opval & 24,0.6639662981033325
|
||
|
3519,"def __init__ ( self ) : <TAB> super ( MultiqcModule, self ). __init__ ( <TAB> <TAB> name = ""Sickle"", <TAB> <TAB> anchor = ""sickle"", <TAB> <TAB> href = ""https://github.com/najoshi/sickle"", <TAB> <TAB> info = ""A windowed adaptive trimming tool for FASTQ files using quality."", <TAB> ) <TAB> <TAB> self. sickle_data = dict ( ) <TAB> for f in self. find_log_files ( ""sickle"" ) : <TAB> <TAB> parsed_data = self. parse_logs ( f [ ""f"" ] ) <TAB> <TAB> if len ( parsed_data ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> log. debug ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Duplicate sample name found! Overwriting: {}"". format ( f [ ""s_name"" ] ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> self. sickle_data [ f [ ""s_name"" ] ] = parsed_data <TAB> <TAB> <TAB> self. add_data_source ( f ) <TAB> self. sickle_data = self. ignore_samples ( self. sickle_data ) <TAB> <TAB> if len ( self. sickle_data ) == 0 : <TAB> <TAB> raise UserWarning <TAB> self. write_data_file ( self. sickle_data, ""multiqc_sickle"" ) <TAB> self. sickle_general_stats_table ( ) <TAB> self. read_count_plot ( )",False,f['s_name'] in self.sickle_data,self.has_sample(f[s_name]),0.6507534384727478
|
||
|
3520,"def get_tests ( args, pkg_path ) : <TAB> """"""Extract test cases given a recipe's meta.yaml file."""""" <TAB> recipes_dir = args. recipes_dir <TAB> tests = [ ] <TAB> input_dir = os. path. dirname ( os. path. join ( recipes_dir, pkg_path ) ) <TAB> recipe_meta = MetaData ( input_dir ) <TAB> tests_commands = recipe_meta. get_value ( ""test/commands"" ) <TAB> tests_imports = recipe_meta. get_value ( ""test/imports"" ) <TAB> requirements = recipe_meta. get_value ( ""requirements/run"" ) <TAB> if tests_imports or tests_commands : <TAB> <TAB> if tests_commands : <TAB> <TAB> <TAB> tests. append ( "" && "". join ( tests_commands ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> tests. append ( <TAB> <TAB> <TAB> <TAB> "" && "". join ( 'python -c ""import %s""' % imp for imp in tests_imports ) <TAB> <TAB> <TAB> ) <TAB> <TAB> elif tests_imports and ( <TAB> <TAB> <TAB> ""perl"" in requirements or ""perl-threaded"" in requirements <TAB> <TAB> ) : <TAB> <TAB> <TAB> tests. append ( <TAB> <TAB> <TAB> <TAB> "" && "". join ( '''perl -e ""use %s;""''' % imp for imp in tests_imports ) <TAB> <TAB> <TAB> ) <TAB> tests = "" && "". join ( tests ) <TAB> tests = tests. replace ( ""$R "", ""Rscript "" ) <TAB> return tests",False,tests_imports and 'python' in requirements,requirements,0.6565852165222168
|
||
|
3521,"def _check_dsl_runner ( self ) -> None : <TAB> """"""Checks if runner in dsl is Kubeflow V2 runner."""""" <TAB> with open ( self. flags_dict [ labels. PIPELINE_DSL_PATH ], ""r"" ) as f : <TAB> <TAB> dsl_contents = f. read ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise RuntimeError ( ""KubeflowV2DagRunner not found in dsl."" )",False,'KubeflowV2DagRunner' not in dsl_contents,not dsl_contents,0.665368914604187
|
||
|
3522,"def u ( v ) : <TAB> if PYTHON3 : <TAB> <TAB> if isinstance ( v, bytes ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return v. decode ( ""utf-8"" ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return v <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> raise Exception ( ""Unknown input type"" ) <TAB> else : <TAB> <TAB> <TAB> <TAB> return v",True,"isinstance(v, str)","isinstance(v, str)",0.6554979085922241
|
||
|
3523,"def _validate_reports ( value, * args, ** kwargs ) : <TAB> from osf. models import OSFUser <TAB> for key, val in value. items ( ) : <TAB> <TAB> if not OSFUser. load ( key ) : <TAB> <TAB> <TAB> raise ValidationValueError ( ""Keys must be user IDs"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValidationTypeError ( ""Values must be dictionaries"" ) <TAB> <TAB> if ( <TAB> <TAB> <TAB> ""category"" not in val <TAB> <TAB> <TAB> or ""text"" not in val <TAB> <TAB> <TAB> or ""date"" not in val <TAB> <TAB> <TAB> or ""retracted"" not in val <TAB> <TAB> ) : <TAB> <TAB> <TAB> raise ValidationValueError ( <TAB> <TAB> <TAB> <TAB> ( ""Values must include `date`, `category`, "", ""`text`, `retracted` keys"" ) <TAB> <TAB> <TAB> )",True,"not isinstance(val, dict)","not isinstance(val, dict)",0.6552532911300659
|
||
|
3524,"def _redirect ( self, chan ) : <TAB> while chan. active : <TAB> <TAB> rqst, _, _ = select ( [ self. request, chan ], [ ], [ ], 5 ) <TAB> <TAB> if self. request in rqst : <TAB> <TAB> <TAB> data = self. request. recv ( 1024 ) <TAB> <TAB> <TAB> if not data : <TAB> <TAB> <TAB> <TAB> self. logger. log ( <TAB> <TAB> <TAB> <TAB> <TAB> TRACE_LEVEL, "">>> OUT {0} recv empty data >>>"". format ( self. info ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> self. logger. log ( <TAB> <TAB> <TAB> <TAB> TRACE_LEVEL, <TAB> <TAB> <TAB> <TAB> "">>> OUT {0} send to {1}: {2} >>>"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> self. info, self. remote_address, hexlify ( data ) <TAB> <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> chan. sendall ( data ) <TAB> <TAB> if chan in rqst : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. logger. log ( <TAB> <TAB> <TAB> <TAB> <TAB> TRACE_LEVEL, ""<<< IN {0} recv is not ready <<<"". format ( self. info ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> data = chan. recv ( 1024 ) <TAB> <TAB> <TAB> self. logger. log ( <TAB> <TAB> <TAB> <TAB> TRACE_LEVEL, ""<<< IN {0} recv: {1} <<<"". format ( self. info, hexlify ( data ) ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> self. request.",False,not chan.recv_ready(),not self.logger,0.660319447517395
|
||
|
3525,"def moveWithinLineHelper ( self, event, spot, extend ) : <TAB> w = self. editWidget ( event ) <TAB> if not w : <TAB> <TAB> return <TAB> <TAB> <TAB> spots = ( ""end-line"", ""finish-line"", ""start-line"" ) <TAB> if hasattr ( w, ""leoMoveCursorHelper"" ) and spot not in spots : <TAB> <TAB> extend = extend or self. extendMode <TAB> <TAB> w. leoMoveCursorHelper ( kind = spot, extend = extend ) <TAB> else : <TAB> <TAB> s = w. getAllText ( ) <TAB> <TAB> ins = w. getInsertPoint ( ) <TAB> <TAB> i, j = g. getLine ( s, ins ) <TAB> <TAB> line = s [ i : j ] <TAB> <TAB> if spot == ""begin-line"" : <TAB> <TAB> <TAB> self. moveToHelper ( event, i, extend = extend ) <TAB> <TAB> elif spot == ""end-line"" : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if g. match ( s, j - 1, ""\n"" ) : <TAB> <TAB> <TAB> <TAB> j -= 1 <TAB> <TAB> <TAB> self. moveToHelper ( event, j, extend = extend ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> if not line. isspace ( ) : <TAB> <TAB> <TAB> <TAB> if g. match ( s, j - 1, ""\n"" ) : <TAB> <TAB> <TAB> <TAB> <TAB> j -= 1 <TAB> <TAB> <TAB> <TAB> while j >= 0 and s [ j ]. isspace ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> j -= 1 <TAB> <TAB> <TAB> self. moveToHelper ( event, j, extend = extend ) <TAB> <TAB> elif spot == ""start-line"" : <TAB> <TAB> <TAB> if not line. isspace ( ) : <TAB> <TAB> <TAB> <TAB> while i < j and",False,spot == 'finish-line',spot == 'start-line',0.66028892993927
|
||
|
3526,"def _sync_get ( self, identifier, * args, ** kw ) : <TAB> self. _mutex. acquire ( ) <TAB> try : <TAB> <TAB> try : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return self. _values [ identifier ] <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. _values [ identifier ] = value = self. creator ( identifier, * args, ** kw ) <TAB> <TAB> <TAB> <TAB> return value <TAB> <TAB> except KeyError : <TAB> <TAB> <TAB> self. _values [ identifier ] = value = self. creator ( identifier, * args, ** kw ) <TAB> <TAB> <TAB> return value <TAB> finally : <TAB> <TAB> self. _mutex. release ( )",False,identifier in self._values,self.has_get(identifier),0.6636478900909424
|
||
|
3527,"def next_part_utts ( self, part_size ) : <TAB> """"""Return next part of utts."""""" <TAB> if self. select_by_spk : <TAB> <TAB> <TAB> <TAB> for index in range ( part_size ) : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> spk = self. spk_keys. pop ( ) <TAB> <TAB> <TAB> except IndexError : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> spk_utts = self. meta. spks [ spk ]. utts <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> random_idx = random. randint ( 0, len ( spk_utts ) - 1 ) <TAB> <TAB> <TAB> if random_idx < 0 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> utt_key = spk_utts [ random_idx ] <TAB> <TAB> <TAB> utt_meta = self. meta. utts [ utt_key ] <TAB> <TAB> <TAB> yield ( utt_key, utt_meta ) <TAB> else : <TAB> <TAB> <TAB> <TAB> for index in range ( part_size ) : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> utt_key = self. utt_keys. pop ( ) <TAB> <TAB> <TAB> except IndexError : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> utt_meta = self. meta. utts [ utt_key ] <TAB> <TAB> <TAB> yield ( utt_key, utt_meta )",False,not spk_utts,utt_utts,0.6674712300300598
|
||
|
3528,"def update_encodings ( self, force_utf8 = False ) : <TAB> if self. ui. write_id3v23. isChecked ( ) : <TAB> <TAB> if self. ui. enc_utf8. isChecked ( ) : <TAB> <TAB> <TAB> self. ui. enc_utf16. setChecked ( True ) <TAB> <TAB> self. ui. enc_utf8. setEnabled ( False ) <TAB> <TAB> self. ui. label_id3v23_join_with. setEnabled ( True ) <TAB> <TAB> self. ui. id3v23_join_with. setEnabled ( True ) <TAB> else : <TAB> <TAB> self. ui. enc_utf8. setEnabled ( True ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. ui. enc_utf8. setChecked ( True ) <TAB> <TAB> self. ui. label_id3v23_join_with. setEnabled ( False ) <TAB> <TAB> self. ui. id3v23_join_with. setEnabled ( False )",True,force_utf8,force_utf8,0.6653125286102295
|
||
|
3529,"def build_json_schema_object ( cls, parent_builder = None ) : <TAB> builder = builders. ObjectBuilder ( cls, parent_builder ) <TAB> if builder. count_type ( builder. type ) > 1 : <TAB> <TAB> return builder <TAB> for _, name, field in cls. iterate_with_name ( ) : <TAB> <TAB> if isinstance ( field, fields. EmbeddedField ) : <TAB> <TAB> <TAB> builder. add_field ( name, field, _parse_embedded ( field, builder ) ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> builder. add_field ( name, field, _parse_list ( field, builder ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> builder. add_field ( name, field, _create_primitive_field_schema ( field ) ) <TAB> return builder",True,"isinstance(field, fields.ListField)","isinstance(field, fields.ListField)",0.6506459712982178
|
||
|
3530,"def main ( ) : <TAB> app = QApplication ( sys. argv ) <TAB> app. setOrganizationName ( ""ReText project"" ) <TAB> app. setApplicationName ( ""ReText"" ) <TAB> if hasattr ( app, ""setApplicationDisplayName"" ) : <TAB> <TAB> app. setApplicationDisplayName ( ""ReText"" ) <TAB> RtTranslator = QTranslator ( ) <TAB> for path in datadirs : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> break <TAB> QtTranslator = QTranslator ( ) <TAB> QtTranslator. load ( <TAB> <TAB> ""qt_"" + QLocale. system ( ). name ( ), <TAB> <TAB> QLibraryInfo. location ( QLibraryInfo. TranslationsPath ), <TAB> ) <TAB> app. installTranslator ( RtTranslator ) <TAB> app. installTranslator ( QtTranslator ) <TAB> if globalSettings. appStyleSheet : <TAB> <TAB> sheetfile = QFile ( globalSettings. appStyleSheet ) <TAB> <TAB> sheetfile. open ( QIODevice. ReadOnly ) <TAB> <TAB> app. setStyleSheet ( QTextStream ( sheetfile ). readAll ( ) ) <TAB> <TAB> sheetfile. close ( ) <TAB> <TAB> webSettings = QWebSettings. globalSettings ( ) <TAB> webSettings. setFontFamily ( QWebSettings. FixedFont, ""monospace"" ) <TAB> window = ReTextWindow ( ) <TAB> window. show ( ) <TAB> fileNames = [ QFileInfo ( arg ). canonicalFilePath ( ) for arg in sys. argv [ 1 : ] ] <TAB> for fileName in fileNames : <TAB> <TAB> if QFile. exists ( fileName ) : <TAB> <TAB> <TAB> window. openFileWrapper ( fileName ) <TAB> signal. signal ( signal. SIGINT, lambda sig, frame : window. close ( ) ) <TAB> sys. exit ( app. exec_ ( ) )",False,"RtTranslator.load('retext_' + QLocale.system().name(), path + '/locale')",QFile.exists(path),0.6528704166412354
|
||
|
3531,"def __call__ ( self, name = None ) : <TAB> with self. _cache_lock : <TAB> <TAB> rv = self. __instances. get ( name, None ) <TAB> <TAB> if rv is None : <TAB> <TAB> <TAB> rv = self. nocache ( name = name ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. __instances [ name ] = rv <TAB> return rv",False,"not (name is None or isinstance(rv, tzlocal_classes))",rv,0.652646541595459
|
||
|
3532,"def get_comment_thumbnail ( self, comment ) : <TAB> try : <TAB> <TAB> x = int ( comment. extra_data [ ""x"" ] ) <TAB> <TAB> y = int ( comment. extra_data [ ""y"" ] ) <TAB> <TAB> width = int ( comment. extra_data [ ""width"" ] ) <TAB> <TAB> height = int ( comment. extra_data [ ""height"" ] ) <TAB> except ( KeyError, ValueError ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return None <TAB> image_url = crop_image ( comment. file_attachment. file, x, y, width, height ) <TAB> if not urlparse ( image_url ). netloc : <TAB> <TAB> image_url = build_server_url ( image_url ) <TAB> image_html = ( <TAB> <TAB> '<img class=""modified-image"" src=""%s"" width=""%s"" height=""%s""'<TAB> <TAB> 'alt=""%s"" />' % ( image_url, width, height, escape ( comment. text ) ) <TAB> ) <TAB> if comment. diff_against_file_attachment_id : <TAB> <TAB> diff_against_image_url = crop_image ( <TAB> <TAB> <TAB> comment. diff_against_file_attachment. file, x, y, width, height <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> diff_against_image_url = build_server_url ( diff_against_image_url ) <TAB> <TAB> diff_against_image_html = ( <TAB> <TAB> <TAB> '<img class=""orig-image"" src=""%s"" width=""%s""'<TAB> <TAB> <TAB> 'height=""%s"" alt=""%s"" />' <TAB> <TAB> <TAB> % ( diff_against_image_url, width, height, escape ( comment. text ) ) <TAB> <TAB> ) <TAB> <TAB> return '<div class=""image-review-ui-diff-thumbnail"">%s%s</div>' % ( <TAB> <TAB> <TAB",False,not urlparse(diff_against_image_url).netloc,not self.get_has_thumbnail(),0.6465672254562378
|
||
|
3533,"def run ( self ) : <TAB> """"""Get the downloaded and/or snatched history"""""" <TAB> data = History ( ). get ( self. limit, self. type ) <TAB> results = [ ] <TAB> for row in data : <TAB> <TAB> status, quality = Quality. split_composite_status ( int ( row [ ""action"" ] ) ) <TAB> <TAB> status = _get_status_strings ( status ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> row [ ""status"" ] = status <TAB> <TAB> row [ ""quality"" ] = get_quality_string ( quality ) <TAB> <TAB> row [ ""date"" ] = row [ ""date"" ]. strftime ( dateTimeFormat ) <TAB> <TAB> del row [ ""action"" ] <TAB> <TAB> row [ ""indexerid"" ] = row. pop ( ""show_id"" ) <TAB> <TAB> row [ ""resource_path"" ] = os. path. dirname ( row [ ""resource"" ] ) <TAB> <TAB> row [ ""resource"" ] = os. path. basename ( row [ ""resource"" ] ) <TAB> <TAB> <TAB> <TAB> row [ ""tvdbid"" ] = row [ ""indexerid"" ] <TAB> <TAB> results. append ( row ) <TAB> return await _responds ( RESULT_SUCCESS, results )",False,self.type and (not status.lower() == self.type),len(status) < 6,0.6507427096366882
|
||
|
3534,"def replacefunc ( elt ) : <TAB> text = elt. attrib [ ""href"" ] <TAB> if link_type ( text )!= ""page"" : <TAB> <TAB> raise zim. formats. VisitorSkip <TAB> href = HRef. new_from_wiki_link ( text ) <TAB> if href. rel == HREF_REL_RELATIVE : <TAB> <TAB> raise zim. formats. VisitorSkip <TAB> elif href. rel == HREF_REL_ABSOLUTE : <TAB> <TAB> oldtarget = self. pages. resolve_link ( page, href ) <TAB> <TAB> if oldtarget == oldroot : <TAB> <TAB> <TAB> return self. _update_link_tag ( elt, page, newroot, href ) <TAB> <TAB> elif oldtarget. ischild ( oldroot ) : <TAB> <TAB> <TAB> newtarget = newroot + oldtarget. relname ( oldroot ) <TAB> <TAB> <TAB> return self. _update_link_tag ( elt, page, newtarget, href ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise zim. formats. VisitorSkip <TAB> else : <TAB> <TAB> assert href. rel == HREF_REL_FLOATING <TAB> <TAB> newtarget = self. pages. resolve_link ( page, href ) <TAB> <TAB> oldtarget = self. pages. resolve_link ( oldpath, href ) <TAB> <TAB> if oldtarget == oldroot : <TAB> <TAB> <TAB> return self. _update_link_tag ( elt, page, newroot, href ) <TAB> <TAB> elif oldtarget. ischild ( oldroot ) : <TAB> <TAB> <TAB> oldanchor = self. pages. resolve_link ( <TAB> <TAB> <TAB> <TAB> oldpath, HRef ( HREF_REL_FLOATING, href. parts ( ) [ 0 ] ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if oldanchor. ischild ( oldroot ) : <TAB> <TAB> <TAB> <TAB> raise zim. formats. VisitorSkip <TAB> <TAB> <TAB> else :",False,newtarget != oldtarget,target.root(),0.6791239976882935
|
||
|
3535,"def get_all_plugins_source ( self ) : <TAB> plugins_path = os. path. join ( ROOT_PATH, ""plugins"" ) <TAB> vuln_template_path = os. path. join ( ROOT_PATH, ""core"", ""data"", ""kb"", ""vuln_templates"" ) <TAB> all_plugin_sources = """" <TAB> for dir_name, subdir_list, file_list in os. walk ( plugins_path ) : <TAB> <TAB> if dir_name in ( ""test"", ""tests"" ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> for fname in file_list : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if fname. startswith ( ""test_"" ) : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if fname == ""__init__.py"" : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> full_path = os. path. join ( plugins_path, dir_name, fname ) <TAB> <TAB> <TAB> ignores = { ""/attack/db/sqlmap/"", ""/attack/payloads/"", ""/plugins/tests/"" } <TAB> <TAB> <TAB> should_continue = False <TAB> <TAB> <TAB> for ignore in ignores : <TAB> <TAB> <TAB> <TAB> if ignore in full_path : <TAB> <TAB> <TAB> <TAB> <TAB> should_continue = True <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> if should_continue : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> all_plugin_sources += file ( full_path ). read ( ) <TAB> for dir_name, subdir_list, file_list in os. walk ( vuln_template_path ) : <TAB> <TAB> for fname in file_list : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB",False,not fname.endswith('.py'),fname.startswith('__init__.py'),0.644178032875061
|
||
|
3536,"def main ( ) : <TAB> nb_checked = 0 <TAB> augs = iaa. SomeOf ( <TAB> <TAB> ( 1, None ), <TAB> <TAB> [ <TAB> <TAB> <TAB> iaa. Resize ( { ""height"" : ( 1, 100 ), ""width"" : ( 1, 100 ) } ), <TAB> <TAB> <TAB> iaa. Affine ( <TAB> <TAB> <TAB> <TAB> scale = ( 0.01, 2.0 ), <TAB> <TAB> <TAB> <TAB> rotate = ( - 360, 360 ), <TAB> <TAB> <TAB> <TAB> shear = ( - 360, 360 ), <TAB> <TAB> <TAB> <TAB> translate_px = { ""x"" : ( - 50, 50 ), ""y"" : ( - 50, 50 ) }, <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> iaa. PerspectiveTransform ( ( 0.01, 0.2 ) ), <TAB> <TAB> ], <TAB> ) <TAB> height, width = 100, 200 <TAB> while True : <TAB> <TAB> poly = create_random_polygon ( height, width, nb_checked ) <TAB> <TAB> psoi = PolygonsOnImage ( [ poly ], shape = ( height, width, 3 ) ) <TAB> <TAB> psoi_aug = augs. augment_polygons ( psoi ) <TAB> <TAB> if not poly. is_valid or not psoi_aug. polygons [ 0 ]. is_valid : <TAB> <TAB> <TAB> print ( ""poly: "", poly, poly. is_valid ) <TAB> <TAB> <TAB> print ( ""poly_aug: "", psoi_aug. polygons [ 0 ], psoi_aug. polygons [ 0 ]. is_valid ) <TAB> <TAB> assert poly. is_valid <TAB> <TAB> assert psoi_aug. polygons [ 0 ]. is_valid <TAB> <TAB> nb_checked += 1 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> print ( ""Checked",False,nb_checked % 100 == 0,nb_checked > 3,0.6664198637008667
|
||
|
3537,"def poll_subprocess ( self ) : <TAB> clt = self. rpcclt <TAB> if clt is None : <TAB> <TAB> return <TAB> try : <TAB> <TAB> response = clt. pollresponse ( self. active_seq, wait = 0.05 ) <TAB> except ( EOFError, IOError, KeyboardInterrupt ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if self. tkconsole. closing : <TAB> <TAB> <TAB> return <TAB> <TAB> response = None <TAB> <TAB> self. restart_subprocess ( ) <TAB> if response : <TAB> <TAB> self. tkconsole. resetoutput ( ) <TAB> <TAB> self. active_seq = None <TAB> <TAB> how, what = response <TAB> <TAB> console = self. tkconsole. console <TAB> <TAB> if how == ""OK"" : <TAB> <TAB> <TAB> if what is not None : <TAB> <TAB> <TAB> <TAB> print >> console, repr ( what ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> if self. tkconsole. getvar ( ""<<toggle-jit-stack-viewer>>"" ) : <TAB> <TAB> <TAB> <TAB> self. remote_stack_viewer ( ) <TAB> <TAB> elif how == ""ERROR"" : <TAB> <TAB> <TAB> errmsg = ""PyShell.ModifiedInterpreter: Subprocess ERROR:\n"" <TAB> <TAB> <TAB> print >> sys. __stderr__, errmsg, what <TAB> <TAB> <TAB> print >> console, errmsg, what <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> self. tkconsole. endexecuting ( ) <TAB> <TAB> except AttributeError : <TAB> <TAB> <TAB> pass <TAB> <TAB> if not self. tkconsole. closing : <TAB> <TAB> self. tkconsole. text. after ( self. tkconsole. pollinterval, self. poll_subprocess )",False,how == 'EXCEPTION',"how == ""ZERO_STACK'",0.6686041355133057
|
||
|
3538,"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 == 18 : <TAB> <TAB> <TAB> self. set_data ( d. getPrefixedString ( ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if tt == 24 : <TAB> <TAB> <TAB> self. set_stream_offset ( d. getVarInt64 ( ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if tt == 32 : <TAB> <TAB> <TAB> self. set_flags ( d. getVarInt32 ( ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if tt == 42 : <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_send_to ( ). TryMerge ( tmp ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. set_timeout_seconds ( d. getDouble ( ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if tt == 0 : <TAB> <TAB> <TAB> raise ProtocolBuffer. ProtocolBufferDecodeError <TAB> <TAB> d. skipData ( tt )",False,tt == 49,tt == 1,0.6955125331878662
|
||
|
3539,"def test_error_stream ( environ, start_response ) : <TAB> writer = start_response ( ""200 OK"", [ ] ) <TAB> wsgi_errors = environ [ ""wsgi.errors"" ] <TAB> error_msg = None <TAB> for method in [ <TAB> <TAB> ""flush"", <TAB> <TAB> ""write"", <TAB> <TAB> ""writelines"", <TAB> ] : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> error_msg = ""wsgi.errors has no '%s' attr"" % method <TAB> <TAB> if not error_msg and not callable ( getattr ( wsgi_errors, method ) ) : <TAB> <TAB> <TAB> error_msg = ""wsgi.errors.%s attr is not callable"" % method <TAB> <TAB> if error_msg : <TAB> <TAB> <TAB> break <TAB> return_msg = error_msg or ""success"" <TAB> writer ( return_msg ) <TAB> return [ ]",False,"not hasattr(wsgi_errors, method)",method in wsgi_errors,0.6513174772262573
|
||
|
3540,"def _construct_train_dsl ( self ) : <TAB> self. _train_dsl [ ""components"" ] = { } <TAB> for name, component in self. _components. items ( ) : <TAB> <TAB> component_dsl = { ""module"" : component. module } <TAB> <TAB> if name in self. _components_input : <TAB> <TAB> <TAB> component_dsl [ ""input"" ] = self. _components_input [ name ] <TAB> <TAB> if hasattr ( component, ""output"" ) : <TAB> <TAB> <TAB> component_dsl [ ""output"" ] = { } <TAB> <TAB> <TAB> if hasattr ( component. output, ""data_output"" ) : <TAB> <TAB> <TAB> <TAB> component_dsl [ ""output"" ] [ ""data"" ] = component. output. data_output <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> component_dsl [ ""output"" ] [ ""model"" ] = component. output. model_output <TAB> <TAB> self. _train_dsl [ ""components"" ] [ name ] = component_dsl <TAB> if not self. _train_dsl : <TAB> <TAB> raise ValueError ( ""there are no components to train"" ) <TAB> LOGGER. debug ( f""train_dsl: {self._train_dsl}"" )",False,"hasattr(component.output, 'model')","hasattr(component.output, 'model_output')",0.6484242081642151
|
||
|
3541,"def addPythonModules ( self ) : <TAB> self. message ( ""Adding Python modules"", 1 ) <TAB> if self. use_zipimport : <TAB> <TAB> <TAB> <TAB> import zipfile <TAB> <TAB> relpath = pathjoin ( ""Contents"", ""Resources"", ZIP_ARCHIVE ) <TAB> <TAB> abspath = pathjoin ( self. bundlepath, relpath ) <TAB> <TAB> zf = zipfile. ZipFile ( abspath, ""w"", zipfile. ZIP_DEFLATED ) <TAB> <TAB> for name, code, ispkg in self. pymodules : <TAB> <TAB> <TAB> self. message ( ""Adding Python module %s"" % name, 2 ) <TAB> <TAB> <TAB> path, pyc = getPycData ( name, code, ispkg ) <TAB> <TAB> <TAB> zf. writestr ( path, pyc ) <TAB> <TAB> zf. close ( ) <TAB> <TAB> <TAB> <TAB> sitepath = pathjoin ( self. bundlepath, ""Contents"", ""Resources"", ""site"" + PYC_EXT ) <TAB> <TAB> writePyc ( self. _getSiteCode ( ), sitepath ) <TAB> else : <TAB> <TAB> <TAB> <TAB> for name, code, ispkg in self. pymodules : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> name += "".__init__"" <TAB> <TAB> <TAB> path = name. split ( ""."" ) <TAB> <TAB> <TAB> path = pathjoin ( ""Contents"", ""Resources"", * path ) + PYC_EXT <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. message ( ""Adding Python package %s"" % path, 2 ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. message ( ""Adding Python module %s"" % path, 2 ) <TAB> <TAB> <TAB> abspath = pathjoin ( self. bundlepath, path ) <TAB> <TAB> <TAB> makedirs ( os. path. dirname ( abspath ) ) <TAB> <TAB",False,ispkg,PYC_EXT,0.6844816207885742
|
||
|
3542,"def ProcessStringLiteral ( self ) : <TAB> if self. _lastToken == None or self. _lastToken. type == self. OpenBrace : <TAB> <TAB> text = super ( JavaScriptBaseLexer, self ). text <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if len ( self. _scopeStrictModes ) > 0 : <TAB> <TAB> <TAB> <TAB> self. _scopeStrictModes. pop ( ) <TAB> <TAB> <TAB> self. _useStrictCurrent = True <TAB> <TAB> <TAB> self. _scopeStrictModes. append ( self. _useStrictCurrent )",False,"text == '""use strict""' or text == ""'use strict'""",text == '',0.6557522416114807
|
||
|
3543,"def _handle_autocomplete_request_for_text ( text ) : <TAB> if not hasattr ( text, ""autocompleter"" ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if isinstance ( text, CodeViewText ) : <TAB> <TAB> <TAB> <TAB> text. autocompleter = Completer ( text ) <TAB> <TAB> <TAB> elif isinstance ( text, ShellText ) : <TAB> <TAB> <TAB> <TAB> text. autocompleter = ShellCompleter ( text ) <TAB> <TAB> <TAB> text. bind ( ""<1>"", text. autocompleter. on_text_click ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return <TAB> text. autocompleter. handle_autocomplete_request ( )",False,"isinstance(text, (CodeViewText, ShellText)) and text.is_python_text()",text.autocomplete_request is False,0.6501612067222595
|
||
|
3544,"def setUpModule ( ) : <TAB> try : <TAB> <TAB> with open ( ""tests.json"", ""r"" ) as tests_fp : <TAB> <TAB> <TAB> DB_OVERRIDES. update ( json. load ( tests_fp ) ) <TAB> except FileNotFoundError : <TAB> <TAB> print ( ""'tests.json' file not found, will use defaults"" ) <TAB> if not aiopg : <TAB> <TAB> print ( ""aiopg is not installed, ignoring PostgreSQL tests"" ) <TAB> <TAB> for key in list ( DB_CLASSES. keys ( ) ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> DB_CLASSES. pop ( key ) <TAB> if not aiomysql : <TAB> <TAB> print ( ""aiomysql is not installed, ignoring MySQL tests"" ) <TAB> <TAB> for key in list ( DB_CLASSES. keys ( ) ) : <TAB> <TAB> <TAB> if key. startswith ( ""mysql"" ) : <TAB> <TAB> <TAB> <TAB> DB_CLASSES. pop ( key ) <TAB> loop = asyncio. new_event_loop ( ) <TAB> all_databases = load_databases ( only = None ) <TAB> for key, database in all_databases. items ( ) : <TAB> <TAB> connect = database. connect_async ( loop = loop ) <TAB> <TAB> loop. run_until_complete ( connect ) <TAB> <TAB> if database. _async_conn is not None : <TAB> <TAB> <TAB> disconnect = database. close_async ( ) <TAB> <TAB> <TAB> loop. run_until_complete ( disconnect ) <TAB> <TAB> else : <TAB> <TAB> <TAB> print ( ""Can't setup connection for %s"" % key ) <TAB> <TAB> <TAB> DB_CLASSES. pop ( key )",False,key.startswith('postgres'),key.startswith('mysql'),0.6501309871673584
|
||
|
3545,"def get_path ( current_path, initial_path ) : <TAB> <TAB> if not self. _path_exists ( current_path ) and not os. path. isabs ( initial_path ) : <TAB> <TAB> new_path = self. _in_root_dir ( initial_path ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> resolves_to = self. schema. paths_to_resolve. get ( key ) <TAB> <TAB> <TAB> log. warning ( <TAB> <TAB> <TAB> <TAB> ""Paths for the '{0}' option should be relative to '{1}'. To suppress this warning, "" <TAB> <TAB> <TAB> <TAB> ""move '{0}' into '{1}', or set it's value to an absolute path."". format ( <TAB> <TAB> <TAB> <TAB> <TAB> key, resolves_to <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> return new_path <TAB> return current_path",False,self._path_exists(new_path),new_path is not None,0.6529514789581299
|
||
|
3546,"def forget_old_txs ( ) : <TAB> new_known_txs = { } <TAB> if self. p2p_node is not None : <TAB> <TAB> for peer in self. p2p_node. peers. itervalues ( ) : <TAB> <TAB> <TAB> new_known_txs. update ( peer. remembered_txs ) <TAB> new_known_txs. update ( self. mining_txs_var. value ) <TAB> for share in self. tracker. get_chain ( <TAB> <TAB> self. best_share_var. value, <TAB> <TAB> min ( 120, self. tracker. get_height ( self. best_share_var. value ) ), <TAB> ) : <TAB> <TAB> for tx_hash in share. new_transaction_hashes : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> new_known_txs [ tx_hash ] = self. known_txs_var. value [ tx_hash ] <TAB> self. known_txs_var. set ( new_known_txs )",True,tx_hash in self.known_txs_var.value,tx_hash in self.known_txs_var.value,0.6525777578353882
|
||
|
3547,"def get_class_name ( item ) : <TAB> class_name, module_name = None, None <TAB> for parent in reversed ( item. listchain ( ) ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> class_name = parent. name <TAB> <TAB> elif isinstance ( parent, pytest. Module ) : <TAB> <TAB> <TAB> module_name = parent. module. __name__ <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if class_name and "".tasks."" not in module_name : <TAB> <TAB> return ""{}.{}"". format ( module_name, class_name ) <TAB> else : <TAB> <TAB> return module_name",False,"isinstance(parent, pytest.Class)","isinstance(parent, pytest.Name)",0.6493468880653381
|
||
|
3548,"def _test_flow_unmatching_check ( self, before_stats, pkt ) : <TAB> <TAB> rcv_msgs = self. _test_get_match_count ( ) <TAB> lookup = False <TAB> for target_tbl_id in pkt [ KEY_TBL_MISS ] : <TAB> <TAB> before = before_stats [ target_tbl_id ] <TAB> <TAB> after = rcv_msgs [ target_tbl_id ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> lookup = True <TAB> <TAB> <TAB> if before [ ""matched"" ] < after [ ""matched"" ] : <TAB> <TAB> <TAB> <TAB> raise TestFailure ( self. state ) <TAB> if not lookup : <TAB> <TAB> raise TestError ( self. state )",False,before['lookup'] < after['lookup'],before and after,0.6524045467376709
|
||
|
3549,"def parseImpl ( self, instring, loc, doActions = True ) : <TAB> <TAB> <TAB> loc, resultlist = self. exprs [ 0 ]. _parse ( instring, loc, doActions, callPreParse = False ) <TAB> errorStop = False <TAB> for e in self. exprs [ 1 : ] : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> errorStop = True <TAB> <TAB> <TAB> continue <TAB> <TAB> if errorStop : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> loc, exprtokens = e. _parse ( instring, loc, doActions ) <TAB> <TAB> <TAB> except ParseSyntaxException : <TAB> <TAB> <TAB> <TAB> raise <TAB> <TAB> <TAB> except ParseBaseException as pe : <TAB> <TAB> <TAB> <TAB> pe. __traceback__ = None <TAB> <TAB> <TAB> <TAB> raise ParseSyntaxException ( pe ) <TAB> <TAB> <TAB> except IndexError : <TAB> <TAB> <TAB> <TAB> raise ParseSyntaxException ( <TAB> <TAB> <TAB> <TAB> <TAB> ParseException ( instring, len ( instring ), self. errmsg, self ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> loc, exprtokens = e. _parse ( instring, loc, doActions ) <TAB> <TAB> if exprtokens or exprtokens. haskeys ( ) : <TAB> <TAB> <TAB> resultlist += exprtokens <TAB> return loc, resultlist",False,"isinstance(e, And._ErrorStop)",callPreParse,0.6523852944374084
|
||
|
3550,"def ParseMultiple ( self, result_dicts ) : <TAB> """"""Parse WMI Event Consumers."""""" <TAB> for result_dict in result_dicts : <TAB> <TAB> wmi_dict = result_dict. ToDict ( ) <TAB> <TAB> try : <TAB> <TAB> <TAB> creator_sid_bytes = bytes ( wmi_dict [ ""CreatorSID"" ] ) <TAB> <TAB> <TAB> wmi_dict [ ""CreatorSID"" ] = BinarySIDtoStringSID ( creator_sid_bytes ) <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> wmi_dict [ ""CreatorSID"" ] = compatibility. Repr ( wmi_dict [ ""CreatorSID"" ] ) <TAB> <TAB> except KeyError : <TAB> <TAB> <TAB> pass <TAB> <TAB> for output_type in self. output_types : <TAB> <TAB> <TAB> anomalies = [ ] <TAB> <TAB> <TAB> output = rdfvalue. RDFValue. classes [ output_type. __name__ ] ( ) <TAB> <TAB> <TAB> for k, v in wmi_dict. items ( ) : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> output. Set ( k, v ) <TAB> <TAB> <TAB> <TAB> except AttributeError as e : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> anomalies. append ( ""Unknown field %s, with value %s"" % ( k, v ) ) <TAB> <TAB> <TAB> <TAB> except ValueError as e : <TAB> <TAB> <TAB> <TAB> <TAB> anomalies. append ( ""Invalid value %s for field %s: %s"" % ( v, k, e ) ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if anomalies : <TAB> <TAB> <TAB> <TAB> yield rdf_anomaly. Anomaly ( <TAB> <TAB> <TAB> <TAB> <TAB> type =",False,wmi_dict and (not output),self.type == 'wmi_event_consumers',0.6525367498397827
|
||
|
3551,"def depart_title ( self, node ) : <TAB> close_tag = self. context [ - 1 ] <TAB> if ( <TAB> <TAB> self. add_permalinks <TAB> <TAB> and self. builder. add_permalinks <TAB> <TAB> and node. parent. hasattr ( ""ids"" ) <TAB> <TAB> and node. parent [ ""ids"" ] <TAB> ) : <TAB> <TAB> aname = node. parent [ ""ids"" ] [ 0 ] <TAB> <TAB> <TAB> <TAB> if close_tag. startswith ( ""</h"" ) : <TAB> <TAB> <TAB> self. body. append ( <TAB> <TAB> <TAB> <TAB> u'<a class=""headerlink"" href=""#%s""'% aname <TAB> <TAB> <TAB> <TAB> + u'title=""%s"">\u00B6</a>' % _ ( ""Permalink to this headline"" ) <TAB> <TAB> <TAB> ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> self. body. append ( <TAB> <TAB> <TAB> <TAB> u'</a><a class=""headerlink"" href=""#%s""'% aname <TAB> <TAB> <TAB> <TAB> + u'title=""%s"">\u00B6' % _ ( ""Permalink to this headline"" ) <TAB> <TAB> <TAB> ) <TAB> BaseTranslator. depart_title ( self, node )",False,close_tag.startswith('</a></h'),close_tag.startswith(TAB),0.6609640121459961
|
||
|
3552,"def call_matching_arguments ( function, arguments, allow_unused = False ) : <TAB> signature = inspect. signature ( function ) <TAB> arguments = copy. deepcopy ( arguments ) <TAB> kwargs = { } <TAB> for name, info in signature. parameters. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> kwargs [ name ] = arguments [ name ] <TAB> <TAB> <TAB> del arguments [ name ] <TAB> <TAB> <TAB> continue <TAB> <TAB> if info. default is not inspect. Parameter. empty : <TAB> <TAB> <TAB> kwargs [ name ] = info. default <TAB> <TAB> <TAB> continue <TAB> <TAB> raise ConfigError ( ""Need a value for {}"". format ( name ) ) <TAB> if not allow_unused and len ( arguments ) > 0 : <TAB> <TAB> raise ConfigError ( ""Unused configuration parameters {}"". format ( arguments. keys ( ) ) ) <TAB> return function ( ** kwargs )",True,name in arguments,name in arguments,0.678224503993988
|
||
|
3553,"def wrapper ( <TAB> self : RequestHandler, * args, ** kwargs ) -> Optional [ Awaitable [ None ] ] : <TAB> if self. request. path. endswith ( ""/"" ) : <TAB> <TAB> if self. request. method in ( ""GET"", ""HEAD"" ) : <TAB> <TAB> <TAB> uri = self. request. path. rstrip ( ""/"" ) <TAB> <TAB> <TAB> if uri : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> uri += ""?"" + self. request. query <TAB> <TAB> <TAB> <TAB> self. redirect ( uri, permanent = True ) <TAB> <TAB> <TAB> <TAB> return None <TAB> <TAB> else : <TAB> <TAB> <TAB> raise HTTPError ( 404 ) <TAB> return method ( self, * args, ** kwargs )",True,self.request.query,self.request.query,0.6592823266983032
|
||
|
3554,"def _decode_pattern_dict ( data ) : <TAB> rv = { } <TAB> for key, value in data. items ( ) : <TAB> <TAB> if isinstance ( key, bytes ) : <TAB> <TAB> <TAB> key = key. encode ( ""utf-8"" ) <TAB> <TAB> if isinstance ( key, str ) : <TAB> <TAB> <TAB> if key in [ ""$in"", ""$gt"", ""$gte"", ""$lt"", ""$lte"", ""$exists"" ] : <TAB> <TAB> <TAB> <TAB> return 1 <TAB> <TAB> <TAB> if key == ""$nin"" : <TAB> <TAB> <TAB> <TAB> value = 1 <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return _decode_pattern_dict ( value ) <TAB> <TAB> <TAB> <TAB> except : <TAB> <TAB> <TAB> <TAB> <TAB> return value <TAB> <TAB> if isinstance ( value, list ) : <TAB> <TAB> <TAB> value = _decode_pattern_list ( value ) <TAB> <TAB> elif isinstance ( value, dict ) : <TAB> <TAB> <TAB> value = _decode_pattern_dict ( value ) <TAB> <TAB> else : <TAB> <TAB> <TAB> value = 1 <TAB> <TAB> rv [ key ] = value <TAB> return rv",False,"key in ['query', '$query']","isinstance(value, dict)",0.6591883897781372
|
||
|
3555,"def server_operation_put ( server_id, operation ) : <TAB> if settings. app. demo_mode : <TAB> <TAB> return utils. demo_blocked ( ) <TAB> svr = server. get_by_id ( server_id, fields = server. operation_fields ) <TAB> try : <TAB> <TAB> if operation == START : <TAB> <TAB> <TAB> svr. start ( ) <TAB> <TAB> <TAB> logger. LogEntry ( message = 'Started server ""%s"".' % svr. name ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> svr. stop ( ) <TAB> <TAB> <TAB> logger. LogEntry ( message = 'Stopped server ""%s"".' % svr. name ) <TAB> <TAB> elif operation == RESTART : <TAB> <TAB> <TAB> svr. restart ( ) <TAB> <TAB> <TAB> logger. LogEntry ( message = 'Restarted server ""%s"".' % svr. name ) <TAB> except : <TAB> <TAB> event. Event ( type = SERVERS_UPDATED ) <TAB> <TAB> raise <TAB> event. Event ( type = SERVERS_UPDATED ) <TAB> event. Event ( type = SERVER_HOSTS_UPDATED, resource_id = svr. id ) <TAB> for org in svr. iter_orgs ( ) : <TAB> <TAB> event. Event ( type = USERS_UPDATED, resource_id = org. id ) <TAB> svr. send_link_events ( ) <TAB> return utils. jsonify ( svr. dict ( ) )",True,operation == STOP,operation == STOP,0.6889662742614746
|
||
|
3556,"def should_keep_alive ( commit_msg ) : <TAB> result = False <TAB> ci = get_current_ci ( ) or """" <TAB> for line in commit_msg. splitlines ( ) : <TAB> <TAB> parts = line. strip ( ""# "" ). split ( "":"", 1 ) <TAB> <TAB> ( key, val ) = parts if len ( parts ) > 1 else ( parts [ 0 ], """" ) <TAB> <TAB> if key == ""CI_KEEP_ALIVE"" : <TAB> <TAB> <TAB> ci_names = val. replace ( "","", "" "" ). lower ( ). split ( ) if val else [ ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> result = True <TAB> return result",False,len(ci_names) == 0 or ci.lower() in ci_names,len(ci_names) > 1 and ci_names[0] in result,0.6553505659103394
|
||
|
3557,"def air_quality ( self ) : <TAB> aqi_data = self. _get_aqi_data ( ) <TAB> if aqi_data : <TAB> <TAB> if aqi_data. get ( ""status"" ) == ""ok"" : <TAB> <TAB> <TAB> aqi_data = self. _organize ( aqi_data ) <TAB> <TAB> <TAB> aqi_data = self. _manipulate ( aqi_data ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> self. py3. error ( aqi_data. get ( ""data"" ) ) <TAB> return { <TAB> <TAB> ""cached_until"" : self. py3. time_in ( self. cache_timeout ), <TAB> <TAB> ""full_text"" : self. py3. safe_format ( self. format, aqi_data ), <TAB> }",False,aqi_data.get('status') == 'error',aqi_data and aqi_data.get('data'),0.6501069068908691
|
||
|
3558,"def findDepth ( self, insts, debug = 0 ) : <TAB> depth = 0 <TAB> maxDepth = 0 <TAB> for i in insts : <TAB> <TAB> opname = i [ 0 ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> print ( i ), <TAB> <TAB> delta = self. effect. get ( opname, None ) <TAB> <TAB> if delta is not None : <TAB> <TAB> <TAB> depth = depth + delta <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for pat, pat_delta in self. patterns : <TAB> <TAB> <TAB> <TAB> if opname [ : len ( pat ) ] == pat : <TAB> <TAB> <TAB> <TAB> <TAB> delta = pat_delta <TAB> <TAB> <TAB> <TAB> <TAB> depth = depth + delta <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if delta is None : <TAB> <TAB> <TAB> <TAB> meth = getattr ( self, opname, None ) <TAB> <TAB> <TAB> <TAB> if meth is not None : <TAB> <TAB> <TAB> <TAB> <TAB> depth = depth + meth ( i [ 1 ] ) <TAB> <TAB> if depth > maxDepth : <TAB> <TAB> <TAB> maxDepth = depth <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> print ( depth, maxDepth ) <TAB> return maxDepth",True,debug,debug,0.6841456890106201
|
||
|
3559,"def update ( self ) : <TAB> while self. running : <TAB> <TAB> command = self. get_command ( ) <TAB> <TAB> if self. debug : <TAB> <TAB> <TAB> self. log ( ""Command = {}"". format ( command ) ) <TAB> <TAB> elif command is not None : <TAB> <TAB> <TAB> self. log ( ""Command = {}"". format ( command ) ) <TAB> <TAB> if command == ""autopilot"" : <TAB> <TAB> <TAB> self. ctr. mode = ""local"" <TAB> <TAB> elif command == ""speedup"" : <TAB> <TAB> <TAB> self. cfg. AI_THROTTLE_MULT += 0.05 <TAB> <TAB> elif command == ""slowdown"" : <TAB> <TAB> <TAB> self. cfg. AI_THROTTLE_MULT -= 0.05 <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> self. ctr. mode = ""user"" <TAB> <TAB> <TAB> self. cfg. AI_THROTTLE_MULT = self. DEFAULT_AI_THROTTLE_MULT <TAB> <TAB> if self. debug : <TAB> <TAB> <TAB> self. log ( <TAB> <TAB> <TAB> <TAB> ""mode = {}, cfg.AI_THROTTLE_MULT={}"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> self. ctr. mode, self. cfg. AI_THROTTLE_MULT <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> time. sleep ( 0.25 )",False,command == 'stop',command == 'slowup_mode',0.662871778011322
|
||
|
3560,"def get_shadows_zip ( filename ) : <TAB> import zipfile <TAB> shadow_pkgs = set ( ) <TAB> with zipfile. ZipFile ( filename ) as lib_zip : <TAB> <TAB> already_test = [ ] <TAB> <TAB> for fname in lib_zip. namelist ( ) : <TAB> <TAB> <TAB> pname, fname = os. path. split ( fname ) <TAB> <TAB> <TAB> if fname or ( pname and fname ) : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if pname not in already_test and ""/"" not in pname : <TAB> <TAB> <TAB> <TAB> already_test. append ( pname ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> shadow_pkgs. add ( pname ) <TAB> return shadow_pkgs",False,is_shadowing(pname),pname and pname not in shadow_pkgs,0.6541174650192261
|
||
|
3561,"def _parse_fill ( fill, img, min_pil_version, name = ""fillcolor"" ) : <TAB> <TAB> major_found, minor_found = ( int ( v ) for v in PILLOW_VERSION. split ( ""."" ) [ : 2 ] ) <TAB> major_required, minor_required = ( int ( v ) for v in min_pil_version. split ( ""."" ) [ : 2 ] ) <TAB> if major_found < major_required or ( <TAB> <TAB> major_found == major_required and minor_found < minor_required <TAB> ) : <TAB> <TAB> if fill is None : <TAB> <TAB> <TAB> return { } <TAB> <TAB> else : <TAB> <TAB> <TAB> msg = ( <TAB> <TAB> <TAB> <TAB> ""The option to fill background area of the transformed image, "" <TAB> <TAB> <TAB> <TAB> ""requires pillow>={}"" <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> raise RuntimeError ( msg. format ( min_pil_version ) ) <TAB> num_bands = len ( img. getbands ( ) ) <TAB> if fill is None : <TAB> <TAB> fill = 0 <TAB> if isinstance ( fill, ( int, float ) ) and num_bands > 1 : <TAB> <TAB> fill = tuple ( [ fill ] * num_bands ) <TAB> if isinstance ( fill, ( list, tuple ) ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> msg = ( <TAB> <TAB> <TAB> <TAB> ""The number of elements in 'fill' does not match the number of "" <TAB> <TAB> <TAB> <TAB> ""bands of the image ({}!= {})"" <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> raise ValueError ( msg. format ( len ( fill ), num_bands ) ) <TAB> <TAB> fill = tuple ( fill ) <TAB> return { name : fill }",True,len(fill) != num_bands,len(fill) != num_bands,0.661264181137085
|
||
|
3562,"def _getValueHist ( self, version, pkgarch, checksum ) : <TAB> data = self. _execute ( <TAB> <TAB> ""SELECT value FROM %s WHERE version=? AND pkgarch=? AND checksum=?;"" <TAB> <TAB> % self. table, <TAB> <TAB> ( version, pkgarch, checksum ), <TAB> ) <TAB> row = data. fetchone ( ) <TAB> if<mask> : <TAB> <TAB> return row [ 0 ] <TAB> else : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> self. _execute ( <TAB> <TAB> <TAB> <TAB> ""INSERT INTO %s VALUES (?,?,?, (select ifnull(max(value)+1,0) from %s where version=? AND pkgarch=?));"" <TAB> <TAB> <TAB> <TAB> % ( self. table, self. table ), <TAB> <TAB> <TAB> <TAB> ( version, pkgarch, checksum, version, pkgarch ), <TAB> <TAB> <TAB> ) <TAB> <TAB> except sqlite3. IntegrityError as exc : <TAB> <TAB> <TAB> logger. error ( str ( exc ) ) <TAB> <TAB> self. dirty = True <TAB> <TAB> data = self. _execute ( <TAB> <TAB> <TAB> ""SELECT value FROM %s WHERE version=? AND pkgarch=? AND checksum=?;"" <TAB> <TAB> <TAB> % self. table, <TAB> <TAB> <TAB> ( version, pkgarch, checksum ), <TAB> <TAB> ) <TAB> <TAB> row = data. fetchone ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return row [ 0 ] <TAB> <TAB> else : <TAB> <TAB> <TAB> raise prserv. NotFoundError",False,row != None,row,0.6841013431549072
|
||
|
3563,"def main ( client ) : <TAB> <TAB> placement_service = client. GetService ( ""PlacementService"", version = ""v202011"" ) <TAB> <TAB> statement = ( <TAB> <TAB> ad_manager. StatementBuilder ( version = ""v202011"" ) <TAB> <TAB>. Where ( ""status = :status"" ) <TAB> <TAB>. WithBindVariable ( ""status"", ""ACTIVE"" ) <TAB> ) <TAB> <TAB> <TAB> while True : <TAB> <TAB> response = placement_service. getPlacementsByStatement ( statement. ToStatement ( ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> for placement in response [ ""results"" ] : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> <TAB> 'Placement with ID ""%d"" and name ""%s"" was found.\n' <TAB> <TAB> <TAB> <TAB> <TAB> % ( placement [ ""id"" ], placement [ ""name"" ] ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> statement. offset += statement. limit <TAB> <TAB> else : <TAB> <TAB> <TAB> break <TAB> print ( ""\nNumber of results found: %s"" % response [ ""totalResultSetSize"" ] )",False,'results' in response and len(response['results']),response[0],0.6574869155883789
|
||
|
3564,"def authorize_application ( <TAB> registration_app_id : UUID, <TAB> onefuzz_app_id : UUID, <TAB> permissions : List [ str ] = [ ""user_impersonation"" ], ) -> None : <TAB> try : <TAB> <TAB> onefuzz_app = get_application ( onefuzz_app_id ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> logger. error ( ""Application '%s' not found"", onefuzz_app_id ) <TAB> <TAB> <TAB> return <TAB> <TAB> scopes = seq ( onefuzz_app [ ""api"" ] [ ""oauth2PermissionScopes"" ] ). filter ( <TAB> <TAB> <TAB> lambda scope : scope [ ""value"" ] in permissions <TAB> <TAB> ) <TAB> <TAB> existing_preAuthorizedApplications = ( <TAB> <TAB> <TAB> seq ( onefuzz_app [ ""api"" ] [ ""preAuthorizedApplications"" ] ) <TAB> <TAB> <TAB>. map ( <TAB> <TAB> <TAB> <TAB> lambda paa : seq ( paa [ ""delegatedPermissionIds"" ] ). map ( <TAB> <TAB> <TAB> <TAB> <TAB> lambda permission_id : ( paa [ ""appId"" ], permission_id ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB>. flatten ( ) <TAB> <TAB> ) <TAB> <TAB> preAuthorizedApplications = ( <TAB> <TAB> <TAB> scopes. map ( lambda s : ( str ( registration_app_id ), s [ ""id"" ] ) ) <TAB> <TAB> <TAB>. union ( existing_preAuthorizedApplications ) <TAB> <TAB> <TAB>. distinct ( ) <TAB> <TAB> <TAB>. group_by_key ( ) <TAB> <TAB> <TAB>. map ( lambda data : { ""appId"" : data [ 0 ], ""delegatedPermissionIds"" : data [ 1 ] } ) <TAB> <TAB> ) <TAB> <TAB> query_microsoft_graph ( <TAB> <",False,onefuzz_app is None,not onefuzz_app,0.6636962294578552
|
||
|
3565,"def _canonicalGlyphName ( name, localName2ucs, localUc2Names, altName2ucs ) : <TAB> ucs = localName2ucs. get ( name ) <TAB> if ucs : <TAB> <TAB> return name, list ( ucs ) [ 0 ] <TAB> ucs = altName2ucs. get ( name ) <TAB> if ucs : <TAB> <TAB> for uc in ucs : <TAB> <TAB> <TAB> localNames = localUc2Names. get ( uc ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return localNames [ 0 ], uc <TAB> return None, None",False,localNames and len(localNames),localNames,0.6551178693771362
|
||
|
3566,"def parse_hgsub ( lines ) : <TAB> """"""Fills OrderedDict with hgsub file content passed as list of lines"""""" <TAB> rv = OrderedDict ( ) <TAB> for l in lines : <TAB> <TAB> ls = l. strip ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> name, value = l. split ( ""="", 1 ) <TAB> <TAB> rv [ name. strip ( ) ] = value. strip ( ) <TAB> return rv",False,not ls or ls[0] == '#',not ls,0.6596238017082214
|
||
|
3567,"def match_delta ( self, value ) : <TAB> """"""Search for timedelta information in the string"""""" <TAB> m = self. REGEX_DELTA. search ( value ) <TAB> delta = datetime. timedelta ( days = 0 ) <TAB> if m : <TAB> <TAB> d = int ( m. group ( 1 ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> d = - d <TAB> <TAB> if m. group ( 2 ) == ""minute"" : <TAB> <TAB> <TAB> delta = datetime. timedelta ( minutes = d ) <TAB> <TAB> elif m. group ( 2 ) == ""hour"" : <TAB> <TAB> <TAB> delta = datetime. timedelta ( hours = d ) <TAB> <TAB> elif m. group ( 2 ) == ""day"" : <TAB> <TAB> <TAB> delta = datetime. timedelta ( days = d ) <TAB> <TAB> elif m. group ( 2 ) == ""week"" : <TAB> <TAB> <TAB> delta = datetime. timedelta ( weeks = d ) <TAB> <TAB> value = self. REGEX_DELTA. sub ( """", value ) <TAB> return ( delta, value )",False,m.group(3) == 'ago' or m.group(3) == 'before',d,0.6476140022277832
|
||
|
3568,"def _find_unicode_literals_frame ( ) : <TAB> import __future__ <TAB> if not hasattr ( sys, ""_getframe"" ) : <TAB> <TAB> return 0 <TAB> frm = sys. _getframe ( 1 ) <TAB> idx = 1 <TAB> while frm is not None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> frm = frm. f_back <TAB> <TAB> <TAB> idx += 1 <TAB> <TAB> elif frm. f_code. co_flags & __future__. unicode_literals. compiler_flag : <TAB> <TAB> <TAB> return idx <TAB> <TAB> else : <TAB> <TAB> <TAB> break <TAB> return 0",False,"frm.f_globals.get('__name__', '').startswith('click.')",__future__.unicode_literals.compiler_flag,0.6529810428619385
|
||
|
3569,"def search_new_server ( self ) : <TAB> """"""Search for a new server for this article"""""" <TAB> <TAB> sabnzbd. BPSMeter. register_server_article_failed ( self. fetcher. id ) <TAB> self. add_to_try_list ( self. fetcher ) <TAB> for server in sabnzbd. Downloader. servers : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if server. priority >= self. fetcher. priority : <TAB> <TAB> <TAB> <TAB> self. tries = 0 <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> sabnzbd. NzbQueue. reset_try_lists ( self, article_reset = False ) <TAB> <TAB> <TAB> <TAB> return True <TAB> logging. info ( T ( ""%s => missing from all servers, discarding"" ) % self ) <TAB> self. nzf. nzo. increase_bad_articles_counter ( ""missing_articles"" ) <TAB> return False",False,server.active and (not self.server_in_try_list(server)),self.has_server,0.6507188081741333
|
||
|
3570,"def emit_properties_changed ( self, interface, properties, path = ""/"" ) : <TAB> """"""Emits PropertiesChanged for the specified properties"""""" <TAB> combos = { } <TAB> for prop in properties : <TAB> <TAB> iface = self. get_interface ( interface, prop ) <TAB> <TAB> if iface is None : <TAB> <TAB> <TAB> raise ValueError ( ""Property %s not registered"" % prop ) <TAB> <TAB> combos. setdefault ( iface, [ ] ). append ( prop ) <TAB> for iface, props in combos. items ( ) : <TAB> <TAB> values = { } <TAB> <TAB> inval = [ ] <TAB> <TAB> for prop in props : <TAB> <TAB> <TAB> emit = self. __props [ iface ] [ prop ] [ ""emit"" ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise ValueError ( ""Can't emit changed signal for %s"" % prop ) <TAB> <TAB> <TAB> elif emit == ""true"" : <TAB> <TAB> <TAB> <TAB> values [ prop ] = self. get_value ( iface, prop, path ) <TAB> <TAB> <TAB> elif emit == ""invalidates"" : <TAB> <TAB> <TAB> <TAB> inval. append ( prop ) <TAB> <TAB> if self. SUPPORTS_MULTIPLE_OBJECT_PATHS : <TAB> <TAB> <TAB> self. PropertiesChanged ( iface, values, inval, rel = path ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. PropertiesChanged ( iface, values, inval )",True,emit == 'false',emit == 'false',0.6633288860321045
|
||
|
3571,"def addClasses ( self, name ) : <TAB> <TAB> <TAB> for n in name. split ( ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> k, method = n. split ( ""."" ) <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> k = n <TAB> <TAB> <TAB> method = None <TAB> <TAB> self. classes [ k ] = 1 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. methods. setdefault ( k, { } ) [ method ] = 1",True,method is not None,method is not None,0.663976788520813
|
||
|
3572,"def pause ( self ) : <TAB> if self. is_playing : <TAB> <TAB> self. state = MusicPlayerState. PAUSED <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _current_player. pause ( ) <TAB> <TAB> self. emit ( ""pause"", player = self, entry = self. current_entry ) <TAB> <TAB> return <TAB> elif self. is_paused : <TAB> <TAB> return <TAB> raise ValueError ( ""Cannot pause a MusicPlayer in state %s"" % self. state )",False,self._current_player,self.state == MusicPlayerState.PAused,0.6601255536079407
|
||
|
3573,"def _make_slices ( <TAB> shape : tp. Tuple [ int,... ], <TAB> axes : tp. Tuple [ int,... ], <TAB> size : int, <TAB> rng : np. random. RandomState, ) -> tp. List [ slice ] : <TAB> slices = [ ] <TAB> for a, s in enumerate ( shape ) : <TAB> <TAB> if a in axes : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise ValueError ( ""Cannot crossover on axis with size 1"" ) <TAB> <TAB> <TAB> start = rng. randint ( s - size ) <TAB> <TAB> <TAB> slices. append ( slice ( start, start + size ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> slices. append ( slice ( None ) ) <TAB> return slices",False,s <= 1,s - size > 1,0.6794853210449219
|
||
|
3574,"def _pop_waiting_trial_id ( self ) -> Optional [ int ] : <TAB> <TAB> for trial in self. _storage. get_all_trials ( self. _study_id, deepcopy = False ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> if not self. _storage. set_trial_state ( trial. _trial_id, TrialState. RUNNING ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> _logger. debug ( ""Trial {} popped from the trial queue."". format ( trial. number ) ) <TAB> <TAB> return trial. _trial_id <TAB> return None",False,trial.state != TrialState.WAITING,trial.number == 0,0.6566871404647827
|
||
|
3575,"def __get_file_by_num ( self, num, file_list, idx = 0 ) : <TAB> for element in file_list : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return element <TAB> <TAB> if element [ 3 ] and element [ 4 ] : <TAB> <TAB> <TAB> i = self. __get_file_by_num ( num, element [ 3 ], idx + 1 ) <TAB> <TAB> <TAB> if not isinstance ( i, int ) : <TAB> <TAB> <TAB> <TAB> return i <TAB> <TAB> <TAB> idx = i <TAB> <TAB> else : <TAB> <TAB> <TAB> idx += 1 <TAB> return idx",False,idx == num,element[0] and element[0],0.6793323159217834
|
||
|
3576,"def _handle_redirects ( self, response, ** extra ) : <TAB> ""Follows any redirects by requesting responses from the server using GET."" <TAB> response. redirect_chain = [ ] <TAB> while response. status_code in ( 301, 302, 303, 307 ) : <TAB> <TAB> url = response [ ""Location"" ] <TAB> <TAB> scheme, netloc, path, query, fragment = urlsplit ( url ) <TAB> <TAB> redirect_chain = response. redirect_chain <TAB> <TAB> redirect_chain. append ( ( url, response. status_code ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> extra [ ""wsgi.url_scheme"" ] = scheme <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> response = self. get ( path, QueryDict ( query ), follow = False, ** extra ) <TAB> <TAB> response. redirect_chain = redirect_chain <TAB> <TAB> <TAB> <TAB> if response. redirect_chain [ - 1 ] in response. redirect_chain [ 0 : - 1 ] : <TAB> <TAB> <TAB> break <TAB> return response",False,scheme,extra,0.6865355968475342
|
||
|
3577,"def get_category_items ( self, context ) : <TAB> category_items = None <TAB> category_items = [ ( GENERAL, ""General"", ""Uncategorized presets"", 0 ) ] <TAB> node_category_items = [ ] <TAB> for idx, category in enumerate ( get_category_names ( ) ) : <TAB> <TAB> node_class = get_node_class_reference ( category ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> title = ""/Node/ {}"". format ( node_class. bl_label ) <TAB> <TAB> <TAB> node_category_items. append ( ( category, title, category, idx + 1 ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> title = category <TAB> <TAB> <TAB> category_items. append ( ( category, title, category, idx + 1 ) ) <TAB> include_node_categories = ( <TAB> <TAB> not hasattr ( self, ""include_node_categories"" ) or self. include_node_categories <TAB> ) <TAB> if node_category_items and include_node_categories : <TAB> <TAB> category_items = category_items + [ None ] + node_category_items <TAB> return category_items",False,"node_class and hasattr(node_class, 'bl_label')",node_class and node_class.bl_label,0.6485708951950073
|
||
|
3578,"def decoration_helper ( self, patched, args, keywargs ) : <TAB> extra_args = [ ] <TAB> with contextlib. ExitStack ( ) as exit_stack : <TAB> <TAB> for patching in patched. patchings : <TAB> <TAB> <TAB> arg = exit_stack. enter_context ( patching ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> keywargs. update ( arg ) <TAB> <TAB> <TAB> elif patching. new is DEFAULT : <TAB> <TAB> <TAB> <TAB> extra_args. append ( arg ) <TAB> <TAB> args += tuple ( extra_args ) <TAB> <TAB> yield ( args, keywargs )",False,patching.attribute_name is not None,patching.new is True,0.6531013250350952
|
||
|
3579,"def test_function ( self ) : <TAB> for start_method, redirs in product ( start_methods ( ), redirects ( ) ) : <TAB> <TAB> with self. subTest ( start_method = start_method, redirs = redirs ) : <TAB> <TAB> <TAB> pc = start_processes ( <TAB> <TAB> <TAB> <TAB> name = ""echo"", <TAB> <TAB> <TAB> <TAB> entrypoint = echo1, <TAB> <TAB> <TAB> <TAB> args = { 0 : ( ""hello"", ), 1 : ( ""hello"", ) }, <TAB> <TAB> <TAB> <TAB> envs = { 0 : { ""RANK"" : ""0"" }, 1 : { ""RANK"" : ""1"" } }, <TAB> <TAB> <TAB> <TAB> log_dir = self. log_dir ( ), <TAB> <TAB> <TAB> <TAB> start_method = start_method, <TAB> <TAB> <TAB> <TAB> redirects = redirs, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> results = pc. wait ( period = 0.1 ) <TAB> <TAB> <TAB> nprocs = pc. nprocs <TAB> <TAB> <TAB> self. assert_pids_noexist ( pc. pids ( ) ) <TAB> <TAB> <TAB> self. assertEqual ( <TAB> <TAB> <TAB> <TAB> { i : f""hello_{i}"" for i in range ( nprocs ) }, results. return_values <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> for i in range ( nprocs ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> self. assertFalse ( results. stdouts [ i ] ) <TAB> <TAB> <TAB> <TAB> if redirs & Std. ERR!= Std. ERR : <TAB> <TAB> <TAB> <TAB> <TAB> self. assertFalse ( results. stderrs [ i ] ) <TAB> <TAB> <TAB> <TAB> if redirs & Std. OUT",False,redirs & Std.OUT != Std.OUT,results.return_values[i] != 0,0.6815295219421387
|
||
|
3580,"def __init__ ( <TAB> self, <TAB> path : typing. Union [ str, ""os.PathLike[str]"" ], <TAB> status_code : int = 200, <TAB> headers : dict = None, <TAB> media_type : str = None, <TAB> background : BackgroundTask = None, <TAB> filename : str = None, <TAB> stat_result : os. stat_result = None, <TAB> method : str = None, ) -> None : <TAB> assert aiofiles is not None, ""'aiofiles' must be installed to use FileResponse"" <TAB> self. path = path <TAB> self. status_code = status_code <TAB> self. filename = filename <TAB> self. send_header_only = method is not None and method. upper ( ) == ""HEAD"" <TAB> if media_type is None : <TAB> <TAB> media_type = guess_type ( filename or path ) [ 0 ] or ""text/plain"" <TAB> self. media_type = media_type <TAB> self. background = background <TAB> self. init_headers ( headers ) <TAB> if self. filename is not None : <TAB> <TAB> content_disposition_filename = quote ( self. filename ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> content_disposition = ""attachment; filename*=utf-8''{}"". format ( <TAB> <TAB> <TAB> <TAB> content_disposition_filename <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> content_disposition = 'attachment; filename=""{}""'. format ( self. filename ) <TAB> <TAB> self. headers. setdefault ( ""content-disposition"", content_disposition ) <TAB> self. stat_result = stat_result <TAB> if stat_result is not None : <TAB> <TAB> self. set_stat_headers ( stat_result )",False,content_disposition_filename != self.filename,self.filename_in_a_filename,0.6603981256484985
|
||
|
3581,"def _check_systemd_reval ( self, args ) : <TAB> penv = { <TAB> <TAB> ""stdout"" : self. _devnull, <TAB> <TAB> ""stderr"" : self. _devnull, <TAB> } <TAB> if not os. getenv ( ""DBUS_SESSION_BUS_ADDRESS"" ) and self. _user : <TAB> <TAB> penv. update ( <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> ""env"" : { <TAB> <TAB> <TAB> <TAB> <TAB> ""DBUS_SESSION_BUS_ADDRESS"" : ""unix:path=/var/run/user/{}/dbus/user_bus_socket"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _uid <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> }, <TAB> <TAB> <TAB> } <TAB> <TAB> ) <TAB> try : <TAB> <TAB> cmd = [ ""systemctl"" ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> cmd. append ( ""--user"" ) <TAB> <TAB> cmd = cmd + args <TAB> <TAB> return subprocess. check_call ( cmd, ** penv ) == 0 <TAB> except ( subprocess. CalledProcessError, OSError ) : <TAB> <TAB> return None",False,self._user,args,0.6727558374404907
|
||
|
3582,"def did_evm_read_storage_callback ( self, state, address, offset, value ) : <TAB> m = self. manticore <TAB> world = state. platform <TAB> tx = world. all_transactions [ - 1 ] <TAB> md = m. get_metadata ( tx. address ) <TAB> if md : <TAB> <TAB> offsets = state. solve_n ( offset, 3000 ) <TAB> <TAB> with self. locked_context ( ""storage_reads"", dict ) as storage_reads : <TAB> <TAB> <TAB> contract_function = ( <TAB> <TAB> <TAB> <TAB> md. name, <TAB> <TAB> <TAB> <TAB> md. get_func_name ( state. solve_one ( tx. data [ 0 : 4 ] ) ), <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> storage_reads [ contract_function ] = set ( ) <TAB> <TAB> <TAB> for off in offsets : <TAB> <TAB> <TAB> <TAB> storage_reads [ contract_function ]. add ( off )",True,contract_function not in storage_reads,contract_function not in storage_reads,0.6535273790359497
|
||
|
3583,"def _update_percent_field_in_targets ( self, args, update_modified = True ) : <TAB> """"""Update percent field in parent transaction"""""" <TAB> if args. get ( ""percent_join_field_parent"" ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> args [ ""name"" ] = self. get ( args [ ""percent_join_field_parent"" ] ) <TAB> <TAB> self. _update_percent_field ( args, update_modified ) <TAB> else : <TAB> <TAB> distinct_transactions = set ( <TAB> <TAB> <TAB> [ <TAB> <TAB> <TAB> <TAB> d. get ( args [ ""percent_join_field"" ] ) <TAB> <TAB> <TAB> <TAB> for d in self. get_all_children ( args [ ""source_dt"" ] ) <TAB> <TAB> <TAB> ] <TAB> <TAB> ) <TAB> <TAB> for name in distinct_transactions : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> args [ ""name"" ] = name <TAB> <TAB> <TAB> <TAB> self. _update_percent_field ( args, update_modified )",True,name,name,0.6797094941139221
|
||
|
3584,"def contact_lists ( request ) : <TAB> tags = Tag. objects. all ( ) <TAB> if request. user. role == ""ADMIN"" : <TAB> <TAB> queryset = ContactList. objects. all ( ). order_by ( ""-created_on"" ) <TAB> else : <TAB> <TAB> queryset = ContactList. objects. filter ( <TAB> <TAB> <TAB> Q ( created_by = request. user ) | Q ( visible_to = request. user ) <TAB> <TAB> ). order_by ( ""-created_on"" ) <TAB> users = User. objects. filter ( id__in = queryset. values_list ( ""created_by_id"", flat = True ) ) <TAB> if request. GET. get ( ""tag"" ) : <TAB> <TAB> queryset = queryset. filter ( tags = request. GET. get ( ""tag"" ) ) <TAB> search = False <TAB> if request. method == ""POST"" : <TAB> <TAB> post_tags = request. POST. getlist ( ""tag"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> queryset = queryset. filter ( <TAB> <TAB> <TAB> <TAB> name__icontains = request. POST. get ( ""contact_list_name"" ) <TAB> <TAB> <TAB> ) <TAB> <TAB> if request. POST. get ( ""created_by"" ) : <TAB> <TAB> <TAB> queryset = queryset. filter ( created_by = request. POST. get ( ""created_by"" ) ) <TAB> <TAB> if request. POST. get ( ""tag"" ) : <TAB> <TAB> <TAB> queryset = queryset. filter ( tags__id__in = post_tags ) <TAB> <TAB> <TAB> request_tags = request. POST. getlist ( ""tag"" ) <TAB> <TAB> if ( <TAB> <TAB> <TAB> request. POST. get ( ""contact_list_name"" ) <TAB> <TAB> <TAB> or request. POST. get ( ""created_by"" ) <TAB> <TAB> <TAB> or request. POST. get ( ""created_by"" ) <TAB> <TAB> ) :",False,request.POST.get('contact_list_name'),post_tags,0.6476304531097412
|
||
|
3585,"def enableCtrls ( self ) : <TAB> <TAB> <TAB> for data in self. storySettingsData : <TAB> <TAB> name = data [ ""name"" ] <TAB> <TAB> if name in self. ctrls : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> set = self. getSetting ( data [ ""requires"" ] ) <TAB> <TAB> <TAB> <TAB> for i in self. ctrls [ name ] : <TAB> <TAB> <TAB> <TAB> <TAB> i. Enable ( set not in [ ""off"", ""false"", ""0"" ] )",False,'requires' in data,data['requires'] != '',0.6880241632461548
|
||
|
3586,"def main ( argv = [ ""worker_setup.py"" ] ) : <TAB> """"""Completely set everything up from a fresh ec2 instance"""""" <TAB> _, ubuntu_arch = check_ubuntu_version ( ) <TAB> opts = get_options ( argv ) <TAB> opts. arch = ubuntu_arch <TAB> with Environ ( ""DEBIAN_FRONTEND"", ""noninteractive"" ) : <TAB> <TAB> if opts. update_system : <TAB> <TAB> <TAB> run_cmd ( ""apt-get update"" ) <TAB> <TAB> <TAB> run_cmd ( ""apt-get upgrade -y"" ) <TAB> <TAB> if opts. install_required : <TAB> <TAB> <TAB> install_required_packages ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> install_utility_packages ( ) <TAB> <TAB> if opts. install_pkg_languages : <TAB> <TAB> <TAB> install_packaged_languages ( ) <TAB> <TAB> if opts. install_languages : <TAB> <TAB> <TAB> install_all_languages ( opts ) <TAB> if opts. install_jailguard : <TAB> <TAB> install_jailguard ( opts ) <TAB> if opts. create_jails : <TAB> <TAB> setup_base_chroot ( opts ) <TAB> if opts. packages_only : <TAB> <TAB> return <TAB> setup_contest_files ( opts ) <TAB> if opts. create_jails : <TAB> <TAB> setup_base_jail ( opts ) <TAB> <TAB> setup_jailusers ( opts ) <TAB> start_script = os. path. join ( <TAB> <TAB> opts. root_dir, opts. local_repo, ""worker/start_worker.sh"" <TAB> ) <TAB> if opts. install_cronjob : <TAB> <TAB> cron_file = ""/etc/cron.d/ai-contest"" <TAB> <TAB> if not file_contains ( cron_file, start_script ) : <TAB> <TAB> <TAB> append_line ( <TAB> <TAB> <TAB> <TAB>",False,opts.install_utilities,opts.install_utility_packages,0.6536614298820496
|
||
|
3587,"def _add_noise ( tokens, lengths, params, subword_token, is_spacer = None ) : <TAB> if not isinstance ( params, list ) : <TAB> <TAB> raise ValueError ( ""Expected a list of noise modules"" ) <TAB> noises = [ ] <TAB> for module in params : <TAB> <TAB> noise_type, args = next ( iter ( module. items ( ) ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> args = [ args ] <TAB> <TAB> noise_type = noise_type. lower ( ) <TAB> <TAB> if noise_type == ""dropout"" : <TAB> <TAB> <TAB> noise_class = noise. WordDropout <TAB> <TAB> elif noise_type == ""replacement"" : <TAB> <TAB> <TAB> noise_class = noise. WordReplacement <TAB> <TAB> elif noise_type == ""permutation"" : <TAB> <TAB> <TAB> noise_class = noise. WordPermutation <TAB> <TAB> else : <TAB> <TAB> <TAB> raise ValueError ( ""Invalid noise type: %s"" % noise_type ) <TAB> <TAB> noises. append ( noise_class ( * args ) ) <TAB> noiser = noise. WordNoiser ( <TAB> <TAB> noises = noises, subword_token = subword_token, is_spacer = is_spacer <TAB> ) <TAB> return noiser ( tokens, lengths, keep_shape = True )",False,"not isinstance(args, list)",len(args) > 0,0.6509168744087219
|
||
|
3588,"def test_is_open_close_time ( ) : <TAB> timestamps = iterate_timestamps ( <TAB> <TAB> entity_type = ""coin"", <TAB> <TAB> exchange = ""binance"", <TAB> <TAB> level = IntervalLevel. LEVEL_1MIN, <TAB> <TAB> start_timestamp = ""2019-05-01"", <TAB> <TAB> end_timestamp = ""2019-05-01"", <TAB> ) <TAB> assert is_open_time ( entity_type = ""coin"", exchange = ""binance"", timestamp = timestamps [ 0 ] ) <TAB> assert is_close_time ( <TAB> <TAB> entity_type = ""coin"", exchange = ""binance"", timestamp = timestamps [ - 1 ] <TAB> ) <TAB> timestamps = iterate_timestamps ( <TAB> <TAB> entity_type = ""coin"", <TAB> <TAB> exchange = ""binance"", <TAB> <TAB> level = IntervalLevel. LEVEL_5MIN, <TAB> <TAB> start_timestamp = ""2019-05-01"", <TAB> <TAB> end_timestamp = ""2019-05-01"", <TAB> ) <TAB> assert is_open_time ( entity_type = ""coin"", exchange = ""binance"", timestamp = timestamps [ 0 ] ) <TAB> assert is_close_time ( <TAB> <TAB> entity_type = ""coin"", exchange = ""binance"", timestamp = timestamps [ - 1 ] <TAB> ) <TAB> timestamps = iterate_timestamps ( <TAB> <TAB> entity_type = ""coin"", <TAB> <TAB> exchange = ""binance"", <TAB> <TAB> level = IntervalLevel. LEVEL_5MIN, <TAB> <TAB> start_timestamp = ""2019-05-01"", <TAB> <TAB> end_timestamp = ""2019-05-02"", <TAB> ) <TAB> open = [ ] <TAB> close = [ ] <TAB> for timestamp in timestamps : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> open. append ( timestamp ) <TAB> <TAB> if is_close_time ( entity_type = ""coin"",",False,"is_open_time(entity_type='coin', exchange='binance', timestamp=timestamp)",timestamp not in open,0.6470658779144287
|
||
|
3589,"def _parse_fixits ( message, titer, line ) : <TAB> """"""Parses fixit messages."""""" <TAB> while ( <TAB> <TAB> OutputParser. message_line_re. match ( line ) is None <TAB> <TAB> and OutputParser. note_line_re. match ( line ) is None <TAB> ) : <TAB> <TAB> message_text = line. strip ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> message. fixits. append ( <TAB> <TAB> <TAB> <TAB> Note ( <TAB> <TAB> <TAB> <TAB> <TAB> message. path, <TAB> <TAB> <TAB> <TAB> <TAB> message. line, <TAB> <TAB> <TAB> <TAB> <TAB> line. find ( message_text ) + 1, <TAB> <TAB> <TAB> <TAB> <TAB> message_text, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> line = next ( titer ) <TAB> return line",False,message_text != '',message_text,0.6673606634140015
|
||
|
3590,"def __attempt_add_to_linked_match ( <TAB> self, input_name, hdca, collection_type_description, subcollection_type ) : <TAB> structure = get_structure ( <TAB> <TAB> hdca, collection_type_description, leaf_subcollection_type = subcollection_type <TAB> ) <TAB> if not self. linked_structure : <TAB> <TAB> self. linked_structure = structure <TAB> <TAB> self. collections [ input_name ] = hdca <TAB> <TAB> self. subcollection_types [ input_name ] = subcollection_type <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise exceptions. MessageException ( CANNOT_MATCH_ERROR_MESSAGE ) <TAB> <TAB> self. collections [ input_name ] = hdca <TAB> <TAB> self. subcollection_types [ input_name ] = subcollection_type",False,not self.linked_structure.can_match(structure),leaf_subcollection_type,0.6484894752502441
|
||
|
3591,"def _FormatContainerContents ( self, node ) : <TAB> """"""Print out the last type parameter of a container. Used for *args/**kw."""""" <TAB> assert isinstance ( node, pytd. Parameter ) <TAB> if isinstance ( node. type, pytd. GenericType ) : <TAB> <TAB> container_name = node. type. name. rpartition ( ""."" ) [ 2 ] <TAB> <TAB> assert container_name in ( ""tuple"", ""dict"" ) <TAB> <TAB> self. _typing_import_counts [ container_name. capitalize ( ) ] -= 1 <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _typing_import_counts [ ""Any"" ] -= 1 <TAB> <TAB> return node. Replace ( type = node. type. parameters [ - 1 ], optional = False ). Visit ( <TAB> <TAB> <TAB> PrintVisitor ( ) <TAB> <TAB> ) <TAB> else : <TAB> <TAB> return node. Replace ( type = pytd. AnythingType ( ), optional = False ). Visit ( <TAB> <TAB> <TAB> PrintVisitor ( ) <TAB> <TAB> )",False,"isinstance(node.type.parameters[-1], pytd.AnythingType)","container_name in (tuple, dict)",0.6497973203659058
|
||
|
3592,"def remove ( self, conv_id ) : <TAB> if self. bot. memory. exists ( [ ""convmem"", conv_id ] ) : <TAB> <TAB> _cached = self. bot. memory. get_by_path ( [ ""convmem"", conv_id ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> logger. info ( ""removing conv: {} {}"". format ( conv_id, _cached [ ""title"" ] ) ) <TAB> <TAB> <TAB> self. bot. memory. pop_by_path ( [ ""convmem"", conv_id ] ) <TAB> <TAB> <TAB> del self. catalog [ conv_id ] <TAB> <TAB> else : <TAB> <TAB> <TAB> logger. warning ( <TAB> <TAB> <TAB> <TAB> ""cannot remove conv: {} {} {}"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> _cached [ ""type"" ], conv_id, _cached [ ""title"" ] <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> else : <TAB> <TAB> logger. warning ( ""cannot remove: {}, not found"". format ( conv_id ) ) <TAB> self. bot. memory. save ( )",False,_cached['type'] == 'GROUP',_cached,0.65423583984375
|
||
|
3593,"def append ( self, * values ) : <TAB> for value in values : <TAB> <TAB> if self. AcceptedType : <TAB> <TAB> <TAB> assert isinstance ( value, self. AcceptedType ) <TAB> <TAB> self. _append ( value ) <TAB> <TAB> name = getattr ( value, ""Name"", None ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> name = MakeAttributeName ( value. Name ) <TAB> <TAB> <TAB> setattr ( self, name, value )",False,name,name is None,0.6858710050582886
|
||
|
3594,"def download_and_unpack ( target_dir, url ) : <TAB> wget_args = ""-q -l 1 -N -nd -c -e robots=off -A tgz -r -np"" <TAB> tgz_dir = os. path. join ( target_dir, ""tgz"" ) <TAB> exit_code = download_multi ( url, tgz_dir, wget_args ) <TAB> if exit_code!= 0 : <TAB> <TAB> print ( ""Download tgz audio files failed with exit code %d."" % exit_code ) <TAB> else : <TAB> <TAB> print ( ""Download done, start unpacking..."" ) <TAB> <TAB> audio_dir = os. path. join ( target_dir, ""audio"" ) <TAB> <TAB> for root, dirs, files in os. walk ( tgz_dir ) : <TAB> <TAB> <TAB> for file in files : <TAB> <TAB> <TAB> <TAB> print ( file ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> unpack ( os. path. join ( root, file ), audio_dir )",False,file.endswith('.tgz'),os.path.isfile(file),0.6473191976547241
|
||
|
3595,"def get_profile_dir ( ) : <TAB> """"""Return path where all profiles of current user are stored."""""" <TAB> if os. name == ""nt"" : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> basedir = unicode ( os. environ [ ""LOCALAPPDATA"" ], nt_filename_encoding ) <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> from.. winutil import get_shell_folder <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> basedir = get_shell_folder ( ""Local AppData"" ) <TAB> <TAB> <TAB> except EnvironmentError : <TAB> <TAB> <TAB> <TAB> basedir = os. path. join ( <TAB> <TAB> <TAB> <TAB> <TAB> os. environ [ ""USERPROFILE"" ], ""Local Settings"", ""Application Data"" <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> dirpath = os. path. join ( basedir, u""Google"", u""Chrome"", u""User Data"" ) <TAB> elif os. name == ""posix"" : <TAB> <TAB> basedir = unicode ( os. environ [ ""HOME"" ] ) <TAB> <TAB> if sys. platform == ""darwin"" : <TAB> <TAB> <TAB> dirpath = os. path. join ( basedir, u""Library"", u""Application Support"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> dirpath = os. path. join ( basedir, u"".config"" ) <TAB> <TAB> dirpath = os. path. join ( dirpath, u""Google"", u""Chrome"" ) <TAB> return dirpath",False,'LOCALAPPDATA' in os.environ,"hasattr(os, 'environ')",0.6537001132965088
|
||
|
3596,"def set_logger_config ( ) : <TAB> config = _GLOBAL_CONTEXT [ ""config"" ] <TAB> if config. get ( ""quiet"" ) : <TAB> <TAB> log. disabled = True <TAB> else : <TAB> <TAB> log_format = config [ ""log_format"" ] <TAB> <TAB> logging. basicConfig ( format = log_format ) <TAB> <TAB> log. setLevel ( getattr ( logging, config [ ""log_level"" ] ) ) <TAB> <TAB> handlers = ( <TAB> <TAB> <TAB> config [ ""log_handlers"" ]. keys ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> else [ config [ ""log_handler"" ] ] <TAB> <TAB> ) <TAB> <TAB> for handler in handlers : <TAB> <TAB> <TAB> handler_class = load_class_by_path ( handler ) <TAB> <TAB> <TAB> handler_config = config [ ""log_handlers"" ]. get ( handler, { } ) <TAB> <TAB> <TAB> handler_format = handler_config. pop ( ""format"", log_format ) <TAB> <TAB> <TAB> handler_level = getattr ( <TAB> <TAB> <TAB> <TAB> logging, handler_config. pop ( ""level"", config [ ""log_level"" ] ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> log_handler = handler_class ( ** handler_config ) <TAB> <TAB> <TAB> formatter = logging. Formatter ( handler_format ) <TAB> <TAB> <TAB> log_handler. setFormatter ( formatter ) <TAB> <TAB> <TAB> log_handler. setLevel ( handler_level ) <TAB> <TAB> <TAB> log. addHandler ( log_handler )",False,config['log_handlers'],config.get('log_handler') is None,0.6573575735092163
|
||
|
3597,"def _meter_worker ( qin, qout, meter, is_train, world_size, rank, filename ) : <TAB> backend = ""gloo"" <TAB> torch. distributed. init_process_group ( <TAB> <TAB> backend = backend, <TAB> <TAB> init_method = ""file://{filename}"". format ( filename = filename ), <TAB> <TAB> world_size = world_size, <TAB> <TAB> rank = rank, <TAB> ) <TAB> <TAB> while True : <TAB> <TAB> try : <TAB> <TAB> <TAB> signal, val = qin. get ( ) <TAB> <TAB> except queue. Empty : <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> meter. update ( val [ 0 ], val [ 1 ], is_train = is_train ) <TAB> <TAB> elif signal == VALUE_SIGNAL : <TAB> <TAB> <TAB> meter. sync_state ( ) <TAB> <TAB> <TAB> qout. put ( meter. value ) <TAB> <TAB> elif signal == SHUTDOWN_SIGNAL : <TAB> <TAB> <TAB> break <TAB> <TAB> else : <TAB> <TAB> <TAB> raise NotImplementedError ( ""Bad signal value"" ) <TAB> return",False,signal == UPDATE_SIGNAL,signal == SIGNAL_VALUE,0.6671662926673889
|
||
|
3598,"def check_syntax ( filename, raise_error = False ) : <TAB> """"""Return True if syntax is okay."""""" <TAB> with autopep8. open_with_encoding ( filename ) as input_file : <TAB> <TAB> try : <TAB> <TAB> <TAB> compile ( input_file. read ( ), ""<string>"", ""exec"", dont_inherit = True ) <TAB> <TAB> <TAB> return True <TAB> <TAB> except ( SyntaxError, TypeError, UnicodeDecodeError ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> return False",True,raise_error,raise_error,0.6604596376419067
|
||
|
3599,"def export_sessions_csv_task ( self, event_id ) : <TAB> sessions = db. session. query ( Session ). filter_by ( event_id = event_id ) <TAB> try : <TAB> <TAB> filedir = os. path. join ( <TAB> <TAB> <TAB> current_app. config. get ( ""BASE_DIR"" ), ""static/uploads/temp/"" <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> os. makedirs ( filedir ) <TAB> <TAB> filename = f""sessions-{uuid.uuid1().hex}.csv"" <TAB> <TAB> file_path = os. path. join ( filedir, filename ) <TAB> <TAB> with open ( file_path, ""w"" ) as temp_file : <TAB> <TAB> <TAB> writer = csv. writer ( temp_file ) <TAB> <TAB> <TAB> from app. api. helpers. csv_jobs_util import export_sessions_csv <TAB> <TAB> <TAB> content = export_sessions_csv ( sessions ) <TAB> <TAB> <TAB> for row in content : <TAB> <TAB> <TAB> <TAB> writer. writerow ( row ) <TAB> <TAB> sessions_csv_file = UploadedFile ( file_path = file_path, filename = filename ) <TAB> <TAB> sessions_csv_url = upload ( <TAB> <TAB> <TAB> sessions_csv_file, <TAB> <TAB> <TAB> UPLOAD_PATHS [ ""exports-temp"" ] [ ""csv"" ]. format ( <TAB> <TAB> <TAB> <TAB> event_id = event_id, identifier = """" <TAB> <TAB> <TAB> ), <TAB> <TAB> ) <TAB> <TAB> result = { ""download_url"" : sessions_csv_url } <TAB> except Exception as e : <TAB> <TAB> result = { ""__error"" : True, ""result"" : str ( e ) } <TAB> <TAB> logging. exception ( ""Error in exporting sessions as CSV"" ) <TAB> return result",False,not os.path.isdir(filedir),not os.path.exists(filedir),0.647394061088562
|
||
|
3600,"def testTokenizer ( ) : <TAB> for filename in get_data_files ( ""tokenizer"", ""*.test"" ) : <TAB> <TAB> with open ( filename ) as fp : <TAB> <TAB> <TAB> tests = json. load ( fp ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> for index, test in enumerate ( tests [ ""tests"" ] ) : <TAB> <TAB> <TAB> <TAB> <TAB> if ""initialStates"" not in test : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> test [ ""initialStates"" ] = [ ""Data state"" ] <TAB> <TAB> <TAB> <TAB> <TAB> if ""doubleEscaped"" in test : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> test = unescape ( test ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if test [ ""input"" ] is None : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> <TAB> for initialState in test [ ""initialStates"" ] : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> test [ ""initialState"" ] = capitalize ( initialState ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> yield runTokenizerTest, test",False,'tests' in tests,len(tests) > 0,0.6723448038101196
|
||
|
3601,"def find_url_region ( view, event = None, pt = None ) : <TAB> if event : <TAB> <TAB> pt = view. window_to_text ( ( event [ ""x"" ], event [ ""y"" ] ) ) <TAB> line = view. line ( pt ) <TAB> line. a = max ( line. a, pt - 1024 ) <TAB> line. b = pt + 1024 <TAB> text = view. substr ( line ) <TAB> original_text = text <TAB> text = text. replace ( CONTINUATION + ""\n"", """" ) <TAB> for match in rex. finditer ( text ) : <TAB> <TAB> if match. start ( ) <= ( pt - line. a ) and match. end ( ) >= ( pt - line. a ) : <TAB> <TAB> <TAB> a = match. start ( ) <TAB> <TAB> <TAB> b = match. end ( ) <TAB> <TAB> <TAB> for marker in re. finditer ( CONTINUATION + ""\n"", original_text ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> b += len ( CONTINUATION ) + 1 <TAB> <TAB> <TAB> return ( line. a + a, line. a + b ) <TAB> return None",False,a <= marker.start() and b >= marker.start(),marker,0.6513715982437134
|
||
|
3602,"def drawSelected ( self, qp ) : <TAB> qp. setFont ( self. font ) <TAB> cursorX, cursorY = self. cursor. getPosition ( ) <TAB> if len ( self. OPCODES ) - 1 < cursorY : <TAB> <TAB> return <TAB> asm = self. OPCODES [ cursorY ] <TAB> _, width, text = asm. getSelectedToken ( cursorX ) <TAB> for i, asm in enumerate ( self. OPCODES ) : <TAB> <TAB> for idx, length, value in asm. tokens ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if cursorY == i and cursorX == idx : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> qp. setOpacity ( 0.4 ) <TAB> <TAB> <TAB> <TAB> brush = QtGui. QBrush ( QtGui. QColor ( 0, 255, 0 ) ) <TAB> <TAB> <TAB> <TAB> qp. fillRect ( <TAB> <TAB> <TAB> <TAB> <TAB> idx * self. fontWidth, <TAB> <TAB> <TAB> <TAB> <TAB> i * self. fontHeight + 2, <TAB> <TAB> <TAB> <TAB> <TAB> width * self. fontWidth, <TAB> <TAB> <TAB> <TAB> <TAB> self. fontHeight, <TAB> <TAB> <TAB> <TAB> <TAB> brush, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> qp. setOpacity ( 1 )",False,value == text,value,0.6705994009971619
|
||
|
3603,"def get_ignored_test ( self ) : <TAB> self. _cleanup ( ) <TAB> for i in range ( 1, 10 ) : <TAB> <TAB> process_data = { <TAB> <TAB> <TAB> u""colord"" : { <TAB> <TAB> <TAB> <TAB> u""memory_mb"" : u""11.3"", <TAB> <TAB> <TAB> <TAB> u""kb_read"" : u""-1.00"", <TAB> <TAB> <TAB> <TAB> u""cpu"" : u""25.00"", <TAB> <TAB> <TAB> <TAB> u""kb_write"" : u""-1.00"", <TAB> <TAB> <TAB> }, <TAB> <TAB> <TAB> u""acpid"" : { <TAB> <TAB> <TAB> <TAB> u""memory_mb"" : u""0.78"", <TAB> <TAB> <TAB> <TAB> u""kb_read"" : u""-1.00"", <TAB> <TAB> <TAB> <TAB> u""cpu"" : u""0.00"", <TAB> <TAB> <TAB> <TAB> u""kb_write"" : u""-1.00"", <TAB> <TAB> <TAB> }, <TAB> <TAB> } <TAB> <TAB> process_model. save_data ( server = self. server, data = process_data, time = i ) <TAB> result = process_model. get_ignored_process_check ( self. server, 9 ) <TAB> for r in result : <TAB> <TAB> name = r. get ( ""name"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> assert float ( r [ ""memory"" ] ) == 11.3 <TAB> <TAB> <TAB> assert float ( r [ ""cpu"" ] ) == 25.00 <TAB> self. _cleanup ( )",False,name == 'colord',name,0.6595348119735718
|
||
|
3604,"def _lemmatize ( self, word : str, tag : Optional [ str ] = None ) -> str : <TAB> lemma = self. memo. get ( ( word, tag ) ) <TAB> if lemma is not None : <TAB> <TAB> return lemma <TAB> parses = self. analyzer. parse ( word ) <TAB> best_lemma, best_distance = word, np. inf <TAB> for i, parse in enumerate ( parses ) : <TAB> <TAB> curr_tag = self. converter ( str ( parse. tag ) ) <TAB> <TAB> distance = get_tag_distance ( tag, curr_tag ) <TAB> <TAB> for feat in self. RARE_FEATURES : <TAB> <TAB> <TAB> if feat in parse. tag : <TAB> <TAB> <TAB> <TAB> distance += self. rare_grammeme_penalty <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> if len ( word ) == 1 and len ( parse. normal_form ) > 1 : <TAB> <TAB> <TAB> distance += self. long_lemma_penalty <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> best_lemma, best_distance = self. _extract_lemma ( parse ), distance <TAB> <TAB> <TAB> if distance == 0 : <TAB> <TAB> <TAB> <TAB> break <TAB> self. memo [ ( word, tag ) ] = best_lemma <TAB> return best_lemma",False,distance < best_distance,distance > best_distance,0.6554915904998779
|
||
|
3605,"def _get_convergence_plans ( <TAB> self, services, strategy, always_recreate_deps = False, one_off = None ) : <TAB> plans = { } <TAB> for service in services : <TAB> <TAB> updated_dependencies = [ <TAB> <TAB> <TAB> name <TAB> <TAB> <TAB> for name in service. get_dependency_names ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> ] <TAB> <TAB> is_one_off = one_off and service. name in one_off <TAB> <TAB> if updated_dependencies and strategy. allows_recreate : <TAB> <TAB> <TAB> log. debug ( <TAB> <TAB> <TAB> <TAB> ""%s has upstream changes (%s)"", <TAB> <TAB> <TAB> <TAB> service. name, <TAB> <TAB> <TAB> <TAB> "", "". join ( updated_dependencies ), <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> containers_stopped = any ( <TAB> <TAB> <TAB> <TAB> service. containers ( <TAB> <TAB> <TAB> <TAB> <TAB> stopped = True, filters = { ""status"" : [ ""created"", ""exited"" ] } <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> service_has_links = any ( service. get_link_names ( ) ) <TAB> <TAB> <TAB> container_has_links = any ( <TAB> <TAB> <TAB> <TAB> c. get ( ""HostConfig.Links"" ) for c in service. containers ( ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> should_recreate_for_links = service_has_links ^ container_has_links <TAB> <TAB> <TAB> if always_recreate_deps or containers_stopped or should_recreate_for_links : <TAB> <TAB> <TAB> <TAB> plan = service. convergence_plan ( ConvergenceStrategy. always, is_one_off ) <TAB> <TAB> <",False,"name in plans and plans[name].action in ('recreate', 'create')",plans,0.6556882858276367
|
||
|
3606,"def set_type ( self, line ) : <TAB> if ""Type:"" in line : <TAB> <TAB> ele_type = line [ line. find ( ""Type:"" ) + len ( ""Type:"" ) : ] <TAB> <TAB> ele_type = ele_type. strip ( ) <TAB> <TAB> if ""Default"" in ele_type : <TAB> <TAB> <TAB> poses = [ <TAB> <TAB> <TAB> <TAB> ele_type. find ( ""Default"" ), <TAB> <TAB> <TAB> <TAB> ele_type. find ( "".Default"" ), <TAB> <TAB> <TAB> <TAB> ele_type. find ( "". Default"" ), <TAB> <TAB> <TAB> <TAB> ele_type. find ( "",Default"" ), <TAB> <TAB> <TAB> <TAB> ele_type. find ( "", Default"" ), <TAB> <TAB> <TAB> ] <TAB> <TAB> else : <TAB> <TAB> <TAB> poses = [ <TAB> <TAB> <TAB> <TAB> max ( [ ele_type. find ( "". "" ), ele_type. find ( ""."" ), ele_type. find ( '.""' ) ] ), <TAB> <TAB> <TAB> <TAB> ele_type. find ( "" "" ), <TAB> <TAB> <TAB> <TAB> ele_type. find ( "", "" ), <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> <TAB> poses = [ ele for ele in poses if ele > 0 ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> end_pos = min ( poses ) <TAB> <TAB> <TAB> ele_type = ele_type [ : end_pos ] <TAB> <TAB> if ele_type : <TAB> <TAB> <TAB> self. ele_type = ele_type",True,poses,poses,0.6933566331863403
|
||
|
3607,"def distinct ( expr, * on ) : <TAB> fields = frozenset ( expr. fields ) <TAB> _on = [ ] <TAB> append = _on. append <TAB> for n in on : <TAB> <TAB> if isinstance ( n, Field ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> n = n. _name <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> raise ValueError ( ""{0} is not a field of {1}"". format ( n, expr ) ) <TAB> <TAB> if not isinstance ( n, _strtypes ) : <TAB> <TAB> <TAB> raise TypeError ( ""on must be a name or field, not: {0}"". format ( n ) ) <TAB> <TAB> elif n not in fields : <TAB> <TAB> <TAB> raise ValueError ( ""{0} is not a field of {1}"". format ( n, expr ) ) <TAB> <TAB> append ( n ) <TAB> return Distinct ( expr, tuple ( _on ) )",False,n._child.isidentical(expr),n._name,0.6504287719726562
|
||
|
3608,"def process ( self, resources ) : <TAB> client = local_session ( self. manager. session_factory ). client ( ""ecs"" ) <TAB> update = self. data. get ( ""update"" ) <TAB> for r in resources : <TAB> <TAB> param = { } <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> net_update = update. get ( ""networkConfiguration"", { } ). get ( ""awsvpcConfiguration"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> net_param = dict ( r [ ""networkConfiguration"" ] [ ""awsvpcConfiguration"" ] ) <TAB> <TAB> <TAB> param [ ""networkConfiguration"" ] = { ""awsvpcConfiguration"" : net_param } <TAB> <TAB> <TAB> for k, v in net_update. items ( ) : <TAB> <TAB> <TAB> <TAB> net_param [ k ] = v <TAB> <TAB> for k, v in update. items ( ) : <TAB> <TAB> <TAB> if k == ""networkConfiguration"" : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> elif r. get ( k )!= v : <TAB> <TAB> <TAB> <TAB> param [ k ] = v <TAB> <TAB> if not param : <TAB> <TAB> <TAB> continue <TAB> <TAB> client. update_service ( <TAB> <TAB> <TAB> cluster = r [ ""clusterArn"" ], service = r [ ""serviceName"" ], ** param <TAB> <TAB> )",True,net_update,net_update,0.6756992340087891
|
||
|
3609,"def get ( quality_name ) : <TAB> """"""Returns a quality object based on canonical quality name."""""" <TAB> found_components = { } <TAB> for part in quality_name. lower ( ). split ( ) : <TAB> <TAB> component = _registry. get ( part ) <TAB> <TAB> if not component : <TAB> <TAB> <TAB> raise ValueError ( ""`%s` is not a valid quality string"" % part ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""`%s` cannot be defined twice in a quality"" % component. type <TAB> <TAB> <TAB> ) <TAB> <TAB> found_components [ component. type ] = component <TAB> if not found_components : <TAB> <TAB> raise ValueError ( ""No quality specified"" ) <TAB> result = Quality ( ) <TAB> for type, component in found_components. items ( ) : <TAB> <TAB> setattr ( result, type, component ) <TAB> return result",False,component.type in found_components,component.type in _registry.get_components(),0.6544457077980042
|
||
|
3610,"def get_vrf_tables ( self, vrf_rf = None ) : <TAB> vrf_tables = { } <TAB> for ( scope_id, table_id ), table in self. _tables. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> if vrf_rf is not None and table_id!= vrf_rf : <TAB> <TAB> <TAB> continue <TAB> <TAB> vrf_tables [ ( scope_id, table_id ) ] = table <TAB> return vrf_tables",True,scope_id is None,scope_id is None,0.6559327840805054
|
||
|
3611,"def make_script_substitutions_in_headline ( self, p ) : <TAB> """"""Make scripting substitutions in p.h."""""" <TAB> c = self. c <TAB> pattern = re. compile ( <TAB> <TAB> ""^(.*)%s(.+)%s(.*)$"" <TAB> <TAB> % ( <TAB> <TAB> <TAB> re. escape ( c. abbrev_subst_start ), <TAB> <TAB> <TAB> re. escape ( c. abbrev_subst_end ), <TAB> <TAB> ) <TAB> ) <TAB> changed = False <TAB> <TAB> m = pattern. match ( p. h ) <TAB> if m : <TAB> <TAB> content = m. group ( 2 ) <TAB> <TAB> c. abbrev_subst_env [ ""x"" ] = """" <TAB> <TAB> try : <TAB> <TAB> <TAB> exec ( content, c. abbrev_subst_env, c. abbrev_subst_env ) <TAB> <TAB> <TAB> x = c. abbrev_subst_env. get ( ""x"" ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> p. h = ""%s%s%s"" % ( m. group ( 1 ), x, m. group ( 3 ) ) <TAB> <TAB> <TAB> <TAB> changed = True <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> g. trace ( ""scripting error in"", p. h ) <TAB> <TAB> <TAB> g. es_exception ( ) <TAB> return changed",True,x,x,0.6866368055343628
|
||
|
3612,"def _get_mpl_patches ( json_content, transform = None, invert_color = False, ** kwargs ) : <TAB> """"""Walks over the json content and builds a list of matplotlib patches"""""" <TAB> mpl_patches = [ ] <TAB> kwargs_edgecolor = kwargs. pop ( ""edgecolor"", None ) <TAB> kwargs_linewidth = kwargs. pop ( ""linewidth"", None ) <TAB> for path in json_content [ ""paths"" ] : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> edgecolor = kwargs_edgecolor <TAB> <TAB> else : <TAB> <TAB> <TAB> edgecolor = path [ ""edgecolor"" ] <TAB> <TAB> <TAB> if invert_color : <TAB> <TAB> <TAB> <TAB> edgecolor = _invert_color ( edgecolor ) <TAB> <TAB> linewidth = kwargs_linewidth or path [ ""linewidth"" ] <TAB> <TAB> path_id = path [ ""id"" ] <TAB> <TAB> for item in path [ ""items"" ] : <TAB> <TAB> <TAB> type = item [ ""type"" ] <TAB> <TAB> <TAB> pts = item [ ""pts"" ] <TAB> <TAB> <TAB> codes = _codes ( type, pts ) <TAB> <TAB> <TAB> path = Path ( pts, codes ) <TAB> <TAB> <TAB> patch = patches. PathPatch ( <TAB> <TAB> <TAB> <TAB> path, <TAB> <TAB> <TAB> <TAB> edgecolor = edgecolor, <TAB> <TAB> <TAB> <TAB> linewidth = linewidth, <TAB> <TAB> <TAB> <TAB> facecolor = ""none"", <TAB> <TAB> <TAB> <TAB> gid = path_id, <TAB> <TAB> <TAB> <TAB> transform = transform, <TAB> <TAB> <TAB> <TAB> ** kwargs <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> mpl_patches. append ( patch ) <TAB> return mpl_patches",False,kwargs_edgecolor is not None,"isinstance(path, Path)",0.665928065776825
|
||
|
3613,"def project ( hidden_states, proj_layer, key_value_states, past_key_value ) : <TAB> """"""projects hidden states correctly to key/query states"""""" <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> hidden_states = shape ( proj_layer ( hidden_states ) ) <TAB> elif past_key_value is None : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> hidden_states = shape ( proj_layer ( key_value_states ) ) <TAB> if past_key_value is not None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> hidden_states = tf. concat ( [ past_key_value, hidden_states ], axis = 2 ) <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> hidden_states = past_key_value <TAB> return hidden_states",True,key_value_states is None,key_value_states is None,0.6521288156509399
|
||
|
3614,"def get ( self, name ) : <TAB> entry, wb_class = self. _get_obj_entry ( name ) <TAB> if entry is not None : <TAB> <TAB> <TAB> <TAB> if self. _manifest_entry_is_artifact_reference ( entry ) : <TAB> <TAB> <TAB> artifact = self. _get_ref_artifact_from_entry ( entry ) <TAB> <TAB> <TAB> return artifact. get ( util. uri_from_path ( entry. ref ) ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. download ( recursive = True ) <TAB> <TAB> <TAB> <TAB> item = self. get_path ( entry. path ) <TAB> <TAB> item_path = item. download ( ) <TAB> <TAB> <TAB> <TAB> result = None <TAB> <TAB> json_obj = { } <TAB> <TAB> with open ( item_path, ""r"" ) as file : <TAB> <TAB> <TAB> json_obj = json. load ( file ) <TAB> <TAB> result = wb_class. from_json ( json_obj, self ) <TAB> <TAB> result. set_artifact_source ( self, name ) <TAB> <TAB> return result",False,wb_class == wandb.Table,entry.path is None,0.6618028283119202
|
||
|
3615,"def collect ( self, paths ) : <TAB> for path in paths or ( ) : <TAB> <TAB> relpath = os. path. relpath ( path, self. _artifact_root ) <TAB> <TAB> dst = os. path. join ( self. _directory, relpath ) <TAB> <TAB> safe_mkdir ( os. path. dirname ( dst ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> shutil. copytree ( path, dst ) <TAB> <TAB> else : <TAB> <TAB> <TAB> shutil. copy ( path, dst ) <TAB> <TAB> self. _relpaths. add ( relpath )",False,os.path.isdir(path),os.path.isdir(dst),0.6449061036109924
|
||
|
3616,"def __get__ ( self, instance, owner = None ) : <TAB> if instance is None : <TAB> <TAB> return self <TAB> if self. attrname is None : <TAB> <TAB> raise TypeError ( <TAB> <TAB> <TAB> ""Cannot use cached_property instance without calling __set_name__ on it."" <TAB> <TAB> ) <TAB> try : <TAB> <TAB> cache = instance. __dict__ <TAB> except AttributeError : <TAB> <TAB> msg = ( <TAB> <TAB> <TAB> f""No '__dict__' attribute on {type(instance).__name__!r} "" <TAB> <TAB> <TAB> f""instance to cache {self.attrname!r} property."" <TAB> <TAB> ) <TAB> <TAB> raise TypeError ( msg ) from None <TAB> val = cache. get ( self. attrname, _NOT_FOUND ) <TAB> if<mask> : <TAB> <TAB> with self. lock : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> val = cache. get ( self. attrname, _NOT_FOUND ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> val = self. func ( instance ) <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> cache [ self. attrname ] = val <TAB> <TAB> <TAB> <TAB> except TypeError : <TAB> <TAB> <TAB> <TAB> <TAB> msg = ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> f""The '__dict__' attribute on {type(instance).__name__!r} instance "" <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> f""does not support item assignment for caching {self.attrname!r} property."" <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> raise TypeError ( msg ) from None <TAB> return val",True,val is _NOT_FOUND,val is _NOT_FOUND,0.659093976020813
|
||
|
3617,"def _cleanup_inactive_receivexlogs ( self, site ) : <TAB> if site in self. receivexlogs : <TAB> <TAB> if not self. receivexlogs [ site ]. running : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. receivexlogs [ site ]. join ( ) <TAB> <TAB> <TAB> del self. receivexlogs [ site ]",False,self.receivexlogs[site].is_alive(),self.receivexlogs[site].join,0.6542024612426758
|
||
|
3618,"def _query ( self ) : <TAB> if self. _mongo_query is None : <TAB> <TAB> self. _mongo_query = self. _query_obj. to_query ( self. _document ) <TAB> <TAB> if self. _cls_query : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. _mongo_query = { ""$and"" : [ self. _cls_query, self. _mongo_query ] } <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. _mongo_query. update ( self. _cls_query ) <TAB> return self. _mongo_query",False,'_cls' in self._mongo_query,"hasattr(self._mongo_query, '__and__')",0.661358118057251
|
||
|
3619,"def process_path ( self, subpath, inner_schema_obj, nums, offsets, squeeze_dims ) : <TAB> """"""Checks if a subpath is valid or not. Does not repeat computation done in a previous ObjectView object"""""" <TAB> paths = subpath. split ( ""/"" ) [ 1 : ] <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if isinstance ( inner_schema_obj, Sequence ) : <TAB> <TAB> <TAB> <TAB> schema_obj = inner_schema_obj. dtype. dict_ [ paths [ 0 ] ] <TAB> <TAB> <TAB> elif isinstance ( inner_schema_obj, SchemaDict ) : <TAB> <TAB> <TAB> <TAB> schema_obj = inner_schema_obj. dict_ [ paths [ 0 ] ] <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> raise KeyError ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> schema_obj = self. schema [ paths [ 0 ] ] <TAB> except ( KeyError, AttributeError ) : <TAB> <TAB> raise KeyError ( f""{paths[0]} is an invalid key"" ) <TAB> self. num_process ( schema_obj, nums, offsets, squeeze_dims ) <TAB> for path in paths [ 1 : ] : <TAB> <TAB> try : <TAB> <TAB> <TAB> if isinstance ( schema_obj, Sequence ) : <TAB> <TAB> <TAB> <TAB> schema_obj = schema_obj. dtype. dict_ [ path ] <TAB> <TAB> <TAB> elif isinstance ( schema_obj, SchemaDict ) : <TAB> <TAB> <TAB> <TAB> schema_obj = schema_obj. dict_ [ path ] <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> raise KeyError ( ) <TAB> <TAB> <TAB> self. num_process ( schema_obj, nums, offsets, squeeze_dims ) <TAB> <TAB> except ( KeyError, AttributeError ) : <TAB> <TAB> <TAB> raise KeyError ( f""{path} is an invalid key"" ) <TAB> return schema_",False,inner_schema_obj,len(paths) > 0,0.6610968112945557
|
||
|
3620,"def create_snapshot ( self, snapshot ) : <TAB> LOG. debug ( ""Create Snapshot\n%s"", pprint. pformat ( snapshot ) ) <TAB> try : <TAB> <TAB> snap_name = self. _get_3par_snap_name ( snapshot [ ""id"" ] ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> vol_name = self. _get_3par_vol_name ( snapshot [ ""volume"" ] ) <TAB> <TAB> extra = { <TAB> <TAB> <TAB> ""volume_name"" : snapshot [ ""volume_name"" ], <TAB> <TAB> <TAB> ""volume_id"" : snapshot. get ( ""volume_id"" ), <TAB> <TAB> } <TAB> <TAB> self. _add_name_id_to_comment ( extra, snapshot [ ""volume"" ] ) <TAB> <TAB> try : <TAB> <TAB> <TAB> extra [ ""display_name"" ] = snapshot [ ""display_name"" ] <TAB> <TAB> except AttributeError : <TAB> <TAB> <TAB> pass <TAB> <TAB> try : <TAB> <TAB> <TAB> extra [ ""description"" ] = snapshot [ ""display_description"" ] <TAB> <TAB> except AttributeError : <TAB> <TAB> <TAB> pass <TAB> <TAB> optional = { ""comment"" : json. dumps ( extra ), ""readOnly"" : True } <TAB> <TAB> if self. config. hpe3par_snapshot_expiration : <TAB> <TAB> <TAB> optional [ ""expirationHours"" ] = int ( self. config. hpe3par_snapshot_expiration ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> optional [ ""retentionHours"" ] = int ( self. config. hpe3par_snapshot_retention ) <TAB> <TAB> self. client. createSnapshot ( snap_name, vol_name, optional ) <TAB> except hpeexceptions. HTTPForbidden as ex : <TAB> <TAB> LOG. error ( ""Exception: %s"", ex ) <TAB> <TAB> raise exception. NotAuthorized ( ) <",True,self.config.hpe3par_snapshot_retention,self.config.hpe3par_snapshot_retention,0.6487696170806885
|
||
|
3621,"def _highlight_do ( self ) : <TAB> new_hl_text = self. highlight_text. text ( ) <TAB> if new_hl_text!= self. hl_text : <TAB> <TAB> self. hl_text = new_hl_text <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. hl. setDocument ( None ) <TAB> <TAB> <TAB> self. hl = None <TAB> <TAB> if self. hl_text : <TAB> <TAB> <TAB> self. hl = Highlighter ( self. hl_text, parent = self. doc ) <TAB> <TAB> self. clear_highlight_button. setEnabled ( bool ( self. hl ) )",False,self.hl is not None,self.hl,0.6611143350601196
|
||
|
3622,"def chopCobraUri ( uri ) : <TAB> purl = urllib. parse. urlparse ( uri ) <TAB> scheme = purl. scheme <TAB> host = purl. hostname <TAB> name = purl. path. strip ( ""/"" ) <TAB> port = purl. port <TAB> if not port : <TAB> <TAB> port = COBRA_PORT <TAB> <TAB> urlparams = { } <TAB> for urlopt in purl. query. split ( ""&"" ) : <TAB> <TAB> urlval = 1 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> urlopt, urlval = urlopt. split ( ""="", 1 ) <TAB> <TAB> urlopt = urlopt. lower ( ) <TAB> <TAB> urlparams [ urlopt ] = urlval <TAB> return scheme, host, port, name, urlparams",False,urlopt.find('=') != -1,urlopt,0.6585469245910645
|
||
|
3623,"def _get_pod_to_ep ( self, service_type ) : <TAB> query = ( <TAB> <TAB> self. _pool. spawn ( <TAB> <TAB> <TAB> self. _client. list_namespaced_pod, <TAB> <TAB> <TAB> namespace = self. _k8s_namespace, <TAB> <TAB> <TAB> label_selector = self. _get_label_selector ( service_type ), <TAB> <TAB> ) <TAB> <TAB>. result ( ) <TAB> <TAB>. to_dict ( ) <TAB> ) <TAB> result = dict ( ) <TAB> for el in query [ ""items"" ] : <TAB> <TAB> name, pod_ep = self. _extract_pod_name_ep ( el ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> pod_ep = None <TAB> <TAB> result [ name ] = pod_ep <TAB> return result",False,pod_ep is not None and (not self._extract_pod_ready(el)),pod_ep is not None,0.6557104587554932
|
||
|
3624,"def after_process_message ( self, broker, message, *, result = None, exception = None ) : <TAB> from.. message import Message <TAB> if exception is None : <TAB> <TAB> group_completion_uuid = message. options. get ( ""group_completion_uuid"" ) <TAB> <TAB> group_completion_callbacks = message. options. get ( ""group_completion_callbacks"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> barrier = Barrier ( <TAB> <TAB> <TAB> <TAB> self. rate_limiter_backend, <TAB> <TAB> <TAB> <TAB> group_completion_uuid, <TAB> <TAB> <TAB> <TAB> ttl = GROUP_CALLBACK_BARRIER_TTL, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if barrier. wait ( block = False ) : <TAB> <TAB> <TAB> <TAB> for message in group_completion_callbacks : <TAB> <TAB> <TAB> <TAB> <TAB> broker. enqueue ( Message ( ** message ) )",True,group_completion_uuid and group_completion_callbacks,group_completion_uuid and group_completion_callbacks,0.653144121170044
|
||
|
3625,"def fitting ( self, value ) : <TAB> self. _fitting = value <TAB> if self. _fitting is not None : <TAB> <TAB> if not os. path. exists ( dirname ( self. checkpoint_path ( ) ) ) : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> os. makedirs ( dirname ( self. checkpoint_path ( ) ) ) <TAB> <TAB> <TAB> except FileExistsError as ex : <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> os. makedirs ( dirname ( self. tensorboard_path ( ) ) ) <TAB> <TAB> <TAB> except FileExistsError as ex : <TAB> <TAB> <TAB> <TAB> pass",False,not os.path.exists(dirname(self.tensorboard_path())),self.tensorboard_path() is not None,0.6508133411407471
|
||
|
3626,"def setup_logger ( ) : <TAB> """"""Set up logger and add stdout handler"""""" <TAB> logging. setLoggerClass ( IPDLogger ) <TAB> logger = logging. getLogger ( ""icloudpd"" ) <TAB> has_stdout_handler = False <TAB> for handler in logger. handlers : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> has_stdout_handler = True <TAB> if not has_stdout_handler : <TAB> <TAB> formatter = logging. Formatter ( <TAB> <TAB> <TAB> fmt = ""%(asctime)s %(levelname)-8s %(message)s"", datefmt = ""%Y-%m-%d %H:%M:%S"" <TAB> <TAB> ) <TAB> <TAB> stdout_handler = logging. StreamHandler ( stream = sys. stdout ) <TAB> <TAB> stdout_handler. setFormatter ( formatter ) <TAB> <TAB> stdout_handler. name = ""stdoutLogger"" <TAB> <TAB> logger. addHandler ( stdout_handler ) <TAB> return logger",False,handler.name == 'stdoutLogger',handler.hasHandlers(),0.6605055332183838
|
||
|
3627,"def pollpacket ( self, wait ) : <TAB> self. _stage0 ( ) <TAB> if len ( self. buffer ) < self. bufneed : <TAB> <TAB> r, w, x = select. select ( [ self. sock. fileno ( ) ], [ ], [ ], wait ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return None <TAB> <TAB> try : <TAB> <TAB> <TAB> s = self. sock. recv ( BUFSIZE ) <TAB> <TAB> except socket. error : <TAB> <TAB> <TAB> raise EOFError <TAB> <TAB> if len ( s ) == 0 : <TAB> <TAB> <TAB> raise EOFError <TAB> <TAB> self. buffer += s <TAB> <TAB> self. _stage0 ( ) <TAB> return self. _stage1 ( )",False,len(r) == 0,len(self.sock) == 0,0.6551221609115601
|
||
|
3628,"def _run_split_on_punc ( self, text, never_split = None ) : <TAB> """"""Splits punctuation on a piece of text."""""" <TAB> if never_split is not None and text in never_split : <TAB> <TAB> return [ text ] <TAB> chars = list ( text ) <TAB> i = 0 <TAB> start_new_word = True <TAB> output = [ ] <TAB> while i < len ( chars ) : <TAB> <TAB> char = chars [ i ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> output. append ( [ char ] ) <TAB> <TAB> <TAB> start_new_word = True <TAB> <TAB> else : <TAB> <TAB> <TAB> if start_new_word : <TAB> <TAB> <TAB> <TAB> output. append ( [ ] ) <TAB> <TAB> <TAB> start_new_word = False <TAB> <TAB> <TAB> output [ - 1 ]. append ( char ) <TAB> <TAB> i += 1 <TAB> return [ """". join ( x ) for x in output ]",True,_is_punctuation(char),_is_punctuation(char),0.649880051612854
|
||
|
3629,"def parse_move ( self, node ) : <TAB> old, new = """", """" <TAB> for child in node : <TAB> <TAB> tag, text = child. tag, child. text <TAB> <TAB> text = text. strip ( ) if text else None <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> old = text <TAB> <TAB> elif tag == ""New"" and text : <TAB> <TAB> <TAB> new = text <TAB> return Move ( old, new )",True,tag == 'Old' and text,tag == 'Old' and text,0.657818078994751
|
||
|
3630,"def calculate_length ( segments, min_segment_length, max_segment_length ) : <TAB> current_point = segments [ 0 ] <TAB> index = 1 <TAB> total = 0 <TAB> any_change = False <TAB> while index < len ( segments ) : <TAB> <TAB> next_point = segments [ index ] <TAB> <TAB> distance = distance_between ( current_point, next_point ) <TAB> <TAB> if distance < min_segment_length and 1 < index < ( len ( segments ) - 2 ) : <TAB> <TAB> <TAB> any_change = True <TAB> <TAB> <TAB> current_point = ( current_point + next_point ) / 2 <TAB> <TAB> <TAB> total += 1 <TAB> <TAB> <TAB> index += 2 <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> any_change = True <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> points = int ( <TAB> <TAB> <TAB> <TAB> ceil ( distance / ( ( max_segment_length + min_segment_length ) / 2 ) ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> total += points <TAB> <TAB> <TAB> current_point = next_point <TAB> <TAB> <TAB> index += 1 <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> total += 1 <TAB> <TAB> <TAB> current_point = next_point <TAB> <TAB> <TAB> index += 1 <TAB> total += 1 <TAB> return any_change, total",False,distance > max_segment_length,distance > max_segment_length and current_point + next_point,0.6548234224319458
|
||
|
3631,"def set_new_lr ( step_num, batch_id ) : <TAB> """"""set new learning rate"""""" <TAB> <TAB> if accumulate : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> step_num += 1 <TAB> else : <TAB> <TAB> step_num += 1 <TAB> <TAB> <TAB> <TAB> if step_num < num_warmup_steps : <TAB> <TAB> new_lr = lr * step_num / num_warmup_steps <TAB> else : <TAB> <TAB> offset = ( <TAB> <TAB> <TAB> ( step_num - num_warmup_steps ) * lr / ( num_train_steps - num_warmup_steps ) <TAB> <TAB> ) <TAB> <TAB> new_lr = lr - offset <TAB> trainer. set_learning_rate ( new_lr ) <TAB> return step_num",False,batch_id % accumulate == 0,step_num < num_train_steps,0.6660550832748413
|
||
|
3632,"def filter ( self, left, operator, right ) : <TAB> if operator == ""and"" : <TAB> <TAB> self. filter ( left. left, left. operator, left. right ) <TAB> <TAB> self. filter ( right. left, right. operator, right. right ) <TAB> else : <TAB> <TAB> left_base = left. split ( ""."" ) [ 0 ] <TAB> <TAB> if left_base in self. FIELDS : <TAB> <TAB> <TAB> self. do_query = True <TAB> <TAB> <TAB> field = self. FIELDS [ left_base ] <TAB> <TAB> <TAB> if field. sqlalchemy_field is not None : <TAB> <TAB> <TAB> <TAB> clazz, attribute = field. sqlalchemy_field <TAB> <TAB> <TAB> <TAB> sqlalchemy_field_value = getattr ( clazz, attribute ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> self. query = self. query. filter ( sqlalchemy_field_value == right ) <TAB> <TAB> <TAB> <TAB> elif operator == ""!="" : <TAB> <TAB> <TAB> <TAB> <TAB> self. query = self. query. filter ( sqlalchemy_field_value!= right ) <TAB> <TAB> <TAB> <TAB> elif operator == ""like"" : <TAB> <TAB> <TAB> <TAB> <TAB> self. query = self. query. filter ( sqlalchemy_field_value. like ( right ) ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> raise GalaxyParseError ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""Invalid comparison operator: %s"" % ( operator ) <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> elif field. handler is not None : <TAB> <TAB> <TAB> <TAB> field. handler ( self, left, operator, right ) <TAB> <TAB> <TAB> elif field. post_filter is not None : <TAB>",False,operator == '=',operator == '==',0.6886146664619446
|
||
|
3633,"def _get ( self, domain ) : <TAB> with self. lock : <TAB> <TAB> try : <TAB> <TAB> <TAB> record = self. cache [ domain ] <TAB> <TAB> <TAB> time_now = time. time ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> record = None <TAB> <TAB> except KeyError : <TAB> <TAB> <TAB> record = None <TAB> <TAB> if not record : <TAB> <TAB> <TAB> record = { ""r"" : ""unknown"", ""dns"" : { }, ""g"" : 1, ""query_count"" : 0 } <TAB> <TAB> <TAB> <TAB> return record",False,time_now - record['update'] > self.ttl,time_now - self.time_of > TAB_TIMEOUT,0.6601200103759766
|
||
|
3634,"def callback ( lexer, match, context ) : <TAB> text = match. group ( ) <TAB> if context. block_scalar_indent is None or len ( text ) <= context. block_scalar_indent : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> yield match. start ( ), indent_token_class, text <TAB> else : <TAB> <TAB> indentation = text [ : context. block_scalar_indent ] <TAB> <TAB> content = text [ context. block_scalar_indent : ] <TAB> <TAB> yield match. start ( ), indent_token_class, indentation <TAB> <TAB> yield ( <TAB> <TAB> <TAB> match. start ( ) + context. block_scalar_indent, <TAB> <TAB> <TAB> content_token_class, <TAB> <TAB> <TAB> content, <TAB> <TAB> ) <TAB> context. pos = match. end ( )",False,text,context.block_scalar_indent == 0,0.6741372346878052
|
||
|
3635,"def _fullSync ( self ) : <TAB> <TAB> if self. col. isEmpty ( ) : <TAB> <TAB> f = ""download"" <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. fullSyncChoice = False <TAB> <TAB> self. fireEvent ( ""fullSync"" ) <TAB> <TAB> while not self. fullSyncChoice : <TAB> <TAB> <TAB> time. sleep ( 0.1 ) <TAB> <TAB> f = self. fullSyncChoice <TAB> if f == ""cancel"" : <TAB> <TAB> return <TAB> self. client = FullSyncer ( self. col, self. hkey, self. server. con ) <TAB> if f == ""upload"" : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. fireEvent ( ""upbad"" ) <TAB> else : <TAB> <TAB> self. client. download ( ) <TAB> <TAB> self. col. reopen ( ) <TAB> self. _syncMedia ( )",False,not self.client.upload(),self.client.close(),0.6534979343414307
|
||
|
3636,"def test_wrap ( self ) : <TAB> none = """" <TAB> stdout_log = os. path. join ( self. test_dir, ""stdout.log"" ) <TAB> stderr_log = os. path. join ( self. test_dir, ""stderr.log"" ) <TAB> redirs = [ <TAB> <TAB> ( none, none ), <TAB> <TAB> ( none, stderr_log ), <TAB> <TAB> ( stdout_log, none ), <TAB> <TAB> ( stdout_log, stderr_log ), <TAB> ] <TAB> for stdout_redir, stderr_redir in redirs : <TAB> <TAB> queue = multiprocessing. SimpleQueue ( ) <TAB> <TAB> _wrap ( <TAB> <TAB> <TAB> local_rank = 0, <TAB> <TAB> <TAB> fn = echo1, <TAB> <TAB> <TAB> args = { 0 : ( ""hello"", ) }, <TAB> <TAB> <TAB> envs = { 0 : { ""RANK"" : ""0"" } }, <TAB> <TAB> <TAB> stdout_redirects = { 0 : stdout_redir }, <TAB> <TAB> <TAB> stderr_redirects = { 0 : stderr_redir }, <TAB> <TAB> <TAB> ret_vals = { 0 : queue }, <TAB> <TAB> ) <TAB> <TAB> self. assertEqual ( ""hello_0"", queue. get ( ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. assert_in_file ( [ ""hello stdout from 0"" ], stdout_log ) <TAB> <TAB> if stderr_redir : <TAB> <TAB> <TAB> self. assert_in_file ( [ ""hello stderr from 0"" ], stderr_log )",True,stdout_redir,stdout_redir,0.6591173410415649
|
||
|
3637,"def test_02_profiler ( self ) : <TAB> self. client. get ( ""/api/people/foo"" ) <TAB> self. client. get ( ""/api/people/foo"" ) <TAB> self. client. get ( ""/api/with/profiler/hello?q=2"" ) <TAB> measurements = list ( flask_profiler. collection. filter ( ) ) <TAB> self. assertEqual ( len ( measurements ), 3 ) <TAB> test_flag = False <TAB> for list_element in measurements : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> test_flag = True <TAB> <TAB> <TAB> self. assertEqual ( list_element [ ""name"" ], ""/api/with/profiler/<message>"" ) <TAB> <TAB> <TAB> self. assertEqual ( list_element [ ""method"" ], ""GET"" ) <TAB> <TAB> <TAB> self. assertEqual ( list_element [ ""kwargs"" ], { ""message"" : ""hello"" } ) <TAB> <TAB> <TAB> self. assertEqual ( list_element [ ""context"" ] [ ""args"" ], { ""q"" : ""2"" } ) <TAB> self. assertEqual ( True, test_flag )",False,list_element['name'] == '/api/with/profiler/<message>',list_element[0],0.6491895914077759
|
||
|
3638,"def get_complete_position ( self, context : UserContext ) -> int : <TAB> <TAB> for prefix_pattern in convert2list ( <TAB> <TAB> self. get_filetype_var ( context [ ""filetype"" ], ""prefix_patterns"" ) <TAB> ) : <TAB> <TAB> m = re. search ( self. _object_pattern + prefix_pattern + r""\w*$"", context [ ""input"" ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> self. _prefix = re. sub ( r""\w*$"", """", m. group ( 0 ) ) <TAB> <TAB> m = re. search ( r""\w*$"", context [ ""input"" ] ) <TAB> <TAB> if m : <TAB> <TAB> <TAB> return m. start ( ) <TAB> return - 1",False,m is None or prefix_pattern == '',m and m.group(0) > 0,0.650195300579071
|
||
|
3639,"def _try_except_filenotfounderror ( try_func, except_func ) : <TAB> if sys. version_info >= ( 3, 3 ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> try_func ( ) <TAB> <TAB> except FileNotFoundError as exc : <TAB> <TAB> <TAB> except_func ( exc ) <TAB> elif os. name!= ""nt"" : <TAB> <TAB> try : <TAB> <TAB> <TAB> try_func ( ) <TAB> <TAB> except EnvironmentError as exc : <TAB> <TAB> <TAB> if exc. errno!= ENOENT : <TAB> <TAB> <TAB> <TAB> raise <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> except_func ( exc ) <TAB> else : <TAB> <TAB> try : <TAB> <TAB> <TAB> try_func ( ) <TAB> <TAB> except WindowsError as exc : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> except_func ( exc ) <TAB> <TAB> except EnvironmentError as exc : <TAB> <TAB> <TAB> if exc. errno!= ENOENT : <TAB> <TAB> <TAB> <TAB> raise <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> except_func ( exc )",False,"exc.errno not in (2, 3)",exc.errno != errno.ENOENT,0.6522950530052185
|
||
|
3640,"def handle ( self, * app_labels, ** options ) : <TAB> include_deployment_checks = options [ ""deploy"" ] <TAB> if options [ ""list_tags"" ] : <TAB> <TAB> self. stdout. write ( <TAB> <TAB> <TAB> ""\n"". join ( sorted ( registry. tags_available ( include_deployment_checks ) ) ) <TAB> <TAB> ) <TAB> <TAB> return <TAB> if app_labels : <TAB> <TAB> app_configs = [ apps. get_app_config ( app_label ) for app_label in app_labels ] <TAB> else : <TAB> <TAB> app_configs = None <TAB> tags = options [ ""tags"" ] <TAB> if tags : <TAB> <TAB> try : <TAB> <TAB> <TAB> invalid_tag = next ( <TAB> <TAB> <TAB> <TAB> tag <TAB> <TAB> <TAB> <TAB> for tag in tags <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> ) <TAB> <TAB> except StopIteration : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> else : <TAB> <TAB> <TAB> raise CommandError ( <TAB> <TAB> <TAB> <TAB> 'There is no system check with the ""%s"" tag.' % invalid_tag <TAB> <TAB> <TAB> ) <TAB> self. check ( <TAB> <TAB> app_configs = app_configs, <TAB> <TAB> tags = tags, <TAB> <TAB> display_num_errors = True, <TAB> <TAB> include_deployment_checks = include_deployment_checks, <TAB> <TAB> fail_level = getattr ( checks, options [ ""fail_level"" ] ), <TAB> )",False,"not checks.tag_exists(tag, include_deployment_checks)",invalid_tag,0.6475452184677124
|
||
|
3641,"def internal_gen ( ) : <TAB> current_epoch = ( self. epoch - 1 ) % self. config. n_epochs + 1 <TAB> it = iter ( gen ) <TAB> if train : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> desc = ""Initialization Epoch {}/{}"". format ( <TAB> <TAB> <TAB> <TAB> current_epoch, self. config. n_epochs <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> desc = ""Epoch {}/{}"". format ( current_epoch, self. config. n_epochs ) <TAB> else : <TAB> <TAB> desc = ""Validation"" <TAB> for _, i in zip ( range ( self. _skip_tqdm ), it ) : <TAB> <TAB> yield i <TAB> for i in ProgressBar ( <TAB> <TAB> it, <TAB> <TAB> desc = desc, <TAB> <TAB> total = total, <TAB> <TAB> miniters = 1, <TAB> <TAB> leave = current_epoch == self. config. n_epochs and train, <TAB> <TAB> update_hook = update_hook, <TAB> <TAB> silent = self. config. debugging_logs, <TAB> ) : <TAB> <TAB> yield i <TAB> if train : <TAB> <TAB> self. epoch += 1",False,self.config.prefit_init and self.epoch <= self.config.n_epochs,current_epoch == self.config.n_epochs,0.6488403081893921
|
||
|
3642,"def __recv_null ( self ) : <TAB> """"""Receive a null byte."""""" <TAB> while 1 : <TAB> <TAB> c = self. sock. recv ( 1 ) <TAB> <TAB> if c == """" : <TAB> <TAB> <TAB> self. close ( ) <TAB> <TAB> <TAB> raise EOFError ( ""Socket Closed"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return",False,c == '\x00',c != '',0.6582741737365723
|
||
|
3643,"def sample_pos_items_for_u ( u, num ) : <TAB> <TAB> pos_items = self. train_items [ u ] <TAB> n_pos_items = len ( pos_items ) <TAB> pos_batch = [ ] <TAB> while True : <TAB> <TAB> if len ( pos_batch ) == num : <TAB> <TAB> <TAB> break <TAB> <TAB> pos_id = np. random. randint ( low = 0, high = n_pos_items, size = 1 ) [ 0 ] <TAB> <TAB> pos_i_id = pos_items [ pos_id ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> pos_batch. append ( pos_i_id ) <TAB> return pos_batch",False,pos_i_id not in pos_batch,np.random.random() < 0.5,0.6526123285293579
|
||
|
3644,"def get_report_to_platform ( self, args, scan_reports ) : <TAB> if self. bc_api_key : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> repo_id = self. get_repository ( args ) <TAB> <TAB> <TAB> self. setup_bridgecrew_credentials ( <TAB> <TAB> <TAB> <TAB> bc_api_key = self. bc_api_key, repo_id = repo_id <TAB> <TAB> <TAB> ) <TAB> <TAB> if self. is_integration_configured ( ) : <TAB> <TAB> <TAB> self. _upload_run ( args, scan_reports )",False,args.directory,self.is_bridgecrew_configured(),0.6583524346351624
|
||
|
3645,"def getSinglePairs ( self ) : <TAB> for pairPos in self. pairPosList : <TAB> <TAB> if pairPos. Format == 1 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> firstGlyphsList = pairPos. Coverage. glyphs <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for pairSetIndex, pairSetInstance in enumerate ( pairPos. PairSet ) : <TAB> <TAB> <TAB> <TAB> for pairValueRecordItem in pairPos. PairSet [ <TAB> <TAB> <TAB> <TAB> <TAB> pairSetIndex <TAB> <TAB> <TAB> <TAB> ]. PairValueRecord : <TAB> <TAB> <TAB> <TAB> <TAB> secondGlyph = pairValueRecordItem. SecondGlyph <TAB> <TAB> <TAB> <TAB> <TAB> valueFormat = pairPos. ValueFormat1 <TAB> <TAB> <TAB> <TAB> <TAB> if valueFormat == 5 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> kernValue = ""<%d 0 %d 0>"" % ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> pairValueRecordItem. Value1. XPlacement, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> pairValueRecordItem. Value1. XAdvance, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> elif valueFormat == 0 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> kernValue = ""<0 0 0 0>"" <TAB> <TAB> <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> kernValue = pairValueRecordItem. Value1. XAdvance <TAB> <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> print ( ""\tValueFormat1 = %d"" % valueFormat, file = sys. stdout ) <TAB> <",False,valueFormat == 4,valueFormat == 6,0.66883385181427
|
||
|
3646,"def parseMessage ( self, toAddress, fromAddress, subject, message ) : <TAB> super ( GatewayAccount, self ). parseMessage ( toAddress, fromAddress, subject, message ) <TAB> if fromAddress == self. relayAddress : <TAB> <TAB> matches = self. regExpIncoming. search ( subject ) <TAB> <TAB> if not matches is None : <TAB> <TAB> <TAB> self. subject = """" <TAB> <TAB> <TAB> if not matches. group ( 1 ) is None : <TAB> <TAB> <TAB> <TAB> self. subject += matches. group ( 1 ) <TAB> <TAB> <TAB> if not matches. group ( 3 ) is None : <TAB> <TAB> <TAB> <TAB> self. subject += matches. group ( 3 ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. fromLabel = matches. group ( 2 ) <TAB> <TAB> <TAB> <TAB> self. fromAddress = matches. group ( 2 ) <TAB> if toAddress == self. relayAddress : <TAB> <TAB> matches = self. regExpOutgoing. search ( subject ) <TAB> <TAB> if not matches is None : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. subject = matches. group ( 2 ) <TAB> <TAB> <TAB> if not matches. group ( 1 ) is None : <TAB> <TAB> <TAB> <TAB> self. toLabel = matches. group ( 1 ) <TAB> <TAB> <TAB> <TAB> self. toAddress = matches. group ( 1 )",False,not matches.group(2) is None,len(matches) == 3,0.6473790407180786
|
||
|
3647,"def test_fuzz_required ( ) : <TAB> for _ in range ( 1000 ) : <TAB> <TAB> n_hidden = random. randint ( 10, 100 ) <TAB> <TAB> n_in = random. randint ( 1, 10 ) <TAB> <TAB> n_out = random. randint ( 1, 10 ) <TAB> <TAB> nodes = list ( <TAB> <TAB> <TAB> set ( random. randint ( 0, 1000 ) for _ in range ( n_in + n_out + n_hidden ) ) <TAB> <TAB> ) <TAB> <TAB> random. shuffle ( nodes ) <TAB> <TAB> inputs = nodes [ : n_in ] <TAB> <TAB> outputs = nodes [ n_in : n_in + n_out ] <TAB> <TAB> connections = [ ] <TAB> <TAB> for _ in range ( n_hidden * 2 ) : <TAB> <TAB> <TAB> a = random. choice ( nodes ) <TAB> <TAB> <TAB> b = random. choice ( nodes ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if a in inputs and b in inputs : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if a in outputs and b in outputs : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> connections. append ( ( a, b ) ) <TAB> <TAB> required = required_for_output ( inputs, outputs, connections ) <TAB> <TAB> for o in outputs : <TAB> <TAB> <TAB> assert o in required",False,a == b,b in outputs,0.6708201766014099
|
||
|
3648,"def _add_defaults_data_files ( self ) : <TAB> <TAB> if self. distribution. has_data_files ( ) : <TAB> <TAB> for item in self. distribution. data_files : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> item = convert_path ( item ) <TAB> <TAB> <TAB> <TAB> if os. path. isfile ( item ) : <TAB> <TAB> <TAB> <TAB> <TAB> self. filelist. append ( item ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> dirname, filenames = item <TAB> <TAB> <TAB> <TAB> for f in filenames : <TAB> <TAB> <TAB> <TAB> <TAB> f = convert_path ( f ) <TAB> <TAB> <TAB> <TAB> <TAB> if os. path. isfile ( f ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. filelist. append ( f )",False,"isinstance(item, str)","isinstance(item, basestring)",0.6552574634552002
|
||
|
3649,"def expected_forward_without_reduce ( self, x_data, t_data, class_weight ) : <TAB> x = numpy. rollaxis ( x_data, 1, x_data. ndim ). reshape ( ( t_data. size, x_data. shape [ 1 ] ) ) <TAB> t = t_data. ravel ( ) <TAB> loss_shape = x_data. shape [ 0 : 1 ] + x_data. shape [ 2 : ] <TAB> loss_expect = numpy. zeros ( loss_shape, x_data. dtype ) <TAB> for i, ( ti, loss_idx ) in enumerate ( zip ( t, numpy. ndindex ( * loss_shape ) ) ) : <TAB> <TAB> xi = x [ i ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> log_z = numpy. ufunc. reduce ( numpy. logaddexp, xi ) <TAB> <TAB> if class_weight is None : <TAB> <TAB> <TAB> loss_expect [ loss_idx ] = - ( xi - log_z ) [ ti ] <TAB> <TAB> else : <TAB> <TAB> <TAB> loss_expect [ loss_idx ] = - ( xi - log_z ) [ ti ] * class_weight [ ti ] <TAB> return numpy. asarray ( loss_expect, dtype = x. dtype )",False,ti == -1,numpy.abs(xi) > 0.0,0.6640071272850037
|
||
|
3650,"def handler ( chan, host, port ) : <TAB> sock = socket ( ) <TAB> try : <TAB> <TAB> sock. connect ( ( host, port ) ) <TAB> except Exception as e : <TAB> <TAB> if verbose == True : <TAB> <TAB> <TAB> print ( e ) <TAB> <TAB> return <TAB> while True : <TAB> <TAB> r, w, x = select. select ( [ sock, chan ], [ ], [ ] ) <TAB> <TAB> if sock in r : <TAB> <TAB> <TAB> data = sock. recv ( 1024 ) <TAB> <TAB> <TAB> if len ( data ) == 0 : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> chan. send ( data ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> data = chan. recv ( 1024 ) <TAB> <TAB> <TAB> if len ( data ) == 0 : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> sock. send ( data ) <TAB> chan. close ( ) <TAB> sock. close ( )",False,chan in r,sock in r,0.6814488172531128
|
||
|
3651,"def extend ( self, tasks ) : <TAB> """"""Add tasks to this particular shovel"""""" <TAB> self. _tasks. extend ( tasks ) <TAB> for task in tasks : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> current = self. map <TAB> <TAB> modules = task. fullname. split ( ""."" ) <TAB> <TAB> for module in modules [ : - 1 ] : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> logger. warn ( ""Overriding task %s with a module"" % current [ module ]. file ) <TAB> <TAB> <TAB> <TAB> shovel = Shovel ( ) <TAB> <TAB> <TAB> <TAB> shovel. overrides = current [ module ] <TAB> <TAB> <TAB> <TAB> current [ module ] = shovel <TAB> <TAB> <TAB> current = current [ module ]. map <TAB> <TAB> <TAB> <TAB> name = modules [ - 1 ] <TAB> <TAB> if name in current : <TAB> <TAB> <TAB> logger. warn ( ""Overriding %s with %s"" % ( ""."". join ( modules ), task. file ) ) <TAB> <TAB> <TAB> task. overrides = current [ name ] <TAB> <TAB> current [ name ] = task",False,"not isinstance(current[module], Shovel)",module in current,0.6566530466079712
|
||
|
3652,"def init ( self, * args, ** kwargs ) : <TAB> if ""_state"" not in kwargs : <TAB> <TAB> state = { } <TAB> <TAB> <TAB> <TAB> for arg in ( ""children"", ""windowState"", ""detachedPanels"" ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> state [ arg ] = kwargs [ arg ] <TAB> <TAB> <TAB> <TAB> del kwargs [ arg ] <TAB> <TAB> if state : <TAB> <TAB> <TAB> kwargs [ ""_state"" ] = state <TAB> originalInit ( self, * args, ** kwargs )",True,arg in kwargs,arg in kwargs,0.677591860294342
|
||
|
3653,"def update_render_status ( self ) : <TAB> Gdk. threads_enter ( ) <TAB> if mltxmlheadless. session_render_complete ( self. get_container_program_id ( ) ) == True : <TAB> <TAB> <TAB> <TAB> job_msg = self. get_completed_job_message ( ) <TAB> <TAB> jobs. update_job_queue ( job_msg ) <TAB> <TAB> GLib. idle_add ( self. create_producer_and_do_update_edit, None ) <TAB> else : <TAB> <TAB> status = mltxmlheadless. get_session_status ( self. get_container_program_id ( ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> fraction, elapsed = status <TAB> <TAB> <TAB> if self. container_data. render_data. do_video_render == True : <TAB> <TAB> <TAB> <TAB> msg = _ ( ""Rendering Video"" ) <TAB> <TAB> <TAB> elif step == ""2"" : <TAB> <TAB> <TAB> <TAB> msg = _ ( ""Rendering Image Sequence"" ) <TAB> <TAB> <TAB> job_msg = self. get_job_queue_message ( ) <TAB> <TAB> <TAB> job_msg. progress = float ( fraction ) <TAB> <TAB> <TAB> job_msg. elapsed = float ( elapsed ) <TAB> <TAB> <TAB> job_msg. text = msg <TAB> <TAB> <TAB> jobs. update_job_queue ( job_msg ) <TAB> <TAB> else : <TAB> <TAB> <TAB> pass <TAB> Gdk. threads_leave ( )",False,status != None,status != 'ACTIVE',0.6671301126480103
|
||
|
3654,"def search ( path, prefix = """" ) : <TAB> loader = TestLoader ( ) <TAB> for _, name, is_pkg in iter_modules ( path ) : <TAB> <TAB> full_name = ""{}.{}"". format ( prefix, name ) <TAB> <TAB> module_path = os. path. join ( path [ 0 ], name ) <TAB> <TAB> if is_pkg : <TAB> <TAB> <TAB> search ( [ module_path ], full_name ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> test_module = import_module ( full_name ) <TAB> <TAB> <TAB> for suite in loader. loadTestsFromModule ( test_module ) : <TAB> <TAB> <TAB> <TAB> for test in suite. _tests : <TAB> <TAB> <TAB> <TAB> <TAB> path = ""{}.{}.{}"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> full_name, test. __class__. __name__, test. _testMethodName <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> rec = { <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""ver"" : ""1.0"", <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""execution"" : { <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""command"" : ""python -m unittest {}"". format ( path ), <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""recording"" : find_recording_file ( path ), <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> }, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""classifier"" : { <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""identifier"" : path, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""type"" : get_test_type ( test",False,not is_pkg and name.startswith('test'),"hasattr(loader, 'loadTests')",0.6488199830055237
|
||
|
3655,"def visit_Assign ( self, node ) : <TAB> for i in node. targets : <TAB> <TAB> err = _not_assignable ( i ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> msg = ""can't assign to {}"". format ( err ) <TAB> <TAB> <TAB> self. error = msg, i. lineno, i. col_offset <TAB> <TAB> <TAB> break",False,err is not None,err,0.666167676448822
|
||
|
3656,"def _maybeRebuildAtlas ( self, threshold = 4, minlen = 1000 ) : <TAB> n = len ( self. fragmentAtlas ) <TAB> if ( n > minlen ) and ( n > threshold * len ( self. data ) ) : <TAB> <TAB> self. fragmentAtlas. rebuild ( <TAB> <TAB> <TAB> list ( zip ( * self. _style ( [ ""symbol"", ""size"", ""pen"", ""brush"" ] ) ) ) <TAB> <TAB> ) <TAB> <TAB> self. data [ ""sourceRect"" ] = 0 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _sourceQRect. clear ( ) <TAB> <TAB> self. updateSpots ( )",False,_USE_QRECT,self._sourceQRect.size() > 0,0.6639128923416138
|
||
|
3657,"def splitProcess ( path, mode ) : <TAB> output = [ ] <TAB> currentSize = 0 <TAB> currentTarget = path <TAB> if options. webtoon : <TAB> <TAB> targetSize = 104857600 <TAB> else : <TAB> <TAB> targetSize = 419430400 <TAB> if options. batchsplit == 2 and mode == 2 : <TAB> <TAB> mode = 3 <TAB> if mode < 3 : <TAB> <TAB> for root, dirs, files in walkLevel ( path, 0 ) : <TAB> <TAB> <TAB> for name in files if mode == 1 else dirs : <TAB> <TAB> <TAB> <TAB> if mode == 1 : <TAB> <TAB> <TAB> <TAB> <TAB> size = os. path. getsize ( os. path. join ( root, name ) ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> size = getDirectorySize ( os. path. join ( root, name ) ) <TAB> <TAB> <TAB> <TAB> if currentSize + size > targetSize : <TAB> <TAB> <TAB> <TAB> <TAB> currentTarget, pathRoot = createNewTome ( ) <TAB> <TAB> <TAB> <TAB> <TAB> output. append ( pathRoot ) <TAB> <TAB> <TAB> <TAB> <TAB> currentSize = size <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> currentSize += size <TAB> <TAB> <TAB> <TAB> if path!= currentTarget : <TAB> <TAB> <TAB> <TAB> <TAB> move ( os. path. join ( root, name ), os. path. join ( currentTarget, name ) ) <TAB> else : <TAB> <TAB> firstTome = True <TAB> <TAB> for root, dirs, _ in walkLevel ( path, 0 ) : <TAB> <TAB> <TAB> for name in dirs : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> currentTarget, pathRoot = createNewTome",False,not firstTome,firstTome,0.6656038761138916
|
||
|
3658,"def native_color ( c ) : <TAB> try : <TAB> <TAB> color = CACHE [ c ] <TAB> except KeyError : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> c = NAMED_COLOR [ c ] <TAB> <TAB> color = Color. FromArgb ( <TAB> <TAB> <TAB> int ( c. rgba. a * 255 ), int ( c. rgba. r ), int ( c. rgba. g ), int ( c. rgba. b ) <TAB> <TAB> ) <TAB> <TAB> CACHE [ c ] = color <TAB> return color",False,"isinstance(c, str)",c >= len(NAMED_COLOR),0.6585873961448669
|
||
|
3659,"def fmt ( console : Console, targets : HydratedTargets ) -> Fmt : <TAB> results = yield [ <TAB> <TAB> Get ( FmtResult, FmtTarget, target. adaptor ) <TAB> <TAB> for target in targets <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if isinstance ( <TAB> <TAB> <TAB> target. adaptor, <TAB> <TAB> <TAB> ( <TAB> <TAB> <TAB> <TAB> PythonAppAdaptor, <TAB> <TAB> <TAB> <TAB> PythonTargetAdaptor, <TAB> <TAB> <TAB> <TAB> PythonTestsAdaptor, <TAB> <TAB> <TAB> <TAB> PythonBinaryAdaptor, <TAB> <TAB> <TAB> ), <TAB> <TAB> ) <TAB> <TAB> and hasattr ( target. adaptor, ""sources"" ) <TAB> ] <TAB> for result in results : <TAB> <TAB> files_content = yield Get ( FilesContent, Digest, result. digest ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for file_content in files_content : <TAB> <TAB> <TAB> with Path ( get_buildroot ( ), file_content. path ). open ( ""wb"" ) as f : <TAB> <TAB> <TAB> <TAB> f. write ( file_content. content ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> console. print_stdout ( result. stdout ) <TAB> <TAB> if result. stderr : <TAB> <TAB> <TAB> console. print_stderr ( result. stderr ) <TAB> <TAB> exit_code = 0 <TAB> yield Fmt ( exit_code )",True,result.stdout,result.stdout,0.6825716495513916
|
||
|
3660,"def expect_block_mapping_key ( self, first = False ) : <TAB> if not first and isinstance ( self. event, MappingEndEvent ) : <TAB> <TAB> self. indent = self. indents. pop ( ) <TAB> <TAB> self. state = self. states. pop ( ) <TAB> else : <TAB> <TAB> self. write_indent ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. states. append ( self. expect_block_mapping_simple_value ) <TAB> <TAB> <TAB> self. expect_node ( mapping = True, simple_key = True ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. write_indicator ( u""?"", True, indention = True ) <TAB> <TAB> <TAB> self. states. append ( self. expect_block_mapping_value ) <TAB> <TAB> <TAB> self. expect_node ( mapping = True )",False,self.check_simple_key(),first,0.6507017016410828
|
||
|
3661,"def _url_encode_impl ( obj, charset, encode_keys, sort, key ) : <TAB> from. datastructures import iter_multi_items <TAB> iterable = iter_multi_items ( obj ) <TAB> if sort : <TAB> <TAB> iterable = sorted ( iterable, key = key ) <TAB> for key, value in iterable : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> if not isinstance ( key, bytes ) : <TAB> <TAB> <TAB> key = text_type ( key ). encode ( charset ) <TAB> <TAB> if not isinstance ( value, bytes ) : <TAB> <TAB> <TAB> value = text_type ( value ). encode ( charset ) <TAB> <TAB> yield _fast_url_quote_plus ( key ) + ""="" + _fast_url_quote_plus ( value )",True,value is None,value is None,0.6580206155776978
|
||
|
3662,"def get_waiting ( self ) -> List [ str ] : <TAB> tasks = self. get_running_tasks_checked ( ) <TAB> waiting = [ ] <TAB> for task in tasks : <TAB> <TAB> state_msg = task. state. name <TAB> <TAB> if task. state in TaskState. has_started ( ) : <TAB> <TAB> <TAB> task = self. onefuzz. tasks. get ( task. task_id ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> state_msg = ""waiting-for-heartbeat"" <TAB> <TAB> waiting. append ( f""{task.config.task.type.name}:{state_msg}"" ) <TAB> return waiting",False,task.events,task.config.task.type == TaskState.cancelled and (not task.config.task.state.has_started()) and (not task.config.task.state.has_started()),0.6749505996704102
|
||
|
3663,"def migrate_common_facts ( facts ) : <TAB> """"""Migrate facts from various roles into common"""""" <TAB> params = { ""node"" : ( ""portal_net"" ), ""master"" : ( ""portal_net"" ) } <TAB> if ""common"" not in facts : <TAB> <TAB> facts [ ""common"" ] = { } <TAB> <TAB> for role in params. keys ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> for param in params [ role ] : <TAB> <TAB> <TAB> <TAB> if param in facts [ role ] : <TAB> <TAB> <TAB> <TAB> <TAB> facts [ ""common"" ] [ param ] = facts [ role ]. pop ( param ) <TAB> return facts",False,role in facts,role in params,0.6870690584182739
|
||
|
3664,"def build ( opt ) : <TAB> dpath, version = download ( opt ) <TAB> if ""light_use_speech_prefix"" not in opt : <TAB> <TAB> opt [ ""light_use_speech_prefix"" ] = True <TAB> <TAB> fields = [ <TAB> <TAB> ""taskname"", <TAB> <TAB> ""setting"", <TAB> <TAB> ""objects"", <TAB> <TAB> ""person_names"", <TAB> <TAB> ""persona"", <TAB> <TAB> ""emote"", <TAB> <TAB> ""speech"", <TAB> <TAB> ""action"", <TAB> <TAB> ""affordances"", <TAB> <TAB> ""repeat"", <TAB> <TAB> ""cands"", <TAB> <TAB> ""current_self_output"", <TAB> <TAB> ""clip_cands"", <TAB> <TAB> ""speech_prefix"", <TAB> ] <TAB> fpath = """" <TAB> for f in fields : <TAB> <TAB> fpath += f + str ( opt [ ""light_use_"" + f ] ) + ""_"" <TAB> dpath2 = os. path. join ( opt [ ""datapath"" ], ""light_dialogue"", fpath [ : - 1 ] ) <TAB> if not build_data. built ( dpath2, version ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> build_data. remove_dir ( dpath2 ) <TAB> <TAB> build_data. make_dir ( dpath2 ) <TAB> <TAB> fname = ""light_data.pkl"" <TAB> <TAB> fname2 = ""light_unseen_data.pkl"" <TAB> <TAB> build_from_db ( opt, dpath, dpath2, fname, fname2 ) <TAB> <TAB> <TAB> <TAB> build_data. mark_done ( dpath2, version )",False,build_data.built(dpath2),dpath2 != dpath2,0.6462545394897461
|
||
|
3665,"def capture_server ( evt, buf, serv ) : <TAB> try : <TAB> <TAB> serv. listen ( 5 ) <TAB> <TAB> conn, addr = serv. accept ( ) <TAB> except socket. timeout : <TAB> <TAB> pass <TAB> else : <TAB> <TAB> n = 200 <TAB> <TAB> while n > 0 : <TAB> <TAB> <TAB> r, w, e = select. select ( [ conn ], [ ], [ ] ) <TAB> <TAB> <TAB> if r : <TAB> <TAB> <TAB> <TAB> data = conn. recv ( 10 ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> buf. write ( data. replace ( ""\n"", """" ) ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> n -= 1 <TAB> <TAB> <TAB> time. sleep ( 0.01 ) <TAB> <TAB> conn. close ( ) <TAB> finally : <TAB> <TAB> serv. close ( ) <TAB> <TAB> evt. set ( )",False,'\n' in data,n > 0,0.6613521575927734
|
||
|
3666,"def check_and_apply_update ( ) : <TAB> check_releases ( ) <TAB> if not args. release_update : <TAB> <TAB> gitconfig ( ) <TAB> <TAB> branch = settings. general. branch <TAB> <TAB> g = git. cmd. Git ( current_working_directory ) <TAB> <TAB> g. fetch ( ""origin"" ) <TAB> <TAB> result = g. diff ( ""--shortstat"", ""origin/"" + branch ) <TAB> <TAB> if len ( result ) == 0 : <TAB> <TAB> <TAB> logging. info ( ""BAZARR No new version of Bazarr available."" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> g. reset ( ""--hard"", ""HEAD"" ) <TAB> <TAB> <TAB> g. checkout ( branch ) <TAB> <TAB> <TAB> g. reset ( ""--hard"", ""origin/"" + branch ) <TAB> <TAB> <TAB> g. pull ( ) <TAB> <TAB> <TAB> logging. info ( <TAB> <TAB> <TAB> <TAB> ""BAZARR Updated to latest version. Restart required. "" + result <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> updated ( ) <TAB> else : <TAB> <TAB> url = ""https://api.github.com/repos/morpheus65535/bazarr/releases/latest"" <TAB> <TAB> release = request_json ( <TAB> <TAB> <TAB> url, <TAB> <TAB> <TAB> timeout = 20, <TAB> <TAB> <TAB> whitelist_status_code = 404, <TAB> <TAB> <TAB> validator = lambda x : type ( x ) == list, <TAB> <TAB> ) <TAB> <TAB> if release is None : <TAB> <TAB> <TAB> logging. warning ( ""BAZARR Could not get releases from GitHub."" ) <TAB> <TAB> <TAB> return <TAB> <TAB> else : <TAB> <TAB> <TAB> latest_release = release [ ""tag_name"" ] <TAB> <TAB> if<mask> : <TAB> <TAB> <",False,'v' + os.environ['BAZARR_VERSION'] != latest_release,latest_release is not None,0.6523812413215637
|
||
|
3667,"def get_data ( self, path ) : <TAB> """"""Gross hack to contort loader to deal w/ load_*()'s bad API."""""" <TAB> if self. file and path == self. path : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> file = self. file <TAB> <TAB> else : <TAB> <TAB> <TAB> self. file = file = open ( self. path, ""r"" ) <TAB> <TAB> with file : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return file. read ( ) <TAB> else : <TAB> <TAB> return super ( ). get_data ( path )",False,not self.file.closed,"hasattr(self.file, 'read')",0.6608824133872986
|
||
|
3668,"def run ( self, input, generator ) : <TAB> complexities = { } <TAB> <TAB> <TAB> piter = generator. orderedEnumeration ( ) <TAB> maxLevin = 1 <TAB> <TAB> while True : <TAB> <TAB> <TAB> <TAB> c = 0 <TAB> <TAB> while c <= maxLevin : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> c, p = next ( piter ) <TAB> <TAB> <TAB> except StopIteration : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> complexities [ c ] = [ p ] <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> complexities [ c ]. append ( p ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for c in range ( maxLevin ) : <TAB> <TAB> <TAB> for p in complexities [ c ] : <TAB> <TAB> <TAB> <TAB> boundP = timeBoundExecution ( p, 2 ** ( maxLevin - c ) / maxLevin ) <TAB> <TAB> <TAB> <TAB> res = boundP. run ( input ) <TAB> <TAB> <TAB> <TAB> if self. stoppingCriterion ( res ) : <TAB> <TAB> <TAB> <TAB> <TAB> return res <TAB> <TAB> maxLevin += 1",True,c not in complexities,c not in complexities,0.6749194860458374
|
||
|
3669,"def get_user_context ( request, escape = False ) : <TAB> if isinstance ( request, HttpRequest ) : <TAB> <TAB> user = getattr ( request, ""user"", None ) <TAB> <TAB> result = { ""ip_address"" : request. META [ ""REMOTE_ADDR"" ] } <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> result. update ( <TAB> <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> <TAB> ""email"" : user. email, <TAB> <TAB> <TAB> <TAB> <TAB> ""id"" : user. id, <TAB> <TAB> <TAB> <TAB> } <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if user. name : <TAB> <TAB> <TAB> <TAB> result [ ""name"" ] = user. name <TAB> else : <TAB> <TAB> result = { } <TAB> return mark_safe ( json. dumps ( result ) )",False,user and user.is_authenticated(),escape,0.6531888246536255
|
||
|
3670,"def _transform_count_encode ( self, X_in, y ) : <TAB> """"""Perform the transform count encoding."""""" <TAB> X = X_in. copy ( deep = True ) <TAB> X. loc [ :, self. cols ] = X. fillna ( value = np. nan ) <TAB> for col in self. cols : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if col in self. _min_group_categories. keys ( ) : <TAB> <TAB> <TAB> <TAB> X [ col ] = X [ col ]. map ( self. _min_group_categories [ col ] ). fillna ( X [ col ] ) <TAB> <TAB> X [ col ] = X [ col ]. map ( self. mapping [ col ] ) <TAB> <TAB> if isinstance ( self. _handle_unknown [ col ], ( int, np. integer ) ) : <TAB> <TAB> <TAB> X [ col ] = X [ col ]. fillna ( self. _handle_unknown [ col ] ) <TAB> <TAB> elif self. _handle_unknown [ col ] == ""error"" and X [ col ]. isnull ( ). any ( ) : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""Missing data found in column %s at transform time."" % ( col, ) <TAB> <TAB> <TAB> ) <TAB> return X, self. mapping",False,self._min_group_size is not None,self.mapping[col],0.6533434391021729
|
||
|
3671,"def mouse ( self, button, mods, x, y ) : <TAB> if button == 1 : <TAB> <TAB> for i in range ( 4 ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. hit = i <TAB> elif button == - 1 : <TAB> <TAB> self. hit = None <TAB> elif self. hit!= None : <TAB> <TAB> self. coords [ self. hit ] = ( x, y ) <TAB> <TAB> self. view. dirty ( )",False,"hypot(x - self.coords[i][0], y - self.coords[i][1]) < 4",i > 0,0.6549968719482422
|
||
|
3672,"def _process_watch ( self, watched_event ) : <TAB> logger. debug ( ""process_watch: %r"", watched_event ) <TAB> with handle_exception ( self. _tree. _error_listeners ) : <TAB> <TAB> if watched_event. type == EventType. CREATED : <TAB> <TAB> <TAB> assert self. _parent is None, ""unexpected CREATED on non-root"" <TAB> <TAB> <TAB> self. on_created ( ) <TAB> <TAB> elif watched_event. type == EventType. DELETED : <TAB> <TAB> <TAB> self. on_deleted ( ) <TAB> <TAB> elif watched_event. type == EventType. CHANGED : <TAB> <TAB> <TAB> self. _refresh_data ( ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> self. _refresh_children ( )",False,watched_event.type == EventType.CHILD,watched_event.type == EventType.CHANGING,0.6578012704849243
|
||
|
3673,"def _reauthenticate_and_retry ( self, func = None ) : <TAB> import kubernetes <TAB> <TAB> <TAB> <TAB> logger. info ( ""Trying to reauthenticate"" ) <TAB> kubernetes. config. load_kube_config ( ) <TAB> subprocess. run ( [ ""kubectl"", ""get"", ""nodes"" ] ) <TAB> self. kubeapi = kubernetes. client. CoreV1Api ( ) <TAB> self. batchapi = kubernetes. client. BatchV1Api ( ) <TAB> try : <TAB> <TAB> self. register_secret ( ) <TAB> except kubernetes. client. rest. ApiException as e : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> logger. warning ( ""409 conflict ApiException when registering secrets"" ) <TAB> <TAB> <TAB> logger. warning ( e ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise WorkflowError ( <TAB> <TAB> <TAB> <TAB> e, <TAB> <TAB> <TAB> <TAB> ""This is likely a bug in "" <TAB> <TAB> <TAB> <TAB> ""https://github.com/kubernetes-client/python."", <TAB> <TAB> <TAB> ) <TAB> if func : <TAB> <TAB> return func ( )",False,e.status == 409 and e.reason == 'Conflict',e.args.error_code == 5,0.657464325428009
|
||
|
3674,"def create_fts_parser ( server, db_name, schema_name, fts_parser_name ) : <TAB> """"""This function will add the fts_parser under test schema."""""" <TAB> try : <TAB> <TAB> connection = get_db_connection ( <TAB> <TAB> <TAB> db_name, <TAB> <TAB> <TAB> server [ ""username"" ], <TAB> <TAB> <TAB> server [ ""db_password"" ], <TAB> <TAB> <TAB> server [ ""host"" ], <TAB> <TAB> <TAB> server [ ""port"" ], <TAB> <TAB> <TAB> server [ ""sslmode"" ], <TAB> <TAB> ) <TAB> <TAB> pg_cursor = connection. cursor ( ) <TAB> <TAB> query = ( <TAB> <TAB> <TAB> ""DROP TEXT SEARCH PARSER IF EXISTS "" + schema_name + ""."" + fts_parser_name <TAB> <TAB> ) <TAB> <TAB> pg_cursor. execute ( query ) <TAB> <TAB> query = ( <TAB> <TAB> <TAB> ""CREATE TEXT SEARCH PARSER "" <TAB> <TAB> <TAB> + schema_name <TAB> <TAB> <TAB> + ""."" <TAB> <TAB> <TAB> + fts_parser_name <TAB> <TAB> <TAB> + ""(START=prsd_start, GETTOKEN=prsd_nexttoken, "" <TAB> <TAB> <TAB> ""END=prsd_end, LEXTYPES=dispell_init)"" <TAB> <TAB> ) <TAB> <TAB> pg_cursor. execute ( query ) <TAB> <TAB> connection. commit ( ) <TAB> <TAB> <TAB> <TAB> pg_cursor. execute ( <TAB> <TAB> <TAB> ""select oid from pg_catalog.pg_ts_parser where "" <TAB> <TAB> <TAB> ""prsname = '%s' order by oid ASC limit 1"" % fts_parser_name <TAB> <TAB> ) <TAB> <TAB> oid = pg_cursor. fetchone ( ) <TAB> <TAB> fts_parser_id = """" <TAB> <TAB> if<mask> :",True,oid,oid,0.7210830450057983
|
||
|
3675,"def wrapper ( * args, spec : Spec, ** kw ) : <TAB> available_configs = set ( configs ) <TAB> if spec. CONFIG_NAME not in available_configs : <TAB> <TAB> message = f""doesn't support this config: {spec.CONFIG_NAME}."" <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> message = f""{message} Reason: {reason}"" <TAB> <TAB> dump_skipping_message ( message ) <TAB> <TAB> return None <TAB> return fn ( * args, spec = spec, ** kw )",False,reason is not None,message,0.664722740650177
|
||
|
3676,"def _run_jdeps_analysis ( <TAB> self, <TAB> target, <TAB> target_artifact_classpaths, <TAB> potential_deps_classpaths, <TAB> jdeps_output_json, ) : <TAB> with self. aliased_classpaths ( potential_deps_classpaths ) as classpaths_by_alias : <TAB> <TAB> with open ( jdeps_output_json, ""w"" ) as f : <TAB> <TAB> <TAB> if len ( target_artifact_classpaths ) : <TAB> <TAB> <TAB> <TAB> jdeps_stdout, jdeps_stderr = self. _spawn_jdeps_command ( <TAB> <TAB> <TAB> <TAB> <TAB> target, target_artifact_classpaths, classpaths_by_alias. keys ( ) <TAB> <TAB> <TAB> <TAB> ). communicate ( ) <TAB> <TAB> <TAB> <TAB> deps_classpaths = set ( ) <TAB> <TAB> <TAB> <TAB> for line in io. StringIO ( jdeps_stdout. decode ( ""utf-8"" ) ) : <TAB> <TAB> <TAB> <TAB> <TAB> match = self. _jdeps_summary_line_regex. fullmatch ( line. strip ( ) ) <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> dep_name = match. group ( 1 ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> deps_classpaths. add ( classpaths_by_alias. get ( dep_name, dep_name ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> deps_classpaths = [ ] <TAB> <TAB> <TAB> json. dump ( list ( deps_classpaths ), f )",False,match is not None,match,0.6587874889373779
|
||
|
3677,"def toxml ( self ) : <TAB> text = self. value <TAB> self. parent. setBidi ( getBidiType ( text ) ) <TAB> if not text. startswith ( HTML_PLACEHOLDER_PREFIX ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> text = text. replace ( ""\n"", ""\n "" ) <TAB> <TAB> elif self. parent. nodeName == ""li"" and self. parent. childNodes [ 0 ] == self : <TAB> <TAB> <TAB> text = ""\n "" + text. replace ( ""\n"", ""\n "" ) <TAB> text = self. doc. normalizeEntities ( text ) <TAB> return text",False,self.parent.nodeName == 'p',self.parent.nodeName == 'li',0.654312014579773
|
||
|
3678,"def runTest ( self, define_g = True ) : <TAB> """"""Run a Leo GeneralTestCase test."""""" <TAB> trace_time = False <TAB> tm = self <TAB> c = tm. c <TAB> p = tm. p. copy ( ) <TAB> if trace_time : <TAB> <TAB> t1 = time. clock ( ) <TAB> script = g. getScript ( c, p ). strip ( ) <TAB> if self. setup_script : <TAB> <TAB> script = self. setup_script + ""\n"" + script <TAB> tm. assertTrue ( script ) <TAB> if c. shortFileName ( ) == ""dynamicUnitTest.leo"" : <TAB> <TAB> c. write_script_file = True <TAB> <TAB> g. app. unitTestDict = { ""c"" : c, ""g"" : g, ""p"" : p and p. copy ( ) } <TAB> if define_g : <TAB> <TAB> d = { <TAB> <TAB> <TAB> ""c"" : c, <TAB> <TAB> <TAB> ""g"" : g, <TAB> <TAB> <TAB> ""p"" : p and p. copy ( ), <TAB> <TAB> <TAB> ""self"" : tm, <TAB> <TAB> } <TAB> else : <TAB> <TAB> d = { <TAB> <TAB> <TAB> ""self"" : tm, <TAB> <TAB> } <TAB> script = script + ""\n"" <TAB> <TAB> <TAB> if c. write_script_file : <TAB> <TAB> scriptFile = c. writeScriptFile ( script ) <TAB> <TAB> <TAB> <TAB> if g. isPython3 : <TAB> <TAB> <TAB> exec ( compile ( script, scriptFile, ""exec"" ), d ) <TAB> <TAB> else : <TAB> <TAB> <TAB> builtins. execfile ( scriptFile, d ) <TAB> else : <TAB> <TAB> exec ( script, d ) <TAB> if trace_time : <TAB> <TAB> t2 = time. clock ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <",False,t2 - t1 > 3.0,t2 and t1 > 0 and (t2 > 0),0.6568703651428223
|
||
|
3679,"def setup_custom_resources ( <TAB> kube_client : KubeClient, <TAB> kind : KubeKind, <TAB> version : str, <TAB> crd : CustomResourceDefinition, <TAB> config_dicts : Mapping [ str, Mapping [ str, Any ] ], <TAB> group : str, <TAB> cluster : str, <TAB> service : str = None, <TAB> instance : str = None, ) -> bool : <TAB> succeded = True <TAB> if config_dicts : <TAB> <TAB> crs = list_custom_resources ( <TAB> <TAB> <TAB> kube_client = kube_client, kind = kind, version = version, group = group <TAB> <TAB> ) <TAB> for svc, config in config_dicts. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> if not reconcile_kubernetes_resource ( <TAB> <TAB> <TAB> kube_client = kube_client, <TAB> <TAB> <TAB> service = svc, <TAB> <TAB> <TAB> instance = instance, <TAB> <TAB> <TAB> instance_configs = config, <TAB> <TAB> <TAB> kind = kind, <TAB> <TAB> <TAB> custom_resources = crs, <TAB> <TAB> <TAB> version = version, <TAB> <TAB> <TAB> group = group, <TAB> <TAB> <TAB> cluster = cluster, <TAB> <TAB> <TAB> crd = crd, <TAB> <TAB> ) : <TAB> <TAB> <TAB> succeded = False <TAB> return succeded",False,service is not None and service != svc,not instance or instance or kind or group or (service == 'cluster'),0.6587128639221191
|
||
|
3680,"def __init__ ( self, sample_function, batch_size, ids, targets = None, shuffle = True ) : <TAB> <TAB> if not is_real_iterable ( ids ) : <TAB> <TAB> raise TypeError ( ""IDs must be an iterable or numpy array of graph node IDs"" ) <TAB> <TAB> if targets is not None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise TypeError ( ""Targets must be None or an iterable or numpy array "" ) <TAB> <TAB> if len ( ids )!= len ( targets ) : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""The length of the targets must be the same as the length of the ids"" <TAB> <TAB> <TAB> ) <TAB> <TAB> self. targets = np. asanyarray ( targets ) <TAB> else : <TAB> <TAB> self. targets = None <TAB> <TAB> if targets is not None and len ( ids )!= len ( targets ) : <TAB> <TAB> raise ValueError ( ""Length of link ids must match length of link targets"" ) <TAB> <TAB> if isinstance ( sample_function, collections. Callable ) : <TAB> <TAB> self. _sample_features = sample_function <TAB> else : <TAB> <TAB> raise TypeError ( <TAB> <TAB> <TAB> ""({}) The sampling function expects a callable function."". format ( <TAB> <TAB> <TAB> <TAB> type ( self ). __name__ <TAB> <TAB> <TAB> ) <TAB> <TAB> ) <TAB> self. batch_size = batch_size <TAB> self. ids = list ( ids ) <TAB> self. data_size = len ( self. ids ) <TAB> self. shuffle = shuffle <TAB> <TAB> self. on_epoch_end ( )",False,not is_real_iterable(targets),"not isinstance(targets, np.ndarray)",0.6524567604064941
|
||
|
3681,"def _level_up_logging ( self ) : <TAB> for handler in self. log. handlers : <TAB> <TAB> if issubclass ( handler. __class__, logging. FileHandler ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> handler. setLevel ( logging. DEBUG ) <TAB> <TAB> <TAB> <TAB> self. log. debug ( ""Leveled up log file verbosity"" )",False,handler.level != logging.DEBUG,"hasattr(handler, 'setLevel')",0.6558986902236938
|
||
|
3682,"def cmd_execution_alter_shell ( separator, cmd, OUTPUT_TEXTFILE ) : <TAB> if settings. TARGET_OS == ""win"" : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> payload = separator + cmd + "" "" <TAB> <TAB> else : <TAB> <TAB> <TAB> python_payload = ( <TAB> <TAB> <TAB> <TAB> settings. WIN_PYTHON_DIR <TAB> <TAB> <TAB> <TAB> + "" -c \""import os; os.system('"" <TAB> <TAB> <TAB> <TAB> + cmd <TAB> <TAB> <TAB> <TAB> + "">"" <TAB> <TAB> <TAB> <TAB> + OUTPUT_TEXTFILE <TAB> <TAB> <TAB> <TAB> + ""')\"""" <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> payload = ( <TAB> <TAB> <TAB> <TAB> separator <TAB> <TAB> <TAB> <TAB> + 'for /f """"t""""o""""k""""e""""n""""s""=*"" %i in (\'cmd /c'<TAB> <TAB> <TAB> <TAB> + python_payload <TAB> <TAB> <TAB> <TAB> + ""') do @set /p =%i< nul"" <TAB> <TAB> <TAB> ) <TAB> else : <TAB> <TAB> payload = ( <TAB> <TAB> <TAB> separator <TAB> <TAB> <TAB> + ""$(python -c \""f=open('"" <TAB> <TAB> <TAB> + settings. WEB_ROOT <TAB> <TAB> <TAB> + OUTPUT_TEXTFILE <TAB> <TAB> <TAB> + ""','w')\nf.write('$(echo $("" <TAB> <TAB> <TAB> + cmd <TAB> <TAB> <TAB> + ""))')\nf.close()\n\"")"" <TAB> <TAB> ) <TAB> <TAB> if ( <TAB> <TAB> settings. USER_AGENT_INJECTION == True <TAB> <TAB> or settings. REFERER_INJECTION == True <TAB> <TAB> or settings. HOST_INJE",False,settings.REVERSE_TCP,"hasattr(os, 'system')",0.6607925891876221
|
||
|
3683,"def visit_list ( <TAB> self, <TAB> items : Sequence [ base. AST ], <TAB> *, <TAB> separator : str = "","", <TAB> terminator : Optional [ str ] = None, <TAB> newlines : bool = True, <TAB> ** kwargs : Any ) -> None : <TAB> <TAB> <TAB> separator = terminator if terminator is not None else separator <TAB> size = len ( items ) <TAB> for i, item in enumerate ( items ) : <TAB> <TAB> self. visit ( item, ** kwargs ) <TAB> <TAB> if i < size - 1 or terminator is not None : <TAB> <TAB> <TAB> self. write ( separator ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. new_lines = 1 <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. write ( "" "" )",True,newlines,newlines,0.6980547308921814
|
||
|
3684,"def get_version ( version_file = STATIC_VERSION_FILE ) : <TAB> version_info = get_static_version_info ( version_file ) <TAB> version = version_info [ ""version"" ] <TAB> if version == ""__use_git__"" : <TAB> <TAB> version = get_version_from_git ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> version = get_version_from_git_archive ( version_info ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> version = Version ( ""unknown"", None, None ) <TAB> <TAB> return pep440_format ( version ) <TAB> else : <TAB> <TAB> return version",False,not version,version == '__None__',0.6803073883056641
|
||
|
3685,"def generateAggregation ( self, agg, where_clausel ) : <TAB> if not agg : <TAB> <TAB> return self. table, where_clausel <TAB> if ( <TAB> <TAB> agg. aggfunc == SigmaAggregationParser. AGGFUNC_COUNT <TAB> <TAB> or agg. aggfunc == SigmaAggregationParser. AGGFUNC_MAX <TAB> <TAB> or agg. aggfunc == SigmaAggregationParser. AGGFUNC_MIN <TAB> <TAB> or agg. aggfunc == SigmaAggregationParser. AGGFUNC_SUM <TAB> <TAB> or agg. aggfunc == SigmaAggregationParser. AGGFUNC_AVG <TAB> ) : <TAB> <TAB> if agg. groupfield : <TAB> <TAB> <TAB> group_by = "" GROUP BY {0}"". format ( <TAB> <TAB> <TAB> <TAB> self. fieldNameMapping ( agg. groupfield, None ) <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> group_by = """" <TAB> <TAB> if agg. aggfield : <TAB> <TAB> <TAB> select = ""{}({}) AS agg"". format ( <TAB> <TAB> <TAB> <TAB> agg. aggfunc_notrans, self. fieldNameMapping ( agg. aggfield, None ) <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> select = ""{}(*) AS agg"". format ( agg. aggfunc_notrans ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> raise SigmaParseError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""For {} aggregation a fieldname needs to be specified"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> agg. aggfunc_notrans <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> temp_table = ""(SELECT {} FROM {} WHERE {}{})"".",False,agg.aggfunc == SigmaAggregationParser.AGGFUNC_COUNT,agg.aggfunc_notrans,0.6619846820831299
|
||
|
3686,def _use_full_params ( self ) -> None : <TAB> for p in self. params : <TAB> <TAB> if not p. _is_sharded : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> assert p. _fp16_shard. storage ( ). size ( )!= 0 <TAB> <TAB> <TAB> <TAB> p. data = p. _fp16_shard <TAB> <TAB> else : <TAB> <TAB> <TAB> assert p. _full_param_padded. storage ( ). size ( )!= 0 <TAB> <TAB> <TAB> p. data = p. _full_param_padded [ : p. _orig_size. numel ( ) ]. view ( p. _orig_size ),False,self.mixed_precision,p._fp16_shard is not None,0.6638258099555969
|
||
|
3687,"def test_read1 ( self ) : <TAB> self. test_write ( ) <TAB> blocks = [ ] <TAB> nread = 0 <TAB> with gzip. GzipFile ( self. filename, ""r"" ) as f : <TAB> <TAB> while True : <TAB> <TAB> <TAB> d = f. read1 ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> blocks. append ( d ) <TAB> <TAB> <TAB> nread += len ( d ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. assertEqual ( f. tell ( ), nread ) <TAB> self. assertEqual ( b"""". join ( blocks ), data1 * 50 )",True,not d,not d,0.6705198287963867
|
||
|
3688,"def _table_schema ( self, table ) : <TAB> rows = self. db. execute_sql ( ""PRAGMA table_info('%s')"" % table ). fetchall ( ) <TAB> <TAB> result = { } <TAB> for _, name, data_type, not_null, _, primary_key in rows : <TAB> <TAB> parts = [ data_type ] <TAB> <TAB> if primary_key : <TAB> <TAB> <TAB> parts. append ( ""PRIMARY KEY"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> parts. append ( ""NOT NULL"" ) <TAB> <TAB> result [ name ] = "" "". join ( parts ) <TAB> return result",True,not_null,not_null,0.662692666053772
|
||
|
3689,"def pytest_collection_modifyitems ( config, items ) : <TAB> <TAB> if platform. python_implementation ( ) == ""PyPy"" : <TAB> <TAB> skip_marker = pytest. mark. skip ( <TAB> <TAB> <TAB> reason = ""FeatureHasher is not compatible with PyPy"" <TAB> <TAB> ) <TAB> <TAB> for item in items : <TAB> <TAB> <TAB> if item. name. endswith ( ( ""_hash.FeatureHasher"", ""text.HashingVectorizer"" ) ) : <TAB> <TAB> <TAB> <TAB> item. add_marker ( skip_marker ) <TAB> <TAB> if config. getoption ( ""--skip-network"" ) : <TAB> <TAB> skip_network = pytest. mark. skip ( reason = ""test requires internet connectivity"" ) <TAB> <TAB> for item in items : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> item. add_marker ( skip_network ) <TAB> <TAB> <TAB> skip_doctests = False <TAB> try : <TAB> <TAB> import numpy as np <TAB> <TAB> if LooseVersion ( np. __version__ ) < LooseVersion ( ""1.14"" ) : <TAB> <TAB> <TAB> reason = ""doctests are only run for numpy >= 1.14"" <TAB> <TAB> <TAB> skip_doctests = True <TAB> <TAB> elif _IS_32BIT : <TAB> <TAB> <TAB> reason = ""doctest are only run when the default numpy int is "" ""64 bits."" <TAB> <TAB> <TAB> skip_doctests = True <TAB> <TAB> elif sys. platform. startswith ( ""win32"" ) : <TAB> <TAB> <TAB> reason = ( <TAB> <TAB> <TAB> <TAB> ""doctests are not run for Windows because numpy arrays "" <TAB> <TAB> <TAB> <TAB> ""repr is inconsistent across platforms."" <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> skip_doctests = True <TAB> except ImportError : <TAB> <TAB",False,'network' in item.keywords,skip_network and skip_doctests,0.6618825197219849
|
||
|
3690,"def get_limit ( self, request ) : <TAB> if self. limit_query_param : <TAB> <TAB> try : <TAB> <TAB> <TAB> limit = int ( request. query_params [ self. limit_query_param ] ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise ValueError ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if settings. MAX_PAGE_SIZE : <TAB> <TAB> <TAB> <TAB> if limit == 0 : <TAB> <TAB> <TAB> <TAB> <TAB> return settings. MAX_PAGE_SIZE <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> return min ( limit, settings. MAX_PAGE_SIZE ) <TAB> <TAB> <TAB> return limit <TAB> <TAB> except ( KeyError, ValueError ) : <TAB> <TAB> <TAB> pass <TAB> return self. default_limit",True,limit < 0,limit < 0,0.6877421140670776
|
||
|
3691,"def repoquery ( self ) : <TAB> """"""perform a repoquery"""""" <TAB> if self. ignore_excluders : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. tmp_file = tempfile. NamedTemporaryFile ( ) <TAB> <TAB> with open ( ""/etc/yum.conf"", ""r"" ) as file_handler : <TAB> <TAB> <TAB> yum_conf_lines = file_handler. readlines ( ) <TAB> <TAB> yum_conf_lines = [ <TAB> <TAB> <TAB> ""exclude="" if l. startswith ( ""exclude="" ) else l for l in yum_conf_lines <TAB> <TAB> ] <TAB> <TAB> with open ( self. tmp_file. name, ""w"" ) as file_handler : <TAB> <TAB> <TAB> file_handler. writelines ( yum_conf_lines ) <TAB> <TAB> <TAB> file_handler. flush ( ) <TAB> repoquery_cmd = self. build_cmd ( ) <TAB> rval = self. _repoquery_cmd ( repoquery_cmd, True, ""raw"" ) <TAB> <TAB> if rval [ ""results"" ] : <TAB> <TAB> processed_versions = Repoquery. process_versions ( rval [ ""results"" ]. strip ( ) ) <TAB> <TAB> formatted_versions = self. format_versions ( processed_versions ) <TAB> <TAB> rval [ ""package_found"" ] = True <TAB> <TAB> rval [ ""versions"" ] = formatted_versions <TAB> <TAB> rval [ ""package_name"" ] = self. name <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> rval [ ""raw_versions"" ] = processed_versions <TAB> <TAB> else : <TAB> <TAB> <TAB> del rval [ ""results"" ] <TAB> <TAB> else : <TAB> <TAB> rval [ ""package_found"" ] = False <TAB> if self. ignore_excluders : <TAB> <TAB> self. tmp_file. close ( ) <TAB> return rval",False,self.verbose,rval['raw_versions'],0.6639021039009094
|
||
|
3692,"def haslayer ( self, cls ) : <TAB> """"""true if self has a layer that is an instance of cls. Superseded by ""cls in self"" syntax."""""" <TAB> if self. __class__ == cls or self. __class__. __name__ == cls : <TAB> <TAB> return 1 <TAB> for f in self. packetfields : <TAB> <TAB> fvalue_gen = self. getfieldval ( f. name ) <TAB> <TAB> if fvalue_gen is None : <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> fvalue_gen = SetGen ( fvalue_gen, _iterpacket = 0 ) <TAB> <TAB> for fvalue in fvalue_gen : <TAB> <TAB> <TAB> if isinstance ( fvalue, Packet ) : <TAB> <TAB> <TAB> <TAB> ret = fvalue. haslayer ( cls ) <TAB> <TAB> <TAB> <TAB> if ret : <TAB> <TAB> <TAB> <TAB> <TAB> return ret <TAB> return self. payload. haslayer ( cls )",False,not f.islist,"isinstance(fvalue_gen, SetGen)",0.6595672369003296
|
||
|
3693,"def reset_parameters ( self ) : <TAB> for m in self. modules ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> elif isinstance ( m, nn. LayerNorm ) : <TAB> <TAB> <TAB> nn. init. constant_ ( m. weight, 0.1 ) <TAB> <TAB> <TAB> nn. init. constant_ ( m. bias, 0 ) <TAB> <TAB> else : <TAB> <TAB> <TAB> for p in m. parameters ( ) : <TAB> <TAB> <TAB> <TAB> nn. init. normal_ ( p, 0, 0.1 )",False,"isinstance(m, nn.Embedding)","isinstance(m, nn.Linear)",0.6592777371406555
|
||
|
3694,"def test_large_headers ( self ) : <TAB> with ExpectLog ( gen_log, ""Unsatisfiable read"", required = False ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> self. fetch ( ""/"", headers = { ""X-Filler"" : ""a"" * 1000 }, raise_error = True ) <TAB> <TAB> <TAB> self. fail ( ""did not raise expected exception"" ) <TAB> <TAB> except HTTPError as e : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. assertIn ( e. response. code, ( 431, 599 ) )",False,e.response is not None,e.response.code == 200,0.6538652181625366
|
||
|
3695,"def time_left ( self ) : <TAB> """"""Return how many seconds are left until the timeout expires"""""" <TAB> if self. is_non_blocking : <TAB> <TAB> return 0 <TAB> elif self. is_infinite : <TAB> <TAB> return None <TAB> else : <TAB> <TAB> delta = self. target_time - self. TIME ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. target_time = self. TIME ( ) + self. duration <TAB> <TAB> <TAB> return self. duration <TAB> <TAB> else : <TAB> <TAB> <TAB> return max ( 0, delta )",False,delta > self.duration,delta < 0,0.6713412404060364
|
||
|
3696,"def __init__ ( self, data, n_bins ) : <TAB> bin_width = span / n_bins <TAB> bins = [ 0 ] * n_bins <TAB> for x in data : <TAB> <TAB> b = int ( mpfloor ( ( x - minimum ) / bin_width ) ) <TAB> <TAB> if b < 0 : <TAB> <TAB> <TAB> b = 0 <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> b = n_bins - 1 <TAB> <TAB> bins [ b ] += 1 <TAB> self. bins = bins <TAB> self. bin_width = bin_width",False,b >= n_bins,b > n_bins - 1,0.6899993419647217
|
||
|
3697,"def _parse_subtitles ( self, video_data, url_key ) : <TAB> subtitles = { } <TAB> for translation in video_data. get ( ""translations"", [ ] ) : <TAB> <TAB> vtt_path = translation. get ( url_key ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> lang = translation. get ( ""language_w3c"" ) or ISO639Utils. long2short ( <TAB> <TAB> <TAB> translation [ ""language_medium"" ] <TAB> <TAB> ) <TAB> <TAB> subtitles. setdefault ( lang, [ ] ). append ( <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> ""ext"" : ""vtt"", <TAB> <TAB> <TAB> <TAB> ""url"" : vtt_path, <TAB> <TAB> <TAB> } <TAB> <TAB> ) <TAB> return subtitles",True,not vtt_path,not vtt_path,0.659387469291687
|
||
|
3698,"def parse_flow_sequence_entry ( self, first = False ) : <TAB> if not self. check_token ( tokens. FlowSequenceEndToken ) : <TAB> <TAB> if not first : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. get_token ( ) <TAB> <TAB> <TAB> <TAB> if self. check_token ( tokens. FlowSequenceEndToken ) : <TAB> <TAB> <TAB> <TAB> <TAB> token = self. peek_token ( ) <TAB> <TAB> <TAB> <TAB> <TAB> self. echoerr ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""While parsing a flow sequence"", <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. marks [ - 1 ], <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ( ""expected sequence value, but got %r"" % token. id ), <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> token. start_mark, <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> token = self. peek_token ( ) <TAB> <TAB> <TAB> <TAB> raise ParserError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""while parsing a flow sequence"", <TAB> <TAB> <TAB> <TAB> <TAB> self. marks [ - 1 ], <TAB> <TAB> <TAB> <TAB> <TAB> ( ""expected ',' or ']', but got %r"" % token. id ), <TAB> <TAB> <TAB> <TAB> <TAB> token. start_mark, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> if not self. check_token ( tokens. FlowSequenceEndToken ) : <TAB> <TAB> <TAB> self. states. append ( self. parse_flow_sequence_entry ) <TAB> <TAB> <TAB> return self. parse_node ( ) <TAB> token = self. get_token (",False,self.check_token(tokens.FlowEntryToken),self.check_token(tokens.FlowSequenceEndToken),0.6497704982757568
|
||
|
3699,"def purge_snapshots ( self ) : <TAB> for table in tuple ( self. snapshots ) : <TAB> <TAB> for _ in range ( MAX_ATTEMPTS ) : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> if table. startswith ( ""ifinfo_"" ) : <TAB> <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. execute ( ""DROP VIEW %s"" % table [ 7 : ] ) <TAB> <TAB> <TAB> <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. log. warning ( ""purge_snapshots: %s"" % traceback. format_exc ( ) ) <TAB> <TAB> <TAB> <TAB> if self. mode == ""sqlite3"" : <TAB> <TAB> <TAB> <TAB> <TAB> self. execute ( ""DROP TABLE %s"" % table ) <TAB> <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> self. execute ( ""DROP TABLE %s CASCADE"" % table ) <TAB> <TAB> <TAB> <TAB> del self. snapshots [ table ] <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> except sqlite3. OperationalError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> time. sleep ( random. random ( ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise Exception ( ""DB snapshot error"" )",False,self.mode == 'psycopg2',self.mode == 'sqlite4.sql_snapshot',0.6523697972297668
|
||
|
3700,def _get_inputs ( out ) : <TAB> inputs = [ ] <TAB> queue = [ out ] <TAB> hash_set = set ( ) <TAB> while queue : <TAB> <TAB> t = queue. pop ( 0 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> inputs. append ( t ) <TAB> <TAB> else : <TAB> <TAB> <TAB> input_tensors = [ t for t in t. op. input_tensors if t not in hash_set ] <TAB> <TAB> <TAB> queue. extend ( input_tensors ) <TAB> <TAB> <TAB> hash_set. update ( input_tensors ) <TAB> return inputs,False,"isinstance(t.op, tensor.PlaceholderOp)",t.op is None,0.6528328657150269
|
||
|
3701,"def parse_edges ( self, pcb ) : <TAB> edges = [ ] <TAB> drawings = list ( pcb. GetDrawings ( ) ) <TAB> bbox = None <TAB> for m in pcb. GetModules ( ) : <TAB> <TAB> for g in m. GraphicalItems ( ) : <TAB> <TAB> <TAB> drawings. append ( g ) <TAB> for d in drawings : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> parsed_drawing = self. parse_drawing ( d ) <TAB> <TAB> <TAB> if parsed_drawing : <TAB> <TAB> <TAB> <TAB> edges. append ( parsed_drawing ) <TAB> <TAB> <TAB> <TAB> if bbox is None : <TAB> <TAB> <TAB> <TAB> <TAB> bbox = d. GetBoundingBox ( ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> bbox. Merge ( d. GetBoundingBox ( ) ) <TAB> if bbox : <TAB> <TAB> bbox. Normalize ( ) <TAB> return edges, bbox",False,d.GetLayer() == pcbnew.Edge_Cuts,d,0.6519386768341064
|
||
|
3702,"def iter_chars_to_words ( self, chars ) : <TAB> current_word = [ ] <TAB> for char in chars : <TAB> <TAB> if not self. keep_blank_chars and char [ ""text"" ]. isspace ( ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> yield current_word <TAB> <TAB> <TAB> <TAB> current_word = [ ] <TAB> <TAB> elif current_word and self. char_begins_new_word ( current_word, char ) : <TAB> <TAB> <TAB> yield current_word <TAB> <TAB> <TAB> current_word = [ char ] <TAB> <TAB> else : <TAB> <TAB> <TAB> current_word. append ( char ) <TAB> if<mask> : <TAB> <TAB> yield current_word",False,current_word,not current_word,0.6678227186203003
|
||
|
3703,"def invoice_details ( request, invoice_id ) : <TAB> invoice = get_object_or_404 ( <TAB> <TAB> Invoice. objects. select_related ( ""from_address"", ""to_address"" ), pk = invoice_id <TAB> ) <TAB> if invoice. company!= request. company : <TAB> <TAB> raise PermissionDenied <TAB> user_assigned_account = False <TAB> user_assigned_accounts = set ( <TAB> <TAB> request. user. account_assigned_users. values_list ( ""id"", flat = True ) <TAB> ) <TAB> invoice_accounts = set ( invoice. accounts. values_list ( ""id"", flat = True ) ) <TAB> if user_assigned_accounts. intersection ( invoice_accounts ) : <TAB> <TAB> user_assigned_account = True <TAB> if not ( <TAB> <TAB> ( request. user. role == ""ADMIN"" ) <TAB> <TAB> or ( request. user. is_superuser ) <TAB> <TAB> or ( invoice. created_by == request. user ) <TAB> <TAB> or ( request. user in invoice. assigned_to. all ( ) ) <TAB> <TAB> or user_assigned_account <TAB> ) : <TAB> <TAB> raise PermissionDenied <TAB> if request. method == ""GET"" : <TAB> <TAB> context = { } <TAB> <TAB> context [ ""invoice"" ] = invoice <TAB> <TAB> context [ ""attachments"" ] = invoice. invoice_attachment. all ( ) <TAB> <TAB> context [ ""comments"" ] = invoice. invoice_comments. all ( ) <TAB> <TAB> context [ ""invoice_history"" ] = invoice. invoice_history. all ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> context [ ""users_mention"" ] = list ( <TAB> <TAB> <TAB> <TAB> User. objects. filter ( is_active = True, company = request. company ). values ( <TAB> <TAB> <TAB> <TAB> <TAB> ""username"" <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB",False,request.user.is_superuser or request.user.role == 'ADMIN',request.method == 'POST',0.6498745679855347
|
||
|
3704,"def dropEvent ( self, event : QDropEvent ) : <TAB> super ( ). dropEvent ( event ) <TAB> if self. count ( ) > 0 : <TAB> <TAB> item = self. itemAt ( event. pos ( ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> index = self. indexFromItem ( item ). row ( ) <TAB> <TAB> <TAB> self. setCurrentRow ( index ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. setCurrentRow ( self. count ( ) - 1 )",False,item is not None,item.isValid(),0.6612706184387207
|
||
|
3705,"def _server_paste_to_uwsgi ( app_desc, server_config, applied_filters ) : <TAB> uwsgi_dict = OrderedDict ( ) <TAB> port = server_config. get ( ""port"", app_desc. default_port ) <TAB> host = server_config. get ( ""host"", ""127.0.0.1"" ) <TAB> if server_config. get ( ""use"", ""egg:Paste#http"" )!= ""egg:Paste#http"" : <TAB> <TAB> raise Exception ( <TAB> <TAB> <TAB> ""Unhandled paste server 'use' value [%s], file must be manually migrate."" <TAB> <TAB> ) <TAB> uwsgi_dict [ ""http"" ] = ""{}:{}"". format ( host, port ) <TAB> <TAB> uwsgi_dict [ ""threads"" ] = int ( server_config. get ( ""threadpool_workers"", 8 ) ) <TAB> <TAB> uwsgi_dict [ ""http-raw-body"" ] = True <TAB> uwsgi_dict [ ""offload-threads"" ] = 8 <TAB> <TAB> prefix = None <TAB> for applied_filter in applied_filters : <TAB> <TAB> if isinstance ( applied_filter, PrefixFilter ) : <TAB> <TAB> <TAB> prefix = applied_filter. prefix <TAB> <TAB> <TAB> break <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> uwsgi_dict [ ""http-auto-gzip"" ] = True <TAB> if prefix : <TAB> <TAB> uwsgi_dict [ ""mount"" ] = ""{}={}"". format ( prefix, app_desc. uwsgi_module ) <TAB> <TAB> uwsgi_dict [ ""manage-script-name"" ] = True <TAB> else : <TAB> <TAB> uwsgi_dict [ ""module"" ] = app_desc. uwsgi_module <TAB> return uwsgi_dict",False,"isinstance(applied_filter, GzipFilter)","isinstance(applied_filter, gzip.BaseGZFilter)",0.6476679444313049
|
||
|
3706,"def _get_addons ( request, addons, addon_id, action ) : <TAB> """"""Create a list of ``MenuItem``s for the activity feed."""""" <TAB> items = [ ] <TAB> a = MenuItem ( ) <TAB> a. selected = not addon_id <TAB> ( a. text, a. url ) = ( gettext ( ""All My Add-ons"" ), reverse ( ""devhub.feed_all"" ) ) <TAB> if<mask> : <TAB> <TAB> a. url += ""?action="" + action <TAB> items. append ( a ) <TAB> for addon in addons : <TAB> <TAB> item = MenuItem ( ) <TAB> <TAB> try : <TAB> <TAB> <TAB> item. selected = addon_id and addon. id == int ( addon_id ) <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> pass <TAB> <TAB> url = reverse ( ""devhub.feed"", args = [ addon. slug ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> url += ""?action="" + action <TAB> <TAB> item. text, item. url = addon. name, url <TAB> <TAB> items. append ( item ) <TAB> return items",False,action,addons,0.7036648988723755
|
||
|
3707,"def modify_urls ( self ) : <TAB> save = True <TAB> if self. urlwatch_config. delete is not None : <TAB> <TAB> job = self. _find_job ( self. urlwatch_config. delete ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. urlwatcher. jobs. remove ( job ) <TAB> <TAB> <TAB> print ( ""Removed %r"" % ( job, ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> print ( ""Not found: %r"" % ( self. urlwatch_config. delete, ) ) <TAB> <TAB> <TAB> save = False <TAB> if self. urlwatch_config. add is not None : <TAB> <TAB> <TAB> <TAB> items = [ item. split ( ""="", 1 ) for item in self. urlwatch_config. add. split ( "","" ) ] <TAB> <TAB> filters = [ v for k, v in items if k == ""filter"" ] <TAB> <TAB> items = [ ( k, v ) for k, v in items if k!= ""filter"" ] <TAB> <TAB> d = { k : v for k, v in items } <TAB> <TAB> if filters : <TAB> <TAB> <TAB> d [ ""filter"" ] = "","". join ( filters ) <TAB> <TAB> job = JobBase. unserialize ( d ) <TAB> <TAB> print ( ""Adding %r"" % ( job, ) ) <TAB> <TAB> self. urlwatcher. jobs. append ( job ) <TAB> if save : <TAB> <TAB> self. urlwatcher. urls_storage. save ( self. urlwatcher. jobs ) <TAB> return 0",False,job is not None,job,0.6591392159461975
|
||
|
3708,"def configure_formatter ( self, config ) : <TAB> """"""Configure a formatter from a dictionary."""""" <TAB> if ""()"" in config : <TAB> <TAB> factory = config [ ""()"" ] <TAB> <TAB> try : <TAB> <TAB> <TAB> result = self. configure_custom ( config ) <TAB> <TAB> except TypeError as te : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> config [ ""fmt"" ] = config. pop ( ""format"" ) <TAB> <TAB> <TAB> config [ ""()"" ] = factory <TAB> <TAB> <TAB> result = self. configure_custom ( config ) <TAB> else : <TAB> <TAB> fmt = config. get ( ""format"", None ) <TAB> <TAB> dfmt = config. get ( ""datefmt"", None ) <TAB> <TAB> style = config. get ( ""style"", ""%"" ) <TAB> <TAB> cname = config. get ( ""class"", None ) <TAB> <TAB> if not cname : <TAB> <TAB> <TAB> c = logging. Formatter <TAB> <TAB> else : <TAB> <TAB> <TAB> c = _resolve ( cname ) <TAB> <TAB> result = c ( fmt, dfmt, style ) <TAB> return result",False,"""'format'"" not in str(te)",'format' not in config,0.6636060476303101
|
||
|
3709,"def _get_notify ( self, action_node ) : <TAB> if action_node. name not in self. _skip_notify_tasks : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> task_notify = NotificationsHelper. to_model ( action_node. notify ) <TAB> <TAB> <TAB> return task_notify <TAB> <TAB> elif self. _chain_notify : <TAB> <TAB> <TAB> return self. _chain_notify <TAB> return None",False,action_node.notify,self.notify,0.6621562242507935
|
||
|
3710,"def _encrypt ( self ) : <TAB> """"""Use your key thing to encrypt things."""""" <TAB> from M2Crypto import BIO, SMIME, X509 <TAB> <TAB> plaintext = ""cert_id=%s\n"" % self. cert_id <TAB> for name, field in self. fields. items ( ) : <TAB> <TAB> value = None <TAB> <TAB> if name in self. initial : <TAB> <TAB> <TAB> value = self. initial [ name ] <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> value = field. initial <TAB> <TAB> if value is not None : <TAB> <TAB> <TAB> plaintext += u""%s=%s\n"" % ( name, value ) <TAB> plaintext = plaintext. encode ( ""utf-8"" ) <TAB> <TAB> s = SMIME. SMIME ( ) <TAB> s. load_key_bio ( BIO. openfile ( self. private_cert ), BIO. openfile ( self. public_cert ) ) <TAB> p7 = s. sign ( BIO. MemoryBuffer ( plaintext ), flags = SMIME. PKCS7_BINARY ) <TAB> x509 = X509. load_cert_bio ( BIO. openfile ( self. paypal_cert ) ) <TAB> sk = X509. X509_Stack ( ) <TAB> sk. push ( x509 ) <TAB> s. set_x509_stack ( sk ) <TAB> s. set_cipher ( SMIME. Cipher ( ""des_ede3_cbc"" ) ) <TAB> tmp = BIO. MemoryBuffer ( ) <TAB> p7. write_der ( tmp ) <TAB> p7 = s. encrypt ( tmp, flags = SMIME. PKCS7_BINARY ) <TAB> out = BIO. MemoryBuffer ( ) <TAB> p7. write ( out ) <TAB> return out. read ( ). decode ( )",False,field.initial is not None,"hasattr(field, 'initial')",0.6518455743789673
|
||
|
3711,"def get_request_headers ( ) -> Dict : <TAB> url = urlparse ( uri ) <TAB> candidates = [ <TAB> <TAB> ""%s://%s"" % ( url. scheme, url. netloc ), <TAB> <TAB> ""%s://%s/"" % ( url. scheme, url. netloc ), <TAB> <TAB> uri, <TAB> <TAB> ""*"", <TAB> ] <TAB> for u in candidates : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> headers = dict ( DEFAULT_REQUEST_HEADERS ) <TAB> <TAB> <TAB> headers. update ( self. config. linkcheck_request_headers [ u ] ) <TAB> <TAB> <TAB> return headers <TAB> return { }",True,u in self.config.linkcheck_request_headers,u in self.config.linkcheck_request_headers,0.6553332805633545
|
||
|
3712,"def handle_data ( self, data ) : <TAB> ds = data. split ( "" "" ) <TAB> lds = len ( ds ) <TAB> if ds [ lds - 1 ]. isdigit ( ) : <TAB> <TAB> if lds == 3 or lds == 4 : <TAB> <TAB> <TAB> day = str ( ds [ lds - 3 ] ) <TAB> <TAB> <TAB> month = str ( ds [ lds - 2 ] ) <TAB> <TAB> <TAB> year = str ( ds [ lds - 1 ] ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> day = ""0"" + day <TAB> <TAB> <TAB> month = month [ 0 : 3 ] <TAB> <TAB> <TAB> monthNum = str ( list ( calendar. month_abbr ). index ( month ) ) <TAB> <TAB> <TAB> if len ( monthNum ) == 1 : <TAB> <TAB> <TAB> <TAB> monthNum = ""0"" + monthNum <TAB> <TAB> <TAB> newDate = year + monthNum + day <TAB> <TAB> <TAB> self. dates. append ( str ( newDate ) )",False,len(day) == 1,len(month) == 1,0.658234715461731
|
||
|
3713,"def filter_queryset ( self, request, queryset, view ) : <TAB> Membership = apps. get_model ( ""projects"", ""Membership"" ) <TAB> operations = { <TAB> <TAB> ""filter"" : self. _prepare_filter_query, <TAB> <TAB> ""exclude"" : self. _prepare_exclude_query, <TAB> } <TAB> for mode, qs_method in operations. items ( ) : <TAB> <TAB> query = self. _get_queryparams ( request. QUERY_PARAMS, mode = mode ) <TAB> <TAB> if query : <TAB> <TAB> <TAB> memberships = ( <TAB> <TAB> <TAB> <TAB> Membership. objects. filter ( query ) <TAB> <TAB> <TAB> <TAB>. exclude ( user__isnull = True ) <TAB> <TAB> <TAB> <TAB>. values_list ( ""user_id"", flat = True ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> user_story_model = apps. get_model ( ""userstories"", ""UserStory"" ) <TAB> <TAB> <TAB> <TAB> queryset = queryset. filter ( <TAB> <TAB> <TAB> <TAB> <TAB> qs_method ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> Q ( self. get_assigned_users_filter ( user_story_model, memberships ) ) <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> ) <TAB> return FilterBackend. filter_queryset ( self, request, queryset, view )",False,memberships,not self.use_user_story,0.6871935129165649
|
||
|
3714,"def update_forum_nums_topic_post ( modeladmin, request, queryset ) : <TAB> for forum in queryset : <TAB> <TAB> forum. num_topics = forum. count_nums_topic ( ) <TAB> <TAB> forum. num_posts = forum. count_nums_post ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> forum. last_post = forum. topic_set. order_by ( ""-last_reply_on"" ) [ 0 ]. last_post <TAB> <TAB> else : <TAB> <TAB> <TAB> forum. last_post = """" <TAB> <TAB> forum. save ( )",False,forum.num_topics,forum.num_topics > 0,0.674964189529419
|
||
|
3715,"def handle_starttag ( self, tag, attrs ) : <TAB> if tag == ""pre"" : <TAB> <TAB> self. in_pre = True <TAB> if self. is_block_tag ( tag ) : <TAB> <TAB> self. output = self. output. rstrip ( ) <TAB> self. output += ""<"" + tag <TAB> <TAB> <TAB> <TAB> if attrs : <TAB> <TAB> attrs. sort ( ) <TAB> <TAB> for ( k, v ) in attrs : <TAB> <TAB> <TAB> self. output += "" "" + k <TAB> <TAB> <TAB> if v in [ ""href"", ""src"" ] : <TAB> <TAB> <TAB> <TAB> self. output += ( <TAB> <TAB> <TAB> <TAB> <TAB> ""="" + '""' + urllib. quote ( urllib. unquote ( v ), safe = ""/"" ) + '""' <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> self. output += ""="" + '""' + cgi. escape ( v, quote = True ) + '""' <TAB> self. output += "">"" <TAB> self. last_tag = tag <TAB> self. last = ""starttag""",False,v != None,"v in ['value', 'type']",0.6725598573684692
|
||
|
3716,"def _prepare ( self ) : <TAB> from_text = str ( self. from_entry. get_text ( ) ) <TAB> self. set_total ( self. db. get_number_of_media ( ) ) <TAB> with self. db. get_media_cursor ( ) as cursor : <TAB> <TAB> for handle, data in cursor : <TAB> <TAB> <TAB> obj = Media ( ) <TAB> <TAB> <TAB> obj. unserialize ( data ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. handle_list. append ( handle ) <TAB> <TAB> <TAB> <TAB> self. path_list. append ( obj. path ) <TAB> <TAB> <TAB> self. update ( ) <TAB> self. reset ( ) <TAB> self. prepared = True",False,obj.get_path().find(from_text) != -1,obj.from_text == from_text,0.6493019461631775
|
||
|
3717,"def f ( view, s ) : <TAB> if mode == modes. INTERNAL_NORMAL : <TAB> <TAB> x_limit = max ( view. line ( s. b ). a, s. b - count ) <TAB> <TAB> return sublime. Region ( s. a, x_limit ) <TAB> <TAB> elif mode in ( modes. VISUAL, modes. VISUAL_BLOCK ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if mode == modes. VISUAL_BLOCK and self. view. rowcol ( s. b - 1 ) [ 1 ] == baseline : <TAB> <TAB> <TAB> <TAB> return s <TAB> <TAB> <TAB> x_limit = max ( view. line ( s. b - 1 ). a + 1, s. b - count ) <TAB> <TAB> <TAB> if view. line ( s. a ) == view. line ( s. b - 1 ) and count >= s. size ( ) : <TAB> <TAB> <TAB> <TAB> x_limit = max ( view. line ( s. b - 1 ). a, s. b - count - 1 ) <TAB> <TAB> <TAB> <TAB> return sublime. Region ( s. a + 1, x_limit ) <TAB> <TAB> <TAB> return sublime. Region ( s. a, x_limit ) <TAB> <TAB> if s. a > s. b : <TAB> <TAB> <TAB> x_limit = max ( view. line ( s. b ). a, s. b - count ) <TAB> <TAB> <TAB> return sublime. Region ( s. a, x_limit ) <TAB> elif mode == modes. NORMAL : <TAB> <TAB> x_limit = max ( view. line ( s. b ). a, s. b - count ) <TAB> <TAB> return sublime. Region ( x_limit, x_limit ) <TAB> <TAB> return s",False,s.a < s.b,self.baseline,0.6604595184326172
|
||
|
3718,"def populate_obj ( self, obj, name ) : <TAB> field = getattr ( obj, name, None ) <TAB> if field is not None : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> field. delete ( ) <TAB> <TAB> <TAB> return <TAB> <TAB> if isinstance ( self. data, FileStorage ) and not is_empty ( self. data. stream ) : <TAB> <TAB> <TAB> if not field. grid_id : <TAB> <TAB> <TAB> <TAB> func = field. put <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> func = field. replace <TAB> <TAB> <TAB> func ( <TAB> <TAB> <TAB> <TAB> self. data. stream, <TAB> <TAB> <TAB> <TAB> filename = self. data. filename, <TAB> <TAB> <TAB> <TAB> content_type = self. data. content_type, <TAB> <TAB> <TAB> )",False,self._should_delete,field.grid_id,0.6581511497497559
|
||
|
3719,"def generator ( self, data ) : <TAB> for sock in data : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> offset = sock. obj_offset <TAB> <TAB> else : <TAB> <TAB> <TAB> offset = sock. obj_vm. vtop ( sock. obj_offset ) <TAB> <TAB> yield ( <TAB> <TAB> <TAB> 0, <TAB> <TAB> <TAB> [ <TAB> <TAB> <TAB> <TAB> Address ( offset ), <TAB> <TAB> <TAB> <TAB> int ( sock. Pid ), <TAB> <TAB> <TAB> <TAB> int ( sock. LocalPort ), <TAB> <TAB> <TAB> <TAB> int ( sock. Protocol ), <TAB> <TAB> <TAB> <TAB> str ( protos. protos. get ( sock. Protocol. v ( ), ""-"" ) ), <TAB> <TAB> <TAB> <TAB> str ( sock. LocalIpAddress ), <TAB> <TAB> <TAB> <TAB> str ( sock. CreateTime ), <TAB> <TAB> <TAB> ], <TAB> <TAB> )",False,not self._config.PHYSICAL_OFFSET,"hasattr(sock, 'obj_vm')",0.6564657688140869
|
||
|
3720,"def _skip_trivial ( constraint_data ) : <TAB> if skip_trivial_constraints : <TAB> <TAB> if isinstance ( constraint_data, LinearCanonicalRepn ) : <TAB> <TAB> <TAB> if constraint_data. variables is None : <TAB> <TAB> <TAB> <TAB> return True <TAB> <TAB> else : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return True <TAB> return False",False,constraint_data.body.polynomial_degree() == 0,constraint_data.constraints is None,0.6509370803833008
|
||
|
3721,"def get_filestream_file_items ( self ) : <TAB> data = { } <TAB> fs_file_updates = self. get_filestream_file_updates ( ) <TAB> for k, v in six. iteritems ( fs_file_updates ) : <TAB> <TAB> l = [ ] <TAB> <TAB> for d in v : <TAB> <TAB> <TAB> offset = d. get ( ""offset"" ) <TAB> <TAB> <TAB> content = d. get ( ""content"" ) <TAB> <TAB> <TAB> assert offset is not None <TAB> <TAB> <TAB> assert content is not None <TAB> <TAB> <TAB> assert offset == 0 or offset == len ( l ), ( k, v, l, d ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> l = [ ] <TAB> <TAB> <TAB> l. extend ( map ( json. loads, content ) ) <TAB> <TAB> data [ k ] = l <TAB> return data",False,not offset,content is not None,0.6812525391578674
|
||
|
3722,"def handle_membership ( self, cmd ) : <TAB> if self. _listen_interfaces is None : <TAB> <TAB> mreq = struct. pack ( <TAB> <TAB> <TAB> str ( ""4sI"" ), socket. inet_aton ( self. _multicast_address [ 0 ] ), socket. INADDR_ANY <TAB> <TAB> ) <TAB> <TAB> self. socket. setsockopt ( socket. IPPROTO_IP, cmd, mreq ) <TAB> else : <TAB> <TAB> for interface in self. _listen_interfaces : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> if_addr = socket. inet_aton ( interface ) <TAB> <TAB> <TAB> except socket. error : <TAB> <TAB> <TAB> <TAB><mask> : <TAB> <TAB> <TAB> mreq = socket. inet_aton ( self. _multicast_address [ 0 ] ) + if_addr <TAB> <TAB> <TAB> self. socket. setsockopt ( socket. IPPROTO_IP, cmd, mreq )",False,if_addr = GetInterfaceAddress(interface),self._multicast_address is not None,0.6487302780151367
|
||
|
3723,"def suckfont ( data ) : <TAB> import re <TAB> m = re. search ( r""/FontName\s+/([^ \t\n\r]+)\s+def"", data ) <TAB> if m : <TAB> <TAB> fontName = m. group ( 1 ) <TAB> else : <TAB> <TAB> fontName = None <TAB> interpreter = PSInterpreter ( ) <TAB> interpreter. interpret ( <TAB> <TAB> ""/Helvetica 4 dict dup /Encoding StandardEncoding put definefont pop"" <TAB> ) <TAB> interpreter. interpret ( data ) <TAB> fontdir = interpreter. dictstack [ 0 ] [ ""FontDirectory"" ]. value <TAB> if fontdir. has_key ( fontName ) : <TAB> <TAB> rawfont = fontdir [ fontName ] <TAB> else : <TAB> <TAB> <TAB> <TAB> fontNames = fontdir. keys ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> fontNames. remove ( ""Helvetica"" ) <TAB> <TAB> fontNames. sort ( ) <TAB> <TAB> rawfont = fontdir [ fontNames [ 0 ] ] <TAB> interpreter. close ( ) <TAB> return unpack_item ( rawfont )",False,len(fontNames) > 1,'Helvetica' in fontNames,0.658035159111023
|
||
|
3724,"def parse_flow_sequence_entry ( self, first = False ) : <TAB> if not self. check_token ( FlowSequenceEndToken ) : <TAB> <TAB> if not first : <TAB> <TAB> <TAB> if self. check_token ( FlowEntryToken ) : <TAB> <TAB> <TAB> <TAB> self. get_token ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> token = self. peek_token ( ) <TAB> <TAB> <TAB> <TAB> raise ParserError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""while parsing a flow sequence"", <TAB> <TAB> <TAB> <TAB> <TAB> self. marks [ - 1 ], <TAB> <TAB> <TAB> <TAB> <TAB> ""expected ',' or ']', but got %r"" % token. id, <TAB> <TAB> <TAB> <TAB> <TAB> token. start_mark, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> if self. check_token ( KeyToken ) : <TAB> <TAB> <TAB> token = self. peek_token ( ) <TAB> <TAB> <TAB> event = MappingStartEvent ( <TAB> <TAB> <TAB> <TAB> None, None, True, token. start_mark, token. end_mark, flow_style = True <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> self. state = self. parse_flow_sequence_entry_mapping_key <TAB> <TAB> <TAB> return event <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> self. states. append ( self. parse_flow_sequence_entry ) <TAB> <TAB> <TAB> return self. parse_flow_node ( ) <TAB> token = self. get_token ( ) <TAB> event = SequenceEndEvent ( token. start_mark, token. end_mark ) <TAB> self. state = self. states. pop ( ) <TAB> self. marks. pop ( ) <TAB> return event",False,not self.check_token(FlowSequenceEndToken),self.check_token(FlowSequenceEndToken),0.6517918109893799
|
||
|
3725,"def interpret ( self, expr ) : <TAB> self. _cg. reset_state ( ) <TAB> self. _reset_reused_expr_cache ( ) <TAB> args = [ ( True, self. _feature_array_name ) ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> args += [ ( True, ""output"" ) ] <TAB> with self. _cg. function_definition ( <TAB> <TAB> name = self. function_name, args = args, is_scalar_output = expr. output_size == 1 <TAB> ) : <TAB> <TAB> last_result = self. _do_interpret ( expr ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _cg. add_assign_array_statement ( last_result, ""output"", expr. output_size ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. _cg. add_return_statement ( last_result ) <TAB> if self. with_linear_algebra : <TAB> <TAB> filename = os. path. join ( os. path. dirname ( __file__ ), ""linear_algebra.c"" ) <TAB> <TAB> self. _cg. prepend_code_lines ( utils. get_file_content ( filename ) ) <TAB> if self. with_vectors : <TAB> <TAB> self. _cg. add_dependency ( ""<string.h>"" ) <TAB> if self. with_math_module : <TAB> <TAB> self. _cg. add_dependency ( ""<math.h>"" ) <TAB> return self. _cg. finalize_and_get_generated_code ( )",False,expr.output_size > 1,is_scalar_output,0.6547500491142273
|
||
|
3726,"def _text ( bitlist ) : <TAB> out = """" <TAB> for typ, text in bitlist : <TAB> <TAB> if not typ : <TAB> <TAB> <TAB> out += text <TAB> <TAB> elif typ == ""em"" : <TAB> <TAB> <TAB> out += ""\\fI%s\\fR"" % text <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> out += ""\\fB%s\\fR"" % text <TAB> <TAB> else : <TAB> <TAB> <TAB> raise ValueError ( ""unexpected tag %r inside text"" % ( typ, ) ) <TAB> out = out. strip ( ) <TAB> out = re. sub ( re. compile ( r""^\s+"", re. M ), """", out ) <TAB> return out",False,"typ in ['strong', 'code']",typ == 'b',0.6679772138595581
|
||
|
3727,"def _configTabs ( self ) : <TAB> for key in list ( self. widgetStore. keys ( ) ) : <TAB> <TAB> if self. widgetStore [ key ] [ 0 ]. disabled : <TAB> <TAB> <TAB> if not useTtk : <TAB> <TAB> <TAB> <TAB> self. widgetStore [ key ] [ 0 ]. config ( <TAB> <TAB> <TAB> <TAB> <TAB> bg = self. disabledBg, fg = self. disabledFg, cursor = """" <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. widgetStore [ key ] [ 0 ]. config ( style = ""DisabledTab.TLabel"", cursor = """" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> if not useTtk : <TAB> <TAB> <TAB> <TAB> <TAB> self. widgetStore [ key ] [ 0 ]. config ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> bg = self. widgetStore [ key ] [ 1 ]. cget ( ""bg"" ), <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> fg = self. activeFg, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> cursor = """", <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> self. widgetStore [ key ] [ 0 ]. config ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> style = ""SelectedTab.TLabel"", cursor = """" <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> self. widgetStore [ key ] [ 1 ]. lift ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> if not useTtk : <TAB> <TAB> <TAB> <TAB> <TAB>",False,key == self.selectedTab,self.widgetStore[key][0].state & 128,0.6616818904876709
|
||
|
3728,"def testMismatchedDataWindow ( self ) : <TAB> <TAB> <TAB> <TAB> main = self. __constantLayer ( """", imath. Color4f ( 1 ), size = imath. V2i ( 64 ) ) <TAB> diffuse = self. __constantLayer ( ""diffuse"", imath. Color4f ( 0.5 ), size = imath. V2i ( 60 ) ) <TAB> copy = GafferImage. CopyChannels ( ) <TAB> copy [ ""in"" ] [ 0 ]. setInput ( main [ ""out"" ] ) <TAB> copy [ ""in"" ] [ 1 ]. setInput ( diffuse [ ""out"" ] ) <TAB> copy [ ""channels"" ]. setValue ( ""*"" ) <TAB> <TAB> <TAB> self. assertEqual ( copy [ ""out"" ] [ ""format"" ]. getValue ( ), main [ ""out"" ] [ ""format"" ]. getValue ( ) ) <TAB> self. assertEqual ( <TAB> <TAB> copy [ ""out"" ] [ ""dataWindow"" ]. getValue ( ), main [ ""out"" ] [ ""dataWindow"" ]. getValue ( ) <TAB> ) <TAB> <TAB> <TAB> for channel in ( ""R"", ""G"", ""B"", ""A"" ) : <TAB> <TAB> diffuseDW = diffuse [ ""out"" ] [ ""dataWindow"" ]. getValue ( ) <TAB> <TAB> copyDW = copy [ ""out"" ] [ ""dataWindow"" ]. getValue ( ) <TAB> <TAB> sampler = GafferImage. Sampler ( copy [ ""out"" ], ""diffuse."" + channel, copyDW ) <TAB> <TAB> for x in range ( copyDW. min ( ). x, copyDW. max ( ). x ) : <TAB> <TAB> <TAB> for y in range ( copyDW. min ( ). y, copyDW. max ( ). y ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> self. assertEqual ( sampler. sample ( x, y ), 0.5 ) <TAB> <TAB> <TAB> <TAB>",False,"GafferImage.BufferAlgo.contains(diffuseDW, imath.V2i(x, y))",sampler.isDefined(),0.6530857086181641
|
||
|
3729,"def upgrade_state_dict_named ( self, state_dict ) : <TAB> <TAB> items_to_add = { } <TAB> keys_to_remove = [ ] <TAB> for k in state_dict. keys ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> dim = int ( state_dict [ k ]. shape [ 0 ] / 3 ) <TAB> <TAB> <TAB> items_to_add [ k. replace ( ""in_proj_weight"", ""q_proj.weight"" ) ] = state_dict [ k ] [ <TAB> <TAB> <TAB> <TAB> : dim <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> items_to_add [ k. replace ( ""in_proj_weight"", ""k_proj.weight"" ) ] = state_dict [ k ] [ <TAB> <TAB> <TAB> <TAB> dim : 2 * dim <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> items_to_add [ k. replace ( ""in_proj_weight"", ""v_proj.weight"" ) ] = state_dict [ k ] [ <TAB> <TAB> <TAB> <TAB> 2 * dim : <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> keys_to_remove. append ( k ) <TAB> <TAB> if k. endswith ( ""in_proj_bias"" ) : <TAB> <TAB> <TAB> dim = int ( state_dict [ k ]. shape [ 0 ] / 3 ) <TAB> <TAB> <TAB> items_to_add [ k. replace ( ""in_proj_bias"", ""q_proj.bias"" ) ] = state_dict [ k ] [ : dim ] <TAB> <TAB> <TAB> items_to_add [ k. replace ( ""in_proj_bias"", ""k_proj.bias"" ) ] = state_dict [ k ] [ <TAB> <TAB> <TAB> <TAB> dim : 2 * dim <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> items_to_add [ k.",False,k.endswith('in_proj_weight'),k.endswith('.q_proj_bias'),0.651056170463562
|
||
|
3730,"def pytest_deselected ( items ) : <TAB> if sb_config. dashboard : <TAB> <TAB> sb_config. item_count -= len ( items ) <TAB> <TAB> for item in items : <TAB> <TAB> <TAB> test_id, display_id = _get_test_ids_ ( item ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> sb_config. _results. pop ( test_id )",False,test_id in sb_config._results.keys(),test_id in sb_config._results,0.6494655609130859
|
||
|
3731,"def find_go_files_mtime ( app_files ) : <TAB> files, mtime = [ ], 0 <TAB> for f, mt in app_files. items ( ) : <TAB> <TAB> if not f. endswith ( "".go"" ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> files. append ( f ) <TAB> <TAB> mtime = max ( mtime, mt ) <TAB> return files, mtime",False,APP_CONFIG.nobuild_files.match(f),"max(mtime, mt) < mt",0.648460865020752
|
||
|
3732,"def check ( self ) : <TAB> user_agent = ""Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)"" <TAB> headers = { <TAB> <TAB> ""User-Agent"" : user_agent, <TAB> <TAB> ""Accept"" : ""text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"", <TAB> <TAB> ""Accept-language"" : ""sk,cs;q=0.8,en-US;q=0.5,en;q,0.3"", <TAB> <TAB> ""Connection"" : ""keep-alive"", <TAB> <TAB> ""Accept-Encoding"" : ""gzip, deflate"", <TAB> <TAB> ""Cache-Control"" : ""no-cache"", <TAB> <TAB> ""Cookie"" : ""C107373883=/omg1337hax"", <TAB> } <TAB> response = self. http_request ( method = ""GET"", path = ""/test"", headers = headers ) <TAB> if response is None : <TAB> <TAB> return False <TAB> if response. status_code!= 404 : <TAB> <TAB> return False <TAB> else : <TAB> <TAB> if ""server"" in response. headers : <TAB> <TAB> <TAB> server = response. headers. get ( ""server"" ) <TAB> <TAB> <TAB> if re. search ( ""RomPager"", server ) is not None : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> return True <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> return None <TAB> return False",False,"re.search('omg1337hax', response.text) is not None","re.search((""Rom pager is using: <TAB> <TAB> <TAB> <TAB> <TAB> > or re.search((""Rom pager is using: <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> > >)",0.6472072601318359
|
||
|
3733,"def computeLeadingWhitespaceWidth ( s, tab_width ) : <TAB> w = 0 <TAB> for ch in s : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> w += 1 <TAB> <TAB> elif ch == ""\t"" : <TAB> <TAB> <TAB> w += abs ( tab_width ) - ( w % abs ( tab_width ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> break <TAB> return w",False,ch == '',ch == '\n',0.6630555391311646
|
||
|
3734,"def fuse_module ( m ) : <TAB> last_conv = None <TAB> last_conv_name = None <TAB> for name, child in m. named_children ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if last_conv is None : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> fused_conv = fuse_conv_bn ( last_conv, child ) <TAB> <TAB> <TAB> m. _modules [ last_conv_name ] = fused_conv <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> m. _modules [ name ] = nn. Identity ( ) <TAB> <TAB> <TAB> last_conv = None <TAB> <TAB> elif isinstance ( child, nn. Conv2d ) : <TAB> <TAB> <TAB> last_conv = child <TAB> <TAB> <TAB> last_conv_name = name <TAB> <TAB> else : <TAB> <TAB> <TAB> fuse_module ( child ) <TAB> return m",False,"isinstance(child, (nn.BatchNorm2d, nn.SyncBatchNorm))",name == last_conv_name,0.6539161205291748
|
||
|
3735,"def htmlify ( self, htmlbuffer, htmlcontext ) : <TAB> stripped = self. _strip ( ) <TAB> if not stripped : <TAB> <TAB> return <TAB> lastIndent = htmlcontext. currentIndentWidth <TAB> currentIndent = self [ 0 ]. indentWidths [ - 1 ] <TAB> dontCompareIndents = False <TAB> if self [ 0 ]. iscode and not htmlcontext. inPRE : <TAB> <TAB> htmlbuffer. write ( ""<pre>\n"" ) <TAB> <TAB> htmlbuffer. write ( """". join ( self ) ) <TAB> <TAB> htmlcontext. inPRE = True <TAB> <TAB> return <TAB> if not self [ 0 ]. iscode and htmlcontext. inPRE : <TAB> <TAB> htmlbuffer. write ( ""</pre>\n"" ) <TAB> <TAB> htmlcontext. inPRE = False <TAB> if self [ 0 ]. bulleted and not htmlcontext. inUL : <TAB> <TAB> <TAB> <TAB> htmlbuffer. write ( ""<ul>"" ) <TAB> <TAB> dontCompareIndents = True <TAB> <TAB> htmlcontext. inUL = True <TAB> elif not self [ 0 ]. bulleted and htmlcontext. inUL : <TAB> <TAB> htmlbuffer. write ( ""</ul>"" ) <TAB> <TAB> htmlcontext. inUL = False <TAB> if not dontCompareIndents : <TAB> <TAB> if lastIndent < currentIndent : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> htmlbuffer. write ( ""<dl>"" ) <TAB> <TAB> <TAB> htmlcontext. inDL = True <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> htmlbuffer. write ( ""</dl>"" ) <TAB> <TAB> <TAB> htmlcontext. inDL = False <TAB> htmlcontext. currentIndentWidth = currentIndent <TAB> if htmlcontext. inUL : <TAB> <TAB> htmlbuffer. write ( ""<li>"" ) <TAB> if htmlcontext. inDL : <TAB> <TAB> htmlbuffer. write ( ""<dt/><dd>"" ) <TAB> htmlbuffer. write ( ""<p>"" + stripped + ""</p",False,lastIndent > currentIndent,htmlcontext.inDL,0.6664372682571411
|
||
|
3736,"def desc ( self ) : <TAB> bits = [ ] <TAB> for type, item in self. items : <TAB> <TAB> if type == ""path"" : <TAB> <TAB> <TAB> bits. append ( basename ( item ) ) <TAB> <TAB> elif type == ""file"" : <TAB> <TAB> <TAB> bits. append ( basename ( item. url ) ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> part_type = item. type <TAB> <TAB> <TAB> if part_type == ""project"" : <TAB> <TAB> <TAB> <TAB> bits. append ( basename ( item. url ) ) <TAB> <TAB> <TAB> elif part_type == ""folder"" : <TAB> <TAB> <TAB> <TAB> bits. append ( item. getStringAttribute ( ""name"" ) ) <TAB> <TAB> <TAB> elif part_type == ""livefolder"" : <TAB> <TAB> <TAB> <TAB> bits. append ( basename ( item. liveDirectory ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> log. warn ( ""unexpected container koIPart type: %r"", part_type ) <TAB> return "", "". join ( bits )",False,type == 'container',type == 'part',0.6596482992172241
|
||
|
3737,"def __init__ ( self, config, scenario, engine ) : <TAB> super ( HierarchicHTTPRequest, self ). __init__ ( <TAB> <TAB> config, scenario, engine, pure_body_file = True <TAB> ) <TAB> self. upload_files = self. config. get ( ""upload-files"", [ ] ) <TAB> if self. method == ""PUT"" and len ( self. upload_files ) > 1 : <TAB> <TAB> self. upload_files = self. upload_files [ : 1 ] <TAB> for file_dict in self. upload_files : <TAB> <TAB> param = file_dict. get ( ""param"", None ) <TAB> <TAB> if self. method == ""PUT"" : <TAB> <TAB> <TAB> file_dict [ ""param"" ] = """" <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise TaurusConfigError ( <TAB> <TAB> <TAB> <TAB> ""Items from upload-files must specify parameter name"" <TAB> <TAB> <TAB> ) <TAB> <TAB> path_exc = TaurusConfigError ( <TAB> <TAB> <TAB> ""Items from upload-files must specify path to file"" <TAB> <TAB> ) <TAB> <TAB> path = str ( file_dict. get ( ""path"", path_exc ) ) <TAB> <TAB> if not has_variable_pattern ( path ) : <TAB> <TAB> <TAB> path = self. engine. find_file ( path ) <TAB> <TAB> else : <TAB> <TAB> <TAB> msg = ""Path '%s' contains variable and can't be expanded. Don't use relative paths in 'upload-files'!"" <TAB> <TAB> <TAB> self. log. warning ( msg % path ) <TAB> <TAB> file_dict [ ""path"" ] = path <TAB> <TAB> mime = mimetypes. guess_type ( file_dict [ ""path"" ] ) [ 0 ] or ""application/octet-stream"" <TAB> <TAB> file_dict. get ( ""mime-type"", mime, force_set = True ) <TAB> self. content_encoding = self. config. get (",False,self.method == 'POST' and (not param),param is None,0.6490879654884338
|
||
|
3738,"def after_insert ( self ) : <TAB> if self. prescription : <TAB> <TAB> frappe. db. set_value ( <TAB> <TAB> <TAB> ""Lab Prescription"", self. prescription, ""lab_test_created"", 1 <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. invoiced = True <TAB> if not self. lab_test_name and self. template : <TAB> <TAB> self. load_test_from_template ( ) <TAB> <TAB> self. reload ( )",False,"frappe.db.get_value('Lab Prescription', self.prescription, 'invoiced')",self.invoiced,0.6584774255752563
|
||
|
3739,"def has_scheme ( self, inp ) : <TAB> if ""://"" in inp : <TAB> <TAB> return True <TAB> else : <TAB> <TAB> authority = inp. replace ( ""/"", ""#"" ). replace ( ""?"", ""#"" ). split ( ""#"" ) [ 0 ] <TAB> <TAB> if "":"" in authority : <TAB> <TAB> <TAB> _, host_or_port = authority. split ( "":"", 1 ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return False <TAB> <TAB> else : <TAB> <TAB> <TAB> return False <TAB> return True",False,"re.match('^\\d+$', host_or_port)",host_or_port == '0',0.6455568075180054
|
||
|
3740,"def __init__ ( self ) : <TAB> """"""Check for errors in the constructor."""""" <TAB> if self. rejected_users and self. allowed_users : <TAB> <TAB> raise AuthorizerError ( <TAB> <TAB> <TAB> ""rejected_users and allowed_users options "" ""are mutually exclusive"" <TAB> <TAB> ) <TAB> users = self. _get_system_users ( ) <TAB> for user in self. allowed_users or self. rejected_users : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise AuthorizerError ( 'invalid username ""anonymous""' ) <TAB> <TAB> if user not in users : <TAB> <TAB> <TAB> raise AuthorizerError ( ""unknown user %s"" % user ) <TAB> if self. anonymous_user is not None : <TAB> <TAB> if not self. has_user ( self. anonymous_user ) : <TAB> <TAB> <TAB> raise AuthorizerError ( ""no such user %s"" % self. anonymous_user ) <TAB> <TAB> home = self. get_home_dir ( self. anonymous_user ) <TAB> <TAB> if not os. path. isdir ( home ) : <TAB> <TAB> <TAB> raise AuthorizerError ( ""no valid home set for user %s"" % self. anonymous_user )",False,user == 'anonymous',self.anonymous_user is None and user not in self.users,0.664953351020813
|
||
|
3741,"def hard_nms ( box_scores, iou_threshold, top_k = - 1, candidate_size = 200 ) : <TAB> scores = box_scores [ :, - 1 ] <TAB> boxes = box_scores [ :, : - 1 ] <TAB> picked = [ ] <TAB> <TAB> indexes = np. argsort ( scores ) <TAB> <TAB> indexes = indexes [ - candidate_size : ] <TAB> while len ( indexes ) > 0 : <TAB> <TAB> <TAB> <TAB> current = indexes [ - 1 ] <TAB> <TAB> picked. append ( current ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> break <TAB> <TAB> current_box = boxes [ current, : ] <TAB> <TAB> <TAB> <TAB> indexes = indexes [ : - 1 ] <TAB> <TAB> rest_boxes = boxes [ indexes, : ] <TAB> <TAB> iou = iou_of ( rest_boxes, np. expand_dims ( current_box, axis = 0 ) ) <TAB> <TAB> indexes = indexes [ iou <= iou_threshold ] <TAB> return box_scores [ picked, : ]",False,0 < top_k == len(picked) or len(indexes) == 1,len(picked) > top_k,0.6510955095291138
|
||
|
3742,"def get_value ( self, trans, grid, repository_metadata ) : <TAB> datatype_list = [ ] <TAB> if repository_metadata : <TAB> <TAB> metadata = repository_metadata. metadata <TAB> <TAB> if metadata : <TAB> <TAB> <TAB> datatype_dicts = metadata. get ( ""datatypes"", [ ] ) <TAB> <TAB> <TAB> if datatype_dicts : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> datatype_tups = [ ] <TAB> <TAB> <TAB> <TAB> for datatype_dict in datatype_dicts : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> extension = datatype_dict. get ( ""extension"", """" ) <TAB> <TAB> <TAB> <TAB> <TAB> dtype = datatype_dict. get ( ""dtype"", """" ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> datatype_tups. append ( ( extension, dtype ) ) <TAB> <TAB> <TAB> <TAB> sorted_datatype_tups = sorted ( <TAB> <TAB> <TAB> <TAB> <TAB> datatype_tups, key = lambda datatype_tup : datatype_tup [ 0 ] <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> for datatype_tup in sorted_datatype_tups : <TAB> <TAB> <TAB> <TAB> <TAB> extension, datatype = datatype_tup [ : 2 ] <TAB> <TAB> <TAB> <TAB> <TAB> datatype_str = ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> '<a href=""browse_datatypes?operation=view_or_manage_repository&id=%s"">' <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> % trans. security. encode_id ( repository_metadata. id ) <TAB> <TAB> <TAB> <TAB>",False,extension and dtype,extension,0.6790333986282349
|
||
|
3743,"def next_idx ( self ) : <TAB> if not self. is_index_valid : <TAB> <TAB> return self. stop ( ) <TAB> playlist_len = len ( self. list ) <TAB> if self. mode == Player. MODE_ORDERED : <TAB> <TAB> <TAB> <TAB> if self. info [ ""idx"" ] < playlist_len : <TAB> <TAB> <TAB> self. info [ ""idx"" ] += 1 <TAB> elif self. mode == Player. MODE_ORDERED_LOOP : <TAB> <TAB> self. info [ ""idx"" ] = ( self. index + 1 ) % playlist_len <TAB> elif self. mode == Player. MODE_SINGLE_LOOP : <TAB> <TAB> self. info [ ""idx"" ] = self. info [ ""idx"" ] <TAB> else : <TAB> <TAB> playing_order_len = len ( self. order ) <TAB> <TAB> if self. _need_to_shuffle ( ) : <TAB> <TAB> <TAB> self. shuffle_order ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _swap_song ( ) <TAB> <TAB> <TAB> playing_order_len = len ( self. order ) <TAB> <TAB> self. info [ ""random_index"" ] += 1 <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. info [ ""random_index"" ] %= playing_order_len <TAB> <TAB> <TAB> <TAB> if self. info [ ""random_index"" ] >= playing_order_len : <TAB> <TAB> <TAB> self. info [ ""idx"" ] = playlist_len <TAB> <TAB> else : <TAB> <TAB> <TAB> self. info [ ""idx"" ] = self. order [ self. info [ ""random_index"" ] ] <TAB> if self. playing_song_changed_callback is not None : <TAB> <TAB> self. playing_song_changed_callback ( )",False,self.mode == Player.MODE_RANDOM_LOOP,self.info['random_index'] %= playing_order_len,0.6558465957641602
|
||
|
3744,"def _setProcessPriority ( process, nice_val, disable_gc ) : <TAB> org_nice_val = Computer. _process_original_nice_value <TAB> try : <TAB> <TAB> process. nice ( nice_val ) <TAB> <TAB> Computer. in_high_priority_mode = nice_val!= org_nice_val <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> gc. disable ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> gc. enable ( ) <TAB> <TAB> return True <TAB> except psutil. AccessDenied : <TAB> <TAB> print2err ( <TAB> <TAB> <TAB> ""WARNING: Could not set process {} priority "" <TAB> <TAB> <TAB> ""to {}"". format ( process. pid, nice_val ) <TAB> <TAB> ) <TAB> <TAB> return False",True,disable_gc,disable_gc,0.6794929504394531
|
||
|
3745,"def raise_if_unsafe ( self ) : <TAB> <TAB> if self. existing and len ( self. existing. records ) >= self. MIN_EXISTING_RECORDS : <TAB> <TAB> existing_record_count = len ( self. existing. records ) <TAB> <TAB> update_pcent = self. change_counts [ ""Update"" ] / existing_record_count <TAB> <TAB> delete_pcent = self. change_counts [ ""Delete"" ] / existing_record_count <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise UnsafePlan ( <TAB> <TAB> <TAB> <TAB> ""Too many updates, {:.2f} is over {:.2f} %"" <TAB> <TAB> <TAB> <TAB> ""({}/{})"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> update_pcent * 100, <TAB> <TAB> <TAB> <TAB> <TAB> self. update_pcent_threshold * 100, <TAB> <TAB> <TAB> <TAB> <TAB> self. change_counts [ ""Update"" ], <TAB> <TAB> <TAB> <TAB> <TAB> existing_record_count, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> if delete_pcent > self. delete_pcent_threshold : <TAB> <TAB> <TAB> raise UnsafePlan ( <TAB> <TAB> <TAB> <TAB> ""Too many deletes, {:.2f} is over {:.2f} %"" <TAB> <TAB> <TAB> <TAB> ""({}/{})"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> delete_pcent * 100, <TAB> <TAB> <TAB> <TAB> <TAB> self. delete_pcent_threshold * 100, <TAB> <TAB> <TAB> <TAB> <TAB> self. change_counts [ ""Delete"" ], <TAB> <TAB> <TAB> <TAB> <TAB> existing_record_count, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> )",True,update_pcent > self.update_pcent_threshold,update_pcent > self.update_pcent_threshold,0.6516165733337402
|
||
|
3746,"def __applyCustomFormat ( self, unused ) : <TAB> with Gaffer. UndoScope ( self. getPlug ( ). ancestor ( Gaffer. ScriptNode ) ) : <TAB> <TAB> with self. getContext ( ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. getPlug ( ). setValue ( <TAB> <TAB> <TAB> <TAB> <TAB> GafferImage. FormatPlug. getDefaultFormat ( self. getContext ( ) ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> Gaffer. Metadata. registerValue ( <TAB> <TAB> <TAB> self. getPlug ( ), ""formatPlugValueWidget:mode"", ""custom"" <TAB> <TAB> )",False,self.getPlug().getValue() == GafferImage.Format(),self.getPlug() is not None,0.6514966487884521
|
||
|
3747,"def flush ( ) : <TAB> if not ptrbuffer : <TAB> <TAB> return <TAB> cline = """" <TAB> for line in ptrbuffer : <TAB> <TAB> for token, value in line : <TAB> <TAB> <TAB> if token == ""TXT"" : <TAB> <TAB> <TAB> <TAB> cline += repr ( value ) <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> cline += ""_str(%s)"" % value <TAB> <TAB> <TAB> elif token == ""CMD"" : <TAB> <TAB> <TAB> <TAB> cline += ""_escape(%s)"" % value <TAB> <TAB> <TAB> cline += "", "" <TAB> <TAB> cline = cline [ : - 2 ] + ""\\\n"" <TAB> cline = cline [ : - 2 ] <TAB> if cline [ : - 1 ]. endswith ( ""\\\\\\\\\\n"" ) : <TAB> <TAB> cline = cline [ : - 7 ] + cline [ - 1 ] <TAB> cline = ""_printlist(["" + cline + ""])"" <TAB> del ptrbuffer [ : ] <TAB> code ( cline )",False,token == 'RAW',token == 'STRING',0.6661654710769653
|
||
|
3748,"def command ( self, slowly = False ) : <TAB> try : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> mailpile. util. LAST_USER_ACTIVITY = 0 <TAB> <TAB> self. _idx ( ). save ( self. session ) <TAB> <TAB> GlobalPostingList. Optimize ( <TAB> <TAB> <TAB> self. session, self. _idx ( ), force = ( ""harder"" in self. args ) <TAB> <TAB> ) <TAB> <TAB> return self. _success ( _ ( ""Optimized search engine"" ) ) <TAB> except KeyboardInterrupt : <TAB> <TAB> return self. _error ( _ ( ""Aborted"" ) )",False,not slowly,slowly,0.6730985641479492
|
||
|
3749,"def __init__ ( self, description, stochastic = None, custom_check = None ) : <TAB> self. _description = description <TAB> self. stochastic = stochastic <TAB> self. custom_check = custom_check <TAB> try : <TAB> <TAB> parsed = ExplicitStateUpdater. DESCRIPTION. parseString ( <TAB> <TAB> <TAB> description, parseAll = True <TAB> <TAB> ) <TAB> except ParseException as p_exc : <TAB> <TAB> ex = SyntaxError ( ""Parsing failed: "" + str ( p_exc. msg ) ) <TAB> <TAB> ex. text = str ( p_exc. line ) <TAB> <TAB> ex. offset = p_exc. column <TAB> <TAB> ex. lineno = p_exc. lineno <TAB> <TAB> raise ex <TAB> self. statements = [ ] <TAB> self. symbols = SYMBOLS. copy ( ) <TAB> for element in parsed : <TAB> <TAB> expression = str_to_sympy ( element. expression ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> expression = expression. subs ( sympy. Function ( ""f"" ), self. symbols [ ""__f"" ] ) <TAB> <TAB> expression = expression. subs ( sympy. Function ( ""g"" ), self. symbols [ ""__g"" ] ) <TAB> <TAB> symbols = list ( expression. atoms ( sympy. Symbol ) ) <TAB> <TAB> unique_symbols = [ ] <TAB> <TAB> for symbol in symbols : <TAB> <TAB> <TAB> if symbol. name == ""dt"" : <TAB> <TAB> <TAB> <TAB> unique_symbols. append ( symbol ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> unique_symbols. append ( _symbol ( ""__"" + symbol. name ) ) <TAB> <TAB> for symbol, unique_symbol in zip ( symbols, unique_symbols ) : <TAB> <TAB> <TAB> expression = expression. subs ( symbol, unique_symbol ) <TAB> <TAB> self. symbols. update ( dict ( ( ( symbol. name, symbol ) for symbol in unique_symbols ) ) ) <TAB> <TAB",False,element.getName() == 'output',stochastic,0.6520749926567078
|
||
|
3750,"def parse_scalar ( <TAB> xml_text, only_inBiddingZone_Domain = False, only_outBiddingZone_Domain = False ) : <TAB> """"""Returns a tuple containing two lists."""""" <TAB> if not xml_text : <TAB> <TAB> return None <TAB> soup = BeautifulSoup ( xml_text, ""html.parser"" ) <TAB> <TAB> values = [ ] <TAB> datetimes = [ ] <TAB> for timeseries in soup. find_all ( ""timeseries"" ) : <TAB> <TAB> resolution = timeseries. find_all ( ""resolution"" ) [ 0 ]. contents [ 0 ] <TAB> <TAB> datetime_start = arrow. get ( timeseries. find_all ( ""start"" ) [ 0 ]. contents [ 0 ] ) <TAB> <TAB> if only_inBiddingZone_Domain : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> elif only_outBiddingZone_Domain : <TAB> <TAB> <TAB> if not len ( timeseries. find_all ( ""outBiddingZone_Domain.mRID"". lower ( ) ) ) : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> for entry in timeseries. find_all ( ""point"" ) : <TAB> <TAB> <TAB> position = int ( entry. find_all ( ""position"" ) [ 0 ]. contents [ 0 ] ) <TAB> <TAB> <TAB> value = float ( entry. find_all ( ""quantity"" ) [ 0 ]. contents [ 0 ] ) <TAB> <TAB> <TAB> datetime = datetime_from_position ( datetime_start, position, resolution ) <TAB> <TAB> <TAB> values. append ( value ) <TAB> <TAB> <TAB> datetimes. append ( datetime ) <TAB> return values, datetimes",False,not len(timeseries.find_all('inBiddingZone_Domain.mRID'.lower())),"not len( timeseries.find_all(""point"".lower())",0.6568495035171509
|
||
|
3751,"def value_to_db_datetime ( self, value ) : <TAB> if value is None : <TAB> <TAB> return None <TAB> <TAB> if timezone. is_aware ( value ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> value = value. astimezone ( timezone. utc ). replace ( tzinfo = None ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""Oracle backend does not support timezone-aware datetimes when USE_TZ is False."" <TAB> <TAB> <TAB> ) <TAB> return six. text_type ( value )",False,settings.USE_TZ,self.use_tz,0.6705401539802551
|
||
|
3752,"def _load_plugins ( self, plugin ) : <TAB> logger. info ( 'loading plugin ""%s""', plugin ) <TAB> path_name = None <TAB> if PY2 : <TAB> <TAB> import imp <TAB> <TAB> for mod in plugin. split ( ""."" ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> path_name = [ path_name ] <TAB> <TAB> <TAB> _, path_name, _ = imp. find_module ( mod, path_name ) <TAB> else : <TAB> <TAB> from importlib. util import find_spec as importlib_find <TAB> <TAB> path_name = importlib_find ( plugin ) <TAB> <TAB> try : <TAB> <TAB> <TAB> path_name = path_name. submodule_search_locations [ 0 ] <TAB> <TAB> except TypeError : <TAB> <TAB> <TAB> path_name = path_name. origin <TAB> module_list = [ plugin ] <TAB> if not path_name. endswith ( "".py"" ) : <TAB> <TAB> module_list = glob ( ""{}/[!_]*.py"". format ( path_name ) ) <TAB> <TAB> module_list = [ <TAB> <TAB> <TAB> ""."". join ( ( plugin, os. path. split ( f ) [ - 1 ] [ : - 3 ] ) ) for f in module_list <TAB> <TAB> ] <TAB> for module in module_list : <TAB> <TAB> try : <TAB> <TAB> <TAB> import_module ( module ) <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> logger. exception ( ""Failed to import %s"", module )",False,path_name is not None,path_name,0.6558045148849487
|
||
|
3753,"def _frameRangeSelectionFilterUpdate ( self ) : <TAB> if not self. frameMonitorTree. getJob ( ) : <TAB> <TAB> self. frameRangeSelection. setFrameRange ( [ ""1"", ""10000"" ] ) <TAB> else : <TAB> <TAB> layers = self. frameMonitorTree. getJob ( ). getLayers ( ) <TAB> <TAB> _min = None <TAB> <TAB> _max = None <TAB> <TAB> for layer in layers : <TAB> <TAB> <TAB> seq = FileSequence. FrameSet ( layer. range ( ) ) <TAB> <TAB> <TAB> seq. normalize ( ) <TAB> <TAB> <TAB> frameList = seq. getAll ( ) <TAB> <TAB> <TAB> if _min is not None : <TAB> <TAB> <TAB> <TAB> _min = min ( _min, int ( frameList [ 0 ] ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> _min = int ( frameList [ 0 ] ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> _max = max ( _max, int ( frameList [ - 1 ] ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> _max = int ( frameList [ - 1 ] ) <TAB> <TAB> if _min == _max : <TAB> <TAB> <TAB> _max += 1 <TAB> <TAB> self. frameRangeSelection. default_select_size = 1000 // len ( layers ) <TAB> <TAB> self. frameRangeSelection. setFrameRange ( [ str ( _min ), str ( _max ) ] )",True,_max is not None,_max is not None,0.6593604683876038
|
||
|
3754,"def get_detections ( im, det, thresh, names, classes ) : <TAB> ""Draw the markings around the detected region"" <TAB> labelstr = [ ] <TAB> category = - 1 <TAB> detection = None <TAB> valid = False <TAB> for j in range ( classes ) : <TAB> <TAB> if det [ ""prob"" ] [ j ] > thresh : <TAB> <TAB> <TAB> if category == - 1 : <TAB> <TAB> <TAB> <TAB> category = j <TAB> <TAB> <TAB> labelstr. append ( names [ j ] + "" "" + str ( round ( det [ ""prob"" ] [ j ], 4 ) ) ) <TAB> if category > - 1 : <TAB> <TAB> valid = True <TAB> <TAB> imc, imh, imw = im. shape <TAB> <TAB> width = int ( imh * 0.006 ) <TAB> <TAB> offset = category * 123457 % classes <TAB> <TAB> red = _get_color ( 2, offset, classes ) <TAB> <TAB> green = _get_color ( 1, offset, classes ) <TAB> <TAB> blue = _get_color ( 0, offset, classes ) <TAB> <TAB> rgb = [ red, green, blue ] <TAB> <TAB> b = det [ ""bbox"" ] <TAB> <TAB> left = int ( ( b. x - b. w / 2.0 ) * imw ) <TAB> <TAB> right = int ( ( b. x + b. w / 2.0 ) * imw ) <TAB> <TAB> top = int ( ( b. y - b. h / 2.0 ) * imh ) <TAB> <TAB> bot = int ( ( b. y + b. h / 2.0 ) * imh ) <TAB> <TAB> if left < 0 : <TAB> <TAB> <TAB> left = 0 <TAB> <TAB> if right > imw - 1 : <TAB> <TAB> <TAB> right = imw - 1 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> top = 0 <TAB> <TAB> if bot > imh - 1 : <TAB> <",True,top < 0,top < 0,0.6721189022064209
|
||
|
3755,"def expect_first_flow_mapping_key ( self ) : <TAB> if isinstance ( self. event, MappingEndEvent ) : <TAB> <TAB> self. indent = self. indents. pop ( ) <TAB> <TAB> self. flow_level -= 1 <TAB> <TAB> self. write_indicator ( ""}"", False ) <TAB> <TAB> self. state = self. states. pop ( ) <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. write_indent ( ) <TAB> <TAB> if not self. canonical and self. check_simple_key ( ) : <TAB> <TAB> <TAB> self. states. append ( self. expect_flow_mapping_simple_value ) <TAB> <TAB> <TAB> self. expect_node ( mapping = True, simple_key = True ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. write_indicator ( ""?"", True ) <TAB> <TAB> <TAB> self. states. append ( self. expect_flow_mapping_value ) <TAB> <TAB> <TAB> self. expect_node ( mapping = True )",False,self.canonical or self.column > self.best_width,self.flow_level > 0,0.6515256762504578
|
||
|
3756,"def language ( self ) : <TAB> if self. lang_data : <TAB> <TAB> lang_data = [ s if s!= ""None"" else None for s in self. lang_data ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return Language ( lang_data [ 0 ], country = lang_data [ 1 ], script = lang_data [ 2 ] )",False,lang_data[0],len(lang_data),0.6593518257141113
|
||
|
3757,"def event_processor ( event, hint ) : <TAB> request = weak_request ( ) <TAB> if request is None : <TAB> <TAB> return event <TAB> if ""transaction"" not in event : <TAB> <TAB> try : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> event [ ""transaction"" ] = request. matched_route. name <TAB> <TAB> <TAB> elif integration. transaction_style == ""route_pattern"" : <TAB> <TAB> <TAB> <TAB> event [ ""transaction"" ] = request. matched_route. pattern <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> pass <TAB> with capture_internal_exceptions ( ) : <TAB> <TAB> PyramidRequestExtractor ( request ). extract_into_event ( event ) <TAB> if _should_send_default_pii ( ) : <TAB> <TAB> with capture_internal_exceptions ( ) : <TAB> <TAB> <TAB> user_info = event. setdefault ( ""user"", { } ) <TAB> <TAB> <TAB> if ""id"" not in user_info : <TAB> <TAB> <TAB> <TAB> user_info [ ""id"" ] = request. authenticated_userid <TAB> return event",True,integration.transaction_style == 'route_name',integration.transaction_style == 'route_name',0.6518987417221069
|
||
|
3758,"def _convert_example ( example, use_bfloat16 ) : <TAB> """"""Cast int64 into int32 and float32 to bfloat16 if use_bfloat16."""""" <TAB> for key in list ( example. keys ( ) ) : <TAB> <TAB> val = example [ key ] <TAB> <TAB> if tf. keras. backend. is_sparse ( val ) : <TAB> <TAB> <TAB> val = tf. sparse. to_dense ( val ) <TAB> <TAB> if val. dtype == tf. int64 : <TAB> <TAB> <TAB> val = tf. cast ( val, tf. int32 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> val = tf. cast ( val, tf. bfloat16 ) <TAB> <TAB> example [ key ] = val",False,use_bfloat16 and val.dtype == tf.float32,val.dtype == tf.float32 and use_bfloat16,0.6499889492988586
|
||
|
3759,"def filterChecker ( url, params, headers, GET, delay, occurences, timeout, encoding ) : <TAB> positions = occurences. keys ( ) <TAB> sortedEfficiencies = { } <TAB> <TAB> environments = set ( [ ""<"", "">"" ] ) <TAB> for i in range ( len ( positions ) ) : <TAB> <TAB> sortedEfficiencies [ i ] = { } <TAB> for i in occurences : <TAB> <TAB> occurences [ i ] [ ""score"" ] = { } <TAB> <TAB> context = occurences [ i ] [ ""context"" ] <TAB> <TAB> if context == ""comment"" : <TAB> <TAB> <TAB> environments. add ( ""-->"" ) <TAB> <TAB> elif context == ""script"" : <TAB> <TAB> <TAB> environments. add ( occurences [ i ] [ ""details"" ] [ ""quote"" ] ) <TAB> <TAB> <TAB> environments. add ( ""</scRipT/>"" ) <TAB> <TAB> elif context == ""attribute"" : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> if ( <TAB> <TAB> <TAB> <TAB> <TAB> occurences [ i ] [ ""details"" ] [ ""name"" ] == ""srcdoc"" <TAB> <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> <TAB> environments. add ( ""<"" ) <TAB> <TAB> <TAB> <TAB> <TAB> environments. add ( "">"" ) <TAB> <TAB> <TAB> if occurences [ i ] [ ""details"" ] [ ""quote"" ] : <TAB> <TAB> <TAB> <TAB> environments. add ( occurences [ i ] [ ""details"" ] [ ""quote"" ] ) <TAB> for environment in environments : <TAB> <TAB> if environment : <TAB> <TAB> <TAB> efficiencies = checker ( <TAB> <TAB> <TAB> <TAB> url, <TAB> <TAB> <TAB> <TAB> params, <TAB> <TAB> <TAB> <TAB> headers, <TAB> <TAB>",False,occurences[i]['details']['type'] == 'value',len(sortedEfficiencies) > 0,0.6617074608802795
|
||
|
3760,"def on_startup ( dispatcher, url = None, cert = None ) : <TAB> setup_handlers ( dispatcher ) <TAB> bot = dispatcher. bot <TAB> <TAB> webhook = await bot. get_webhook_info ( ) <TAB> if url : <TAB> <TAB> <TAB> <TAB> if webhook. url!= url : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if not webhook. url : <TAB> <TAB> <TAB> <TAB> await bot. delete_webhook ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> with open ( cert, ""rb"" ) as cert_file : <TAB> <TAB> <TAB> <TAB> <TAB> await bot. set_webhook ( url, certificate = cert_file ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> await bot. set_webhook ( url ) <TAB> elif webhook. url : <TAB> <TAB> <TAB> <TAB> await bot. delete_webhook ( )",True,cert,cert,0.6862301230430603
|
||
|
3761,"def _get_compressor ( compress_type, compresslevel = None ) : <TAB> if compress_type == ZIP_DEFLATED : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return zlib. compressobj ( compresslevel, zlib. DEFLATED, - 15 ) <TAB> <TAB> return zlib. compressobj ( zlib. Z_DEFAULT_COMPRESSION, zlib. DEFLATED, - 15 ) <TAB> elif compress_type == ZIP_BZIP2 : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return bz2. BZ2Compressor ( compresslevel ) <TAB> <TAB> return bz2. BZ2Compressor ( ) <TAB> <TAB> elif compress_type == ZIP_LZMA : <TAB> <TAB> return LZMACompressor ( ) <TAB> else : <TAB> <TAB> return None",True,compresslevel is not None,compresslevel is not None,0.6605966091156006
|
||
|
3762,"def button_release ( self, mapper ) : <TAB> self. pressed = False <TAB> if self. waiting_task and self. active is None and not self. action : <TAB> <TAB> <TAB> <TAB> mapper. cancel_task ( self. waiting_task ) <TAB> <TAB> self. waiting_task = None <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. normalaction. button_press ( mapper ) <TAB> <TAB> <TAB> mapper. schedule ( 0.02, self. normalaction. button_release ) <TAB> elif self. active : <TAB> <TAB> <TAB> <TAB> self. active. button_release ( mapper ) <TAB> <TAB> self. active = None",False,self.normalaction,self.pressed,0.6700454950332642
|
||
|
3763,"def parse_plugins_list ( data : str ) -> List [ str ] : <TAB> plugins : List [ str ] = [ ] <TAB> modules : Dict [ str, Tuple [ int, str ] ] = { } <TAB> for line, entry in enumerate ( data. splitlines ( ) ) : <TAB> <TAB> plugin = entry. strip ( ) <TAB> <TAB> if ""#"" in plugin : <TAB> <TAB> <TAB> comment_start = plugin. find ( ""#"" ) <TAB> <TAB> <TAB> plugin = plugin [ : comment_start ]. strip ( ) <TAB> <TAB> if not plugin : <TAB> <TAB> <TAB> continue <TAB> <TAB> if ""@"" in plugin : <TAB> <TAB> <TAB> module, path = map ( lambda x : x. strip ( ), plugin. split ( ""@"", 1 ) ) <TAB> <TAB> <TAB> plugin = f""{module}@{path}"" <TAB> <TAB> <TAB> validate_local_plugin ( line, module, path ) <TAB> <TAB> else : <TAB> <TAB> <TAB> module = plugin <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> first_line, first_entry = modules [ module ] <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> f""plugin '{module}' is listed more than once: "" <TAB> <TAB> <TAB> <TAB> f""at line {first_line} ('{first_entry}') and at {line} ('{entry}')"" <TAB> <TAB> <TAB> ) <TAB> <TAB> modules [ module ] = line, entry <TAB> <TAB> plugins. append ( plugin ) <TAB> return plugins",True,module in modules,module in modules,0.672839343547821
|
||
|
3764,"def __codeanalysis_settings_changed ( self, current_finfo ) : <TAB> if self. data : <TAB> <TAB> run_pyflakes, run_pep8 = self. pyflakes_enabled, self. pep8_enabled <TAB> <TAB> for finfo in self. data : <TAB> <TAB> <TAB> self. __update_editor_margins ( finfo. editor ) <TAB> <TAB> <TAB> finfo. cleanup_analysis_results ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> if current_finfo is not finfo : <TAB> <TAB> <TAB> <TAB> <TAB> finfo. run_code_analysis ( run_pyflakes, run_pep8 )",False,(run_pyflakes or run_pep8) and current_finfo is not None,self.has_key(finfo),0.6502747535705566
|
||
|
3765,"def __call__ ( self, model_output : ModelOutput ) -> ModelOutput : <TAB> for model_output_i in model_output : <TAB> <TAB> instances = model_output_i [ ""instances"" ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> instances_filtered = instances [ instances. scores >= self. min_score ] <TAB> <TAB> model_output_i [ ""instances"" ] = instances_filtered <TAB> return model_output",False,not instances.has('scores'),instances is None,0.6536625623703003
|
||
|
3766,"def randomly_choose_false_edges ( nodes, true_edges, num ) : <TAB> true_edges_set = set ( true_edges ) <TAB> tmp_list = list ( ) <TAB> all_flag = False <TAB> for _ in range ( num ) : <TAB> <TAB> trial = 0 <TAB> <TAB> while True : <TAB> <TAB> <TAB> x = nodes [ random. randint ( 0, len ( nodes ) - 1 ) ] <TAB> <TAB> <TAB> y = nodes [ random. randint ( 0, len ( nodes ) - 1 ) ] <TAB> <TAB> <TAB> trial += 1 <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> all_flag = True <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> if x!= y and ( x, y ) not in true_edges_set and ( y, x ) not in true_edges_set : <TAB> <TAB> <TAB> <TAB> tmp_list. append ( ( x, y ) ) <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> if all_flag : <TAB> <TAB> <TAB> break <TAB> return tmp_list",False,trial >= 1000,trial == true_edges,0.682117223739624
|
||
|
3767,"def _toplevel_window_state_event_cb ( self, toplevel, event ) : <TAB> """"""Handle transitions between fullscreen and windowed."""""" <TAB> if event. changed_mask & Gdk. WindowState. FULLSCREEN : <TAB> <TAB> fullscreen = event. new_window_state & Gdk. WindowState. FULLSCREEN <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if self. autohide_enabled : <TAB> <TAB> <TAB> <TAB> self. _connect_autohide_events ( ) <TAB> <TAB> <TAB> <TAB> self. _start_autohide_timeout ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for floating in self. _floating : <TAB> <TAB> <TAB> <TAB> floating. show_all ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. _disconnect_autohide_events ( ) <TAB> <TAB> <TAB> self. _show_autohide_widgets ( ) <TAB> <TAB> self. _is_fullscreen = bool ( fullscreen ) <TAB> <TAB> self. _update_canvas_scrolledwindow ( ) <TAB> if event. changed_mask & Gdk. WindowState. MAXIMIZED : <TAB> <TAB> maximized = event. new_window_state & Gdk. WindowState. MAXIMIZED <TAB> <TAB> self. _is_maximized = bool ( maximized )",True,fullscreen,fullscreen,0.6715191006660461
|
||
|
3768,"def main ( client ) : <TAB> <TAB> cms_metadata_service = client. GetService ( ""CmsMetadataService"", version = ""v202005"" ) <TAB> <TAB> statement = ad_manager. StatementBuilder ( version = ""v202005"" ) <TAB> <TAB> <TAB> while True : <TAB> <TAB> response = cms_metadata_service. getCmsMetadataValuesByStatement ( <TAB> <TAB> <TAB> statement. ToStatement ( ) <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> for cms_metadata_value in response [ ""results"" ] : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> <TAB> ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> 'CMS metadata value with Id %d and name ""%s"", associated with'<TAB> <TAB> <TAB> <TAB> <TAB> <TAB> 'the CmsMetadataKey with id %d and name ""%s"", was found.\n' <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> % ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> cms_metadata_value [ ""cmsMetadataValueId"" ], <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> cms_metadata_value [ ""valueName"" ], <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> cms_metadata_value [ ""key"" ] [ ""id"" ], <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> cms_metadata_value [ ""key"" ] [ ""name"" ], <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> statement. offset += statement. limit <TAB> <TAB> else : <TAB> <TAB> <TAB> break <TAB> print ( ""\nNumber of results found: %s"" % response [ ""totalResultSetSize"" ] )",False,'results' in response and len(response['results']),response[0] == 'cmsMetadataValueId',0.6575781106948853
|
||
|
3769,"def validate ( self, attrs ) : <TAB> credentials = { <TAB> <TAB> self. username_field : attrs. get ( self. username_field ), <TAB> <TAB> ""password"" : attrs. get ( ""password"" ), <TAB> } <TAB> if all ( credentials. values ( ) ) : <TAB> <TAB> user = authenticate ( ** credentials ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if not user. is_active : <TAB> <TAB> <TAB> <TAB> msg = _ ( ""User account is disabled."" ) <TAB> <TAB> <TAB> <TAB> raise serializers. ValidationError ( msg ) <TAB> <TAB> <TAB> payload = jwt_payload_handler ( user ) <TAB> <TAB> <TAB> return { ""token"" : jwt_encode_handler ( payload ), ""user"" : user } <TAB> <TAB> else : <TAB> <TAB> <TAB> msg = _ ( ""Unable to login with provided credentials."" ) <TAB> <TAB> <TAB> raise serializers. ValidationError ( msg ) <TAB> else : <TAB> <TAB> msg = _ ( 'Must include ""{username_field}"" and ""password"".' ) <TAB> <TAB> msg = msg. format ( username_field = self. username_field ) <TAB> <TAB> raise serializers. ValidationError ( msg )",False,user,self.username_field,0.6883484721183777
|
||
|
3770,"def __getitem__ ( self, index ) : <TAB> if self. _check ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if index < 0 or index >= len ( self. features ) : <TAB> <TAB> <TAB> <TAB> raise IndexError ( index ) <TAB> <TAB> <TAB> if self. features [ index ] is None : <TAB> <TAB> <TAB> <TAB> feature = self. device. feature_request ( FEATURE. FEATURE_SET, 0x10, index ) <TAB> <TAB> <TAB> <TAB> if feature : <TAB> <TAB> <TAB> <TAB> <TAB> ( feature, ) = _unpack ( ""!H"", feature [ : 2 ] ) <TAB> <TAB> <TAB> <TAB> <TAB> self. features [ index ] = FEATURE [ feature ] <TAB> <TAB> <TAB> return self. features [ index ] <TAB> <TAB> elif isinstance ( index, slice ) : <TAB> <TAB> <TAB> indices = index. indices ( len ( self. features ) ) <TAB> <TAB> <TAB> return [ self. __getitem__ ( i ) for i in range ( * indices ) ]",False,"isinstance(index, int)",self.features is not None,0.65706866979599
|
||
|
3771,"def getNextInvalidLink ( ) : <TAB> for originID, targetID, originType, targetType in getAllDataLinkIDs ( ) : <TAB> <TAB> if ( originType, targetType ) in approvedLinkTypes : <TAB> <TAB> <TAB> continue <TAB> <TAB> origin = idToSocket ( originID ) <TAB> <TAB> target = idToSocket ( targetID ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> approvedLinkTypes. add ( ( originType, targetType ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return origin, target <TAB> return None, None",False,"isConnectionValid(origin, target)",targetType,0.6510434150695801
|
||
|
3772,"def main ( ) : <TAB> setupLogging ( ) <TAB> if ( <TAB> <TAB> platform. system ( ) == ""Linux"" <TAB> <TAB> and os. getuid ( )!= 0 <TAB> <TAB> and rqd. rqconstants. RQD_BECOME_JOB_USER <TAB> ) : <TAB> <TAB> logging. critical ( ""Please run launch as root"" ) <TAB> <TAB> sys. exit ( 1 ) <TAB> try : <TAB> <TAB> opts, argv = getopt. getopt ( <TAB> <TAB> <TAB> sys. argv [ 1 : ], ""hdc:"", [ ""help"", ""daemon"", ""nimbyoff"", ""update"" ] <TAB> <TAB> ) <TAB> except getopt. GetoptError : <TAB> <TAB> usage ( ) <TAB> <TAB> sys. exit ( 1 ) <TAB> optNimbyOff = False <TAB> for o, a in opts : <TAB> <TAB> if o in [ ""-h"", ""--help"" ] : <TAB> <TAB> <TAB> usage ( ) <TAB> <TAB> <TAB> sys. exit ( 0 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> if o in [ ""--nimbyoff"" ] : <TAB> <TAB> <TAB> optNimbyOff = True <TAB> rqd. rqutil. permissionsLow ( ) <TAB> logging. warning ( ""RQD Starting Up"" ) <TAB> rqCore = rqd. rqcore. RqCore ( optNimbyOff ) <TAB> rqCore. start ( )",False,"o in ['-d', '--daemon']","a in [--h"", '--help']",0.6554223895072937
|
||
|
3773,"def on_batch_end ( self, training_state, snapshot = False ) : <TAB> if snapshot & ( self. snapshot_step is not None ) : <TAB> <TAB> self. save ( training_state. step ) <TAB> if None not in ( <TAB> <TAB> self. best_snapshot_path, <TAB> <TAB> self. best_val_accuracy, <TAB> <TAB> training_state. val_acc, <TAB> ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. best_val_accuracy = training_state. val_acc <TAB> <TAB> <TAB> self. save_best ( int ( 10000 * round ( training_state. val_acc, 4 ) ) )",False,training_state.val_acc > self.best_val_accuracy,not self.best_snapshot_path,0.6495373249053955
|
||
|
3774,"def test_update_topic ( self ) : <TAB> async with self. chat_client : <TAB> <TAB> await self. _create_thread ( ) <TAB> <TAB> topic = ""update topic"" <TAB> <TAB> async with self. chat_thread_client : <TAB> <TAB> <TAB> await self. chat_thread_client. update_topic ( topic = topic ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> await self. chat_client. delete_chat_thread ( self. thread_id )",False,not self.is_playback(),self.thread_id,0.6489672660827637
|
||
|
3775,"def save_all_changed_extensions ( self ) : <TAB> """"""Save configuration changes to the user config file."""""" <TAB> has_changes = False <TAB> for ext_name in self. extensions : <TAB> <TAB> options = self. extensions [ ext_name ] <TAB> <TAB> for opt in options : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> has_changes = True <TAB> if has_changes : <TAB> <TAB> self. ext_userCfg. Save ( )",False,"self.set_extension_value(ext_name, opt)",opt in self.extensions,0.645179033279419
|
||
|
3776,"def get_help_width ( ) : <TAB> """"""Returns the integer width of help lines that is used in TextWrap."""""" <TAB> if not sys. stdout. isatty ( ) or termios is None or fcntl is None : <TAB> <TAB> return _DEFAULT_HELP_WIDTH <TAB> try : <TAB> <TAB> data = fcntl. ioctl ( sys. stdout, termios. TIOCGWINSZ, ""1234"" ) <TAB> <TAB> columns = struct. unpack ( ""hh"", data ) [ 1 ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return columns <TAB> <TAB> <TAB> <TAB> return int ( os. getenv ( ""COLUMNS"", _DEFAULT_HELP_WIDTH ) ) <TAB> except ( TypeError, IOError, struct. error ) : <TAB> <TAB> return _DEFAULT_HELP_WIDTH",False,columns >= _MIN_HELP_WIDTH,len(columns),0.6583073139190674
|
||
|
3777,"def __init__ ( self, host, port = None, username = None, password = None, protocol = ""https"" ) : <TAB> if not port : <TAB> <TAB> if protocol == ""https"" : <TAB> <TAB> <TAB> port = 443 <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> port = 80 <TAB> <TAB> else : <TAB> <TAB> <TAB> raise Exception ( <TAB> <TAB> <TAB> <TAB> ""Can't determine port from protocol. "" ""Please specifiy a port."" <TAB> <TAB> <TAB> ) <TAB> self. cwd = ""/"" <TAB> self. baseurl = ""%s://%s:%d"" % ( protocol, host, port ) <TAB> self. host = host <TAB> self. port = port <TAB> self. protocol = protocol <TAB> self. username = username <TAB> self. password = password <TAB> if username and password : <TAB> <TAB> self. auth = base64. encodestring ( ""%s:%s"" % ( username, password ) ). replace ( <TAB> <TAB> <TAB> ""\n"", """" <TAB> <TAB> ) <TAB> else : <TAB> <TAB> self. auth = None",True,protocol == 'http',protocol == 'http',0.6666197776794434
|
||
|
3778,"def tamper ( payload, ** kwargs ) : <TAB> junk_chars = ""!#$%&()*~+-_.,:;?@[/|\]^`"" <TAB> retval = """" <TAB> for i, char in enumerate ( payload, start = 1 ) : <TAB> <TAB> amount = random. randint ( 10, 15 ) <TAB> <TAB> if char == "">"" : <TAB> <TAB> <TAB> retval += "">"" <TAB> <TAB> <TAB> for _ in range ( amount ) : <TAB> <TAB> <TAB> <TAB> retval += random. choice ( junk_chars ) <TAB> <TAB> elif char == ""<"" : <TAB> <TAB> <TAB> retval += ""<"" <TAB> <TAB> <TAB> for _ in range ( amount ) : <TAB> <TAB> <TAB> <TAB> retval += random. choice ( junk_chars ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> for _ in range ( amount ) : <TAB> <TAB> <TAB> <TAB> retval += random. choice ( junk_chars ) <TAB> <TAB> else : <TAB> <TAB> <TAB> retval += char <TAB> return retval",False,char == '',char == '>',0.6676473021507263
|
||
|
3779,"def process_cookie_options ( self, grab, req ) : <TAB> <TAB> <TAB> if grab. config [ ""cookiefile"" ] : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> grab. cookies. load_from_file ( grab. config [ ""cookiefile"" ] ) <TAB> <TAB> except IOError as ex : <TAB> <TAB> <TAB> logging. error ( ex ) <TAB> request_host = urlsplit ( req. url ). hostname <TAB> if request_host : <TAB> <TAB> if request_host. startswith ( ""www."" ) : <TAB> <TAB> <TAB> request_host_no_www = request_host [ 4 : ] <TAB> <TAB> else : <TAB> <TAB> <TAB> request_host_no_www = request_host <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if grab. config [ ""cookies"" ] : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise error. GrabMisuseError ( ""cookies option should"" "" be a dict"" ) <TAB> <TAB> <TAB> for name, value in grab. config [ ""cookies"" ]. items ( ) : <TAB> <TAB> <TAB> <TAB> grab. cookies. set ( name = name, value = value, domain = request_host_no_www ) <TAB> cookie_hdr = grab. cookies. get_cookie_header ( req ) <TAB> if cookie_hdr : <TAB> <TAB> req. headers [ ""Cookie"" ] = cookie_hdr",False,"not isinstance(grab.config['cookies'], dict)","hasattr(grab.config['cookies']) and hasattr(grab.config['cookies'], 'keys')",0.6539105772972107
|
||
|
3780,"def update_files ( data, python = True ) : <TAB> """"""Update files with new version number."""""" <TAB> if len ( sys. argv )!= 2 : <TAB> <TAB> e = Exception ( 'Specify PEP440 version: ""%s 1.2.3""' % sys. argv [ 0 ] ) <TAB> <TAB> raise ( e ) <TAB> version = verify_pep440 ( sys. argv [ 1 ] ) <TAB> <TAB> if not python : <TAB> <TAB> version = version. base_version <TAB> for filename, regex in data. items ( ) : <TAB> <TAB> filename = os. path. join ( BASE_DIR, filename ) <TAB> <TAB> matched = False <TAB> <TAB> pattern = re. compile ( regex ) <TAB> <TAB> for line in fileinput. input ( filename, inplace = True ) : <TAB> <TAB> <TAB> if pattern. match ( line. rstrip ( ) ) : <TAB> <TAB> <TAB> <TAB> matched = True <TAB> <TAB> <TAB> line = re. sub ( regex, r""\g<pre>%s\g<post>"" % version, line. rstrip ( ) ) <TAB> <TAB> <TAB> print ( line ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise Exception ( 'In file ""%s"", did not find regex ""%s""' % ( filename, regex ) )",True,not matched,not matched,0.6663120985031128
|
||
|
3781,"def _compute_operands ( self, v ) : <TAB> expl_operand_list = [ ] <TAB> impl_operand_list = [ ] <TAB> for op in v. parsed_operands : <TAB> <TAB> s = None <TAB> <TAB> if op. name in [ ""MEM0"", ""MEM1"" ] : <TAB> <TAB> <TAB> s = ""MEM"" <TAB> <TAB> elif op. name in [ ""IMM0"", ""IMM1"" ] : <TAB> <TAB> <TAB> s = ""IMM"" <TAB> <TAB> elif op. type == ""nt_lookup_fn"" : <TAB> <TAB> <TAB> s = op. lookupfn_name <TAB> <TAB> <TAB> s = re. sub ( r""[()]*"", """", s ) <TAB> <TAB> <TAB> s = re. sub ( r""_[RBN].*"", """", s ) <TAB> <TAB> <TAB> s = re. sub ( r""FINAL_.*"", """", s ) <TAB> <TAB> elif op. type == ""reg"" : <TAB> <TAB> <TAB> s = op. bits <TAB> <TAB> <TAB> s = re. sub ( r""XED_REG_"", """", s ) <TAB> <TAB> elif op. type == ""imm_const"" : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> s = op. name <TAB> <TAB> else : <TAB> <TAB> <TAB> msgb ( ""UNHANDLED"", ""{}"". format ( op ) ) <TAB> <TAB> if s : <TAB> <TAB> <TAB> if op. visibility in [ ""IMPLICIT"", ""SUPPRESSED"" ] : <TAB> <TAB> <TAB> <TAB> impl_operand_list. append ( s ) <TAB> <TAB> <TAB> if op. visibility in [ ""EXPLICIT"", ""DEFAULT"" ] : <TAB> <TAB> <TAB> <TAB> expl_operand_list. append ( s ) <TAB> return expl",False,"op.name in ['BCAST', 'SCALE']",s,0.6584795713424683
|
||
|
3782,"def _real_extract ( self, url ) : <TAB> display_id = self. _match_id ( url ) <TAB> webpage = self. _download_webpage ( url, display_id ) <TAB> drupal_settings = self. _parse_json ( <TAB> <TAB> self. _search_regex ( <TAB> <TAB> <TAB> r""jQuery\.extend\(Drupal\.settings\s*,\s*({.+?})\);"", <TAB> <TAB> <TAB> webpage, <TAB> <TAB> <TAB> ""drupal settings"", <TAB> <TAB> ), <TAB> <TAB> display_id, <TAB> ) <TAB> entries = [ ] <TAB> for config_profile in drupal_settings. get ( ""ren_jwplayer"", { } ). values ( ) : <TAB> <TAB> media_id = config_profile. get ( ""mediaid"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> media_id = compat_str ( media_id ) <TAB> <TAB> entries. append ( self. url_result ( ""rentv:"" + media_id, ""RENTV"", media_id ) ) <TAB> return self. playlist_result ( entries, display_id )",True,not media_id,not media_id,0.6625657081604004
|
||
|
3783,"def whole ( self, mapper, x, y, what ) : <TAB> distance = sqrt ( x * x + y * y ) <TAB> if distance < STICK_PAD_MAX_HALF : <TAB> <TAB> <TAB> <TAB> self. angle = None <TAB> <TAB> if mapper. was_touched ( what ) : <TAB> <TAB> <TAB> self. action. change ( mapper, 0, 0, what ) <TAB> else : <TAB> <TAB> <TAB> <TAB> angle = atan2 ( x, y ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. angle, angle = angle, 0 <TAB> <TAB> <TAB> self. _haptic_counter = 0 <TAB> <TAB> else : <TAB> <TAB> <TAB> self. angle, angle = angle, self. angle - angle <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if angle > PI : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> angle -= 2 * PI <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> elif angle < - PI : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> angle += 2 * PI <TAB> <TAB> <TAB> <TAB> angle *= 10000.0 <TAB> <TAB> <TAB> <TAB> if self. haptic : <TAB> <TAB> <TAB> self. _haptic_counter += angle * self. speed / self. haptic. frequency <TAB> <TAB> <TAB> if abs ( self. _haptic_counter ) > 0.5 : <TAB> <TAB> <TAB> <TAB> if self. _haptic_counter > 0.5 : <TAB> <TAB> <TAB> <TAB> <TAB> self. _haptic_counter -= 0.5 <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> self. _haptic_counter += 0.",False,self.angle is None,self.angle > 0,0.6592676639556885
|
||
|
3784,"def recent_results ( self, items ) : <TAB> """"""Set recent results from provider."""""" <TAB> if not recent_results. get ( self. get_id ( ) ) : <TAB> <TAB> recent_results. update ( { self. get_id ( ) : [ ] } ) <TAB> if items : <TAB> <TAB> add_to_list = [ ] <TAB> <TAB> for item in items : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> add_to_list += [ item ] <TAB> <TAB> results = add_to_list + recent_results [ self. get_id ( ) ] <TAB> <TAB> recent_results [ self. get_id ( ) ] = results [ : self. max_recent_items ]",False,item not in recent_results[self.get_id()],self._recent_items(item),0.6495741009712219
|
||
|
3785,"def find_test_functions ( collections ) : <TAB> if not isinstance ( collections, list ) : <TAB> <TAB> collections = [ collections ] <TAB> functions = [ ] <TAB> for collection in collections : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> collection = vars ( collection ) <TAB> <TAB> keys = collection. keys ( ) <TAB> <TAB> keys. sort ( ) <TAB> <TAB> for key in keys : <TAB> <TAB> <TAB> value = collection [ key ] <TAB> <TAB> <TAB> if isinstance ( value, types. FunctionType ) and hasattr ( value, ""unittest"" ) : <TAB> <TAB> <TAB> <TAB> functions. append ( value ) <TAB> return functions",False,"not isinstance(collection, dict)","isinstance(collection, types.Dict)",0.656400203704834
|
||
|
3786,"def test_chunkcoding ( self ) : <TAB> tstring_lines = [ ] <TAB> for b in self. tstring : <TAB> <TAB> lines = b. split ( b""\n"" ) <TAB> <TAB> last = lines. pop ( ) <TAB> <TAB> assert last == b"""" <TAB> <TAB> lines = [ line + b""\n"" for line in lines ] <TAB> <TAB> tstring_lines. append ( lines ) <TAB> for native, utf8 in zip ( * tstring_lines ) : <TAB> <TAB> u = self. decode ( native ) [ 0 ] <TAB> <TAB> self. assertEqual ( u, utf8. decode ( ""utf-8"" ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. assertEqual ( native, self. encode ( u ) [ 0 ] )",False,self.roundtriptest,u != native,0.6564186811447144
|
||
|
3787,"def assertionHelper ( left_type, left_op, op, right_type, right_op, expected ) : <TAB> """"""Helper function used to figure out which test cases fail without blowing up the rest of the test."""""" <TAB> import clr <TAB> import System <TAB> expression_str = ""{0}({1}) {2} {3}({4})"". format ( <TAB> <TAB> left_type, left_op, str ( op ), right_type, right_op <TAB> ) <TAB> <TAB> if unsupported_operands. count ( left_type + op + right_type ) > 0 : <TAB> <TAB> with self. assertRaises ( TypeError ) : <TAB> <TAB> <TAB> eval ( expression_str ) <TAB> <TAB> return <TAB> try : <TAB> <TAB> expression = eval ( expression_str ) <TAB> except TypeError as e : <TAB> <TAB> self. fail ( ""TYPE BUG: %s"" % expression_str ) <TAB> try : <TAB> <TAB> self. assertEqual ( expression, expected ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. fail ( ""NO BUG FOR: %s"" % expression_str ) <TAB> except : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return <TAB> <TAB> self. fail ( expression_str )",False,known_bugs.count(left_type + op + right_type) > 0,not expected,0.6478638648986816
|
||
|
3788,"def _should_include_path ( path, includes, excludes ) : <TAB> """"""Return True iff the given path should be included."""""" <TAB> from os. path import basename <TAB> from fnmatch import fnmatch <TAB> base = basename ( path ) <TAB> if includes : <TAB> <TAB> for include in includes : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> log. debug ( ""include `%s' (matches `%s')"", path, include ) <TAB> <TAB> <TAB> <TAB> except ( NameError, AttributeError ) : <TAB> <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> else : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> log. debug ( ""exclude `%s' (matches no includes)"", path ) <TAB> <TAB> <TAB> except ( NameError, AttributeError ) : <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> return False <TAB> for exclude in excludes : <TAB> <TAB> if fnmatch ( base, exclude ) : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> log. debug ( ""exclude `%s' (matches `%s')"", path, exclude ) <TAB> <TAB> <TAB> except ( NameError, AttributeError ) : <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> return False <TAB> return True",True,"fnmatch(base, include)","fnmatch(base, include)",0.6508344411849976
|
||
|
3789,"def _try_make_reader ( self ) : <TAB> if self. reader : <TAB> <TAB> return <TAB> if not self. data_file : <TAB> <TAB> files = glob ( self. _data_file_pattern ) <TAB> <TAB> if not files : <TAB> <TAB> <TAB> return <TAB> <TAB> files. sort ( ) <TAB> <TAB> self. log. debug ( ""Files found by pattern: %s"", files ) <TAB> <TAB> if not os. path. getsize ( files [ - 1 ] ) : <TAB> <TAB> <TAB> return <TAB> <TAB> self. data_file = files [ - 1 ] <TAB> self. data_file = self. engine. find_file ( self. data_file ) <TAB> if not os. path. exists ( self. data_file ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. log. debug ( ""File not exists yet: %s"", self. data_file ) <TAB> <TAB> <TAB> return <TAB> <TAB> else : <TAB> <TAB> <TAB> msg = ""File has not appeared within %ss: %s"" % ( <TAB> <TAB> <TAB> <TAB> self. _file_exists_wait, <TAB> <TAB> <TAB> <TAB> self. data_file, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> raise TaurusInternalException ( msg ) <TAB> self. log. info ( ""Will load external results from file: %s"", self. data_file ) <TAB> self. label = self. data_file <TAB> self. reader = self. _get_reader ( ) <TAB> if isinstance ( self. engine. aggregator, ConsolidatingAggregator ) : <TAB> <TAB> self. engine. aggregator. add_underling ( self. reader ) <TAB> <TAB> self. engine. aggregator. add_listener ( self )",False,time.time() - self._file_check_ts < self._file_exists_wait,os.path.exists(self.data_file),0.6542251110076904
|
||
|
3790,"def check_package ( self, package, package_dir ) : <TAB> """"""Check namespace packages' __init__ for declare_namespace"""""" <TAB> try : <TAB> <TAB> return self. packages_checked [ package ] <TAB> except KeyError : <TAB> <TAB> pass <TAB> init_py = _build_py. check_package ( self, package, package_dir ) <TAB> self. packages_checked [ package ] = init_py <TAB> if not init_py or not self. distribution. namespace_packages : <TAB> <TAB> return init_py <TAB> for pkg in self. distribution. namespace_packages : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> break <TAB> else : <TAB> <TAB> return init_py <TAB> f = open ( init_py, ""rU"" ) <TAB> if ""declare_namespace"" not in f. read ( ) : <TAB> <TAB> from distutils import log <TAB> <TAB> log. warn ( <TAB> <TAB> <TAB> ""WARNING: %s is a namespace package, but its __init__.py does\n"" <TAB> <TAB> <TAB> ""not declare_namespace(); setuptools 0.7 will REQUIRE this!\n"" <TAB> <TAB> <TAB> '(See the setuptools manual under ""Namespace Packages"" for'<TAB> <TAB> <TAB> ""details.)\n"", <TAB> <TAB> <TAB> package, <TAB> <TAB> ) <TAB> f. close ( ) <TAB> return init_py",False,pkg == package or pkg.startswith(package + '.'),pkg in self.packages_checked,0.6520081162452698
|
||
|
3791,"def test_invalid_mountinfo ( self ) : <TAB> line = ( <TAB> <TAB> ""20 1 252:1 / / rw,relatime - ext4 /dev/mapper/vg0-root"" <TAB> <TAB> ""rw,errors=remount-ro,data=ordered"" <TAB> ) <TAB> elements = line. split ( ) <TAB> for i in range ( len ( elements ) + 1 ) : <TAB> <TAB> lines = [ "" "". join ( elements [ 0 : i ] ) ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> expected = None <TAB> <TAB> else : <TAB> <TAB> <TAB> expected = ( ""/dev/mapper/vg0-root"", ""ext4"", ""/"" ) <TAB> <TAB> self. assertEqual ( expected, util. parse_mount_info ( ""/"", lines ) )",False,i < 10,has_mountinfo(),0.6805335283279419
|
||
|
3792,"def get_cluster_config ( cluster = None ) : <TAB> if cluster and cluster. get ( ""connector"" ) : <TAB> <TAB> cluster_config = cluster <TAB> elif cluster and cluster. get ( ""id"" )!= CLUSTER_ID. get ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> compute_end_point = ( <TAB> <TAB> <TAB> <TAB> cluster [ ""compute_end_point"" ] [ 0 ] <TAB> <TAB> <TAB> <TAB> if type ( cluster [ ""compute_end_point"" ] ) == list <TAB> <TAB> <TAB> <TAB> else cluster [ ""compute_end_point"" ] <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> cluster_config = { <TAB> <TAB> <TAB> <TAB> ""server_host"" : compute_end_point, <TAB> <TAB> <TAB> <TAB> ""name"" : cluster [ ""name"" ], <TAB> <TAB> <TAB> } <TAB> <TAB> else : <TAB> <TAB> <TAB> cluster_config = Cluster ( user = None ). get_config ( <TAB> <TAB> <TAB> <TAB> cluster [ ""id"" ] <TAB> <TAB> <TAB> ) <TAB> else : <TAB> <TAB> cluster_config = None <TAB> return cluster_config",False,'altus:dataware:k8s' in cluster['id'],cluster and cluster['compute_end_point'],0.6575764417648315
|
||
|
3793,"def it_should_undrain_and_drain ( context, num_undrain_expected, num_drain_expected ) : <TAB> num_undrain_expected = int ( num_undrain_expected ) <TAB> num_drain_expected = int ( num_drain_expected ) <TAB> for _ in range ( 10 ) : <TAB> <TAB> print ( ""currently drained: %r"" % drain_lib. TestDrainMethod. downed_task_ids ) <TAB> <TAB> print ( ""drained previously: %r"" % context. drained_tasks ) <TAB> <TAB> num_drained = len ( <TAB> <TAB> <TAB> drain_lib. TestDrainMethod. downed_task_ids - context. drained_tasks <TAB> <TAB> ) <TAB> <TAB> num_undrained = len ( <TAB> <TAB> <TAB> context. drained_tasks - drain_lib. TestDrainMethod. downed_task_ids <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return <TAB> <TAB> time. sleep ( 1 ) <TAB> else : <TAB> <TAB> raise Exception ( <TAB> <TAB> <TAB> ""Expected %d tasks to drain and %d to undrain, saw %d and %d"" <TAB> <TAB> <TAB> % ( num_drain_expected, num_undrain_expected, num_drained, num_undrained ) <TAB> <TAB> )",False,num_drained >= num_drain_expected and num_undrained >= num_undrain_expected,num_undrained == 0,0.6489992737770081
|
||
|
3794,"def require_access_to_dropdown_queries ( user, query_def ) : <TAB> parameters = query_def. get ( ""options"", { } ). get ( ""parameters"", [ ] ) <TAB> dropdown_query_ids = set ( <TAB> <TAB> [ str ( p [ ""queryId"" ] ) for p in parameters if p [ ""type"" ] == ""query"" ] <TAB> ) <TAB> if dropdown_query_ids : <TAB> <TAB> groups = models. Query. all_groups_for_query_ids ( dropdown_query_ids ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> abort ( <TAB> <TAB> <TAB> <TAB> 400, <TAB> <TAB> <TAB> <TAB> message = ""You are trying to associate a dropdown query that does not have a matching group. "" <TAB> <TAB> <TAB> <TAB> ""Please verify the dropdown query id you are trying to associate with this query."", <TAB> <TAB> <TAB> ) <TAB> <TAB> require_access ( dict ( groups ), user, view_only )",False,len(groups) < len(dropdown_query_ids),groups and len(groups) > 0,0.6494700908660889
|
||
|
3795,"def _yield_accessible_unix_file_names ( path ) : <TAB> """"""yield file names of executable files in path."""""" <TAB> if not os. path. exists ( path ) : <TAB> <TAB> return <TAB> for file_ in scandir ( path ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> yield file_. name <TAB> <TAB> except OSError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> pass",False,"file_.is_file() and os.access(file_.path, os.X_OK)",os.path.exists(file_),0.6489675045013428
|
||
|
3796,"def _find_ttinfo ( self, dt, laststd = 0 ) : <TAB> timestamp = ( <TAB> <TAB> ( dt. toordinal ( ) - EPOCHORDINAL ) * 86400 <TAB> <TAB> + dt. hour * 3600 <TAB> <TAB> + dt. minute * 60 <TAB> <TAB> + dt. second <TAB> ) <TAB> idx = 0 <TAB> for trans in self. _trans_list : <TAB> <TAB> if timestamp < trans : <TAB> <TAB> <TAB> break <TAB> <TAB> idx += 1 <TAB> else : <TAB> <TAB> return self. _ttinfo_std <TAB> if idx == 0 : <TAB> <TAB> return self. _ttinfo_before <TAB> if laststd : <TAB> <TAB> while idx > 0 : <TAB> <TAB> <TAB> tti = self. _trans_idx [ idx - 1 ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return tti <TAB> <TAB> <TAB> idx -= 1 <TAB> <TAB> else : <TAB> <TAB> <TAB> return self. _ttinfo_std <TAB> else : <TAB> <TAB> return self. _trans_idx [ idx - 1 ]",False,not tti.isdst,tti > 0,0.6638116836547852
|
||
|
3797,"def __call__ ( self, path = ""."" ) : <TAB> l = os. listdir ( path ) <TAB> l. sort ( ) <TAB> for f in l : <TAB> <TAB> st = os. stat ( ""%s/%s"" % ( path, f ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> print ( "" <dir> %s"" % f ) <TAB> <TAB> else : <TAB> <TAB> <TAB> print ( ""% 8d %s"" % ( st [ 6 ], f ) )",False,st[0] & 16384,st[6] == 6,0.6641519069671631
|
||
|
3798,"def _pyro_sample ( self, msg ) : <TAB> is_collapsible = getattr ( msg [ ""fn"" ], ""collapsible"", False ) <TAB> <TAB> if is_collapsible : <TAB> <TAB> conj_node, parent = None, None <TAB> <TAB> for site_name in self. trace. observation_nodes + self. trace. stochastic_nodes : <TAB> <TAB> <TAB> parent = getattr ( self. trace. nodes [ site_name ] [ ""fn"" ], ""parent"", None ) <TAB> <TAB> <TAB> if parent is not None and parent. _latent. site_name == msg [ ""name"" ] : <TAB> <TAB> <TAB> <TAB> conj_node = self. trace. nodes [ site_name ] <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> assert ( <TAB> <TAB> <TAB> conj_node is not None <TAB> <TAB> ), ""Collapsible latent site `{}` with no corresponding conjugate site."". format ( <TAB> <TAB> <TAB> msg [ ""name"" ] <TAB> <TAB> ) <TAB> <TAB> msg [ ""fn"" ] = parent. posterior ( conj_node [ ""value"" ] ) <TAB> <TAB> msg [ ""value"" ] = msg [ ""fn"" ]. sample ( ) <TAB> <TAB> else : <TAB> <TAB> name = msg [ ""name"" ] <TAB> <TAB> if name in self. trace : <TAB> <TAB> <TAB> guide_msg = self. trace. nodes [ name ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return None <TAB> <TAB> <TAB> if guide_msg [ ""type"" ]!= ""sample"" : <TAB> <TAB> <TAB> <TAB> raise RuntimeError ( ""site {} must be sample in trace"". format ( name ) ) <TAB> <TAB> <TAB> msg [ ""done"" ] = True <TAB> <TAB> <TAB> msg [ ""value"" ] = guide_msg [ ""value"" ] <TAB> <TAB> <TAB> msg [ ""infer"" ]",False,msg['is_observed'],guide_msg is None,0.6555825471878052
|
||
|
3799,"def authdebug_view ( context, request ) : <TAB> view_name = getattr ( request, ""view_name"", None ) <TAB> if authn_policy and authz_policy : <TAB> <TAB> if permission is NO_PERMISSION_REQUIRED : <TAB> <TAB> <TAB> msg = ""Allowed (NO_PERMISSION_REQUIRED)"" <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> msg = ""Allowed (no permission registered)"" <TAB> <TAB> else : <TAB> <TAB> <TAB> principals = authn_policy. effective_principals ( request ) <TAB> <TAB> <TAB> msg = str ( authz_policy. permits ( context, principals, permission ) ) <TAB> else : <TAB> <TAB> msg = ""Allowed (no authorization policy in use)"" <TAB> view_name = getattr ( request, ""view_name"", None ) <TAB> url = getattr ( request, ""url"", None ) <TAB> msg = ""debug_authorization of url %s (view name %r against "" ""context %r): %s"" % ( <TAB> <TAB> url, <TAB> <TAB> view_name, <TAB> <TAB> context, <TAB> <TAB> msg, <TAB> ) <TAB> if logger : <TAB> <TAB> logger. debug ( msg ) <TAB> if request is not None : <TAB> <TAB> request. authdebug_message = msg <TAB> return view ( context, request )",True,permission is None,permission is None,0.6677500009536743
|
||
|
3800,"def __setitem__ ( self, ndx, val ) : <TAB> <TAB> <TAB> <TAB> exprdata = None <TAB> if ndx in self. _data : <TAB> <TAB> exprdata = self. _data [ ndx ] <TAB> else : <TAB> <TAB> _ndx = normalize_index ( ndx ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> exprdata = self. _data [ _ndx ] <TAB> if exprdata is None : <TAB> <TAB> raise KeyError ( <TAB> <TAB> <TAB> ""Cannot set the value of Expression '%s' with "" <TAB> <TAB> <TAB> ""invalid index '%s'"" % ( self. cname ( True ), str ( ndx ) ) <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> exprdata. set_value ( val )",True,_ndx in self._data,_ndx in self._data,0.6684638261795044
|
||
|
3801,"def _validate_cors_for_route ( route_url, route_methods ) : <TAB> <TAB> entries_with_cors = [ entry for entry in route_methods. values ( ) if entry. cors ] <TAB> if entries_with_cors : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""Route entry cannot have both cors=True and "" <TAB> <TAB> <TAB> <TAB> ""methods=['OPTIONS',...] configured. When "" <TAB> <TAB> <TAB> <TAB> ""CORS is enabled, an OPTIONS method is automatically "" <TAB> <TAB> <TAB> <TAB> ""added for you. Please remove 'OPTIONS' from the list of "" <TAB> <TAB> <TAB> <TAB> ""configured HTTP methods for: %s"" % route_url <TAB> <TAB> <TAB> ) <TAB> <TAB> if not all ( <TAB> <TAB> <TAB> entries_with_cors [ 0 ]. cors == entry. cors for entry in entries_with_cors <TAB> <TAB> ) : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""Route may not have multiple differing CORS configurations. "" <TAB> <TAB> <TAB> <TAB> 'Please ensure all views for ""%s"" that have CORS configured'<TAB> <TAB> <TAB> <TAB> ""have the same CORS configuration."" % route_url <TAB> <TAB> <TAB> )",False,'OPTIONS' in route_methods,route_url.startswith('http') and (not route.methods),0.6583787202835083
|
||
|
3802,"def func_std_string ( func_name ) : <TAB> if func_name [ : 2 ] == ( ""~"", 0 ) : <TAB> <TAB> <TAB> <TAB> name = func_name [ 2 ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return ""{%s}"" % name [ 1 : - 1 ] <TAB> <TAB> else : <TAB> <TAB> <TAB> return name <TAB> else : <TAB> <TAB> return ""%s:%d(%s)"" % func_name",False,name.startswith('<') and name.endswith('>'),"name[0] == (StringType, 0) and name[1:-1] == (StringType, 0)",0.6496857404708862
|
||
|
3803,"def del_ ( self, key ) : <TAB> initial_hash = hash_ = self. hash ( key ) <TAB> while True : <TAB> <TAB> if self. _keys [ hash_ ] is self. _empty : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return None <TAB> <TAB> elif self. _keys [ hash_ ] == key : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _keys [ hash_ ] = self. _deleted <TAB> <TAB> <TAB> self. _values [ hash_ ] = self. _deleted <TAB> <TAB> <TAB> self. _len -= 1 <TAB> <TAB> <TAB> return <TAB> <TAB> hash_ = self. _rehash ( hash_ ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return None",False,initial_hash == hash_,hash_ == initial_hash,0.6572629809379578
|
||
|
3804,"def parse ( self, date_string, parse_method, settings = None ) : <TAB> date_string = str ( date_string ) <TAB> if not date_string. strip ( ) : <TAB> <TAB> raise ValueError ( ""Empty string"" ) <TAB> date_string = strip_braces ( date_string ) <TAB> date_string, ptz = pop_tz_offset_from_string ( date_string ) <TAB> date_obj, period = parse_method ( date_string, settings = settings ) <TAB> _settings_tz = settings. TIMEZONE. lower ( ) <TAB> if ptz : <TAB> <TAB> if hasattr ( ptz, ""localize"" ) : <TAB> <TAB> <TAB> date_obj = ptz. localize ( date_obj ) <TAB> <TAB> else : <TAB> <TAB> <TAB> date_obj = date_obj. replace ( tzinfo = ptz ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> date_obj = apply_timezone ( date_obj, settings. TIMEZONE ) <TAB> else : <TAB> <TAB> if ""local"" in _settings_tz : <TAB> <TAB> <TAB> stz = get_localzone ( ) <TAB> <TAB> <TAB> if hasattr ( stz, ""localize"" ) : <TAB> <TAB> <TAB> <TAB> date_obj = stz. localize ( date_obj ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> date_obj = date_obj. replace ( tzinfo = stz ) <TAB> <TAB> else : <TAB> <TAB> <TAB> date_obj = localize_timezone ( date_obj, settings. TIMEZONE ) <TAB> if settings. TO_TIMEZONE : <TAB> <TAB> date_obj = apply_timezone ( date_obj, settings. TO_TIMEZONE ) <TAB> if not settings. RETURN_AS_TIMEZONE_AWARE or ( <TAB> <TAB> settings. RETURN_AS_TIMEZONE_AWARE <TAB> <TAB> and ""default"" == settings. RETURN_AS_TIMEZONE_AWARE <TAB> <TAB> and not ptz <",False,'local' not in _settings_tz,settings.TIMEZONE,0.6483238935470581
|
||
|
3805,"def close ( self ) : <TAB> """"""Close the session. This will release any borrowed resources, such as connections, and will roll back any outstanding transactions."""""" <TAB> if self. _connection : <TAB> <TAB> if self. _autoResult : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> self. _autoResult. consume ( ) <TAB> <TAB> <TAB> <TAB> <TAB> self. _collect_bookmark ( self. _autoResult. _bookmark ) <TAB> <TAB> <TAB> <TAB> except Exception as error : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _autoResult = None <TAB> <TAB> <TAB> <TAB> <TAB> self. _state_failed = True <TAB> <TAB> if self. _transaction : <TAB> <TAB> <TAB> if self. _transaction. closed ( ) is False : <TAB> <TAB> <TAB> <TAB> self. _transaction. rollback ( ) <TAB> <TAB> <TAB> self. _transaction = None <TAB> <TAB> try : <TAB> <TAB> <TAB> if self. _connection : <TAB> <TAB> <TAB> <TAB> self. _connection. send_all ( ) <TAB> <TAB> <TAB> <TAB> self. _connection. fetch_all ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> except Neo4jError : <TAB> <TAB> <TAB> pass <TAB> <TAB> except TransactionError : <TAB> <TAB> <TAB> pass <TAB> <TAB> except ServiceUnavailable : <TAB> <TAB> <TAB> pass <TAB> <TAB> except SessionExpired : <TAB> <TAB> <TAB> pass <TAB> <TAB> finally : <TAB> <TAB> <TAB> self. _disconnect ( ) <TAB> <TAB> self. _state_failed = False <TAB> <TAB> self. _closed = True",False,self._state_failed is False,self._bookmark,0.6607035994529724
|
||
|
3806,"def display ( self, custom_tz = None, utc_shift = None ) : <TAB> try : <TAB> <TAB> arw = self. as_arrow ( ) <TAB> <TAB> if custom_tz : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> arw = arw. to ( custom_tz ) <TAB> <TAB> <TAB> except RuntimeError : <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> elif utc_shift is not None : <TAB> <TAB> <TAB> arw = arw. to ( ShiftedTimezone ( int ( utc_shift ) ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> arw = arw. to ( self. obj_session. GetParameter ( ""timezone"", ""UTC"" ) ) <TAB> <TAB> <TAB> <TAB> formatted_date = arw. format ( self. timeformat ) <TAB> <TAB> formatted_tz = arw. format ( ""Z"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> formatted_tz = ""Z"" <TAB> <TAB> return formatted_date + formatted_tz <TAB> except ValueError as e : <TAB> <TAB> return obj. NoneObject ( ""Error: %s"", e )",False,"formatted_tz in ('-0000', '+0000')",formatted_date and formatted_tz,0.6527063846588135
|
||
|
3807,"def create_primary_collection_for_provider ( sender, instance, created, ** kwargs ) : <TAB> if created : <TAB> <TAB> Collection = apps. get_model ( ""osf.Collection"" ) <TAB> <TAB> user = getattr ( instance, ""_creator"", None ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> c = Collection ( <TAB> <TAB> <TAB> <TAB> title = ""{}'s Collection"". format ( instance. name ), <TAB> <TAB> <TAB> <TAB> creator = user, <TAB> <TAB> <TAB> <TAB> provider = instance, <TAB> <TAB> <TAB> <TAB> is_promoted = True, <TAB> <TAB> <TAB> <TAB> is_public = True, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> c. save ( ) <TAB> <TAB> <TAB> instance. primary_collection = c <TAB> <TAB> <TAB> instance. save ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> sentry. log_message ( <TAB> <TAB> <TAB> <TAB> ""Unable to create primary_collection for {}Provider {}"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> instance. readable_type. capitalize ( ), instance. name <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> )",True,user,user,0.6853420734405518
|
||
|
3808,"def __init__ ( <TAB> self, <TAB> url, <TAB> version = None, <TAB> data = None, <TAB> full_response = False, <TAB> http = None, <TAB> timeout = None, <TAB> sync = False, <TAB> loop = None, <TAB> encoding = ""ascii"", <TAB> ** kw ) : <TAB> self. sync = sync <TAB> self. _url = url <TAB> self. _version = version or self. __class__. default_version <TAB> self. _full_response = full_response <TAB> self. _data = data if data is not None else { } <TAB> if not http : <TAB> <TAB> timeout = timeout if timeout is not None else self. default_timeout <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> loop = new_event_loop ( ) <TAB> <TAB> http = HttpClient ( timeout = timeout, loop = loop, ** kw ) <TAB> http. headers [ ""accept"" ] = ""application/json, text/*; q=0.5"" <TAB> http. headers [ ""content-type"" ] = ""application/json"" <TAB> self. _http = http <TAB> self. _encoding = encoding",False,sync and (not loop),not loop,0.6537997722625732
|
||
|
3809,"def handle_addl_headers ( self, headers ) : <TAB> for key, value in headers : <TAB> <TAB> if key == ""x-goog-hash"" : <TAB> <TAB> <TAB> for hash_pair in value. split ( "","" ) : <TAB> <TAB> <TAB> <TAB> alg, b64_digest = hash_pair. strip ( ). split ( ""="", 1 ) <TAB> <TAB> <TAB> <TAB> self. cloud_hashes [ alg ] = binascii. a2b_base64 ( b64_digest ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> self. component_count = int ( value ) <TAB> <TAB> elif key == ""x-goog-generation"" : <TAB> <TAB> <TAB> self. generation = value <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> elif key == ""x-goog-stored-content-encoding"" : <TAB> <TAB> <TAB> self. content_encoding = value <TAB> <TAB> elif key == ""x-goog-stored-content-length"" : <TAB> <TAB> <TAB> self. size = int ( value ) <TAB> <TAB> elif key == ""x-goog-storage-class"" : <TAB> <TAB> <TAB> self. storage_class = value",True,key == 'x-goog-component-count',key == 'x-goog-component-count',0.6445107460021973
|
||
|
3810,"def test_commit_msg_hook_fail ( self, rw_repo ) : <TAB> index = rw_repo. index <TAB> hp = _make_hook ( <TAB> <TAB> index. repo. git_dir, ""commit-msg"", ""echo stdout; echo stderr 1>&2; exit 1"" <TAB> ) <TAB> try : <TAB> <TAB> index. commit ( ""This should fail"" ) <TAB> except HookExecutionError as err : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. assertIsInstance ( err. status, OSError ) <TAB> <TAB> <TAB> self. assertEqual ( err. command, [ hp ] ) <TAB> <TAB> <TAB> self. assertEqual ( err. stdout, """" ) <TAB> <TAB> <TAB> self. assertEqual ( err. stderr, """" ) <TAB> <TAB> <TAB> assert str ( err ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. assertEqual ( err. status, 1 ) <TAB> <TAB> <TAB> self. assertEqual ( err. command, [ hp ] ) <TAB> <TAB> <TAB> self. assertEqual ( err. stdout, ""\n stdout:'stdout\n'"" ) <TAB> <TAB> <TAB> self. assertEqual ( err. stderr, ""\n stderr:'stderr\n'"" ) <TAB> <TAB> <TAB> assert str ( err ) <TAB> else : <TAB> <TAB> raise AssertionError ( ""Should have cought a HookExecutionError"" )",False,is_win,"hasattr(err, 'status')",0.663103461265564
|
||
|
3811,"def _reset ( self ) : <TAB> self. _handle_connect ( ) <TAB> if self. rewarder_session : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> env_id = random. choice ( self. _sample_env_ids ) <TAB> <TAB> <TAB> logger. info ( ""Randomly sampled env_id={}"". format ( env_id ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> env_id = None <TAB> <TAB> self. rewarder_session. reset ( env_id = env_id ) <TAB> else : <TAB> <TAB> logger. info ( <TAB> <TAB> <TAB> ""No rewarder session exists, so cannot send a reset via the rewarder channel"" <TAB> <TAB> ) <TAB> self. _reset_mask ( ) <TAB> return [ None ] * self. n",False,self._sample_env_ids,len(self._sample_env_ids) > 0,0.6583123207092285
|
||
|
3812,def __next__ ( self ) : <TAB> try : <TAB> <TAB> data = next ( self. iter_loader ) <TAB> except StopIteration : <TAB> <TAB> self. _epoch += 1 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _dataloader. sampler. set_epoch ( self. _epoch ) <TAB> <TAB> self. iter_loader = iter ( self. _dataloader ) <TAB> <TAB> data = next ( self. iter_loader ) <TAB> return data,False,"hasattr(self._dataloader.sampler, 'set_epoch')","hasattr(self, '_dataloader')",0.6535096168518066
|
||
|
3813,"def unicode_argv ( ) : <TAB> if iswindows : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> from ctypes import POINTER, byref, cdll, c_int, windll <TAB> <TAB> from ctypes. wintypes import LPCWSTR, LPWSTR <TAB> <TAB> GetCommandLineW = cdll. kernel32. GetCommandLineW <TAB> <TAB> GetCommandLineW. argtypes = [ ] <TAB> <TAB> GetCommandLineW. restype = LPCWSTR <TAB> <TAB> CommandLineToArgvW = windll. shell32. CommandLineToArgvW <TAB> <TAB> CommandLineToArgvW. argtypes = [ LPCWSTR, POINTER ( c_int ) ] <TAB> <TAB> CommandLineToArgvW. restype = POINTER ( LPWSTR ) <TAB> <TAB> cmd = GetCommandLineW ( ) <TAB> <TAB> argc = c_int ( 0 ) <TAB> <TAB> argv = CommandLineToArgvW ( cmd, byref ( argc ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> start = argc. value - len ( sys. argv ) <TAB> <TAB> <TAB> return [ argv [ i ] for i in range ( start, argc. value ) ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return [ ""ignoblekeyfetch.py"" ] <TAB> else : <TAB> <TAB> argvencoding = sys. stdin. encoding or ""utf-8"" <TAB> <TAB> return [ <TAB> <TAB> <TAB> arg if isinstance ( arg, str ) else str ( arg, argvencoding ) for arg in sys. argv <TAB> <TAB> ]",False,argc.value > 0,"hasattr(argc, 'value')",0.6623032689094543
|
||
|
3814,"def plugins_end_test ( self, retcode ) : <TAB> """"""Call end_test() on all plugins"""""" <TAB> logger. info ( ""Finishing test..."" ) <TAB> self. publish ( ""core"", ""stage"", ""end"" ) <TAB> self. publish ( ""generator"", ""test_end"", time. time ( ) ) <TAB> logger. info ( ""Stopping load generator and aggregator"" ) <TAB> retcode = self. job. aggregator. end_test ( retcode ) <TAB> logger. debug ( ""RC after: %s"", retcode ) <TAB> logger. info ( ""Stopping monitoring"" ) <TAB> for plugin in self. job. monitoring_plugins : <TAB> <TAB> logger. info ( ""Stopping %s"", plugin ) <TAB> <TAB> retcode = plugin. end_test ( retcode ) or retcode <TAB> <TAB> logger. info ( ""RC after: %s"", retcode ) <TAB> for plugin in [ <TAB> <TAB> p <TAB> <TAB> for p in self. plugins. values ( ) <TAB> <TAB> if p is not self. job. generator_plugin and p not in self. job. monitoring_plugins <TAB> ] : <TAB> <TAB> logger. debug ( ""Finalize %s"", plugin ) <TAB> <TAB> try : <TAB> <TAB> <TAB> logger. debug ( ""RC before: %s"", retcode ) <TAB> <TAB> <TAB> retcode = plugin. end_test ( retcode ) <TAB> <TAB> <TAB> logger. debug ( ""RC after: %s"", retcode ) <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> logger. error ( ""Failed finishing plugin %s"", plugin, exc_info = True ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> retcode = 1 <TAB> return retcode",False,not retcode,retcode == 0,0.6817899942398071
|
||
|
3815,"def _verify_endpoint_tests_conf ( endpoint_tests ) : <TAB> for t in endpoint_tests : <TAB> <TAB> _check_all_keys_are_present_in_dict ( t, [ ""tests"", ""type"" ] ) <TAB> <TAB> _verify_type_specification ( t [ ""type"" ] ) <TAB> <TAB> assert 0 < len ( t [ ""tests"" ]. keys ( ) ) < 8 <TAB> <TAB> if ""is_endpoint_redirecting_properly"" in t [ ""tests"" ] : <TAB> <TAB> <TAB> _verify_is_endpoint_redirecting_properly ( <TAB> <TAB> <TAB> <TAB> t [ ""tests"" ] [ ""is_endpoint_redirecting_properly"" ] <TAB> <TAB> <TAB> ) <TAB> <TAB> if ""is_location_header_rewritten"" in t [ ""tests"" ] : <TAB> <TAB> <TAB> _verify_is_location_header_rewritten ( <TAB> <TAB> <TAB> <TAB> t [ ""tests"" ] [ ""is_location_header_rewritten"" ] <TAB> <TAB> <TAB> ) <TAB> <TAB> if ""is_upstream_correct"" in t [ ""tests"" ] : <TAB> <TAB> <TAB> _verify_is_upstream_correct_test_conf ( t [ ""tests"" ] [ ""is_upstream_correct"" ] ) <TAB> <TAB> if ""is_upstream_req_ok"" in t [ ""tests"" ] : <TAB> <TAB> <TAB> _verify_is_upstream_req_ok_test_conf ( t [ ""tests"" ] [ ""is_upstream_req_ok"" ] ) <TAB> <TAB> if ""are_upstream_req_headers_ok"" in t [ ""tests"" ] : <TAB> <TAB> <TAB> _verify_are_upstream_req_headers_ok ( <TAB> <TAB> <TAB> <TAB> t [ ""tests"" ] [ ""are_upstream_req_headers_ok"" ] <TAB> <TAB> <TAB> ) <TAB> <TAB> if ""is_response_",False,'is_unauthed_access_permitted' in t['tests'],'is_response_' is False,0.6493114233016968
|
||
|
3816,"def import_modules ( directory, include = None, exclude = None ) : <TAB> base_name = os. path. relpath ( directory, shared_dir ). replace ( os. path. sep, ""."" ) <TAB> log. debug ( ""Importing modules from: %s"", base_name ) <TAB> for name in os. listdir ( directory ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> if exclude and name in exclude : <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> path = os. path. join ( directory, name ) <TAB> <TAB> <TAB> <TAB> if not is_module ( path, name ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> if not import_module ( path, base_name, name ) : <TAB> <TAB> <TAB> log. warn ( ""Unable to import module: %r"", name )",True,include and name not in include,include and name not in include,0.6586755514144897
|
||
|
3817,"def get_v2_image_tags ( self, imagerepo, tags_only = False ) : <TAB> """"""Get list of tags in a repo from Docker Hub"""""" <TAB> if ""/"" not in imagerepo : <TAB> <TAB> imagerepo = ""library/"" + imagerepo <TAB> url = self. registry_url + ""/v2/"" + imagerepo + ""/tags/list"" <TAB> Msg ( ). err ( ""tags url:"", url, l = Msg. DBG ) <TAB> ( dummy, buf ) = self. _get_url ( url ) <TAB> tags = [ ] <TAB> try : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> for tag in json. loads ( buf. getvalue ( ) ) [ ""tags"" ] : <TAB> <TAB> <TAB> <TAB> tags. append ( tag ) <TAB> <TAB> <TAB> return tags <TAB> <TAB> else : <TAB> <TAB> <TAB> return json. loads ( buf. getvalue ( ) ) <TAB> except ( IOError, OSError, AttributeError, ValueError, TypeError ) : <TAB> <TAB> return [ ]",True,tags_only,tags_only,0.663990318775177
|
||
|
3818,"def determine_encoding ( self ) : <TAB> while not self. eof and len ( self. raw_buffer ) < 2 : <TAB> <TAB> self. update_raw ( ) <TAB> if not isinstance ( self. raw_buffer, unicode ) : <TAB> <TAB> if self. raw_buffer. startswith ( codecs. BOM_UTF16_LE ) : <TAB> <TAB> <TAB> self. raw_decode = codecs. utf_16_le_decode <TAB> <TAB> <TAB> self. encoding = ""utf-16-le"" <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> self. raw_decode = codecs. utf_16_be_decode <TAB> <TAB> <TAB> self. encoding = ""utf-16-be"" <TAB> <TAB> else : <TAB> <TAB> <TAB> self. raw_decode = codecs. utf_8_decode <TAB> <TAB> <TAB> self. encoding = ""utf-8"" <TAB> self. update ( 1 )",True,self.raw_buffer.startswith(codecs.BOM_UTF16_BE),self.raw_buffer.startswith(codecs.BOM_UTF16_BE),0.6479853391647339
|
||
|
3819,"def main ( self ) : <TAB> self. clear_text ( ) <TAB> active_handle = self. get_active ( ""Place"" ) <TAB> if active_handle : <TAB> <TAB> active = self. dbstate. db. get_place_from_handle ( active_handle ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. get_notes ( active ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. set_has_data ( False ) <TAB> else : <TAB> <TAB> self. set_has_data ( False )",True,active,active,0.690086841583252
|
||
|
3820,"def handle ( type ) : <TAB> callback_field = ""_{}_callback"". format ( type ) <TAB> code_string = getattr ( self. _args, type + ""_callback"" ) <TAB> if code_string : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise SystemExit ( <TAB> <TAB> <TAB> <TAB> _ ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Error: Cannot pass a %s_callback to RepoFilter "" <TAB> <TAB> <TAB> <TAB> <TAB> ""AND pass --%s-callback"" % ( type, type ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> if ""return "" not in code_string and type not in ( <TAB> <TAB> <TAB> ""blob"", <TAB> <TAB> <TAB> ""commit"", <TAB> <TAB> <TAB> ""tag"", <TAB> <TAB> <TAB> ""reset"", <TAB> <TAB> ) : <TAB> <TAB> <TAB> raise SystemExit ( <TAB> <TAB> <TAB> <TAB> _ ( ""Error: --%s-callback should have a return statement"" ) % type <TAB> <TAB> <TAB> ) <TAB> <TAB> setattr ( self, callback_field, make_callback ( type, code_string ) )",False,"getattr(self, callback_field)",callback_field in self._args,0.6506005525588989
|
||
|
3821,"def list ( self, arg, opts ) : <TAB> counter = 0 <TAB> if ( len ( self. filters ) ) > 0 : <TAB> <TAB> self. protocol. sendData ( <TAB> <TAB> <TAB> ""#%s %s %s %s"" <TAB> <TAB> <TAB> % ( <TAB> <TAB> <TAB> <TAB> ""Filter id"". ljust ( 16 ), <TAB> <TAB> <TAB> <TAB> ""Type"". ljust ( 22 ), <TAB> <TAB> <TAB> <TAB> ""Routes"". ljust ( 6 ), <TAB> <TAB> <TAB> <TAB> ""Description"". ljust ( 32 ), <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> prompt = False, <TAB> <TAB> ) <TAB> <TAB> for fid, _filter in self. filters. items ( ) : <TAB> <TAB> <TAB> counter += 1 <TAB> <TAB> <TAB> routes = """" <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> routes += ""MO "" <TAB> <TAB> <TAB> if _filter. __class__. __name__ in MTFILTERS : <TAB> <TAB> <TAB> <TAB> routes += ""MT"" <TAB> <TAB> <TAB> self. protocol. sendData ( <TAB> <TAB> <TAB> <TAB> ""#%s %s %s %s"" <TAB> <TAB> <TAB> <TAB> % ( <TAB> <TAB> <TAB> <TAB> <TAB> str ( fid ). ljust ( 16 ), <TAB> <TAB> <TAB> <TAB> <TAB> str ( _filter. __class__. __name__ ). ljust ( 22 ), <TAB> <TAB> <TAB> <TAB> <TAB> routes. ljust ( 6 ), <TAB> <TAB> <TAB> <TAB> <TAB> repr ( _filter ). ljust ( 32 ), <TAB> <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> <TAB> prompt = False, <TAB> <TAB> <TAB> ) <TAB> <TAB>",False,_filter.__class__.__name__ in MOFILTERS,_filter.__class__.__name__ in PHMFILTERS,0.6573112607002258
|
||
|
3822,"def _get_extended_color ( numbers ) : <TAB> n = numbers. pop ( 0 ) <TAB> if n == 2 and len ( numbers ) >= 3 : <TAB> <TAB> <TAB> <TAB> r = numbers. pop ( 0 ) <TAB> <TAB> g = numbers. pop ( 0 ) <TAB> <TAB> b = numbers. pop ( 0 ) <TAB> <TAB> if not all ( 0 <= c <= 255 for c in ( r, g, b ) ) : <TAB> <TAB> <TAB> raise ValueError ( ) <TAB> elif n == 5 and len ( numbers ) >= 1 : <TAB> <TAB> <TAB> <TAB> idx = numbers. pop ( 0 ) <TAB> <TAB> if idx < 0 : <TAB> <TAB> <TAB> raise ValueError ( ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return idx <TAB> <TAB> elif idx < 232 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> r = ( idx - 16 ) // 36 <TAB> <TAB> <TAB> r = 55 + r * 40 if r > 0 else 0 <TAB> <TAB> <TAB> g = ( ( idx - 16 ) % 36 ) // 6 <TAB> <TAB> <TAB> g = 55 + g * 40 if g > 0 else 0 <TAB> <TAB> <TAB> b = ( idx - 16 ) % 6 <TAB> <TAB> <TAB> b = 55 + b * 40 if b > 0 else 0 <TAB> <TAB> elif idx < 256 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> r = g = b = ( idx - 232 ) * 10 + 8 <TAB> <TAB> else : <TAB> <TAB> <TAB> raise ValueError ( ) <TAB> else : <TAB> <TAB> raise ValueError ( ) <TAB> return r, g, b",True,idx < 16,idx < 16,0.6788617372512817
|
||
|
3823,"def parse_converter_args ( argstr : str ) -> t. Tuple [ t. Tuple, t. Dict [ str, t. Any ] ] : <TAB> argstr += "","" <TAB> args = [ ] <TAB> kwargs = { } <TAB> for item in _converter_args_re. finditer ( argstr ) : <TAB> <TAB> value = item. group ( ""stringval"" ) <TAB> <TAB> if value is None : <TAB> <TAB> <TAB> value = item. group ( ""value"" ) <TAB> <TAB> value = _pythonize ( value ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> args. append ( value ) <TAB> <TAB> else : <TAB> <TAB> <TAB> name = item. group ( ""name"" ) <TAB> <TAB> <TAB> kwargs [ name ] = value <TAB> return tuple ( args ), kwargs",False,not item.group('name'),value < <TAB > <TAB> <TAB> <TAB> <TAB> <TAB> <value,0.6553870439529419
|
||
|
3824,"def post_pass ( self, gnx2body, gnx2vnode, root_v ) : <TAB> """"""Set all body text."""""" <TAB> <TAB> if self. test : <TAB> <TAB> <TAB> <TAB> bkeys = sorted ( gnx2body. keys ( ) ) <TAB> <TAB> vkeys = sorted ( gnx2vnode. keys ( ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> g. trace ( ""KEYS MISMATCH"" ) <TAB> <TAB> <TAB> g. printObj ( bkeys ) <TAB> <TAB> <TAB> g. printObj ( vkeys ) <TAB> <TAB> <TAB> if self. test : <TAB> <TAB> <TAB> <TAB> sys. exit ( 1 ) <TAB> <TAB> <TAB> <TAB> for key in vkeys : <TAB> <TAB> <TAB> v = gnx2vnode. get ( key ) <TAB> <TAB> <TAB> body = gnx2body. get ( key ) <TAB> <TAB> <TAB> v. _bodyString = """". join ( body ) <TAB> else : <TAB> <TAB> assert root_v. gnx in gnx2vnode, root_v <TAB> <TAB> assert root_v. gnx in gnx2body, root_v <TAB> <TAB> <TAB> <TAB> for key in gnx2body : <TAB> <TAB> <TAB> body = gnx2body. get ( key ) <TAB> <TAB> <TAB> v = gnx2vnode. get ( key ) <TAB> <TAB> <TAB> assert v, ( key, v ) <TAB> <TAB> <TAB> v. _bodyString = g. toUnicode ( """". join ( body ) )",False,bkeys != vkeys,len(bkeys) > 0,0.6657154560089111
|
||
|
3825,"def iter_filters ( filters, block_end = False ) : <TAB> queue = deque ( filters ) <TAB> while queue : <TAB> <TAB> f = queue. popleft ( ) <TAB> <TAB> if f is not None and f. type in ( ""or"", ""and"", ""not"" ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> queue. appendleft ( None ) <TAB> <TAB> <TAB> for gf in f. filters : <TAB> <TAB> <TAB> <TAB> queue. appendleft ( gf ) <TAB> <TAB> yield f",True,block_end,block_end,0.6628148555755615
|
||
|
3826,"def writeLinks ( fp, skel, config ) : <TAB> if skel is None : <TAB> <TAB> return <TAB> ooLink ( fp, ""Model::%s"" % skel. name, ""Model::RootNode"", config ) <TAB> for bone in skel. getBones ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> parentName = bone. parent. name if bone. parent else None <TAB> <TAB> <TAB> ooLink ( fp, ""Model::%s"" % bone. name, ""Model::%s"" % parentName, config ) <TAB> <TAB> else : <TAB> <TAB> <TAB> ooLink ( fp, ""Model::%s"" % bone. name, ""Model::%s"" % skel. name, config ) <TAB> <TAB> ooLink ( fp, ""NodeAttribute::%s"" % bone. name, ""Model::%s"" % bone. name, config )",True,bone.parent,bone.parent,0.664536714553833
|
||
|
3827,"def process_element ( e ) : <TAB> if e. ref is not None : <TAB> <TAB> tn = e. ref <TAB> <TAB> name = e. ref. split ( "":"", 1 ) [ - 1 ] <TAB> elif e. name is not None : <TAB> <TAB> tn = e. type <TAB> <TAB> name = e. name <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. debug2 ( "" skipped: %s ur-type"", e. name ) <TAB> <TAB> <TAB> return <TAB> else : <TAB> <TAB> raise Exception ( ""dunno"" ) <TAB> process_type ( tn, name, element = e )",False,tn is None,tn == e.type,0.6808267831802368
|
||
|
3828,"def forwards ( self, orm ) : <TAB> ""Migrate the Users and Groups so they extend AccessEntity"" <TAB> for user in orm [ ""core.User"" ]. objects. all ( ) : <TAB> <TAB> entity = orm [ ""core.AccessEntity"" ]. objects. create ( ) <TAB> <TAB> entity. id = user. id <TAB> <TAB> entity. save ( ) <TAB> <TAB> user. accessentity_ptr = entity <TAB> <TAB> user. save ( ) <TAB> for group in orm [ ""core.Group"" ]. objects. all ( ) : <TAB> <TAB> group. accessentity_ptr = orm [ ""core.AccessEntity"" ]. objects. create ( ) <TAB> <TAB> group. accessentity_ptr. save ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> parent = orm [ ""core.Group"" ]. objects. get ( id = group. parent_id ) <TAB> <TAB> <TAB> group. parent_id = parent. accessentity_ptr_id <TAB> <TAB> group. save ( ) <TAB> for user in orm [ ""core.User"" ]. objects. all ( ) : <TAB> <TAB> group = orm [ ""core.Group"" ]. objects. get ( pk = user. default_group_id ) <TAB> <TAB> user. default_group = group. accessentity_ptr <TAB> <TAB> user. save ( ) <TAB> for obj in orm [ ""core.Object"" ]. objects. all ( ) : <TAB> <TAB> obj. creator = obj. user <TAB> <TAB> obj. save ( )",False,group.parent,self.parent_id,0.6618846654891968
|
||
|
3829,"def _real_extract ( self, url ) : <TAB> mobj = re. match ( self. _VALID_URL, url ) <TAB> track_id = mobj. group ( ""track_id"" ) <TAB> query = { } <TAB> if track_id : <TAB> <TAB> info_json_url = self. _API_V2_BASE + ""tracks/"" + track_id <TAB> <TAB> full_title = track_id <TAB> <TAB> token = mobj. group ( ""secret_token"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> query [ ""secret_token"" ] = token <TAB> else : <TAB> <TAB> full_title = resolve_title = ""%s/%s"" % mobj. group ( ""uploader"", ""title"" ) <TAB> <TAB> token = mobj. group ( ""token"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> resolve_title += ""/%s"" % token <TAB> <TAB> info_json_url = self. _resolv_url ( self. _BASE_URL + resolve_title ) <TAB> info = self. _download_json ( <TAB> <TAB> info_json_url, <TAB> <TAB> full_title, <TAB> <TAB> ""Downloading info JSON"", <TAB> <TAB> query = query, <TAB> <TAB> headers = self. _HEADERS, <TAB> ) <TAB> return self. _extract_info_dict ( info, full_title, token )",True,token,token,0.6830238699913025
|
||
|
3830,"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. STRING : <TAB> <TAB> <TAB> <TAB> self. message = iprot. readString ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif fid == 2 : <TAB> <TAB> <TAB> if ftype == TType. STRING : <TAB> <TAB> <TAB> <TAB> self. log_context = 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. handle = QueryHandle ( ) <TAB> <TAB> <TAB> <TAB> self. handle. read ( iprot ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif fid == 4 : <TAB> <TAB> <TAB> if ftype == TType. I32 : <TAB> <TAB> <TAB> <TAB> self. errorCode = iprot. readI32 ( ) <TAB> <TAB> <TAB",False,ftype == TType.STRUCT,fid == 4,0.6658495664596558
|
||
|
3831,"def test_chunkcoding ( self ) : <TAB> for native, utf8 in zip ( * [ StringIO ( f ). readlines ( ) for f in self. tstring ] ) : <TAB> <TAB> u = self. decode ( native ) [ 0 ] <TAB> <TAB> self. assertEqual ( u, utf8. decode ( ""utf-8"" ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. assertEqual ( native, self. encode ( u ) [ 0 ] )",False,self.roundtriptest,utf8.upper() == 'utf-8',0.6563947200775146
|
||
|
3832,"def walk_depth_first ( name ) : <TAB> stack = [ name ] <TAB> while stack : <TAB> <TAB> name = stack. pop ( ) <TAB> <TAB> if name in levels_by_name : <TAB> <TAB> <TAB> continue <TAB> <TAB> if name not in graph or not graph [ name ] : <TAB> <TAB> <TAB> level = 0 <TAB> <TAB> <TAB> add_level_to_name ( name, level ) <TAB> <TAB> <TAB> continue <TAB> <TAB> children = graph [ name ] <TAB> <TAB> children_not_calculated = [ <TAB> <TAB> <TAB> child for child in children if child not in levels_by_name <TAB> <TAB> ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> stack. append ( name ) <TAB> <TAB> <TAB> stack. extend ( children_not_calculated ) <TAB> <TAB> <TAB> continue <TAB> <TAB> level = 1 + max ( levels_by_name [ lname ] for lname in children ) <TAB> <TAB> add_level_to_name ( name, level )",True,children_not_calculated,children_not_calculated,0.6556819081306458
|
||
|
3833,"def added_variables ( self ) : <TAB> variables = set ( ) <TAB> for task in self. tasks_data : <TAB> <TAB> if ""tags"" not in task : <TAB> <TAB> <TAB> next <TAB> <TAB> if ""when"" not in task : <TAB> <TAB> <TAB> task [ ""when"" ] = [ ] <TAB> <TAB> elif isinstance ( task [ ""when"" ], str ) : <TAB> <TAB> <TAB> task [ ""when"" ] = [ task [ ""when"" ] ] <TAB> <TAB> variables_to_add = { <TAB> <TAB> <TAB> tag for tag in task [ ""tags"" ] if self. _tag_is_valid_variable ( tag ) <TAB> <TAB> } <TAB> <TAB> task [ ""when"" ] = [ <TAB> <TAB> <TAB> ""{varname} | bool"". format ( varname = v ) for v in variables_to_add <TAB> <TAB> ] + task [ ""when"" ] <TAB> <TAB> variables. update ( variables_to_add ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> del task [ ""when"" ] <TAB> return variables",False,not task['when'],'when' in task,0.6660057306289673
|
||
|
3834,"def get_selectable_values ( self, request ) : <TAB> shop = lfs. core. utils. get_default_shop ( request ) <TAB> countries = [ ] <TAB> for country in shop. shipping_countries. all ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> selected = True <TAB> <TAB> else : <TAB> <TAB> <TAB> selected = False <TAB> <TAB> countries. append ( <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> ""id"" : country. id, <TAB> <TAB> <TAB> <TAB> ""name"" : country. name, <TAB> <TAB> <TAB> <TAB> ""selected"" : selected, <TAB> <TAB> <TAB> } <TAB> <TAB> ) <TAB> return countries",False,country in self.value.all(),country.selected,0.6514890193939209
|
||
|
3835,"def parse_voc_xml ( self, node : ET. Element ) -> Dict [ str, Any ] : <TAB> voc_dict : Dict [ str, Any ] = { } <TAB> children = list ( node ) <TAB> if children : <TAB> <TAB> def_dic : Dict [ str, Any ] = collections. defaultdict ( list ) <TAB> <TAB> for dc in map ( self. parse_voc_xml, children ) : <TAB> <TAB> <TAB> for ind, v in dc. items ( ) : <TAB> <TAB> <TAB> <TAB> def_dic [ ind ]. append ( v ) <TAB> <TAB> if node. tag == ""annotation"" : <TAB> <TAB> <TAB> def_dic [ ""object"" ] = [ def_dic [ ""object"" ] ] <TAB> <TAB> voc_dict = { <TAB> <TAB> <TAB> node. tag : { ind : v [ 0 ] if len ( v ) == 1 else v for ind, v in def_dic. items ( ) } <TAB> <TAB> } <TAB> if node. text : <TAB> <TAB> text = node. text. strip ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> voc_dict [ node. tag ] = text <TAB> return voc_dict",False,not children,text,0.6756261587142944
|
||
|
3836,"def get_backward_connection ( start, stop, layer ) : <TAB> start_layer, start_category, start_buffer = start. split ( ""."", 2 ) <TAB> stop_layer, stop_category, stop_buffer = stop. split ( ""."", 2 ) <TAB> back_buffer_name = { <TAB> <TAB> ""parameters"" : ""gradients"", <TAB> <TAB> ""inputs"" : ""input_deltas"", <TAB> <TAB> ""outputs"" : ""output_deltas"", <TAB> } <TAB> new_end = ""."". join ( [ stop_layer, back_buffer_name [ stop_category ], stop_buffer ] ) <TAB> if start_category == ""internals"" : <TAB> <TAB> dstart_buffer = ""d"" + start_buffer <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise KeyError ( <TAB> <TAB> <TAB> <TAB> ""Missing delta buffer {} for the internal buffer {}"" <TAB> <TAB> <TAB> <TAB> ""."". format ( dstart_buffer, start_buffer ) <TAB> <TAB> <TAB> ) <TAB> <TAB> new_start = ""."". join ( [ start_layer, ""internals"", dstart_buffer ] ) <TAB> else : <TAB> <TAB> new_start = ""."". join ( <TAB> <TAB> <TAB> [ start_layer, back_buffer_name [ start_category ], start_buffer ] <TAB> <TAB> ) <TAB> return new_start, new_end",False,dstart_buffer not in layer.internal_shapes,dstart_buffer not in dstart_buffer,0.6518374681472778
|
||
|
3837,"def _convert_word_to_char_ids ( self, word ) : <TAB> code = np. zeros ( [ self. _max_word_length ], dtype = np. int32 ) <TAB> if self. _pad_special_char_use : <TAB> <TAB> code [ : ] = self. pad_char <TAB> if<mask> : <TAB> <TAB> word_encoded = word. encode ( ""utf-8"", ""ignore"" ) [ : self. _max_word_length - 2 ] <TAB> <TAB> code [ 0 ] = self. bow_char <TAB> <TAB> for k, chr_id in enumerate ( word_encoded, start = 1 ) : <TAB> <TAB> <TAB> code [ k ] = chr_id <TAB> <TAB> code [ len ( word_encoded ) + 1 ] = self. eow_char <TAB> else : <TAB> <TAB> word_encoded = word. encode ( ""utf-8"", ""ignore"" ) [ : self. _max_word_length ] <TAB> <TAB> for k, chr_id in enumerate ( word_encoded ) : <TAB> <TAB> <TAB> code [ k ] = chr_id <TAB> if not self. _pad_special_char_use : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> code = code [ : len ( word_encoded ) + 2 ] <TAB> <TAB> else : <TAB> <TAB> <TAB> code = code [ : len ( word_encoded ) ] <TAB> return code",False,self._word_boundary_special_char_use,self._max_word_length > 0,0.6493944525718689
|
||
|
3838,"def _parse_fields ( cls, read ) : <TAB> read = unicode_to_str ( read ) <TAB> if type ( read ) is not str : <TAB> <TAB> _wrong_type_for_arg ( read, ""str"", ""read"" ) <TAB> fields = { } <TAB> while read and read [ 0 ]!= "";"" : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> DeserializeError ( read, ""does not separate fields with commas"" ) <TAB> <TAB> read = read [ 1 : ] <TAB> <TAB> key, _type, value, read = cls. _parse_field ( read ) <TAB> <TAB> fields [ key ] = ( _type, value ) <TAB> if read : <TAB> <TAB> <TAB> <TAB> read = read [ 1 : ] <TAB> return fields, read",False,"read and read[0] != ','",fields,0.6585848331451416
|
||
|
3839,"def __str__ ( self, prefix = """", printElemNumber = 0 ) : <TAB> res = """" <TAB> cnt = 0 <TAB> for e in self. scope_ : <TAB> <TAB> elm = """" <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> elm = ""(%d)"" % cnt <TAB> <TAB> res += prefix + ( ""scope%s: %s\n"" % ( elm, self. DebugFormatString ( e ) ) ) <TAB> <TAB> cnt += 1 <TAB> if self. has_service_account_id_ : <TAB> <TAB> res += prefix + ( <TAB> <TAB> <TAB> ""service_account_id: %s\n"" % self. DebugFormatInt64 ( self. service_account_id_ ) <TAB> <TAB> ) <TAB> return res",True,printElemNumber,printElemNumber,0.6857435703277588
|
||
|
3840,"def visit_Macro ( self, node, frame ) : <TAB> macro_frame, macro_ref = self. macro_body ( node, frame ) <TAB> self. newline ( ) <TAB> if frame. toplevel : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. write ( ""context.exported_vars.add(%r)"" % node. name ) <TAB> <TAB> ref = frame. symbols. ref ( node. name ) <TAB> <TAB> self. writeline ( ""context.vars[%r] = "" % node. name ) <TAB> self. write ( ""%s = "" % frame. symbols. ref ( node. name ) ) <TAB> self. macro_def ( macro_ref, macro_frame )",False,not node.name.startswith('_'),node.name,0.6528820991516113
|
||
|
3841,"def fetch_scatter_outputs ( self, task ) : <TAB> scatteroutputs = [ ] <TAB> for var in task [ ""body"" ] : <TAB> <TAB> <TAB> <TAB> if var. startswith ( ""call"" ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> for output in self. tasks_dictionary [ task [ ""body"" ] [ var ] [ ""task"" ] ] [ <TAB> <TAB> <TAB> <TAB> <TAB> ""outputs"" <TAB> <TAB> <TAB> <TAB> ] : <TAB> <TAB> <TAB> <TAB> <TAB> scatteroutputs. append ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> { ""task"" : task [ ""body"" ] [ var ] [ ""alias"" ], ""output"" : output [ 0 ] } <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> return scatteroutputs",False,'outputs' in self.tasks_dictionary[task['body'][var]['task']],var in self.tasks_dictionary,0.6666173934936523
|
||
|
3842,"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<mask> : <TAB> <TAB> <TAB> break <TAB> <TAB> if fid == 1 : <TAB> <TAB> <TAB> if ftype == TType. LIST : <TAB> <TAB> <TAB> <TAB> self. new_parts = [ ] <TAB> <TAB> <TAB> <TAB> ( _etype302, _size299 ) = iprot. readListBegin ( ) <TAB> <TAB> <TAB> <TAB> for _i303 in xrange ( _size299 ) : <TAB> <TAB> <TAB> <TAB> <TAB> _elem304 = Partition ( ) <TAB> <TAB> <TAB> <TAB> <TAB> _elem304. read ( iprot ) <TAB> <TAB> <TAB> <TAB> <TAB> self. new_parts. append ( _elem304 ) <TAB> <TAB> <TAB> <TAB> iprot. readListEnd ( ) <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.STOP,fid == 0,0.6589915752410889
|
||
|
3843,"def _load_tracker_file_etag ( self ) : <TAB> f = None <TAB> try : <TAB> <TAB> f = open ( self. tracker_file_name, ""r"" ) <TAB> <TAB> self. etag_value_for_current_download = f. readline ( ). rstrip ( ""\n"" ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> ""Couldn't read etag in tracker file (%s). Restarting "" <TAB> <TAB> <TAB> <TAB> ""download from scratch."" % self. tracker_file_name <TAB> <TAB> <TAB> ) <TAB> except IOError as e : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if e. errno!= errno. ENOENT : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> ""Couldn't read URI tracker file (%s): %s. Restarting "" <TAB> <TAB> <TAB> <TAB> ""download from scratch."" % ( self. tracker_file_name, e. strerror ) <TAB> <TAB> <TAB> ) <TAB> finally : <TAB> <TAB> if f : <TAB> <TAB> <TAB> f. close ( )",False,len(self.etag_value_for_current_download) < self.MIN_ETAG_LEN,self.etag_value_for_current_download,0.6532106995582581
|
||
|
3844,"def confirm ( request ) : <TAB> details = request. session. get ( ""reauthenticate"" ) <TAB> if not details : <TAB> <TAB> return redirect ( ""home"" ) <TAB> <TAB> request. user = User. objects. get ( pk = details [ ""user_pk"" ] ) <TAB> if request. method == ""POST"" : <TAB> <TAB> confirm_form = PasswordConfirmForm ( request, request. POST ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> request. session. pop ( ""reauthenticate"" ) <TAB> <TAB> <TAB> request. session [ ""reauthenticate_done"" ] = True <TAB> <TAB> <TAB> return redirect ( ""social:complete"", backend = details [ ""backend"" ] ) <TAB> else : <TAB> <TAB> confirm_form = PasswordConfirmForm ( request ) <TAB> context = { ""confirm_form"" : confirm_form } <TAB> context. update ( details ) <TAB> return render ( request, ""accounts/confirm.html"", context )",False,confirm_form.is_valid(),reauthenticate_done and 'reauthenticate' in request.session,0.6494632363319397
|
||
|
3845,"def prepare ( self, size = None ) : <TAB> if _is_seekable ( self. file ) : <TAB> <TAB> start_pos = self. file. tell ( ) <TAB> <TAB> self. file. seek ( 0, 2 ) <TAB> <TAB> end_pos = self. file. tell ( ) <TAB> <TAB> self. file. seek ( start_pos ) <TAB> <TAB> fsize = end_pos - start_pos <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. remain = fsize <TAB> <TAB> else : <TAB> <TAB> <TAB> self. remain = min ( fsize, size ) <TAB> return self. remain",True,size is None,size is None,0.66523277759552
|
||
|
3846,"def _get_path_rvar ( <TAB> stmt : pgast. Query, <TAB> path_id : irast. PathId, <TAB> *, <TAB> aspect : str, <TAB> ctx : context. CompilerContextLevel, ) -> Tuple [ pgast. PathRangeVar, irast. PathId ] : <TAB> qry : Optional [ pgast. Query ] = stmt <TAB> while qry is not None : <TAB> <TAB> rvar = pathctx. maybe_get_path_rvar ( qry, path_id, aspect = aspect, env = ctx. env ) <TAB> <TAB> if rvar is not None : <TAB> <TAB> <TAB> if qry is not stmt : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> pathctx. put_path_rvar ( stmt, path_id, rvar, aspect = aspect, env = ctx. env ) <TAB> <TAB> <TAB> return rvar, path_id <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> path_id = pathctx. reverse_map_path_id ( path_id, qry. view_path_id_map ) <TAB> <TAB> qry = ctx. rel_hierarchy. get ( qry ) <TAB> raise LookupError ( f""there is no range var for {path_id} in {stmt}"" )",False,qry.view_path_id_map,path_id is not None,0.65373295545578
|
||
|
3847,"def onMouseWheel ( self, event ) : <TAB> if self. selectedHuman. isVisible ( ) : <TAB> <TAB> zoomOut = event. wheelDelta > 0 <TAB> <TAB> if self. getSetting ( ""invertMouseWheel"" ) : <TAB> <TAB> <TAB> zoomOut = not zoomOut <TAB> <TAB> if event. x is not None : <TAB> <TAB> <TAB> self. modelCamera. mousePickHumanCenter ( event. x, event. y ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. zoomOut ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. zoomIn ( )",True,zoomOut,zoomOut,0.702865481376648
|
||
|
3848,"def _remove_iptables_rule ( self, rule, ipv6 = False, tables = None ) : <TAB> if not isinstance ( rule, tuple ) : <TAB> <TAB> return self. _remove_iptables_rule_cmd ( rule, ipv6 ) <TAB> _global_lock. acquire ( ) <TAB> try : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if rule [ 0 ] == ""POSTROUTING"" : <TAB> <TAB> <TAB> <TAB> if tables : <TAB> <TAB> <TAB> <TAB> <TAB> table = tables [ ""nat6"" ] <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> table = iptc. Table6 ( iptc. Table. NAT ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> if tables : <TAB> <TAB> <TAB> <TAB> <TAB> table = tables [ ""filter6"" ] <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> table = iptc. Table6 ( iptc. Table. FILTER ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if rule [ 0 ] == ""POSTROUTING"" : <TAB> <TAB> <TAB> <TAB> if tables : <TAB> <TAB> <TAB> <TAB> <TAB> table = tables [ ""nat"" ] <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> table = iptc. Table ( iptc. Table. NAT ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> if tables : <TAB> <TAB> <TAB> <TAB> <TAB> table = tables [ ""filter"" ] <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> table = iptc. Table ( iptc. Table. FILTER ) <TAB> <TAB> chain = iptc. Chain ( table, rule [ 0 ] ) <TAB> <",True,ipv6,ipv6,0.6762512922286987
|
||
|
3849,"def expect_document_start ( self, first = False ) : <TAB> if isinstance ( self. event, DocumentStartEvent ) : <TAB> <TAB> if ( self. event. version or self. event. tags ) and self. open_ended : <TAB> <TAB> <TAB> self. write_indicator ( ""..."", True ) <TAB> <TAB> <TAB> self. write_indent ( ) <TAB> <TAB> if self. event. version : <TAB> <TAB> <TAB> version_text = self. prepare_version ( self. event. version ) <TAB> <TAB> <TAB> self. write_version_directive ( version_text ) <TAB> <TAB> self. tag_prefixes = self. DEFAULT_TAG_PREFIXES. copy ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> handles = sorted ( self. event. tags. keys ( ) ) <TAB> <TAB> <TAB> for handle in handles : <TAB> <TAB> <TAB> <TAB> prefix = self. event. tags [ handle ] <TAB> <TAB> <TAB> <TAB> self. tag_prefixes [ prefix ] = handle <TAB> <TAB> <TAB> <TAB> handle_text = self. prepare_tag_handle ( handle ) <TAB> <TAB> <TAB> <TAB> prefix_text = self. prepare_tag_prefix ( prefix ) <TAB> <TAB> <TAB> <TAB> self. write_tag_directive ( handle_text, prefix_text ) <TAB> <TAB> implicit = ( <TAB> <TAB> <TAB> first <TAB> <TAB> <TAB> and not self. event. explicit <TAB> <TAB> <TAB> and not self. canonical <TAB> <TAB> <TAB> and not self. event. version <TAB> <TAB> <TAB> and not self. event. tags <TAB> <TAB> <TAB> and not self. check_empty_document ( ) <TAB> <TAB> ) <TAB> <TAB> if not implicit : <TAB> <TAB> <TAB> self. write_indent ( ) <TAB> <TAB> <TAB> self. write_indicator ( ""---"", True ) <TAB> <TAB> <TAB> if self.",False,self.event.tags,first,0.66018146276474
|
||
|
3850,"def send_slack_msg ( self, key, message_payload ) : <TAB> if key. startswith ( ""https://hooks.slack.com/"" ) : <TAB> <TAB> response = requests. post ( <TAB> <TAB> <TAB> url = key, data = message_payload, headers = { ""Content-Type"" : ""application/json"" } <TAB> <TAB> ) <TAB> else : <TAB> <TAB> response = requests. post ( <TAB> <TAB> <TAB> url = ""https://slack.com/api/chat.postMessage"", <TAB> <TAB> <TAB> data = message_payload, <TAB> <TAB> <TAB> headers = { <TAB> <TAB> <TAB> <TAB> ""Content-Type"" : ""application/json;charset=utf-8"", <TAB> <TAB> <TAB> <TAB> ""Authorization"" : ""Bearer %s"" % self. config. get ( ""slack_token"" ), <TAB> <TAB> <TAB> }, <TAB> <TAB> ) <TAB> if response. status_code == 429 and ""Retry-After"" in response. headers : <TAB> <TAB> self. logger. info ( <TAB> <TAB> <TAB> ""Slack API rate limiting. Waiting %d seconds"", <TAB> <TAB> <TAB> int ( response. headers [ ""Retry-After"" ] ), <TAB> <TAB> ) <TAB> <TAB> time. sleep ( int ( response. headers [ ""Retry-After"" ] ) ) <TAB> <TAB> return <TAB> elif response. status_code!= 200 : <TAB> <TAB> self. logger. info ( <TAB> <TAB> <TAB> ""Error in sending Slack message status:%s response: %s"", <TAB> <TAB> <TAB> response. status_code, <TAB> <TAB> <TAB> response. text, <TAB> <TAB> ) <TAB> <TAB> return <TAB> if ""text/html"" in response. headers [ ""content-type"" ] : <TAB> <TAB> if response. text!= ""ok"" : <TAB> <TAB> <TAB> self. logger. info ( <TAB> <TAB>",False,not response_json['ok'],self.config.get('slack_token'),0.6493945121765137
|
||
|
3851,"def _discover_formatters ( ) : <TAB> import inspect <TAB> from pygments. formatters import get_all_formatters <TAB> <TAB> default_exts = { } <TAB> exts = { } <TAB> <TAB> default_names = { } <TAB> names = { } <TAB> formatters = { ""exts"" : exts, ""names"" : names } <TAB> if DEBUG : <TAB> <TAB> from collections import defaultdict <TAB> <TAB> duplicates = defaultdict ( set ) <TAB> for cls in get_all_formatters ( ) : <TAB> <TAB> mod = inspect. getmodule ( cls ) <TAB> <TAB> val = ( mod. __name__, cls. __name__ ) <TAB> <TAB> <TAB> <TAB> for filename in cls. filenames : <TAB> <TAB> <TAB> if filename. startswith ( ""*."" ) : <TAB> <TAB> <TAB> <TAB> filename = filename [ 1 : ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if ( <TAB> <TAB> <TAB> <TAB> DEBUG <TAB> <TAB> <TAB> <TAB> and filename in exts <TAB> <TAB> <TAB> <TAB> and exts [ filename ]!= val <TAB> <TAB> <TAB> <TAB> and filename not in default_exts <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> duplicates [ filename ]. add ( val ) <TAB> <TAB> <TAB> <TAB> duplicates [ filename ]. add ( exts [ filename ] ) <TAB> <TAB> <TAB> exts [ filename ] = val <TAB> <TAB> <TAB> <TAB> names [ cls. name ] = val <TAB> <TAB> for alias in cls. aliases : <TAB> <TAB> <TAB> if ( <TAB> <TAB> <TAB> <TAB> DEBUG <TAB> <TAB> <TAB> <TAB> and alias in names <TAB> <TAB> <TAB> <TAB> and names [ alias ]!= val <TAB> <TAB> <TAB> <TAB> and alias not in default_names",False,'*' in filename,filename in formatters,0.679736852645874
|
||
|
3852,"def _get_frame_value ( frame, keyframes ) : <TAB> for i in range ( 0, len ( keyframes ) ) : <TAB> <TAB> kf_frame, kf_value = keyframes [ i ] <TAB> <TAB> if kf_frame == frame : <TAB> <TAB> <TAB> return kf_value <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> frame_n, value_n = keyframes [ i + 1 ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> time_fract = float ( ( frame - kf_frame ) ) / float ( ( frame_n - kf_frame ) ) <TAB> <TAB> <TAB> <TAB> value_range = value_n - kf_value <TAB> <TAB> <TAB> <TAB> return kf_value + time_fract * value_range <TAB> <TAB> except : <TAB> <TAB> <TAB> return kf_value",False,kf_frame < frame and frame < frame_n,kf_value == frame_n,0.6589030623435974
|
||
|
3853,"def validate ( self, entry, field_uri = None ) : <TAB> super ( ). validate ( entry, field_uri ) <TAB> if entry is None : <TAB> <TAB> return <TAB> field_uri = field_uri or self. field_uri <TAB> if not isinstance ( entry, dict ) : <TAB> <TAB> raise ConfigError ( ""{} is expected to be dict"". format ( field_uri ) ) <TAB> if not entry and not self. allow_empty : <TAB> <TAB> self. raise_error ( entry, field_uri, ""value is empty"" ) <TAB> for k, v in entry. items ( ) : <TAB> <TAB> if self. validate_keys : <TAB> <TAB> <TAB> uri = ""{}.keys.{}"". format ( field_uri, k ) <TAB> <TAB> <TAB> self. key_type. validate ( k, uri ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> uri = ""{}.{}"". format ( field_uri, k ) <TAB> <TAB> <TAB> self. value_type. validate ( v, uri )",False,self.validate_values,self.validate_value,0.6518567800521851
|
||
|
3854,"def ack ( self, sha ) : <TAB> """"""Ack that a revision and its ancestors are present in the source."""""" <TAB> if len ( sha )!= 40 : <TAB> <TAB> raise ValueError ( ""unexpected sha %r received"" % sha ) <TAB> ancestors = set ( [ sha ] ) <TAB> <TAB> while self. heads : <TAB> <TAB> for a in ancestors : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. heads. remove ( a ) <TAB> <TAB> <TAB> <TAB> new_ancestors = set ( ) <TAB> <TAB> for a in ancestors : <TAB> <TAB> <TAB> ps = self. parents. get ( a ) <TAB> <TAB> <TAB> if ps is not None : <TAB> <TAB> <TAB> <TAB> new_ancestors. update ( ps ) <TAB> <TAB> <TAB> self. parents [ a ] = None <TAB> <TAB> <TAB> <TAB> if not new_ancestors : <TAB> <TAB> <TAB> break <TAB> <TAB> ancestors = new_ancestors",False,a in self.heads,a in self.parents,0.6693235039710999
|
||
|
3855,"def _onFrameNavigated ( self, framePayload : dict ) -> None : <TAB> isMainFrame = not framePayload. get ( ""parentId"" ) <TAB> if isMainFrame : <TAB> <TAB> frame = self. _mainFrame <TAB> else : <TAB> <TAB> self. _frames. get ( framePayload. get ( ""id"", """" ) ) <TAB> if not ( isMainFrame or frame ) : <TAB> <TAB> raise PageError ( <TAB> <TAB> <TAB> ""We either navigate top level or have old version "" ""of the navigated frame"" <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> for child in frame. childFrames : <TAB> <TAB> <TAB> self. _removeFramesRecursively ( child ) <TAB> <TAB> _id = framePayload. get ( ""id"", """" ) <TAB> if isMainFrame : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _frames. pop ( frame. _id, None ) <TAB> <TAB> <TAB> frame. _id = _id <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> frame = Frame ( self. _client, self. _mouse, self. _touchscreen, None, _id ) <TAB> <TAB> self. _frames [ _id ] = frame <TAB> <TAB> self. _mainFrame = frame <TAB> <TAB> frame. _navigated ( framePayload ) <TAB> self. emit ( FrameManager. Events. FrameNavigated, frame )",False,frame,frame.childFrames,0.6889786720275879
|
||
|
3856,"def __call__ ( self, event, data = None ) : <TAB> datatype, delta = event <TAB> self. midi_ctrl. delta += delta <TAB> if TIMING_CLOCK in datatype and not self. played : <TAB> <TAB> self. midi_ctrl. pulse += 1 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> t_master = 60.0 <TAB> <TAB> <TAB> self. midi_ctrl. bpm = round ( 60.0 / self. midi_ctrl. delta, 0 ) <TAB> <TAB> <TAB> self. midi_ctrl. pulse = 0 <TAB> <TAB> <TAB> self. midi_ctrl. delta = 0.0",False,self.midi_ctrl.pulse == self.midi_ctrl.ppqn,self.midi_ctrl.pulse >= 1.0,0.6615312695503235
|
||
|
3857,"def IndexDocuments ( self, documents, response ) : <TAB> """"""Indexes an iterable DocumentPb.Document."""""" <TAB> for document in documents : <TAB> <TAB> doc_id = document. id ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> doc_id = str ( uuid. uuid4 ( ) ) <TAB> <TAB> <TAB> document. set_id ( doc_id ) <TAB> <TAB> response. add_doc_id ( doc_id ) <TAB> <TAB> if doc_id in self. _documents : <TAB> <TAB> <TAB> old_document = self. _documents [ doc_id ] <TAB> <TAB> <TAB> self. _inverted_index. RemoveDocument ( old_document ) <TAB> <TAB> self. _documents [ doc_id ] = document <TAB> <TAB> new_status = response. add_status ( ) <TAB> <TAB> new_status. set_code ( search_service_pb. SearchServiceError. OK ) <TAB> <TAB> self. _inverted_index. AddDocument ( doc_id, document )",False,not doc_id,doc_id is None,0.6599835157394409
|
||
|
3858,"def __load_protos ( ) : <TAB> g = globals ( ) <TAB> for k, v in g. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> name = k [ 4 : ] <TAB> <TAB> <TAB> modname = name. lower ( ) <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> mod = __import__ ( modname, g, level = 1 ) <TAB> <TAB> <TAB> <TAB> PPP. set_p ( v, getattr ( mod, name ) ) <TAB> <TAB> <TAB> except ( ImportError, AttributeError ) : <TAB> <TAB> <TAB> <TAB> continue",False,k.startswith('PPP_'),k.startswith('<TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> < / / >,0.6541726589202881
|
||
|
3859,"def get_meminfo ( ) -> Dict [ str, Any ] : <TAB> res = { } <TAB> try : <TAB> <TAB> import psutil <TAB> except ImportError : <TAB> <TAB> res [ ""memory_psutil_missing"" ] = ( <TAB> <TAB> <TAB> ""psutil not found, run pip install mypy[dmypy] "" <TAB> <TAB> <TAB> ""to install the needed components for dmypy"" <TAB> <TAB> ) <TAB> else : <TAB> <TAB> process = psutil. Process ( ) <TAB> <TAB> meminfo = process. memory_info ( ) <TAB> <TAB> res [ ""memory_rss_mib"" ] = meminfo. rss / MiB <TAB> <TAB> res [ ""memory_vms_mib"" ] = meminfo. vms / MiB <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> res [ ""memory_maxrss_mib"" ] = meminfo. peak_wset / MiB <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> import resource <TAB> <TAB> <TAB> rusage = resource. getrusage ( resource. RUSAGE_SELF ) <TAB> <TAB> <TAB> if sys. platform == ""darwin"" : <TAB> <TAB> <TAB> <TAB> factor = 1 <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> factor = 1024 <TAB> <TAB> <TAB> res [ ""memory_maxrss_mib"" ] = rusage. ru_maxrss * factor / MiB <TAB> return res",True,sys.platform == 'win32',sys.platform == 'win32',0.66079181432724
|
||
|
3860,"def get_key ( self, view_instance, view_method, request, args, kwargs ) : <TAB> if<mask> : <TAB> <TAB> memoization_key = self. _get_memoization_key ( <TAB> <TAB> <TAB> view_instance = view_instance, <TAB> <TAB> <TAB> view_method = view_method, <TAB> <TAB> <TAB> args = args, <TAB> <TAB> <TAB> kwargs = kwargs, <TAB> <TAB> ) <TAB> <TAB> if not hasattr ( request, ""_key_constructor_cache"" ) : <TAB> <TAB> <TAB> request. _key_constructor_cache = { } <TAB> if self. memoize_for_request and memoization_key in request. _key_constructor_cache : <TAB> <TAB> return request. _key_constructor_cache. get ( memoization_key ) <TAB> else : <TAB> <TAB> value = self. _get_key ( <TAB> <TAB> <TAB> view_instance = view_instance, <TAB> <TAB> <TAB> view_method = view_method, <TAB> <TAB> <TAB> request = request, <TAB> <TAB> <TAB> args = args, <TAB> <TAB> <TAB> kwargs = kwargs, <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> request. _key_constructor_cache [ memoization_key ] = value <TAB> <TAB> return value",False,self.memoize_for_request,memoization_key is not None,0.654608964920044
|
||
|
3861,"def find ( self, path ) : <TAB> if os. path. isfile ( path ) or os. path. islink ( path ) : <TAB> <TAB> self. num_files = self. num_files + 1 <TAB> <TAB> if self. match_function ( path ) : <TAB> <TAB> <TAB> self. files. append ( path ) <TAB> elif os. path. isdir ( path ) : <TAB> <TAB> for content in os. listdir ( path ) : <TAB> <TAB> <TAB> file = os. path. join ( path, content ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. num_files = self. num_files + 1 <TAB> <TAB> <TAB> <TAB> if self. match_function ( file ) : <TAB> <TAB> <TAB> <TAB> <TAB> self. files. append ( file ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. find ( file )",False,os.path.isfile(file) or os.path.islink(file),os.path.isfile(file),0.6462186574935913
|
||
|
3862,"def __init__ ( self, section, source = None, lineno = None ) : <TAB> msg = [ repr ( section ), "" already exists"" ] <TAB> if source is not None : <TAB> <TAB> message = [ ""While reading from "", repr ( source ) ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> message. append ( "" [line {0:2d}]"". format ( lineno ) ) <TAB> <TAB> message. append ( "": section "" ) <TAB> <TAB> message. extend ( msg ) <TAB> <TAB> msg = message <TAB> else : <TAB> <TAB> msg. insert ( 0, ""Section "" ) <TAB> Error. __init__ ( self, """". join ( msg ) ) <TAB> self. section = section <TAB> self. source = source <TAB> self. lineno = lineno <TAB> self. args = ( section, source, lineno )",True,lineno is not None,lineno is not None,0.6798129081726074
|
||
|
3863,"def do_list ( self, q ) : <TAB> marker = q. params [ ""marker"" ] [ 0 ] if ""marker"" in q. params else None <TAB> max_keys = int ( q. params [ ""max_keys"" ] [ 0 ] ) if ""max_keys"" in q. params else 1000 <TAB> prefix = q. params [ ""prefix"" ] [ 0 ] if ""prefix"" in q. params else """" <TAB> resp = [ <TAB> <TAB> '<?xml version=""1.0"" encoding=""UTF-8""?>', <TAB> <TAB> '<ListBucketResult xmlns=""%s"">' % self. xml_ns, <TAB> <TAB> ""<MaxKeys>%d</MaxKeys>"" % max_keys, <TAB> <TAB> ""<IsTruncated>false</IsTruncated>"", <TAB> ] <TAB> count = 0 <TAB> for key in sorted ( self. server. data ) : <TAB> <TAB> if not key. startswith ( prefix ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> if marker and key <= marker : <TAB> <TAB> <TAB> continue <TAB> <TAB> resp. append ( ""<Contents><Key>%s</Key></Contents>"" % xml_escape ( key ) ) <TAB> <TAB> count += 1 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> resp [ 3 ] = ""<IsTruncated>true</IsTruncated>"" <TAB> <TAB> <TAB> break <TAB> resp. append ( ""</ListBucketResult>"" ) <TAB> body = ""\n"". join ( resp ). encode ( ) <TAB> self. send_response ( 200 ) <TAB> self. send_header ( ""Content-Type"", ""text/xml"" ) <TAB> self. send_header ( ""Content-Length"", str ( len ( body ) ) ) <TAB> self. end_headers ( ) <TAB> self. wfile. write ( body )",False,count == max_keys,count > max_keys,0.6624726057052612
|
||
|
3864,"def insert ( self, pack_id, data ) : <TAB> if ( pack_id not in self. queue ) and pack_id > self. begin_id : <TAB> <TAB> self. queue [ pack_id ] = PacketInfo ( data ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. end_id = pack_id + 1 <TAB> <TAB> elif self. end_id < pack_id : <TAB> <TAB> <TAB> eid = self. end_id <TAB> <TAB> <TAB> while eid < pack_id : <TAB> <TAB> <TAB> <TAB> self. miss_queue. add ( eid ) <TAB> <TAB> <TAB> <TAB> eid += 1 <TAB> <TAB> <TAB> self. end_id = pack_id + 1 <TAB> <TAB> else : <TAB> <TAB> <TAB> self. miss_queue. remove ( pack_id )",False,self.end_id == pack_id,self.begin_id > pack_id,0.6509692668914795
|
||
|
3865,"def walks_generator ( ) : <TAB> if filelist is not None : <TAB> <TAB> bucket = [ ] <TAB> <TAB> for filename in filelist : <TAB> <TAB> <TAB> with io. open ( filename ) as inf : <TAB> <TAB> <TAB> <TAB> for line in inf : <TAB> <TAB> <TAB> <TAB> <TAB> walk = [ int ( x ) for x in line. strip ( ""\n"" ). split ( "" "" ) ] <TAB> <TAB> <TAB> <TAB> <TAB> bucket. append ( walk ) <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> yield bucket <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> bucket = [ ] <TAB> <TAB> if len ( bucket ) : <TAB> <TAB> <TAB> yield bucket <TAB> else : <TAB> <TAB> for _ in range ( epoch ) : <TAB> <TAB> <TAB> for nodes in graph. node_batch_iter ( batch_size ) : <TAB> <TAB> <TAB> <TAB> walks = graph. random_walk ( nodes, walk_len ) <TAB> <TAB> <TAB> <TAB> yield walks",False,len(bucket) == batch_size,len(bucket) > 0,0.651907205581665
|
||
|
3866,"def reloadCols ( self ) : <TAB> self. columns = [ ] <TAB> for i, ( name, fmt, * shape ) in enumerate ( self. npy. dtype. descr ) : <TAB> <TAB> if shape : <TAB> <TAB> <TAB> t = anytype <TAB> <TAB> elif ""M"" in fmt : <TAB> <TAB> <TAB> self. addColumn ( Column ( name, type = date, getter = lambda c, r, i = i : str ( r [ i ] ) ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> t = int <TAB> <TAB> elif ""f"" in fmt : <TAB> <TAB> <TAB> t = float <TAB> <TAB> else : <TAB> <TAB> <TAB> t = anytype <TAB> <TAB> self. addColumn ( ColumnItem ( name, i, type = t ) )",False,'i' in fmt,'st' in fmt,0.667656421661377
|
||
|
3867,"def test_createFile ( self ) : <TAB> text = ""This is a test!"" <TAB> path = tempfile. mktemp ( ) <TAB> try : <TAB> <TAB> koDoc = self. _koDocFromPath ( path, load = False ) <TAB> <TAB> koDoc. buffer = text <TAB> <TAB> koDoc. save ( 0 ) <TAB> <TAB> del koDoc <TAB> <TAB> koDoc2 = self. _koDocFromPath ( path ) <TAB> <TAB> assert koDoc2. buffer == text <TAB> finally : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> os. unlink ( path )",True,os.path.exists(path),os.path.exists(path),0.6471022367477417
|
||
|
3868,"def get_selection ( self ) : <TAB> if self. interface. multiple_select : <TAB> <TAB> selection = [ ] <TAB> <TAB> current_index = self. tree. selectedRowIndexes. firstIndex <TAB> <TAB> for i in range ( self. tree. selectedRowIndexes. count ) : <TAB> <TAB> <TAB> selection. append ( self. tree. itemAtRow ( current_index ). attrs [ ""node"" ] ) <TAB> <TAB> <TAB> current_index = self. tree. selectedRowIndexes. indexGreaterThanIndex ( <TAB> <TAB> <TAB> <TAB> current_index <TAB> <TAB> <TAB> ) <TAB> <TAB> return selection <TAB> else : <TAB> <TAB> index = self. tree. selectedRow <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return self. tree. itemAtRow ( index ). attrs [ ""node"" ] <TAB> <TAB> else : <TAB> <TAB> <TAB> return None",False,index != -1,index is not None and index.isValid(),0.6681556701660156
|
||
|
3869,"def detect_ssl_option ( self ) : <TAB> for option in self. ssl_options ( ) : <TAB> <TAB> if scan_argv ( self. argv, option ) is not None : <TAB> <TAB> <TAB> for other_option in self. ssl_options ( ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> if scan_argv ( self. argv, other_option ) is not None : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> raise ConfigurationError ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""Cannot give both %s and %s"" % ( option, other_option ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> return option",False,option != other_option,option == other_option,0.6600449085235596
|
||
|
3870,"def save_map ( world, path, prefix ) : <TAB> map_file = os. path. join ( path, prefix + "".sqlite"" ) <TAB> db = DbReader ( map_file ) <TAB> read_savegame_template ( db ) <TAB> db ( ""BEGIN"" ) <TAB> for island in world. islands : <TAB> <TAB> island_name = ""{}_island_{:d}_{:d}.sqlite"". format ( <TAB> <TAB> <TAB> prefix, island. origin. x, island. origin. y <TAB> <TAB> ) <TAB> <TAB> island_db_path = os. path. join ( path, island_name ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> os. unlink ( island_db_path ) <TAB> <TAB> db ( <TAB> <TAB> <TAB> ""INSERT INTO island (x, y, file) VALUES(?,?,?)"", <TAB> <TAB> <TAB> island. origin. x, <TAB> <TAB> <TAB> island. origin. y, <TAB> <TAB> <TAB> ""content/islands/"" + island_name, <TAB> <TAB> ) <TAB> <TAB> island_db = DbReader ( island_db_path ) <TAB> <TAB> island. save_map ( island_db ) <TAB> <TAB> island_db. close ( ) <TAB> db ( ""COMMIT"" ) <TAB> db. close ( )",False,os.path.exists(island_db_path),os.path.isfile(island_db_path),0.6468785405158997
|
||
|
3871,"def _getItemHeight ( self, item, ctrl = None ) : <TAB> """"""Returns the full height of the item to be inserted in the form"""""" <TAB> if type ( ctrl ) == psychopy. visual. TextBox2 : <TAB> <TAB> return ctrl. size [ 1 ] <TAB> if type ( ctrl ) == psychopy. visual. Slider : <TAB> <TAB> <TAB> <TAB> if item [ ""layout"" ] == ""horiz"" : <TAB> <TAB> <TAB> return 0.03 + ctrl. labelHeight * 3 <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return ctrl. labelHeight * len ( item [ ""options"" ] )",False,item['layout'] == 'vert',item['layout'] == 'group',0.6513952016830444
|
||
|
3872,"def decrypt_hash ( edata, nlkm, ch, xp = True ) : <TAB> if xp : <TAB> <TAB> hmac_md5 = HMAC. new ( nlkm, ch ) <TAB> <TAB> rc4key = hmac_md5. digest ( ) <TAB> <TAB> rc4 = ARC4. new ( rc4key ) <TAB> <TAB> data = rc4. encrypt ( edata ) <TAB> else : <TAB> <TAB> <TAB> <TAB> aes = AES. new ( nlkm [ 16 : 32 ], AES. MODE_CBC, ch ) <TAB> <TAB> data = """" <TAB> <TAB> for i in range ( 0, len ( edata ), 16 ) : <TAB> <TAB> <TAB> buf = edata [ i : i + 16 ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> buf += ( 16 - len ( buf ) ) * ""\00"" <TAB> <TAB> <TAB> data += aes. decrypt ( buf ) <TAB> return data",True,len(buf) < 16,len(buf) < 16,0.6589879989624023
|
||
|
3873,"def draw_left_axis ( self, bounds, y_ticks, y_tick_text ) : <TAB> ( left, top, right, bottom ) = bounds <TAB> stats = { } <TAB> for stat in self. stat_info : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> stats [ stat ] = self. stat_info [ stat ] <TAB> <TAB> <TAB> stats [ stat ] [ ""values"" ] = self. stats [ stat ] <TAB> <TAB> <TAB> stats [ stat ] [ ""fill_color"" ] = change_opacity ( stats [ stat ] [ ""color"" ], 0.5 ) <TAB> <TAB> <TAB> stats [ stat ] [ ""color"" ] = change_opacity ( stats [ stat ] [ ""color"" ], 0.8 ) <TAB> height = bottom - top <TAB> max_value = y_ticks [ - 1 ] <TAB> ratio = height / max_value <TAB> for i, y_val in enumerate ( y_ticks ) : <TAB> <TAB> y = int ( bottom - y_val * ratio ) - 0.5 <TAB> <TAB> if i!= 0 : <TAB> <TAB> <TAB> self. draw_dotted_line ( gray, left, y, right, y ) <TAB> <TAB> self. draw_y_text ( y_tick_text [ i ], left, y ) <TAB> self. draw_line ( gray, left, top, left, bottom ) <TAB> for stat, info in stats. items ( ) : <TAB> <TAB> if len ( info [ ""values"" ] ) > 0 : <TAB> <TAB> <TAB> self. draw_value_poly ( info [ ""values"" ], info [ ""color"" ], max_value, bounds ) <TAB> <TAB> <TAB> self. draw_value_poly ( <TAB> <TAB> <TAB> <TAB> info [ ""values"" ], info [ ""fill_color"" ], max_value, bounds, info [ ""fill"" ] <TAB> <TAB> <TAB> )",False,self.stat_info[stat]['axis'] == 'left',stat in self.stats,0.6550924777984619
|
||
|
3874,"def visit_symbol_table ( self, symtab : SymbolTable, table_fullname : str ) -> None : <TAB> <TAB> for key, value in list ( symtab. items ( ) ) : <TAB> <TAB> cross_ref = value. cross_ref <TAB> <TAB> if cross_ref is not None : <TAB> <TAB> <TAB> value. cross_ref = None <TAB> <TAB> <TAB> if cross_ref in self. modules : <TAB> <TAB> <TAB> <TAB> value. node = self. modules [ cross_ref ] <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> stnode = lookup_qualified_stnode ( <TAB> <TAB> <TAB> <TAB> <TAB> self. modules, cross_ref, self. allow_missing <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> assert stnode. node is not None, ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> table_fullname + ""."" + key, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> cross_ref, <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> value. node = stnode. node <TAB> <TAB> <TAB> <TAB> elif not self. allow_missing : <TAB> <TAB> <TAB> <TAB> <TAB> assert False, ""Could not find cross-ref %s"" % ( cross_ref, ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> value. node = missing_info ( self. modules ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if isinstance ( value. node, TypeInfo ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. visit_type_info ( value. node )",True,stnode is not None,stnode is not None,0.6625056266784668
|
||
|
3875,"def prepare_verify ( verify, verify_fingerprint ) : <TAB> if isinstance ( verify, ( str, bytes ) ) : <TAB> <TAB> verify = expand_path ( verify ) <TAB> elif not isinstance ( verify, bool ) : <TAB> <TAB> raise exceptions. UserError ( <TAB> <TAB> <TAB> ""Invalid value for verify ({}), "" <TAB> <TAB> <TAB> ""must be a path to a PEM-file or boolean."". format ( verify ) <TAB> <TAB> ) <TAB> if verify_fingerprint is not None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise exceptions. UserError ( <TAB> <TAB> <TAB> <TAB> ""Invalid value for verify_fingerprint "" <TAB> <TAB> <TAB> <TAB> ""({}), must be a string or null."". format ( verify_fingerprint ) <TAB> <TAB> <TAB> ) <TAB> elif not verify : <TAB> <TAB> raise exceptions. UserError ( <TAB> <TAB> <TAB> ""Disabling all SSL validation is forbidden. Consider setting "" <TAB> <TAB> <TAB> ""verify_fingerprint if you have a broken or self-signed cert."" <TAB> <TAB> ) <TAB> return { <TAB> <TAB> ""verify"" : verify, <TAB> <TAB> ""verify_fingerprint"" : verify_fingerprint, <TAB> }",False,"not isinstance(verify_fingerprint, (bytes, str))","not isinstance(verify_fingerprint, str)",0.6545051336288452
|
||
|
3876,"def show_image ( self, wnd_name, img ) : <TAB> if wnd_name in self. named_windows : <TAB> <TAB> if self. named_windows [ wnd_name ] == 0 : <TAB> <TAB> <TAB> self. named_windows [ wnd_name ] = 1 <TAB> <TAB> <TAB> self. on_create_window ( wnd_name ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. capture_mouse ( wnd_name ) <TAB> <TAB> self. on_show_image ( wnd_name, img ) <TAB> else : <TAB> <TAB> print ( ""show_image: named_window "", wnd_name, "" not found."" )",False,wnd_name in self.capture_mouse_windows,self.capture_mouse and wnd_name in self.named_windows,0.6506874561309814
|
||
|
3877,"def replace ( self, state ) : <TAB> if state. key in self. _dict : <TAB> <TAB> existing = self. _dict [ state. key ] <TAB> <TAB> existing = attributes. instance_state ( existing ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _manage_removed_state ( existing ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return <TAB> self. _dict [ state. key ] = state. obj ( ) <TAB> self. _manage_incoming_state ( state )",False,existing is not state,existing.has_state(),0.6668130159378052
|
||
|
3878,"def _cleanupSocket ( self ) : <TAB> """"""Close the Connection's socket."""""" <TAB> try : <TAB> <TAB> self. _sock. shutdown ( socket. SHUT_WR ) <TAB> except : <TAB> <TAB> return <TAB> try : <TAB> <TAB> while True : <TAB> <TAB> <TAB> r, w, e = select. select ( [ self. _sock ], [ ], [ ] ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> break <TAB> except : <TAB> <TAB> pass <TAB> self. _sock. close ( )",False,not r or not self._sock.recv(1024),r,0.6514097452163696
|
||
|
3879,"def native_device_prefix ( prefixes ) : <TAB> log. debug ( <TAB> <TAB> ""Getting the OS-native device prefix from potential prefixes: {0}"". format ( <TAB> <TAB> <TAB> prefixes <TAB> <TAB> ) <TAB> ) <TAB> for prefix in prefixes : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> log. debug ( ""Native prefix is {0}"". format ( prefix ) ) <TAB> <TAB> <TAB> return prefix <TAB> else : <TAB> <TAB> log. debug ( ""{0} contains no native device prefixes"". format ( prefixes ) ) <TAB> <TAB> return None",False,any((device.startswith(prefix) for device in os.listdir('/sys/block'))),lib.PCI_DEVICE_PREFIX.match(prefix),0.6466257572174072
|
||
|
3880,"def _handle_class_and_struct ( self, class_type ) : <TAB> if self. _handling_typedef : <TAB> <TAB> return self. _get_class ( class_type, None ) <TAB> name_tokens, var_token = self. get_name ( ) <TAB> if var_token. token_type == tokenize. NAME or var_token. name in ""*&"" : <TAB> <TAB> tokens, last = self. _get_var_tokens_up_to ( False, ""("", "";"", ""{"" ) <TAB> <TAB> tokens. insert ( 0, var_token ) <TAB> <TAB> tokens = name_tokens + tokens <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _add_back_token ( last ) <TAB> <TAB> <TAB> self. _add_back_tokens ( tokens ) <TAB> <TAB> <TAB> return self. _get_class ( class_type, None ) <TAB> <TAB> if last. name == ""("" : <TAB> <TAB> <TAB> return self. _get_method ( tokens, 0, None, False ) <TAB> <TAB> return self. _get_variable ( tokens ) <TAB> self. _add_back_token ( var_token ) <TAB> self. _add_back_tokens ( name_tokens ) <TAB> return self. _get_class ( class_type, None )",False,last.name == '{',last != None,0.6577915549278259
|
||
|
3881,"def add_lines_into_order ( self, order, lines ) : <TAB> <TAB> order_line_by_source = { <TAB> <TAB> id ( order_line. source_line ) : order_line for order_line in lines <TAB> } <TAB> <TAB> for index, order_line in enumerate ( lines ) : <TAB> <TAB> order_line. order = order <TAB> <TAB> order_line. ordering = index <TAB> <TAB> parent_src_line = order_line. parent_source_line <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> parent_order_line = order_line_by_source [ id ( parent_src_line ) ] <TAB> <TAB> <TAB> assert parent_order_line. pk, ""Parent line should be saved"" <TAB> <TAB> <TAB> order_line. parent_line = parent_order_line <TAB> <TAB> order_line. save ( ) <TAB> self. add_line_taxes ( lines ) <TAB> <TAB> for order_line in lines : <TAB> <TAB> self. process_saved_order_line ( order = order, order_line = order_line )",False,parent_src_line,parent_src_line and parent_src_line.pk,0.6582622528076172
|
||
|
3882,"def _get_event_for_message ( self, message_id ) : <TAB> with self. event_lock : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise RuntimeError ( <TAB> <TAB> <TAB> <TAB> ""Event for message[{}] should have been created before accessing"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> message_id <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> return self. _events [ message_id ]",True,message_id not in self._events,message_id not in self._events,0.6641417741775513
|
||
|
3883,"def _cross_replica_average ( self, t, num_shards_per_group ) : <TAB> """"""Calculates the average value of input tensor across TPU replicas."""""" <TAB> num_shards = tpu_function. get_tpu_context ( ). number_of_shards <TAB> group_assignment = None <TAB> if num_shards_per_group > 1 : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""num_shards: %d mod shards_per_group: %d, should be 0"" <TAB> <TAB> <TAB> <TAB> % ( num_shards, num_shards_per_group ) <TAB> <TAB> <TAB> ) <TAB> <TAB> num_groups = num_shards // num_shards_per_group <TAB> <TAB> group_assignment = [ <TAB> <TAB> <TAB> [ x for x in range ( num_shards ) if x // num_shards_per_group == y ] <TAB> <TAB> <TAB> for y in range ( num_groups ) <TAB> <TAB> ] <TAB> return tpu_ops. cross_replica_sum ( t, group_assignment ) / tf. cast ( <TAB> <TAB> num_shards_per_group, t. dtype <TAB> )",False,num_shards % num_shards_per_group != 0,num_shards_per_group == 0,0.6530584692955017
|
||
|
3884,"def run ( self ) : <TAB> self. _spawn ( ) <TAB> while True : <TAB> <TAB> ( rds, _, _ ) = select. select ( [ self. child. stdout, self. child. stderr ], [ ], [ ], 1 ) <TAB> <TAB> if self. child. stdout in rds : <TAB> <TAB> <TAB> line = self. child. stdout. readline ( ) <TAB> <TAB> <TAB> self. captured_stdout. append ( line. decode ( ""utf-8"" ). rstrip ( ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> line = self. child. stderr. readline ( ) <TAB> <TAB> <TAB> self. captured_stderr. append ( line. decode ( ""utf-8"" ). rstrip ( ) ) <TAB> <TAB> if self. child. poll ( ) is not None : <TAB> <TAB> <TAB> self. dump_logs ( ) <TAB> <TAB> <TAB> break <TAB> <TAB> if self. should_die. is_set ( ) : <TAB> <TAB> <TAB> self. _despawn ( ) <TAB> <TAB> <TAB> break",True,self.child.stderr in rds,self.child.stderr in rds,0.6546010971069336
|
||
|
3885,"def tearDown ( self ) : <TAB> """"""Shutdown the server."""""" <TAB> try : <TAB> <TAB> if self. server : <TAB> <TAB> <TAB> self. server. stop ( 2.0 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. root_logger. removeHandler ( self. sl_hdlr ) <TAB> <TAB> <TAB> self. sl_hdlr. close ( ) <TAB> finally : <TAB> <TAB> BaseTest. tearDown ( self )",False,self.sl_hdlr,self.root_logger,0.662135899066925
|
||
|
3886,"def __init__ ( self, handler ) : <TAB> self. handler = handler <TAB> self. headers = handler. headers <TAB> self. path = handler. path <TAB> self. head = False <TAB> self. url = urlparse ( self. path ) <TAB> try : <TAB> <TAB> length = int ( self. headers [ ""Content-Length"" ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. post = None <TAB> <TAB> else : <TAB> <TAB> <TAB> self. post = handler. rfile. read ( length ) <TAB> <TAB> <TAB> <TAB> except BaseException : <TAB> <TAB> self. post = None <TAB> self. bits = [ urllib. parse. unquote ( x ) for x in self. url. path. split ( ""/"" ) if x ] <TAB> self. query = parse_qs ( self. url. query ) <TAB> try : <TAB> <TAB> for k, v in self. query. items ( ) : <TAB> <TAB> <TAB> self. query [ k ] = v [ 0 ] <TAB> except BaseException : <TAB> <TAB> pass <TAB> self. user = None",False,not length,length > 0,0.6768758296966553
|
||
|
3887,"def _parse_version ( version : str ) -> PythonVersionInfo : <TAB> match = re. match ( r""(\d+)(?:\.(\d+)(?:\.\d+)?)?$"", version ) <TAB> if match is None : <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> ( <TAB> <TAB> <TAB> <TAB> ""The given version is not in the right format. "" <TAB> <TAB> <TAB> <TAB> + 'Use something like ""3.2"" or ""3"".' <TAB> <TAB> <TAB> ) <TAB> <TAB> ) <TAB> major = int ( match. group ( 1 ) ) <TAB> minor = match. group ( 2 ) <TAB> if minor is None : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if major == 2 : <TAB> <TAB> <TAB> minor = ""7"" <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> minor = ""6"" <TAB> <TAB> else : <TAB> <TAB> <TAB> raise NotImplementedError ( <TAB> <TAB> <TAB> <TAB> ""Sorry, no support yet for those fancy new/old versions."" <TAB> <TAB> <TAB> ) <TAB> minor = int ( minor ) <TAB> return PythonVersionInfo ( major, minor )",False,major == 3,major == 6,0.6767346858978271
|
||
|
3888,"def escape ( text, newline = False ) : <TAB> """"""Escape special html characters."""""" <TAB> if isinstance ( text, str ) : <TAB> <TAB> if ""&"" in text : <TAB> <TAB> <TAB> text = text. replace ( ""&"", ""&"" ) <TAB> <TAB> if "">"" in text : <TAB> <TAB> <TAB> text = text. replace ( "">"", "">"" ) <TAB> <TAB> if ""<"" in text : <TAB> <TAB> <TAB> text = text. replace ( ""<"", ""<"" ) <TAB> <TAB> if '""' in text : <TAB> <TAB> <TAB> text = text. replace ( '""', """"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> text = text. replace ( ""'"", """"" ) <TAB> <TAB> if newline : <TAB> <TAB> <TAB> if ""\n"" in text : <TAB> <TAB> <TAB> <TAB> text = text. replace ( ""\n"", ""<br>"" ) <TAB> return text",False,"""'"" in text","'""' in text",0.6692028045654297
|
||
|
3889,"def _process_out_of_bounds ( self, value, start, end ) : <TAB> ""Sets out of bounds values to None"" <TAB> if isinstance ( value, np. datetime64 ) : <TAB> <TAB> v = dt64_to_dt ( value ) <TAB> <TAB> if isinstance ( start, ( int, float ) ) : <TAB> <TAB> <TAB> start = convert_timestamp ( start ) <TAB> <TAB> if isinstance ( end, ( int, float ) ) : <TAB> <TAB> <TAB> end = convert_timestamp ( end ) <TAB> <TAB> s, e = start, end <TAB> <TAB> if isinstance ( s, np. datetime64 ) : <TAB> <TAB> <TAB> s = dt64_to_dt ( s ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> e = dt64_to_dt ( e ) <TAB> else : <TAB> <TAB> v, s, e = value, start, end <TAB> if v < s or v > e : <TAB> <TAB> value = None <TAB> return value",True,"isinstance(e, np.datetime64)","isinstance(e, np.datetime64)",0.6484342813491821
|
||
|
3890,"def _get_initialized_app ( app ) : <TAB> """"""Returns a reference to an initialized App instance."""""" <TAB> if app is None : <TAB> <TAB> return firebase_admin. get_app ( ) <TAB> if isinstance ( app, firebase_admin. App ) : <TAB> <TAB> initialized_app = firebase_admin. get_app ( app. name ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""Illegal app argument. App instance not "" <TAB> <TAB> <TAB> <TAB> ""initialized via the firebase module."" <TAB> <TAB> <TAB> ) <TAB> <TAB> return app <TAB> raise ValueError ( <TAB> <TAB> ""Illegal app argument. Argument must be of type "" <TAB> <TAB>'firebase_admin.App, but given ""{0}"".'. format ( type ( app ) ) <TAB> )",False,app is not initialized_app,initialized_app is None,0.6588306427001953
|
||
|
3891,"def _iter_lines ( path = path, response = response, max_next = options. http_max_next ) : <TAB> path. responses = [ ] <TAB> n = 0 <TAB> while response : <TAB> <TAB> path. responses. append ( response ) <TAB> <TAB> yield from response. iter_lines ( decode_unicode = True ) <TAB> <TAB> src = response. links. get ( ""next"", { } ). get ( ""url"", None ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> break <TAB> <TAB> n += 1 <TAB> <TAB> if n > max_next : <TAB> <TAB> <TAB> vd. warning ( f""stopping at max {max_next} pages"" ) <TAB> <TAB> <TAB> break <TAB> <TAB> vd. status ( f""fetching next page from {src}"" ) <TAB> <TAB> response = requests. get ( src, stream = True )",True,not src,not src,0.6894989013671875
|
||
|
3892,"def train ( config, inputs, args ) : <TAB> gan = setup_gan ( config, inputs, args ) <TAB> sampler = TrainingVideoFrameSampler ( gan ) <TAB> gan. selected_sampler = """" <TAB> samples = 0 <TAB> <TAB> <TAB> for i in range ( args. steps ) : <TAB> <TAB> gan. step ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> print ( ""saving "" + save_file ) <TAB> <TAB> <TAB> gan. save ( save_file ) <TAB> <TAB> if i % args. sample_every == 0 : <TAB> <TAB> <TAB> sample_file = ""samples/"" + args. config + ""/%06d.png"" % ( samples ) <TAB> <TAB> <TAB> os. makedirs ( os. path. expanduser ( os. path. dirname ( sample_file ) ), exist_ok = True ) <TAB> <TAB> <TAB> samples += 1 <TAB> <TAB> <TAB> sampler. sample ( sample_file, args. save_samples ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return [ ]",False,args.action == 'train' and i % args.save_every == 0 and (i > 0),args.save_samples == False,0.6525763273239136
|
||
|
3893,"def convertunit ( self, unit, prefix ) : <TAB> if self. ignorefunc : <TAB> <TAB> if self. ignorefunc ( unit ) : <TAB> <TAB> <TAB> return unit <TAB> if prefix. find ( ""@hash_placeholder@"" )!= - 1 : <TAB> <TAB> if unit. getlocations ( ) : <TAB> <TAB> <TAB> hashable = unit. getlocations ( ) [ 0 ] <TAB> <TAB> else : <TAB> <TAB> <TAB> hashable = unit. source <TAB> <TAB> prefix = prefix. replace ( <TAB> <TAB> <TAB> ""@hash_placeholder@"", md5 ( hashable ). hexdigest ( ) [ : self. hash_len ] <TAB> <TAB> ) <TAB> if unit. istranslated ( ) : <TAB> <TAB> rich_string = unit. rich_target <TAB> else : <TAB> <TAB> rich_string = unit. rich_source <TAB> if not isinstance ( rich_string, StringElem ) : <TAB> <TAB> rich_string = [ rich_parse ( string, podebug_parsers ) for string in rich_string ] <TAB> if self. rewritefunc : <TAB> <TAB> rewritten = [ self. rewritefunc ( string ) for string in rich_string ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> rich_string = rewritten <TAB> unit. rich_target = add_prefix ( prefix, rich_string ) <TAB> return unit",False,rewritten,"hasattr(prefix, 'rich_target')",0.6894533634185791
|
||
|
3894,"def add_target_and_index ( <TAB> self, name_obj : Tuple [ str, str ], sig : str, signode : desc_signature ) -> None : <TAB> mod_name = self. env. ref_context. get ( ""js:module"" ) <TAB> fullname = ( mod_name + ""."" if mod_name else """" ) + name_obj [ 0 ] <TAB> node_id = make_id ( self. env, self. state. document, """", fullname ) <TAB> signode [ ""ids"" ]. append ( node_id ) <TAB> <TAB> <TAB> old_node_id = self. make_old_id ( fullname ) <TAB> if old_node_id not in self. state. document. ids and old_node_id not in signode [ ""ids"" ] : <TAB> <TAB> signode [ ""ids"" ]. append ( old_node_id ) <TAB> self. state. document. note_explicit_target ( signode ) <TAB> domain = cast ( JavaScriptDomain, self. env. get_domain ( ""js"" ) ) <TAB> domain. note_object ( fullname, self. objtype, node_id, location = signode ) <TAB> if ""noindexentry"" not in self. options : <TAB> <TAB> indextext = self. get_index_text ( mod_name, name_obj ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. indexnode [ ""entries"" ]. append ( ( ""single"", indextext, node_id, """", None ) )",True,indextext,indextext,0.6693501472473145
|
||
|
3895,"def assertMultiLineEqual ( self, first, second, msg = None ) : <TAB> """"""Assert that two multi-line strings are equal."""""" <TAB> self. assertIsInstance ( first, str, ""First argument is not a string"" ) <TAB> self. assertIsInstance ( second, str, ""Second argument is not a string"" ) <TAB> if first!= second : <TAB> <TAB> <TAB> <TAB> if len ( first ) > self. _diffThreshold or len ( second ) > self. _diffThreshold : <TAB> <TAB> <TAB> self. _baseAssertEqual ( first, second, msg ) <TAB> <TAB> firstlines = first. splitlines ( keepends = True ) <TAB> <TAB> secondlines = second. splitlines ( keepends = True ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> firstlines = [ first + ""\n"" ] <TAB> <TAB> <TAB> secondlines = [ second + ""\n"" ] <TAB> <TAB> standardMsg = ""%s!= %s"" % _common_shorten_repr ( first, second ) <TAB> <TAB> diff = ""\n"" + """". join ( difflib. ndiff ( firstlines, secondlines ) ) <TAB> <TAB> standardMsg = self. _truncateMessage ( standardMsg, diff ) <TAB> <TAB> self. fail ( self. _formatMessage ( msg, standardMsg ) )",False,len(firstlines) == 1 and first.strip('\r\n') == first,keepends,0.6496038436889648
|
||
|
3896,"def check ( conf, token, prev, next, nextnext, context ) : <TAB> if ""stack"" not in context : <TAB> <TAB> context [ ""stack"" ] = [ ] <TAB> if isinstance ( token, ( yaml. BlockMappingStartToken, yaml. FlowMappingStartToken ) ) : <TAB> <TAB> context [ ""stack"" ]. append ( Parent ( MAP ) ) <TAB> elif isinstance ( token, ( yaml. BlockSequenceStartToken, yaml. FlowSequenceStartToken ) ) : <TAB> <TAB> context [ ""stack"" ]. append ( Parent ( SEQ ) ) <TAB> elif isinstance ( <TAB> <TAB> token, ( yaml. BlockEndToken, yaml. FlowMappingEndToken, yaml. FlowSequenceEndToken ) <TAB> ) : <TAB> <TAB> context [ ""stack"" ]. pop ( ) <TAB> elif isinstance ( token, yaml. KeyToken ) and isinstance ( next, yaml. ScalarToken ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if len ( context [ ""stack"" ] ) > 0 and context [ ""stack"" ] [ - 1 ]. type == MAP : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> yield LintProblem ( <TAB> <TAB> <TAB> <TAB> <TAB> next. start_mark. line + 1, <TAB> <TAB> <TAB> <TAB> <TAB> next. start_mark. column + 1, <TAB> <TAB> <TAB> <TAB> <TAB> 'wrong ordering of key ""%s"" in mapping' % next. value, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> context [ ""stack"" ] [ - 1 ]. keys. append ( next. value )",False,"any((strcoll(next.value, key) < 0 for key in context['stack'][-1].keys))",next is not None,0.6503562927246094
|
||
|
3897,"def gen_cli ( docs_dir ) : <TAB> with open ( os. path. join ( docs_dir, ""CLI_template.md"" ), ""r"" ) as cli_temp_file : <TAB> <TAB> temp_lines = cli_temp_file. readlines ( ) <TAB> lines = [ ] <TAB> for line in temp_lines : <TAB> <TAB> matched = re. match ( r""{onnx-tf.*}"", line ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> command = matched. string. strip ( ) [ 1 : - 1 ] <TAB> <TAB> <TAB> output = subprocess. check_output ( command. split ( "" "" ) ). decode ( ""UTF-8"" ) <TAB> <TAB> <TAB> lines. append ( output ) <TAB> <TAB> else : <TAB> <TAB> <TAB> lines. append ( line ) <TAB> with open ( os. path. join ( docs_dir, ""CLI.md"" ), ""w"" ) as cli_file : <TAB> <TAB> cli_file. writelines ( lines )",True,matched,matched,0.6802220344543457
|
||
|
3898,"def __init__ ( self, file ) : <TAB> logger. load_obj ( Dummy ( ) ) <TAB> self. conf = Config ( ) <TAB> buf = self. conf. read_config ( [ file ] ) <TAB> raw_objects = self. conf. read_config_buf ( buf ) <TAB> self. conf. create_objects_for_type ( raw_objects, ""arbiter"" ) <TAB> self. conf. create_objects_for_type ( raw_objects, ""module"" ) <TAB> self. conf. early_arbiter_linking ( ) <TAB> self. conf. create_objects ( raw_objects ) <TAB> for mod in self. conf. modules : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. mod_sqlite = get_instance_sqlite ( mod ) <TAB> <TAB> <TAB> self. mod_sqlite. init ( ) <TAB> <TAB> if mod. module_type == ""logstore_mongodb"" : <TAB> <TAB> <TAB> self. mod_mongodb = get_instance_mongodb ( mod )",True,mod.module_type == 'logstore_sqlite',mod.module_type == 'logstore_sqlite',0.6535748243331909
|
||
|
3899,"def attrgetter ( item ) : <TAB> items = [ None ] * len ( attribute ) <TAB> for i, attribute_part in enumerate ( attribute ) : <TAB> <TAB> item_i = item <TAB> <TAB> for part in attribute_part : <TAB> <TAB> <TAB> item_i = environment. getitem ( item_i, part ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> item_i = postprocess ( item_i ) <TAB> <TAB> items [ i ] = item_i <TAB> return items",True,postprocess is not None,postprocess is not None,0.6614655256271362
|
||
|
3900,"def set_related_perm ( _mapper : Mapper, _connection : Connection, target : Slice ) -> None : <TAB> src_class = target. cls_model <TAB> id_ = target. datasource_id <TAB> if id_ : <TAB> <TAB> ds = db. session. query ( src_class ). filter_by ( id = int ( id_ ) ). first ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> target. perm = ds. perm <TAB> <TAB> <TAB> target. schema_perm = ds. schema_perm",True,ds,ds,0.6816925406455994
|
||
|
3901,"def simulate ( self, data, asset, orders_for_asset ) : <TAB> self. _volume_for_bar = 0 <TAB> volume = data. current ( asset, ""volume"" ) <TAB> if volume == 0 : <TAB> <TAB> return <TAB> <TAB> <TAB> price = data. current ( asset, ""close"" ) <TAB> <TAB> <TAB> <TAB> <TAB> if isnull ( price ) : <TAB> <TAB> return <TAB> <TAB> dt = data. current_dt <TAB> for order in orders_for_asset : <TAB> <TAB> if order. open_amount == 0 : <TAB> <TAB> <TAB> continue <TAB> <TAB> order. check_triggers ( price, dt ) <TAB> <TAB> if not order. triggered : <TAB> <TAB> <TAB> continue <TAB> <TAB> txn = None <TAB> <TAB> try : <TAB> <TAB> <TAB> execution_price, execution_volume = self. process_order ( data, order ) <TAB> <TAB> <TAB> if execution_price is not None : <TAB> <TAB> <TAB> <TAB> txn = create_transaction ( <TAB> <TAB> <TAB> <TAB> <TAB> order, data. current_dt, execution_price, execution_volume <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> except LiquidityExceeded : <TAB> <TAB> <TAB> break <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _volume_for_bar += abs ( txn. amount ) <TAB> <TAB> <TAB> yield order, txn",True,txn,txn,0.698900580406189
|
||
|
3902,"def _handle ( self ) : <TAB> try : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. send_response ( 200 ) <TAB> <TAB> <TAB> self. set_common_headers ( ) <TAB> <TAB> <TAB> self. wfile. write ( json. dumps ( self. received_requests ). encode ( ""utf-8"" ) ) <TAB> <TAB> <TAB> return <TAB> <TAB> if self. is_valid_token ( ) and self. is_valid_user_agent ( ) : <TAB> <TAB> <TAB> self. send_response ( HTTPStatus. OK ) <TAB> <TAB> <TAB> self. set_common_headers ( ) <TAB> <TAB> <TAB> self. wfile. close ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. send_response ( HTTPStatus. BAD_REQUEST ) <TAB> <TAB> <TAB> self. set_common_headers ( ) <TAB> <TAB> <TAB> self. wfile. close ( ) <TAB> except Exception as e : <TAB> <TAB> self. logger. error ( str ( e ), exc_info = True ) <TAB> <TAB> raise",False,self.path == '/received_requests.json',self.received_requests is not None,0.6521310806274414
|
||
|
3903,"def format_listing ( <TAB> listing, json_output = False, human_readable = False, recursive = False, summary = False ) : <TAB> if json_output : <TAB> <TAB> for node in listing : <TAB> <TAB> <TAB> yield json. dumps ( node ) <TAB> else : <TAB> <TAB> nodes = [ ] <TAB> <TAB> last_dir = None <TAB> <TAB> try : <TAB> <TAB> <TAB> while True : <TAB> <TAB> <TAB> <TAB> node = listing. next ( ) <TAB> <TAB> <TAB> <TAB> dir_name = os. path. dirname ( node [ ""path"" ] ) <TAB> <TAB> <TAB> <TAB> if dir_name!= last_dir : <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> yield _create_dir_listing ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> nodes, human_readable, recursive, summary <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> last_dir = dir_name <TAB> <TAB> <TAB> <TAB> <TAB> nodes = [ ] <TAB> <TAB> <TAB> <TAB> nodes. append ( node ) <TAB> <TAB> except StopIteration : <TAB> <TAB> <TAB> yield _create_dir_listing ( nodes, human_readable, recursive, summary )",False,last_dir,nodes,0.6665686964988708
|
||
|
3904,"def hash_path_recursively ( path, ignorer = None, hasher = hashlib. sha1 ) : <TAB> checksum = hasher ( ) <TAB> size = 0 <TAB> if os. path. isdir ( path ) : <TAB> <TAB> tp = ""dir"" <TAB> <TAB> checksum. update ( b""DIR:\n"" ) <TAB> <TAB> for item in sorted ( os. listdir ( path ) ) : <TAB> <TAB> <TAB> fullpath = os. path. join ( path, item ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> item_res = hash_path_recursively ( fullpath, ignorer, hasher ) <TAB> <TAB> <TAB> if item_res [ ""type"" ] == ""dir"" and item_res [ ""size"" ] == 0 : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> digest = item_res [ ""checksum"" ]. digest ( ) <TAB> <TAB> <TAB> line = digest + b"" "" + item. encode ( ""utf-8"" ) + b""\n"" <TAB> <TAB> <TAB> checksum. update ( line ) <TAB> <TAB> <TAB> size += 1 <TAB> else : <TAB> <TAB> tp = ""file"" <TAB> <TAB> with open ( path, ""rb"" ) as fp : <TAB> <TAB> <TAB> data = b""FILE:\n"" <TAB> <TAB> <TAB> while data : <TAB> <TAB> <TAB> <TAB> checksum. update ( data ) <TAB> <TAB> <TAB> <TAB> data = fp. read ( 65536 ) <TAB> <TAB> <TAB> <TAB> size += len ( data ) <TAB> return { ""checksum"" : checksum, ""size"" : size, ""type"" : tp }",False,ignorer and ignorer(fullpath),not fullpath,0.662824273109436
|
||
|
3905,"def generic_info_hook ( state ) : <TAB> addr = state. solver. eval ( state. regs. ip ) <TAB> chall_resp_plugin = state. get_plugin ( ""chall_resp_info"" ) <TAB> format_info = chall_resp_plugin. format_infos [ addr ]. copy ( ) <TAB> if format_info. get_type ( ) == ""DontConstrain"" : <TAB> <TAB> arg_num = format_info. check_symbolic_arg <TAB> <TAB> arg = angr. calling_conventions. SimCCCdecl ( state. arch ). arg ( state, arg_num ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> l. warning ( ""symbolic arg not hooking"" ) <TAB> <TAB> <TAB> return <TAB> <TAB> if chall_resp_plugin. pending_info is not None : <TAB> <TAB> chall_resp_plugin. backup_pending_info. append ( <TAB> <TAB> <TAB> ( chall_resp_plugin. ret_addr_to_unhook, chall_resp_plugin. pending_info ) <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> state. project. unhook ( chall_resp_plugin. ret_addr_to_unhook ) <TAB> <TAB> chall_resp_plugin. ret_addr_to_unhook = None <TAB> <TAB> chall_resp_plugin. pending_info = None <TAB> <TAB> ret_addr = state. solver. eval ( state. memory. load ( state. regs. sp, 4, endness = ""Iend_LE"" ) ) <TAB> chall_resp_plugin. ret_addr_to_unhook = ret_addr <TAB> state. project. hook ( ret_addr, end_info_hook, length = 0 ) <TAB> format_info. compute ( state ) <TAB> chall_resp_plugin. pending_info = format_info <TAB> l. debug ( ""starting hook for %s at %#x"", format_info. func_name, format_info. addr )",False,state.mem[arg].string.resolved.symbolic,arg.l.debug(),0.6489238142967224
|
||
|
3906,"def handle_query ( self, query : str ) -> BaseAction : <TAB> if query == ""~"" : <TAB> <TAB> return SetUserQueryAction ( ""~/"" ) <TAB> path = Path ( query ) <TAB> result_items = [ ] <TAB> try : <TAB> <TAB> existing_dir = path. get_existing_dir ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> file_names = self. list_files ( path. get_abs_path ( ), sort_by_usage = True ) <TAB> <TAB> <TAB> for name in self. filter_dot_files ( file_names ) [ : self. RESULT_LIMIT ] : <TAB> <TAB> <TAB> <TAB> file = os. path. join ( existing_dir, name ) <TAB> <TAB> <TAB> <TAB> result_items. append ( self. create_result_item ( file ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> file_names = self. list_files ( existing_dir ) <TAB> <TAB> <TAB> search_for = path. get_search_part ( ) <TAB> <TAB> <TAB> if not search_for. startswith ( ""."" ) : <TAB> <TAB> <TAB> <TAB> file_names = self. filter_dot_files ( file_names ) <TAB> <TAB> <TAB> files = [ os. path. join ( existing_dir, name ) for name in file_names ] <TAB> <TAB> <TAB> result_items = SortedList ( search_for, min_score = 40, limit = self. RESULT_LIMIT ) <TAB> <TAB> <TAB> result_items. extend ( <TAB> <TAB> <TAB> <TAB> [ self. create_result_item ( name ) for name in reversed ( files ) ] <TAB> <TAB> <TAB> ) <TAB> except ( InvalidPathError, OSError ) : <TAB> <TAB> result_items = [ ] <TAB> return RenderResultListAction ( result_items )",False,existing_dir == path.get_abs_path(),existing_dir,0.650510311126709
|
||
|
3907,"def test_calculate_all_ctc_probs ( module, mtlalpha ) : <TAB> m = importlib. import_module ( module ) <TAB> args = make_arg ( mtlalpha = mtlalpha, asr_weight = 0.3 ) <TAB> if ""pytorch"" in module : <TAB> <TAB> batch = prepare_inputs ( ""pytorch"" ) <TAB> else : <TAB> <TAB> batch = prepare_inputs ( ""chainer"" ) <TAB> model = m. E2E ( 40, 5, args ) <TAB> with chainer. no_backprop_mode ( ) : <TAB> <TAB> if ""pytorch"" in module : <TAB> <TAB> <TAB> ctc_probs = model. calculate_all_ctc_probs ( * batch ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> print ( ctc_probs. shape ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> assert ctc_probs is None <TAB> <TAB> else : <TAB> <TAB> <TAB> raise NotImplementedError",False,mtlalpha > 0,ctc_probs is not None,0.6656359434127808
|
||
|
3908,"def _render_all_change_lines ( self, differ, old_lines, new_lines ) : <TAB> for tag, i1, i2, j1, j2 in differ. get_opcodes ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> lines = self. _render_change_lines ( <TAB> <TAB> <TAB> <TAB> differ, tag, None, None, i1, i2, old_lines <TAB> <TAB> <TAB> ) <TAB> <TAB> elif tag == ""insert"" : <TAB> <TAB> <TAB> lines = self. _render_change_lines ( differ, tag, None, ""+"", j1, j2, new_lines ) <TAB> <TAB> elif tag == ""delete"" : <TAB> <TAB> <TAB> lines = self. _render_change_lines ( differ, tag, ""-"", None, i1, i2, old_lines ) <TAB> <TAB> elif tag == ""replace"" : <TAB> <TAB> <TAB> lines = self. _render_change_replace_lines ( <TAB> <TAB> <TAB> <TAB> differ, i1, i2, j1, j2, old_lines, new_lines <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise ValueError ( 'Unexpected tag ""%s""' % tag ) <TAB> <TAB> for line in lines : <TAB> <TAB> <TAB> yield line",False,tag == 'equal',tag == 'expand',0.6578370332717896
|
||
|
3909,"def apply_mask ( self, mask, data_t, data_f ) : <TAB> ind_t, ind_f = 0, 0 <TAB> out = [ ] <TAB> for m in cycle ( mask ) : <TAB> <TAB> if m : <TAB> <TAB> <TAB> if ind_t == len ( data_t ) : <TAB> <TAB> <TAB> <TAB> return out <TAB> <TAB> <TAB> out. append ( data_t [ ind_t ] ) <TAB> <TAB> <TAB> ind_t += 1 <TAB> <TAB> else : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return out <TAB> <TAB> <TAB> out. append ( data_f [ ind_f ] ) <TAB> <TAB> <TAB> ind_f += 1 <TAB> return out",True,ind_f == len(data_f),ind_f == len(data_f),0.6546093225479126
|
||
|
3910,"def _on_frame_data ( self, data ) : <TAB> handled_future = None <TAB> self. _wire_bytes_in += len ( data ) <TAB> if self. _frame_opcode_is_control : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if not self. _final_frame : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _abort ( ) <TAB> <TAB> <TAB> return <TAB> <TAB> opcode = self. _frame_opcode <TAB> elif self. _frame_opcode == 0 : <TAB> <TAB> if self. _fragmented_message_buffer is None : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _abort ( ) <TAB> <TAB> <TAB> return <TAB> <TAB> self. _fragmented_message_buffer += data <TAB> <TAB> if self. _final_frame : <TAB> <TAB> <TAB> opcode = self. _fragmented_message_opcode <TAB> <TAB> <TAB> data = self. _fragmented_message_buffer <TAB> <TAB> <TAB> self. _fragmented_message_buffer = None <TAB> else : <TAB> <TAB> if self. _fragmented_message_buffer is not None : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _abort ( ) <TAB> <TAB> <TAB> return <TAB> <TAB> if self. _final_frame : <TAB> <TAB> <TAB> opcode = self. _frame_opcode <TAB> <TAB> else : <TAB> <TAB> <TAB> self. _fragmented_message_opcode = self. _frame_opcode <TAB> <TAB> <TAB> self. _fragmented_message_buffer = data <TAB> if self. _final_frame : <TAB> <TAB> handled_future = self. _handle_message ( opcode, data ) <TAB> if not self. client_terminated : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB>",False,handled_future,handled_future is not None,0.6683714389801025
|
||
|
3911,"def add_prop_to_socket ( self, socket, default_value ) : <TAB> try : <TAB> <TAB> self. halt_updates = True <TAB> <TAB> if default_value is not None : <TAB> <TAB> <TAB> if isinstance ( default_value, float ) : <TAB> <TAB> <TAB> <TAB> if not socket. use_prop or socket. default_property_type!= ""float"" : <TAB> <TAB> <TAB> <TAB> <TAB> socket. use_prop = True <TAB> <TAB> <TAB> <TAB> <TAB> socket. default_property_type = ""float"" <TAB> <TAB> <TAB> <TAB> <TAB> socket. default_float_property = default_value <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> if not socket. use_prop or socket. default_property_type!= ""int"" : <TAB> <TAB> <TAB> <TAB> <TAB> socket. use_prop = True <TAB> <TAB> <TAB> <TAB> <TAB> socket. default_property_type = ""int"" <TAB> <TAB> <TAB> <TAB> <TAB> socket. default_int_property = default_value <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> socket. use_prop = False <TAB> <TAB> else : <TAB> <TAB> <TAB> socket. use_prop = False <TAB> except : <TAB> <TAB> print ( ""some failure in the add_props_to_sockets function. ouch."" ) <TAB> self. halt_updates = False",False,"isinstance(default_value, int)","isinstance(default_value, str)",0.6497331857681274
|
||
|
3912,"def __saveCache ( self, file ) : <TAB> cache_file = None <TAB> try : <TAB> <TAB> temp = RopperService. CACHE_FOLDER <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> os. makedirs ( temp ) <TAB> <TAB> cache_file = temp + os. path. sep + self. __getCacheFileName ( file ) <TAB> <TAB> count = RopperService. CACHE_FILE_COUNT <TAB> <TAB> if not isWindows ( ) and len ( file. allGadgets ) > 1000 : <TAB> <TAB> <TAB> if os. path. exists ( cache_file ) : <TAB> <TAB> <TAB> <TAB> os. remove ( cache_file ) <TAB> <TAB> <TAB> length = len ( file. allGadgets ) <TAB> <TAB> <TAB> step = int ( length / count ) <TAB> <TAB> <TAB> for i in range ( count - 1 ) : <TAB> <TAB> <TAB> <TAB> gadgets = file. allGadgets [ i * step : ( i + 1 ) * step ] <TAB> <TAB> <TAB> <TAB> with open ( cache_file + ""_%d"" % ( i + 1 ), ""wb"" ) as f : <TAB> <TAB> <TAB> <TAB> <TAB> f. write ( encode ( repr ( gadgets ). encode ( ""ascii"" ), ""zip"" ) ) <TAB> <TAB> <TAB> gadgets = file. allGadgets [ ( count - 1 ) * step : ] <TAB> <TAB> <TAB> with open ( cache_file + ""_%d"" % ( count ), ""wb"" ) as f : <TAB> <TAB> <TAB> <TAB> f. write ( encode ( repr ( gadgets ). encode ( ""ascii"" ), ""zip"" ) ) <TAB> <TAB> <TAB> return <TAB> <TAB> with open ( cache_file, ""wb"" ) as f : <TAB> <TAB> <TAB> f. write ( encode ( repr ( file. allGadgets ). encode ( ""ascii"" ), ""zip"" ) ) <TAB>",True,not os.path.exists(temp),not os.path.exists(temp),0.6488783359527588
|
||
|
3913,"def _draw_number ( <TAB> screen, x_offset, y_offset, number, token = Token. Clock, transparent = False ) : <TAB> ""Write number at position."" <TAB> fg = Char ( "" "", token ) <TAB> bg = Char ( "" "", Token ) <TAB> for y, row in enumerate ( _numbers [ number ] ) : <TAB> <TAB> screen_row = screen. data_buffer [ y + y_offset ] <TAB> <TAB> for x, n in enumerate ( row ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> screen_row [ x + x_offset ] = fg <TAB> <TAB> <TAB> elif not transparent : <TAB> <TAB> <TAB> <TAB> screen_row [ x + x_offset ] = bg",False,n == '#',n,0.6756603717803955
|
||
|
3914,"def add ( self, tag, values ) : <TAB> if tag not in self. different : <TAB> <TAB> if tag not in self : <TAB> <TAB> <TAB> self [ tag ] = values <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> self. different. add ( tag ) <TAB> <TAB> <TAB> self [ tag ] = [ """" ] <TAB> self. counts [ tag ] += 1",False,self[tag] != values,tag in values,0.6605939865112305
|
||
|
3915,"def readframes ( self, nframes ) : <TAB> if self. _data_seek_needed : <TAB> <TAB> self. _data_chunk. seek ( 0, 0 ) <TAB> <TAB> pos = self. _soundpos * self. _framesize <TAB> <TAB> if pos : <TAB> <TAB> <TAB> self. _data_chunk. seek ( pos, 0 ) <TAB> <TAB> self. _data_seek_needed = 0 <TAB> if nframes == 0 : <TAB> <TAB> return """" <TAB> if self. _sampwidth in ( 2, 4 ) and sys. byteorder == ""big"" : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> import array <TAB> <TAB> chunk = self. _data_chunk <TAB> <TAB> data = array. array ( _array_fmts [ self. _sampwidth ] ) <TAB> <TAB> assert data. itemsize == self. _sampwidth <TAB> <TAB> nitems = nframes * self. _nchannels <TAB> <TAB> if nitems * self. _sampwidth > chunk. chunksize - chunk. size_read : <TAB> <TAB> <TAB> nitems = ( chunk. chunksize - chunk. size_read ) // self. _sampwidth <TAB> <TAB> data. fromfile ( chunk. file. file, nitems ) <TAB> <TAB> <TAB> <TAB> chunk. size_read = chunk. size_read + nitems * self. _sampwidth <TAB> <TAB> <TAB> <TAB> chunk = chunk. file <TAB> <TAB> chunk. size_read = chunk. size_read + nitems * self. _sampwidth <TAB> <TAB> data. byteswap ( ) <TAB> <TAB> data = data. tostring ( ) <TAB> else : <TAB> <TAB> data = self. _data_chunk. read ( nframes * self. _framesize ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> data = _byteswap3 ( data ) <TAB> if self. _convert and data : <TAB> <TAB> data =",False,self._sampwidth == 3 and sys.byteorder == 'big',self._convert and data,0.6538362503051758
|
||
|
3916,"def transform ( self, X, y = None ) : <TAB> if isinstance ( X, dict ) : <TAB> <TAB> for col, col_dict in self. column_ranges. items ( ) : <TAB> <TAB> <TAB> if col in X : <TAB> <TAB> <TAB> <TAB> X [ col ] = scale_val ( <TAB> <TAB> <TAB> <TAB> <TAB> val = X [ col ], <TAB> <TAB> <TAB> <TAB> <TAB> min_val = col_dict [ ""min_val"" ], <TAB> <TAB> <TAB> <TAB> <TAB> total_range = col_dict [ ""inner_range"" ], <TAB> <TAB> <TAB> <TAB> <TAB> truncate_large_values = self. truncate_large_values, <TAB> <TAB> <TAB> <TAB> ) <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> X = utils. safely_drop_columns ( X, self. cols_to_ignore ) <TAB> <TAB> for col, col_dict in self. column_ranges. items ( ) : <TAB> <TAB> <TAB> if col in X. columns : <TAB> <TAB> <TAB> <TAB> min_val = col_dict [ ""min_val"" ] <TAB> <TAB> <TAB> <TAB> inner_range = col_dict [ ""inner_range"" ] <TAB> <TAB> <TAB> <TAB> X [ col ] = X [ col ]. apply ( <TAB> <TAB> <TAB> <TAB> <TAB> lambda x : scale_val ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> x, min_val, inner_range, self. truncate_large_values <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> ) <TAB> return X",False,len(self.cols_to_ignore) > 0,self.cols_to_ignore,0.650653600692749
|
||
|
3917,"def load_session ( dic ) : <TAB> inst = bilibili. instance <TAB> for i in dic. keys ( ) : <TAB> <TAB> inst. dic_bilibili [ i ] = dic [ i ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> inst. dic_bilibili [ ""pcheaders"" ] [ ""cookie"" ] = dic [ i ] <TAB> <TAB> <TAB> inst. dic_bilibili [ ""appheaders"" ] [ ""cookie"" ] = dic [ i ]",False,i == 'cookie',i in 'pcheaders',0.672454833984375
|
||
|
3918,"def test_identity ( self ) : <TAB> for x in ( <TAB> <TAB> None, <TAB> <TAB> False, <TAB> <TAB> True, <TAB> <TAB> 12345, <TAB> <TAB> 123.45, <TAB> <TAB> ""abcde"", <TAB> <TAB> b""abcde"", <TAB> <TAB> datetime. datetime ( 2004, 10, 26, 10, 33, 33 ), <TAB> <TAB> plistlib. Data ( b""abcde"" ), <TAB> <TAB> bytearray ( b""abcde"" ), <TAB> <TAB> [ 12, 345 ], <TAB> <TAB> ( 12, 345 ), <TAB> <TAB> { ""12"" : 345 }, <TAB> ) : <TAB> <TAB> with self. subTest ( x = x ) : <TAB> <TAB> <TAB> data = plistlib. dumps ( [ x ] * 2, fmt = plistlib. FMT_BINARY ) <TAB> <TAB> <TAB> a, b = plistlib. loads ( data ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> x = list ( x ) <TAB> <TAB> <TAB> self. assertEqual ( a, x ) <TAB> <TAB> <TAB> self. assertEqual ( b, x ) <TAB> <TAB> <TAB> self. assertIs ( a, b )",False,"isinstance(x, tuple)",len(x) > 0,0.6495096683502197
|
||
|
3919,"def main ( <TAB> league, <TAB> time, <TAB> standings, <TAB> team, <TAB> live, <TAB> use12hour, <TAB> players, <TAB> output_format, <TAB> output_file, <TAB> upcoming, ) : <TAB> """"""A CLI for live and past football scores from various football leagues"""""" <TAB> try : <TAB> <TAB> if output_format == ""stdout"" and output_file : <TAB> <TAB> <TAB> raise IncorrectParametersException ( <TAB> <TAB> <TAB> <TAB> ""Printing output to stdout and "" <TAB> <TAB> <TAB> <TAB> ""saving to a file are mutually exclusive"" <TAB> <TAB> <TAB> ) <TAB> <TAB> writer = get_writer ( output_format, output_file ) <TAB> <TAB> if live : <TAB> <TAB> <TAB> get_live_scores ( writer, use12hour ) <TAB> <TAB> <TAB> return <TAB> <TAB> if standings : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise IncorrectParametersException ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Please specify a league. "" ""Example --standings --league=EPL"" <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> get_standings ( league, writer ) <TAB> <TAB> <TAB> return <TAB> <TAB> if team : <TAB> <TAB> <TAB> if players : <TAB> <TAB> <TAB> <TAB> get_team_players ( team, writer ) <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> get_team_scores ( team, time, writer, upcoming, use12hour ) <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> get_league_scores ( league, time, writer, upcoming, use12hour ) <TAB> except IncorrectParametersException as e : <TAB> <TAB>",False,not league,league is None,0.7011781334877014
|
||
|
3920,"def _handle_raise ( self, values, is_NAs, origins ) : <TAB> for is_NA, origin in zip ( is_NAs, origins ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> msg = ( <TAB> <TAB> <TAB> <TAB> ""Missing values detected. If you want rows with missing "" <TAB> <TAB> <TAB> <TAB> ""values to be automatically deleted in a list-wise "" <TAB> <TAB> <TAB> <TAB> ""manner (not recommended), please set dropna=True in "" <TAB> <TAB> <TAB> <TAB> ""the Bambi Model initialization."" <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> raise PatsyError ( msg, origin ) <TAB> return values",False,np.any(is_NA),values[0] is None or is_NA is False,0.6508210897445679
|
||
|
3921,"def parseArrayPattern ( self ) : <TAB> node = Node ( ) <TAB> elements = [ ] <TAB> self. expect ( ""["" ) <TAB> while not self. match ( ""]"" ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. lex ( ) <TAB> <TAB> <TAB> elements. append ( null ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if self. match ( ""..."" ) : <TAB> <TAB> <TAB> <TAB> restNode = Node ( ) <TAB> <TAB> <TAB> <TAB> self. lex ( ) <TAB> <TAB> <TAB> <TAB> rest = self. parseVariableIdentifier ( ) <TAB> <TAB> <TAB> <TAB> elements. append ( restNode. finishRestElement ( rest ) ) <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> elements. append ( self. parsePatternWithDefault ( ) ) <TAB> <TAB> <TAB> if not self. match ( ""]"" ) : <TAB> <TAB> <TAB> <TAB> self. expect ( "","" ) <TAB> self. expect ( ""]"" ) <TAB> return node. finishArrayPattern ( elements )",False,"self.match(',')",self.match(null),0.6488161087036133
|
||
|
3922,"def extract_within_coref ( self, mention : MentionData ) -> List [ str ] : <TAB> tokens = mention. tokens_number <TAB> within_coref_token = [ ] <TAB> for token_id in tokens : <TAB> <TAB> token_x_id = MentionData. static_gen_token_unique_id ( <TAB> <TAB> <TAB> str ( mention. doc_id ), str ( mention. sent_id ), str ( token_id ) <TAB> <TAB> ) <TAB> <TAB> if token_x_id in self. within_doc_coref_chain : <TAB> <TAB> <TAB> token_coref_chain = self. within_doc_coref_chain [ token_x_id ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> within_coref_token. append ( token_coref_chain ) <TAB> <TAB> else : <TAB> <TAB> <TAB> within_coref_token. append ( ""-"" ) <TAB> <TAB> <TAB> break <TAB> return within_coref_token",False,token_coref_chain,token_coref_chain is not None,0.6555942296981812
|
||
|
3923,"def do_schedule ( self ) : <TAB> if ( <TAB> <TAB> self. cur_thread. is_stop ( ) <TAB> <TAB> or self. ins_count % QlWindowsThreadManagement. TIME_SLICE == 0 <TAB> ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return <TAB> <TAB> else : <TAB> <TAB> <TAB> for i in range ( 1, len ( self. threads ) ) : <TAB> <TAB> <TAB> <TAB> next_id = ( self. cur_thread. id + i ) % len ( self. threads ) <TAB> <TAB> <TAB> <TAB> next_thread = self. threads [ next_id ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if next_thread. status == QlWindowsThread. RUNNING and ( <TAB> <TAB> <TAB> <TAB> <TAB> not next_thread. has_waitfor ( ) <TAB> <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> <TAB> if self. cur_thread. is_stop ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. cur_thread. suspend ( ) <TAB> <TAB> <TAB> <TAB> <TAB> next_thread. resume ( ) <TAB> <TAB> <TAB> <TAB> <TAB> self. cur_thread = next_thread <TAB> <TAB> <TAB> <TAB> <TAB> break",False,len(self.threads) <= 1,self.cur_thread.is_alive(),0.6619405746459961
|
||
|
3924,"def done ( self, result ) : <TAB> logger. debug ( ""Done"" ) <TAB> if result == 1 : <TAB> <TAB> page = self. currentPage ( ) <TAB> <TAB> if type ( page ) == PageProjectProperties : <TAB> <TAB> <TAB> venv = page. vtxtPlace. text ( ) <TAB> <TAB> <TAB> if venv : <TAB> <TAB> <TAB> <TAB> if sys. platform == ""win32"" : <TAB> <TAB> <TAB> <TAB> <TAB> venv = os. path. join ( venv, ""Scripts"", ""python.exe"" ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> venv = os. path. join ( venv, ""bin"", ""python"" ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> btnPressed = QMessageBox. information ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. tr ( ""Virtualenv Folder"" ), <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. tr ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""Folder don't exists or this is not a "" <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""valid Folder.\n If you want to set "" <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""or modify, go to project properties"" <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. tr ( ""Back"" ), <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. tr ( ""Continue"" ), <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB",False,not os.path.exists(venv),not self.hasOpen(),0.6477036476135254
|
||
|
3925,"def load_state_dict ( self, state_dict, strict = True ) : <TAB> """"""Customized load."""""" <TAB> self. language_model. load_state_dict ( <TAB> <TAB> state_dict [ self. _language_model_key ], strict = strict <TAB> ) <TAB> if mpu. is_pipeline_last_stage ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. multichoice_head. load_state_dict ( <TAB> <TAB> <TAB> <TAB> state_dict [ self. _multichoice_head_key ], strict = strict <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> print_rank_last ( <TAB> <TAB> <TAB> <TAB> ""***WARNING*** could not find {} in the checkpoint, "" <TAB> <TAB> <TAB> <TAB> ""initializing to random"". format ( self. _multichoice_head_key ) <TAB> <TAB> <TAB> )",False,self._multichoice_head_key in state_dict,self.multichoice_head is not None,0.6564022302627563
|
||
|
3926,"def closeEvent ( self, event : QCloseEvent ) : <TAB> if self. device. backend is not Backends. none : <TAB> <TAB> self. emit_editing_finished_signals ( ) <TAB> self. timer. stop ( ) <TAB> self. device. stop ( ""Dialog closed. Killing recording process."" ) <TAB> logger. debug ( ""Device stopped successfully."" ) <TAB> if not self. testing_mode : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> event. ignore ( ) <TAB> <TAB> <TAB> return <TAB> time. sleep ( 0.1 ) <TAB> if self. device. backend not in ( Backends. none, Backends. network ) : <TAB> <TAB> <TAB> <TAB> logger. debug ( ""Cleaning up device"" ) <TAB> <TAB> self. device. cleanup ( ) <TAB> <TAB> logger. debug ( ""Successfully cleaned up device"" ) <TAB> <TAB> self. device_settings_widget. emit_device_parameters_changed ( ) <TAB> settings. write ( ""{}/geometry"". format ( self. __class__. __name__ ), self. saveGeometry ( ) ) <TAB> if self. device is not None : <TAB> <TAB> self. device. free_data ( ) <TAB> self. scene_manager. eliminate ( ) <TAB> self. _eliminate_graphic_view ( ) <TAB> super ( ). closeEvent ( event )",False,not self.save_before_close(),self.device is not None,0.6529676914215088
|
||
|
3927,"def create ( self, defn, check, allow_reboot, allow_recreate ) : <TAB> self. no_subscription_id_change ( defn ) <TAB> self. no_property_change ( defn, ""dns_zone"" ) <TAB> self. no_property_change ( defn, ""record_type"" ) <TAB> self. copy_mgmt_credentials ( defn ) <TAB> self. dns_record_set_name = defn. dns_record_set_name <TAB> self. dns_zone = defn. dns_zone <TAB> self. record_type = defn. record_type <TAB> if check : <TAB> <TAB> rset = self. get_settled_resource ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. warn_missing_resource ( ) <TAB> <TAB> elif self. state == self. UP : <TAB> <TAB> <TAB> self. handle_changed_property ( ""tags"", rset [ ""tags"" ] ) <TAB> <TAB> <TAB> self. handle_changed_property ( ""properties"", rset [ ""properties"" ] ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. warn_not_supposed_to_exist ( ) <TAB> <TAB> <TAB> self. confirm_destroy ( ) <TAB> if self. state!= self. UP : <TAB> <TAB> if self. get_settled_resource ( ) : <TAB> <TAB> <TAB> raise Exception ( <TAB> <TAB> <TAB> <TAB> ""tried creating a DNS record set that already exists; "" <TAB> <TAB> <TAB> <TAB> ""please run 'deploy --check' to fix this"" <TAB> <TAB> <TAB> ) <TAB> <TAB> self. log ( ""creating {0}..."". format ( self. full_name ) ) <TAB> <TAB> self. _create_or_update ( defn ) <TAB> if self. properties_changed ( defn ) : <TAB> <TAB> self. log ( ""updating properties of {0}..."". format ( self. full_name ) ) <TAB>",False,not rset,rset is None,0.6759865283966064
|
||
|
3928,"def test_wdi_download_w_retired_indicator ( self ) : <TAB> cntry_codes = [ ""CA"", ""MX"", ""US"" ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> inds = [ ""GDPPCKD"" ] <TAB> with pytest. raises ( ValueError ) : <TAB> <TAB> result = download ( <TAB> <TAB> <TAB> country = cntry_codes, <TAB> <TAB> <TAB> indicator = inds, <TAB> <TAB> <TAB> start = 2003, <TAB> <TAB> <TAB> end = 2004, <TAB> <TAB> <TAB> errors = ""ignore"", <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> pytest. skip ( ""Invalid results"" )",False,len(result) > 0,len(result) != 0,0.6564669609069824
|
||
|
3929,"def canonicalize_instruction_name ( instr ) : <TAB> name = instr. insn_name ( ). upper ( ) <TAB> <TAB> if name == ""MOV"" : <TAB> <TAB> if instr. mnemonic. startswith ( ""lsr"" ) : <TAB> <TAB> <TAB> return ""LSR"" <TAB> <TAB> elif instr. mnemonic. startswith ( ""lsl"" ) : <TAB> <TAB> <TAB> return ""LSL"" <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> return ""ASR"" <TAB> return OP_NAME_MAP. get ( name, name )",False,instr.mnemonic.startswith('asr'),name == 'ASR',0.6596343517303467
|
||
|
3930,"def validate_pk ( self ) : <TAB> try : <TAB> <TAB> self. _key = serialization. load_pem_private_key ( <TAB> <TAB> <TAB> self. key, password = None, backend = default_backend ( ) <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> AWSValidationException ( <TAB> <TAB> <TAB> <TAB> ""The private key length is not supported. Only 1024-bit and 2048-bit are allowed."" <TAB> <TAB> <TAB> ) <TAB> except Exception as err : <TAB> <TAB> if isinstance ( err, AWSValidationException ) : <TAB> <TAB> <TAB> raise <TAB> <TAB> raise AWSValidationException ( <TAB> <TAB> <TAB> ""The private key is not PEM-encoded or is not valid."" <TAB> <TAB> )",False,self._key.key_size > 2048,len(self.key) > 1024 or len(self.key) > 2048,0.6550278663635254
|
||
|
3931,def tickframe ( self ) : <TAB> self. frame = ( self. frame + 1 ) % 8 <TAB> <TAB> if self. uselen and self. frame & 1 == 0 and self. lengthtimer > 0 : <TAB> <TAB> self. lengthtimer -= 1 <TAB> <TAB> if self. lengthtimer == 0 : <TAB> <TAB> <TAB> self. enable = False <TAB> <TAB> if self. frame == 7 and self. envelopetimer!= 0 : <TAB> <TAB> self. envelopetimer -= 1 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> newvolume = self. volume + ( self. envdir or - 1 ) <TAB> <TAB> <TAB> if newvolume < 0 or newvolume > 15 : <TAB> <TAB> <TAB> <TAB> self. envelopetimer = 0 <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. envelopetimer = self. envper <TAB> <TAB> <TAB> <TAB> self. volume = newvolume,False,self.envelopetimer == 0,self.volume,0.663364827632904
|
||
|
3932,"def cart_number_checksum_validation ( cls, number ) : <TAB> digits = [ ] <TAB> even = False <TAB> if not number. isdigit ( ) : <TAB> <TAB> return False <TAB> for digit in reversed ( number ) : <TAB> <TAB> digit = ord ( digit ) - ord ( ""0"" ) <TAB> <TAB> if even : <TAB> <TAB> <TAB> digit *= 2 <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> digit = digit % 10 + digit // 10 <TAB> <TAB> digits. append ( digit ) <TAB> <TAB> even = not even <TAB> return sum ( digits ) % 10 == 0 if digits else False",False,digit >= 10,even,0.6977077126502991
|
||
|
3933,"def getRenderingFor ( self, build ) : <TAB> value = build. render ( self. value ) <TAB> index = build. render ( self. index ) <TAB> value, index = yield defer. gatherResults ( [ value, index ] ) <TAB> if index not in value : <TAB> <TAB> rv = yield build. render ( self. default ) <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> rv = yield build. render ( value [ index ] ) <TAB> <TAB> <TAB> if not rv : <TAB> <TAB> <TAB> <TAB> rv = yield build. render ( self. default ) <TAB> <TAB> <TAB> elif self. hasKey!= _notHasKey : <TAB> <TAB> <TAB> <TAB> rv = yield build. render ( self. hasKey ) <TAB> <TAB> elif self. hasKey!= _notHasKey : <TAB> <TAB> <TAB> rv = yield build. render ( self. hasKey ) <TAB> <TAB> else : <TAB> <TAB> <TAB> rv = yield build. render ( value [ index ] ) <TAB> if rv is None : <TAB> <TAB> rv = yield build. render ( self. elideNoneAs ) <TAB> defer. returnValue ( rv )",False,self.defaultWhenFalse,index in value,0.6545971035957336
|
||
|
3934,"def read_until ( self, min_num_bytes, ending, timeout = 10, data_consumer = None ) : <TAB> <TAB> assert data_consumer is None or len ( ending ) == 1 <TAB> data = self. serial. read ( min_num_bytes ) <TAB> if<mask> : <TAB> <TAB> data_consumer ( data ) <TAB> timeout_count = 0 <TAB> while True : <TAB> <TAB> if data. endswith ( ending ) : <TAB> <TAB> <TAB> break <TAB> <TAB> elif self. serial. inWaiting ( ) > 0 : <TAB> <TAB> <TAB> new_data = self. serial. read ( 1 ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> data_consumer ( new_data ) <TAB> <TAB> <TAB> <TAB> data = new_data <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> data = data + new_data <TAB> <TAB> <TAB> timeout_count = 0 <TAB> <TAB> else : <TAB> <TAB> <TAB> timeout_count += 1 <TAB> <TAB> <TAB> if timeout is not None and timeout_count >= 100 * timeout : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> time. sleep ( 0.01 ) <TAB> return data",False,data_consumer,data_consumer is not None,0.6642252206802368
|
||
|
3935,"def clean_file_name ( self, c, ext, p ) : <TAB> """"""Compute the file name when subdirectories mirror the node's hierarchy in Leo."""""" <TAB> use_extentions = c. config. getBool ( ""open-with-uses-derived-file-extensions"" ) <TAB> ancestors, found = [ ], False <TAB> for p2 in p. self_and_parents ( copy = False ) : <TAB> <TAB> h = p2. anyAtFileNodeName ( ) <TAB> <TAB> if not h : <TAB> <TAB> <TAB> h = p2. h <TAB> <TAB> elif use_extentions and not found : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> found = True <TAB> <TAB> <TAB> base, ext2 = g. os_path_splitext ( h ) <TAB> <TAB> <TAB> if p2 == p : <TAB> <TAB> <TAB> <TAB> h = base <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> ext = ext2 <TAB> <TAB> ancestors. append ( g. sanitize_filename ( h ) ) <TAB> <TAB> ancestors. append ( ""Leo"" + str ( id ( p. v ) ) ) <TAB> <TAB> td = os. path. abspath ( tempfile. gettempdir ( ) ) <TAB> while len ( ancestors ) > 1 : <TAB> <TAB> td = os. path. join ( td, ancestors. pop ( ) ) <TAB> <TAB> if not os. path. exists ( td ) : <TAB> <TAB> <TAB> os. mkdir ( td ) <TAB> <TAB> name = ancestors. pop ( ) + ext <TAB> path = os. path. join ( td, name ) <TAB> return path",False,ext2,ext2 != None,0.6726727485656738
|
||
|
3936,"def get_usage_list ( self, start, end ) : <TAB> show_terminated = self. request. GET. get ( ""show_terminated"", self. show_terminated ) <TAB> instances = [ ] <TAB> terminated_instances = [ ] <TAB> usage = api. usage_get ( self. request, self. tenant_id, start, end ) <TAB> <TAB> if hasattr ( usage, ""server_usages"" ) : <TAB> <TAB> now = datetime. datetime. now ( ) <TAB> <TAB> for server_usage in usage. server_usages : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> server_uptime = server_usage [ ""uptime"" ] <TAB> <TAB> <TAB> total_uptime = now - datetime. timedelta ( seconds = server_uptime ) <TAB> <TAB> <TAB> server_usage [ ""uptime_at"" ] = total_uptime <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> terminated_instances. append ( server_usage ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> instances. append ( server_usage ) <TAB> usage. server_usages = instances <TAB> return ( usage, )",False,server_usage['ended_at'] and (not show_terminated),show_terminated,0.6477519273757935
|
||
|
3937,"def get_domain_ssl_files ( <TAB> domain, ssl_certificates, env, allow_missing_cert = False, use_main_cert = True ) : <TAB> if use_main_cert or not allow_missing_cert : <TAB> <TAB> <TAB> <TAB> ssl_private_key = os. path. join ( <TAB> <TAB> <TAB> os. path. join ( env [ ""STORAGE_ROOT"" ], ""ssl"", ""ssl_private_key.pem"" ) <TAB> <TAB> ) <TAB> <TAB> ssl_certificate = os. path. join ( <TAB> <TAB> <TAB> os. path. join ( env [ ""STORAGE_ROOT"" ], ""ssl"", ""ssl_certificate.pem"" ) <TAB> <TAB> ) <TAB> <TAB> system_certificate = { <TAB> <TAB> <TAB> ""private-key"" : ssl_private_key, <TAB> <TAB> <TAB> ""certificate"" : ssl_certificate, <TAB> <TAB> <TAB> ""primary-domain"" : env [ ""PRIMARY_HOSTNAME"" ], <TAB> <TAB> <TAB> ""certificate_object"" : load_pem ( load_cert_chain ( ssl_certificate ) [ 0 ] ), <TAB> <TAB> } <TAB> if use_main_cert : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return system_certificate <TAB> wildcard_domain = re. sub ( ""^[^\.]+"", ""*"", domain ) <TAB> if domain in ssl_certificates : <TAB> <TAB> return ssl_certificates [ domain ] <TAB> elif wildcard_domain in ssl_certificates : <TAB> <TAB> return ssl_certificates [ wildcard_domain ] <TAB> elif not allow_missing_cert : <TAB> <TAB> <TAB> <TAB> return system_certificate <TAB> else : <TAB> <TAB> <TAB> <TAB> return None",False,domain == env['PRIMARY_HOSTNAME'],domain in ssl_certificates,0.6521974802017212
|
||
|
3938,"def accept_handler ( fd : socket. socket, events : int ) -> None : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for i in range ( _DEFAULT_BACKLOG ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> try : <TAB> <TAB> <TAB> connection, address = sock. accept ( ) <TAB> <TAB> except BlockingIOError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> except ConnectionAbortedError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> callback ( connection, address )",False,removed[0],events & 1,0.6726330518722534
|
||
|
3939,"def __repr__ ( self ) : <TAB> attrs = [ ] <TAB> for k in self. keydata : <TAB> <TAB> if k == ""p"" : <TAB> <TAB> <TAB> attrs. append ( ""p(%d)"" % ( self. size ( ) + 1, ) ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> attrs. append ( k ) <TAB> if self. has_private ( ) : <TAB> <TAB> attrs. append ( ""private"" ) <TAB> return ""<%s @0x%x %s>"" % ( self. __class__. __name__, id ( self ), "","". join ( attrs ) )",False,"hasattr(self.key, k)",k == 'k',0.6577895879745483
|
||
|
3940,"def _verifySubs ( self ) : <TAB> for inst in self. subs : <TAB> <TAB> if not isinstance ( inst, ( _Block, _Instantiator, Cosimulation ) ) : <TAB> <TAB> <TAB> raise BlockError ( _error. ArgType % ( self. name, ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if not inst. modctxt : <TAB> <TAB> <TAB> <TAB> raise BlockError ( _error. InstanceError % ( self. name, inst. callername ) )",False,"isinstance(inst, (_Block, _Instantiator))",inst.argid,0.6546672582626343
|
||
|
3941,"def sleep ( ) : <TAB> if isinstance ( seconds, float ) : <TAB> <TAB> time. sleep ( seconds ) <TAB> elif isinstance ( seconds, basestring ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> time. sleep ( <TAB> <TAB> <TAB> <TAB> random. uniform ( <TAB> <TAB> <TAB> <TAB> <TAB> float ( seconds. split ( ""-"" ) [ 0 ] ), float ( seconds. split ( ""-"" ) [ 1 ] ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> time. sleep ( float ( seconds ) )",False,'-' in seconds,seconds >= '-',0.679764986038208
|
||
|
3942,"def _tab_focus_stack ( self, mode : str, *, show_error : bool = True ) -> None : <TAB> """"""Select the tab which was last focused."""""" <TAB> tab_deque = self. _tabbed_browser. tab_deque <TAB> cur_tab = self. _cntwidget ( ) <TAB> try : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> tab = tab_deque. last ( cur_tab ) <TAB> <TAB> elif mode == ""stack-prev"" : <TAB> <TAB> <TAB> tab = tab_deque. prev ( cur_tab ) <TAB> <TAB> elif mode == ""stack-next"" : <TAB> <TAB> <TAB> tab = tab_deque. next ( cur_tab ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise utils. Unreachable ( ""Missing implementation for stack mode!"" ) <TAB> except IndexError : <TAB> <TAB> if not show_error : <TAB> <TAB> <TAB> return <TAB> <TAB> raise cmdutils. CommandError ( ""Could not find requested tab!"" ) <TAB> idx = self. _tabbed_browser. widget. indexOf ( tab ) <TAB> if idx == - 1 : <TAB> <TAB> raise cmdutils. CommandError ( ""Requested tab vanished!"" ) <TAB> self. _set_current_index ( idx )",False,mode == 'last',mode == 'stack-last',0.6606627106666565
|
||
|
3943,"def __pathToEditor ( self, editor ) : <TAB> path = [ ] <TAB> child = editor <TAB> parent = child. parent ( ) <TAB> while parent is not None : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> path. append ( ""c"" ) <TAB> <TAB> <TAB> break <TAB> <TAB> elif isinstance ( parent, _DetachedPanel ) : <TAB> <TAB> <TAB> path. append ( str ( self. __detachedPanels. index ( parent ) ) ) <TAB> <TAB> <TAB> path. append ( ""p"" ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> path. append ( str ( parent. index ( child ) ) ) <TAB> <TAB> child = parent <TAB> <TAB> parent = child. parent ( ) <TAB> <TAB> path. reverse ( ) <TAB> <TAB> return ""-"". join ( path )",False,"isinstance(parent, GafferUI.CompoundEditor)",parent == child,0.6511542201042175
|
||
|
3944,"def _temp_connection_check ( self, rid, temp_conn, db_row, types, dependents ) : <TAB> if temp_conn. connected ( ) : <TAB> <TAB> query = render_template ( <TAB> <TAB> <TAB> ""/"". join ( [ self. sql_path, ""dependents.sql"" ] ), <TAB> <TAB> <TAB> fetch_dependents = True, <TAB> <TAB> <TAB> rid = rid, <TAB> <TAB> <TAB> lastsysoid = db_row [ ""datlastsysoid"" ], <TAB> <TAB> ) <TAB> <TAB> status, result = temp_conn. execute_dict ( query ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> current_app. logger. error ( result ) <TAB> <TAB> RoleView. _handle_dependents_data ( result, types, dependents, db_row )",False,not status,status != 0,0.6738032698631287
|
||
|
3945,"def __init__ ( self, data = None, dataset = None, device = None ) : <TAB> """"""Create a Batch from a list of examples."""""" <TAB> if data is not None : <TAB> <TAB> self. batch_size = len ( data ) <TAB> <TAB> self. dataset = dataset <TAB> <TAB> self. fields = dataset. fields. keys ( ) <TAB> <TAB> self. input_fields = [ <TAB> <TAB> <TAB> k for k, v in dataset. fields. items ( ) if v is not None and not v. is_target <TAB> <TAB> ] <TAB> <TAB> self. target_fields = [ <TAB> <TAB> <TAB> k for k, v in dataset. fields. items ( ) if v is not None and v. is_target <TAB> <TAB> ] <TAB> <TAB> for ( name, field ) in dataset. fields. items ( ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> batch = [ getattr ( x, name ) for x in data ] <TAB> <TAB> <TAB> <TAB> setattr ( self, name, field. process ( batch, device = device ) )",False,field is not None,data is not None,0.662406861782074
|
||
|
3946,"def iter_GEN ( name ) : <TAB> st = 0 <TAB> for line in io. open ( name, ""rt"", encoding = ""utf-8"" ) : <TAB> <TAB> line = line. strip ( ) <TAB> <TAB> splitted = line. split ( ""#"", 1 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if splitted [ 0 ]!= """" : <TAB> <TAB> <TAB> <TAB> yield ( False, splitted [ 0 ], st ) <TAB> <TAB> else : <TAB> <TAB> <TAB> testcase, comment = splitted <TAB> <TAB> <TAB> is_trivial = comment. startswith ( "" "" ) <TAB> <TAB> <TAB> testcase = testcase. strip ( ) <TAB> <TAB> <TAB> comment = comment. strip ( ) <TAB> <TAB> <TAB> testcase_detected = len ( testcase ) > 0 <TAB> <TAB> <TAB> copy_testcase_detected = comment. startswith ( ""COPY:"" ) <TAB> <TAB> <TAB> subtask_detected = comment. startswith ( ""ST:"" ) <TAB> <TAB> <TAB> flags = [ testcase_detected, copy_testcase_detected, subtask_detected ] <TAB> <TAB> <TAB> flags_count = len ( [ x for x in flags if x ] ) <TAB> <TAB> <TAB> if flags_count > 1 : <TAB> <TAB> <TAB> <TAB> raise Exception ( ""No testcase and command in"" "" the same line allowed"" ) <TAB> <TAB> <TAB> if flags_count == 0 and not is_trivial : <TAB> <TAB> <TAB> <TAB> raise Exception ( ""Unrecognized non-trivial line"" ) <TAB> <TAB> <TAB> if testcase_detected : <TAB> <TAB> <TAB> <TAB> yield ( False, testcase, st ) <TAB> <TAB> <TAB> if copy_testcase_detected : <TAB> <TAB> <TAB> <TAB> yield ( True, comment [ 5 : ]. strip",False,len(splitted) == 1,len(splitted) > 0,0.6603318452835083
|
||
|
3947,"def __iadd__ ( self, addend ) : <TAB> if isinstance ( addend, COEFFICIENT_TYPES ) : <TAB> <TAB> self. constant += addend <TAB> <TAB> return self <TAB> if not issubclass ( type ( addend ), PolynomialTensor ) : <TAB> <TAB> raise TypeError ( ""Invalid type."" ) <TAB> if self. n_qubits!= addend. n_qubits : <TAB> <TAB> raise TypeError ( ""Invalid tensor shape."" ) <TAB> for key in addend. n_body_tensors : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. n_body_tensors [ key ] = numpy. add ( <TAB> <TAB> <TAB> <TAB> self. n_body_tensors [ key ], addend. n_body_tensors [ key ] <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. n_body_tensors [ key ] = addend. n_body_tensors [ key ] <TAB> return self",True,key in self.n_body_tensors,key in self.n_body_tensors,0.6566682457923889
|
||
|
3948,"def rollback ( self ) : <TAB> for operation, values in self. current_transaction_state [ : : - 1 ] : <TAB> <TAB> if operation == ""insert"" : <TAB> <TAB> <TAB> values. remove ( ) <TAB> <TAB> elif operation == ""update"" : <TAB> <TAB> <TAB> old_value, new_value = values <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> os. unlink ( new_value. full_filename ) <TAB> <TAB> <TAB> old_value. write ( ) <TAB> self. _post_xact_cleanup ( )",False,new_value.full_filename != old_value.full_filename,new_value.is_file(),0.6495531797409058
|
||
|
3949,"def _copy_device_array_to_device ( <TAB> x : DeviceArray, device : Optional [ xc. Device ] ) -> DeviceArray : <TAB> if device is None : <TAB> <TAB> <TAB> <TAB> return x <TAB> elif is_device_constant ( x ) : <TAB> <TAB> <TAB> <TAB> return DeviceArray ( x. aval, device, x. _lazy_expr, DeviceConstant ( device ) ) <TAB> elif xb. get_device_backend ( device ). platform == x. device_buffer. platform ( ) : <TAB> <TAB> <TAB> <TAB> if x. device_buffer. device ( ) == device : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return x <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> moved_buf = x. device_buffer <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> moved_buf = x. device_buffer. copy_to_device ( device ) <TAB> else : <TAB> <TAB> <TAB> <TAB> backend = xb. get_device_backend ( device ) <TAB> <TAB> moved_buf = backend. buffer_from_pyval ( x. device_buffer. to_py ( ), device ) <TAB> return DeviceArray ( x. aval, device, x. _lazy_expr, moved_buf )",False,x._device == device,moved_buf is None,0.6686573028564453
|
||
|
3950,"def handle ( self, * args, ** options ) : <TAB> try : <TAB> <TAB> role_names = [ <TAB> <TAB> <TAB> settings. ROLE_PROJECT_ADMIN, <TAB> <TAB> <TAB> settings. ROLE_ANNOTATOR, <TAB> <TAB> <TAB> settings. ROLE_ANNOTATION_APPROVER, <TAB> <TAB> ] <TAB> except KeyError as key_error : <TAB> <TAB> self. stderr. write ( self. style. ERROR ( f'Missing Key: ""{key_error}""' ) ) <TAB> for role_name in role_names : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> role = Role ( ) <TAB> <TAB> role. name = role_name <TAB> <TAB> try : <TAB> <TAB> <TAB> role. save ( ) <TAB> <TAB> except DatabaseError as db_error : <TAB> <TAB> <TAB> self. stderr. write ( self. style. ERROR ( f'Database Error: ""{db_error}""' ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. stdout. write ( <TAB> <TAB> <TAB> <TAB> self. style. SUCCESS ( f'Role created successfully ""{role_name}""' ) <TAB> <TAB> <TAB> )",False,Role.objects.filter(name=role_name).exists(),role_name == '',0.651489794254303
|
||
|
3951,"def ls ( self, * path ) : <TAB> success = True <TAB> cur = self <TAB> for name in path : <TAB> <TAB> if not name or name == ""."" : <TAB> <TAB> <TAB> continue <TAB> <TAB> elif name == "".."" : <TAB> <TAB> <TAB> if cur. parent : <TAB> <TAB> <TAB> <TAB> cur = cur. parent <TAB> <TAB> else : <TAB> <TAB> <TAB> child = cur. find_child ( name ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> cur = child <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> success = False <TAB> <TAB> <TAB> <TAB> break <TAB> if success : <TAB> <TAB> for node in sorted ( cur. children ) : <TAB> <TAB> <TAB> yield node",True,child,child,0.6960253715515137
|
||
|
3952,"def _method_events_callback ( self, values ) : <TAB> try : <TAB> <TAB> previous_echoed = ( <TAB> <TAB> <TAB> values [ ""child_result_list"" ] [ - 1 ]. decode ( ). split ( ""\n"" ) [ - 2 ]. strip ( ) <TAB> <TAB> ) <TAB> <TAB> if previous_echoed. endswith ( ""foo1"" ) : <TAB> <TAB> <TAB> return ""echo foo2\n"" <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> return ""echo foo3\n"" <TAB> <TAB> elif previous_echoed. endswith ( ""foo3"" ) : <TAB> <TAB> <TAB> return ""exit\n"" <TAB> <TAB> else : <TAB> <TAB> <TAB> raise Exception ( ""Unexpected output {0!r}"". format ( previous_echoed ) ) <TAB> except IndexError : <TAB> <TAB> return ""echo foo1\n""",False,previous_echoed.endswith('foo2'),"previous_echoed.ends( ""foo2')",0.6497566103935242
|
||
|
3953,"def main ( ) : <TAB> ( <TAB> <TAB> filename, <TAB> <TAB> start_line_str, <TAB> <TAB> start_col_str, <TAB> <TAB> end_line_str, <TAB> <TAB> end_col_str, <TAB> <TAB> * mypy_and_args, <TAB> ) = sys. argv [ 1 : ] <TAB> start_line = int ( start_line_str ) <TAB> start_col = int ( start_col_str ) <TAB> end_line = int ( end_line_str ) <TAB> end_col = int ( end_col_str ) <TAB> with open ( filename, ""r"" ) as f : <TAB> <TAB> lines = f. readlines ( ) <TAB> <TAB> lines [ end_line - 1 ] = update_line ( <TAB> <TAB> <TAB> lines [ end_line - 1 ], REVEAL_TYPE_END, end_col <TAB> <TAB> ) <TAB> <TAB> lines [ start_line - 1 ] = update_line ( <TAB> <TAB> <TAB> lines [ start_line - 1 ], REVEAL_TYPE_START, start_col <TAB> <TAB> ) <TAB> <TAB> with tempfile. NamedTemporaryFile ( mode = ""w"", prefix = ""mypy"" ) as tmp_f : <TAB> <TAB> <TAB> tmp_f. writelines ( lines ) <TAB> <TAB> <TAB> tmp_f. flush ( ) <TAB> <TAB> <TAB> output = run_mypy ( mypy_and_args, filename, tmp_f. name ) <TAB> <TAB> <TAB> revealed_type, error = process_output ( output, filename, start_line ) <TAB> <TAB> <TAB> if revealed_type : <TAB> <TAB> <TAB> <TAB> print ( revealed_type ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> print ( output ) <TAB> <TAB> <TAB> exit ( int ( error ) )",True,error,error,0.6858798265457153
|
||
|
3954,"def get_param ( node ) : <TAB> edges = defaultdict ( list ) <TAB> for edge in node. findall ( ""Edge"" ) : <TAB> <TAB> if edge. find ( ""Terminal"" ) is not None : <TAB> <TAB> <TAB> edges [ edge. get ( ""val"" ) ] = edge. find ( ""Terminal"" ). text <TAB> <TAB> elif edge. find ( ""Node"" ) is not None : <TAB> <TAB> <TAB> node_cpd = defaultdict ( list ) <TAB> <TAB> <TAB> node_cpd [ edge. find ( ""Node"" ). get ( ""var"" ) ] = get_param ( edge. find ( ""Node"" ) ) <TAB> <TAB> <TAB> edges [ edge. get ( ""val"" ) ] = node_cpd <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> subdag_attribute = defaultdict ( list ) <TAB> <TAB> <TAB> subdag_attribute [ ""type"" ] = edge. find ( ""SubDAG"" ). get ( ""type"" ) <TAB> <TAB> <TAB> if subdag_attribute [ ""type"" ] == ""template"" : <TAB> <TAB> <TAB> <TAB> subdag_attribute [ ""idref"" ] = edge. find ( ""SubDAG"" ). get ( ""idref"" ) <TAB> <TAB> <TAB> if edge. find ( ""SubDAG"" ). get ( ""var"" ) : <TAB> <TAB> <TAB> <TAB> subdag_attribute [ ""var"" ] = edge. find ( ""SubDAG"" ). get ( ""var"" ) <TAB> <TAB> <TAB> if edge. find ( ""SubDAG"" ). get ( ""val"" ) : <TAB> <TAB> <TAB> <TAB> subdag_attribute [ ""val"" ] = edge. find ( ""SubDAG"" ). get ( ""val"" ) <TAB> <TAB> <TAB> edges [ edge. get ( ""val"" ) ] = subdag_attribute <TAB> return edges",True,edge.find('SubDAG') is not None,edge.find('SubDAG') is not None,0.652458906173706
|
||
|
3955,"def _find_mini_cluster_jar ( self, path ) : <TAB> for dirpath, dirnames, filenames in os. walk ( path ) : <TAB> <TAB> for files in filenames : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return os. path. join ( dirpath, files )",False,"re.match('.*hadoop-mapreduce-client-jobclient.+-tests.jar', files)",len(files) > 0,0.6438804864883423
|
||
|
3956,"def WriteMacBundleResources ( self, resources, bundle_depends ) : <TAB> """"""Writes ninja edges for'mac_bundle_resources'."""""" <TAB> xcassets = [ ] <TAB> extra_env = self. xcode_settings. GetPerTargetSettings ( ) <TAB> env = self. GetSortedXcodeEnv ( additional_settings = extra_env ) <TAB> env = self. ComputeExportEnvString ( env ) <TAB> isBinary = self. xcode_settings. IsBinaryOutputFormat ( self. config_name ) <TAB> for output, res in gyp. xcode_emulation. GetMacBundleResources ( <TAB> <TAB> generator_default_variables [ ""PRODUCT_DIR"" ], <TAB> <TAB> self. xcode_settings, <TAB> <TAB> map ( self. GypPathToNinja, resources ), <TAB> ) : <TAB> <TAB> output = self. ExpandSpecial ( output ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. ninja. build ( <TAB> <TAB> <TAB> <TAB> output, <TAB> <TAB> <TAB> <TAB> ""mac_tool"", <TAB> <TAB> <TAB> <TAB> res, <TAB> <TAB> <TAB> <TAB> variables = [ <TAB> <TAB> <TAB> <TAB> <TAB> ( ""mactool_cmd"", ""copy-bundle-resource"" ), <TAB> <TAB> <TAB> <TAB> <TAB> ( ""env"", env ), <TAB> <TAB> <TAB> <TAB> <TAB> ( ""binary"", isBinary ), <TAB> <TAB> <TAB> <TAB> ], <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> bundle_depends. append ( output ) <TAB> <TAB> else : <TAB> <TAB> <TAB> xcassets. append ( res ) <TAB> return xcassets",False,os.path.splitext(output)[-1] != '.xcassets',self.hasMacBundle,0.6487319469451904
|
||
|
3957,"def _doc_module ( self, module, filters, exclusive ) : <TAB> """"""Extract config options from module."""""" <TAB> options = [ ] <TAB> try : <TAB> <TAB> mod = importlib. import_module ( module ) <TAB> <TAB> for prop in dir ( mod ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if exclusive and prop not in exclusive : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> thing = getattr ( mod, prop ) <TAB> <TAB> <TAB> if isinstance ( thing, cfg. Opt ) and thing not in options : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> options. append ( thing ) <TAB> <TAB> <TAB> elif ( <TAB> <TAB> <TAB> <TAB> isinstance ( thing, list ) <TAB> <TAB> <TAB> <TAB> and len ( thing ) > 0 <TAB> <TAB> <TAB> <TAB> and isinstance ( thing [ 0 ], cfg. Opt ) <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> options. extend ( thing ) <TAB> except Exception as e : <TAB> <TAB> self. error ( ""Unable to import {}: {}"". format ( module, e ) ) <TAB> return options",False,prop in filters,filters and prop not in filters,0.681423544883728
|
||
|
3958,"def summary ( self ) -> str : <TAB> recorded_stats = { } <TAB> output_string = """" <TAB> local_rank = ""0"" if self. local_rank is None else self. local_rank <TAB> if not self. enabled : <TAB> <TAB> return output_string <TAB> for action_name, function_events in self. profiled_actions. items ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> function_events. populate_cpu_children = lambda : None <TAB> <TAB> if self. export_to_chrome : <TAB> <TAB> <TAB> filename = f""{action_name}_{local_rank}_trace.json"" <TAB> <TAB> <TAB> path_to_trace = ( <TAB> <TAB> <TAB> <TAB> filename <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> else os. path. join ( self. path_to_export_trace, filename ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> function_events. export_chrome_trace ( path_to_trace ) <TAB> <TAB> if self. emit_nvtx : <TAB> <TAB> <TAB> return output_string <TAB> <TAB> else : <TAB> <TAB> <TAB> data = function_events. key_averages ( <TAB> <TAB> <TAB> <TAB> group_by_input_shapes = self. group_by_input_shapes <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> table = data. table ( sort_by = self. sort_by_key, row_limit = self. row_limit ) <TAB> <TAB> <TAB> recorded_stats [ action_name ] = table <TAB> <TAB> output_string = f""{os.linesep}Profiler Report{os.linesep}"" <TAB> for action, stats in recorded_stats. items ( ) : <TAB> <TAB> output_string += f""{os.linesep}Profile stats for: {action} rank: {local_rank} {os.linesep}{stats}""",False,self.path_to_export_trace is None,self.path_to_export_trace,0.6506867408752441
|
||
|
3959,"def parse ( self ) -> _NodeT : <TAB> <TAB> if self. __was_parse_called : <TAB> <TAB> raise Exception ( ""Each parser object may only be used to parse once."" ) <TAB> self. __was_parse_called = True <TAB> for token in self. tokens : <TAB> <TAB> self. _add_token ( token ) <TAB> while True : <TAB> <TAB> tos = self. stack [ - 1 ] <TAB> <TAB> if not tos. dfa. is_final : <TAB> <TAB> <TAB> expected_str = get_expected_str ( EOFSentinel. EOF, tos. dfa. transitions. keys ( ) ) <TAB> <TAB> <TAB> raise ParserSyntaxError ( <TAB> <TAB> <TAB> <TAB> f""Incomplete input. {expected_str}"", <TAB> <TAB> <TAB> <TAB> lines = self. lines, <TAB> <TAB> <TAB> <TAB> raw_line = len ( self. lines ), <TAB> <TAB> <TAB> <TAB> raw_column = len ( self. lines [ - 1 ] ), <TAB> <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _pop ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return self. convert_nonterminal ( tos. nonterminal, tos. nodes )",False,len(self.stack) > 1,self.has_last_token(),0.6496908664703369
|
||
|
3960,"def _parse_apt_operations ( help_text_lines ) : <TAB> is_commands_list = False <TAB> for line in help_text_lines : <TAB> <TAB> line = line. decode ( ). strip ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> yield line. split ( ) [ 0 ] <TAB> <TAB> elif line. startswith ( ""Basic commands:"" ) or line. startswith ( <TAB> <TAB> <TAB> ""Most used commands:"" <TAB> <TAB> ) : <TAB> <TAB> <TAB> is_commands_list = True",False,is_commands_list and line,is_commands_list,0.6552774310112
|
||
|
3961,"def split_requests ( model ) : <TAB> structs = [ ] <TAB> for struct in model. structs : <TAB> <TAB> structtype = None <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> structtype = ""Request"" <TAB> <TAB> elif struct. name. endswith ( ""Response"" ) or struct. name == ""ServiceFault"" : <TAB> <TAB> <TAB> structtype = ""Response"" <TAB> <TAB> if structtype : <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> struct. needconstructor = True <TAB> <TAB> <TAB> field = Field ( ) <TAB> <TAB> <TAB> field. name = ""TypeId"" <TAB> <TAB> <TAB> field. uatype = ""NodeId"" <TAB> <TAB> <TAB> struct. fields. insert ( 0, field ) <TAB> <TAB> if structtype and not struct. name in NoSplitStruct : <TAB> <TAB> <TAB> paramstruct = Struct ( ) <TAB> <TAB> <TAB> if structtype == ""Request"" : <TAB> <TAB> <TAB> <TAB> basename = struct. name. replace ( ""Request"", """" ) + ""Parameters"" <TAB> <TAB> <TAB> <TAB> paramstruct. name = basename <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> basename = struct. name. replace ( ""Response"", """" ) + ""Result"" <TAB> <TAB> <TAB> <TAB> paramstruct. name = basename <TAB> <TAB> <TAB> paramstruct. fields = struct. fields [ 2 : ] <TAB> <TAB> <TAB> paramstruct. bits = struct. bits <TAB> <TAB> <TAB> struct. fields = struct. fields [ : 2 ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> structs. append ( paramstruct ) <TAB> <TAB",False,struct.name.endswith('Request') and (not struct.name in NotRequest),"struct.name.endswith((""Request"", ""Response"")",0.6544246673583984
|
||
|
3962,"def do_monitor ( self, l ) : <TAB> interval = 5 <TAB> if not self. p. online : <TAB> <TAB> self. logError ( _ ( ""Printer is not online. Please connect to it first."" ) ) <TAB> <TAB> return <TAB> if not ( self. p. printing or self. sdprinting ) : <TAB> <TAB> self. logError ( <TAB> <TAB> <TAB> _ ( ""Printer is not printing. Please print something before monitoring."" ) <TAB> <TAB> ) <TAB> <TAB> return <TAB> self. log ( _ ( ""Monitoring printer, use ^C to interrupt."" ) ) <TAB> if len ( l ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> interval = float ( l ) <TAB> <TAB> except : <TAB> <TAB> <TAB> self. logError ( _ ( ""Invalid period given."" ) ) <TAB> self. log ( _ ( ""Updating values every %f seconds."" ) % ( interval, ) ) <TAB> self. monitoring = 1 <TAB> prev_msg_len = 0 <TAB> try : <TAB> <TAB> while True : <TAB> <TAB> <TAB> self. p. send_now ( ""M105"" ) <TAB> <TAB> <TAB> if self. sdprinting : <TAB> <TAB> <TAB> <TAB> self. p. send_now ( ""M27"" ) <TAB> <TAB> <TAB> time. sleep ( interval ) <TAB> <TAB> <TAB> if self. p. printing : <TAB> <TAB> <TAB> <TAB> preface = _ ( ""Print progress: "" ) <TAB> <TAB> <TAB> <TAB> progress = 100 * float ( self. p. queueindex ) / len ( self. p. mainqueue ) <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> preface = _ ( ""SD print progress: "" ) <TAB> <TAB> <TAB> <TAB> progress = self. percentdone <TAB> <TAB> <TAB> prev_msg = preface + ""%.1f%%"" % progress <TAB> <TAB> <TAB> if self. silent is False",False,self.sdprinting,self.silent,0.657619059085846
|
||
|
3963,"def _post_order ( op ) : <TAB> if isinstance ( op, tvm. tir. Allocate ) : <TAB> <TAB> lift_stmt [ - 1 ]. append ( op ) <TAB> <TAB> return op. body <TAB> if isinstance ( op, tvm. tir. AttrStmt ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> lift_stmt [ - 1 ]. append ( op ) <TAB> <TAB> <TAB> return op. body <TAB> <TAB> if op. attr_key == ""virtual_thread"" : <TAB> <TAB> <TAB> return _merge_block ( lift_stmt. pop ( ) + [ op ], op. body ) <TAB> <TAB> return op <TAB> if isinstance ( op, tvm. tir. For ) : <TAB> <TAB> return _merge_block ( lift_stmt. pop ( ) + [ op ], op. body ) <TAB> raise RuntimeError ( ""not reached"" )",False,op.attr_key == 'storage_scope',op.attr_key == 'lift_stmt',0.6514294743537903
|
||
|
3964,"def train_prog ( exe, program, loss, node2vec_pyreader, args, train_steps ) : <TAB> trainer_id = int ( os. getenv ( ""PADDLE_TRAINER_ID"", ""0"" ) ) <TAB> step = 0 <TAB> if not os. path. exists ( args. save_path ) : <TAB> <TAB> os. makedirs ( args. save_path ) <TAB> while True : <TAB> <TAB> try : <TAB> <TAB> <TAB> begin_time = time. time ( ) <TAB> <TAB> <TAB> ( loss_val, ) = exe. run ( program, fetch_list = [ loss ] ) <TAB> <TAB> <TAB> log. info ( <TAB> <TAB> <TAB> <TAB> ""step %s: loss %.5f speed: %.5f s/step"" <TAB> <TAB> <TAB> <TAB> % ( step, np. mean ( loss_val ), time. time ( ) - begin_time ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> step += 1 <TAB> <TAB> except F. core. EOFException : <TAB> <TAB> <TAB> node2vec_pyreader. reset ( ) <TAB> <TAB> if step % args. steps_per_save == 0 or step == train_steps : <TAB> <TAB> <TAB> save_path = args. save_path <TAB> <TAB> <TAB> if trainer_id == 0 : <TAB> <TAB> <TAB> <TAB> model_path = os. path. join ( save_path, ""%s"" % step ) <TAB> <TAB> <TAB> <TAB> fleet. save_persistables ( exe, model_path ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> break",False,step == train_steps,trainer_id == 1,0.6636180877685547
|
||
|
3965,"def _test_reshape ( data, out_shape, wrap_shape ) : <TAB> """"""One iteration of reshape operation with given data and out shape"""""" <TAB> with tf. Graph ( ). as_default ( ) : <TAB> <TAB> in_data = array_ops. placeholder ( shape = data. shape, dtype = data. dtype ) <TAB> <TAB> out_shape = out_shape if<mask> : else np. array ( out_shape, dtype = np. int32 ) <TAB> <TAB> in_shape = ( <TAB> <TAB> <TAB> out_shape <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> else array_ops. placeholder ( <TAB> <TAB> <TAB> <TAB> shape = out_shape. shape, dtype = out_shape. dtype, name = ""Newshape"" <TAB> <TAB> <TAB> ) <TAB> <TAB> ) <TAB> <TAB> out = array_ops. reshape ( in_data, in_shape ) <TAB> <TAB> compare_tflite_with_tvm ( <TAB> <TAB> <TAB> [ data, out_shape ] if wrap_shape else [ data ], <TAB> <TAB> <TAB> [ ""Placeholder:0"", ""Newshape:0"" ] if wrap_shape else [ ""Placeholder:0"" ], <TAB> <TAB> <TAB> [ in_data, in_shape ] if wrap_shape else [ in_data ], <TAB> <TAB> <TAB> [ out ], <TAB> <TAB> <TAB> mode = ""vm"", <TAB> <TAB> )",False,not wrap_shape,out_shape is None,0.65927654504776
|
||
|
3966,"def _power_exact ( y, xc, yc, xe ) : <TAB> yc, ye = y. int, y. exp <TAB> while yc % 10 == 0 : <TAB> <TAB> yc //= 10 <TAB> <TAB> ye += 1 <TAB> if xc == 1 : <TAB> <TAB> xe *= yc <TAB> <TAB> while xe % 10 == 0 : <TAB> <TAB> <TAB> xe //= 10 <TAB> <TAB> <TAB> ye += 1 <TAB> <TAB> if ye < 0 : <TAB> <TAB> <TAB> return None <TAB> <TAB> exponent = xe * 10 ** ye <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> xc = exponent <TAB> <TAB> else : <TAB> <TAB> <TAB> xc = 0 <TAB> <TAB> return 5",False,y and xe,exponent < 0,0.7027629613876343
|
||
|
3967,"def upload_recipe_files ( self ) : <TAB> path = self. job. resultdir <TAB> <TAB> tests = self. get_processed_tests ( ) <TAB> logging. debug ( ""Recipe filtering following tests: %s"" % tests ) <TAB> for root, dirnames, files in os. walk ( path ) : <TAB> <TAB> """"""do not upload previously uploaded results files"""""" <TAB> <TAB> for d in dirnames : <TAB> <TAB> <TAB> if d in tests : <TAB> <TAB> <TAB> <TAB> dirnames. remove ( d ) <TAB> <TAB> for name in files : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> remotepath = re. sub ( path, """", root ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> localfile = os. path. join ( root, name ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. bkr_proxy. recipe_upload_file ( localfile, remotepath )",False,os.path.getsize(localfile) == 0,not localpath,0.6478428840637207
|
||
|
3968,"def _add_constant_node ( self, source_node ) : <TAB> parent_ids = range ( len ( source_node. in_edges ) ) <TAB> for idx in parent_ids : <TAB> <TAB> parent_node = self. tf_graph. get_node ( source_node. in_edges [ idx ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _rename_Const ( parent_node )",False,parent_node.type == 'Const',parent_node,0.6516399383544922
|
||
|
3969,"def __init__ ( <TAB> self, <TAB> ec2_backend, <TAB> subnet, <TAB> private_ip_address, <TAB> private_ip_addresses = None, <TAB> device_index = 0, <TAB> public_ip_auto_assign = True, <TAB> group_ids = None, <TAB> description = None, ) : <TAB> self. ec2_backend = ec2_backend <TAB> self. id = random_eni_id ( ) <TAB> self. device_index = device_index <TAB> self. private_ip_address = private_ip_address or random_private_ip ( ) <TAB> self. private_ip_addresses = private_ip_addresses <TAB> self. subnet = subnet <TAB> self. instance = None <TAB> self. attachment_id = None <TAB> self. description = description <TAB> self. public_ip = None <TAB> self. public_ip_auto_assign = public_ip_auto_assign <TAB> self. start ( ) <TAB> self. attachments = [ ] <TAB> <TAB> <TAB> self. _group_set = [ ] <TAB> group = None <TAB> if group_ids : <TAB> <TAB> for group_id in group_ids : <TAB> <TAB> <TAB> group = self. ec2_backend. get_security_group_from_id ( group_id ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> group = SecurityGroup ( <TAB> <TAB> <TAB> <TAB> <TAB> self. ec2_backend, <TAB> <TAB> <TAB> <TAB> <TAB> group_id, <TAB> <TAB> <TAB> <TAB> <TAB> group_id, <TAB> <TAB> <TAB> <TAB> <TAB> group_id, <TAB> <TAB> <TAB> <TAB> <TAB> vpc_id = subnet. vpc_id, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> self. ec2_backend. groups [ subnet. vpc_id ] [ group",False,not group,group,0.6749142408370972
|
||
|
3970,"def df_index_expr ( self, length_expr = None, as_range = False ) : <TAB> """"""Generate expression to get or create index of DF"""""" <TAB> if isinstance ( self. index, types. NoneType ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> length_expr = df_length_expr ( self ) <TAB> <TAB> if as_range : <TAB> <TAB> <TAB> return f""range({length_expr})"" <TAB> <TAB> else : <TAB> <TAB> <TAB> return f""numpy.arange({length_expr})"" <TAB> return ""self._index""",True,length_expr is None,length_expr is None,0.6605559587478638
|
||
|
3971,"def tag_export_edited ( ) : <TAB> tag_enabled_misp = request. form. getlist ( ""tag_enabled_misp"" ) <TAB> tag_enabled_hive = request. form. getlist ( ""tag_enabled_hive"" ) <TAB> list_export_tags = list ( r_serv_db. smembers ( ""list_export_tags"" ) ) <TAB> r_serv_db. delete ( ""whitelist_misp"" ) <TAB> r_serv_db. delete ( ""whitelist_hive"" ) <TAB> for tag in tag_enabled_misp : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> r_serv_db. sadd ( ""whitelist_misp"", tag ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return ""invalid input"" <TAB> for tag in tag_enabled_hive : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> r_serv_db. sadd ( ""whitelist_hive"", tag ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return ""invalid input"" <TAB> return redirect ( url_for ( ""PasteSubmit.edit_tag_export"" ) )",False,"r_serv_db.sismember('list_export_tags', tag)",tag in list_export_tags,0.6452752947807312
|
||
|
3972,"def _update_and_return ( layer : nn. Module, key : str ) : <TAB> if memory is None : <TAB> <TAB> <TAB> <TAB> out = layer ( queries ) <TAB> <TAB> if cache is not None : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> res : MaybeList [ torch. Tensor ] = cache [ key ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> res. append ( out. squeeze ( 1 ) ) <TAB> <TAB> <TAB> <TAB> out = torch. stack ( res, dim = 1 ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> res = torch. cat ( [ res, out ], dim = 1 ) <TAB> <TAB> <TAB> <TAB> out = res <TAB> <TAB> <TAB> cache [ key ] = res <TAB> else : <TAB> <TAB> <TAB> <TAB> if cache is not None : <TAB> <TAB> <TAB> res : MaybeList [ torch. Tensor ] = cache [ key ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if len ( res ) == 0 : <TAB> <TAB> <TAB> <TAB> <TAB> out = layer ( memory ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> out = torch. stack ( res, dim = 1 ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if res. size ( 1 ) == 0 : <TAB> <TAB> <TAB> <TAB> <TAB> out = layer ( memory ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> out = res <TAB> <TAB> else : <TAB> <TAB> <TAB> out =",False,"isinstance(res, list)",len(res) > 0,0.6555722951889038
|
||
|
3973,"def update_gstin ( context ) : <TAB> dirty = False <TAB> for key, value in iteritems ( frappe. form_dict ) : <TAB> <TAB> if key!= ""party"" : <TAB> <TAB> <TAB> address_name = frappe. get_value ( ""Address"", key ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> address = frappe. get_doc ( ""Address"", address_name ) <TAB> <TAB> <TAB> <TAB> address. gstin = value. upper ( ) <TAB> <TAB> <TAB> <TAB> address. save ( ignore_permissions = True ) <TAB> <TAB> <TAB> <TAB> dirty = True <TAB> if dirty : <TAB> <TAB> frappe. db. commit ( ) <TAB> <TAB> context. updated = True",True,address_name,address_name,0.6615316867828369
|
||
|
3974,"def sql_indexes_for_field ( self, model, f, style ) : <TAB> ""Return any spatial index creation SQL for the field."" <TAB> from django. contrib. gis. db. models. fields import GeometryField <TAB> output = super ( SpatiaLiteCreation, self ). sql_indexes_for_field ( model, f, style ) <TAB> if isinstance ( f, GeometryField ) : <TAB> <TAB> gqn = self. connection. ops. geo_quote_name <TAB> <TAB> qn = self. connection. ops. quote_name <TAB> <TAB> db_table = model. _meta. db_table <TAB> <TAB> output. append ( <TAB> <TAB> <TAB> style. SQL_KEYWORD ( ""SELECT "" ) <TAB> <TAB> <TAB> + style. SQL_TABLE ( ""AddGeometryColumn"" ) <TAB> <TAB> <TAB> + ""("" <TAB> <TAB> <TAB> + style. SQL_TABLE ( gqn ( db_table ) ) <TAB> <TAB> <TAB> + "", "" <TAB> <TAB> <TAB> + style. SQL_FIELD ( gqn ( f. column ) ) <TAB> <TAB> <TAB> + "", "" <TAB> <TAB> <TAB> + style. SQL_FIELD ( str ( f. srid ) ) <TAB> <TAB> <TAB> + "", "" <TAB> <TAB> <TAB> + style. SQL_COLTYPE ( gqn ( f. geom_type ) ) <TAB> <TAB> <TAB> + "", "" <TAB> <TAB> <TAB> + style. SQL_KEYWORD ( str ( f. dim ) ) <TAB> <TAB> <TAB> + "", "" <TAB> <TAB> <TAB> + style. SQL_KEYWORD ( str ( int ( not f. null ) ) ) <TAB> <TAB> <TAB> + "");"" <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> output. append ( <TAB> <TAB> <TAB> <TAB> style. SQL_KEYWORD ( ""SELECT "" ) <TAB> <TAB> <TAB> <TAB> + style. SQL_TABLE ( ""CreateSpatialIndex"" ) <TAB> <",False,f.spatial_index,f.spatial_index is not None,0.6597077250480652
|
||
|
3975,"def __init__ ( self, dst, table, include = [ ], exclude = [ ], autobatch = 0, executor = executor ) : <TAB> self. dst = dst <TAB> self. table = table <TAB> self. total = 0 <TAB> self. rows = [ ] <TAB> self. autobatch = autobatch <TAB> self. bindings = { } <TAB> include = map ( lambda x : x. lower ( ), include ) <TAB> exclude = map ( lambda x : x. lower ( ), exclude ) <TAB> _verbose = self. dst. verbose <TAB> self. dst. verbose = 0 <TAB> try : <TAB> <TAB> self. dst. table ( self. table ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> colmap = { } <TAB> <TAB> <TAB> for a in self. dst. results : <TAB> <TAB> <TAB> <TAB> colmap [ a [ 3 ]. lower ( ) ] = a [ 4 ] <TAB> <TAB> <TAB> cols = self. __filter__ ( colmap. keys ( ), include, exclude ) <TAB> <TAB> <TAB> for a in zip ( range ( len ( cols ) ), cols ) : <TAB> <TAB> <TAB> <TAB> self. bindings [ a [ 0 ] ] = colmap [ a [ 1 ] ] <TAB> <TAB> <TAB> colmap = None <TAB> <TAB> else : <TAB> <TAB> <TAB> cols = self. __filter__ ( include, include, exclude ) <TAB> finally : <TAB> <TAB> self. dst. verbose = _verbose <TAB> self. executor = executor ( table, cols )",True,self.dst.results,self.dst.results,0.6548646688461304
|
||
|
3976,"def check_database ( ) : <TAB> if len ( EmailAddress. objects. all ( ) ) > 0 : <TAB> <TAB> print ( <TAB> <TAB> <TAB> ""Are you sure you want to wipe the existing development database and reseed it? (Y/N)"" <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> destroy_database ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return False <TAB> else : <TAB> <TAB> return True",False,raw_input().lower() == 'y',EmailAddress.objects.filter(email_address=self.email).exists(),0.6506912708282471
|
||
|
3977,"def _parse_rosdep_resolve_dependencies ( <TAB> dependency_name : str, output : str ) -> Dict [ str, Set [ str ] ] : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> delimiters = re. compile ( r""\n|\s"" ) <TAB> lines = delimiters. split ( output ) <TAB> dependencies : Dict [ str, Set [ str ] ] = { } <TAB> dependency_set = None <TAB> for line in lines : <TAB> <TAB> line = line. strip ( ) <TAB> <TAB> if line. startswith ( ""#"" ) : <TAB> <TAB> <TAB> key = line. strip ( ""# "" ) <TAB> <TAB> <TAB> dependencies [ key ] = set ( ) <TAB> <TAB> <TAB> dependency_set = dependencies [ key ] <TAB> <TAB> elif line : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise RosdepUnexpectedResultError ( dependency_name, output ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> dependency_set. add ( line ) <TAB> return dependencies",True,dependency_set is None,dependency_set is None,0.6681257486343384
|
||
|
3978,"def _test_blob ( self, obj = 0 ) : <TAB> assert self. has_table ( ""blobtable"" ), ""no blob table"" <TAB> tabname, sql = self. table ( ""blobtable"" ) <TAB> fn = tempfile. mktemp ( ) <TAB> fp = None <TAB> c = self. cursor ( ) <TAB> try : <TAB> <TAB> hello = ( ""hello"", ) * 1024 <TAB> <TAB> c. execute ( sql ) <TAB> <TAB> self. db. commit ( ) <TAB> <TAB> from java. io import ( <TAB> <TAB> <TAB> FileOutputStream, <TAB> <TAB> <TAB> FileInputStream, <TAB> <TAB> <TAB> ObjectOutputStream, <TAB> <TAB> <TAB> ObjectInputStream, <TAB> <TAB> <TAB> ByteArrayInputStream, <TAB> <TAB> ) <TAB> <TAB> fp = FileOutputStream ( fn ) <TAB> <TAB> oos = ObjectOutputStream ( fp ) <TAB> <TAB> oos. writeObject ( hello ) <TAB> <TAB> fp. close ( ) <TAB> <TAB> fp = FileInputStream ( fn ) <TAB> <TAB> blob = ObjectInputStream ( fp ) <TAB> <TAB> value = blob. readObject ( ) <TAB> <TAB> fp. close ( ) <TAB> <TAB> assert hello == value, ""unable to serialize properly"" <TAB> <TAB> if obj == 1 : <TAB> <TAB> <TAB> fp = open ( fn, ""rb"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> fp = FileInputStream ( fn ) <TAB> <TAB> c. execute ( <TAB> <TAB> <TAB> ""insert into %s (a, b) values (?,?)"" % ( tabname ), <TAB> <TAB> <TAB> [ ( 0, fp ) ], <TAB> <TAB> <TAB> { 1 : zxJDBC. BLOB }, <TAB> <TAB> ) <TAB> <TAB> self. db. commit ( ) <TAB> <TAB> c. execute ( ""select * from %s"" % ( tabname ) ) <TAB> <TAB> f = c. fetchall ( ) <TAB> <TAB> bytes = f [ 0 ] [ 1",False,os.path.exists(fn),obj == 0,0.6480526924133301
|
||
|
3979,"def __getitem__ ( self, key ) : <TAB> self. _update ( ) <TAB> dx = c_double ( ) <TAB> dy = c_double ( ) <TAB> dz = c_double ( ) <TAB> m = self. __len__ ( ) <TAB> has_z = self. _ndim == 3 <TAB> if isinstance ( key, int ) : <TAB> <TAB> if key + m < 0 or key >= m : <TAB> <TAB> <TAB> raise IndexError ( ""index out of range"" ) <TAB> <TAB> if key < 0 : <TAB> <TAB> <TAB> i = m + key <TAB> <TAB> else : <TAB> <TAB> <TAB> i = key <TAB> <TAB> lgeos. GEOSCoordSeq_getX ( self. _cseq, i, byref ( dx ) ) <TAB> <TAB> lgeos. GEOSCoordSeq_getY ( self. _cseq, i, byref ( dy ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> lgeos. GEOSCoordSeq_getZ ( self. _cseq, i, byref ( dz ) ) <TAB> <TAB> <TAB> return ( dx. value, dy. value, dz. value ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return ( dx. value, dy. value ) <TAB> elif isinstance ( key, slice ) : <TAB> <TAB> res = [ ] <TAB> <TAB> start, stop, stride = key. indices ( m ) <TAB> <TAB> for i in range ( start, stop, stride ) : <TAB> <TAB> <TAB> lgeos. GEOSCoordSeq_getX ( self. _cseq, i, byref ( dx ) ) <TAB> <TAB> <TAB> lgeos. GEOSCoordSeq_getY ( self. _cseq, i, byref ( dy ) ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> lgeos. GEOSCoordSeq_getZ ( self. _cseq, i, byref ( dz ) ) <TAB",True,has_z,has_z,0.6727516651153564
|
||
|
3980,"def _find_escaped_or_filtered ( self, body, pos, chars ) : <TAB> filtered = [ ] <TAB> escaped = [ ] <TAB> for c in chars : <TAB> <TAB> try : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> pos += 1 <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> elif body [ pos ] == ""\\"" and body [ pos + 1 ] == c : <TAB> <TAB> <TAB> <TAB> escaped += [ c ] <TAB> <TAB> <TAB> <TAB> pos += 2 <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> filtered += [ c ] <TAB> <TAB> <TAB> <TAB> pos += 1 <TAB> <TAB> except IndexError : <TAB> <TAB> <TAB> filtered += [ c ] <TAB> <TAB> <TAB> continue <TAB> return filtered, escaped",False,body[pos] == c,pos >= len(body),0.6669749021530151
|
||
|
3981,"def removeSentinelLines ( self, s, line_delim, start_delim, unused_end_delim ) : <TAB> """"""Properly remove all sentinle lines in s."""""" <TAB> delim = ( line_delim or start_delim or """" ) + ""@"" <TAB> verbatim = delim + ""verbatim"" <TAB> verbatimFlag = False <TAB> result = [ ] <TAB> lines = g. splitLines ( s ) <TAB> for line in lines : <TAB> <TAB> i = g. skip_ws ( line, 0 ) <TAB> <TAB> if not verbatimFlag and g. match ( line, i, delim ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> verbatimFlag = True <TAB> <TAB> else : <TAB> <TAB> <TAB> result. append ( line ) <TAB> <TAB> <TAB> verbatimFlag = False <TAB> result = """". join ( result ) <TAB> return result",False,"g.match(line, i, verbatim)",unused_end_delim,0.6471948623657227
|
||
|
3982,"def save ( self ) : <TAB> for var_name in self. default_config : <TAB> <TAB> if getattr ( self, var_name, None ) == self. default_config [ var_name ] : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> del self. file_config [ var_name ] <TAB> <TAB> else : <TAB> <TAB> <TAB> self. file_config [ var_name ] = getattr ( self, var_name ) <TAB> with open ( self. config_path, ""w"" ) as f : <TAB> <TAB> f. write ( json. dumps ( self. file_config, indent = 2 ) )",False,var_name in self.file_config,"hasattr(self, var_name)",0.6539607644081116
|
||
|
3983,"def _draw ( self, context, opacity ) : <TAB> """"""draw accumulated instructions in context"""""" <TAB> <TAB> fresh_draw = len ( self. __new_instructions or [ ] ) > 0 <TAB> if fresh_draw : <TAB> <TAB> self. paths = [ ] <TAB> <TAB> self. __instruction_cache = self. __new_instructions <TAB> <TAB> self. __new_instructions = [ ] <TAB> else : <TAB> <TAB> if not self. __instruction_cache : <TAB> <TAB> <TAB> return <TAB> for instruction, args in self. __instruction_cache : <TAB> <TAB> if fresh_draw : <TAB> <TAB> <TAB> if instruction in ( ""new_path"", ""stroke"", ""fill"", ""clip"" ) : <TAB> <TAB> <TAB> <TAB> self. paths. append ( ( instruction, ""path"", context. copy_path ( ) ) ) <TAB> <TAB> <TAB> elif instruction in ( ""save"", ""restore"", ""translate"", ""scale"", ""rotate"" ) : <TAB> <TAB> <TAB> <TAB> self. paths. append ( ( instruction, ""transform"", args ) ) <TAB> <TAB> if instruction == ""set_color"" : <TAB> <TAB> <TAB> self. _set_color ( context, args [ 0 ], args [ 1 ], args [ 2 ], args [ 3 ] * opacity ) <TAB> <TAB> elif instruction == ""show_layout"" : <TAB> <TAB> <TAB> self. _show_layout ( context, * args ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> context. paint_with_alpha ( opacity ) <TAB> <TAB> else : <TAB> <TAB> <TAB> getattr ( context, instruction ) ( * args )",False,opacity < 1 and instruction == 'paint',instruction == 'paint_with_alpha',0.6563804149627686
|
||
|
3984,"def semanticTags ( self, semanticTags ) : <TAB> if semanticTags is None : <TAB> <TAB> self. __semanticTags = OrderedDict ( ) <TAB> <TAB> for key, value in list ( semanticTags. items ( ) ) : <TAB> <TAB> if not isinstance ( key, int ) : <TAB> <TAB> <TAB> raise TypeError ( ""At least one key is not a valid int position"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise TypeError ( <TAB> <TAB> <TAB> <TAB> ""At least one value of the provided dict is not a list of string"" <TAB> <TAB> <TAB> ) <TAB> <TAB> for x in value : <TAB> <TAB> <TAB> if not isinstance ( x, str ) : <TAB> <TAB> <TAB> <TAB> raise TypeError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""At least one value of the provided dict is not a list of string"" <TAB> <TAB> <TAB> <TAB> ) <TAB> self. __semanticTags = semanticTags",False,"not isinstance(value, list)","not isinstance(value, str)",0.6548378467559814
|
||
|
3985,"def get_value_threshold ( self ) : <TAB> total_values = [ ] <TAB> for ( <TAB> <TAB> col_name, <TAB> <TAB> col_results, <TAB> ) in self. binning_obj. binning_obj. bin_results. all_cols_results. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> total_values. append ( col_results. iv ) <TAB> if not self. local_only : <TAB> <TAB> LOGGER. debug ( <TAB> <TAB> <TAB> ""host_results: {}, host_selection_properties: {}"". format ( <TAB> <TAB> <TAB> <TAB> self. binning_obj. host_results, self. host_selection_properties <TAB> <TAB> <TAB> ) <TAB> <TAB> ) <TAB> <TAB> for host_id, host_binning_obj in enumerate ( self. binning_obj. host_results ) : <TAB> <TAB> <TAB> host_select_param = self. host_selection_properties [ host_id ] <TAB> <TAB> <TAB> for ( <TAB> <TAB> <TAB> <TAB> col_name, <TAB> <TAB> <TAB> <TAB> col_results, <TAB> <TAB> <TAB> ) in host_binning_obj. bin_results. all_cols_results. items ( ) : <TAB> <TAB> <TAB> <TAB> if col_name in host_select_param. select_col_names : <TAB> <TAB> <TAB> <TAB> <TAB> total_values. append ( col_results. iv ) <TAB> sorted_value = sorted ( total_values, reverse = True ) <TAB> thres_idx = int ( <TAB> <TAB> math. floor ( self. percentile_threshold * len ( sorted_value ) - consts. FLOAT_ZERO ) <TAB> ) <TAB> return sorted_value [ thres_idx ]",False,col_name in self.selection_properties.select_col_names,col_results.iv,0.6507352590560913
|
||
|
3986,"def _get_check_overlays ( self, force = False ) : <TAB> if self. _check_overlays_stale or force : <TAB> <TAB> if self. _connectivity_checker. online : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> url = self. _settings. get ( [ ""check_overlay_url"" ] ) <TAB> <TAB> <TAB> self. _logger. info ( ""Fetching check overlays from {}"". format ( url ) ) <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> r = requests. get ( url, timeout = 3.1 ) <TAB> <TAB> <TAB> <TAB> r. raise_for_status ( ) <TAB> <TAB> <TAB> <TAB> data = r. json ( ) <TAB> <TAB> <TAB> except Exception as exc : <TAB> <TAB> <TAB> <TAB> self. _logger. error ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Could not fetch check overlay from {}: {}"". format ( url, exc ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> self. _overlay_cache = { } <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. _overlay_cache = data <TAB> <TAB> else : <TAB> <TAB> <TAB> self. _logger. info ( ""Not fetching check overlays, we are offline"" ) <TAB> <TAB> <TAB> self. _overlay_cache = { } <TAB> <TAB> self. _overlay_cache_timestamp = time. time ( ) <TAB> <TAB> default_overlay = { } <TAB> <TAB> defaults = self. get_settings_defaults ( ) <TAB> <TAB> for key in defaults [ ""checks"" ] : <TAB> <TAB> <TAB> if key in self. _overlay_cache : <TAB> <TAB> <TAB> <TAB> default_overlay [ key ] = self. _overlay_cache [ key ] <TAB> <TAB> self. _settings. remove_overlay ( self. CHECK_OVERLAY_",False,default_overlay,self._overlay_cache_timestamp is None or force,0.6626017093658447
|
||
|
3987,"def _set_peer_statuses ( self ) : <TAB> """"""Set peer statuses."""""" <TAB> cutoff = time. time ( ) - STALE_SECS <TAB> for peer in self. peers : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> peer. status = PEER_BAD <TAB> <TAB> elif peer. last_good > cutoff : <TAB> <TAB> <TAB> peer. status = PEER_GOOD <TAB> <TAB> elif peer. last_good : <TAB> <TAB> <TAB> peer. status = PEER_STALE <TAB> <TAB> else : <TAB> <TAB> <TAB> peer. status = PEER_NEVER",True,peer.bad,peer.bad,0.6627126932144165
|
||
|
3988,"def credentials ( self ) : <TAB> """"""The session credentials as a dict"""""" <TAB> creds = { } <TAB> if self. _creds : <TAB> <TAB> if self. _creds. access_key : <TAB> <TAB> <TAB> creds [ ""aws_access_key_id"" ] = self. _creds. access_key <TAB> <TAB> if self. _creds. secret_key : <TAB> <TAB> <TAB> creds [ ""aws_secret_access_key"" ] = self. _creds. secret_key <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> creds [ ""aws_session_token"" ] = self. _creds. token <TAB> if self. _session. region_name : <TAB> <TAB> creds [ ""aws_region"" ] = self. _session. region_name <TAB> if self. requester_pays : <TAB> <TAB> creds [ ""aws_request_payer"" ] = ""requester"" <TAB> return creds",False,self._creds.token,self._session,0.6739875078201294
|
||
|
3989,"def __init__ ( self, ** values ) : <TAB> self. start_date = values. pop ( ""start_date"", None ) <TAB> if self. start_date : <TAB> <TAB> self. start_date = convert_to_datetime ( self. start_date ) <TAB> <TAB> for key, value in list ( iteritems ( values ) ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise TypeError ( ""Invalid field name: %s"" % key ) <TAB> <TAB> if value is None : <TAB> <TAB> <TAB> del values [ key ] <TAB> self. fields = [ ] <TAB> assign_defaults = False <TAB> for field_name in self. FIELD_NAMES : <TAB> <TAB> if field_name in values : <TAB> <TAB> <TAB> exprs = values. pop ( field_name ) <TAB> <TAB> <TAB> is_default = False <TAB> <TAB> <TAB> assign_defaults = not values <TAB> <TAB> elif assign_defaults : <TAB> <TAB> <TAB> exprs = DEFAULT_VALUES [ field_name ] <TAB> <TAB> <TAB> is_default = True <TAB> <TAB> else : <TAB> <TAB> <TAB> exprs = ""*"" <TAB> <TAB> <TAB> is_default = True <TAB> <TAB> field_class = self. FIELDS_MAP [ field_name ] <TAB> <TAB> field = field_class ( field_name, exprs, is_default ) <TAB> <TAB> self. fields. append ( field )",True,key not in self.FIELD_NAMES,key not in self.FIELD_NAMES,0.6679651737213135
|
||
|
3990,"def load ( self ) : <TAB> if self. is_resource : <TAB> <TAB> self. loaded = True <TAB> <TAB> return <TAB> buf = self. _buf <TAB> buf. seek ( self. _buf_ofs ) <TAB> buf. endian = "">"" <TAB> self. metadata_size = buf. read_uint ( ) <TAB> self. file_size = buf. read_uint ( ) <TAB> self. format = buf. read_uint ( ) <TAB> self. data_offset = buf. read_uint ( ) <TAB> if self. format >= 9 : <TAB> <TAB> self. endianness = buf. read_uint ( ) <TAB> <TAB> if self. endianness == 0 : <TAB> <TAB> <TAB> buf. endian = ""<"" <TAB> self. tree. load ( buf ) <TAB> if 7 <= self. format <= 13 : <TAB> <TAB> self. long_object_ids = bool ( buf. read_uint ( ) ) <TAB> num_objects = buf. read_uint ( ) <TAB> for i in range ( num_objects ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> buf. align ( ) <TAB> <TAB> obj = ObjectInfo ( self ) <TAB> <TAB> obj. load ( buf ) <TAB> <TAB> self. register_object ( obj ) <TAB> if self. format >= 11 : <TAB> <TAB> num_adds = buf. read_uint ( ) <TAB> <TAB> for i in range ( num_adds ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> buf. align ( ) <TAB> <TAB> <TAB> id = self. read_id ( buf ) <TAB> <TAB> <TAB> self. adds. append ( ( id, buf. read_int ( ) ) ) <TAB> if self. format >= 6 : <TAB> <TAB> num_refs = buf. read_uint ( ) <TAB> <TAB> for i in range ( num_refs ) : <TAB> <TAB> <TAB> ref = AssetRef ( self ) <TAB> <TAB> <TAB>",False,self.format >= 14,i > 0,0.6619637608528137
|
||
|
3991,"def _is_perf_file ( file_path ) : <TAB> f = get_file ( file_path ) <TAB> for line in f : <TAB> <TAB> if line [ 0 ] == ""#"" : <TAB> <TAB> <TAB> continue <TAB> <TAB> r = event_regexp. search ( line ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> f. close ( ) <TAB> <TAB> <TAB> return True <TAB> <TAB> f. close ( ) <TAB> <TAB> return False",True,r,r,0.6941646933555603
|
||
|
3992,"def command ( self, args = None ) : <TAB> config = self. session. config <TAB> args = args if ( args is not None ) else list ( self. args ) <TAB> now = int ( time. time ( ) ) <TAB> if args : <TAB> <TAB> job = args. pop ( 0 ) <TAB> while args : <TAB> <TAB> op = args. pop ( 0 ). lower ( ). replace ( ""-"", """" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> interval = int ( args. pop ( 0 ) ) <TAB> <TAB> <TAB> config. cron_worker. schedule [ job ] [ 1 ] = interval <TAB> <TAB> elif op == ""trigger"" : <TAB> <TAB> <TAB> interval = config. cron_worker. schedule [ job ] [ 1 ] <TAB> <TAB> <TAB> config. cron_worker. schedule [ job ] [ 3 ] = now - interval <TAB> <TAB> elif op == ""postpone"" : <TAB> <TAB> <TAB> hours = float ( args. pop ( 0 ) ) <TAB> <TAB> <TAB> config. cron_worker. schedule [ job ] [ 3 ] += int ( hours * 3600 ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise NotImplementedError ( ""Unknown op: %s"" % op ) <TAB> return self. _success ( <TAB> <TAB> _ ( ""Displayed CRON schedule"" ), <TAB> <TAB> result = { <TAB> <TAB> <TAB> ""last_run"" : config. cron_worker. last_run, <TAB> <TAB> <TAB> ""jobs"" : config. cron_worker. schedule. values ( ), <TAB> <TAB> }, <TAB> )",False,op == 'interval',op == 'set',0.662510871887207
|
||
|
3993,"def test_raxml ( self ) : <TAB> """"""Run RAxML using the wrapper."""""" <TAB> cmd = RaxmlCommandline ( <TAB> <TAB> raxml_exe, sequences = EX_PHYLIP, model = ""PROTCATWAG"", name = ""test"" <TAB> ) <TAB> <TAB> self. assertIn ( ""-p"", str ( cmd ) ) <TAB> <TAB> try : <TAB> <TAB> out, err = cmd ( ) <TAB> <TAB> self. assertGreater ( len ( out ), 0 ) <TAB> <TAB> self. assertEqual ( len ( err ), 0 ) <TAB> <TAB> <TAB> <TAB> tree = Phylo. read ( ""RAxML_result.test"", ""newick"" ) <TAB> <TAB> self. assertEqual ( tree. count_terminals ( ), 4 ) <TAB> finally : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for fname in [ <TAB> <TAB> <TAB> ""RAxML_info.test"", <TAB> <TAB> <TAB> ""RAxML_log.test"", <TAB> <TAB> <TAB> ""RAxML_parsimonyTree.test"", <TAB> <TAB> <TAB> ""RAxML_result.test"", <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""RAxML_bestTree.test"", <TAB> <TAB> ] : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> os. remove ( fname )",False,os.path.isfile(fname),os.path.exists(fname),0.6483091115951538
|
||
|
3994,"def test_order_discount_price ( self ) : <TAB> """"""Tests the price of the discount within an order."""""" <TAB> order = add_order ( self. request ) <TAB> for order_item in order. items. all ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. assertEqual ( ""%.2f"" % order_item. price_net, ""-8.40"" ) <TAB> <TAB> <TAB> self. assertEqual ( ""%.2f"" % order_item. product_price_net, ""-8.40"" )",False,order_item.product_name == 'Summer',order_item.price_net > 0,0.651544451713562
|
||
|
3995,"def help ( cls, task = None ) : <TAB> """"""Describe available tasks or one specific task"""""" <TAB> if task is None : <TAB> <TAB> usage_list = [ ] <TAB> <TAB> for task in iter ( cls. _tasks ) : <TAB> <TAB> <TAB> task_func = getattr ( cls, task ) <TAB> <TAB> <TAB> usage_string = "" %s %s"" % ( cls. _prog, task_func. usage ) <TAB> <TAB> <TAB> desc = task_func. __doc__. splitlines ( ) [ 0 ] <TAB> <TAB> <TAB> usage_list. append ( ( usage_string, desc ) ) <TAB> <TAB> max_len = functools. reduce ( lambda m, item : max ( m, len ( item [ 0 ] ) ), usage_list, 0 ) <TAB> <TAB> print ( ""Tasks:"" ) <TAB> <TAB> cols = int ( os. environ. get ( ""COLUMNS"", 80 ) ) <TAB> <TAB> for line, desc in usage_list : <TAB> <TAB> <TAB> task_func = getattr ( cls, task ) <TAB> <TAB> <TAB> if desc : <TAB> <TAB> <TAB> <TAB> line = ""%s%s # %s"" % ( line, "" "" * ( max_len - len ( line ) ), desc ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> line = line [ : cols - 3 ] + ""..."" <TAB> <TAB> <TAB> print ( line ) <TAB> else : <TAB> <TAB> task_func = getattr ( cls, task ) <TAB> <TAB> print ( ""Usage:"" ) <TAB> <TAB> print ( "" %s %s"" % ( cls. _prog, task_func. usage ) ) <TAB> <TAB> print ( """" ) <TAB> <TAB> print ( task_func. __doc__ )",False,len(line) > cols,cols > 3,0.6632709503173828
|
||
|
3996,"def readline ( self, size = None ) : <TAB> if size is not None : <TAB> <TAB> data = self. rfile. readline ( size ) <TAB> <TAB> self. bytes_read += len ( data ) <TAB> <TAB> self. _check_length ( ) <TAB> <TAB> return data <TAB> <TAB> <TAB> res = [ ] <TAB> while True : <TAB> <TAB> data = self. rfile. readline ( 256 ) <TAB> <TAB> self. bytes_read += len ( data ) <TAB> <TAB> self. _check_length ( ) <TAB> <TAB> res. append ( data ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return EMPTY. join ( res )",False,len(data) < 256 or data[-1:] == '\n',len(res) > 0,0.6516119241714478
|
||
|
3997,def setup ( level = None ) : <TAB> from pipeline. logging import pipeline_logger as logger <TAB> from pipeline. log. handlers import EngineLogHandler <TAB> if level in set ( logging. _levelToName. values ( ) ) : <TAB> <TAB> logger. setLevel ( level ) <TAB> logging. _acquireLock ( ) <TAB> try : <TAB> <TAB> for hdl in logger. handlers : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> else : <TAB> <TAB> <TAB> hdl = EngineLogHandler ( ) <TAB> <TAB> <TAB> hdl. setLevel ( logger. level ) <TAB> <TAB> <TAB> logger. addHandler ( hdl ) <TAB> finally : <TAB> <TAB> logging. _releaseLock ( ),False,"isinstance(hdl, EngineLogHandler)",hdl is None,0.6565418243408203
|
||
|
3998,"def user_agent_header ( ) : <TAB> <TAB> if menu. options. random_agent : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> err_msg = ""The option '--random-agent' is incompatible with option '--user-agent' or switch '--mobile'."" <TAB> <TAB> <TAB> print ( settings. print_critical_msg ( err_msg ) ) <TAB> <TAB> <TAB> raise SystemExit ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if settings. VERBOSITY_LEVEL >= 1 : <TAB> <TAB> <TAB> <TAB> debug_msg = ""Fetching random HTTP User-Agent header. "" <TAB> <TAB> <TAB> <TAB> sys. stdout. write ( settings. print_debug_msg ( debug_msg ) ) <TAB> <TAB> <TAB> <TAB> sys. stdout. flush ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> menu. options. agent = random. choice ( settings. USER_AGENT_LIST ) <TAB> <TAB> <TAB> <TAB> if settings. VERBOSITY_LEVEL >= 1 : <TAB> <TAB> <TAB> <TAB> <TAB> print ( settings. SUCCESS_STATUS ) <TAB> <TAB> <TAB> <TAB> info_msg = ( <TAB> <TAB> <TAB> <TAB> <TAB> ""The fetched random HTTP User-Agent header value is '"" <TAB> <TAB> <TAB> <TAB> <TAB> + menu. options. agent <TAB> <TAB> <TAB> <TAB> <TAB> + ""'."" <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> print ( settings. print_info_msg ( info_msg ) ) <TAB> <TAB> <TAB> except : <TAB> <TAB> <TAB> <TAB> print ( settings. FAIL_STATUS )",False,menu.options.agent != settings.DEFAULT_USER_AGENT or menu.options.mobile,settings.user_agent_string,0.653887927532196
|
||
|
3999,"def makeFootnotesDiv ( self, root ) : <TAB> """"""Return div of footnotes as et Element."""""" <TAB> if not list ( self. footnotes. keys ( ) ) : <TAB> <TAB> return None <TAB> div = util. etree. Element ( ""div"" ) <TAB> div. set ( ""class"", ""footnote"" ) <TAB> util. etree. SubElement ( div, ""hr"" ) <TAB> ol = util. etree. SubElement ( div, ""ol"" ) <TAB> surrogate_parent = util. etree. Element ( ""div"" ) <TAB> for id in self. footnotes. keys ( ) : <TAB> <TAB> li = util. etree. SubElement ( ol, ""li"" ) <TAB> <TAB> li. set ( ""id"", self. makeFootnoteId ( id ) ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. parser. parseChunk ( surrogate_parent, self. footnotes [ id ] ) <TAB> <TAB> for el in list ( surrogate_parent ) : <TAB> <TAB> <TAB> li. append ( el ) <TAB> <TAB> <TAB> surrogate_parent. remove ( el ) <TAB> <TAB> backlink = util. etree. Element ( ""a"" ) <TAB> <TAB> backlink. set ( ""href"", ""#"" + self. makeFootnoteRefId ( id ) ) <TAB> <TAB> if self. md. output_format not in [ ""html5"", ""xhtml5"" ] : <TAB> <TAB> <TAB> backlink. set ( ""rev"", ""footnote"" ) <TAB> <TAB> backlink. set ( ""class"", ""footnote-backref"" ) <TAB> <TAB> backlink. set ( <TAB> <TAB> <TAB> ""title"", self. getConfig ( ""BACKLINK_TITLE"" ) % ( self. footnotes. index ( id ) + 1 ) <TAB> <TAB> ) <TAB> <TAB> backlink. text = FN_BACKLINK_TEXT <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> node = li [ - 1 ] <TAB> <TAB> <TAB> if node.",False,len(li),li > 0,0.6595869064331055
|
||
|
4000,"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. STRING : <TAB> <TAB> <TAB> <TAB> self. dbname = iprot. readString ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> if ftype == TType. LIST : <TAB> <TAB> <TAB> <TAB> self. tbl_names = [ ] <TAB> <TAB> <TAB> <TAB> ( _etype690, _size687 ) = iprot. readListBegin ( ) <TAB> <TAB> <TAB> <TAB> for _i691 in xrange ( _size687 ) : <TAB> <TAB> <TAB> <TAB> <TAB> _elem692 = iprot. readString ( ) <TAB> <TAB> <TAB> <TAB> <TAB> self. tbl_names. append ( _elem692 ) <TAB> <TAB> <TAB> <TAB> iprot. readListEnd ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> else : <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB",True,fid == 2,fid == 2,0.679181694984436
|
||
|
4001,"def move_to_obj ( self, arg, attr = None ) : <TAB> if not arg : <TAB> <TAB> return <TAB> lst = self. get_list ( ) <TAB> if not lst : <TAB> <TAB> return <TAB> do_get_attr = isinstance ( attr, str ) <TAB> good = arg <TAB> if do_get_attr : <TAB> <TAB> try : <TAB> <TAB> <TAB> good = getattr ( arg, attr ) <TAB> <TAB> except ( TypeError, AttributeError ) : <TAB> <TAB> <TAB> pass <TAB> for obj, i in zip ( lst, range ( len ( lst ) ) ) : <TAB> <TAB> if do_get_attr : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> test = getattr ( obj, attr ) <TAB> <TAB> <TAB> except AttributeError : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> else : <TAB> <TAB> <TAB> test = obj <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. move ( absolute = i ) <TAB> <TAB> <TAB> return True <TAB> return self. move ( absolute = self. pointer )",False,test == good,good and test and (i > 0),0.6686276197433472
|
||
|
4002,"def two_mat_relative_entropy ( mat_1, mat_2, logbase = 2, diag = diagALL ) : <TAB> """"""Return relative entropy of two matrices."""""" <TAB> rel_ent = 0.0 <TAB> key_list_1 = sorted ( mat_1 ) <TAB> key_list_2 = sorted ( mat_2 ) <TAB> key_list = [ ] <TAB> sum_ent_1 = 0.0 <TAB> sum_ent_2 = 0.0 <TAB> for i in key_list_1 : <TAB> <TAB> if i in key_list_2 : <TAB> <TAB> <TAB> key_list. append ( i ) <TAB> if len ( key_list_1 )!= len ( key_list_2 ) : <TAB> <TAB> sys. stderr. write ( ""Warning: first matrix has more entries than the second\n"" ) <TAB> if key_list_1!= key_list_2 : <TAB> <TAB> sys. stderr. write ( ""Warning: indices not the same between matrices\n"" ) <TAB> for key in key_list : <TAB> <TAB> if diag == diagNO and key [ 0 ] == key [ 1 ] : <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> if mat_1 [ key ] > EPSILON and mat_2 [ key ] > EPSILON : <TAB> <TAB> <TAB> sum_ent_1 += mat_1 [ key ] <TAB> <TAB> <TAB> sum_ent_2 += mat_2 [ key ] <TAB> for key in key_list : <TAB> <TAB> if diag == diagNO and key [ 0 ] == key [ 1 ] : <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> if mat_1 [ key ] > EPSILON and mat_2 [ key ] > EPSILON : <TAB> <TAB> <TAB> val_1 = mat_1 [ key ] / sum_ent_1 <TAB> <TAB> <TAB> val_2 = mat_2 [ key ] / sum",False,diag == diagONLY and key[0] != key[1],mat_1[key] > rel_ent or mat_2[key] > sum_ent_1,0.656577467918396
|
||
|
4003,"def calc_person ( self, index, indi_handle, fams_handle ) : <TAB> working_lines = """" <TAB> if index [ 1 ] % 2 == 0 or ( index [ 1 ] == 1 and self. center_use == 0 ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> working_lines = self. __calc_l. calc_lines ( <TAB> <TAB> <TAB> <TAB> None, None, self. _gui. get_val ( ""father_disp"" ) <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> working_lines = self. disp_father <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> working_lines = self. __calc_l. calc_lines ( <TAB> <TAB> <TAB> <TAB> None, None, self. _gui. get_val ( ""mother_disp"" ) <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> working_lines = self. disp_mother <TAB> if<mask> : <TAB> <TAB> return working_lines <TAB> else : <TAB> <TAB> return self. __calc_l. calc_lines ( indi_handle, fams_handle, working_lines )",False,indi_handle == fams_handle == None,self.center_use == 1,0.6546370387077332
|
||
|
4004,"def file_update_many ( fh, points, now = None ) : <TAB> if LOCK : <TAB> <TAB> fcntl. flock ( fh. fileno ( ), fcntl. LOCK_EX ) <TAB> header = __readHeader ( fh ) <TAB> if now is None : <TAB> <TAB> now = int ( time. time ( ) ) <TAB> archives = iter ( header [ ""archives"" ] ) <TAB> currentArchive = next ( archives ) <TAB> currentPoints = [ ] <TAB> for point in points : <TAB> <TAB> age = now - point [ 0 ] <TAB> <TAB> while ( <TAB> <TAB> <TAB> currentArchive [ ""retention"" ] < age <TAB> <TAB> ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> currentPoints. reverse ( ) <TAB> <TAB> <TAB> <TAB> __archive_update_many ( fh, header, currentArchive, currentPoints ) <TAB> <TAB> <TAB> <TAB> currentPoints = [ ] <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> currentArchive = next ( archives ) <TAB> <TAB> <TAB> except StopIteration : <TAB> <TAB> <TAB> <TAB> currentArchive = None <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> if not currentArchive : <TAB> <TAB> <TAB> break <TAB> <TAB> currentPoints. append ( point ) <TAB> <TAB> if currentArchive and currentPoints : <TAB> <TAB> currentPoints. reverse ( ) <TAB> <TAB> __archive_update_many ( fh, header, currentArchive, currentPoints ) <TAB> if AUTOFLUSH : <TAB> <TAB> fh. flush ( ) <TAB> <TAB> os. fsync ( fh. fileno ( ) )",True,currentPoints,currentPoints,0.6865641474723816
|
||
|
4005,"def testCoreInterfaceIntInputData ( ) : <TAB> result_testing = False <TAB> for _ in range ( 10 ) : <TAB> <TAB> hsyncnet_instance = hsyncnet ( <TAB> <TAB> <TAB> [ [ 1 ], [ 2 ], [ 3 ], [ 20 ], [ 21 ], [ 22 ] ], 2, initial_type. EQUIPARTITION, ccore = True <TAB> <TAB> ) <TAB> <TAB> analyser = hsyncnet_instance. process ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> result_testing = True <TAB> <TAB> <TAB> break <TAB> assert result_testing",False,len(analyser.allocate_clusters(0.1)) == 2,analyser.get_num_rows() > 0,0.6531205177307129
|
||
|
4006,"def set_default ( self, line ) : <TAB> if ""Default:"" in line : <TAB> <TAB> default_val = line [ line. find ( ""Default:"" ) + len ( ""Default:"" ) : ] <TAB> <TAB> default_val = default_val. strip ( ) <TAB> <TAB> float_mode = default_val [ 0 ]. isnumeric ( ) <TAB> <TAB> list_mode = default_val [ 0 ] == ""["" <TAB> <TAB> end_pos = - 1 <TAB> <TAB> first_point = True <TAB> <TAB> if float_mode or list_mode : <TAB> <TAB> <TAB> for index, ele in enumerate ( default_val ) : <TAB> <TAB> <TAB> <TAB> end_pos = index <TAB> <TAB> <TAB> <TAB> if float_mode and ele. isnumeric ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> if float_mode and ele == ""."" and first_point : <TAB> <TAB> <TAB> <TAB> <TAB> first_point = False <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> elif float_mode : <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> elif list_mode and ele == ""]"" : <TAB> <TAB> <TAB> <TAB> <TAB> end_pos += 1 <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> else : <TAB> <TAB> <TAB> poses = [ <TAB> <TAB> <TAB> <TAB> max ( <TAB> <TAB> <TAB> <TAB> <TAB> [ <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> default_val. find ( "". "" ), <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> default_val. find ( ""."" ), <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> default_val. find ( '.""' ), <TAB>",False,end_pos != -1,len(line) > 0,0.6596670150756836
|
||
|
4007,"def TryMerge ( self, d ) : <TAB> while d. avail ( ) > 0 : <TAB> <TAB> tt = d. getVarInt32 ( ) <TAB> <TAB> if tt == 10 : <TAB> <TAB> <TAB> self. set_id ( d. getPrefixedString ( ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if tt == 18 : <TAB> <TAB> <TAB> self. set_language ( 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. add_field ( ). TryMerge ( tmp ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. set_order_id ( d. getVarInt32 ( ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if tt == 40 : <TAB> <TAB> <TAB> self. set_storage ( d. getVarInt32 ( ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if tt == 50 : <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_acl ( ). TryMerge ( tmp ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if tt == 56 : <TAB> <TAB> <TAB> self. set_version ( d. getVarInt64 ( ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if tt == 0 : <TAB> <TAB> <TAB> raise ProtocolBuffer. ProtocolBufferDecodeError <TAB>",True,tt == 32,tt == 32,0.6817759275436401
|
||
|
4008,"def __init__ ( self, pattern, flags = 0 ) : <TAB> """"""The parameters C{pattern} and C{flags} are passed to the C{re.compile()} function as-is. See the Python C{re} module for an explanation of the acceptable patterns and flags."""""" <TAB> super ( Regex, self ). __init__ ( ) <TAB> if isinstance ( pattern, basestring ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> warnings. warn ( <TAB> <TAB> <TAB> <TAB> ""null string passed to Regex; use Empty() instead"", <TAB> <TAB> <TAB> <TAB> SyntaxWarning, <TAB> <TAB> <TAB> <TAB> stacklevel = 2, <TAB> <TAB> <TAB> ) <TAB> <TAB> self. pattern = pattern <TAB> <TAB> self. flags = flags <TAB> <TAB> try : <TAB> <TAB> <TAB> self. re = re. compile ( self. pattern, self. flags ) <TAB> <TAB> <TAB> self. reString = self. pattern <TAB> <TAB> except sre_constants. error : <TAB> <TAB> <TAB> warnings. warn ( <TAB> <TAB> <TAB> <TAB> ""invalid pattern (%s) passed to Regex"" % pattern, <TAB> <TAB> <TAB> <TAB> SyntaxWarning, <TAB> <TAB> <TAB> <TAB> stacklevel = 2, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> raise <TAB> elif isinstance ( pattern, Regex. compiledREtype ) : <TAB> <TAB> self. re = pattern <TAB> <TAB> self. pattern = self. reString = str ( pattern ) <TAB> <TAB> self. flags = flags <TAB> else : <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> ""Regex may only be constructed with a string or a compiled RE object"" <TAB> <TAB> ) <TAB> self. name = _ustr ( self ) <TAB> self. errmsg = ""Expected "" + self. name <TAB> self. mayIndexError = False <TAB> self. mayReturnEmpty = True",True,len(pattern) == 0,len(pattern) == 0,0.6583430767059326
|
||
|
4009,"def process_pipeline ( collection, database, pipeline, session ) : <TAB> if session : <TAB> <TAB> raise NotImplementedError ( ""Mongomock does not handle sessions yet"" ) <TAB> for stage in pipeline : <TAB> <TAB> for operator, options in six. iteritems ( stage ) : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> handler = _PIPELINE_HANDLERS [ operator ] <TAB> <TAB> <TAB> except KeyError as err : <TAB> <TAB> <TAB> <TAB> raise_from ( <TAB> <TAB> <TAB> <TAB> <TAB> NotImplementedError ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""%s is not a valid operator for the aggregation pipeline. "" <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""See http://docs.mongodb.org/manual/meta/aggregation-quick-reference/ "" <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""for a complete list of valid operators."" % operator <TAB> <TAB> <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> <TAB> <TAB> err, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise NotImplementedError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Although '%s' is a valid operator for the aggregation pipeline, it is "" <TAB> <TAB> <TAB> <TAB> <TAB> ""currently not implemented in Mongomock."" % operator <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> collection = handler ( collection, database, options ) <TAB> return command_cursor. CommandCursor ( collection )",False,not handler,database,0.6782671213150024
|
||
|
4010,"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<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. STRING : <TAB> <TAB> <TAB> <TAB> self. delegationToken = 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 == 1,fid == 1,0.6761176586151123
|
||
|
4011,"def set ( self, key, data, timeout = None ) : <TAB> filename = self. _key_to_filename ( key ) <TAB> dirname = os. path. dirname ( filename ) <TAB> if timeout is None : <TAB> <TAB> timeout = self. _default_timeout <TAB> try : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> os. makedirs ( dirname ) <TAB> <TAB> <TAB> <TAB> f = os. open ( filename, os. O_EXCL | os. O_WRONLY | os. O_CREAT ) <TAB> <TAB> try : <TAB> <TAB> <TAB> os. write ( f, pickle. dumps ( data, pickle. HIGHEST_PROTOCOL ) ) <TAB> <TAB> finally : <TAB> <TAB> <TAB> os. close ( f ) <TAB> <TAB> <TAB> <TAB> os. utime ( filename, ( 0, time. time ( ) + timeout ) ) <TAB> except ( IOError, OSError ) : <TAB> <TAB> pass",True,not os.path.exists(dirname),not os.path.exists(dirname),0.6489837169647217
|
||
|
4012,"def _on_protocol_state_changed ( self, state ) : <TAB> if state == WANoiseProtocol. STATE_TRANSPORT : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> config = self. _config_manager. load ( self. _username ) <TAB> <TAB> <TAB> config. server_static_public = self. _wa_noiseprotocol. rs <TAB> <TAB> <TAB> self. _config_manager. save ( config ) <TAB> <TAB> <TAB> self. _rs = self. _wa_noiseprotocol. rs <TAB> <TAB> self. _flush_incoming_buffer ( )",False,self._rs != self._wa_noiseprotocol.rs,self._username is not None,0.6569958925247192
|
||
|
4013,"def wait ( self ) : <TAB> while True : <TAB> <TAB> return_code = self. _process. poll ( ) <TAB> <TAB> if return_code is not None : <TAB> <TAB> <TAB> line = self. _process. stdout. readline ( ). decode ( ""utf-8"" ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> log. debug ( line. strip ( ""\n"" ) ) <TAB> return True",False,line == '',not line,0.6751984357833862
|
||
|
4014,def has_price ( self ) : <TAB> if self. can_decode_claim : <TAB> <TAB> claim = self. claim <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> stream = claim. stream <TAB> <TAB> <TAB> return stream. has_fee and stream. fee. amount and stream. fee. amount > 0 <TAB> return False,False,claim.is_stream,claim,0.6609058380126953
|
||
|
4015,"def _in_out_vector_helper ( self, name1, name2, ceil ) : <TAB> vector = [ ] <TAB> stats = self. record <TAB> if ceil is None : <TAB> <TAB> ceil = self. _get_max_rate ( name1, name2 ) <TAB> maxlen = self. config. get_stats_history_length ( ) <TAB> for n in [ name1, name2 ] : <TAB> <TAB> for i in range ( maxlen + 1 ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> vector. append ( float ( stats [ i ] [ n ] ) / ceil ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> vector. append ( 0.0 ) <TAB> return vector",False,i < len(stats),stats[i] is not None,0.6611990928649902
|
||
|
4016,"def check_path_owner ( path ) : <TAB> <TAB> <TAB> <TAB> if not hasattr ( os, ""geteuid"" ) : <TAB> <TAB> return True <TAB> previous = None <TAB> while path!= previous : <TAB> <TAB> if os. path. lexists ( path ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> path_uid = get_path_uid ( path ) <TAB> <TAB> <TAB> <TAB> except OSError : <TAB> <TAB> <TAB> <TAB> <TAB> return False <TAB> <TAB> <TAB> <TAB> return path_uid == 0 <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> return os. access ( path, os. W_OK ) <TAB> <TAB> else : <TAB> <TAB> <TAB> previous, path = path, os. path. dirname ( path ) <TAB> return False",False,os.geteuid() == 0,os.path.isdir(path),0.662284255027771
|
||
|
4017,"def Tool ( self, tool, toolpath = None, ** kw ) : <TAB> if SCons. Util. is_String ( tool ) : <TAB> <TAB> tool = self. subst ( tool ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> toolpath = self. get ( ""toolpath"", [ ] ) <TAB> <TAB> toolpath = list ( map ( self. _find_toolpath_dir, toolpath ) ) <TAB> <TAB> tool = SCons. Tool. Tool ( tool, toolpath, ** kw ) <TAB> tool ( self )",True,toolpath is None,toolpath is None,0.6637915968894958
|
||
|
4018,"def _init_nvml ( ) : <TAB> global _nvml_lib, _no_device_warned <TAB> if _init_pid == os. getpid ( ) : <TAB> <TAB> return <TAB> nvml_paths = [ <TAB> <TAB> ""libnvidia-ml.so"", <TAB> <TAB> ""libnvidia-ml.so.1"", <TAB> <TAB> ""libnvidia-ml.dylib"", <TAB> <TAB> ""nvml.dll"", <TAB> ] <TAB> if sys. platform [ : 3 ] == ""win"" : <TAB> <TAB> nvml_paths. append ( <TAB> <TAB> <TAB> os. path. join ( <TAB> <TAB> <TAB> <TAB> os. getenv ( ""ProgramFiles"", ""C:/Program Files"" ), <TAB> <TAB> <TAB> <TAB> ""NVIDIA Corporation/NVSMI/nvml.dll"", <TAB> <TAB> <TAB> ) <TAB> <TAB> ) <TAB> _nvml_lib = _load_nv_library ( * nvml_paths ) <TAB> if _nvml_lib is None : <TAB> <TAB> return <TAB> try : <TAB> <TAB> _nvml_check_error ( _nvml_lib. nvmlInit_v2 ( ) ) <TAB> except NVMLAPIError as ex : <TAB> <TAB> if ex. errno == NVML_DRIVER_NOT_LOADED : <TAB> <TAB> <TAB> _nvml_lib = None <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> logger. warning ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Failed to load libnvidia-ml: %s, no CUDA device will be enabled"", <TAB> <TAB> <TAB> <TAB> <TAB> ex. message, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> _no_device_warned = True <TAB> <TAB> else : <TAB> <TAB> <TAB> logger. exception",False,not _no_device_warned,_no_device_warned,0.6536405086517334
|
||
|
4019,"def get_tokens_unprocessed ( self, text ) : <TAB> buffered = """" <TAB> insertions = [ ] <TAB> lng_buffer = [ ] <TAB> for i, t, v in self. language_lexer. get_tokens_unprocessed ( text ) : <TAB> <TAB> if t is self. needle : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> insertions. append ( ( len ( buffered ), lng_buffer ) ) <TAB> <TAB> <TAB> <TAB> lng_buffer = [ ] <TAB> <TAB> <TAB> buffered += v <TAB> <TAB> else : <TAB> <TAB> <TAB> lng_buffer. append ( ( i, t, v ) ) <TAB> if<mask> : <TAB> <TAB> insertions. append ( ( len ( buffered ), lng_buffer ) ) <TAB> return do_insertions ( insertions, self. root_lexer. get_tokens_unprocessed ( buffered ) )",False,lng_buffer,i == 0,0.680876612663269
|
||
|
4020,"def _add_auth_information ( self ) : <TAB> if self. message_type == ""logstash"" : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> logstash_auth = requests. auth. HTTPBasicAuth ( self. username, self. password ) <TAB> <TAB> self. session. auth = logstash_auth <TAB> elif self. message_type == ""splunk"" : <TAB> <TAB> auth_header = ""Splunk %s"" % self. password <TAB> <TAB> headers = { ""Authorization"" : auth_header, ""Content-Type"" : ""application/json"" } <TAB> <TAB> self. session. headers. update ( headers )",False,not self.username,self.username and self.password,0.6592991352081299
|
||
|
4021,"def _table_reprfunc ( self, row, col, val ) : <TAB> if self. _table. column_names [ col ]. endswith ( ""Size"" ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return "" %s"" % val <TAB> <TAB> elif val < 1024 ** 2 : <TAB> <TAB> <TAB> return "" %.1f KB"" % ( val / 1024.0 ** 1 ) <TAB> <TAB> elif val < 1024 ** 3 : <TAB> <TAB> <TAB> return "" %.1f MB"" % ( val / 1024.0 ** 2 ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return "" %.1f GB"" % ( val / 1024.0 ** 3 ) <TAB> if col in ( 0, """" ) : <TAB> <TAB> return str ( val ) <TAB> else : <TAB> <TAB> return "" %s"" % val",False,"isinstance(val, compat.string_types)",val < 1024,0.6479079127311707
|
||
|
4022,"def loadalbum ( albumname ) : <TAB> song_ids = [ ] <TAB> album = str ( albumname ) <TAB> if os. path. isfile ( ""{}/songs.json"". format ( USER_PATH ) ) : <TAB> <TAB> with open ( ""{}/songs.json"". format ( USER_PATH ), ""r"" ) as input_file : <TAB> <TAB> <TAB> songs_list = json. load ( input_file ) <TAB> <TAB> else : <TAB> <TAB> songs_list = api. get_all_songs ( ) <TAB> <TAB> with open ( ""{}/songs.json"". format ( USER_PATH ), ""w"" ) as output_file : <TAB> <TAB> <TAB> json. dump ( songs_list, output_file ) <TAB> for i in range ( 0, len ( songs_list ) ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> song_ids. append ( songs_list [ i ] [ ""id"" ] ) <TAB> <TAB> else : <TAB> <TAB> <TAB> print ( ""Album not found"" ) <TAB> songsnum = len ( song_ids ) <TAB> return song_ids, songsnum",False,album.lower() in songs_list[i]['album'].lower(),songs_list[i],0.654258131980896
|
||
|
4023,"def event_handler ( event ) : <TAB> if isinstance ( event, EndEpochEvent ) : <TAB> <TAB> test_reader = paddle. batch ( paddle. dataset. mnist. test ( ), batch_size = BATCH_SIZE ) <TAB> <TAB> avg_cost, acc = trainer. test ( reader = test_reader, feed_order = [ ""img"", ""label"" ] ) <TAB> <TAB> print ( ""avg_cost: %s"" % avg_cost ) <TAB> <TAB> print ( ""acc : %s"" % acc ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> trainer. save_params ( params_dirname ) <TAB> <TAB> else : <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> ""BatchID {0}, Test Loss {1:0.2}, Acc {2:0.2}"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> event. epoch + 1, avg_cost, acc <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if math. isnan ( avg_cost ) : <TAB> <TAB> <TAB> <TAB> sys. exit ( ""got NaN loss, training failed."" ) <TAB> elif isinstance ( event, EndStepEvent ) : <TAB> <TAB> print ( <TAB> <TAB> <TAB> ( <TAB> <TAB> <TAB> <TAB> ""Step {0}, Epoch {1} Metrics {2}"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> event. step, event. epoch, list ( map ( numpy. array, event. metrics ) ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> )",False,acc > 0.2,"hasattr(trainer, 'save_params')",0.6596013307571411
|
||
|
4024,"def get_spec ( spec_file, spec_name, lab_mode, pre_ ) : <TAB> """"""Get spec using args processed from inputs"""""" <TAB> if lab_mode in TRAIN_MODES : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> spec = spec_util. get ( spec_file, spec_name ) <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> predir = pre_ <TAB> <TAB> <TAB> if predir == ""latest"" : <TAB> <TAB> <TAB> <TAB> predir = sorted ( glob ( f""data/{spec_name}*/"" ) ) [ <TAB> <TAB> <TAB> <TAB> <TAB> - 1 <TAB> <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> _, _, _, _, experiment_ts = util. prepath_split ( <TAB> <TAB> <TAB> <TAB> predir <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> logger. info ( f""Resolved to train@{predir}"" ) <TAB> <TAB> <TAB> spec = spec_util. get ( spec_file, spec_name, experiment_ts ) <TAB> elif lab_mode == ""enjoy"" : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> session_spec_file = pre_ <TAB> <TAB> assert ( <TAB> <TAB> <TAB> session_spec_file is not None <TAB> <TAB> ), ""enjoy mode must specify a `enjoy@{session_spec_file}`"" <TAB> <TAB> spec = util. read ( f""{session_spec_file}"" ) <TAB> else : <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> f""Unrecognizable lab_mode not of {TRAIN_MODES} or {EVAL_MODES}"" <TAB> <TAB> ) <TAB> return spec",False,pre_ is None,spec_name in spec_util,0.6618254780769348
|
||
|
4025,"def __setattr__ ( self, option_name, option_value ) : <TAB> if option_name in self. _options : <TAB> <TAB> <TAB> <TAB> sort = self. OPTIONS [ self. arch. name ] [ option_name ] [ 0 ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _options [ option_name ] = option_value <TAB> <TAB> else : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> 'Value for option ""%s"" must be of type %s' % ( option_name, sort ) <TAB> <TAB> <TAB> ) <TAB> else : <TAB> <TAB> super ( CFGArchOptions, self ). __setattr__ ( option_name, option_value )",False,"sort is None or isinstance(option_value, sort)","sort in (TAB > <TAB > <TAB> or isinstance(option_value, CFGArchOptions)",0.6525413393974304
|
||
|
4026,"def __str__ ( self ) : <TAB> """"""Only keeps the True values."""""" <TAB> result = [ ""SlicingSpec("" ] <TAB> if self. entire_dataset : <TAB> <TAB> result. append ( "" Entire dataset,"" ) <TAB> if self. by_class : <TAB> <TAB> if isinstance ( self. by_class, Iterable ) : <TAB> <TAB> <TAB> result. append ( "" Into classes %s,"" % self. by_class ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> result. append ( "" Up to class %d,"" % self. by_class ) <TAB> <TAB> else : <TAB> <TAB> <TAB> result. append ( "" By classes,"" ) <TAB> if self. by_percentiles : <TAB> <TAB> result. append ( "" By percentiles,"" ) <TAB> if self. by_classification_correctness : <TAB> <TAB> result. append ( "" By classification correctness,"" ) <TAB> result. append ( "")"" ) <TAB> return ""\n"". join ( result )",False,"isinstance(self.by_class, int)","isinstance(self.by_class, Number)",0.6511653065681458
|
||
|
4027,"def checkFilename ( filename ) : <TAB> while True : <TAB> <TAB> if filename [ 0 ] == ""'"" : <TAB> <TAB> <TAB> filename = filename [ 1 : ] <TAB> <TAB> if filename [ len ( filename ) - 1 ] == ""'"" : <TAB> <TAB> <TAB> filename = filename [ : - 1 ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return filename <TAB> <TAB> filename = input ( <TAB> <TAB> <TAB> ""[!] Cannot find '%s'.\n[*] Enter a valid name of the file containing the paths to test -> "" <TAB> <TAB> <TAB> % filename <TAB> <TAB> )",False,os.path.exists(filename),"filename[len(filename) == ""'""",0.6533585786819458
|
||
|
4028,"def fact ( n ) : <TAB> if n < 1 : <TAB> <TAB> raise ValueError ( ""fact() argument should be >= 1"" ) <TAB> if n == 1 : <TAB> <TAB> return [ ] <TAB> res = [ ] <TAB> <TAB> while n % 2 == 0 : <TAB> <TAB> res. append ( 2 ) <TAB> <TAB> n //= 2 <TAB> <TAB> limit = sqrt ( n + 1 ) <TAB> i = 3 <TAB> while i <= limit : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> res. append ( i ) <TAB> <TAB> <TAB> n //= i <TAB> <TAB> <TAB> limit = sqrt ( n + 1 ) <TAB> <TAB> else : <TAB> <TAB> <TAB> i += 2 <TAB> if n!= 1 : <TAB> <TAB> res. append ( n ) <TAB> return res",False,n % i == 0,n % 2 == 0,0.6830201148986816
|
||
|
4029,"def _getString ( self ) : <TAB> c = self. _getChar ( ) <TAB> if c is SyntaxToken. EOF or c!= '""' : <TAB> <TAB> raise Exception ( ""Internal: parsing string?"" ) <TAB> res = """" <TAB> escape = False <TAB> c = self. _peekChar ( ) <TAB> while True : <TAB> <TAB> if c is SyntaxToken. EOF : <TAB> <TAB> <TAB> raise Exception ( ""Hit EOF in string literal."" ) <TAB> <TAB> elif c == ""\n"" or c == ""\r"" : <TAB> <TAB> <TAB> raise Exception ( ""Hit newline in string literal"" ) <TAB> <TAB> elif c == ""\\"" and not escape : <TAB> <TAB> <TAB> self. _getChar ( ) <TAB> <TAB> <TAB> escape = True <TAB> <TAB> elif c == '""' and not escape : <TAB> <TAB> <TAB> self. _getChar ( ) <TAB> <TAB> <TAB> return StringToken ( res ) <TAB> <TAB> elif escape : <TAB> <TAB> <TAB> escape = False <TAB> <TAB> <TAB> self. _getChar ( ) <TAB> <TAB> <TAB> if c == ""n"" : <TAB> <TAB> <TAB> <TAB> res = res + ""\n"" <TAB> <TAB> <TAB> elif c == ""t"" : <TAB> <TAB> <TAB> <TAB> res = res + ""\t"" <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> res = res = ""\r"" <TAB> <TAB> <TAB> elif c == '""' : <TAB> <TAB> <TAB> <TAB> res = res + c <TAB> <TAB> <TAB> elif c == ""\\"" : <TAB> <TAB> <TAB> <TAB> res = res + c <TAB> <TAB> else : <TAB> <TAB> <TAB> self. _getChar ( ) <TAB> <TAB> <TAB> res = res + c <TAB> <TAB> c = self. _peekChar ( )",True,c == 'r',c == 'r',0.665661096572876
|
||
|
4030,"def main ( ) : <TAB> testmergeinto ( ) <TAB> try : <TAB> <TAB> by = bypy. ByPy ( configdir = ConfigDir, debug = 1, verbose = 1 ) <TAB> <TAB> if ""refresh"" in sys. argv : <TAB> <TAB> <TAB> by. refreshtoken ( ) <TAB> <TAB> if ""many"" in sys. argv : <TAB> <TAB> <TAB> testmanyfiles ( by ) <TAB> <TAB> <TAB> return <TAB> <TAB> runTests ( by ) <TAB> <TAB> if ""1"" in sys. argv : <TAB> <TAB> <TAB> return <TAB> <TAB> time. sleep ( 10 ) <TAB> <TAB> by = bypy. ByPy ( configdir = ConfigDir, processes = 2, debug = 1, verbose = 1 ) <TAB> <TAB> runTests ( by ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> <TAB> by = bypy. ByPy ( configdir = ConfigDir, downloader = ""aria2"", debug = 1, verbose = 1 ) <TAB> <TAB> downdir ( by ) <TAB> <TAB> by = bypy. ByPy ( <TAB> <TAB> <TAB> configdir = ConfigDir, downloader = ""aria2"", processes = 2, debug = 1, verbose = 1 <TAB> <TAB> ) <TAB> <TAB> downdir ( by ) <TAB> except KeyboardInterrupt : <TAB> <TAB> print ( ""User cancelled, cleaning up..."" ) <TAB> finally : <TAB> <TAB> cleanup ( ) <TAB> <TAB> print ( ""Clean up done."" )",False,'2' in sys.argv,'1' in sys.argv,0.6544889211654663
|
||
|
4031,"def _wait_for_multipass_ready ( cls, *, echoer ) : <TAB> echoer. wrapped ( ""Waiting for multipass..."" ) <TAB> retry_count = 60 <TAB> while retry_count : <TAB> <TAB> try : <TAB> <TAB> <TAB> output = subprocess. check_output ( [ cls. provider_cmd, ""version"" ] ). decode ( ) <TAB> <TAB> except subprocess. CalledProcessError : <TAB> <TAB> <TAB> output = """" <TAB> <TAB> except FileNotFoundError : <TAB> <TAB> <TAB> raise errors. ProviderStartError ( <TAB> <TAB> <TAB> <TAB> provider_name = cls. provider_name, <TAB> <TAB> <TAB> <TAB> error_message = ""multipass not found - please check that it"" <TAB> <TAB> <TAB> <TAB> "" can be found in the configured PATH"", <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> break <TAB> <TAB> retry_count -= 1 <TAB> <TAB> sleep ( 1 )",False,'multipassd' in output,retry_count == 0,0.6611419916152954
|
||
|
4032,"def i_rol ( self, op ) : <TAB> dstSize = op. opers [ 0 ]. tsize <TAB> count = self. getOperValue ( op, 1 ) <TAB> tempCount = shiftMask ( count, dstSize ) <TAB> if tempCount > 0 : <TAB> <TAB> while tempCount : <TAB> <TAB> <TAB> val = self. getOperValue ( op, 0 ) <TAB> <TAB> <TAB> tempCf = e_bits. msb ( val, dstSize ) <TAB> <TAB> <TAB> self. setOperValue ( op, 0, ( val * 2 ) + tempCf ) <TAB> <TAB> <TAB> tempCount -= 1 <TAB> <TAB> val = self. getOperValue ( op, 0 ) <TAB> <TAB> self. setFlag ( EFLAGS_CF, e_bits. lsb ( val ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> val = self. getOperValue ( op, 0 ) <TAB> <TAB> <TAB> cf = self. getFlag ( EFLAGS_CF ) <TAB> <TAB> <TAB> self. setFlag ( EFLAGS_OF, e_bits. msb ( val, dstSize ) ^ cf ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. setFlag ( EFLAGS_OF, False )",False,count == 1,dstSize > 0,0.6736946105957031
|
||
|
4033,"def _scrub_generated_timestamps ( self, target_workdir ) : <TAB> """"""Remove the first line of comment from each file if it contains a timestamp."""""" <TAB> for root, _, filenames in safe_walk ( target_workdir ) : <TAB> <TAB> for filename in filenames : <TAB> <TAB> <TAB> source = os. path. join ( root, filename ) <TAB> <TAB> <TAB> with open ( source, ""r"" ) as f : <TAB> <TAB> <TAB> <TAB> lines = f. readlines ( ) <TAB> <TAB> <TAB> if len ( lines ) < 1 : <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> with open ( source, ""w"" ) as f : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> f. write ( lines [ 0 ] ) <TAB> <TAB> <TAB> <TAB> for line in lines [ 1 : ] : <TAB> <TAB> <TAB> <TAB> <TAB> f. write ( line )",False,not self._COMMENT_WITH_TIMESTAMP_RE.match(lines[0]),len(lines) > 1,0.6501803398132324
|
||
|
4034,"def _encode_numpy ( values, uniques = None, encode = False, check_unknown = True ) : <TAB> <TAB> if uniques is None : <TAB> <TAB> if encode : <TAB> <TAB> <TAB> uniques, encoded = np. unique ( values, return_inverse = True ) <TAB> <TAB> <TAB> return uniques, encoded <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return np. unique ( values ) <TAB> if encode : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> diff = _encode_check_unknown ( values, uniques ) <TAB> <TAB> <TAB> if diff : <TAB> <TAB> <TAB> <TAB> raise ValueError ( ""y contains previously unseen labels: %s"" % str ( diff ) ) <TAB> <TAB> encoded = np. searchsorted ( uniques, values ) <TAB> <TAB> return uniques, encoded <TAB> else : <TAB> <TAB> return uniques",True,check_unknown,check_unknown,0.6630774736404419
|
||
|
4035,"def check_command ( self ) : <TAB> exit_status = self. p. poll ( ) <TAB> if exit_status is not None : <TAB> <TAB> output = self. p. stdout. read ( ) <TAB> <TAB> lines = output. split ( ""\n"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> lines = lines [ : - 1 ] <TAB> <TAB> command = os. path. basename ( self. command ) <TAB> <TAB> if exit_status : <TAB> <TAB> <TAB> logging. warn ( <TAB> <TAB> <TAB> <TAB> ""%s: command has finished with non-zero exit status: %s"" <TAB> <TAB> <TAB> <TAB> % ( command, exit_status ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> for line in lines : <TAB> <TAB> <TAB> <TAB> logging. warn ( ""%s: %s"" % ( command, line ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> logging. debug ( ""%s: command has finished"" % command ) <TAB> <TAB> <TAB> for line in lines : <TAB> <TAB> <TAB> <TAB> logging. debug ( ""%s: %s"" % ( command, line ) ) <TAB> <TAB> self. finish_json ( { ""status"" : exit_status } ) <TAB> else : <TAB> <TAB> self. io_loop. add_timeout ( <TAB> <TAB> <TAB> datetime. timedelta ( milliseconds = 100 ), self. check_command <TAB> <TAB> )",False,not lines[-1],lines[-1] > 0,0.6581934690475464
|
||
|
4036,"def resolve_value ( par : str, domain : Domain ) -> Dict : <TAB> sampler = domain. get_sampler ( ) <TAB> if isinstance ( sampler, Quantized ) : <TAB> <TAB> logger. warning ( <TAB> <TAB> <TAB> ""Dragonfly search does not support quantization. "" ""Dropped quantization."" <TAB> <TAB> ) <TAB> <TAB> sampler = sampler. get_sampler ( ) <TAB> if isinstance ( domain, Float ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> logger. warning ( <TAB> <TAB> <TAB> <TAB> ""Dragonfly does not support specific sampling methods."" <TAB> <TAB> <TAB> <TAB> "" The {} sampler will be dropped."". format ( sampler ) <TAB> <TAB> <TAB> ) <TAB> <TAB> return { ""name"" : par, ""type"" : ""float"", ""min"" : domain. lower, ""max"" : domain. upper } <TAB> raise ValueError ( <TAB> <TAB> ""Dragonfly does not support parameters of type "" <TAB> <TAB> ""`{}`"". format ( type ( domain ). __name__ ) <TAB> )",False,domain.sampler is not None,sampler.has_sampling_method(domain),0.6656016111373901
|
||
|
4037,"def walk ( self, path : path_type ) -> Iterator [ Tuple [ str, List [ str ], List [ str ] ] ] : <TAB> path = self. _process_path ( path ) <TAB> q = [ path ] <TAB> while q : <TAB> <TAB> curr = q. pop ( 0 ) <TAB> <TAB> file_selector : FileSelector = FileSelector ( curr ) <TAB> <TAB> dirs, files = [ ], [ ] <TAB> <TAB> for info in self. _arrow_fs. get_file_info ( file_selector ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> files. append ( info. base_name ) <TAB> <TAB> <TAB> elif info. type == FileType. Directory : <TAB> <TAB> <TAB> <TAB> dirs. append ( info. base_name ) <TAB> <TAB> <TAB> <TAB> q. append ( info. path ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> yield curr, dirs, files",True,info.type == FileType.File,info.type == FileType.File,0.6694533824920654
|
||
|
4038,"def _clean ( self ) : <TAB> logger. info ( ""Cleaning up..."" ) <TAB> if self. _process is not None : <TAB> <TAB> if self. _process. poll ( ) is None : <TAB> <TAB> <TAB> for _ in range ( 3 ) : <TAB> <TAB> <TAB> <TAB> self. _process. terminate ( ) <TAB> <TAB> <TAB> <TAB> time. sleep ( 0.5 ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. _process. kill ( ) <TAB> <TAB> <TAB> <TAB> self. _process. wait ( ) <TAB> <TAB> <TAB> <TAB> logger. error ( ""KILLED"" ) <TAB> if os. path. exists ( self. _tmp_dir ) : <TAB> <TAB> shutil. rmtree ( self. _tmp_dir ) <TAB> self. _process = None <TAB> self. _ws = None <TAB> logger. info ( ""Cleanup complete"" )",False,self._process.poll() is not None,self._ws is None,0.6496672630310059
|
||
|
4039,"def __jpeg ( self, stream ) : <TAB> if stream. read ( 2 ) == ""\xFF\xD8"" : <TAB> <TAB> while True : <TAB> <TAB> <TAB> ( marker, code, length ) = struct. unpack ( ""!BBH"", stream. read ( 4 ) ) <TAB> <TAB> <TAB> if marker!= 0xFF : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> return tuple ( reversed ( struct. unpack ( ""!xHH"", stream. read ( 5 ) ) ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> stream. read ( length - 2 ) <TAB> return - 1, - 1",False,code >= 192 and code <= 195,length > 2,0.6562279462814331
|
||
|
4040,"def describe_cluster_snapshots ( self, cluster_identifier = None, snapshot_identifier = None ) : <TAB> if cluster_identifier : <TAB> <TAB> cluster_snapshots = [ ] <TAB> <TAB> for snapshot in self. snapshots. values ( ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> cluster_snapshots. append ( snapshot ) <TAB> <TAB> if cluster_snapshots : <TAB> <TAB> <TAB> return cluster_snapshots <TAB> if snapshot_identifier : <TAB> <TAB> if snapshot_identifier in self. snapshots : <TAB> <TAB> <TAB> return [ self. snapshots [ snapshot_identifier ] ] <TAB> <TAB> raise ClusterSnapshotNotFoundError ( snapshot_identifier ) <TAB> return self. snapshots. values ( )",False,snapshot.cluster.cluster_identifier == cluster_identifier,snapshot,0.6535824537277222
|
||
|
4041,"def addBanTicket ( self, ticket, reason = { } ) : <TAB> eob = ticket. getEndOfBanTime ( self. __banTime ) <TAB> with self. __lock : <TAB> <TAB> <TAB> <TAB> fid = ticket. getID ( ) <TAB> <TAB> oldticket = self. __banList. get ( fid ) <TAB> <TAB> if oldticket : <TAB> <TAB> <TAB> reason [ ""ticket"" ] = oldticket <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if eob > oldticket. getEndOfBanTime ( self. __banTime ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> reason [ ""prolong"" ] = 1 <TAB> <TAB> <TAB> <TAB> btm = ticket. getBanTime ( self. __banTime ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> diftm = ticket. getTime ( ) - oldticket. getTime ( ) <TAB> <TAB> <TAB> <TAB> <TAB> if diftm > 0 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> btm += diftm <TAB> <TAB> <TAB> <TAB> oldticket. setBanTime ( btm ) <TAB> <TAB> <TAB> return False <TAB> <TAB> <TAB> <TAB> self. __banList [ fid ] = ticket <TAB> <TAB> self. __banTotal += 1 <TAB> <TAB> <TAB> <TAB> if self. __nextUnbanTime > eob : <TAB> <TAB> <TAB> self. __nextUnbanTime = eob <TAB> <TAB> return True",False,btm != -1,btm,0.6780818700790405
|
||
|
4042,"def update_angles ( self, context ) : <TAB> """"""Convert angle values to selected angle units"""""" <TAB> if self. last_angle_units == ""RAD"" : <TAB> <TAB> if self. angle_units == ""RAD"" : <TAB> <TAB> <TAB> au = 1.0 <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> au = 180.0 / pi <TAB> <TAB> elif self. angle_units == ""UNI"" : <TAB> <TAB> <TAB> au = 0.5 / pi <TAB> elif self. last_angle_units == ""DEG"" : <TAB> <TAB> if self. angle_units == ""RAD"" : <TAB> <TAB> <TAB> au = pi / 180 <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> au = 1.0 <TAB> <TAB> elif self. angle_units == ""UNI"" : <TAB> <TAB> <TAB> au = 1.0 / 360 <TAB> elif self. last_angle_units == ""UNI"" : <TAB> <TAB> if self. angle_units == ""RAD"" : <TAB> <TAB> <TAB> au = 2 * pi <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> au = 360 <TAB> <TAB> elif self. angle_units == ""UNI"" : <TAB> <TAB> <TAB> au = 1.0 <TAB> self. last_angle_units = self. angle_units <TAB> self. updating = True <TAB> self. twist = au * self. twist <TAB> self. phase = au * self. phase <TAB> self. updating = False <TAB> updateNode ( self, context )",True,self.angle_units == 'DEG',self.angle_units == 'DEG',0.6523205041885376
|
||
|
4043,"def intersect_two ( f1, f2, work_dir, data ) : <TAB> """"""Intersect two regions, handling cases where either file is not present."""""" <TAB> bedtools = config_utils. get_program ( ""bedtools"", data, default = ""bedtools"" ) <TAB> f1_exists = f1 and utils. file_exists ( f1 ) <TAB> f2_exists = f2 and utils. file_exists ( f2 ) <TAB> if not f1_exists and not f2_exists : <TAB> <TAB> return None <TAB> elif f1_exists and not f2_exists : <TAB> <TAB> return f1 <TAB> elif f2_exists and not f1_exists : <TAB> <TAB> return f2 <TAB> else : <TAB> <TAB> out_file = os. path. join ( <TAB> <TAB> <TAB> work_dir, ""%s-merged.bed"" % ( utils. splitext_plus ( os. path. basename ( f1 ) ) [ 0 ] ) <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> with file_transaction ( data, out_file ) as tx_out_file : <TAB> <TAB> <TAB> <TAB> cmd = ""{bedtools} intersect -a {f1} -b {f2} > {tx_out_file}"" <TAB> <TAB> <TAB> <TAB> do. run ( cmd. format ( ** locals ( ) ), ""Intersect BED files"", data ) <TAB> <TAB> return out_file",False,not utils.file_exists(out_file),os.path.exists(out_file),0.6449155807495117
|
||
|
4044,"def save ( self, order ) : <TAB> for a in getattr ( order, ""_answers"", [ ] ) : <TAB> <TAB> a. orderposition = ( <TAB> <TAB> <TAB> a. orderposition <TAB> <TAB> ) <TAB> <TAB> a. save ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> a. options. add ( * a. _options )",False,"hasattr(a, '_options')",a.options,0.6534874439239502
|
||
|
4045,"def main ( self ) : <TAB> with open ( self. args. cachefile [ 0 ], ""rb"" ) as cachefile : <TAB> <TAB> pickled = pickle. Unpickler ( cachefile ) <TAB> <TAB> while True : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> key = pickled. load ( ) <TAB> <TAB> <TAB> <TAB> val = pickled. load ( ) <TAB> <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> if isinstance ( val, CoreRecipeInfo ) : <TAB> <TAB> <TAB> <TAB> pn = val. pn <TAB> <TAB> <TAB> <TAB> if self. args. recipe and self. args. recipe!= pn : <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> if self. args. skip and val. skipped : <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> out = key <TAB> <TAB> <TAB> <TAB> <TAB> for member in self. args. members. split ( "","" ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> out += "": %s"" % val. __dict__. get ( member ) <TAB> <TAB> <TAB> <TAB> <TAB> print ( ""%s"" % out ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> print ( ""%s: %s"" % ( key, val. __dict__ ) ) <TAB> <TAB> <TAB> elif not self. args. recipe : <TAB> <TAB> <TAB> <TAB> print ( ""%s %s"" % ( key, val ) )",True,self.args.members,self.args.members,0.6567422151565552
|
||
|
4046,"def conj ( self ) : <TAB> dtype = self. dtype <TAB> if issubclass ( self. dtype. type, np. complexfloating ) : <TAB> <TAB> if not self. flags. forc : <TAB> <TAB> <TAB> raise RuntimeError ( <TAB> <TAB> <TAB> <TAB> ""only contiguous arrays may "" ""be used as arguments to this operation"" <TAB> <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> order = ""F"" <TAB> <TAB> else : <TAB> <TAB> <TAB> order = ""C"" <TAB> <TAB> result = self. _new_like_me ( order = order ) <TAB> <TAB> func = elementwise. get_conj_kernel ( dtype ) <TAB> <TAB> func. prepared_async_call ( <TAB> <TAB> <TAB> self. _grid, self. _block, None, self. gpudata, result. gpudata, self. mem_size <TAB> <TAB> ) <TAB> <TAB> return result <TAB> else : <TAB> <TAB> return self",False,self.flags.f_contiguous,self.flags.f_in_conj,0.6529178619384766
|
||
|
4047,"def _process_message_line ( lineno, line ) : <TAB> if line. startswith ( ""msgid_plural"" ) : <TAB> <TAB> in_msgid [ 0 ] = True <TAB> <TAB> msg = line [ 12 : ]. lstrip ( ) <TAB> <TAB> messages. append ( msg ) <TAB> elif line. startswith ( ""msgid"" ) : <TAB> <TAB> in_msgid [ 0 ] = True <TAB> <TAB> offset [ 0 ] = lineno <TAB> <TAB> txt = line [ 5 : ]. lstrip ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> _add_message ( ) <TAB> <TAB> messages. append ( txt ) <TAB> elif line. startswith ( ""msgstr"" ) : <TAB> <TAB> in_msgid [ 0 ] = False <TAB> <TAB> in_msgstr [ 0 ] = True <TAB> <TAB> msg = line [ 6 : ]. lstrip ( ) <TAB> <TAB> if msg. startswith ( ""["" ) : <TAB> <TAB> <TAB> idx, msg = msg [ 1 : ]. split ( ""]"", 1 ) <TAB> <TAB> <TAB> translations. append ( [ int ( idx ), msg. lstrip ( ) ] ) <TAB> <TAB> else : <TAB> <TAB> <TAB> translations. append ( [ 0, msg ] ) <TAB> elif line. startswith ( '""' ) : <TAB> <TAB> if in_msgid [ 0 ] : <TAB> <TAB> <TAB> messages [ - 1 ] += u""\n"" + line. rstrip ( ) <TAB> <TAB> elif in_msgstr [ 0 ] : <TAB> <TAB> <TAB> translations [ - 1 ] [ 1 ] += u""\n"" + line. rstrip ( )",False,messages,txt.startswith(message),0.698043704032898
|
||
|
4048,"def M ( b, d ) : <TAB> c = [ ] <TAB> g = 0 <TAB> while g < len ( b ) : <TAB> <TAB> i = 0 <TAB> <TAB> if ""a"" <= b [ g ] and ""z"" >= b [ g ] : <TAB> <TAB> <TAB> i = ord ( b [ g ] [ 0 ] ) - 97 <TAB> <TAB> else : <TAB> <TAB> <TAB> i = int ( b [ g ] ) + 26 <TAB> <TAB> f = 0 <TAB> <TAB> while f < 36 and f < len ( d ) : <TAB> <TAB> <TAB> if ( isinstance ( d [ f ], int ) or d [ f ]. isnumeric ( ) ) and int ( d [ f ] ) == i : <TAB> <TAB> <TAB> <TAB> i = f <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> f += 1 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> c. append ( i - 26 ) <TAB> <TAB> else : <TAB> <TAB> <TAB> c. append ( chr ( i + 97 ) ) <TAB> <TAB> g += 1 <TAB> tmp = """" <TAB> for x in c : <TAB> <TAB> tmp += str ( x ) <TAB> return tmp",False,25 < i,i >= 34,0.6914723515510559
|
||
|
4049,"def visit_Module ( self, mod : ast27. Module ) -> MypyFile : <TAB> self. type_ignores = { } <TAB> for ti in mod. type_ignores : <TAB> <TAB> parsed = parse_type_ignore_tag ( ti. tag ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. type_ignores [ ti. lineno ] = parsed <TAB> <TAB> else : <TAB> <TAB> <TAB> self. fail ( INVALID_TYPE_IGNORE, ti. lineno, - 1 ) <TAB> body = self. fix_function_overloads ( self. translate_stmt_list ( mod. body, module = True ) ) <TAB> return MypyFile ( <TAB> <TAB> body, <TAB> <TAB> self. imports, <TAB> <TAB> False, <TAB> <TAB> self. type_ignores, <TAB> )",False,parsed is not None,parsed,0.6679314374923706
|
||
|
4050,"def ListMessages ( viewed = None ) : <TAB> <TAB> if type ( viewed ) is str : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> viewed = None <TAB> <TAB> else : <TAB> <TAB> <TAB> viewed = viewed == ""True"" <TAB> <TAB> messages = list ( <TAB> <TAB> List ( viewed = viewed ). order_by ( Message. last_logged_at. desc ( ) ). limit ( 50 ) <TAB> ) <TAB> total_messages = List ( ). count ( ) <TAB> <TAB> oc = ObjectContainer ( title2 = _ ( ""Messages"" ) ) <TAB> for m in messages : <TAB> <TAB> if m. type is None or m. summary is None : <TAB> <TAB> <TAB> continue <TAB> <TAB> thumb = None <TAB> <TAB> if m. type == Message. Type. Exception : <TAB> <TAB> <TAB> thumb = ( <TAB> <TAB> <TAB> <TAB> R ( ""icon-exception-viewed.png"" ) if m. viewed else R ( ""icon-exception.png"" ) <TAB> <TAB> <TAB> ) <TAB> <TAB> elif m. type == Message. Type. Info : <TAB> <TAB> <TAB> thumb = ( <TAB> <TAB> <TAB> <TAB> R ( ""icon-notification-viewed.png"" ) <TAB> <TAB> <TAB> <TAB> if m. viewed <TAB> <TAB> <TAB> <TAB> else R ( ""icon-notification.png"" ) <TAB> <TAB> <TAB> ) <TAB> <TAB> elif m. type in ERROR_TYPES : <TAB> <TAB> <TAB> thumb = R ( ""icon-error-viewed.png"" ) if m. viewed else R ( ""icon-error.png"" ) <TAB> <TAB> oc. add ( <TAB> <TAB> <TAB> DirectoryObject ( <TAB> <TAB> <TAB> <TAB> key = Callback ( ViewMessage, error_id = m. id ), <TAB> <TAB> <TAB> <TAB> title = pad_title",False,viewed == 'None',viewed == False,0.6621967554092407
|
||
|
4051,"def streamErrorHandler ( self, conn, error ) : <TAB> name, text = ""error"", error. getData ( ) <TAB> for tag in error. getChildren ( ) : <TAB> <TAB> if tag. getNamespace ( ) == NS_XMPP_STREAMS : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> text = tag. getData ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> name = tag. getName ( ) <TAB> if name in stream_exceptions. keys ( ) : <TAB> <TAB> exc = stream_exceptions [ name ] <TAB> else : <TAB> <TAB> exc = StreamError <TAB> raise exc ( ( name, text ) )",False,tag.getName() == 'text',tag.getNamespace() == NS_XMPP_STREAMS,0.6582554578781128
|
||
|
4052,"def work ( ) : <TAB> """"""work"""""" <TAB> _graph_wrapper = copy. copy ( graph_wrapper ) <TAB> _graph_wrapper. node_feat_tensor_dict = { } <TAB> for batch_train_samples, batch_train_labels in batch_info : <TAB> <TAB> start_nodes = batch_train_samples <TAB> <TAB> nodes = start_nodes <TAB> <TAB> edges = [ ] <TAB> <TAB> for max_deg in samples : <TAB> <TAB> <TAB> pred_nodes = graph. sample_predecessor ( start_nodes, max_degree = max_deg ) <TAB> <TAB> <TAB> for dst_node, src_nodes in zip ( start_nodes, pred_nodes ) : <TAB> <TAB> <TAB> <TAB> for src_node in src_nodes : <TAB> <TAB> <TAB> <TAB> <TAB> edges. append ( ( src_node, dst_node ) ) <TAB> <TAB> <TAB> last_nodes = nodes <TAB> <TAB> <TAB> nodes = [ nodes, pred_nodes ] <TAB> <TAB> <TAB> nodes = flat_node_and_edge ( nodes ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> start_nodes = list ( set ( nodes ) - set ( last_nodes ) ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> subgraph = graph. subgraph ( <TAB> <TAB> <TAB> nodes = nodes, edges = edges, with_node_feat = True, with_edge_feat = True <TAB> <TAB> ) <TAB> <TAB> sub_node_index = subgraph. reindex_from_parrent_nodes ( batch_train_samples ) <TAB> <TAB> feed_dict = _graph_wrapper. to_feed ( subgraph ) <TAB> <TAB> feed_dict [ ""node_label"" ] = batch_train_labels <TAB> <TAB> feed_dict [ ""node_index"" ] = sub_node_index <TAB> <TAB> feed_dict [ ""parent_node_index"" ] = np. array ( nodes,",False,len(start_nodes) == 0,len(batch_info) == 0,0.6545653343200684
|
||
|
4053,"def parse_hicup_logs ( self, f ) : <TAB> """"""Parse a HiCUP summary report"""""" <TAB> if not f [ ""fn"" ]. endswith ( "".txt"" ) : <TAB> <TAB> return None <TAB> header = [ ] <TAB> lines = f [ ""f"" ]. splitlines ( ) <TAB> for l in lines : <TAB> <TAB> s = l. split ( ""\t"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if s [ 0 ]!= ""File"" : <TAB> <TAB> <TAB> <TAB> return None <TAB> <TAB> <TAB> header = s [ 1 : ] <TAB> <TAB> else : <TAB> <TAB> <TAB> s_name = self. clean_s_name ( s [ 0 ], f [ ""root"" ] ) <TAB> <TAB> <TAB> if s_name. startswith ( ""HiCUP_output/"" ) : <TAB> <TAB> <TAB> <TAB> s_name = s_name [ 13 : ] <TAB> <TAB> <TAB> parsed_data = { } <TAB> <TAB> <TAB> for idx, num in enumerate ( s [ 1 : ] ) : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> parsed_data [ header [ idx ] ] = float ( num ) <TAB> <TAB> <TAB> <TAB> except : <TAB> <TAB> <TAB> <TAB> <TAB> parsed_data [ header [ idx ] ] = num <TAB> <TAB> <TAB> parsed_data [ ""Duplicate_Read_Pairs"" ] = ( <TAB> <TAB> <TAB> <TAB> parsed_data [ ""Valid_Pairs"" ] <TAB> <TAB> <TAB> <TAB> - parsed_data [ ""Deduplication_Read_Pairs_Uniques"" ] <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if s_name in self. hicup_data : <TAB> <TAB> <TAB> <TAB> log. debug ( ""Duplicate sample name found! Overwriting: {}"". format ( s_name ) )",False,len(header) == 0,len(s) > 0,0.6548022031784058
|
||
|
4054,"def test_despine_with_offset ( self ) : <TAB> f, ax = plt. subplots ( ) <TAB> for side in self. sides : <TAB> <TAB> nt. assert_equal ( ax. spines [ side ]. get_position ( ), self. original_position ) <TAB> utils. despine ( ax = ax, offset = self. offset ) <TAB> for side in self. sides : <TAB> <TAB> is_visible = ax. spines [ side ]. get_visible ( ) <TAB> <TAB> new_position = ax. spines [ side ]. get_position ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> nt. assert_equal ( new_position, self. offset_position ) <TAB> <TAB> else : <TAB> <TAB> <TAB> nt. assert_equal ( new_position, self. original_position ) <TAB> plt. close ( ""all"" )",True,is_visible,is_visible,0.6615877747535706
|
||
|
4055,"def inner ( obj, p, cycle ) : <TAB> typ = type ( obj ) <TAB> if ( <TAB> <TAB> basetype is not None <TAB> <TAB> and typ is not basetype <TAB> <TAB> and typ. __repr__!= basetype. __repr__ <TAB> ) : <TAB> <TAB> <TAB> <TAB> return p. text ( typ. __repr__ ( obj ) ) <TAB> if cycle : <TAB> <TAB> return p. text ( ""{...}"" ) <TAB> p. begin_group ( 1, start ) <TAB> keys = obj. keys ( ) <TAB> <TAB> <TAB> if not ( p. max_seq_length and len ( obj ) >= p. max_seq_length ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> keys = sorted ( keys ) <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> pass <TAB> for idx, key in p. _enumerate ( keys ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> p. text ( "","" ) <TAB> <TAB> <TAB> p. breakable ( ) <TAB> <TAB> p. pretty ( key ) <TAB> <TAB> p. text ( "": "" ) <TAB> <TAB> p. pretty ( obj [ key ] ) <TAB> p. end_group ( 1, end )",False,idx,idx == len(obj) - 1,0.6968404054641724
|
||
|
4056,"def export_assets ( self, asset_dir, asset_prefix = """" ) : <TAB> assets = { } <TAB> <TAB> config = self. _config. copy ( ) <TAB> for key, value in config. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> basename = os. path. basename ( value ) <TAB> <TAB> <TAB> config [ key ] = basename <TAB> <TAB> <TAB> assets [ basename ] = value <TAB> <TAB> config_name = ""%stokenizer_config.yml"" % asset_prefix <TAB> config_path = os. path. join ( asset_dir, config_name ) <TAB> assets [ config_name ] = config_path <TAB> with tf. io. gfile. GFile ( config_path, ""w"" ) as config_file : <TAB> <TAB> yaml. dump ( config, stream = config_file, default_flow_style = False ) <TAB> return assets",False,"isinstance(value, str) and tf.io.gfile.exists(value)",key in assets,0.647707998752594
|
||
|
4057,"def assert_counts ( res, lang, files, blank, comment, code ) : <TAB> for line in res : <TAB> <TAB> fields = line. split ( ) <TAB> <TAB> if len ( fields ) >= 5 : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. assertEqual ( files, int ( fields [ 1 ] ) ) <TAB> <TAB> <TAB> <TAB> self. assertEqual ( blank, int ( fields [ 2 ] ) ) <TAB> <TAB> <TAB> <TAB> self. assertEqual ( comment, int ( fields [ 3 ] ) ) <TAB> <TAB> <TAB> <TAB> self. assertEqual ( code, int ( fields [ 4 ] ) ) <TAB> <TAB> <TAB> <TAB> return <TAB> self. fail ( ""Found no output line for {}"". format ( lang ) )",False,fields[0] == lang,len(fields) == 4,0.6669728755950928
|
||
|
4058,"def decide_file_icon ( file ) : <TAB> if file. state == File. ERROR : <TAB> <TAB> return FileItem. icon_error <TAB> elif isinstance ( file. parent, Track ) : <TAB> <TAB> if file. state == File. NORMAL : <TAB> <TAB> <TAB> return FileItem. icon_saved <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> return FileItem. match_pending_icons [ int ( file. similarity * 5 + 0.5 ) ] <TAB> <TAB> else : <TAB> <TAB> <TAB> return FileItem. match_icons [ int ( file. similarity * 5 + 0.5 ) ] <TAB> elif<mask> : <TAB> <TAB> return FileItem. icon_file_pending <TAB> else : <TAB> <TAB> return FileItem. icon_file",True,file.state == File.PENDING,file.state == File.PENDING,0.663223922252655
|
||
|
4059,"def do_request_ ( self, request ) : <TAB> host = request. host <TAB> if not host : <TAB> <TAB> raise URLError ( ""no host given"" ) <TAB> if request. data is not None : <TAB> <TAB> data = request. data <TAB> <TAB> if isinstance ( data, str ) : <TAB> <TAB> <TAB> msg = ( <TAB> <TAB> <TAB> <TAB> ""POST data should be bytes, an iterable of bytes, "" <TAB> <TAB> <TAB> <TAB> ""or a file object. It cannot be of type str."" <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> raise TypeError ( msg ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> request. add_unredirected_header ( <TAB> <TAB> <TAB> <TAB> ""Content-type"", ""application/x-www-form-urlencoded"" <TAB> <TAB> <TAB> ) <TAB> <TAB> if not request. has_header ( ""Content-length"" ) and not request. has_header ( <TAB> <TAB> <TAB> ""Transfer-encoding"" <TAB> <TAB> ) : <TAB> <TAB> <TAB> content_length = self. _get_content_length ( request ) <TAB> <TAB> <TAB> if content_length is not None : <TAB> <TAB> <TAB> <TAB> request. add_unredirected_header ( ""Content-length"", str ( content_length ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> request. add_unredirected_header ( ""Transfer-encoding"", ""chunked"" ) <TAB> sel_host = host <TAB> if request. has_proxy ( ) : <TAB> <TAB> scheme, sel = _splittype ( request. selector ) <TAB> <TAB> sel_host, sel_path = _splithost ( sel ) <TAB> if not request. has_header ( ""Host"" ) : <TAB> <TAB> request. add_unredirected_header ( ""Host"", sel_host ) <TAB> for name, value in self.",False,not request.has_header('Content-type'),self.redirect_empty_tags,0.6466919183731079
|
||
|
4060,"def print_topics ( self, header, cmds, cmdlen, maxcol ) : <TAB> """"""make help menu more readable"""""" <TAB> if cmds : <TAB> <TAB> self. stdout. write ( header ) <TAB> <TAB> self. stdout. write ( ""\n"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. stdout. write ( self. ruler * len ( header ) ) <TAB> <TAB> <TAB> self. stdout. write ( ""\n"" ) <TAB> <TAB> for cmd in cmds : <TAB> <TAB> <TAB> help_msg = getattr ( self, ""do_{}"". format ( cmd ) ). __doc__ <TAB> <TAB> <TAB> self. stdout. write ( ""{:<16}"". format ( cmd ) ) <TAB> <TAB> <TAB> self. stdout. write ( help_msg ) <TAB> <TAB> <TAB> self. stdout. write ( ""\n"" ) <TAB> <TAB> self. stdout. write ( ""\n"" )",False,self.ruler,cmdlen,0.6640629172325134
|
||
|
4061,"def _authorized_sid ( self, jid, sid, ifrom, iq ) : <TAB> with self. _preauthed_sids_lock : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> del self. _preauthed_sids [ ( jid, sid, ifrom ) ] <TAB> <TAB> <TAB> return True <TAB> <TAB> return False",False,"(jid, sid, ifrom) in self._preauthed_sids",jid in self._preauthed_sids,0.6584668159484863
|
||
|
4062,"def post ( self, forum_id = None, slug = None ) : <TAB> <TAB> if forum_id is not None : <TAB> <TAB> forum_instance = Forum. query. filter_by ( id = forum_id ). first_or_404 ( ) <TAB> <TAB> forumsread = ForumsRead. query. filter_by ( <TAB> <TAB> <TAB> user_id = real ( current_user ). id, forum_id = forum_instance. id <TAB> <TAB> ). first ( ) <TAB> <TAB> TopicsRead. query. filter_by ( <TAB> <TAB> <TAB> user_id = real ( current_user ). id, forum_id = forum_instance. id <TAB> <TAB> ). delete ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> forumsread = ForumsRead ( ) <TAB> <TAB> <TAB> forumsread. user = real ( current_user ) <TAB> <TAB> <TAB> forumsread. forum = forum_instance <TAB> <TAB> forumsread. last_read = time_utcnow ( ) <TAB> <TAB> forumsread. cleared = time_utcnow ( ) <TAB> <TAB> db. session. add ( forumsread ) <TAB> <TAB> db. session. commit ( ) <TAB> <TAB> flash ( <TAB> <TAB> <TAB> _ ( ""Forum %(forum)s marked as read."", forum = forum_instance. title ), ""success"" <TAB> <TAB> ) <TAB> <TAB> return redirect ( forum_instance. url ) <TAB> <TAB> ForumsRead. query. filter_by ( user_id = real ( current_user ). id ). delete ( ) <TAB> TopicsRead. query. filter_by ( user_id = real ( current_user ). id ). delete ( ) <TAB> forums = Forum. query. all ( ) <TAB> forumsread_list = [ ] <TAB> for forum_instance in forums : <TAB> <TAB> forumsread = ForumsRead ( ) <TAB> <TAB> forumsread. user",False,not forumsread,forum_id,0.6758328676223755
|
||
|
4063,"def generate_lorem_ipsum ( n = 5, html = True, min = 20, max = 100 ) : <TAB> """"""Generate some lorem impsum for the template."""""" <TAB> from jinja2. constants import LOREM_IPSUM_WORDS <TAB> from random import choice, randrange <TAB> words = LOREM_IPSUM_WORDS. split ( ) <TAB> result = [ ] <TAB> for _ in range ( n ) : <TAB> <TAB> next_capitalized = True <TAB> <TAB> last_comma = last_fullstop = 0 <TAB> <TAB> word = None <TAB> <TAB> last = None <TAB> <TAB> p = [ ] <TAB> <TAB> <TAB> <TAB> for idx, _ in enumerate ( range ( randrange ( min, max ) ) ) : <TAB> <TAB> <TAB> while True : <TAB> <TAB> <TAB> <TAB> word = choice ( words ) <TAB> <TAB> <TAB> <TAB> if word!= last : <TAB> <TAB> <TAB> <TAB> <TAB> last = word <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> if next_capitalized : <TAB> <TAB> <TAB> <TAB> word = word. capitalize ( ) <TAB> <TAB> <TAB> <TAB> next_capitalized = False <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if idx - randrange ( 3, 8 ) > last_comma : <TAB> <TAB> <TAB> <TAB> last_comma = idx <TAB> <TAB> <TAB> <TAB> last_fullstop += 2 <TAB> <TAB> <TAB> <TAB> word += "","" <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if idx - randrange ( 10, 20 ) > last_fullstop : <TAB> <TAB> <TAB> <TAB> last_comma = last_fullstop = idx <TAB> <TAB> <TAB> <TAB> word += ""."" <TAB> <TAB> <TAB> <TAB> next_capitalized = True <TAB> <TAB> <TAB> p.",False,not p.endswith('.'),html,0.6513152122497559
|
||
|
4064,"def writeLibraryGeometry ( fp, meshes, config, shapes = None ) : <TAB> progress = Progress ( len ( meshes ), None ) <TAB> fp. write ( ""\n <library_geometries>\n"" ) <TAB> for mIdx, mesh in enumerate ( meshes ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> shape = None <TAB> <TAB> else : <TAB> <TAB> <TAB> shape = shapes [ mIdx ] <TAB> <TAB> writeGeometry ( fp, mesh, config, shape ) <TAB> <TAB> progress. step ( ) <TAB> fp. write ( "" </library_geometries>\n"" )",True,shapes is None,shapes is None,0.6831676363945007
|
||
|
4065,"def test_pad_cval_is_tuple ( self ) : <TAB> aug = iaa. Pad ( <TAB> <TAB> px = ( 0, 1, 0, 0 ), pad_mode = ""constant"", pad_cval = ( 50, 52 ), keep_size = False <TAB> ) <TAB> image = np. zeros ( ( 1, 1 ), dtype = np. uint8 ) <TAB> seen = [ 0, 0, 0 ] <TAB> for _ in sm. xrange ( 300 ) : <TAB> <TAB> observed = aug. augment_image ( image ) <TAB> <TAB> if observed [ 0, 1 ] == 50 : <TAB> <TAB> <TAB> seen [ 0 ] += 1 <TAB> <TAB> elif observed [ 0, 1 ] == 51 : <TAB> <TAB> <TAB> seen [ 1 ] += 1 <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> seen [ 2 ] += 1 <TAB> <TAB> else : <TAB> <TAB> <TAB> assert False <TAB> assert np. all ( [ 100 - 50 < v < 100 + 50 for v in seen ] )",False,"observed[0, 1] == 52","observed[0, 2] == 50",0.652206301689148
|
||
|
4066,"def find_widget_by_id ( self, id, parent = None ) : <TAB> """"""Recursively searches for widget with specified ID"""""" <TAB> if parent == None : <TAB> <TAB> if id in self : <TAB> <TAB> <TAB> return self [ id ] <TAB> <TAB> parent = self [ ""editor"" ] <TAB> for c in parent. get_children ( ) : <TAB> <TAB> if hasattr ( c, ""get_id"" ) : <TAB> <TAB> <TAB> if c. get_id ( ) == id : <TAB> <TAB> <TAB> <TAB> return c <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> r = self. find_widget_by_id ( id, c ) <TAB> <TAB> <TAB> if not r is None : <TAB> <TAB> <TAB> <TAB> return r <TAB> return None",False,"isinstance(c, Gtk.Container)",id in self,0.6492255926132202
|
||
|
4067,"def setupterm ( term = None, fd = - 1 ) : <TAB> if fd == - 1 : <TAB> <TAB> <TAB> <TAB> fd = sys. stdout. fileno ( ) <TAB> if _initialised_setupterm : <TAB> <TAB> return None <TAB> if term is None : <TAB> <TAB> term = ffi. NULL <TAB> err = ffi. new ( ""int *"" ) <TAB> if lib. setupterm ( term, fd, err ) == lib. ERR : <TAB> <TAB> err = err [ 0 ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise error ( ""setupterm: could not find terminal"" ) <TAB> <TAB> elif err == - 1 : <TAB> <TAB> <TAB> raise error ( ""setupterm: could not find terminfo database"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise error ( ""setupterm: unknown error"" ) <TAB> globals ( ) [ ""_initialised_setupterm"" ] = True <TAB> return None",False,err == 0,err == -2,0.6795936822891235
|
||
|
4068,"def testShows5LatestHunts ( self ) : <TAB> <TAB> <TAB> timestamp = rdfvalue. RDFDatetime. Now ( ) - rdfvalue. Duration. From ( 1, rdfvalue. DAYS ) <TAB> for i in range ( 20 ) : <TAB> <TAB> with test_lib. FakeTime ( <TAB> <TAB> <TAB> timestamp + rdfvalue. Duration. From ( 1000 * i, rdfvalue. SECONDS ) <TAB> <TAB> ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> descr = ""foo-%d"" % i <TAB> <TAB> <TAB> <TAB> creator = ""another"" <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> descr = ""bar-%d"" % i <TAB> <TAB> <TAB> <TAB> creator = self. token. username <TAB> <TAB> <TAB> self. CreateSampleHunt ( descr, creator = creator ) <TAB> self. Open ( ""/"" ) <TAB> for i in range ( 11, 20, 2 ) : <TAB> <TAB> self. WaitUntil ( <TAB> <TAB> <TAB> self. IsElementPresent, <TAB> <TAB> <TAB> ""css=grr-user-dashboard "" <TAB> <TAB> <TAB> ""div[name=RecentlyCreatedHunts]:contains('bar-%d')"" % i, <TAB> <TAB> ) <TAB> self. WaitUntilNot ( <TAB> <TAB> self. IsElementPresent, <TAB> <TAB> ""css=grr-user-dashboard "" ""div[name=RecentlyCreatedHunts]:contains('foo')"", <TAB> )",False,i % 2 == 0,self.token.username,0.673223614692688
|
||
|
4069,"def after_end ( session, transaction ) : <TAB> caller_info = find_caller ( inspect. stack ( ) [ 1 : ] ) <TAB> with open_transactions_lock : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> open_time = time. time ( ) - open_transactions [ transaction ] [ 0 ] <TAB> <TAB> msg = ""Transaction 0x%08X closed %s (open time %s)"" % ( <TAB> <TAB> <TAB> id ( transaction ), <TAB> <TAB> <TAB> caller_info, <TAB> <TAB> <TAB> open_time, <TAB> <TAB> ) <TAB> <TAB> if open_time > 2 : <TAB> <TAB> <TAB> log. warning ( msg ) <TAB> <TAB> else : <TAB> <TAB> <TAB> log. debug ( msg ) <TAB> <TAB> del open_transactions [ transaction ]",True,transaction not in open_transactions,transaction not in open_transactions,0.6662943363189697
|
||
|
4070,"def _decode_field ( message, field, value ) : <TAB> """"""Decode optional or required field."""""" <TAB> if field. type == FieldDescriptor. TYPE_MESSAGE : <TAB> <TAB> decode ( getattr ( message, field. name ), value ) <TAB> else : <TAB> <TAB> try : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> value = base64. b64decode ( value ) <TAB> <TAB> <TAB> setattr ( message, field. name, value ) <TAB> <TAB> except ( ValueError, TypeError ) as e : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> logger. warning ( <TAB> <TAB> <TAB> <TAB> ""Message %r ignoring field %s: %s"", <TAB> <TAB> <TAB> <TAB> message. __class__. __name__, <TAB> <TAB> <TAB> <TAB> field. name, <TAB> <TAB> <TAB> <TAB> e, <TAB> <TAB> <TAB> )",False,field.type == FieldDescriptor.TYPE_BYTES,field.type == FieldDescriptor.TYPE_BASE64,0.6631757020950317
|
||
|
4071,"def __call__ ( cls, * args, ** kwargs ) : <TAB> session = kwargs. pop ( ""session"", None ) <TAB> instance = object. __new__ ( cls, * args, ** kwargs ) <TAB> instance. session = session <TAB> instance. config = config. Config ( [ ] ) <TAB> config_section = getattr ( instance, ""configSection"", None ) <TAB> switch = getattr ( instance, ""commandLineSwitch"", None ) <TAB> if session is not None and config_section is not None : <TAB> <TAB> instance. config = session. get ( config_section ) <TAB> always_on = instance. config. as_bool ( ""always-on"", default = instance. alwaysOn ) <TAB> instance. __init__ ( * args, ** kwargs ) <TAB> if always_on : <TAB> <TAB> instance. register ( ) <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> short_opt, long_opt, help = switch <TAB> <TAB> <TAB> instance. addOption ( instance. _register_cb, short_opt, long_opt, help ) <TAB> return instance",False,switch is not None,switch,0.6584217548370361
|
||
|
4072,"def getApiLevel ( self ) : <TAB> if not self. api_level : <TAB> <TAB> try : <TAB> <TAB> <TAB> data = self. call ( ""app/apilevel"", auth = False ) <TAB> <TAB> <TAB> self. api_level = float ( data. get ( ""apilevel"" ) ) <TAB> <TAB> except HTTPError as e : <TAB> <TAB> <TAB> sc = e. response. status_code <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> log. error ( <TAB> <TAB> <TAB> <TAB> <TAB> ""This version of NZBVortex isn't supported. Please update to 2.8.6 or higher"" <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> log. error ( <TAB> <TAB> <TAB> <TAB> <TAB> ""NZBVortex doesn't seem to be running or maybe the remote option isn't enabled yet: %s"", <TAB> <TAB> <TAB> <TAB> <TAB> traceback. format_exc ( 1 ), <TAB> <TAB> <TAB> <TAB> ) <TAB> return self. api_level",False,sc == 403,sc.status_code == 200,0.6735562086105347
|
||
|
4073,"def close ( self, wait = True, abort = False ) : <TAB> """"""Close the socket connection."""""" <TAB> if not self. closed and not self. closing : <TAB> <TAB> self. closing = True <TAB> <TAB> self. server. _trigger_event ( ""disconnect"", self. sid, run_async = False ) <TAB> <TAB> if not abort : <TAB> <TAB> <TAB> self. send ( packet. Packet ( packet. CLOSE ) ) <TAB> <TAB> self. closed = True <TAB> <TAB> self. queue. put ( None ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. queue. join ( )",True,wait,wait,0.6937553882598877
|
||
|
4074,"def test_k_is_stochastic_parameter ( self ) : <TAB> <TAB> aug = iaa. MedianBlur ( k = iap. Choice ( [ 3, 5 ] ) ) <TAB> seen = [ False, False ] <TAB> for i in sm. xrange ( 100 ) : <TAB> <TAB> observed = aug. augment_image ( self. base_img ) <TAB> <TAB> if np. array_equal ( observed, self. blur3x3 ) : <TAB> <TAB> <TAB> seen [ 0 ] += True <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> seen [ 1 ] += True <TAB> <TAB> else : <TAB> <TAB> <TAB> raise Exception ( ""Unexpected result in MedianBlur@2"" ) <TAB> <TAB> if all ( seen ) : <TAB> <TAB> <TAB> break <TAB> assert np. all ( seen )",False,"np.array_equal(observed, self.blur5x5)","np.array_equal(observed, self.blur2x3)",0.6499741077423096
|
||
|
4075,"def parse ( self, s ) : <TAB> self. tokens = self. lexer. tokenize ( s ) <TAB> self. _current_token = 0 <TAB> self. _tokens_len = len ( self. tokens ) <TAB> self. _mark_locations = [ ] <TAB> if self. _tokens_len < 0 : <TAB> <TAB> raise SyntaxError ( ""could not find any entries"" ) <TAB> self. database = database = Database ( ) <TAB> while True : <TAB> <TAB> try : <TAB> <TAB> <TAB> self. _advance ( ) <TAB> <TAB> except IndexError : <TAB> <TAB> <TAB> self. unexpected_token ( ""preamble, string, entry_start, or eof"" ) <TAB> <TAB> token_type = self. token_type <TAB> <TAB> if token_type == ""PREAMBLE"" : <TAB> <TAB> <TAB> preamble = self. preamble ( ) <TAB> <TAB> <TAB> database. add_preamble ( self. _handle_value ( preamble. contents ) ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> string = self. string ( ) <TAB> <TAB> <TAB> database. add_macro ( string. key, self. _handle_value ( string. value ) ) <TAB> <TAB> elif token_type == ""ENTRY_START"" : <TAB> <TAB> <TAB> entry_node = self. entry ( ) <TAB> <TAB> <TAB> entry = Entry ( entry_node. entry_type, entry_node. key. value ) <TAB> <TAB> <TAB> for field in entry_node. fields : <TAB> <TAB> <TAB> <TAB> entry [ field. key ] = self. _handle_value ( field. value ) <TAB> <TAB> <TAB> <TAB> if field. key in Name. NAME_FIELDS : <TAB> <TAB> <TAB> <TAB> <TAB> entry [ field. key ] = "" and "". join ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ( unicode ( Name ( s ) ) for s in tokenize_list ( entry [ field. key ] )",True,token_type == 'STRING',token_type == 'STRING',0.659516453742981
|
||
|
4076,"def tax_edit ( request, tax_id, response_format = ""html"" ) : <TAB> ""Tax edit"" <TAB> tax = get_object_or_404 ( Tax, pk = tax_id ) <TAB> if not request. user. profile. has_permission ( <TAB> <TAB> tax, mode = ""w"" <TAB> ) and not request. user. profile. is_admin ( ""treeio_finance"" ) : <TAB> <TAB> return user_denied ( <TAB> <TAB> <TAB> request, ""You don't have access to this Tax"", response_format <TAB> <TAB> ) <TAB> if request. POST : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> form = TaxForm ( request. user. profile, request. POST, instance = tax ) <TAB> <TAB> <TAB> if form. is_valid ( ) : <TAB> <TAB> <TAB> <TAB> tax = form. save ( ) <TAB> <TAB> <TAB> <TAB> return HttpResponseRedirect ( reverse ( ""finance_tax_view"", args = [ tax. id ] ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return HttpResponseRedirect ( reverse ( ""finance_tax_view"", args = [ tax. id ] ) ) <TAB> else : <TAB> <TAB> form = TaxForm ( request. user. profile, instance = tax ) <TAB> return render_to_response ( <TAB> <TAB> ""finance/tax_edit"", <TAB> <TAB> { ""form"" : form, ""tax"" : tax }, <TAB> <TAB> context_instance = RequestContext ( request ), <TAB> <TAB> response_format = response_format, <TAB> )",False,'cancel' not in request.POST,tax.id > 0,0.6586582064628601
|
||
|
4077,"def printConnections ( switches ) : <TAB> ""Compactly print connected nodes to each switch"" <TAB> for sw in switches : <TAB> <TAB> output ( ""%s: "" % sw ) <TAB> <TAB> for intf in sw. intfList ( ) : <TAB> <TAB> <TAB> link = intf. link <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> intf1, intf2 = link. intf1, link. intf2 <TAB> <TAB> <TAB> <TAB> remote = intf1 if intf1. node!= sw else intf2 <TAB> <TAB> <TAB> <TAB> output ( ""%s(%s) "" % ( remote. node, sw. ports [ intf ] ) ) <TAB> <TAB> output ( ""\n"" )",False,link,link and link.ports,0.707377016544342
|
||
|
4078,"def _get_vector ( self, word = ""house"" ) : <TAB> try : <TAB> <TAB> import lmdb <TAB> <TAB> with self. env. begin ( ) as txn : <TAB> <TAB> <TAB> vector = txn. get ( word. encode ( encoding = ""UTF-8"" ) ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> word_vector = pickle. loads ( vector ) <TAB> <TAB> <TAB> <TAB> vector = None <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> word_vector = np. zeros ( ( self. k, ), dtype = np. float32 ) <TAB> except lmdb. Error : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. env. close ( ) <TAB> <TAB> self. env = lmdb. open ( <TAB> <TAB> <TAB> self. store_path, <TAB> <TAB> <TAB> readonly = True, <TAB> <TAB> <TAB> max_readers = 2048, <TAB> <TAB> <TAB> max_spare_txns = 2, <TAB> <TAB> <TAB> lock = False, <TAB> <TAB> ) <TAB> <TAB> return self. _get_vector ( word ) <TAB> except ModuleNotFoundError : <TAB> <TAB> logger. warning ( ""-"" * 100 ) <TAB> <TAB> logger. warning ( 'ATTENTION! The library ""lmdb"" is not installed!' ) <TAB> <TAB> logger. warning ( 'To use LMDB, please first install with ""pip install lmdb""' ) <TAB> <TAB> logger. warning ( ""-"" * 100 ) <TAB> <TAB> word_vector = np. zeros ( ( self. k, ), dtype = np. float32 ) <TAB> return word_vector",True,vector,vector,0.6913517713546753
|
||
|
4079,"def shutdownAutoSave ( self ) : <TAB> if not self. shutdown : <TAB> <TAB> self. shutdown = 1 <TAB> <TAB> <TAB> <TAB> self. _cv. acquire ( ) <TAB> <TAB> self. _cv. notify ( ) <TAB> <TAB> self. _cv. release ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> log. debug ( ""waiting for thread to terminate"" ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _thread. join ( 3 ) <TAB> <TAB> <TAB> log. debug ( ""thread has terminated"" ) <TAB> <TAB> <TAB> self. _thread = None",True,self._thread,self._thread,0.6864792108535767
|
||
|
4080,"def _iter_source_val_assigns ( src ) : <TAB> for node in _iter_source_assigns ( src ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> val = python_util. ast_param_val ( node. value ) <TAB> <TAB> except TypeError : <TAB> <TAB> <TAB> pass <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> target = node. targets [ - 1 ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> yield node, target, node. value, val",False,"isinstance(target, ast.Name)",target,0.6488354206085205
|
||
|
4081,"def __call__ ( self, X, y, net ) : <TAB> if self. shuffle : <TAB> <TAB> _shuffle_arrays ( [ X, y ] if y is not None else [ X ], self. random ) <TAB> if self. eval_size : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> kf = KFold ( y. shape [ 0 ], round ( 1.0 / self. eval_size ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> kf = StratifiedKFold ( y, round ( 1.0 / self. eval_size ) ) <TAB> <TAB> train_indices, valid_indices = next ( iter ( kf ) ) <TAB> <TAB> X_train = _sldict ( X, train_indices ) <TAB> <TAB> y_train = _sldict ( y, train_indices ) <TAB> <TAB> X_valid = _sldict ( X, valid_indices ) <TAB> <TAB> y_valid = _sldict ( y, valid_indices ) <TAB> else : <TAB> <TAB> X_train, y_train = X, y <TAB> <TAB> X_valid, y_valid = _sldict ( X, slice ( 0, 0 ) ), _sldict ( y, slice ( 0, 0 ) ) <TAB> return X_train, X_valid, y_train, y_valid",False,net.regression or not self.stratify,y.dim() == 2,0.6510807275772095
|
||
|
4082,def scope ( self ) : <TAB> if<mask> : <TAB> <TAB> self. lazy_init_lock_. acquire ( ) <TAB> <TAB> try : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. scope_ = Scope ( ) <TAB> <TAB> finally : <TAB> <TAB> <TAB> self. lazy_init_lock_. release ( ) <TAB> return self. scope_,True,self.scope_ is None,self.scope_ is None,0.6571006774902344
|
||
|
4083,"def finish_task ( task ) : <TAB> if task. stream : <TAB> <TAB> if task. stream [ ""args"" ]. get ( ""progress"" ) : <TAB> <TAB> <TAB> update_stream ( task, status = ""complete"" ) <TAB> <TAB> if task. stream [ ""args"" ]. get ( ""entry_dump"" ) : <TAB> <TAB> <TAB> entries = [ entry. store for entry in task. entries ] <TAB> <TAB> <TAB> task. stream [ ""queue"" ]. put ( EntryDecoder ( ). encode ( { ""entry_dump"" : entries } ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> task. stream [ ""queue"" ]. put ( <TAB> <TAB> <TAB> <TAB> json. dumps ( <TAB> <TAB> <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""summary"" : { <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""accepted"" : len ( task. accepted ), <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""rejected"" : len ( task. rejected ), <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""failed"" : len ( task. failed ), <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""undecided"" : len ( task. undecided ), <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""aborted"" : task. aborted, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""abort_reason"" : task. abort_reason, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> } <TAB> <TAB> <TAB> <TAB> <TAB> } <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> )",False,task.stream['args'].get('summary'),task.has_tab,0.6579177975654602
|
||
|
4084,"def __str__ ( self ) -> str : <TAB> text = ""\n"" <TAB> for k, r in self. result. items ( ) : <TAB> <TAB> text += ""{}\n"". format ( ""#"" * 40 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> text += ""# {} (failed)\n"". format ( k ) <TAB> <TAB> else : <TAB> <TAB> <TAB> text += ""# {} (succeeded)\n"". format ( k ) <TAB> <TAB> text += ""{}\n"". format ( ""#"" * 40 ) <TAB> <TAB> for sub_r in r : <TAB> <TAB> <TAB> text += ""**** {}\n"". format ( sub_r. name ) <TAB> <TAB> <TAB> text += ""{}\n"". format ( sub_r ) <TAB> return text",False,r.failed,k is None,0.6732447147369385
|
||
|
4085,"def get_updated_action_list ( <TAB> cls, <TAB> base_action_list : list, <TAB> other_action_list : list, ) -> List [ dict ] : <TAB> base_action_list_dict = { action [ ""name"" ] : action for action in base_action_list } <TAB> for other_action in other_action_list : <TAB> <TAB> other_action_name = other_action [ ""name"" ] <TAB> <TAB> if other_action_name in base_action_list_dict : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> base_action_list_dict. pop ( other_action_name ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> nested_update ( base_action_list_dict [ other_action_name ], other_action ) <TAB> <TAB> else : <TAB> <TAB> <TAB> base_action_list_dict [ other_action_name ] = other_action <TAB> return list ( base_action_list_dict. values ( ) )",False,other_action['action'] is None,other_action_name in other_action_list_dict,0.6547008752822876
|
||
|
4086,"def post_process_extensions ( self, extensions, resp_obj, request, action_args ) : <TAB> for ext in extensions : <TAB> <TAB> response = None <TAB> <TAB> if inspect. isgenerator ( ext ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> with ResourceExceptionHandler ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> response = ext. send ( resp_obj ) <TAB> <TAB> <TAB> except StopIteration : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> except Fault as ex : <TAB> <TAB> <TAB> <TAB> response = ex <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> with ResourceExceptionHandler ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> response = ext ( req = request, resp_obj = resp_obj, ** action_args ) <TAB> <TAB> <TAB> except exception. VersionNotFoundForAPIMethod : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> except Fault as ex : <TAB> <TAB> <TAB> <TAB> response = ex <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return response <TAB> return None",False,response,response is not None,0.7019158601760864
|
||
|
4087,"def generate ( g = generator, m = module ) : <TAB> try : <TAB> <TAB> for test in g ( ) : <TAB> <TAB> <TAB> test_func, arg = self. parseGeneratedTest ( test ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> test_func = getattr ( m, test_func ) <TAB> <TAB> <TAB> yield FunctionTestCase ( test_func, arg = arg, descriptor = g ) <TAB> except KeyboardInterrupt : <TAB> <TAB> raise <TAB> except : <TAB> <TAB> exc = sys. exc_info ( ) <TAB> <TAB> yield Failure ( exc [ 0 ], exc [ 1 ], exc [ 2 ], address = test_address ( generator ) )",False,not callable(test_func),"hasattr(m, test_func)",0.6521293520927429
|
||
|
4088,"def crawl ( self, url, path = None ) : <TAB> self. results = { } <TAB> self. url = urlparse ( url ) <TAB> if path : <TAB> <TAB> self. url = self. url. _replace ( path = path ) <TAB> self. url = self. url. _replace ( fragment = """" ) <TAB> self. _add_target ( url, 1 ) <TAB> self. _spawn_new_worker ( ) <TAB> while self. threads : <TAB> <TAB> try : <TAB> <TAB> <TAB> for t in self. threads : <TAB> <TAB> <TAB> <TAB> t. join ( 1 ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> self. threads. remove ( t ) <TAB> <TAB> except KeyboardInterrupt : <TAB> <TAB> <TAB> sys. exit ( 1 ) <TAB> return self. results",False,not t.is_alive(),t in self.threads,0.6542649865150452
|
||
|
4089,"def draw ( self, dc, f, ** key ) : <TAB> dc. SetPen ( wx. Pen ( Setting [ ""color"" ], width = 1, style = wx. SOLID ) ) <TAB> dc. SetTextForeground ( Setting [ ""tcolor"" ] ) <TAB> font = wx. Font ( <TAB> <TAB> 10, wx. FONTFAMILY_DEFAULT, wx. FONTSTYLE_NORMAL, wx. FONTWEIGHT_NORMAL, False <TAB> ) <TAB> dc. SetFont ( font ) <TAB> dc. DrawLines ( [ f ( * i ) for i in self. buf ] ) <TAB> for i in self. buf : <TAB> <TAB> dc. DrawCircle ( f ( * i ), 2 ) <TAB> for pg in self. body : <TAB> <TAB> plg = Polygon ( pg ) <TAB> <TAB> dc. DrawLines ( [ f ( * i ) for i in pg ] ) <TAB> <TAB> for i in pg : <TAB> <TAB> <TAB> dc. DrawCircle ( f ( * i ), 2 ) <TAB> <TAB> area, xy = plg. area, plg. centroid <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> area *= self. unit [ 0 ] ** 2 <TAB> <TAB> dc. DrawText ( ""%.1f"" % area, f ( xy. x, xy. y ) )",False,self.unit != None,self.unit[0] > 0,0.656484842300415
|
||
|
4090,"def read_embeddings ( file_enc, skip_lines = 0, filter_set = None ) : <TAB> embs = dict ( ) <TAB> total_vectors_in_file = 0 <TAB> with open ( file_enc, ""rb"" ) as f : <TAB> <TAB> for i, line in enumerate ( f ) : <TAB> <TAB> <TAB> if i < skip_lines : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if not line : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> l_split = line. decode ( ""utf8"" ). strip ( ). split ( "" "" ) <TAB> <TAB> <TAB> if len ( l_split ) == 2 : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> total_vectors_in_file += 1 <TAB> <TAB> <TAB> if filter_set is not None and l_split [ 0 ] not in filter_set : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> embs [ l_split [ 0 ] ] = [ float ( em ) for em in l_split [ 1 : ] ] <TAB> return embs, total_vectors_in_file",False,len(line) == 0,line and len(line) > 0,0.6593886613845825
|
||
|
4091,"def run ( self ) : <TAB> check_paths = [ ] <TAB> for root, dirs, files in os. walk ( ""."" ) : <TAB> <TAB> for file in files : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> path = os. path. join ( root, file ) <TAB> <TAB> <TAB> <TAB> check_paths. append ( path ) <TAB> for pattern in self. exclude_patterns : <TAB> <TAB> exclude = lambda path : not fnmatch. fnmatch ( path, pattern ) <TAB> <TAB> check_paths = list ( filter ( exclude, check_paths ) ) <TAB> bad_paths = list ( filter ( self. _header_bad, check_paths ) ) <TAB> if bad_paths : <TAB> <TAB> raise MissingHeaderError ( bad_paths )",False,file.endswith('.py') or file.endswith('.c'),file,0.6443114280700684
|
||
|
4092,"def __call__ ( self, epoch_nr, update_nr, net, stepper, logs ) : <TAB> for log_name in self. logs_to_check : <TAB> <TAB> log = get_by_path ( logs, log_name ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. message ( ""NaN or inf detected in {}!"". format ( log_name ) ) <TAB> <TAB> <TAB> raise StopIteration ( ) <TAB> if self. check_parameters : <TAB> <TAB> if not net. handler. is_fully_finite ( net. buffer. parameters ) : <TAB> <TAB> <TAB> self. message ( ""NaN or inf detected in parameters!"" ) <TAB> <TAB> <TAB> raise StopIteration ( ) <TAB> if self. check_training_loss and ""rolling_training"" in logs : <TAB> <TAB> rtrain = logs [ ""rolling_training"" ] <TAB> <TAB> if ""total_loss"" in rtrain : <TAB> <TAB> <TAB> loss = rtrain [ ""total_loss"" ] <TAB> <TAB> else : <TAB> <TAB> <TAB> loss = rtrain [ ""Loss"" ] <TAB> <TAB> if not np. all ( np. isfinite ( loss ) ) : <TAB> <TAB> <TAB> self. message ( ""NaN or inf detected in rolling training loss!"" ) <TAB> <TAB> <TAB> raise StopIteration ( )",False,not np.all(np.isfinite(log)),log,0.6494882106781006
|
||
|
4093,"def get_next_requests ( self, max_n_requests, ** kwargs ) : <TAB> next_pages = [ ] <TAB> partitions = set ( kwargs. pop ( ""partitions"", [ ] ) ) <TAB> for partition_id in range ( 0, self. queue_partitions ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> results = self. queue. get_next_requests ( max_n_requests, partition_id ) <TAB> <TAB> next_pages. extend ( results ) <TAB> <TAB> self. logger. debug ( <TAB> <TAB> <TAB> ""Got %d requests for partition id %d"", len ( results ), partition_id <TAB> <TAB> ) <TAB> return next_pages",False,partition_id not in partitions,len(partitions) == 0,0.6595758199691772
|
||
|
4094,"def __exit__ ( self, exc_type, exc_val, exc_tb ) : <TAB> saved_values = self. saved_values <TAB> del self. saved_values <TAB> for name, get, restore in self. resource_info ( ) : <TAB> <TAB> current = get ( ) <TAB> <TAB> original = saved_values. pop ( name ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. changed = True <TAB> <TAB> <TAB> restore ( original ) <TAB> <TAB> <TAB> if not self. quiet : <TAB> <TAB> <TAB> <TAB> print >> sys. stderr, ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Warning -- {} was modified by {}"". format ( name, self. testname ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> if self. verbose > 1 : <TAB> <TAB> <TAB> <TAB> <TAB> print >> sys. stderr, ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> "" Before: {}\n After: {} "". format ( original, current ) <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return False",False,current != original,current != restore,0.6939069628715515
|
||
|
4095,"def compute ( self, x, y = None, targets = None ) : <TAB> if targets is None : <TAB> <TAB> targets = self. out_params <TAB> in_params = list ( self. in_x ) <TAB> if len ( in_params ) == 1 : <TAB> <TAB> args = [ x ] <TAB> else : <TAB> <TAB> args = list ( zip ( * x ) ) <TAB> if y is None : <TAB> <TAB> pipe = self. pipe <TAB> else : <TAB> <TAB> pipe = self. train_pipe <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> args. append ( y ) <TAB> <TAB> else : <TAB> <TAB> <TAB> args += list ( zip ( * y ) ) <TAB> <TAB> in_params += self. in_y <TAB> return self. _compute ( * args, pipe = pipe, param_names = in_params, targets = targets )",False,len(self.in_y) == 1,y is None,0.6501501798629761
|
||
|
4096,"def ziplist_entry_overhead ( self, value ) : <TAB> <TAB> if self. is_integer_type ( value ) : <TAB> <TAB> header = 1 <TAB> <TAB> if value < 12 : <TAB> <TAB> <TAB> size = 0 <TAB> <TAB> elif value < 2 ** 8 : <TAB> <TAB> <TAB> size = 1 <TAB> <TAB> elif value < 2 ** 16 : <TAB> <TAB> <TAB> size = 2 <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> size = 3 <TAB> <TAB> elif value < 2 ** 32 : <TAB> <TAB> <TAB> size = 4 <TAB> <TAB> else : <TAB> <TAB> <TAB> size = 8 <TAB> else : <TAB> <TAB> size = len ( value ) <TAB> <TAB> if size <= 63 : <TAB> <TAB> <TAB> header = 1 <TAB> <TAB> elif size <= 16383 : <TAB> <TAB> <TAB> header = 2 <TAB> <TAB> else : <TAB> <TAB> <TAB> header = 5 <TAB> <TAB> prev_len = 1 if size < 254 else 5 <TAB> return prev_len + header + size",False,value < 2 ** 24,value < 2 ** 8,0.670365571975708
|
||
|
4097,"def _check_start_pipeline_execution_errors ( <TAB> graphene_info, execution_params, execution_plan ) : <TAB> if execution_params. step_keys : <TAB> <TAB> for step_key in execution_params. step_keys : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise UserFacingGraphQLError ( <TAB> <TAB> <TAB> <TAB> <TAB> graphene_info. schema. type_named ( ""InvalidStepError"" ) ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> invalid_step_key = step_key <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> )",False,not execution_plan.has_step(step_key),step_key not in graphene_info.schema.keys(),0.6502330303192139
|
||
|
4098,"def _status_changed ( self, device, alert = _status. ALERT. NONE, reason = None ) : <TAB> assert device is not None <TAB> if _log. isEnabledFor ( _INFO ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> _log. info ( <TAB> <TAB> <TAB> <TAB> ""status_changed %s: %s, %s (%X) %s"", <TAB> <TAB> <TAB> <TAB> device, <TAB> <TAB> <TAB> <TAB> ""present"" if bool ( device ) else ""removed"", <TAB> <TAB> <TAB> <TAB> device. status, <TAB> <TAB> <TAB> <TAB> alert, <TAB> <TAB> <TAB> <TAB> reason or """", <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> _log. info ( <TAB> <TAB> <TAB> <TAB> ""status_changed %s: %s %s, %s (%X) %s"", <TAB> <TAB> <TAB> <TAB> device, <TAB> <TAB> <TAB> <TAB> ""paired"" if bool ( device ) else ""unpaired"", <TAB> <TAB> <TAB> <TAB> ""online"" if device. online else ""offline"", <TAB> <TAB> <TAB> <TAB> device. status, <TAB> <TAB> <TAB> <TAB> alert, <TAB> <TAB> <TAB> <TAB> reason or """", <TAB> <TAB> <TAB> ) <TAB> if<mask> : <TAB> <TAB> assert device == self. receiver <TAB> <TAB> <TAB> <TAB> self. status_changed_callback ( device, alert, reason ) <TAB> <TAB> return <TAB> assert device. receiver == self. receiver <TAB> if not device : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> _log. warn ( ""device %s was unpaired, ghosting"", device ) <TAB> <TAB> device = _ghost ( device ) <TAB> self. status_changed_callback ( device,",False,device.kind is None,self._log,0.6557866334915161
|
||
|
4099,"def __getitem__ ( self, block_id ) : <TAB> if not block_id : <TAB> <TAB> raise ValueError ( ""None or empty block_id is an invalid identifier"" ) <TAB> with self. _lock : <TAB> <TAB> try : <TAB> <TAB> <TAB> value = self. _cache [ block_id ] <TAB> <TAB> <TAB> value. touch ( ) <TAB> <TAB> <TAB> return value. value <TAB> <TAB> except KeyError : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> block = self. _block_store [ block_id ] <TAB> <TAB> <TAB> <TAB> self. __setitem__ ( block_id, block ) <TAB> <TAB> <TAB> <TAB> return block <TAB> <TAB> <TAB> raise",True,block_id in self._block_store,block_id in self._block_store,0.6613422632217407
|
||
|
4100,"def xform_name ( name, sep = ""_"", _xform_cache = _xform_cache ) : <TAB> if sep in name : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return name <TAB> key = ( name, sep ) <TAB> if key not in _xform_cache : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> is_special = _special_case_transform. search ( name ) <TAB> <TAB> <TAB> matched = is_special. group ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> name = name [ : - len ( matched ) ] + sep + matched. lower ( ) <TAB> <TAB> s1 = _first_cap_regex. sub ( r""\1"" + sep + r""\2"", name ) <TAB> <TAB> s2 = _number_cap_regex. sub ( r""\1"" + sep + r""\2"", s1 ) <TAB> <TAB> transformed = _end_cap_regex. sub ( r""\1"" + sep + r""\2"", s2 ). lower ( ) <TAB> <TAB> _xform_cache [ key ] = transformed <TAB> return _xform_cache [ key ]",False,_special_case_transform.search(name) is not None,_special_case_transform is not None,0.6481164693832397
|
||
|
4101,"def _encode_body ( self, data, files, json ) : <TAB> body = None <TAB> if isinstance ( data, ( str, bytes ) ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""data cannot be a string or bytes when "" ""files are present"" <TAB> <TAB> <TAB> ) <TAB> <TAB> body = to_bytes ( data, self. charset ) <TAB> elif data and is_streamed ( data ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( ""data cannot be an iterator when "" ""files are present"" ) <TAB> <TAB> if ""content-length"" not in self. headers : <TAB> <TAB> <TAB> self. headers [ ""transfer-encoding"" ] = ""chunked"" <TAB> <TAB> return data <TAB> elif data or files : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> body, content_type = self. _encode_files ( data, files ) <TAB> <TAB> else : <TAB> <TAB> <TAB> body, content_type = self. _encode_params ( data ) <TAB> <TAB> self. headers [ ""Content-Type"" ] = content_type <TAB> elif json : <TAB> <TAB> body = _json. dumps ( json ). encode ( self. charset ) <TAB> <TAB> self. headers [ ""Content-Type"" ] = ""application/json"" <TAB> if body : <TAB> <TAB> self. headers [ ""content-length"" ] = str ( len ( body ) ) <TAB> return body",True,files,files,0.6860677003860474
|
||
|
4102,"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. STRUCT : <TAB> <TAB> <TAB> <TAB> self. o1 = AlreadyExistsException ( ) <TAB> <TAB> <TAB> <TAB> self. o1. 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. o2 = InvalidObjectException ( ) <TAB> <TAB> <TAB> <TAB> self. o2. read ( iprot ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif fid == 3 : <TAB> <TAB> <TAB> if ftype == TType. STRUCT : <TAB> <TAB> <TAB> <TAB> self. o3 = MetaException ( ) <TAB> <TAB> <TAB> <TAB> self. o3. read ( iprot ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif<mask> : <",True,fid == 4,fid == 4,0.6739135980606079
|
||
|
4103,"def webfinger ( environ, start_response, _ ) : <TAB> query = parse_qs ( environ [ ""QUERY_STRING"" ] ) <TAB> try : <TAB> <TAB> rel = query [ ""rel"" ] <TAB> <TAB> resource = query [ ""resource"" ] [ 0 ] <TAB> except KeyError : <TAB> <TAB> resp = BadRequest ( ""Missing parameter in request"" ) <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> resp = BadRequest ( ""Bad issuer in request"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> wf = WebFinger ( ) <TAB> <TAB> <TAB> resp = Response ( wf. response ( subject = resource, base = OAS. baseurl ) ) <TAB> return resp ( environ, start_response )",False,rel != [OIC_ISSUER],resource is None,0.6621189117431641
|
||
|
4104,"def number_loop ( queue, mappings, opc ) : <TAB> while len ( queue ) > 0 : <TAB> <TAB> code1 = queue. popleft ( ) <TAB> <TAB> code2 = queue. popleft ( ) <TAB> <TAB> assert code1. co_name == code2. co_name <TAB> <TAB> linestarts_orig = findlinestarts ( code1 ) <TAB> <TAB> linestarts_uncompiled = list ( findlinestarts ( code2 ) ) <TAB> <TAB> mappings += [ <TAB> <TAB> <TAB> [ line, offset2line ( offset, linestarts_uncompiled ) ] <TAB> <TAB> <TAB> for offset, line in linestarts_orig <TAB> <TAB> ] <TAB> <TAB> bytecode1 = Bytecode ( code1, opc ) <TAB> <TAB> bytecode2 = Bytecode ( code2, opc ) <TAB> <TAB> instr2s = bytecode2. get_instructions ( code2 ) <TAB> <TAB> seen = set ( [ code1. co_name ] ) <TAB> <TAB> for instr in bytecode1. get_instructions ( code1 ) : <TAB> <TAB> <TAB> next_code1 = None <TAB> <TAB> <TAB> if iscode ( instr. argval ) : <TAB> <TAB> <TAB> <TAB> next_code1 = instr. argval <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> next_code2 = None <TAB> <TAB> <TAB> <TAB> while not next_code2 : <TAB> <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> instr2 = next ( instr2s ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if iscode ( instr2. argval ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> next_code2 = instr2. argval <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> <",False,next_code1,next_code1 is None,0.6636793613433838
|
||
|
4105,"def default ( self, line ) : <TAB> <TAB> if len ( line ) == 2 and line [ 1 ] == "":"" : <TAB> <TAB> <TAB> <TAB> self. execute_remote ( line ) <TAB> <TAB> if len ( self. __outputBuffer. strip ( ""\r\n"" ) ) > 0 : <TAB> <TAB> <TAB> print ( self. __outputBuffer ) <TAB> <TAB> <TAB> self. __outputBuffer = """" <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. __pwd = line <TAB> <TAB> <TAB> self. execute_remote ( ""cd "" ) <TAB> <TAB> <TAB> self. __pwd = self. __outputBuffer. strip ( ""\r\n"" ) <TAB> <TAB> <TAB> self. prompt = self. __pwd + "">"" <TAB> <TAB> <TAB> self. __outputBuffer = """" <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> x = inspect. currentframe ( ) <TAB> <TAB> <TAB> y = inspect. getouterframes ( x, 2 ) <TAB> <TAB> <TAB> return self. send_data ( line )",False,line != '',self.prompt,0.6819586753845215
|
||
|
4106,"def __extract_member_from_pointer ( self, cexpr, obj ) : <TAB> parents_type = map ( <TAB> <TAB> lambda x : idaapi. get_ctype_name ( x. cexpr. op ), list ( self. parents ) [ : 0 : - 1 ] <TAB> ) <TAB> parents = map ( lambda x : x. cexpr, list ( self. parents ) [ : 0 : - 1 ] ) <TAB> logger. debug ( ""Parsing expression {}. Parents - {}"". format ( obj. name, parents_type ) ) <TAB> <TAB> if parents_type [ 0 ] in ( ""idx"", ""add"" ) : <TAB> <TAB> <TAB> <TAB> if parents [ 0 ]. y. op!= idaapi. cot_num : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> offset = parents [ 0 ]. y. numval ( ) * cexpr. type. get_ptrarr_objsize ( ) <TAB> <TAB> cexpr = self. parent_expr ( ) <TAB> <TAB> if parents_type [ 0 ] == ""add"" : <TAB> <TAB> <TAB> del parents_type [ 0 ] <TAB> <TAB> <TAB> del parents [ 0 ] <TAB> elif parents_type [ 0 : 2 ] == [ ""cast"", ""add"" ] : <TAB> <TAB> <TAB> <TAB> if parents [ 1 ]. y. op!= idaapi. cot_num : <TAB> <TAB> <TAB> return <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> size = parents [ 0 ]. type. get_ptrarr_objsize ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> size = 1 <TAB> <TAB> offset = parents [ 1 ]. theother ( parents [ 0 ] ). numval ( ) * size <TAB> <TAB> cexpr = parents [ 1 ] <TAB> <TAB> del parents_type [ 0 : 2 ] <TAB> <TAB> del parents [ 0 : 2 ] <TAB> else : <TAB> <TAB> offset = 0 <TAB> return self. __extract",False,parents[0].type.is_ptr(),len(parents) == 1,0.6515637636184692
|
||
|
4107,"def url ( self, name ) : <TAB> provider_type = self. provider [ ""type"" ]. lower ( ) <TAB> obj = self. _get_object ( name ) <TAB> if not obj : <TAB> <TAB> return None <TAB> try : <TAB> <TAB> url = self. driver. get_object_cdn_url ( obj ) <TAB> except NotImplementedError as e : <TAB> <TAB> object_path = ""{}/{}"". format ( self. bucket, obj. name ) <TAB> <TAB> if ""s3"" in provider_type : <TAB> <TAB> <TAB> base_url = ""https://%s"" % self. driver. connection. host <TAB> <TAB> <TAB> url = urljoin ( base_url, object_path ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> url = urljoin ( ""https://storage.googleapis.com"", object_path ) <TAB> <TAB> elif ""azure"" in provider_type : <TAB> <TAB> <TAB> base_url = ""https://%s.blob.core.windows.net"" % self. provider [ ""user"" ] <TAB> <TAB> <TAB> url = urljoin ( base_url, object_path ) <TAB> <TAB> elif ""backblaze"" in provider_type : <TAB> <TAB> <TAB> url = urljoin ( ""api.backblaze.com/b2api/v1/"", object_path ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise e <TAB> return url",False,'google' in provider_type,'s3_1' in provider_type,0.6531490087509155
|
||
|
4108,"def validate_subevent ( self, subevent ) : <TAB> if self. context [ ""event"" ]. has_subevents : <TAB> <TAB> if not subevent : <TAB> <TAB> <TAB> raise ValidationError ( ""You need to set a subevent."" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValidationError ( <TAB> <TAB> <TAB> <TAB> ""The specified subevent does not belong to this event."" <TAB> <TAB> <TAB> ) <TAB> elif subevent : <TAB> <TAB> raise ValidationError ( ""You cannot set a subevent for this event."" ) <TAB> return subevent",False,subevent.event != self.context['event'],subevent and self.context['event'].subevents not in subevent,0.6512810587882996
|
||
|
4109,"def qa ( ctx ) : <TAB> """"""Run a quality report"""""" <TAB> header ( qa. __doc__ ) <TAB> with ctx. cd ( ROOT ) : <TAB> <TAB> info ( ""Ensure PyPI can render README and CHANGELOG"" ) <TAB> <TAB> info ( ""Building dist package"" ) <TAB> <TAB> dist = ctx. run ( ""python setup.py sdist"", pty = True, warn = False, hide = True ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> error ( ""Unable to build sdist package"" ) <TAB> <TAB> <TAB> exit ( ""Quality check failed"", dist. return_code ) <TAB> <TAB> readme_results = ctx. run ( ""twine check dist/*"", pty = True, warn = True, hide = True ) <TAB> <TAB> if readme_results. failed : <TAB> <TAB> <TAB> print ( readme_results. stdout ) <TAB> <TAB> <TAB> error ( ""README and/or CHANGELOG is not renderable by PyPI"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> success ( ""README and CHANGELOG are renderable by PyPI"" ) <TAB> if readme_results. failed : <TAB> <TAB> exit ( ""Quality check failed"", readme_results. return_code ) <TAB> success ( ""Quality check OK"" )",True,dist.failed,dist.failed,0.6672093272209167
|
||
|
4110,"def formfield ( self, form_class = forms. CharField, ** kwargs ) : <TAB> ""Returns a django.forms.Field instance for this database Field."" <TAB> defaults = { <TAB> <TAB> ""required"" : not self. blank, <TAB> <TAB> ""label"" : capfirst ( self. verbose_name ), <TAB> <TAB> ""help_text"" : self. help_text, <TAB> } <TAB> if self. has_default ( ) : <TAB> <TAB> if callable ( self. default ) : <TAB> <TAB> <TAB> defaults [ ""initial"" ] = self. default <TAB> <TAB> <TAB> defaults [ ""show_hidden_initial"" ] = True <TAB> <TAB> else : <TAB> <TAB> <TAB> defaults [ ""initial"" ] = self. get_default ( ) <TAB> if self. choices : <TAB> <TAB> <TAB> <TAB> include_blank = self. blank or not ( self. has_default ( ) or ""initial"" in kwargs ) <TAB> <TAB> defaults [ ""choices"" ] = self. get_choices ( include_blank = include_blank ) <TAB> <TAB> defaults [ ""coerce"" ] = self. to_python <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> defaults [ ""empty_value"" ] = None <TAB> <TAB> form_class = forms. TypedChoiceField <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for k in kwargs. keys ( ) : <TAB> <TAB> <TAB> if k not in ( <TAB> <TAB> <TAB> <TAB> ""coerce"", <TAB> <TAB> <TAB> <TAB> ""empty_value"", <TAB> <TAB> <TAB> <TAB> ""choices"", <TAB> <TAB> <TAB> <TAB> ""required"", <TAB> <TAB> <TAB> <TAB> ""widget"", <TAB> <TAB> <TAB> <TAB> ""label"", <TAB> <TAB> <TAB> <TAB> ""initial"", <TAB> <TAB> <TAB> <TAB> ""help_text"", <",False,self.null,self.empty_value is None,0.6616407036781311
|
||
|
4111,def heal ( self ) : <TAB> if not self. doctors : <TAB> <TAB> return <TAB> proc_ids = self. _get_process_ids ( ) <TAB> for proc_id in proc_ids : <TAB> <TAB> <TAB> <TAB> proc = PipelineProcess. objects. get ( id = proc_id ) <TAB> <TAB> if not proc. is_alive or proc. is_frozen : <TAB> <TAB> <TAB> continue <TAB> <TAB> for dr in self. doctors : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> dr. cure ( proc ) <TAB> <TAB> <TAB> <TAB> break,False,dr.confirm(proc),dr.has_proc(),0.6547521352767944
|
||
|
4112,"def generator ( self, data ) : <TAB> for ( proc_as, key_buf_ptr ) in data : <TAB> <TAB> key_buf = proc_as. read ( key_buf_ptr, 24 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> key = """". join ( ""%02X"" % ord ( k ) for k in key_buf ) <TAB> <TAB> yield ( <TAB> <TAB> <TAB> 0, <TAB> <TAB> <TAB> [ <TAB> <TAB> <TAB> <TAB> str ( key ), <TAB> <TAB> <TAB> ], <TAB> <TAB> )",False,not key_buf,len(key_buf) == 0,0.6629738807678223
|
||
|
4113,"def test_sas_add_inside_range ( <TAB> self, tables_cosmos_account_name, tables_primary_cosmos_account_key ) : <TAB> <TAB> url = self. account_url ( tables_cosmos_account_name, ""cosmos"" ) <TAB> await self. _set_up ( tables_cosmos_account_name, tables_primary_cosmos_account_key ) <TAB> try : <TAB> <TAB> <TAB> <TAB> token = generate_table_sas ( <TAB> <TAB> <TAB> tables_cosmos_account_name, <TAB> <TAB> <TAB> tables_primary_cosmos_account_key, <TAB> <TAB> <TAB> self. table_name, <TAB> <TAB> <TAB> permission = TableSasPermissions ( add = True ), <TAB> <TAB> <TAB> expiry = datetime. utcnow ( ) + timedelta ( hours = 1 ), <TAB> <TAB> <TAB> start_pk = ""test"", <TAB> <TAB> <TAB> start_rk = ""test1"", <TAB> <TAB> <TAB> end_pk = ""test"", <TAB> <TAB> <TAB> end_rk = ""test1"", <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> service = TableServiceClient ( <TAB> <TAB> <TAB> self. account_url ( tables_cosmos_account_name, ""cosmos"" ), <TAB> <TAB> <TAB> credential = token, <TAB> <TAB> ) <TAB> <TAB> table = service. get_table_client ( self. table_name ) <TAB> <TAB> entity = self. _create_random_entity_dict ( ""test"", ""test1"" ) <TAB> <TAB> await table. create_entity ( entity = entity ) <TAB> <TAB> <TAB> <TAB> resp = await self. table. get_entity ( ""test"", ""test1"" ) <TAB> <TAB> self. _assert_default_entity ( resp ) <TAB> finally : <TAB> <TAB> await self. _tear_down ( ) <TAB> <TAB> if",False,self.is_live,tables_cosmos_account_name,0.6563279628753662
|
||
|
4114,"def log_url ( self, url_data ) : <TAB> """"""Write one node."""""" <TAB> node = self. get_node ( url_data ) <TAB> if node is not None : <TAB> <TAB> self. writeln ( u' ""%s"" [' % dotquote ( node [ ""label"" ] ) ) <TAB> <TAB> if self. has_part ( ""realurl"" ) : <TAB> <TAB> <TAB> self. writeln ( u' href=""%s"",' % dotquote ( node [ ""url"" ] ) ) <TAB> <TAB> if node [ ""dltime"" ] >= 0 and self. has_part ( ""dltime"" ) : <TAB> <TAB> <TAB> self. writeln ( u"" dltime=%d,"" % node [ ""dltime"" ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. writeln ( u"" size=%d,"" % node [ ""size"" ] ) <TAB> <TAB> if node [ ""checktime"" ] and self. has_part ( ""checktime"" ) : <TAB> <TAB> <TAB> self. writeln ( u"" checktime=%d,"" % node [ ""checktime"" ] ) <TAB> <TAB> if self. has_part ( ""extern"" ) : <TAB> <TAB> <TAB> self. writeln ( u"" extern=%d,"" % node [ ""extern"" ] ) <TAB> <TAB> self. writeln ( u"" ];"" )",False,node['size'] >= 0 and self.has_part('dlsize'),self.has_part('dltime'),0.648543655872345
|
||
|
4115,"def suggest ( self, trial_id : str ) -> Optional [ Dict ] : <TAB> if not self. _dim_dict or not self. optimizer : <TAB> <TAB> raise RuntimeError ( <TAB> <TAB> <TAB> UNDEFINED_SEARCH_SPACE. format ( cls = self. __class__. __name__, space = ""dim_dict"" ) <TAB> <TAB> ) <TAB> if not self. _metric or not self. _mode : <TAB> <TAB> raise RuntimeError ( <TAB> <TAB> <TAB> UNDEFINED_METRIC_MODE. format ( <TAB> <TAB> <TAB> <TAB> cls = self. __class__. __name__, metric = self. _metric, mode = self. _mode <TAB> <TAB> <TAB> ) <TAB> <TAB> ) <TAB> _solution = self. optimizer. suggest ( ) <TAB> if _solution == ""FINISHED"" : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return Searcher. FINISHED <TAB> <TAB> else : <TAB> <TAB> <TAB> return None <TAB> if _solution : <TAB> <TAB> self. solution_dict [ str ( trial_id ) ] = _solution <TAB> <TAB> _x = _solution. get_x ( ) <TAB> <TAB> new_trial = dict ( zip ( self. _dim_keys, _x ) ) <TAB> <TAB> self. _live_trial_mapping [ trial_id ] = new_trial <TAB> <TAB> return unflatten_dict ( new_trial )",False,ray.__version__ >= '0.8.7',trial_id is None,0.6513925194740295
|
||
|
4116,"def update ( self, values : List ) -> None : <TAB> assert isinstance ( values, list ) <TAB> self. num_iters += 1 <TAB> current_stats = [ ] <TAB> for i in range ( len ( values ) ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> if isinstance ( values [ i ], list ) is False : <TAB> <TAB> <TAB> values [ i ] = [ values [ i ] ] <TAB> <TAB> if self. metrics [ i ] [ 0 ] is None : <TAB> <TAB> <TAB> self. metrics [ i ] [ 0 ] = np. mean ( values [ i ] ) <TAB> <TAB> <TAB> self. metrics [ i ] [ 1 ] = np. mean ( values [ i ] ) <TAB> <TAB> <TAB> self. metrics [ i ] [ 2 ] = np. mean ( values [ i ] ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. metrics [ i ] [ 0 ] = ( <TAB> <TAB> <TAB> <TAB> self. metrics [ i ] [ 0 ] * ( self. num_iters - 1 ) + np. mean ( values [ i ] ) <TAB> <TAB> <TAB> ) / self. num_iters <TAB> <TAB> <TAB> self. metrics [ i ] [ 1 ] = 0.95 * self. metrics [ i ] [ 1 ] + 0.05 * np. mean ( values [ i ] ) <TAB> <TAB> <TAB> self. metrics [ i ] [ 2 ] = np. mean ( values [ i ] ) <TAB> <TAB> self. metrics [ i ] [ 0 ] = float ( self. metrics [ i ] [ 0 ] ) <TAB> <TAB> self. metrics [ i ] [ 1 ] = float ( self. metrics [ i ] [ 1 ] ) <TAB> <TAB> self. metrics [ i ] [ 2 ] = float ( self. metrics [ i ] [ 2 ] ) <TAB> <TAB> current_stats. append ( self. metrics [ i ] ) <TAB> self. stats. append ( copy. deepcopy ( current_stats ) )",False,values[i] is None,i == 0,0.660628080368042
|
||
|
4117,def __create_table ( self ) : <TAB> for i in range ( 256 ) : <TAB> <TAB> crcreg = i <TAB> <TAB> for j in range ( 8 ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> crcreg = self. __CRCPOLYNOMIAL ^ ( crcreg >> 1 ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> crcreg >>= 1 <TAB> <TAB> self. __crctable [ i ] = crcreg,False,crcreg & 1 != 0,j == 6,0.6702196002006531
|
||
|
4118,"def __call__ ( self, text, ** kargs ) : <TAB> words = jieba. tokenize ( text, mode = ""search"" ) <TAB> token = Token ( ) <TAB> for ( w, start_pos, stop_pos ) in words : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> token. original = token. text = w <TAB> <TAB> token. pos = start_pos <TAB> <TAB> token. startchar = start_pos <TAB> <TAB> token. endchar = stop_pos <TAB> <TAB> yield token",False,not accepted_chars.match(w) and len(w) <= 1,w == token.text,0.6505142450332642
|
||
|
4119,"def _update_state ( self ) : <TAB> if ( <TAB> <TAB> self. is_atari_env <TAB> <TAB> and hasattr ( self, ""current_ale_lives"" ) <TAB> <TAB> and self. current_ale_lives!= self. env. unwrapped. ale. lives ( ) <TAB> ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. done = True <TAB> <TAB> elif self. phase == RunPhase. TEST and not self. done : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _press_fire ( ) <TAB> <TAB> self. _update_ale_lives ( ) <TAB> <TAB> if self. state and ""desired_goal"" in self. state. keys ( ) : <TAB> <TAB> self. goal = self. state [ ""desired_goal"" ]",False,self.phase == RunPhase.TRAIN or self.phase == RunPhase.HEATUP,self.phase == RunPhase.RUNNING,0.6573666930198669
|
||
|
4120,"def action_delete ( self, request, attachments ) : <TAB> deleted_attachments = [ ] <TAB> desynced_posts = [ ] <TAB> for attachment in attachments : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> deleted_attachments. append ( attachment. pk ) <TAB> <TAB> <TAB> desynced_posts. append ( attachment. post_id ) <TAB> if desynced_posts : <TAB> <TAB> with transaction. atomic ( ) : <TAB> <TAB> <TAB> for post in Post. objects. filter ( id__in = desynced_posts ) : <TAB> <TAB> <TAB> <TAB> self. delete_from_cache ( post, deleted_attachments ) <TAB> for attachment in attachments : <TAB> <TAB> attachment. delete ( ) <TAB> message = _ ( ""Selected attachments have been deleted."" ) <TAB> messages. success ( request, message )",False,attachment.post,attachment.post_id is not None,0.6725665330886841
|
||
|
4121,def daemonize_if_required ( self ) : <TAB> if self. options. daemon : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> log. shutdown_multiprocessing_logging_listener ( daemonizing = True ) <TAB> <TAB> <TAB> <TAB> salt. utils. process. daemonize ( ) <TAB> <TAB> self. _setup_mp_logging_listener ( ),False,self._setup_mp_logging_listener_ is True,not self.mp_logging_listener,0.6535711288452148
|
||
|
4122,"def bundle_directory ( self, dirpath ) : <TAB> """"""Bundle all modules/packages in the given directory."""""" <TAB> dirpath = os. path. abspath ( dirpath ) <TAB> for nm in os. listdir ( dirpath ) : <TAB> <TAB> nm = _u ( nm ) <TAB> <TAB> if nm. startswith ( ""."" ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> itempath = os. path. join ( dirpath, nm ) <TAB> <TAB> if os. path. isdir ( itempath ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. bundle_package ( itempath ) <TAB> <TAB> elif nm. endswith ( "".py"" ) : <TAB> <TAB> <TAB> self. bundle_module ( itempath )",False,"os.path.exists(os.path.join(itempath, '__init__.py'))","nm.endswith("".py')",0.6438416838645935
|
||
|
4123,def all_left_col_indexes ( self ) : <TAB> result = [ ] <TAB> for idx in self. last_left_col_indexes : <TAB> <TAB> if idx not in self. select_col_indexes : <TAB> <TAB> <TAB> result. append ( idx ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> result. append ( idx ) <TAB> return result,False,idx in self.left_col_indexes,idx in self.select_col_indexes,0.6604180932044983
|
||
|
4124,"def getfileinfo ( name ) : <TAB> finfo = FInfo ( ) <TAB> with io. open ( name, ""rb"" ) as fp : <TAB> <TAB> <TAB> <TAB> data = fp. read ( 512 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> finfo. Type = ""TEXT"" <TAB> <TAB> fp. seek ( 0, 2 ) <TAB> <TAB> dsize = fp. tell ( ) <TAB> dir, file = os. path. split ( name ) <TAB> file = file. replace ( "":"", ""-"", 1 ) <TAB> return file, finfo, dsize, 0",False,0 not in data,data,0.665570855140686
|
||
|
4125,"def update ( self ) : <TAB> <TAB> if self. xPos > self. chart. width or self. xPos < 0 : <TAB> <TAB> self. xVel = - self. xVel <TAB> <TAB> self. xPos += self. xVel <TAB> <TAB> <TAB> <TAB> self. xDampening = max ( self. xDampening - 0.1, 0 ) <TAB> <TAB> self. xVel *= self. xDampening <TAB> if self. yPos > self. chart. height or self. yPos < 0 : <TAB> <TAB> self. yVel = - self. yVel <TAB> <TAB> self. yPos += self. yVel <TAB> <TAB> <TAB> <TAB> self. yDampening = max ( self. yDampening - 0.1, 0 ) <TAB> <TAB> self. yVel *= self. yDampening <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. yPos = self. chart. height <TAB> <TAB> <TAB> self. xVel = 0 <TAB> <TAB> <TAB> self. gravity = 0 <TAB> <TAB> <TAB> self. kill = True <TAB> self. xPos += self. xVel <TAB> self. yPos += self. yVel <TAB> <TAB> self. yVel += self. gravity",False,self.yPos > self.chart.height - 4 and abs(self.yVel) < 0.1,self.yPos > self.chart.width,0.6562715768814087
|
||
|
4126,"def Run ( self, cmd_val ) : <TAB> <TAB> attrs, arg_r = flag_spec. ParseCmdVal ( ""type"", cmd_val ) <TAB> arg = arg_types. type ( attrs. attrs ) <TAB> if arg. f : <TAB> <TAB> funcs = { } <TAB> else : <TAB> <TAB> funcs = self. funcs <TAB> status = 0 <TAB> r = _ResolveNames ( arg_r. Rest ( ), funcs, self. aliases, self. search_path ) <TAB> for kind, name in r : <TAB> <TAB> if kind is None : <TAB> <TAB> <TAB> self. errfmt. StderrLine ( ""type: %r not found"" % name ) <TAB> <TAB> <TAB> status = 1 <TAB> <TAB> else : <TAB> <TAB> <TAB> if arg. t : <TAB> <TAB> <TAB> <TAB> print ( kind ) <TAB> <TAB> <TAB> elif arg. p : <TAB> <TAB> <TAB> <TAB> if kind == ""file"" : <TAB> <TAB> <TAB> <TAB> <TAB> print ( name ) <TAB> <TAB> <TAB> elif arg. P : <TAB> <TAB> <TAB> <TAB> if kind == ""file"" : <TAB> <TAB> <TAB> <TAB> <TAB> print ( name ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> resolved = self. search_path. Lookup ( name ) <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> status = 1 <TAB> <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> print ( resolved ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <",False,resolved is None,resolved is not None,0.6768121123313904
|
||
|
4127,"def scale_axes ( self ) : <TAB> """"""Set the axes limits appropriate to the images we have"""""" <TAB> max_x = max_y = 0 <TAB> for image_row in self. image_rows : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> shape = image_row. data. pixel_data. shape <TAB> <TAB> <TAB> max_x = max ( shape [ 1 ], max_x ) <TAB> <TAB> <TAB> max_y = max ( shape [ 0 ], max_y ) <TAB> if self. __axes_scale is not None : <TAB> <TAB> init_x, init_y = self. __axes_scale <TAB> <TAB> if float ( max_x )!= init_x [ 1 ] or float ( max_y )!= init_y [ 0 ] : <TAB> <TAB> <TAB> self. __axes_scale = None <TAB> <TAB> <TAB> self. frame. navtoolbar. _nav_stack. clear ( ) <TAB> <TAB> elif init_x!= self. axes. get_xlim ( ) or init_y!= self. axes. get_ylim ( ) : <TAB> <TAB> <TAB> return <TAB> if max_x > 0 and max_y > 0 : <TAB> <TAB> self. axes. set_xlim ( 0, max_x ) <TAB> <TAB> self. axes. set_ylim ( 0, max_y ) <TAB> <TAB> self. axes. invert_yaxis ( ) <TAB> <TAB> self. __axes_scale = ( ( 0.0, float ( max_x ) ), ( float ( max_y ), 0.0 ) ) <TAB> <TAB> self. frame. navtoolbar. reset ( )",False,image_row.data.mode != MODE_HIDE,"hasattr(image_row.data, 'pixel_data')",0.6491804122924805
|
||
|
4128,"def boot_time ( ) : <TAB> """"""Return the system boot time expressed in seconds since the epoch."""""" <TAB> global BOOT_TIME <TAB> f = open ( ""/proc/stat"", ""rb"" ) <TAB> try : <TAB> <TAB> BTIME = b ( ""btime"" ) <TAB> <TAB> for line in f : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> ret = float ( line. strip ( ). split ( ) [ 1 ] ) <TAB> <TAB> <TAB> <TAB> BOOT_TIME = ret <TAB> <TAB> <TAB> <TAB> return ret <TAB> <TAB> raise RuntimeError ( ""line 'btime' not found"" ) <TAB> finally : <TAB> <TAB> f. close ( )",False,line.startswith(BTIME),line.startswith(b'btime'),0.653969943523407
|
||
|
4129,"def Run ( self ) : <TAB> """"""The main run method of the client."""""" <TAB> for thread in self. _threads. values ( ) : <TAB> <TAB> thread. start ( ) <TAB> logging. info ( START_STRING ) <TAB> while True : <TAB> <TAB> dead_threads = [ tn for ( tn, t ) in self. _threads. items ( ) if not t. isAlive ( ) ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise FatalError ( <TAB> <TAB> <TAB> <TAB> ""These threads are dead: %r. Shutting down..."" % dead_threads <TAB> <TAB> <TAB> ) <TAB> <TAB> time. sleep ( 10 )",False,dead_threads,len(dead_threads) == 0,0.6729820966720581
|
||
|
4130,"def iter_renderables ( <TAB> column_count : int, ) -> Iterable [ Tuple [ int, Optional [ RenderableType ] ] ] : <TAB> item_count = len ( renderables ) <TAB> if self. column_first : <TAB> <TAB> width_renderables = list ( zip ( renderable_widths, renderables ) ) <TAB> <TAB> column_lengths : List [ int ] = [ item_count // column_count ] * column_count <TAB> <TAB> for col_no in range ( item_count % column_count ) : <TAB> <TAB> <TAB> column_lengths [ col_no ] += 1 <TAB> <TAB> row_count = ( item_count + column_count - 1 ) // column_count <TAB> <TAB> cells = [ [ - 1 ] * column_count for _ in range ( row_count ) ] <TAB> <TAB> row = col = 0 <TAB> <TAB> for index in range ( item_count ) : <TAB> <TAB> <TAB> cells [ row ] [ col ] = index <TAB> <TAB> <TAB> column_lengths [ col ] -= 1 <TAB> <TAB> <TAB> if column_lengths [ col ] : <TAB> <TAB> <TAB> <TAB> row += 1 <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> col += 1 <TAB> <TAB> <TAB> <TAB> row = 0 <TAB> <TAB> for index in chain. from_iterable ( cells ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> yield width_renderables [ index ] <TAB> else : <TAB> <TAB> yield from zip ( renderable_widths, renderables ) <TAB> <TAB> if item_count % column_count : <TAB> <TAB> for _ in range ( column_count - ( item_count % column_count ) ) : <TAB> <TAB> <TAB> yield 0, None",False,index == -1,width_renderables is not None and index % width_renderables[row],0.6668978333473206
|
||
|
4131,"def get_in_inputs ( key, data ) : <TAB> if isinstance ( data, dict ) : <TAB> <TAB> for k, v in data. items ( ) : <TAB> <TAB> <TAB> if k == key : <TAB> <TAB> <TAB> <TAB> return v <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> out = get_in_inputs ( key, v ) <TAB> <TAB> <TAB> <TAB> if out : <TAB> <TAB> <TAB> <TAB> <TAB> return out <TAB> elif isinstance ( data, ( list, tuple ) ) : <TAB> <TAB> out = [ get_in_inputs ( key, x ) for x in data ] <TAB> <TAB> out = [ x for x in out if x ] <TAB> <TAB> if out : <TAB> <TAB> <TAB> return out [ 0 ]",False,"isinstance(v, (list, tuple, dict))","isinstance(v, dict)",0.6514726281166077
|
||
|
4132,"def copy_files ( imgs, txts, out_dir ) : <TAB> assert len ( imgs ) == len ( txts ) <TAB> if not os. path. exists ( out_dir ) : <TAB> <TAB> os. makedirs ( out_dir ) <TAB> for img, txt in tqdm ( <TAB> <TAB> zip ( imgs, txts ), total = len ( imgs ), desc = ""Writing to {}"". format ( out_dir ) <TAB> ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> logger. warning ( ""Image file at {} not found"". format ( img ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if not os. path. exists ( txt ) : <TAB> <TAB> <TAB> logger. warning ( ""Ground truth file at {} not found"". format ( txt ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> shutil. copyfile ( img, os. path. join ( out_dir, os. path. basename ( img ) ) ) <TAB> <TAB> shutil. copyfile ( txt, os. path. join ( out_dir, os. path. basename ( txt ) ) )",True,not os.path.exists(img),not os.path.exists(img),0.647951602935791
|
||
|
4133,"def _check_number_of_sessions ( ) : <TAB> nb_desktop_sessions = sessions. get_number_of_desktop_sessions ( ignore_gdm = True ) <TAB> if nb_desktop_sessions > 1 : <TAB> <TAB> print ( <TAB> <TAB> <TAB> ""WARNING : There are %d other desktop sessions open. The GPU switch will not become effective until you have manually"" <TAB> <TAB> <TAB> "" logged out from ALL desktop sessions.\n"" <TAB> <TAB> <TAB> ""Continue? (y/N)"" % ( nb_desktop_sessions - 1 ) <TAB> <TAB> ) <TAB> <TAB> confirmation = ask_confirmation ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> sys. exit ( 0 )",False,not confirmation,not confirmation or confirmation == False,0.6686437129974365
|
||
|
4134,"def __init__ ( self, * args, ** kwargs ) : <TAB> self. max_workers = kwargs. pop ( ""max_workers"", None ) <TAB> super ( AutoscalePool, self ). __init__ ( * args, ** kwargs ) <TAB> if self. max_workers is None : <TAB> <TAB> settings_absmem = getattr ( settings, ""SYSTEM_TASK_ABS_MEM"", None ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> total_memory_gb = int ( settings_absmem ) <TAB> <TAB> else : <TAB> <TAB> <TAB> total_memory_gb = ( <TAB> <TAB> <TAB> <TAB> psutil. virtual_memory ( ). total >> 30 <TAB> <TAB> <TAB> ) + 1 <TAB> <TAB> <TAB> <TAB> self. max_workers = total_memory_gb * 5 <TAB> <TAB> self. max_workers = max ( self. min_workers, self. max_workers )",True,settings_absmem is not None,settings_absmem is not None,0.650885820388794
|
||
|
4135,"def check ( cls ) : <TAB> cls. subclasses |= cls. discover_subclasses ( cls. BASE_SEARCH_CLASS. __subclasses__ ( ) ) <TAB> cls. exceptions |= cls. discover_subclasses ( cls. exceptions ) <TAB> success = True <TAB> for subclass in cls. subclasses : <TAB> <TAB> if subclass in cls. exceptions : <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> f""Subclass {subclass.__module__}.{subclass.__name__} is missing a"" <TAB> <TAB> <TAB> <TAB> "" table of common attributes."" <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> success = False <TAB> <TAB> for method_name in dir ( subclass ) : <TAB> <TAB> <TAB> if method_name in cls. METHOD_EXCEPTIONS : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> method = getattr ( subclass, method_name ) <TAB> <TAB> <TAB> if ( <TAB> <TAB> <TAB> <TAB> callable ( method ) or isinstance ( method, cachedproperty ) <TAB> <TAB> <TAB> ) and not method_name. startswith ( ""_"" ) : <TAB> <TAB> <TAB> <TAB> if isinstance ( method, cachedproperty ) : <TAB> <TAB> <TAB> <TAB> <TAB> method = method. func <TAB> <TAB> <TAB> <TAB> if cls. HAS_CODE_BLOCK. search ( method. __doc__ ) : <TAB> <TAB> <TAB> <TAB> <TAB> if cls. CODE_BLOCK_IMPROPER_INDENT. search ( method. __doc__ ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""Code block for method"" <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> f"" {subclass.__module__}.{subclass.__name__}.{method.__name__}"" <TAB> <TAB> <",False,not cls.HAS_ATTRIBUTE_TABLE.search(subclass.__doc__),not success,0.6575620770454407
|
||
|
4136,"def _invoke ( self, args ) : <TAB> arity = len ( args ) <TAB> if self. _is_variadic : <TAB> <TAB> if arity < self. _arity : <TAB> <TAB> <TAB> runtime_error ( <TAB> <TAB> <TAB> <TAB> u""Wrong number of args to fn: got "" <TAB> <TAB> <TAB> <TAB> + unicode ( str ( arity ) ) <TAB> <TAB> <TAB> <TAB> + u"", expected at least "" <TAB> <TAB> <TAB> <TAB> + unicode ( str ( self. _arity ) ) <TAB> <TAB> <TAB> ) <TAB> else : <TAB> <TAB> if arity!= self. _arity : <TAB> <TAB> <TAB> runtime_error ( <TAB> <TAB> <TAB> <TAB> u""Wrong number of args to fn: got "" <TAB> <TAB> <TAB> <TAB> + unicode ( str ( arity ) ) <TAB> <TAB> <TAB> <TAB> + u"", expected "" <TAB> <TAB> <TAB> <TAB> + unicode ( str ( self. _arity ) ) <TAB> <TAB> <TAB> ) <TAB> exb, tokens = self. prep_exb ( args ) <TAB> cd = jit. promote ( self. _cd ) <TAB> <TAB> jit_ffi_call ( cd, self. _f_ptr, exb ) <TAB> ret_val = self. get_ret_val_from_buffer ( exb ) <TAB> for x in range ( len ( args ) ) : <TAB> <TAB> t = tokens [ x ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> t. finalize_token ( ) <TAB> lltype. free ( exb, flavor = ""raw"" ) <TAB> keepalive_until_here ( args ) <TAB> return ret_val",False,t is not None,t.has_token(),0.6632798314094543
|
||
|
4137,"def main ( ) -> None : <TAB> prog, * args = argv <TAB> if not set ( args ). issubset ( cmds ) : <TAB> <TAB> print ( ""usage:"", prog, "" "". join ( ""[%s]"" % k for k in cmds ) ) <TAB> <TAB> print ( ) <TAB> <TAB> print ( <TAB> <TAB> <TAB> ""Run the given tests. If given no arguments, run everything except mypyc-extra."" <TAB> <TAB> ) <TAB> <TAB> exit ( 1 ) <TAB> if not args : <TAB> <TAB> args = DEFAULT_COMMANDS [ : ] <TAB> status = 0 <TAB> if ""self"" in args and ""lint"" in args : <TAB> <TAB> <TAB> <TAB> proc = start_background_cmd ( ""lint"" ) <TAB> <TAB> cmd_status = run_cmd ( ""self"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> status = cmd_status <TAB> <TAB> cmd_status = wait_background_cmd ( ""lint"", proc ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> status = cmd_status <TAB> <TAB> args = [ arg for arg in args if arg not in ( ""self"", ""lint"" ) ] <TAB> for arg in args : <TAB> <TAB> cmd_status = run_cmd ( arg ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> status = cmd_status <TAB> exit ( status )",False,cmd_status,args,0.6722873449325562
|
||
|
4138,"def iterate ( dataset, batch_size, epochs, deterministic, pad_batches ) : <TAB> n_samples = dataset. _X_shape [ 0 ] <TAB> if deterministic : <TAB> <TAB> sample_perm = np. arange ( n_samples ) <TAB> if batch_size is None : <TAB> <TAB> batch_size = n_samples <TAB> for epoch in range ( epochs ) : <TAB> <TAB> if not deterministic : <TAB> <TAB> <TAB> sample_perm = np. random. permutation ( n_samples ) <TAB> <TAB> batch_idx = 0 <TAB> <TAB> num_batches = np. math. ceil ( n_samples / batch_size ) <TAB> <TAB> while batch_idx < num_batches : <TAB> <TAB> <TAB> start = batch_idx * batch_size <TAB> <TAB> <TAB> end = min ( n_samples, ( batch_idx + 1 ) * batch_size ) <TAB> <TAB> <TAB> indices = range ( start, end ) <TAB> <TAB> <TAB> perm_indices = sample_perm [ indices ] <TAB> <TAB> <TAB> if isinstance ( dataset. _X, np. ndarray ) : <TAB> <TAB> <TAB> <TAB> X_batch = dataset. _X [ perm_indices ] <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> X_batch = load_image_files ( [ dataset. _X [ i ] for i in perm_indices ] ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> y_batch = dataset. _y [ perm_indices ] <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> y_batch = load_image_files ( [ dataset. _y [ i ] for i in perm_indices ] ) <TAB> <TAB> <TAB> w_batch = dataset. _w [ perm_indices ] <TAB> <TAB> <TAB> ids_batch = dataset. _ids [ perm_indices ] <TAB> <TAB> <TAB> if pad_batches : <TAB> <TAB> <TAB> <TAB>",False,"isinstance(dataset._y, np.ndarray)",pad_batches,0.6508355140686035
|
||
|
4139,"def SmartStr ( string, encoding = ""utf8"" ) : <TAB> """"""Forces the string to be an encoded byte string."""""" <TAB> if six. PY3 : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return string. encode ( encoding, ""ignore"" ) <TAB> <TAB> elif isinstance ( string, bytes ) : <TAB> <TAB> <TAB> return string <TAB> <TAB> elif hasattr ( string, ""__bytes__"" ) : <TAB> <TAB> <TAB> return string. __bytes__ ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return bytes ( SmartUnicode ( string ), ""utf8"" ) <TAB> if six. PY2 : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return string <TAB> <TAB> elif hasattr ( string, ""__bytes__"" ) : <TAB> <TAB> <TAB> return string. __bytes__ ( ) <TAB> <TAB> return str ( string ). encode ( encoding )",False,"isinstance(string, str)","isinstance(string, ignore)",0.6524001359939575
|
||
|
4140,"def body ( self ) : <TAB> """"""Access the body of a constraint expression."""""" <TAB> if self. _constructed : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""Accessing the body of SimpleConstraint "" <TAB> <TAB> <TAB> <TAB> ""'%s' before the Constraint has been assigned "" <TAB> <TAB> <TAB> <TAB> ""an expression. There is currently "" <TAB> <TAB> <TAB> <TAB> ""nothing to access."" % ( self. cname ( True ) ) <TAB> <TAB> <TAB> ) <TAB> <TAB> return _GeneralConstraintData. body. fget ( self ) <TAB> raise ValueError ( <TAB> <TAB> ""Accessing the body of constraint '%s' "" <TAB> <TAB> ""before the Constraint has been constructed (there "" <TAB> <TAB> ""is currently no value to return)."" % ( self. cname ( True ) ) <TAB> )",False,len(self._data) == 0,self.name(True) == False,0.6555230617523193
|
||
|
4141,"def ToggleShellMode ( self, enableShellMode = None ) : <TAB> if enableShellMode == None : <TAB> <TAB> if self. mode == ""ShellMode"" : <TAB> <TAB> <TAB> self. mode = ""SlicesMode"" <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> self. mode = ""ShellMode"" <TAB> elif enableShellMode : <TAB> <TAB> self. mode = ""ShellMode"" <TAB> else : <TAB> <TAB> self. mode = ""SlicesMode"" <TAB> input_color = ""red"" <TAB> if self. mode == ""SlicesMode"" : <TAB> <TAB> self. MarkerDefine ( INPUT_START, stc. STC_MARK_BOXMINUS, ""white"", input_color ) <TAB> <TAB> self. MarkerDefine ( <TAB> <TAB> <TAB> INPUT_START_FOLDED, stc. STC_MARK_BOXPLUS, ""white"", input_color <TAB> <TAB> ) <TAB> <TAB> self. MarkerDefine ( INPUT_MIDDLE, stc. STC_MARK_VLINE, ""white"", input_color ) <TAB> <TAB> self. MarkerDefine ( INPUT_END, stc. STC_MARK_LCORNER, ""white"", input_color ) <TAB> elif self. mode == ""ShellMode"" : <TAB> <TAB> self. MarkerDefine ( INPUT_START, stc. STC_MARK_ARROWS, input_color, ""white"" ) <TAB> <TAB> self. MarkerDefine ( <TAB> <TAB> <TAB> INPUT_START_FOLDED, stc. STC_MARK_BOXPLUS, ""white"", input_color <TAB> <TAB> ) <TAB> <TAB> self. MarkerDefine ( INPUT_MIDDLE, stc. STC_MARK_DOTDOTDOT, input_color, ""white"" ) <TAB> <TAB> self. MarkerDefine ( INPUT_END, stc. STC_MARK_DOTDOTDOT, input_color, ""white"" )",True,self.mode == 'SlicesMode',self.mode == 'SlicesMode',0.6655997037887573
|
||
|
4142,"def recent_events ( self, events ) : <TAB> frame = events. get ( ""frame"" ) <TAB> if frame : <TAB> <TAB> try : <TAB> <TAB> <TAB> if self. format == ""jpeg"" : <TAB> <TAB> <TAB> <TAB> data = frame. jpeg_buffer <TAB> <TAB> <TAB> elif self. format == ""yuv"" and hasattr ( frame, ""yuv_buffer"" ) : <TAB> <TAB> <TAB> <TAB> data = frame. yuv_buffer <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> data = frame. bgr <TAB> <TAB> <TAB> elif self. format == ""gray"" and hasattr ( frame, ""gray"" ) : <TAB> <TAB> <TAB> <TAB> data = frame. gray <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> raise AttributeError ( ) <TAB> <TAB> except AttributeError : <TAB> <TAB> <TAB> logger. warning ( <TAB> <TAB> <TAB> <TAB> '{}s are not compatible with format ""{}""'. format ( <TAB> <TAB> <TAB> <TAB> <TAB> type ( frame ), self. format <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> blob = data <TAB> <TAB> events [ ""frame.world"" ] = [ <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> ""topic"" : ""frame"", <TAB> <TAB> <TAB> <TAB> ""width"" : frame. width, <TAB> <TAB> <TAB> <TAB> ""height"" : frame. height, <TAB> <TAB> <TAB> <TAB> ""index"" : frame. index, <TAB> <TAB> <TAB> <TAB> ""timestamp"" : frame. timestamp, <TAB> <TAB> <TAB> <TAB> ""format"" : self. format, <TAB> <TAB> <TAB> <",False,"self.format == 'bgr' and hasattr(frame, 'bgr')",self.format == 'bgr',0.6542139053344727
|
||
|
4143,"def download_subtitle ( self, subtitle ) : <TAB> <TAB> url = ""http://zip.{}/{}.zip"". format ( self. server_url, subtitle. subtitle_id ) <TAB> r = self. session. get ( url, headers = { ""Referer"" : subtitle. page_link }, timeout = 10 ) <TAB> r. raise_for_status ( ) <TAB> if len ( r. content ) == 0 : <TAB> <TAB> return <TAB> <TAB> with zipfile. ZipFile ( io. BytesIO ( r. content ) ) as zf : <TAB> <TAB> <TAB> <TAB> namelist = [ <TAB> <TAB> <TAB> n for n in zf. namelist ( ) if os. path. splitext ( n ) [ 1 ] in [ "".srt"", "".sub"" ] <TAB> <TAB> ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ProviderError ( ""More than one file to unzip"" ) <TAB> <TAB> subtitle. content = fix_line_ending ( zf. read ( namelist [ 0 ] ) )",True,len(namelist) > 1,len(namelist) > 1,0.6517270803451538
|
||
|
4144,"def _sync_remote_run ( remote_run ) : <TAB> assert remote_run. remote <TAB> remote_name = remote_run. remote. name <TAB> pull_args = click_util. Args ( remote = remote_name, delete = False ) <TAB> try : <TAB> <TAB> remote_impl_support. pull_runs ( [ remote_run ], pull_args ) <TAB> except Exception as e : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> log. exception ( ""pull %s from %s"", remote_run. id, remote_name ) <TAB> <TAB> else : <TAB> <TAB> <TAB> log. error ( ""error pulling %s from %s: %s"", remote_run. id, remote_name, e )",False,log.getEffectiveLevel() <= logging.DEBUG,delete,0.653241753578186
|
||
|
4145,"def _open_server ( self ) : <TAB> log_path = path. join ( <TAB> <TAB> self. experiment_path if self. experiment_path is not None else ""."", <TAB> <TAB> ""logs"", <TAB> <TAB> ""CARLA_LOG_{}.txt"". format ( self. port ), <TAB> ) <TAB> if not os. path. exists ( os. path. dirname ( log_path ) ) : <TAB> <TAB> os. makedirs ( os. path. dirname ( log_path ) ) <TAB> with open ( log_path, ""wb"" ) as out : <TAB> <TAB> cmd = [ <TAB> <TAB> <TAB> path. join ( environ. get ( ""CARLA_ROOT"" ), ""CarlaUE4.sh"" ), <TAB> <TAB> <TAB> self. map_path, <TAB> <TAB> <TAB> ""-benchmark"", <TAB> <TAB> <TAB> ""-carla-server"", <TAB> <TAB> <TAB> ""-fps={}"". format ( 30 / self. frame_skip ), <TAB> <TAB> <TAB> ""-world-port={}"". format ( self. port ), <TAB> <TAB> <TAB> ""-windowed -ResX={} -ResY={}"". format ( self. server_width, self. server_height ), <TAB> <TAB> <TAB> ""-carla-no-hud"", <TAB> <TAB> ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> cmd. append ( ""-carla-settings={}"". format ( self. config ) ) <TAB> <TAB> p = subprocess. Popen ( cmd, stdout = out, stderr = out ) <TAB> return p",True,self.config,self.config,0.6570847630500793
|
||
|
4146,"def convert ( low, high, lockout = False ) : <TAB> time = """" <TAB> tmp = 0 <TAB> if low == 0 and hex ( high ) == ""-0x80000000"" : <TAB> <TAB> return ""Not Set"" <TAB> if low == 0 and high == 0 : <TAB> <TAB> return ""None"" <TAB> if not lockout : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> high = abs ( high + 1 ) <TAB> <TAB> else : <TAB> <TAB> <TAB> high = abs ( high ) <TAB> <TAB> <TAB> low = abs ( low ) <TAB> <TAB> <TAB> tmp = low + ( high ) * 16 ** 8 <TAB> <TAB> <TAB> tmp *= 1e-7 <TAB> else : <TAB> <TAB> tmp = abs ( high ) * ( 1e-7 ) <TAB> try : <TAB> <TAB> minutes = int ( strftime ( ""%M"", gmtime ( tmp ) ) ) <TAB> <TAB> hours = int ( strftime ( ""%H"", gmtime ( tmp ) ) ) <TAB> <TAB> days = int ( strftime ( ""%j"", gmtime ( tmp ) ) ) - 1 <TAB> except ValueError as e : <TAB> <TAB> return ""[-] Invalid TIME"" <TAB> if days > 1 : <TAB> <TAB> time += ""{0} days "". format ( days ) <TAB> elif days == 1 : <TAB> <TAB> time += ""{0} day "". format ( days ) <TAB> if hours > 1 : <TAB> <TAB> time += ""{0} hours "". format ( hours ) <TAB> elif hours == 1 : <TAB> <TAB> time += ""{0} hour "". format ( hours ) <TAB> if minutes > 1 : <TAB> <TAB> time += ""{0} minutes "". format ( minutes ) <TAB> elif minutes == 1 : <TAB> <TAB> time += ""{0} minute "". format ( minutes ) <TAB> return time",False,low != 0,high > 0,0.6863808035850525
|
||
|
4147,"def _wait_security_domain_operation ( <TAB> client, hsm_name, identifier = None ) : <TAB> retries = 0 <TAB> max_retries = 30 <TAB> wait_second = 5 <TAB> while retries < max_retries : <TAB> <TAB> try : <TAB> <TAB> <TAB> ret = client. upload_pending ( vault_base_url = hsm_name ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return ret <TAB> <TAB> except : <TAB> <TAB> <TAB> pass <TAB> <TAB> time. sleep ( wait_second ) <TAB> <TAB> retries += 1 <TAB> return None",False,"ret and getattr(ret, 'status', None) in ['Succeeded', 'Failed']",identifier,0.6567783355712891
|
||
|
4148,"def addError ( self, test, err ) : <TAB> if err [ 0 ] is SkipTest : <TAB> <TAB> if self. showAll : <TAB> <TAB> <TAB> self. stream. writeln ( str ( err [ 1 ] ) ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> self. stream. write ( ""s"" ) <TAB> <TAB> <TAB> self. stream. flush ( ) <TAB> <TAB> return <TAB> _org_AddError ( self, test, err )",False,self.dots,self.showAll,0.6646468639373779
|
||
|
4149,"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> ( _ktype31, _vtype32, _size30 ) = iprot. readMapBegin ( ) <TAB> <TAB> <TAB> <TAB> for _i34 in xrange ( _size30 ) : <TAB> <TAB> <TAB> <TAB> <TAB> _key35 = iprot. readString ( ) <TAB> <TAB> <TAB> <TAB> <TAB> _val36 = ColumnDescriptor ( ) <TAB> <TAB> <TAB> <TAB> <TAB> _val36. read ( iprot ) <TAB> <TAB> <TAB> <TAB> <TAB> self. success [ _key35 ] = _val36 <TAB> <TAB> <TAB> <TAB> iprot. readMapEnd ( ) <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. io = IOError ( ) <TAB> <TAB> <TAB> <TAB> self. io. read ( i",False,ftype == TType.MAP,ftype == TType.ENUM,0.6627984642982483
|
||
|
4150,"def load_state ( self ) : <TAB> state = load_pickled_state_file ( ""files_tab.state"" ) <TAB> if not state : <TAB> <TAB> return <TAB> if state [ ""sort_id"" ] is not None and state [ ""sort_order"" ] is not None : <TAB> <TAB> self. treestore. set_sort_column_id ( state [ ""sort_id"" ], state [ ""sort_order"" ] ) <TAB> for ( index, column ) in enumerate ( self. listview. get_columns ( ) ) : <TAB> <TAB> cname = column. get_title ( ) <TAB> <TAB> if cname in state [ ""columns"" ] : <TAB> <TAB> <TAB> cstate = state [ ""columns"" ] [ cname ] <TAB> <TAB> <TAB> column. set_sizing ( Gtk. TreeViewColumnSizing. FIXED ) <TAB> <TAB> <TAB> column. set_fixed_width ( cstate [ ""width"" ] if cstate [ ""width"" ] > 0 else 10 ) <TAB> <TAB> <TAB> if state [ ""sort_id"" ] == index and state [ ""sort_order"" ] is not None : <TAB> <TAB> <TAB> <TAB> column. set_sort_indicator ( True ) <TAB> <TAB> <TAB> <TAB> column. set_sort_order ( state [ ""sort_order"" ] ) <TAB> <TAB> <TAB> if cstate [ ""position"" ]!= index : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> self. listview. move_column_after ( column, None ) <TAB> <TAB> <TAB> <TAB> elif ( <TAB> <TAB> <TAB> <TAB> <TAB> self. listview. get_columns ( ) [ cstate [ ""position"" ] - 1 ]. get_title ( ) <TAB> <TAB> <TAB> <TAB> <TAB>!= cname <TAB> <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> <TAB",False,cstate['position'] == 0,cstate['move_column'],0.6584089994430542
|
||
|
4151,"def nodes ( self, gid, sid, jid = None ) : <TAB> SQL = render_template ( <TAB> <TAB> ""/"". join ( [ self. template_path, self. _NODES_SQL ] ), jid = jid, conn = self. conn <TAB> ) <TAB> status, rset = self. conn. execute_dict ( SQL ) <TAB> if not status : <TAB> <TAB> return internal_server_error ( errormsg = rset ) <TAB> if jid is not None : <TAB> <TAB> if len ( rset [ ""rows"" ] )!= 1 : <TAB> <TAB> <TAB> return gone ( errormsg = _ ( ""Could not find the pgAgent job on the server."" ) ) <TAB> <TAB> return make_json_response ( <TAB> <TAB> <TAB> data = self. blueprint. generate_browser_node ( <TAB> <TAB> <TAB> <TAB> rset [ ""rows"" ] [ 0 ] [ ""jobid"" ], <TAB> <TAB> <TAB> <TAB> sid, <TAB> <TAB> <TAB> <TAB> rset [ ""rows"" ] [ 0 ] [ ""jobname"" ], <TAB> <TAB> <TAB> <TAB> ""icon-pga_job"" <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> else ""icon-pga_job-disabled"", <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> status = 200, <TAB> <TAB> ) <TAB> res = [ ] <TAB> for row in rset [ ""rows"" ] : <TAB> <TAB> res. append ( <TAB> <TAB> <TAB> self. blueprint. generate_browser_node ( <TAB> <TAB> <TAB> <TAB> row [ ""jobid"" ], <TAB> <TAB> <TAB> <TAB> sid, <TAB> <TAB> <TAB> <TAB> row [ ""jobname"" ], <TAB> <TAB> <TAB> <TAB> ""icon-pga_job"" if row [ ""jobenabled"" ] else ""icon-pga_job-disabled"", <TAB>",False,rset['rows'][0]['jobenabled'],rset['jobenabled'],0.6641470193862915
|
||
|
4152,"def complete_tags ( cls ) : <TAB> u""""""build a list of tags and store it in variable b:org_tag_completion"""""" <TAB> d = ORGMODE. get_document ( ) <TAB> heading = d. current_heading ( ) <TAB> if not heading : <TAB> <TAB> return <TAB> leading_portion = vim. eval ( u""a:ArgLead"" ). decode ( u""utf-8"" ) <TAB> cursor = int ( vim. eval ( u""a:CursorPos"" ) ) <TAB> <TAB> idx_orig = leading_portion. rfind ( u"":"", 0, cursor ) <TAB> if idx_orig == - 1 : <TAB> <TAB> idx = 0 <TAB> else : <TAB> <TAB> idx = idx_orig <TAB> current_tag = leading_portion [ idx : cursor ]. lstrip ( u"":"" ) <TAB> head = leading_portion [ : idx + 1 ] <TAB> if idx_orig == - 1 : <TAB> <TAB> head = u"""" <TAB> tail = leading_portion [ cursor : ] <TAB> <TAB> all_tags = set ( ) <TAB> for h in d. all_headings ( ) : <TAB> <TAB> for t in h. tags : <TAB> <TAB> <TAB> all_tags. add ( t ) <TAB> ignorecase = bool ( <TAB> <TAB> int ( <TAB> <TAB> <TAB> settings. get ( <TAB> <TAB> <TAB> <TAB> u""org_tag_completion_ignorecase"", int ( vim. eval ( u""&ignorecase"" ) ) <TAB> <TAB> <TAB> ) <TAB> <TAB> ) <TAB> ) <TAB> possible_tags = [ ] <TAB> current_tags = heading. tags <TAB> for t in all_tags : <TAB> <TAB> if ignorecase : <TAB> <TAB> <TAB> if t. lower ( ). startswith ( current_tag. lower ( ) ) : <TAB> <TAB> <TAB> <TAB> possible_tags. append ( t ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> possible_tags. append ( t ) <TAB> vim.",False,t.startswith(current_tag),t.lower().startswith(current_tag.lower()),0.6501619815826416
|
||
|
4153,"def __init__ ( self, * args, ** kwargs ) : <TAB> super ( ChallengePhaseCreateSerializer, self ). __init__ ( * args, ** kwargs ) <TAB> context = kwargs. get ( ""context"" ) <TAB> if context : <TAB> <TAB> challenge = context. get ( ""challenge"" ) <TAB> <TAB> if challenge : <TAB> <TAB> <TAB> kwargs [ ""data"" ] [ ""challenge"" ] = challenge. pk <TAB> <TAB> test_annotation = context. get ( ""test_annotation"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> kwargs [ ""data"" ] [ ""test_annotation"" ] = test_annotation",True,test_annotation,test_annotation,0.6686559915542603
|
||
|
4154,"def failUnlessRaises ( self, excClass, callableObj, * args, ** kwargs ) : <TAB> try : <TAB> <TAB> callableObj ( * args, ** kwargs ) <TAB> except excClass : <TAB> <TAB> return <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> excName = excClass. __name__ <TAB> <TAB> else : <TAB> <TAB> <TAB> excName = str ( excClass ) <TAB> <TAB> <TAB> <TAB> self. fail ( ""%s not raised"" % excName )",True,"hasattr(excClass, '__name__')","hasattr(excClass, '__name__')",0.6558315753936768
|
||
|
4155,"def _get_port ( ) : <TAB> while True : <TAB> <TAB> port = 20000 + random. randint ( 1, 9999 ) <TAB> <TAB> for i in range ( 5 ) : <TAB> <TAB> <TAB> sock = socket. socket ( socket. AF_INET, socket. SOCK_STREAM ) <TAB> <TAB> <TAB> result = sock. connect_ex ( ( ""127.0.0.1"", port ) ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> else : <TAB> <TAB> <TAB> return port",False,result == 0,result,0.6756051778793335
|
||
|
4156,"def slugify_instance ( inst, label, reserved = ( ), max_length = 30, * args, ** kwargs ) : <TAB> base_slug = slugify ( label ) [ : max_length ] <TAB> if base_slug in reserved : <TAB> <TAB> base_slug = None <TAB> elif base_slug is not None : <TAB> <TAB> base_slug = base_slug. strip ( ) <TAB> if not base_slug : <TAB> <TAB> base_slug = uuid4 ( ). hex [ : 12 ] <TAB> base_qs = type ( inst ). objects. all ( ) <TAB> if inst. id : <TAB> <TAB> base_qs = base_qs. exclude ( id = inst. id ) <TAB> if args or kwargs : <TAB> <TAB> base_qs = base_qs. filter ( * args, ** kwargs ) <TAB> inst. slug = base_slug <TAB> <TAB> if<mask> : <TAB> <TAB> return <TAB> <TAB> <TAB> <TAB> sizes = ( <TAB> <TAB> ( 1, 2 ), <TAB> <TAB> ( 5, 3 ), <TAB> <TAB> ( 20, 5 ), <TAB> <TAB> ( 1, 12 ), <TAB> ) <TAB> for attempts, size in sizes : <TAB> <TAB> for i in xrange ( attempts ) : <TAB> <TAB> <TAB> end = get_random_string ( <TAB> <TAB> <TAB> <TAB> size, allowed_chars = ""abcdefghijklmnopqrstuvwxyz0123456790"" <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> inst. slug = base_slug [ : max_length - size - 1 ] + ""-"" + end <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return",False,not base_qs.filter(slug__iexact=inst.slug).exists(),len(base_qs) > max_length,0.6466219425201416
|
||
|
4157,"def check ( self ) : <TAB> """"""Perform required checks to conclude if it's safe to operate"""""" <TAB> if self. interpreter. manual is None : <TAB> <TAB> if not self. process. healthy : <TAB> <TAB> <TAB> self. error = self. process. error <TAB> <TAB> <TAB> self. tip = self. process. tip <TAB> <TAB> <TAB> return False <TAB> start = time. time ( ) <TAB> while not self. _status ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. error = ""can't connect to the minserver on {}:{}"". format ( <TAB> <TAB> <TAB> <TAB> self. interpreter. host, self. interpreter. port <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> self. tip = ""check your vagrant machine is running"" <TAB> <TAB> <TAB> return False <TAB> <TAB> time. sleep ( 0.1 ) <TAB> return True",False,time.time() - start >= 2,self.interpreter.host is None or self.interpreter.port is None,0.6583954095840454
|
||
|
4158,"def _bytecode_filenames ( self, py_filenames ) : <TAB> bytecode_files = [ ] <TAB> for py_file in py_filenames : <TAB> <TAB> if not py_file. endswith ( "".py"" ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> bytecode_files. append ( py_file + ""c"" ) <TAB> <TAB> if self. optimize > 0 : <TAB> <TAB> <TAB> bytecode_files. append ( py_file + ""o"" ) <TAB> return bytecode_files",False,self.compile,self.compile > 0,0.6697002053260803
|
||
|
4159,"def get_files ( d ) : <TAB> f = [ ] <TAB> for root, dirs, files in os. walk ( d ) : <TAB> <TAB> for name in files : <TAB> <TAB> <TAB> if ""meta-environment"" in root or ""cross-canadian"" in root : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if ""do_build"" not in name and ""do_populate_sdk"" not in name : <TAB> <TAB> <TAB> <TAB> f. append ( os. path. join ( root, name ) ) <TAB> return f",False,'qemux86copy-' in root or 'qemux86-' in root,name == 'has-tags',0.6564231514930725
|
||
|
4160,"def listdir ( self, d ) : <TAB> try : <TAB> <TAB> return [ <TAB> <TAB> <TAB> p <TAB> <TAB> <TAB> for p in os. listdir ( d ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> ] <TAB> except OSError : <TAB> <TAB> return [ ]",False,"os.path.basename(p) != 'CVS' and os.path.isdir(os.path.join(d, p))",not self.lexicon,0.6517463326454163
|
||
|
4161,"def get ( self, subject, topic ) : <TAB> """"""Handles GET requests."""""" <TAB> if subject in feconf. AVAILABLE_LANDING_PAGES : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. render_template ( ""topic-landing-page.mainpage.html"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise self. PageNotFoundException <TAB> else : <TAB> <TAB> raise self. PageNotFoundException",False,topic in feconf.AVAILABLE_LANDING_PAGES[subject],topic in feconf.AVAILABLE_LANDING_PAGES,0.6543331146240234
|
||
|
4162,"def makeMasterGuiBinding ( self, stroke, w = None, trace = False ) : <TAB> """"""Make a master gui binding for stroke in pane w, or in all the standard widgets."""""" <TAB> k = self <TAB> c = k. c <TAB> f = c. frame <TAB> if w : <TAB> <TAB> widgets = [ w ] <TAB> else : <TAB> <TAB> <TAB> <TAB> bindingWidget = ( <TAB> <TAB> <TAB> f. tree and hasattr ( f. tree, ""bindingWidget"" ) and f. tree. bindingWidget or None <TAB> <TAB> ) <TAB> <TAB> wrapper = f. body and hasattr ( f. body, ""wrapper"" ) and f. body. wrapper or None <TAB> <TAB> canvas = f. tree and hasattr ( f. tree, ""canvas"" ) and f. tree. canvas or None <TAB> <TAB> widgets = ( c. miniBufferWidget, wrapper, canvas, bindingWidget ) <TAB> for w in widgets : <TAB> <TAB> if not w : <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> aList = k. masterGuiBindingsDict. get ( stroke, [ ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> aList. append ( w ) <TAB> <TAB> <TAB> k. masterGuiBindingsDict [ stroke ] = aList",False,w not in aList,aList and trace,0.6632737517356873
|
||
|
4163,"def __fill_counter_values ( self, command : str ) : <TAB> result = [ ] <TAB> regex = r""(item[0-9]+\.counter_value)"" <TAB> for token in re. split ( regex, command ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> result. append ( str ( self. simulator_config. item_dict [ token ]. value ) ) <TAB> <TAB> <TAB> except ( KeyError, ValueError, AttributeError ) : <TAB> <TAB> <TAB> <TAB> logger. error ( ""Could not get counter value for "" + token ) <TAB> <TAB> else : <TAB> <TAB> <TAB> result. append ( token ) <TAB> return """". join ( result )",False,"re.match(regex, token) is not None",token in self.simulator_config.item_dict,0.6487523317337036
|
||
|
4164,"def _update ( self, child ) : <TAB> <TAB> ( left, top, right, bot ) = child. bbox ( ) <TAB> y = self. _yalign ( top, bot ) <TAB> for c in self. _children : <TAB> <TAB> ( x1, y1, x2, y2 ) = c. bbox ( ) <TAB> <TAB> c. move ( 0, y - self. _yalign ( y1, y2 ) ) <TAB> if self. _ordered and len ( self. _children ) > 1 : <TAB> <TAB> index = self. _children. index ( child ) <TAB> <TAB> x = right + self. _space <TAB> <TAB> for i in range ( index + 1, len ( self. _children ) ) : <TAB> <TAB> <TAB> ( x1, y1, x2, y2 ) = self. _children [ i ]. bbox ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. _children [ i ]. move ( x - x1, 0 ) <TAB> <TAB> <TAB> <TAB> x += x2 - x1 + self. _space <TAB> <TAB> x = left - self. _space <TAB> <TAB> for i in range ( index - 1, - 1, - 1 ) : <TAB> <TAB> <TAB> ( x1, y1, x2, y2 ) = self. _children [ i ]. bbox ( ) <TAB> <TAB> <TAB> if x < x2 : <TAB> <TAB> <TAB> <TAB> self. _children [ i ]. move ( x - x2, 0 ) <TAB> <TAB> <TAB> <TAB> x -= x2 - x1 + self. _space",False,x > x1,x < right,0.6712762117385864
|
||
|
4165,"def mouse_down ( self, ips, x, y, btn, ** key ) : <TAB> lim = 5.0 / key [ ""canvas"" ]. get_scale ( ) <TAB> ips. mark = self. helper <TAB> if btn == 1 : <TAB> <TAB> if not self. doing : <TAB> <TAB> <TAB> print ( ips. roi ) <TAB> <TAB> <TAB> print ( self. curobj ) <TAB> <TAB> <TAB> if ips. roi!= None : <TAB> <TAB> <TAB> <TAB> self. curobj = ips. roi. pick ( x, y, ips. cur, lim ) <TAB> <TAB> <TAB> <TAB> ips. roi. info ( ips, self. curobj ) <TAB> <TAB> <TAB> if self. curobj!= None : <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> if ips. roi == None : <TAB> <TAB> <TAB> <TAB> print ( 1 ) <TAB> <TAB> <TAB> <TAB> ips. roi = lineroi. LineRoi ( ) <TAB> <TAB> <TAB> <TAB> self. doing = True <TAB> <TAB> <TAB> elif ips. roi. dtype == ""line"" and key [ ""shift"" ] : <TAB> <TAB> <TAB> <TAB> print ( 2 ) <TAB> <TAB> <TAB> <TAB> self. doing = True <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> ips. roi = None <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. helper. addpoint ( ( x, y ) ) <TAB> <TAB> <TAB> self. curobj = ( self. helper. buf, - 1 ) <TAB> <TAB> <TAB> self. odx, self. ody = x, y <TAB> elif btn == 3 : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. helper. addpoint ( ( x, y ) ) <TAB> <TAB> <TAB> self. doing = False <TAB> <TAB> <TAB> ips. roi.",True,self.doing,self.doing,0.6586557626724243
|
||
|
4166,"def _unpack_map ( code, fp, options ) : <TAB> if ( ord ( code ) & 0xF0 ) == 0x80 : <TAB> <TAB> length = ord ( code ) & ~ 0xF0 <TAB> elif code == b""\xde"" : <TAB> <TAB> length = struct. unpack ( "">H"", _read_except ( fp, 2 ) ) [ 0 ] <TAB> elif code == b""\xdf"" : <TAB> <TAB> length = struct. unpack ( "">I"", _read_except ( fp, 4 ) ) [ 0 ] <TAB> else : <TAB> <TAB> raise Exception ( ""logic error, not map: 0x%02x"" % ord ( code ) ) <TAB> d = { } if not options. get ( ""use_ordered_dict"" ) else collections. OrderedDict ( ) <TAB> for _ in xrange ( length ) : <TAB> <TAB> <TAB> <TAB> k = _unpack ( fp, options ) <TAB> <TAB> if isinstance ( k, list ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> k = _deep_list_to_tuple ( k ) <TAB> <TAB> elif not isinstance ( k, collections. Hashable ) : <TAB> <TAB> <TAB> raise UnhashableKeyException ( <TAB> <TAB> <TAB> <TAB> ""encountered unhashable key: %s, %s"" % ( str ( k ), str ( type ( k ) ) ) <TAB> <TAB> <TAB> ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> raise DuplicateKeyException ( <TAB> <TAB> <TAB> <TAB> ""encountered duplicate key: %s, %s"" % ( str ( k ), str ( type ( k ) ) ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> v = _unpack ( fp, options ) <TAB> <TAB> try : <TAB> <TAB> <TAB> d [ k ] = v <TAB> <TAB> except TypeError : <TAB> <TAB> <TAB> raise UnhashableKeyException ( ""encountered unhashable key: %s"" % str ( k ) ) <TAB",True,k in d,k in d,0.676453709602356
|
||
|
4167,"def _printForward ( user, result ) : <TAB> if ""enabled"" in result : <TAB> <TAB> row = { ""User"" : user, ""forwardEnabled"" : result [ ""enabled"" ] } <TAB> <TAB> if result [ ""enabled"" ] : <TAB> <TAB> <TAB> row [ ""forwardTo"" ] = result [ ""emailAddress"" ] <TAB> <TAB> <TAB> row [ ""disposition"" ] = result [ ""disposition"" ] <TAB> else : <TAB> <TAB> row = { ""User"" : user, ""forwardEnabled"" : result [ ""enable"" ] } <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> row [ ""forwardTo"" ] = result [ ""forwardTo"" ] <TAB> <TAB> <TAB> row [ ""disposition"" ] = EMAILSETTINGS_OLD_NEW_OLD_FORWARD_ACTION_MAP [ <TAB> <TAB> <TAB> <TAB> result [ ""action"" ] <TAB> <TAB> <TAB> ] <TAB> csvRows. append ( row )",False,result['enable'] == 'true',result['forwardTo'],0.6590452194213867
|
||
|
4168,"def _stop_child_threads ( self, name = None ) : <TAB> """"""Stops all threads spawn by this activity."""""" <TAB> for thread_name, thread in list ( self. _child_thread_map. items ( ) ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> LOG. debug ( ""%s: Stopping child thread %s"", self. name, thread_name ) <TAB> <TAB> <TAB> thread. kill ( ) <TAB> <TAB> <TAB> self. _child_thread_map. pop ( thread_name, None )",False,name is not None and thread_name is name,name is None or thread_name is name,0.6503958702087402
|
||
|
4169,"def page_file ( self, page ) : <TAB> try : <TAB> <TAB> page = self. notebook. get_page ( page ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return page. source <TAB> <TAB> else : <TAB> <TAB> <TAB> return None <TAB> except PageNotFoundError : <TAB> <TAB> return None",False,"hasattr(page, 'source') and isinstance(page.source, File)",page,0.6521341800689697
|
||
|
4170,"def logIn ( username = """", password = """" ) : <TAB> cf = TidalConfig ( ) <TAB> if username == """" or password == """" : <TAB> <TAB> print ( ""----------------LogIn------------------"" ) <TAB> <TAB> username = myinput ( ""username:"" ) <TAB> <TAB> password = myinput ( ""password:"" ) <TAB> account3 = TidalMobileSession ( username, password, TIDAL_TOKEN. clientID, cf ) <TAB> if account3. errmsg is None : <TAB> <TAB> cf. set_account2 ( <TAB> <TAB> <TAB> username, <TAB> <TAB> <TAB> password, <TAB> <TAB> <TAB> account3. access_token, <TAB> <TAB> <TAB> account3. country_code, <TAB> <TAB> <TAB> account3. user_id, <TAB> <TAB> ) <TAB> else : <TAB> <TAB> cf. set_account2 ( username, password, """", """", """" ) <TAB> <TAB> printWarning ( 0, ""Login err(by mobile)!"" + account3. errmsg ) <TAB> <TAB> account = TidalAccount ( username, password, TIDAL_TOKEN, False, cf ) <TAB> <TAB> account2 = TidalAccount ( username, password, TIDAL_TOKEN, True, cf ) <TAB> <TAB> if account. errmsg!= """" and account2. errmsg!= """" : <TAB> <TAB> <TAB> printErr ( 0, account. errmsg ) <TAB> <TAB> <TAB> return False <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> account = account2 <TAB> <TAB> elif account2. errmsg!= """" : <TAB> <TAB> <TAB> account2 = account <TAB> <TAB> cf. set_account ( <TAB> <TAB> <TAB> username, <TAB> <TAB> <TAB> password, <TAB> <TAB> <TAB> account. session_id, <TAB> <TAB> <TAB> account. country_code, <TAB> <TAB> <TAB> account. user_id, <TAB> <TAB> <TAB> account2. session_id,",False,account.errmsg != '',account.errmsg == '',0.6822667121887207
|
||
|
4171,"def deserialize_txs ( ) : <TAB> to_hashX = self. coin. hashX_from_script <TAB> deserializer = self. coin. DESERIALIZER <TAB> txs = { } <TAB> for hash, raw_tx in zip ( hashes, raw_txs ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> tx, tx_size = deserializer ( raw_tx ). read_tx_and_vsize ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> txin_pairs = tuple ( <TAB> <TAB> <TAB> ( txin. prev_hash, txin. prev_idx ) <TAB> <TAB> <TAB> for txin in tx. inputs <TAB> <TAB> <TAB> if not txin. is_generation ( ) <TAB> <TAB> ) <TAB> <TAB> txout_pairs = tuple ( <TAB> <TAB> <TAB> ( to_hashX ( txout. pk_script ), txout. value ) for txout in tx. outputs <TAB> <TAB> ) <TAB> <TAB> txs [ hash ] = MemPoolTx ( txin_pairs, None, txout_pairs, 0, tx_size ) <TAB> return txs",False,not raw_tx,raw_tx is None,0.6741667985916138
|
||
|
4172,"def get_lang ( node ) : <TAB> <TAB> retval = None <TAB> if node. hasAttribute ( ""lang"" ) : <TAB> <TAB> retval = node. getAttribute ( ""lang"" ) <TAB> if retval and node. hasAttribute ( ""xml:lang"" ) : <TAB> <TAB> xmllang = node. getAttribute ( ""xml:lang"" ). lower ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> retval = None <TAB> return retval",False,not (xmllang != None and xmllang == retval.lower()),xmllang != 'en',0.6515306234359741
|
||
|
4173,"def chop ( expr, delta = 10.0 ** ( - 10.0 ) ) : <TAB> if isinstance ( expr, Real ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return Integer ( 0 ) <TAB> elif isinstance ( expr, Complex ) and expr. is_inexact ( ) : <TAB> <TAB> real, imag = expr. real, expr. imag <TAB> <TAB> if - delta < real. get_float_value ( ) < delta : <TAB> <TAB> <TAB> real = Integer ( 0 ) <TAB> <TAB> if - delta < imag. get_float_value ( ) < delta : <TAB> <TAB> <TAB> imag = Integer ( 0 ) <TAB> <TAB> return Complex ( real, imag ) <TAB> elif isinstance ( expr, Expression ) : <TAB> <TAB> return Expression ( chop ( expr. head ), * [ chop ( leaf ) for leaf in expr. leaves ] ) <TAB> return expr",False,-delta < expr.get_float_value() < delta,-delta < 0,0.6514445543289185
|
||
|
4174,def getFirstSubGraph ( graph ) : <TAB> if len ( graph ) == 0 : <TAB> <TAB> return None <TAB> subg = { } <TAB> todo = [ graph. keys ( ) [ 0 ] ] <TAB> while len ( todo ) > 0 : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> subg [ todo [ 0 ] ] = graph [ todo [ 0 ] ] <TAB> <TAB> <TAB> todo. extend ( graph [ todo [ 0 ] ] ) <TAB> <TAB> <TAB> del graph [ todo [ 0 ] ] <TAB> <TAB> del todo [ 0 ] <TAB> return subg,False,todo[0] in graph.keys(),graph[todo[0]] == 1,0.6583659648895264
|
||
|
4175,"def __process_update ( self, table, uuid, old, new ) : <TAB> old_row = table. rows. get ( uuid ) <TAB> if old_row is not None : <TAB> <TAB> old_row = model. Row ( dictify ( old_row ) ) <TAB> <TAB> old_row [ ""_uuid"" ] = uuid <TAB> changed = idl. Idl. __process_update ( self, table, uuid, old, new ) <TAB> if changed : <TAB> <TAB> if not new : <TAB> <TAB> <TAB> ev = ( event. EventRowDelete, ( table. name, old_row ) ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> new_row = model. Row ( dictify ( table. rows. get ( uuid ) ) ) <TAB> <TAB> <TAB> new_row [ ""_uuid"" ] = uuid <TAB> <TAB> <TAB> ev = ( event. EventRowInsert, ( table. name, new_row ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> new_row = model. Row ( dictify ( table. rows. get ( uuid ) ) ) <TAB> <TAB> <TAB> new_row [ ""_uuid"" ] = uuid <TAB> <TAB> <TAB> ev = ( event. EventRowUpdate, ( table. name, old_row, new_row ) ) <TAB> <TAB> self. _events. append ( ev ) <TAB> return changed",False,not old,uuid,0.6882584095001221
|
||
|
4176,"def get_encoding ( headers, content ) : <TAB> """"""Get encoding from request headers or page head."""""" <TAB> encoding = None <TAB> content_type = headers. get ( ""content-type"" ) <TAB> if content_type : <TAB> <TAB> _, params = cgi. parse_header ( content_type ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> encoding = params [ ""charset"" ]. strip ( ""'\"""" ) <TAB> if not encoding : <TAB> <TAB> content = utils. pretty_unicode ( content [ : 1000 ] ) if six. PY3 else content <TAB> <TAB> charset_re = re. compile ( r'<meta.*?charset=[""\']*(.+?)[""\'>]', flags = re. I ) <TAB> <TAB> pragma_re = re. compile ( <TAB> <TAB> <TAB> r'<meta.*?content=[""\']*;?charset=(.+?)[""\'>]', flags = re. I <TAB> <TAB> ) <TAB> <TAB> xml_re = re. compile ( r'^<\?xml.*?encoding=[""\']*(.+?)[""\'>]' ) <TAB> <TAB> encoding = ( <TAB> <TAB> <TAB> charset_re. findall ( content ) <TAB> <TAB> <TAB> + pragma_re. findall ( content ) <TAB> <TAB> <TAB> + xml_re. findall ( content ) <TAB> <TAB> ) <TAB> <TAB> encoding = encoding and encoding [ 0 ] or None <TAB> return encoding",True,'charset' in params,'charset' in params,0.6701338291168213
|
||
|
4177,"def add ( <TAB> self, <TAB> action : types. NestedArray, <TAB> next_timestep : dm_env. TimeStep, <TAB> extras : types. NestedArray = ( ), ) : <TAB> """"""Record an action and the following timestep."""""" <TAB> if self. _next_observation is None : <TAB> <TAB> raise ValueError ( ""adder.add_first must be called before adder.add."" ) <TAB> discount = next_timestep. discount <TAB> if next_timestep. last ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> discount = tree. map_structure ( <TAB> <TAB> <TAB> <TAB> lambda d : np. broadcast_to ( next_timestep. discount, np. shape ( d ) ), <TAB> <TAB> <TAB> <TAB> self. _buffer [ - 1 ]. discount, <TAB> <TAB> <TAB> ) <TAB> <TAB> self. _buffer. append ( <TAB> <TAB> Step ( <TAB> <TAB> <TAB> observation = self. _next_observation, <TAB> <TAB> <TAB> action = action, <TAB> <TAB> <TAB> reward = next_timestep. reward, <TAB> <TAB> <TAB> discount = discount, <TAB> <TAB> <TAB> start_of_episode = self. _start_of_episode, <TAB> <TAB> <TAB> extras = extras, <TAB> <TAB> ) <TAB> ) <TAB> <TAB> self. _next_observation = next_timestep. observation <TAB> self. _start_of_episode = False <TAB> self. _write ( ) <TAB> <TAB> if next_timestep. last ( ) : <TAB> <TAB> self. _write_last ( ) <TAB> <TAB> self. reset ( )",False,self._buffer and (not tree.is_nested(next_timestep.discount)),tree is not None,0.6526888012886047
|
||
|
4178,"def after_name ( ) -> None : <TAB> self. write ( ""("" ) <TAB> self. visit_list ( node. params, newlines = False ) <TAB> self. write ( "")"" ) <TAB> self. write ( "" -> "" ) <TAB> self. write ( node. returning_typemod. to_edgeql ( ), "" "" ) <TAB> self. visit ( node. returning ) <TAB> if node. commands : <TAB> <TAB> self. write ( "" {"" ) <TAB> <TAB> self. _block_ws ( 1 ) <TAB> <TAB> self. visit_list ( node. commands, terminator = "";"" ) <TAB> <TAB> self. new_lines = 1 <TAB> else : <TAB> <TAB> self. write ( "" "" ) <TAB> if node. code. from_function : <TAB> <TAB> from_clause = f""USING {node.code.language} FUNCTION "" <TAB> <TAB> if self. sdlmode : <TAB> <TAB> <TAB> from_clause = from_clause. lower ( ) <TAB> <TAB> self. write ( from_clause ) <TAB> <TAB> self. write ( f""{node.code.from_function!r}"" ) <TAB> elif node. code. language is qlast. Language. EdgeQL : <TAB> <TAB> if node. nativecode : <TAB> <TAB> <TAB> self. _write_keywords ( ""USING"" ) <TAB> <TAB> <TAB> self. write ( "" ("" ) <TAB> <TAB> <TAB> self. visit ( node. nativecode ) <TAB> <TAB> <TAB> self. write ( "")"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> assert node. code. code <TAB> <TAB> <TAB> self. _write_keywords ( ""USING"" ) <TAB> <TAB> <TAB> self. write ( f"" ({node.code.code})"" ) <TAB> else : <TAB> <TAB> from_clause = f""USING {node.code.language} "" <TAB> <TAB> if self. sdlmode : <TAB> <TAB> <TAB> from_clause = from_clause.",False,node.code.code,node.code,0.6557097434997559
|
||
|
4179,"def validate ( self ) : <TAB> <TAB> for tree_node in self. _tree_nodes : <TAB> <TAB> sum_probabilities = 0.0 <TAB> <TAB> if len ( tree_node. _children ) > 0 : <TAB> <TAB> <TAB> for child in tree_node. _children : <TAB> <TAB> <TAB> <TAB> sum_probabilities += child. _conditional_probability <TAB> <TAB> <TAB> if abs ( 1.0 - sum_probabilities ) > 0.000001 : <TAB> <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> <TAB> ""The child conditional probabilities for tree node=%s "" <TAB> <TAB> <TAB> <TAB> <TAB> "" sum to %s"" % ( tree_node. _name, sum_probabilities ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> return False <TAB> <TAB> num_roots = 0 <TAB> root_ids = [ ] <TAB> for tree_node in self. _tree_nodes : <TAB> <TAB> if tree_node. _parent is None : <TAB> <TAB> <TAB> num_roots += 1 <TAB> <TAB> <TAB> root_ids. append ( tree_node. _name ) <TAB> if num_roots!= 1 : <TAB> <TAB> print ( ""Illegal set of root nodes detected: "" + str ( root_ids ) ) <TAB> <TAB> return False <TAB> <TAB> for tree_node in self. _tree_nodes : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> ""There are no scenarios associated with tree node=%s"" <TAB> <TAB> <TAB> <TAB> % ( tree_node. _name ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> return False <TAB> return True",False,len(tree_node._scenarios) == 0,len(tree_node._scenarioes) == 0,0.653666615486145
|
||
|
4180,"def findcommonoutgoing ( orig, repo, other, * args, ** kwargs ) : <TAB> if isinstance ( other, gitrepo. gitrepo ) : <TAB> <TAB> git = GitHandler ( repo, repo. ui ) <TAB> <TAB> heads = git. get_refs ( other. path ) [ 0 ] <TAB> <TAB> kw = { } <TAB> <TAB> kw. update ( kwargs ) <TAB> <TAB> for val, k in zip ( args, ( ""onlyheads"", ""force"", ""commoninc"", ""portable"" ) ) : <TAB> <TAB> <TAB> kw [ k ] = val <TAB> <TAB> force = kw. get ( ""force"", False ) <TAB> <TAB> commoninc = kw. get ( ""commoninc"", None ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> commoninc = discovery. findcommonincoming ( <TAB> <TAB> <TAB> <TAB> repo, other, heads = heads, force = force <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> kw [ ""commoninc"" ] = commoninc <TAB> <TAB> return orig ( repo, other, ** kw ) <TAB> return orig ( repo, other, * args, ** kwargs )",False,commoninc is None,commoninc is None or force,0.6587353944778442
|
||
|
4181,"def chromecast_control ( action ) : <TAB> <TAB> <TAB> TV = pychromecast. Chromecast ( <TAB> <TAB> ""192.168.1.13"" <TAB> ) <TAB> mc = TV. media_controller <TAB> if ""pause"". lower ( ) in str ( action ). lower ( ) : <TAB> <TAB> TV. wait ( ) <TAB> <TAB> time. sleep ( 1 ) <TAB> <TAB> mc. pause ( ) <TAB> if ""resume"". lower ( ) in str ( action ). lower ( ) : <TAB> <TAB> TV. wait ( ) <TAB> <TAB> time. sleep ( 1 ) <TAB> <TAB> mc. play ( ) <TAB> if ""end"". lower ( ) in str ( action ). lower ( ) : <TAB> <TAB> TV. wait ( ) <TAB> <TAB> time. sleep ( 1 ) <TAB> <TAB> mc. stop ( ) <TAB> if ""volume"". lower ( ) in str ( action ). lower ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> TV. wait ( ) <TAB> <TAB> <TAB> time. sleep ( 1 ) <TAB> <TAB> <TAB> TV. volume_up ( 0.2 ) <TAB> <TAB> if ""down"". lower ( ) in str ( action ). lower ( ) : <TAB> <TAB> <TAB> TV. wait ( ) <TAB> <TAB> <TAB> time. sleep ( 1 ) <TAB> <TAB> <TAB> TV. volume_down ( 0.2 )",False,'up'.lower() in str(action).lower(),action.lower(),0.6485540270805359
|
||
|
4182,"def on_request ( self, context, request ) : <TAB> if ""Invoke-PSInject.ps1"" == request. path [ 1 : ] : <TAB> <TAB> request. send_response ( 200 ) <TAB> <TAB> request. end_headers ( ) <TAB> <TAB> request. wfile. write ( self. ps_script1 ) <TAB> elif ""Get-Keystrokes.ps1"" == request. path [ 1 : ] : <TAB> <TAB> request. send_response ( 200 ) <TAB> <TAB> request. end_headers ( ) <TAB> <TAB> <TAB> <TAB> keys_folder_path = os. path. join ( <TAB> <TAB> <TAB> context. log_folder_path, <TAB> <TAB> <TAB> ""get_keystrokes_{}"". format ( request. client_address [ 0 ] ), <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> os. mkdir ( keys_folder_path ) <TAB> <TAB> request. wfile. write ( self. ps_script2 ) <TAB> <TAB> request. stop_tracking_host ( ) <TAB> else : <TAB> <TAB> request. send_response ( 404 ) <TAB> <TAB> request. end_headers ( )",True,not os.path.exists(keys_folder_path),not os.path.exists(keys_folder_path),0.645585298538208
|
||
|
4183,"def render_logic ( self, path = """" ) : <TAB> if path in self. files : <TAB> <TAB> filesystem_path = self. files [ path ] <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> filenames = [ ] <TAB> <TAB> <TAB> for filename in os. listdir ( filesystem_path ) : <TAB> <TAB> <TAB> <TAB> if os. path. isdir ( os. path. join ( filesystem_path, filename ) ) : <TAB> <TAB> <TAB> <TAB> <TAB> filenames. append ( filename + ""/"" ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> filenames. append ( filename ) <TAB> <TAB> <TAB> filenames. sort ( ) <TAB> <TAB> <TAB> return self. directory_listing ( filenames, path, filesystem_path ) <TAB> <TAB> <TAB> <TAB> elif os. path. isfile ( filesystem_path ) : <TAB> <TAB> <TAB> if self. download_individual_files : <TAB> <TAB> <TAB> <TAB> return self. stream_individual_file ( filesystem_path ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> history_id = self. cur_history_id <TAB> <TAB> <TAB> <TAB> self. cur_history_id += 1 <TAB> <TAB> <TAB> <TAB> return self. web. error404 ( history_id ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> history_id = self. cur_history_id <TAB> <TAB> <TAB> self. cur_history_id += 1 <TAB> <TAB> <TAB> return self. web. error404 ( history_id ) <TAB> else : <TAB> <TAB> <TAB> <TAB> if path == """" : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> filenames = list ( self. root_files ) <TAB> <TAB> <TAB> filenames. sort ( )",True,os.path.isdir(filesystem_path),os.path.isdir(filesystem_path),0.6479696035385132
|
||
|
4184,"def fit ( self, series : TimeSeries ) : <TAB> super ( ). fit ( series ) <TAB> series = self. training_series <TAB> in_df = pd. DataFrame ( <TAB> <TAB> data = { ""ds"" : series. time_index ( ), ""y"" : series. univariate_values ( ) } <TAB> ) <TAB> <TAB> self. model = fbprophet. Prophet ( ** self. prophet_kwargs ) <TAB> if self. freq is not None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> interval_length = 30.4375 <TAB> <TAB> elif series. freq_str ( ) == ""Y"" : <TAB> <TAB> <TAB> interval_length = 365.25 <TAB> <TAB> else : <TAB> <TAB> <TAB> interval_length = pd. to_timedelta ( series. freq_str ( ) ). days <TAB> <TAB> self. model. add_seasonality ( <TAB> <TAB> <TAB> name = ""custom"", period = self. freq * interval_length, fourier_order = 5 <TAB> <TAB> ) <TAB> <TAB> if self. country_holidays is not None : <TAB> <TAB> self. model. add_country_holidays ( self. country_holidays ) <TAB> execute_and_suppress_output ( self. model. fit, logger, logging. WARNING, in_df )",False,"series.freq_str() in ['MS', 'M', 'ME']",series.freq_str() == 'X',0.6523253917694092
|
||
|
4185,"def sanitize_css ( self, style ) : <TAB> <TAB> style = re. compile ( ""url\s*\(\s*[^\s)]+?\s*\)\s*"" ). sub ( "" "", style ) <TAB> <TAB> if not re. match ( <TAB> <TAB> """"""^([:,;#%.\sa-zA-Z0-9!]|\w-\w|'[\s\w]+'|""[\s\w]+""|\([\d,\s]+\))*$"""""", style <TAB> ) : <TAB> <TAB> return """" <TAB> if not re. match ( ""^\s*([-\w]+\s*:[^:;]*(;\s*|$))*$"", style ) : <TAB> <TAB> return """" <TAB> clean = [ ] <TAB> for prop, value in re. findall ( ""([-\w]+)\s*:\s*([^:;]*)"", style ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> if prop. lower ( ) in self. allowed_css_properties : <TAB> <TAB> <TAB> clean. append ( prop + "": "" + value + "";"" ) <TAB> <TAB> elif prop. split ( ""-"" ) [ 0 ]. lower ( ) in [ <TAB> <TAB> <TAB> ""background"", <TAB> <TAB> <TAB> ""border"", <TAB> <TAB> <TAB> ""margin"", <TAB> <TAB> <TAB> ""padding"", <TAB> <TAB> ] : <TAB> <TAB> <TAB> for keyword in value. split ( ) : <TAB> <TAB> <TAB> <TAB> if keyword not in self. acceptable_css_keywords and not re. match ( <TAB> <TAB> <TAB> <TAB> <TAB> ""^(#[0-9a-f]+|rgb\(\d+%?,\d*%?,?\d*%?\)?|\d{0,2}\.?\d{0,2}(cm|em|ex|in|mm|pc|pt|px|%|,|\))?)$"", <TAB> <TAB> <TAB> <TAB> <TAB> keyword, <TAB> <TAB> <TAB",False,not value,len(clean) > 0,0.6665922999382019
|
||
|
4186,"def render ( self, name, value, attrs = None ) : <TAB> r = super ( AdminFileWithPreviewWidget, self ). render ( name, value, attrs = attrs ) <TAB> if value and getattr ( value, ""instance"", None ) : <TAB> <TAB> image = admin_thumbnail ( value. instance ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> r = mark_safe ( <TAB> <TAB> <TAB> <TAB> ( <TAB> <TAB> <TAB> <TAB> <TAB> '<img src=""%s"" alt="""" style=""float: left; padding-right:' <TAB> <TAB> <TAB> <TAB> <TAB> '8px; border-right: 1px solid #ccc; margin-right: 8px""' <TAB> <TAB> <TAB> <TAB> <TAB> "">"" % image <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> + r <TAB> <TAB> <TAB> ) <TAB> return r",True,image,image,0.6937013268470764
|
||
|
4187,"def add_hook ( self, save = True ) : <TAB> if self. user_settings : <TAB> <TAB> connect = GitLabClient ( external_account = self. external_account ) <TAB> <TAB> secret = utils. make_hook_secret ( ) <TAB> <TAB> hook = connect. add_hook ( <TAB> <TAB> <TAB> self. user, <TAB> <TAB> <TAB> self. repo, <TAB> <TAB> <TAB> ""web"", <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> ""url"" : urljoin ( <TAB> <TAB> <TAB> <TAB> <TAB> hook_domain, os. path. join ( self. owner. api_url, ""gitlab"", ""hook/"" ) <TAB> <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> <TAB> ""content_type"" : gitlab_settings. HOOK_CONTENT_TYPE, <TAB> <TAB> <TAB> <TAB> ""secret"" : secret, <TAB> <TAB> <TAB> }, <TAB> <TAB> <TAB> events = gitlab_settings. HOOK_EVENTS, <TAB> <TAB> ) <TAB> <TAB> if hook : <TAB> <TAB> <TAB> self. hook_id = hook. id <TAB> <TAB> <TAB> self. hook_secret = secret <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. save ( )",True,save,save,0.6947234272956848
|
||
|
4188,"def _load_testfile ( filename, package, module_relative ) : <TAB> if module_relative : <TAB> <TAB> package = _normalize_module ( package, 3 ) <TAB> <TAB> filename = _module_relative_path ( package, filename ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if hasattr ( package. __loader__, ""get_data"" ) : <TAB> <TAB> <TAB> <TAB> file_contents = package. __loader__. get_data ( filename ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return file_contents. replace ( os. linesep, ""\n"" ), filename <TAB> return open ( filename ). read ( ), filename",False,"hasattr(package, '__loader__')",filename is not None,0.6530807018280029
|
||
|
4189,"def _post_process_ttl ( zone ) : <TAB> for name in zone : <TAB> <TAB> for record_type in zone [ name ] : <TAB> <TAB> <TAB> records = zone [ name ] [ record_type ] <TAB> <TAB> <TAB> if isinstance ( records, list ) : <TAB> <TAB> <TAB> <TAB> ttl = min ( [ x [ ""ttl"" ] for x in records ] ) <TAB> <TAB> <TAB> <TAB> for record in records : <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> logger. warning ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""Using lowest TTL {} for the record set. Ignoring value {}"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ttl, record [ ""ttl"" ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> record [ ""ttl"" ] = ttl",False,record['ttl'] != ttl,record['ttl'] is None,0.6723483800888062
|
||
|
4190,"def execute ( cls, ctx, op ) : <TAB> inputs, device_id, xp = as_same_device ( <TAB> <TAB> [ ctx [ inp. key ] for inp in op. inputs ], device = op. device, ret_extra = True <TAB> ) <TAB> a = inputs [ 0 ] <TAB> if len ( inputs ) == 2 : <TAB> <TAB> kth = inputs [ 1 ] <TAB> else : <TAB> <TAB> kth = op. kth <TAB> return_value, return_indices = op. return_value, op. return_indices <TAB> with device ( device_id ) : <TAB> <TAB> kw = { } <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> kw [ ""kind"" ] = op. kind <TAB> <TAB> if op. order is not None : <TAB> <TAB> <TAB> kw [ ""order"" ] = op. order <TAB> <TAB> if return_indices : <TAB> <TAB> <TAB> if not return_value : <TAB> <TAB> <TAB> <TAB> ctx [ op. outputs [ 0 ]. key ] = xp. argpartition ( a, kth, axis = op. axis, ** kw ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> argparts = ctx [ op. outputs [ 1 ]. key ] = xp. argpartition ( <TAB> <TAB> <TAB> <TAB> <TAB> a, kth, axis = op. axis, ** kw <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> ctx [ op. outputs [ 0 ]. key ] = xp. take_along_axis ( a, argparts, op. axis ) <TAB> <TAB> else : <TAB> <TAB> <TAB> ctx [ op. outputs [ 0 ]. key ] = xp. partition ( a, kth, axis = op. axis, ** kw )",True,op.kind is not None,op.kind is not None,0.6598044633865356
|
||
|
4191,"def test ( parsed, unknown ) : <TAB> with timer ( ""boot time"" ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> env. NAME = env. TEST <TAB> <TAB> <TAB> logger. level = logging. WARN <TAB> <TAB> import unittest <TAB> <TAB> if parsed. modules : <TAB> <TAB> <TAB> names = parsed. modules. split ( "","" ) <TAB> <TAB> <TAB> print ( ansi. success ( ""RUNNING "" ) + ""Tests in "" + "", "". join ( names ) ) <TAB> <TAB> <TAB> suite = unittest. TestLoader ( ). loadTestsFromNames ( names ) <TAB> <TAB> else : <TAB> <TAB> <TAB> print ( ansi. success ( ""RUNNING "" ) + ""Test Suite"" ) <TAB> <TAB> <TAB> suite = unittest. defaultTestLoader. discover ( env. TESTS_DIR ) <TAB> result = unittest. TextTestRunner ( ). run ( suite ) <TAB> if not result. wasSuccessful ( ) : <TAB> <TAB> sys. exit ( 1 ) <TAB> else : <TAB> <TAB> sys. exit ( 0 )",False,'LORE_ENV' not in os.environ,unknown,0.6504732370376587
|
||
|
4192,"def try_convert ( self, string ) : <TAB> string = string. strip ( ) <TAB> try : <TAB> <TAB> return int ( string ) <TAB> except : <TAB> <TAB> try : <TAB> <TAB> <TAB> return float ( string ) <TAB> <TAB> except : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return True <TAB> <TAB> <TAB> if string == ""False"" : <TAB> <TAB> <TAB> <TAB> return False <TAB> <TAB> <TAB> return string",True,string == 'True',string == 'True',0.6608721613883972
|
||
|
4193,"def list_org_repos ( self, org, type = ""all"" ) : <TAB> headers = { ""Authorization"" : ""token {}"". format ( self. github_creds [ org ] ) } <TAB> params = { ""page"" : 1, ""type"" : type } <TAB> done = False <TAB> repos = [ ] <TAB> while not done : <TAB> <TAB> url = ""https://api.github.com/orgs/{}/repos"". format ( org ) <TAB> <TAB> result = requests. get ( url, headers = headers, params = params ) <TAB> <TAB> if result. status_code!= 200 : <TAB> <TAB> <TAB> raise InvalidResponseCodeFromGitHubError ( org, result. status_code ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> done = True <TAB> <TAB> else : <TAB> <TAB> <TAB> params [ ""page"" ] += 1 <TAB> <TAB> result_json = result. json ( ) <TAB> <TAB> repos += result_json <TAB> return repos",False,not result.links.get('last'),type == 'all',0.6484960913658142
|
||
|
4194,"def test ( self, setting ) : <TAB> self. logger. debug ( ""Testing connection to snzbget"" ) <TAB> rpc = self. get_rpc ( <TAB> <TAB> setting. host, <TAB> <TAB> setting. ssl, <TAB> <TAB> setting. port, <TAB> <TAB> setting. username, <TAB> <TAB> urllib. quote ( setting. password. encode ( ""utf-8"" ) ), <TAB> ) <TAB> try : <TAB> <TAB> if rpc. writelog ( ""INFO"", ""NZB Hydra connected to test connection"" ) : <TAB> <TAB> <TAB> version = rpc. version ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. logger. error ( ""NZBGet needs to be version 13 or higher"" ) <TAB> <TAB> <TAB> <TAB> return False, ""NZBGet needs to be version 13 or higher"" <TAB> <TAB> <TAB> self. logger. info ( ""Connection test to NZBGet successful"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. logger. info ( <TAB> <TAB> <TAB> <TAB> ""Successfully connected to NZBGet, but unable to send a message"" <TAB> <TAB> <TAB> ) <TAB> except socket. error : <TAB> <TAB> self. logger. error ( <TAB> <TAB> <TAB> ""NZBGet is not responding. Please ensure that NZBGet is running and host setting is correct."" <TAB> <TAB> ) <TAB> <TAB> return False, ""NZBGet is not responding under this address, scheme and port"" <TAB> except xmlrpc. client. ProtocolError as e : <TAB> <TAB> if e. errcode == 401 : <TAB> <TAB> <TAB> self. logger. error ( ""Wrong credentials"" ) <TAB> <TAB> <TAB> return False, ""Wrong credentials"" <TAB> <TAB> else : <TAB> <TAB> <TAB> self. logger. error ( ""Protocol error: %s"", e ) <TAB>",False,int(version[:2]) < 13,version > 13,0.6596469879150391
|
||
|
4195,"def __eq__ ( self, target_charges : Union [ np. ndarray, ""BaseCharge"" ] ) -> np. ndarray : <TAB> if isinstance ( target_charges, type ( self ) ) : <TAB> <TAB> if len ( target_charges ) == 0 : <TAB> <TAB> <TAB> raise ValueError ( ""input to __eq__ cannot be an empty charge"" ) <TAB> <TAB> targets = target_charges. charges <TAB> else : <TAB> <TAB> if target_charges. ndim == 1 : <TAB> <TAB> <TAB> target_charges = target_charges [ :, None ] <TAB> <TAB> if target_charges. shape [ 0 ] == 0 : <TAB> <TAB> <TAB> raise ValueError ( ""input to __eq__ cannot be an empty np.ndarray"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""shape of `target_charges = {}` is incompatible with "" <TAB> <TAB> <TAB> <TAB> ""`self.num_symmetries = {}"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> target_charges. shape, self. num_symmetries <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> targets = target_charges <TAB> return np. logical_and. reduce ( <TAB> <TAB> self. charges [ :, :, None ] == targets. T [ None, :, : ], axis = 1 <TAB> )",False,target_charges.shape[1] != self.num_symmetries,self.num_symmetries is None,0.6546242237091064
|
||
|
4196,"def close ( self ) : <TAB> with BrowserContext. _BROWSER_LOCK : <TAB> <TAB> BrowserContext. _BROWSER_REFCNT -= 1 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> logger. info ( ""Destroying browser main loop"" ) <TAB> <TAB> <TAB> BrowserContext. _BROWSER_LOOP. destroy ( ) <TAB> <TAB> <TAB> BrowserContext. _BROWSER_LOOP = None",False,BrowserContext._BROWSER_REFCNT == 0,not self.has_main_loop,0.6577253341674805
|
||
|
4197,"def number_of_layers ( self, ** kwargs ) : <TAB> """"""Returns the deepest nested item in the event"""""" <TAB> num = 1 <TAB> for attr, value in self. event. items ( ) : <TAB> <TAB> value = kwargs. get ( attr, value ) <TAB> <TAB> if isinstance ( value, PGroup ) : <TAB> <TAB> <TAB> l = pattern_depth ( value ) <TAB> <TAB> else : <TAB> <TAB> <TAB> l = 1 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> num = l <TAB> return num",False,l > num,l > 0,0.6682604551315308
|
||
|
4198,"def test_enumerating_directions ( ) : <TAB> for backend in imp_op_backends : <TAB> <TAB> print ( ""testing directions for"", backend. framework_name ) <TAB> <TAB> for shape in [ [ ], [ 1 ], [ 1, 1, 1 ], [ 2, 3, 5, 7 ] ] : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> x = numpy. arange ( numpy. prod ( shape ) ). reshape ( shape ) <TAB> <TAB> <TAB> axes1 = _enumerate_directions ( x ) <TAB> <TAB> <TAB> axes2 = _enumerate_directions ( backend. from_numpy ( x ) ) <TAB> <TAB> <TAB> for axe1, axe2 in zip ( axes1, axes2 ) : <TAB> <TAB> <TAB> <TAB> axe2 = backend. to_numpy ( axe2 ) <TAB> <TAB> <TAB> <TAB> assert axe1. shape == axe2. shape <TAB> <TAB> <TAB> <TAB> assert numpy. allclose ( axe1, axe2 )",False,backend.framework_name == 'mxnet.ndarray' and len(shape) == 0,len(shape) > 0,0.6532028913497925
|
||
|
4199,"def _unpack ( self, fmt, byt ) : <TAB> d = unpack ( self. _header [ ""byteorder"" ] + fmt, byt ) [ 0 ] <TAB> if fmt [ - 1 ] in self. MISSING_VALUES : <TAB> <TAB> nmin, nmax = self. MISSING_VALUES [ fmt [ - 1 ] ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if self. _missing_values : <TAB> <TAB> <TAB> <TAB> return StataMissingValue ( nmax, d ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> return None <TAB> return d",False,d < nmin or d > nmax,self._min_values and nmax,0.6667759418487549
|
||
|
4200,"def login_begin ( request ) : <TAB> redirect_to = request. GET. get ( ""next"", ""/"" ) <TAB> is_first_login_ever = OpenIDBackend. is_first_login_ever ( ) <TAB> request. session. set_test_cookie ( ) <TAB> openid_url = getattr ( settings, ""OPENID_SSO_SERVER_URL"", None ) <TAB> identity_url_prefix = getattr ( settings, ""OPENID_IDENTITY_URL_PREFIX"", None ) <TAB> <TAB> if openid_url is not None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return render_to_response ( <TAB> <TAB> <TAB> <TAB> ""openid-login.html"", <TAB> <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> <TAB> ""action"" : urlresolvers. reverse ( ""openid-login"" ), <TAB> <TAB> <TAB> <TAB> <TAB> ""next"" : redirect_to, <TAB> <TAB> <TAB> <TAB> <TAB> ""first_login_ever"" : is_first_login_ever, <TAB> <TAB> <TAB> <TAB> <TAB> ""hide_field"" : True, <TAB> <TAB> <TAB> <TAB> }, <TAB> <TAB> <TAB> <TAB> context_instance = RequestContext ( request ), <TAB> <TAB> <TAB> ) <TAB> return django_login_begin ( <TAB> <TAB> request, template_name = ""openid-login.html"", form_class = OpenIDLoginFormExt <TAB> )",False,request.method == 'GET',identity_url_prefix is None,0.6539400219917297
|
||
|
4201,"def parse_until_text ( self, watch_nesting, * text ) : <TAB> startpos = self. match_position <TAB> text_re = r""|"". join ( text ) <TAB> brace_level = 0 <TAB> paren_level = 0 <TAB> bracket_level = 0 <TAB> while True : <TAB> <TAB> match = self. match ( r""#.*\n"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> match = self. match ( r""(\""\""\""|\'\'\'|\""|\')[^\\]*?(\\.[^\\]*?)*\1"", re. S ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> match = self. match ( r""(%s)"" % text_re ) <TAB> <TAB> if match and not ( <TAB> <TAB> <TAB> watch_nesting and ( brace_level > 0 or paren_level > 0 or bracket_level > 0 ) <TAB> <TAB> ) : <TAB> <TAB> <TAB> return ( <TAB> <TAB> <TAB> <TAB> self. text [ startpos : self. match_position - len ( match. group ( 1 ) ) ], <TAB> <TAB> <TAB> <TAB> match. group ( 1 ), <TAB> <TAB> <TAB> ) <TAB> <TAB> elif not match : <TAB> <TAB> <TAB> match = self. match ( r""(.*?)(?=\""|\'|#|%s)"" % text_re, re. S ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> brace_level += match. group ( 1 ). count ( ""{"" ) <TAB> <TAB> <TAB> brace_level -= match. group ( 1 ). count ( ""}"" ) <TAB> <TAB> <TAB> paren_level += match. group ( 1 ). count ( ""("" ) <TAB> <TAB> <TAB> paren_level -= match. group ( 1 ). count ( "")"" ) <TAB> <TAB> <TAB> bracket_level += match. group ( 1 ). count ( ""["" ) <TAB> <TAB> <TAB>",True,match,match,0.6749268770217896
|
||
|
4202,"def test_model_save ( dummy_data, make_model, tmp_path ) : <TAB> <TAB> <TAB> data, labels = dummy_data <TAB> model = make_model <TAB> model. compile ( optimizer = ""adam"", loss = ""binary_crossentropy"", metrics = [ ""accuracy"" ] ) <TAB> <TAB> model. fit ( data, labels, epochs = 5, batch_size = 32 ) <TAB> for save_path in [ ""test_model"", ""test_model.h5"" ] : <TAB> <TAB> <TAB> <TAB> save_path = tmp_path / save_path <TAB> <TAB> model. save ( save_path ) <TAB> <TAB> loaded_model = load_model ( save_path ) <TAB> <TAB> <TAB> <TAB> if os. path. isdir ( save_path ) : <TAB> <TAB> <TAB> shutil. rmtree ( save_path ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> os. remove ( save_path ) <TAB> <TAB> <TAB> <TAB> np. testing. assert_equal ( model. predict ( data ), loaded_model. predict ( data ) )",False,os.path.exists(save_path),os.path.isdir(save_path),0.6478309631347656
|
||
|
4203,"def test_204_invalid_content_length ( self ) : <TAB> <TAB> with ExpectLog ( gen_log, "".*Response with code 204 should not have body"" ) : <TAB> <TAB> response = self. fetch ( ""/?error=1"" ) <TAB> <TAB> if not self. http1 : <TAB> <TAB> <TAB> self. skipTest ( ""requires HTTP/1.x"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. skipTest ( ""curl client accepts invalid headers"" ) <TAB> <TAB> self. assertEqual ( response. code, 599 )",False,self.http_client.configured_class != SimpleAsyncHTTPClient,not self.curl_client,0.6534282565116882
|
||
|
4204,"def _get_java_version ( self ) -> Tuple [ int, int ] : <TAB> """"""This assumes we've already checked that java exists."""""" <TAB> _proc : asyncio. subprocess. Process = ( <TAB> <TAB> await asyncio. create_subprocess_exec ( <TAB> <TAB> <TAB> self. _java_exc, <TAB> <TAB> <TAB> ""-version"", <TAB> <TAB> <TAB> stdout = asyncio. subprocess. PIPE, <TAB> <TAB> <TAB> stderr = asyncio. subprocess. PIPE, <TAB> <TAB> ) <TAB> ) <TAB> <TAB> _, err = await _proc. communicate ( ) <TAB> version_info : str = err. decode ( ""utf-8"" ) <TAB> lines = version_info. splitlines ( ) <TAB> for line in lines : <TAB> <TAB> match = _RE_JAVA_VERSION_LINE_PRE223. search ( line ) <TAB> <TAB> if match is None : <TAB> <TAB> <TAB> match = _RE_JAVA_VERSION_LINE_223. search ( line ) <TAB> <TAB> if match is None : <TAB> <TAB> <TAB> continue <TAB> <TAB> major = int ( match [ ""major"" ] ) <TAB> <TAB> minor = 0 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> minor = int ( minor_str ) <TAB> <TAB> return major, minor <TAB> raise RuntimeError ( f""The output of `{self._java_exc} -version` was unexpected."" )",False,"minor_str := match [ ""minor"" ]",minor_str is not None,0.6552532911300659
|
||
|
4205,"def de_dot ( dot_string, msg ) : <TAB> """"""Turn message and dotted string into a nested dictionary"""""" <TAB> arr = dot_string. split ( ""."" ) <TAB> arr. append ( msg ) <TAB> retval = None <TAB> for idx in range ( len ( arr ), 1, - 1 ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> retval = { arr [ idx - 2 ] : arr [ idx - 1 ] } <TAB> <TAB> <TAB> except Exception as err : <TAB> <TAB> <TAB> <TAB> raise LoggingException ( err ) <TAB> <TAB> else : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> new_d = { arr [ idx - 2 ] : retval } <TAB> <TAB> <TAB> <TAB> retval = new_d <TAB> <TAB> <TAB> except Exception as err : <TAB> <TAB> <TAB> <TAB> raise LoggingException ( err ) <TAB> return retval",False,not retval,retval is None,0.6868017911911011
|
||
|
4206,"def _put_nowait ( self, data, *, sender ) : <TAB> if not self. _running : <TAB> <TAB> logger. warning ( ""Pub/Sub listener message after stop: %r, %r"", sender, data ) <TAB> <TAB> return <TAB> self. _queue. put_nowait ( ( sender, data ) ) <TAB> if self. _waiter is not None : <TAB> <TAB> fut, self. _waiter = self. _waiter, None <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> assert fut. cancelled ( ), ( ""Waiting future is in wrong state"", self, fut ) <TAB> <TAB> <TAB> return <TAB> <TAB> fut. set_result ( None )",False,fut.done(),fut is not None,0.6583906412124634
|
||
|
4207,"def __str__ ( self, prefix = """", printElemNumber = 0 ) : <TAB> res = """" <TAB> cnt = 0 <TAB> for e in self. index_value_ : <TAB> <TAB> elm = """" <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> elm = ""(%d)"" % cnt <TAB> <TAB> res += prefix + ( ""index_value%s <\n"" % elm ) <TAB> <TAB> res += e. __str__ ( prefix + "" "", printElemNumber ) <TAB> <TAB> res += prefix + "">\n"" <TAB> <TAB> cnt += 1 <TAB> if self. has_key_ : <TAB> <TAB> res += prefix + ""key <\n"" <TAB> <TAB> res += self. key_. __str__ ( prefix + "" "", printElemNumber ) <TAB> <TAB> res += prefix + "">\n"" <TAB> if self. has_before_ : <TAB> <TAB> res += prefix + ( ""before: %s\n"" % self. DebugFormatBool ( self. before_ ) ) <TAB> return res",False,printElemNumber,e.has_index_value,0.6839258670806885
|
||
|
4208,"def get_data ( filters, columns ) : <TAB> data = [ ] <TAB> entry = frappe. get_all ( <TAB> <TAB> ""Work Order"", <TAB> <TAB> fields = [ <TAB> <TAB> <TAB> ""creation"", <TAB> <TAB> <TAB> ""modified"", <TAB> <TAB> <TAB> ""actual_start_date"", <TAB> <TAB> <TAB> ""actual_end_date"", <TAB> <TAB> <TAB> ""planned_start_date"", <TAB> <TAB> <TAB> ""planned_end_date"", <TAB> <TAB> <TAB> ""status"", <TAB> <TAB> ], <TAB> <TAB> filters = { ""docstatus"" : 1, ""company"" : filters [ ""company"" ] }, <TAB> ) <TAB> periodic_data = get_periodic_data ( filters, entry ) <TAB> labels = [ ""All Work Orders"", ""Not Started"", ""Overdue"", ""Pending"", ""Completed"" ] <TAB> chart_data = get_chart_data ( periodic_data, columns ) <TAB> ranges = get_period_date_ranges ( filters ) <TAB> for label in labels : <TAB> <TAB> work = { } <TAB> <TAB> work [ ""Status"" ] = label <TAB> <TAB> for dummy, end_date in ranges : <TAB> <TAB> <TAB> period = get_period ( end_date, filters ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> work [ scrub ( period ) ] = periodic_data. get ( label ). get ( period ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> work [ scrub ( period ) ] = 0.0 <TAB> <TAB> data. append ( work ) <TAB> return data, chart_data",False,periodic_data.get(label).get(period),period is not None,0.6482834815979004
|
||
|
4209,"def inner_connection_checker ( self, * args, ** kwargs ) : <TAB> LOG. debug ( ""in _connection_checker"" ) <TAB> for attempts in range ( 5 ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> return func ( self, * args, ** kwargs ) <TAB> <TAB> except exception. VolumeBackendAPIException as e : <TAB> <TAB> <TAB> pattern = re. compile ( r"".*Session id expired$"" ) <TAB> <TAB> <TAB> matches = pattern. match ( six. text_type ( e ) ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> if attempts < 4 : <TAB> <TAB> <TAB> <TAB> <TAB> LOG. debug ( ""Session might have expired."" "" Trying to relogin"" ) <TAB> <TAB> <TAB> <TAB> <TAB> self. _login ( ) <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> LOG. error ( ""Re-throwing Exception %s"", e ) <TAB> <TAB> <TAB> raise",True,matches,matches,0.6898159980773926
|
||
|
4210,"def record_expected_exportable_production ( self, ticks ) : <TAB> """"""Record the amount of production that should be transferred to other islands."""""" <TAB> for ( quota_holder, resource_id ), amount in self. _low_priority_requests. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _settlement_manager_id [ quota_holder ] = WorldObject. get_object_by_id ( <TAB> <TAB> <TAB> <TAB> int ( quota_holder [ 1 : ]. split ( "","" ) [ 0 ] ) <TAB> <TAB> <TAB> ). settlement_manager. worldid <TAB> <TAB> self. trade_storage [ self. _settlement_manager_id [ quota_holder ] ] [ resource_id ] += ( <TAB> <TAB> <TAB> ticks * amount <TAB> <TAB> )",True,quota_holder not in self._settlement_manager_id,quota_holder not in self._settlement_manager_id,0.65946364402771
|
||
|
4211,"def display_top ( snapshot, key_type = ""lineno"", limit = 3 ) : <TAB> snapshot = snapshot. filter_traces ( <TAB> <TAB> ( <TAB> <TAB> <TAB> tracemalloc. Filter ( False, ""<frozen importlib._bootstrap>"" ), <TAB> <TAB> <TAB> tracemalloc. Filter ( False, ""<unknown>"" ), <TAB> <TAB> ) <TAB> ) <TAB> top_stats = snapshot. statistics ( key_type ) <TAB> print ( ""Top %s lines"" % limit ) <TAB> for index, stat in enumerate ( top_stats [ : limit ], 1 ) : <TAB> <TAB> frame = stat. traceback [ 0 ] <TAB> <TAB> <TAB> <TAB> filename = os. sep. join ( frame. filename. split ( os. sep ) [ - 4 : ] ) <TAB> <TAB> print ( <TAB> <TAB> <TAB> ""#%s: %s:%s: %.1f KiB"" % ( index, filename, frame. lineno, stat. size / 1024 ) <TAB> <TAB> ) <TAB> <TAB> line = linecache. getline ( frame. filename, frame. lineno ). strip ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> print ( "" %s"" % line ) <TAB> other = top_stats [ limit : ] <TAB> if other : <TAB> <TAB> size = sum ( stat. size for stat in other ) <TAB> <TAB> print ( ""%s other: %.1f KiB"" % ( len ( other ), size / 1024 ) ) <TAB> total = sum ( stat. size for stat in top_stats ) <TAB> print ( ""Total allocated size: %.1f KiB"" % ( total / 1024 ) )",True,line,line,0.675983190536499
|
||
|
4212,"def check_region ( self, region ) : <TAB> for other in self. regions : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> if ( other. start < region. start < other. end ) or ( <TAB> <TAB> <TAB> other. start < region. end < other. end <TAB> <TAB> ) : <TAB> <TAB> <TAB> raise Exception ( ""%r overlaps with %r"" % ( region, other ) )",False,other is region,not other,0.6608564853668213
|
||
|
4213,"def _get_node_type_specific_fields ( self, node_id : str, fields_key : str ) -> Any : <TAB> fields = self. config [ fields_key ] <TAB> node_tags = self. provider. node_tags ( node_id ) <TAB> if TAG_RAY_USER_NODE_TYPE in node_tags : <TAB> <TAB> node_type = node_tags [ TAG_RAY_USER_NODE_TYPE ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( f""Unknown node type tag: {node_type}."" ) <TAB> <TAB> node_specific_config = self. available_node_types [ node_type ] <TAB> <TAB> if fields_key in node_specific_config : <TAB> <TAB> <TAB> fields = node_specific_config [ fields_key ] <TAB> return fields",True,node_type not in self.available_node_types,node_type not in self.available_node_types,0.6543549299240112
|
||
|
4214,"def link ( self, label, nodename ) : <TAB> if nodename : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> addr = ""../dir.html"" <TAB> <TAB> else : <TAB> <TAB> <TAB> addr = makefile ( nodename ) <TAB> <TAB> self. write ( <TAB> <TAB> <TAB> label, ': <A HREF=""', addr, '"" TYPE=""', label, '"">', nodename, ""</A> \n"" <TAB> <TAB> )",False,nodename.lower() == '(dir)',label == 'directory',0.663213849067688
|
||
|
4215,"def attribute_table ( self, attribute ) : <TAB> """"""Return a tuple (schema, table) for attribute."""""" <TAB> dimension = attribute. dimension <TAB> if dimension : <TAB> <TAB> schema = self. naming. dimension_schema or self. naming. schema <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> table = self. fact_name <TAB> <TAB> else : <TAB> <TAB> <TAB> table = self. naming. dimension_table_name ( dimension ) <TAB> else : <TAB> <TAB> table = self. fact_name <TAB> <TAB> schema = self. naming. schema <TAB> return ( schema, table )",False,dimension.is_flat and (not dimension.has_details),dimension,0.6497431993484497
|
||
|
4216,"def _expand_ports ( self, ports_list ) : <TAB> ports = [ ] <TAB> for i in ports_list. split ( "","" ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> ports. append ( int ( i ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> l, h = map ( int, i. split ( ""-"" ) ) <TAB> <TAB> <TAB> ports += range ( l, h + 1 ) <TAB> return ports",False,'-' not in i,i.isdigit(),0.6792011260986328
|
||
|
4217,"def optimize ( self, graph : Graph ) : <TAB> MAX_TEXTURE_SIZE = config. WEBGL_MAX_TEXTURE_SIZE <TAB> flag_changed = False <TAB> for v in traverse. listup_variables ( graph ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> height, width = TextureShape. get ( v ) <TAB> <TAB> if height <= MAX_TEXTURE_SIZE and width <= MAX_TEXTURE_SIZE : <TAB> <TAB> <TAB> continue <TAB> <TAB> if not v. has_attribute ( SplitTarget ) : <TAB> <TAB> <TAB> flag_changed = True <TAB> <TAB> <TAB> v. attributes. add ( SplitTarget ( ) ) <TAB> return graph, flag_changed",False,not Placeholder.check_resolved(v.size),not v.has_attribute(TextureShape),0.6563107967376709
|
||
|
4218,"def _check_ordering_item ( self, obj, model, field_name, label ) : <TAB> """"""Check that `ordering` refers to existing fields."""""" <TAB> if field_name == ""?"" and len ( obj. ordering )!= 1 : <TAB> <TAB> return [ <TAB> <TAB> <TAB> checks. Error ( <TAB> <TAB> <TAB> <TAB> ""The value of 'ordering' has the random ordering marker '?', "" <TAB> <TAB> <TAB> <TAB> ""but contains other fields as well."", <TAB> <TAB> <TAB> <TAB> hint = 'Either remove the ""?"", or remove the other fields.', <TAB> <TAB> <TAB> <TAB> obj = obj. __class__, <TAB> <TAB> <TAB> <TAB> id = ""admin.E032"", <TAB> <TAB> <TAB> ) <TAB> <TAB> ] <TAB> elif field_name == ""?"" : <TAB> <TAB> return [ ] <TAB> elif LOOKUP_SEP in field_name : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return [ ] <TAB> else : <TAB> <TAB> if field_name. startswith ( ""-"" ) : <TAB> <TAB> <TAB> field_name = field_name [ 1 : ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return [ ] <TAB> <TAB> try : <TAB> <TAB> <TAB> model. _meta. get_field ( field_name ) <TAB> <TAB> except FieldDoesNotExist : <TAB> <TAB> <TAB> return refer_to_missing_field ( <TAB> <TAB> <TAB> <TAB> field = field_name, option = label, model = model, obj = obj, id = ""admin.E033"" <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return [ ]",False,field_name == 'pk',field_name in model._meta.get_fields,0.6591110229492188
|
||
|
4219,"def tostr ( object, encoding = None ) : <TAB> """"""get a unicode safe string representation of an object"""""" <TAB> if isinstance ( object, basestring ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return object <TAB> <TAB> else : <TAB> <TAB> <TAB> return object. encode ( encoding ) <TAB> if isinstance ( object, tuple ) : <TAB> <TAB> s = [ ""("" ] <TAB> <TAB> for item in object : <TAB> <TAB> <TAB> if isinstance ( item, basestring ) : <TAB> <TAB> <TAB> <TAB> s. append ( item ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> s. append ( tostr ( item ) ) <TAB> <TAB> <TAB> s. append ( "", "" ) <TAB> <TAB> s. append ( "")"" ) <TAB> <TAB> return """". join ( s ) <TAB> if isinstance ( object, list ) : <TAB> <TAB> s = [ ""["" ] <TAB> <TAB> for item in object : <TAB> <TAB> <TAB> if isinstance ( item, basestring ) : <TAB> <TAB> <TAB> <TAB> s. append ( item ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> s. append ( tostr ( item ) ) <TAB> <TAB> <TAB> s. append ( "", "" ) <TAB> <TAB> s. append ( ""]"" ) <TAB> <TAB> return """". join ( s ) <TAB> if isinstance ( object, dict ) : <TAB> <TAB> s = [ ""{"" ] <TAB> <TAB> for item in object. items ( ) : <TAB> <TAB> <TAB> if isinstance ( item [ 0 ], basestring ) : <TAB> <TAB> <TAB> <TAB> s. append ( item [ 0 ] ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> s. append ( tostr ( item [ 0 ] ) ) <TAB> <TAB> <TAB> s. append ( "" = "" ) <TAB> <TAB> <TAB> if isinstance ( item [ 1",True,encoding is None,encoding is None,0.6722312569618225
|
||
|
4220,"def get_release_milestone ( build_type, platform ) : <TAB> """"""Return milestone for a particular release."""""" <TAB> if build_type == ""head"" : <TAB> <TAB> actual_build_type = ""canary"" <TAB> else : <TAB> <TAB> actual_build_type = build_type <TAB> builds_metadata = get_production_builds_info ( platform ) <TAB> for build_metadata in builds_metadata : <TAB> <TAB> if build_metadata. build_type == actual_build_type : <TAB> <TAB> <TAB> version_parts = build_metadata. version. split ( ""."" ) <TAB> <TAB> <TAB> milestone = version_parts [ 0 ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return int ( milestone ) <TAB> if actual_build_type == ""canary"" : <TAB> <TAB> <TAB> <TAB> return get_release_milestone ( ""canary"", ""win"" ) <TAB> return None",False,milestone and milestone.isdigit(),milestone,0.6652882099151611
|
||
|
4221,"def _size ( self, filepath ) : <TAB> files_count = 0 <TAB> files_size = 0 <TAB> if not path. isdir ( filepath ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> filestat = stat ( filepath ) <TAB> <TAB> else : <TAB> <TAB> <TAB> filestat = lstat ( filepath ) <TAB> <TAB> yield { <TAB> <TAB> <TAB> F_TYPE : T_SIZE, <TAB> <TAB> <TAB> F_PATH : filepath, <TAB> <TAB> <TAB> F_FILES : 1, <TAB> <TAB> <TAB> F_SIZE : filestat. st_size, <TAB> <TAB> } <TAB> <TAB> return <TAB> for root, dirs, files, syms, hards, specials in self. _walk_scandir ( filepath ) : <TAB> <TAB> for f in files : <TAB> <TAB> <TAB> files_count += 1 <TAB> <TAB> <TAB> files_size += f. stat ( ). st_size <TAB> <TAB> <TAB> if self. _terminate. is_set ( ) : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> if self. _terminate. is_set ( ) : <TAB> <TAB> <TAB> break <TAB> yield { <TAB> <TAB> F_TYPE : T_SIZE, <TAB> <TAB> F_PATH : filepath, <TAB> <TAB> F_FILES : files_count, <TAB> <TAB> F_SIZE : files_size, <TAB> }",False,self.follow_symlinks,self.is_dir(filepath),0.6563965082168579
|
||
|
4222,"def filter_tests_by_tags ( suite, tags, exclude_tags ) : <TAB> suite_class = type ( suite ) <TAB> filtered_suite = suite_class ( ) <TAB> for test in suite : <TAB> <TAB> if isinstance ( test, suite_class ) : <TAB> <TAB> <TAB> filtered_suite. addTests ( filter_tests_by_tags ( test, tags, exclude_tags ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> test_tags = set ( getattr ( test, ""tags"", set ( ) ) ) <TAB> <TAB> <TAB> test_fn_name = getattr ( test, ""_testMethodName"", str ( test ) ) <TAB> <TAB> <TAB> test_fn = getattr ( test, test_fn_name, test ) <TAB> <TAB> <TAB> test_fn_tags = set ( getattr ( test_fn, ""tags"", set ( ) ) ) <TAB> <TAB> <TAB> all_tags = test_tags. union ( test_fn_tags ) <TAB> <TAB> <TAB> matched_tags = all_tags. intersection ( tags ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> filtered_suite. addTest ( test ) <TAB> return filtered_suite",False,matched_tags or not tags) and (not all_tags.intersection(exclude_tags),matched_tags,0.6453063488006592
|
||
|
4223,"def main ( argv ) : <TAB> ( opts, argv ) = CreateOptionsParser ( ). parse_args ( argv [ 1 : ] ) <TAB> try : <TAB> <TAB> csv_path = argv [ 0 ] <TAB> except IndexError : <TAB> <TAB> raise RuntimeError ( ""Expected CSV filename."" ) <TAB> schema = None <TAB> if opts. schema : <TAB> <TAB> try : <TAB> <TAB> <TAB> schema_f = open ( opts. schema ) <TAB> <TAB> except IOError as e : <TAB> <TAB> <TAB> raise RuntimeError ( ""Error opening schema: %s"" % e ) <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> schema_path = csv_path. replace ( "".csv"", "".schema.csv"" ) <TAB> <TAB> elif csv_path. endswith ( "".tsv"" ) : <TAB> <TAB> <TAB> schema_path = csv_path. replace ( "".tsv"", "".schema.tsv"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise AssertionError ( csv_path ) <TAB> <TAB> log ( ""schema path %s"", schema_path ) <TAB> <TAB> try : <TAB> <TAB> <TAB> schema_f = open ( schema_path ) <TAB> <TAB> except IOError : <TAB> <TAB> <TAB> schema_f = None <TAB> if schema_f : <TAB> <TAB> if opts. tsv : <TAB> <TAB> <TAB> r = csv. reader ( <TAB> <TAB> <TAB> <TAB> schema_f, delimiter = ""\t"", doublequote = False, quoting = csv. QUOTE_NONE <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> r = csv. reader ( schema_f ) <TAB> <TAB> schema = Schema ( list ( r ) ) <TAB> else : <TAB> <TAB> schema = NullSchema ( ) <TAB> <TAB> <TAB> log ( ""schema %s"", schema ) <TAB> with open ( csv_path ) as f : <TAB> <TAB> col_names, rows =",False,csv_path.endswith('.csv'),"csv_path.endswith("".csv)",0.6489740610122681
|
||
|
4224,"def run ( self, execution_id ) : <TAB> execution = self. _get_execution ( execution_id ) <TAB> context = { ""six"" : six, ""execution"" : execution } <TAB> template = self. default_template <TAB> result = { ""enabled"" : True } <TAB> alias_id = execution [ ""context"" ]. get ( ""action_alias_ref"", { } ). get ( ""id"", None ) <TAB> if alias_id : <TAB> <TAB> alias = self. client. managers [ ""ActionAlias"" ]. get_by_id ( alias_id ) <TAB> <TAB> context. update ( { ""alias"" : alias } ) <TAB> <TAB> result_params = getattr ( alias, ""result"", None ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if not result_params. get ( ""enabled"", True ) : <TAB> <TAB> <TAB> <TAB> result [ ""enabled"" ] = False <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> if ""format"" in alias. result : <TAB> <TAB> <TAB> <TAB> <TAB> template = alias. result [ ""format"" ] <TAB> <TAB> <TAB> <TAB> if ""extra"" in alias. result : <TAB> <TAB> <TAB> <TAB> <TAB> result [ ""extra"" ] = jinja_utils. render_values ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> alias. result [ ""extra"" ], context <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> result [ ""message"" ] = self. jinja. from_string ( template ). render ( context ) <TAB> return result",False,result_params,alias and result_params,0.6667323112487793
|
||
|
4225,"def find_region_by_value ( key, value ) : <TAB> for region in cognitoidp_backends : <TAB> <TAB> backend = cognitoidp_backends [ region ] <TAB> <TAB> for user_pool in backend. user_pools. values ( ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return region <TAB> <TAB> <TAB> if key == ""access_token"" and value in user_pool. access_tokens : <TAB> <TAB> <TAB> <TAB> return region <TAB> <TAB> <TAB> <TAB> return list ( cognitoidp_backends ) [ 0 ]",False,key == 'client_id' and value in user_pool.clients,key == 'token' and value in user_pool.token,0.6503800749778748
|
||
|
4226,"def load ( self, file_obj, header = True, ** kwargs ) : <TAB> count = 0 <TAB> reader = csv. reader ( file_obj, ** kwargs ) <TAB> if header : <TAB> <TAB> try : <TAB> <TAB> <TAB> header_keys = next ( reader ) <TAB> <TAB> except StopIteration : <TAB> <TAB> <TAB> return count <TAB> <TAB> if self. strict : <TAB> <TAB> <TAB> header_fields = [ ] <TAB> <TAB> <TAB> for idx, key in enumerate ( header_keys ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> header_fields. append ( ( idx, self. columns [ key ] ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> header_fields = list ( enumerate ( header_keys ) ) <TAB> else : <TAB> <TAB> header_fields = list ( enumerate ( self. model. _meta. sorted_fields ) ) <TAB> if not header_fields : <TAB> <TAB> return count <TAB> for row in reader : <TAB> <TAB> obj = { } <TAB> <TAB> for idx, field in header_fields : <TAB> <TAB> <TAB> if self. strict : <TAB> <TAB> <TAB> <TAB> obj [ field. name ] = field. python_value ( row [ idx ] ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> obj [ field ] = row [ idx ] <TAB> <TAB> self. table. insert ( ** obj ) <TAB> <TAB> count += 1 <TAB> return count",True,key in self.columns,key in self.columns,0.6647553443908691
|
||
|
4227,"def create_datetime_column ( spec, column_options ) : <TAB> if spec. startswith ( ""DateTime64"" ) : <TAB> <TAB> cls = DateTime64Column <TAB> <TAB> spec = spec [ 11 : - 1 ] <TAB> <TAB> params = spec. split ( "","", 1 ) <TAB> <TAB> column_options [ ""scale"" ] = int ( params [ 0 ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> spec = params [ 1 ]. strip ( ) + "")"" <TAB> else : <TAB> <TAB> cls = DateTimeColumn <TAB> <TAB> spec = spec [ 9 : ] <TAB> context = column_options [ ""context"" ] <TAB> tz_name = timezone = None <TAB> offset_naive = True <TAB> <TAB> if spec and spec [ - 1 ] == "")"" : <TAB> <TAB> tz_name = spec [ 1 : - 2 ] <TAB> <TAB> offset_naive = False <TAB> else : <TAB> <TAB> if not context. settings. get ( ""use_client_time_zone"", False ) : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> local_timezone = get_localzone ( ). zone <TAB> <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> <TAB> local_timezone = None <TAB> <TAB> <TAB> if local_timezone!= context. server_info. timezone : <TAB> <TAB> <TAB> <TAB> tz_name = context. server_info. timezone <TAB> if tz_name : <TAB> <TAB> timezone = get_timezone ( tz_name ) <TAB> return cls ( timezone = timezone, offset_naive = offset_naive, ** column_options )",False,len(params) > 1,params[0] != 'undefined',0.6589964628219604
|
||
|
4228,"def shutdown ( self, timeout, callback = None ) : <TAB> logger. debug ( ""background worker got shutdown request"" ) <TAB> with self. _lock : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _queue. put_nowait ( _TERMINATOR ) <TAB> <TAB> <TAB> if timeout > 0.0 : <TAB> <TAB> <TAB> <TAB> self. _wait_shutdown ( timeout, callback ) <TAB> <TAB> self. _thread = None <TAB> <TAB> self. _thread_for_pid = None <TAB> logger. debug ( ""background worker shut down"" )",False,self.is_alive,self._queue.empty(),0.658618688583374
|
||
|
4229,"def get ( self, * args, ** kwargs ) : <TAB> name = self. get_argument ( ""name"" ) <TAB> url = self. get_argument ( ""url"" ) <TAB> cookies = self. get_argument ( ""cookies"" ) <TAB> title_tag = self. get_argument ( ""titleTAG"" ) <TAB> providerObj = TorrentRssProvider ( name, url, cookies, title_tag ) <TAB> if providerObj. id not in sickrage. app. search_providers. torrentrss ( ) : <TAB> <TAB> validate = providerObj. validateRSS ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return self. write ( json_encode ( { ""success"" : providerObj. id } ) ) <TAB> <TAB> return self. write ( json_encode ( { ""error"" : validate [ ""message"" ] } ) ) <TAB> return self. write ( <TAB> <TAB> json_encode ( { ""error"" : ""Provider name already exists as {}"". format ( name ) } ) <TAB> )",False,validate['result'],validate[0] != 0,0.6574536561965942
|
||
|
4230,"def forward ( self, * x ) : <TAB> encoded_tensors = [ ] <TAB> if len ( x ) > 1 : <TAB> <TAB> assert len ( x ) == self. num_columns <TAB> <TAB> for i in range ( self. num_columns ) : <TAB> <TAB> <TAB> input = x [ i ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> input = input. long ( ) <TAB> <TAB> <TAB> encoded_tensors. append ( torch. eq ( input, self. condition_tensors [ i ] ) ) <TAB> else : <TAB> <TAB> <TAB> <TAB> x = x [ 0 ] <TAB> <TAB> if x. dtype!= torch. int64 : <TAB> <TAB> <TAB> x = x. long ( ) <TAB> <TAB> for i in range ( self. num_columns ) : <TAB> <TAB> <TAB> encoded_tensors. append ( torch. eq ( x [ :, i : i + 1 ], self. condition_tensors [ i ] ) ) <TAB> return torch. cat ( encoded_tensors, dim = 1 ). float ( )",False,input.dtype != torch.int64,x.dtype != torch.dtype.float64,0.655195415019989
|
||
|
4231,"def send ( self, request, ** kwargs ) : <TAB> if MockTransport. ENABLE : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if request. method!= ""PUT"" : <TAB> <TAB> <TAB> <TAB> assert ""-secondary"" in request. url <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> request. url = request. url. replace ( ""-secondary"", """" ) <TAB> response = super ( MockTransport, self ). send ( request, ** kwargs ) <TAB> if MockTransport. ENABLE : <TAB> <TAB> assert response. status_code in [ 200, 201, 409 ] <TAB> <TAB> if MockTransport. CALL_NUMBER == 1 : <TAB> <TAB> <TAB> response. status_code = 408 <TAB> <TAB> el if<mask> : <TAB> <TAB> <TAB> if response. status_code == 409 : <TAB> <TAB> <TAB> <TAB> response. status_code = 201 <TAB> <TAB> else : <TAB> <TAB> <TAB> pytest. fail ( ""This test is not supposed to do more calls"" ) <TAB> <TAB> MockTransport. CALL_NUMBER += 1 <TAB> return response",False,MockTransport.CALL_NUMBER == 2,request.method == 'POST',0.6637427806854248
|
||
|
4232,"def url ( regex, view, kwargs = None, name = None, prefix = """" ) : <TAB> if isinstance ( view, ( list, tuple ) ) : <TAB> <TAB> <TAB> <TAB> urlconf_module, app_name, namespace = view <TAB> <TAB> return RegexURLResolver ( <TAB> <TAB> <TAB> regex, urlconf_module, kwargs, app_name = app_name, namespace = namespace <TAB> <TAB> ) <TAB> else : <TAB> <TAB> if isinstance ( view, basestring ) : <TAB> <TAB> <TAB> if not view : <TAB> <TAB> <TAB> <TAB> raise ImproperlyConfigured ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Empty URL pattern view name not permitted (for pattern %r)"" % regex <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> view = prefix + ""."" + view <TAB> <TAB> return RegexURLPattern ( regex, view, kwargs, name )",True,prefix,prefix,0.6858685612678528
|
||
|
4233,"def isReadOnly ( self, fileName ) : <TAB> <TAB> if g. os_path_exists ( fileName ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> g. error ( ""can not write: read only:"", fileName ) <TAB> <TAB> <TAB> <TAB> return True <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> pass <TAB> return False",False,"not os.access(fileName, os.W_OK)",not self.hasRead(fileName),0.6540493965148926
|
||
|
4234,"def assert_readback ( vehicle, values ) : <TAB> i = 10 <TAB> while i > 0 : <TAB> <TAB> time. sleep ( 0.1 ) <TAB> <TAB> i -= 0.1 <TAB> <TAB> for k, v in values. items ( ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> break <TAB> if i <= 0 : <TAB> <TAB> raise Exception ( ""Did not match in channels readback %s"" % values )",False,vehicle.channels[k] != v,v.tag == k,0.6581739783287048
|
||
|
4235,"def on_evaluate ( self, args, state, control, metrics = None, ** kwargs ) : <TAB> if self. training_tracker is not None : <TAB> <TAB> values = { ""Training Loss"" : ""No log"" } <TAB> <TAB> for log in reversed ( state. log_history ) : <TAB> <TAB> <TAB> if ""loss"" in log : <TAB> <TAB> <TAB> <TAB> values [ ""Training Loss"" ] = log [ ""loss"" ] <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> values [ ""Epoch"" ] = int ( state. epoch ) <TAB> <TAB> else : <TAB> <TAB> <TAB> values [ ""Step"" ] = state. global_step <TAB> <TAB> values [ ""Validation Loss"" ] = metrics [ ""eval_loss"" ] <TAB> <TAB> _ = metrics. pop ( ""total_flos"", None ) <TAB> <TAB> _ = metrics. pop ( ""epoch"", None ) <TAB> <TAB> for k, v in metrics. items ( ) : <TAB> <TAB> <TAB> if k == ""eval_loss"" : <TAB> <TAB> <TAB> <TAB> values [ ""Validation Loss"" ] = v <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> splits = k. split ( ""_"" ) <TAB> <TAB> <TAB> <TAB> name = "" "". join ( [ part. capitalize ( ) for part in splits [ 1 : ] ] ) <TAB> <TAB> <TAB> <TAB> values [ name ] = v <TAB> <TAB> self. training_tracker. write_line ( values ) <TAB> <TAB> self. training_tracker. remove_child ( ) <TAB> <TAB> self. prediction_bar = None <TAB> <TAB> <TAB> <TAB> self. _force_next_update = True",False,self.first_column == 'Epoch',metrics is None,0.6502366065979004
|
||
|
4236,"def sendState ( self, position, paused, doSeek, latencyCalculation, stateChange = False ) : <TAB> state = { } <TAB> positionAndPausedIsSet = position is not None and paused is not None <TAB> clientIgnoreIsNotSet = ( <TAB> <TAB> self. clientIgnoringOnTheFly == 0 or self. serverIgnoringOnTheFly!= 0 <TAB> ) <TAB> if clientIgnoreIsNotSet and positionAndPausedIsSet : <TAB> <TAB> state [ ""playstate"" ] = { } <TAB> <TAB> state [ ""playstate"" ] [ ""position"" ] = position <TAB> <TAB> state [ ""playstate"" ] [ ""paused"" ] = paused <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> state [ ""playstate"" ] [ ""doSeek"" ] = doSeek <TAB> state [ ""ping"" ] = { } <TAB> if latencyCalculation : <TAB> <TAB> state [ ""ping"" ] [ ""latencyCalculation"" ] = latencyCalculation <TAB> state [ ""ping"" ] [ ""clientLatencyCalculation"" ] = self. _pingService. newTimestamp ( ) <TAB> state [ ""ping"" ] [ ""clientRtt"" ] = self. _pingService. getRtt ( ) <TAB> if stateChange : <TAB> <TAB> self. clientIgnoringOnTheFly += 1 <TAB> if self. serverIgnoringOnTheFly or self. clientIgnoringOnTheFly : <TAB> <TAB> state [ ""ignoringOnTheFly"" ] = { } <TAB> <TAB> if self. serverIgnoringOnTheFly : <TAB> <TAB> <TAB> state [ ""ignoringOnTheFly"" ] [ ""server"" ] = self. serverIgnoringOnTheFly <TAB> <TAB> <TAB> self. serverIgnoringOnTheFly = 0 <TAB> <TAB> if self. clientIgnoringOnTheFly : <TAB> <TAB> <TAB> state [ ""ignoringOnTheFly"" ] [ ""client"" ] = self. clientIgnoringOnTheFly <TAB> self. sendMessage ( { ""State"" : state } )",True,doSeek,doSeek,0.7035470604896545
|
||
|
4237,"def _build_episode ( x ) : <TAB> """"""Create a Movie object for a given series' episode."""""" <TAB> episode_id = analyze_imdbid ( x. get ( ""link"" ) ) <TAB> episode_title = x. get ( ""title"" ) <TAB> e = Movie ( movieID = episode_id, title = episode_title ) <TAB> e [ ""kind"" ] = u""episode"" <TAB> oad = x. get ( ""oad"" ) <TAB> if oad : <TAB> <TAB> e [ ""original air date"" ] = oad. strip ( ) <TAB> year = x. get ( ""year"" ) <TAB> if year is not None : <TAB> <TAB> year = year [ 5 : ] <TAB> <TAB> if year == ""unknown"" : <TAB> <TAB> <TAB> year = u""????"" <TAB> <TAB> if year and year. isdigit ( ) : <TAB> <TAB> <TAB> year = int ( year ) <TAB> <TAB> e [ ""year"" ] = year <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> e [ ""year"" ] = int ( oad [ - 4 : ] ) <TAB> epinfo = x. get ( ""episode"" ) <TAB> if epinfo is not None : <TAB> <TAB> season, episode = epinfo. split ( "":"" ) [ 0 ]. split ( "","" ) <TAB> <TAB> e [ ""season"" ] = int ( season [ 7 : ] ) <TAB> <TAB> e [ ""episode"" ] = int ( episode [ 8 : ] ) <TAB> else : <TAB> <TAB> e [ ""season"" ] = ""unknown"" <TAB> <TAB> e [ ""episode"" ] = ""unknown"" <TAB> plot = x. get ( ""plot"" ) <TAB> if plot : <TAB> <TAB> e [ ""plot"" ] = plot. strip ( ) <TAB> return e",False,oad and oad[-4:].isdigit(),oad.startswith('j'),0.6599984169006348
|
||
|
4238,"def get_config_updates_recursive ( self ) : <TAB> config_updates = self. config_updates. copy ( ) <TAB> for sr_path, subrunner in self. subrunners. items ( ) : <TAB> <TAB> if not is_prefix ( self. path, sr_path ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> update = subrunner. get_config_updates_recursive ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> config_updates [ rel_path ( self. path, sr_path ) ] = update <TAB> return config_updates",True,update,update,0.6933262348175049
|
||
|
4239,"def _add_horizontal_html_lines ( self, lines, headers, max_depth ) : <TAB> esc = self. get_cell_html <TAB> new_depth = max_depth - 1 if max_depth > 1 else max_depth <TAB> if max_depth > 1 : <TAB> <TAB> new_depth = max_depth - 1 <TAB> if headers : <TAB> <TAB> _thth = self. _html_th_close + self. _html_th <TAB> <TAB> lines. append ( self. _html_thead ) <TAB> <TAB> lines. append ( <TAB> <TAB> <TAB> self. _html_tr <TAB> <TAB> <TAB> + self. _html_th <TAB> <TAB> <TAB> + _thth. join ( [ esc ( h ) for h in headers ] ) <TAB> <TAB> <TAB> + self. _html_th_close <TAB> <TAB> <TAB> + self. _html_tr_close <TAB> <TAB> ) <TAB> <TAB> lines. append ( self. _html_thead_close ) <TAB> trtd, _tdtd, _td_tr = ( <TAB> <TAB> self. _html_tr + self. _html_td, <TAB> <TAB> self. _html_td_close + self. _html_td, <TAB> <TAB> self. _html_td_close + self. _html_tr_close, <TAB> ) <TAB> lines. append ( self. _html_tbody ) <TAB> for row in self. _data : <TAB> <TAB> if max_depth > 1 : <TAB> <TAB> <TAB> _fill_parts = [ ] <TAB> <TAB> <TAB> for cell in row : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> _fill_parts. append ( cell. to_html ( max_depth = new_depth ) ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> _fill_parts. append ( esc ( cell ) ) <TAB> <TAB",False,"isinstance(cell, Table)",new_depth > 0,0.6504001617431641
|
||
|
4240,"def train ( self, data_loaders, ** kwargs ) : <TAB> self. model. train ( ) <TAB> self. mode = ""train"" <TAB> self. data_loaders = data_loaders <TAB> self. main_loader = self. data_loaders [ 0 ] <TAB> <TAB> self. data_loader = self. main_loader <TAB> self. aux_loaders = self. data_loaders [ 1 : ] <TAB> self. aux_iters = [ cycle ( loader ) for loader in self. aux_loaders ] <TAB> auxiliary_iter_times = [ 1 ] * len ( self. aux_loaders ) <TAB> use_aux_per_niter = 1 <TAB> if ""train_ratio"" in kwargs : <TAB> <TAB> train_ratio = kwargs. pop ( ""train_ratio"" ) <TAB> <TAB> use_aux_per_niter = train_ratio [ 0 ] <TAB> <TAB> auxiliary_iter_times = train_ratio [ 1 : ] <TAB> self. _max_iters = self. _max_epochs * len ( self. main_loader ) <TAB> self. call_hook ( ""before_train_epoch"" ) <TAB> time. sleep ( 2 ) <TAB> for i, data_batch in enumerate ( self. main_loader ) : <TAB> <TAB> self. _inner_iter = i <TAB> <TAB> self. call_hook ( ""before_train_iter"" ) <TAB> <TAB> self. run_iter ( data_batch, train_mode = True, source = """" ) <TAB> <TAB> self. call_hook ( ""after_train_iter"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _iter += 1 <TAB> <TAB> <TAB> continue <TAB> <TAB> for idx, n_times in enumerate ( auxiliary_iter_times ) : <TAB> <TAB> <TAB> for _ in range ( n_times ) : <TAB> <TAB> <TAB> <TAB> data_batch = next ( self. aux_iters [ idx ] ) <TAB> <TAB> <TAB> <TAB> self. call_hook ( ""before_",False,self._iter % use_aux_per_niter != 0,use_aux_per_niter or use_aux_per_niter,0.6500099301338196
|
||
|
4241,"def test_headerdb_canonical_head_updates_to_longest_chain ( headerdb, genesis_header ) : <TAB> headerdb. persist_header ( genesis_header ) <TAB> chain_a = mk_header_chain ( genesis_header, 7 ) <TAB> chain_b = mk_header_chain ( genesis_header, 5 ) <TAB> chain_c = mk_header_chain ( genesis_header, 9 ) <TAB> <TAB> for idx, header in enumerate ( chain_a, 1 ) : <TAB> <TAB> headerdb. persist_header ( header ) <TAB> <TAB> assert_is_canonical_chain ( headerdb, chain_a [ : idx ] ) <TAB> <TAB> for header in chain_b : <TAB> <TAB> headerdb. persist_header ( header ) <TAB> <TAB> <TAB> <TAB> assert_is_canonical_chain ( headerdb, chain_a ) <TAB> <TAB> for idx, header in enumerate ( chain_c, 1 ) : <TAB> <TAB> headerdb. persist_header ( header ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> assert_is_canonical_chain ( headerdb, chain_a ) <TAB> <TAB> else : <TAB> <TAB> <TAB> assert_is_canonical_chain ( headerdb, chain_c [ : idx ] ) <TAB> assert_is_canonical_chain ( headerdb, chain_c )",False,idx <= 7,idx == 0,0.6705527305603027
|
||
|
4242,"def update_ip_desc ( self ) : <TAB> is_manual, name, ipv4, ipv6, ignore = self. get_config_ip_info ( ) <TAB> label = """" <TAB> if is_manual : <TAB> <TAB> if ipv4 : <TAB> <TAB> <TAB> label += ""IPv4: %s"" % ( ipv4. dhcp and ""DHCP"" or ""Static"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if label : <TAB> <TAB> <TAB> <TAB> label += "", "" <TAB> <TAB> <TAB> label += ""IPv6: "" <TAB> <TAB> <TAB> mode_label = """" <TAB> <TAB> <TAB> if ipv6. autoconf and ipv6. dhcp : <TAB> <TAB> <TAB> <TAB> mode_label += ""Autoconf "" <TAB> <TAB> <TAB> if ipv6. dhcp : <TAB> <TAB> <TAB> <TAB> mode_label += ""DHCP"" <TAB> <TAB> <TAB> if not mode_label : <TAB> <TAB> <TAB> <TAB> mode_label = ""Static"" <TAB> <TAB> <TAB> label += mode_label <TAB> else : <TAB> <TAB> if name : <TAB> <TAB> <TAB> label = ""Copy configuration from '%s'"" % name <TAB> if not label : <TAB> <TAB> label = ""No configuration"" <TAB> self. widget ( ""ip-config-label"" ). set_text ( label )",False,ipv6,ignore,0.6872738599777222
|
||
|
4243,"def delete ( self, waiters ) : <TAB> <TAB> msgs = self. ofctl. get_all_flow ( waiters ) <TAB> for msg in msgs : <TAB> <TAB> for stats in msg. body : <TAB> <TAB> <TAB> vlan_id = VlanRouter. _cookie_to_id ( REST_VLANID, stats. cookie ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. ofctl. delete_flow ( stats ) <TAB> assert len ( self. packet_buffer ) == 0",False,vlan_id == self.vlan_id,vlan_id == self.ofctl.get_vlan_id(),0.6644588708877563
|
||
|
4244,"def get ( self, request ) : <TAB> if self. _serve_only : <TAB> <TAB> suffix = request. urlargs. get ( ""path"", """" ). split ( ""."" ) [ - 1 ] <TAB> <TAB> if suffix not in self. _serve_only : <TAB> <TAB> <TAB> raise self. SkipRoute <TAB> fullpath = self. filesystem_path ( request ) <TAB> if not self. _serve_only : <TAB> <TAB> if os. path. isdir ( fullpath ) and self. _default_file : <TAB> <TAB> <TAB> file = os. path. join ( fullpath, self. _default_file ) <TAB> <TAB> <TAB> if os. path. isfile ( file ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> return request. redirect ( ""%s/"" % request. path ) <TAB> <TAB> <TAB> <TAB> fullpath = file <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if self. _default_suffix : <TAB> <TAB> <TAB> ext = "".%s"" % self. _default_suffix <TAB> <TAB> <TAB> if not fullpath. endswith ( ext ) : <TAB> <TAB> <TAB> <TAB> file = ""%s%s"" % ( fullpath, ext ) <TAB> <TAB> <TAB> <TAB> if os. path. isfile ( file ) : <TAB> <TAB> <TAB> <TAB> <TAB> fullpath = file <TAB> <TAB> if os. path. isdir ( fullpath ) : <TAB> <TAB> <TAB> if self. _show_indexes : <TAB> <TAB> <TAB> <TAB> return self. directory_index ( request, fullpath ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> raise Http404 <TAB> <TAB> try : <TAB> <TAB> return self. serve_file ( request, fullpath ) <TAB> except Http404 : <TAB> <TAB> file404 = self. get_full_path ( ""404.html"" ) <TAB> <TAB> if os. path.",False,not request.path.endswith('/'),self._redirect_redirect,0.6492774486541748
|
||
|
4245,"def del_from_section ( kwargs ) : <TAB> """"""Remove keyword in section"""""" <TAB> section = kwargs. get ( ""section"", """" ) <TAB> if section in ( ""servers"", ""rss"", ""categories"" ) : <TAB> <TAB> keyword = kwargs. get ( ""keyword"" ) <TAB> <TAB> if keyword : <TAB> <TAB> <TAB> item = config. get_config ( section, keyword ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> item. delete ( ) <TAB> <TAB> <TAB> <TAB> del item <TAB> <TAB> <TAB> <TAB> config. save_config ( ) <TAB> <TAB> <TAB> <TAB> if section == ""servers"" : <TAB> <TAB> <TAB> <TAB> <TAB> sabnzbd. Downloader. update_server ( keyword, None ) <TAB> <TAB> return True <TAB> else : <TAB> <TAB> return False",True,item,item,0.697033166885376
|
||
|
4246,"def get_address_tax_category ( <TAB> tax_category = None, billing_address = None, shipping_address = None ) : <TAB> addr_tax_category_from = frappe. db. get_single_value ( <TAB> <TAB> ""Accounts Settings"", ""determine_address_tax_category_from"" <TAB> ) <TAB> if addr_tax_category_from == ""Shipping Address"" : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> tax_category = ( <TAB> <TAB> <TAB> <TAB> frappe. db. get_value ( ""Address"", shipping_address, ""tax_category"" ) <TAB> <TAB> <TAB> <TAB> or tax_category <TAB> <TAB> <TAB> ) <TAB> else : <TAB> <TAB> if billing_address : <TAB> <TAB> <TAB> tax_category = ( <TAB> <TAB> <TAB> <TAB> frappe. db. get_value ( ""Address"", billing_address, ""tax_category"" ) <TAB> <TAB> <TAB> <TAB> or tax_category <TAB> <TAB> <TAB> ) <TAB> return cstr ( tax_category )",True,shipping_address,shipping_address,0.6665627360343933
|
||
|
4247,"def _sync_author_detail ( self, key = ""author"" ) : <TAB> context = self. _get_context ( ) <TAB> detail = context. get ( ""%ss"" % key, [ FeedParserDict ( ) ] ) [ - 1 ] <TAB> if detail : <TAB> <TAB> name = detail. get ( ""name"" ) <TAB> <TAB> email = detail. get ( ""email"" ) <TAB> <TAB> if name and email : <TAB> <TAB> <TAB> context [ key ] = ""%s (%s)"" % ( name, email ) <TAB> <TAB> elif name : <TAB> <TAB> <TAB> context [ key ] = name <TAB> <TAB> elif email : <TAB> <TAB> <TAB> context [ key ] = email <TAB> else : <TAB> <TAB> author, email = context. get ( key ), None <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return <TAB> <TAB> emailmatch = re. search ( <TAB> <TAB> <TAB> r""""""(([a-zA-Z0-9\_\-\.\+]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?))(\?subject=\S+)?"""""", <TAB> <TAB> <TAB> author, <TAB> <TAB> ) <TAB> <TAB> if emailmatch : <TAB> <TAB> <TAB> email = emailmatch. group ( 0 ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> author = author. replace ( email, """" ) <TAB> <TAB> <TAB> author = author. replace ( ""()"", """" ) <TAB> <TAB> <TAB> author = author. replace ( ""<>"", """" ) <TAB> <TAB> <TAB> author = author. replace ( ""<>"", """" ) <TAB> <TAB> <TAB> author = author. strip ( ) <TAB> <TAB> <",False,not author,email,0.670666515827179
|
||
|
4248,"def _make_ext_obj ( self, obj ) : <TAB> ext = self. _get_ext_class ( obj. objname ) ( ) <TAB> for name, val in obj. body : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise Exception ( <TAB> <TAB> <TAB> <TAB> ""Error val should be a list, this is a python-opcua bug"", <TAB> <TAB> <TAB> <TAB> name, <TAB> <TAB> <TAB> <TAB> type ( val ), <TAB> <TAB> <TAB> <TAB> val, <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> for attname, v in val : <TAB> <TAB> <TAB> <TAB> self. _set_attr ( ext, attname, v ) <TAB> return ext",True,"not isinstance(val, list)","not isinstance(val, list)",0.6528000831604004
|
||
|
4249,"def predict ( self, dataloader, return_preds = False ) : <TAB> self. eval ( ) <TAB> gold_dict = defaultdict ( list ) <TAB> prob_dict = defaultdict ( list ) <TAB> for batch_num, ( X_batch_dict, Y_batch_dict ) in enumerate ( dataloader ) : <TAB> <TAB> prob_batch_dict = self. _calculate_probs ( <TAB> <TAB> <TAB> X_batch_dict, dataloader. task_to_label_dict. keys ( ) <TAB> <TAB> ) <TAB> <TAB> for task_name in dataloader. task_to_label_dict. keys ( ) : <TAB> <TAB> <TAB> prob_dict [ task_name ]. extend ( prob_batch_dict [ task_name ] ) <TAB> <TAB> <TAB> gold_dict [ task_name ]. extend ( <TAB> <TAB> <TAB> <TAB> Y_batch_dict [ dataloader. task_to_label_dict [ task_name ] ]. cpu ( ). numpy ( ) <TAB> <TAB> <TAB> ) <TAB> for task_name in gold_dict : <TAB> <TAB> gold_dict [ task_name ] = np. array ( gold_dict [ task_name ] ) <TAB> <TAB> prob_dict [ task_name ] = np. array ( prob_dict [ task_name ] ) <TAB> <TAB> if len ( gold_dict [ task_name ]. shape ) == 1 : <TAB> <TAB> <TAB> active = ( gold_dict [ task_name ]!= 0 ). reshape ( - 1 ) <TAB> <TAB> else : <TAB> <TAB> <TAB> active = np. sum ( gold_dict [ task_name ] == 0, axis = 1 ) > 0 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> gold_dict [ task_name ] = gold_dict [ task_name ] [ active ] <TAB> <TAB> <TAB> prob_dict [ task_name ] = prob_dict [ task_name ] [ active ] <TAB> if return_preds : <TAB> <TAB> pred_dict = defaultdict",False,0 in active,active != 0,0.6706842184066772
|
||
|
4250,"def processDomain ( self, domainName, parentEvent, affil = False, host = None ) : <TAB> if domainName in self. domresults : <TAB> <TAB> self. sf. debug ( f""Skipping domain, {domainName}, already processed."" ) <TAB> <TAB> return None <TAB> self. domresults [ domainName ] = True <TAB> if affil : <TAB> <TAB> domevt = SpiderFootEvent ( <TAB> <TAB> <TAB> ""AFFILIATE_DOMAIN_NAME"", domainName, self. __name__, parentEvent <TAB> <TAB> ) <TAB> <TAB> self. notifyListeners ( domevt ) <TAB> <TAB> return None <TAB> if self. getTarget ( ). matches ( domainName ) : <TAB> <TAB> domevt = SpiderFootEvent ( ""DOMAIN_NAME"", domainName, self. __name__, parentEvent ) <TAB> <TAB> self. notifyListeners ( domevt ) <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return None <TAB> <TAB> if parentEvent. data. endswith ( ""."" + domainName ) : <TAB> <TAB> <TAB> domevt = SpiderFootEvent ( <TAB> <TAB> <TAB> <TAB> ""DOMAIN_NAME_PARENT"", domainName, self. __name__, parentEvent <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> self. notifyListeners ( domevt ) <TAB> return None",False,not host,parentEvent.data.startswith('.'),0.6747801303863525
|
||
|
4251,"def subject ( self, subject, depth = 1 ) : <TAB> if not subject in self. __serialized : <TAB> <TAB> self. __serialized [ subject ] = 1 <TAB> <TAB> if isinstance ( subject, ( BNode, URIRef ) ) : <TAB> <TAB> <TAB> write = self. write <TAB> <TAB> <TAB> indent = "" "" * depth <TAB> <TAB> <TAB> element_name = ""rdf:Description"" <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> write ( '%s<%s rdf:nodeID=""%s""' % ( indent, element_name, subject ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> uri = quoteattr ( self. relativize ( subject ) ) <TAB> <TAB> <TAB> <TAB> write ( ""%s<%s rdf:about=%s"" % ( indent, element_name, uri ) ) <TAB> <TAB> <TAB> if ( subject, None, None ) in self. store : <TAB> <TAB> <TAB> <TAB> write ( "">\n"" ) <TAB> <TAB> <TAB> <TAB> for predicate, object in self. store. predicate_objects ( subject ) : <TAB> <TAB> <TAB> <TAB> <TAB> self. predicate ( predicate, object, depth + 1 ) <TAB> <TAB> <TAB> <TAB> write ( ""%s</%s>\n"" % ( indent, element_name ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> write ( ""/>\n"" )",False,"isinstance(subject, BNode)",depth == 1,0.6496599912643433
|
||
|
4252,"def __iter__ ( self ) : <TAB> """"""Iterate over the file handle; yields key, start offset, and length."""""" <TAB> handle = self. _handle <TAB> handle. seek ( 0 ) <TAB> qresult_key = None <TAB> while True : <TAB> <TAB> start_offset = handle. tell ( ) <TAB> <TAB> line = handle. readline ( ) <TAB> <TAB> if line. startswith ( self. _query_mark ) : <TAB> <TAB> <TAB> if qresult_key is None : <TAB> <TAB> <TAB> <TAB> qresult_key = self. get_qresult_id ( start_offset ) <TAB> <TAB> <TAB> <TAB> qresult_offset = start_offset <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> curr_key = self. get_qresult_id ( start_offset ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> yield qresult_key, qresult_offset, start_offset - qresult_offset <TAB> <TAB> <TAB> <TAB> <TAB> qresult_key = curr_key <TAB> <TAB> <TAB> <TAB> <TAB> qresult_offset = start_offset <TAB> <TAB> <TAB> <TAB> <TAB> handle. seek ( qresult_offset ) <TAB> <TAB> elif not line : <TAB> <TAB> <TAB> yield qresult_key, qresult_offset, start_offset - qresult_offset <TAB> <TAB> <TAB> break",False,curr_key != qresult_key,curr_key is not None,0.6577798128128052
|
||
|
4253,"def verify_installer_integrity ( game, installer ) : <TAB> error_message = """" <TAB> if not os. path. exists ( installer ) : <TAB> <TAB> error_message = _ ( ""{} failed to download."" ). format ( installer ) <TAB> if not error_message : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> print ( ""Executing integrity check for {}"". format ( installer ) ) <TAB> <TAB> <TAB> <TAB> os. chmod ( installer, 0o744 ) <TAB> <TAB> <TAB> <TAB> result = subprocess. run ( [ installer, ""--check"" ] ) <TAB> <TAB> <TAB> <TAB> if not result. returncode == 0 : <TAB> <TAB> <TAB> <TAB> <TAB> error_message = _ ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""{} was corrupted. Please download it again."" <TAB> <TAB> <TAB> <TAB> <TAB> ). format ( installer ) <TAB> <TAB> <TAB> except Exception as ex : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> print ( ""Error, exception encountered: {}"". format ( ex ) ) <TAB> <TAB> <TAB> <TAB> error_message = _ ( ""{} was corrupted. Please download it again."" ). format ( <TAB> <TAB> <TAB> <TAB> <TAB> installer <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> return error_message",False,game.platform == 'linux',os.path.exists(installer),0.6613783240318298
|
||
|
4254,"def compareIgnoringNodeNames ( self, s1, s2, delims, verbose = False ) : <TAB> <TAB> delim1, delim2, delim3 = delims <TAB> lines1 = g. splitLines ( s1 ) <TAB> lines2 = g. splitLines ( s2 ) <TAB> if len ( lines1 )!= len ( lines2 ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> g. trace ( ""Different number of lines"" ) <TAB> <TAB> return False <TAB> <TAB> for i in range ( len ( lines2 ) ) : <TAB> <TAB> line1 = lines1 [ i ] <TAB> <TAB> line2 = lines2 [ i ] <TAB> <TAB> if line1 == line2 : <TAB> <TAB> <TAB> continue <TAB> <TAB> else : <TAB> <TAB> <TAB> n1 = g. skip_ws ( line1, 0 ) <TAB> <TAB> <TAB> n2 = g. skip_ws ( line2, 0 ) <TAB> <TAB> <TAB> if not g. match ( line1, n1, delim1 ) or not g. match ( line2, n2, delim1 ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> g. trace ( ""Mismatched non-sentinel lines"" ) <TAB> <TAB> <TAB> <TAB> return False <TAB> <TAB> <TAB> n1 += len ( delim1 ) <TAB> <TAB> <TAB> n2 += len ( delim1 ) <TAB> <TAB> <TAB> if g. match ( line1, n1, ""@+node"" ) and g. match ( line2, n2, ""@+node"" ) : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if g. match ( line1, n1, ""@-node"" ) and g. match ( line2, n2, ""@-node"" ) : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> if<mask>",True,verbose,verbose,0.6830271482467651
|
||
|
4255,"def init_weights ( self ) : <TAB> """"""Initialize model weights."""""" <TAB> for m in self. predict_layers. modules ( ) : <TAB> <TAB> if isinstance ( m, nn. Conv2d ) : <TAB> <TAB> <TAB> kaiming_init ( m ) <TAB> <TAB> elif isinstance ( m, nn. BatchNorm2d ) : <TAB> <TAB> <TAB> constant_init ( m, 1 ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> normal_init ( m, std = 0.01 )",True,"isinstance(m, nn.Linear)","isinstance(m, nn.Linear)",0.6553023457527161
|
||
|
4256,"def _get_setting_types_quickref ( ) : <TAB> """"""Generate the setting types quick reference."""""" <TAB> out = [ ] <TAB> out. append ( ""[[types]]"" ) <TAB> out. append ( '[options=""header"",width=""75%"",cols=""25%,75%""]' ) <TAB> out. append ( ""|=============="" ) <TAB> out. append ( ""|Type|Description"" ) <TAB> for name, typ in _get_configtypes ( ) : <TAB> <TAB> parser = docutils. DocstringParser ( typ ) <TAB> <TAB> desc = parser. short_desc <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> desc += ""\n\n"" + parser. long_desc <TAB> <TAB> out. append ( ""|{}|{}"". format ( name, desc ) ) <TAB> out. append ( ""|=============="" ) <TAB> return ""\n"". join ( out )",False,parser.long_desc,desc,0.6660737991333008
|
||
|
4257,"def _validate_duplicate_detection_history_time_window ( namespace ) : <TAB> if namespace. duplicate_detection_history_time_window : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> pass <TAB> <TAB> elif timedeltapattern. match ( namespace. duplicate_detection_history_time_window ) : <TAB> <TAB> <TAB> pass <TAB> <TAB> else : <TAB> <TAB> <TAB> raise CLIError ( <TAB> <TAB> <TAB> <TAB> ""--duplicate-detection-history-time-window Value Error : {0} value is not in ISO 8601 timespan / duration format. e.g. PT10M for duration of 10 min or 00:10:00 for duration of 10 min"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> namespace. duplicate_detection_history_time_window <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> )",False,iso8601pattern.match(namespace.duplicate_detection_history_time_window),duration.match(namespace.duplicate_detection_history_time_window),0.648791491985321
|
||
|
4258,"def getTable ( self, offset ) : <TAB> record_list = [ ] <TAB> BASE_ADDR = sizeof ( _APPL_DB_HEADER ) + offset <TAB> TableMetaData = _memcpy ( <TAB> <TAB> self. fbuf [ BASE_ADDR : BASE_ADDR + sizeof ( _TABLE_HEADER ) ], _TABLE_HEADER <TAB> ) <TAB> RECORD_OFFSET_BASE = BASE_ADDR + sizeof ( _TABLE_HEADER ) <TAB> record_count = 0 <TAB> offset = 0 <TAB> while TableMetaData. RecordCount!= record_count : <TAB> <TAB> RecordOffset = struct. unpack ( <TAB> <TAB> <TAB> "">I"", <TAB> <TAB> <TAB> self. fbuf [ <TAB> <TAB> <TAB> <TAB> RECORD_OFFSET_BASE <TAB> <TAB> <TAB> <TAB> + ( ATOM_SIZE * offset ) : RECORD_OFFSET_BASE <TAB> <TAB> <TAB> <TAB> + ( ATOM_SIZE * offset ) <TAB> <TAB> <TAB> <TAB> + ATOM_SIZE <TAB> <TAB> <TAB> ], <TAB> <TAB> ) [ 0 ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> record_list. append ( RecordOffset ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> record_count += 1 <TAB> <TAB> offset += 1 <TAB> return TableMetaData, record_list",False,RecordOffset != 0 and RecordOffset % 4 == 0,TableMetaData.RecordOffset != 0,0.6655939817428589
|
||
|
4259,"def _check_bidi ( s ) : <TAB> """"""Enforce bidirectional character check from RFC 3454 (stringprep)"""""" <TAB> r_and_al_cat = False <TAB> l_cat = False <TAB> for c in s : <TAB> <TAB> if not r_and_al_cat and stringprep. in_table_d1 ( c ) : <TAB> <TAB> <TAB> r_and_al_cat = True <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> l_cat = True <TAB> if r_and_al_cat and l_cat : <TAB> <TAB> raise SASLPrepError ( ""Both RandALCat and LCat characters present"" ) <TAB> if r_and_al_cat and not ( <TAB> <TAB> stringprep. in_table_d1 ( s [ 0 ] ) and stringprep. in_table_d1 ( s [ - 1 ] ) <TAB> ) : <TAB> <TAB> raise SASLPrepError ( ""RandALCat character not at both start and end"" )",False,not l_cat and stringprep.in_table_d2(c),l_cat,0.6496564745903015
|
||
|
4260,"def opps_output_converter ( kpt_list ) : <TAB> kpts = [ ] <TAB> mpii_keys = to_opps_converter. keys ( ) <TAB> for mpii_idx in range ( 0, 16 ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> model_idx = to_opps_converter [ mpii_idx ] <TAB> <TAB> <TAB> x, y = kpt_list [ model_idx ] <TAB> <TAB> <TAB> if x < 0 or y < 0 : <TAB> <TAB> <TAB> <TAB> kpts += [ 0.0, 0.0, - 1.0 ] <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> kpts += [ x, y, 1.0 ] <TAB> <TAB> else : <TAB> <TAB> <TAB> kpts += [ 0.0, 0.0, - 1.0 ] <TAB> return kpts",False,mpii_idx in mpii_keys,mpii_keys[mpii_idx] == kpt_list[mpii_idx],0.6584970951080322
|
||
|
4261,"def create_season_posters ( self, show_obj ) : <TAB> if self. season_posters and show_obj : <TAB> <TAB> result = [ ] <TAB> <TAB> for season, episodes in show_obj. episodes. iteritems ( ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> logger. log ( <TAB> <TAB> <TAB> <TAB> <TAB> u""Metadata provider "" <TAB> <TAB> <TAB> <TAB> <TAB> + self. name <TAB> <TAB> <TAB> <TAB> <TAB> + "" creating season posters for "" <TAB> <TAB> <TAB> <TAB> <TAB> + show_obj. name, <TAB> <TAB> <TAB> <TAB> <TAB> logger. DEBUG, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> result = result + [ self. save_season_posters ( show_obj, season ) ] <TAB> <TAB> return all ( result ) <TAB> return False",False,"not self._has_season_poster(show_obj, season)",self.logger,0.6538586020469666
|
||
|
4262,"def substitute_prompt ( prompt ) : <TAB> ""Perform substitutions on PROMPT."" <TAB> result = """" <TAB> plen = len ( prompt ) <TAB> i = 0 <TAB> while i < plen : <TAB> <TAB> if prompt [ i ] == ""\\"" : <TAB> <TAB> <TAB> i = i + 1 <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> cmdch = prompt [ i ] <TAB> <TAB> <TAB> if cmdch in prompt_substitutions : <TAB> <TAB> <TAB> <TAB> cmd = prompt_substitutions [ cmdch ] <TAB> <TAB> <TAB> <TAB> if i + 1 < plen and prompt [ i + 1 ] == ""{"" : <TAB> <TAB> <TAB> <TAB> <TAB> j = i + 1 <TAB> <TAB> <TAB> <TAB> <TAB> while j < plen and prompt [ j ]!= ""}"" : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> j = j + 1 <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if j >= plen or prompt [ j ]!= ""}"" : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> arg = None <TAB> <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> arg = prompt [ i + 2 : j ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> i = j <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> arg = None <TAB> <TAB> <TAB> <TAB> result += str ( cmd ( arg ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> result += prompt [ i ] <TAB> <TAB> else : <TAB> <TAB> <",False,i >= plen,i == plen,0.6755286455154419
|
||
|
4263,"def test_change_height_by_list_of_ints_width_by_fixed_int ( self ) : <TAB> aug = iaa. Resize ( { ""height"" : [ 12, 14 ], ""width"" : 12 } ) <TAB> seen2d = [ False, False ] <TAB> seen3d = [ False, False ] <TAB> for _ in sm. xrange ( 100 ) : <TAB> <TAB> observed2d = aug. augment_image ( self. image2d ) <TAB> <TAB> observed3d = aug. augment_image ( self. image3d ) <TAB> <TAB> assert observed2d. shape in [ ( 12, 12 ), ( 14, 12 ) ] <TAB> <TAB> assert observed3d. shape in [ ( 12, 12, 3 ), ( 14, 12, 3 ) ] <TAB> <TAB> if observed2d. shape == ( 12, 12 ) : <TAB> <TAB> <TAB> seen2d [ 0 ] = True <TAB> <TAB> else : <TAB> <TAB> <TAB> seen2d [ 1 ] = True <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> seen3d [ 0 ] = True <TAB> <TAB> else : <TAB> <TAB> <TAB> seen3d [ 1 ] = True <TAB> <TAB> if np. all ( seen2d ) and np. all ( seen3d ) : <TAB> <TAB> <TAB> break <TAB> assert np. all ( seen2d ) <TAB> assert np. all ( seen3d )",False,"observed3d.shape == (12, 12, 3)","seen3d.shape == (12, 12)",0.6496413946151733
|
||
|
4264,"def on_corner_motion ( self, event ) : <TAB> corner = self. GetGridCornerLabelWindow ( ) <TAB> hit_code = self. corner_hit_test ( event. X, event. Y ) <TAB> if self. corner_hitcode == self. CORNER_HIT_NONE : <TAB> <TAB> if hit_code == self. CORNER_HIT_NONE : <TAB> <TAB> <TAB> corner. SetToolTip ( """" ) <TAB> <TAB> elif hit_code == self. CORNER_HIT_UPDATE : <TAB> <TAB> <TAB> corner. SetToolTip ( self. tooltip ) <TAB> else : <TAB> <TAB> was_pressed = self. corner_button_pressed <TAB> <TAB> self. corner_button_pressed = ( <TAB> <TAB> <TAB> self. corner_hitcode!= self. CORNER_HIT_NONE <TAB> <TAB> <TAB> and self. corner_hitcode == hit_code <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> corner. RefreshRect ( <TAB> <TAB> <TAB> <TAB> self. get_corner_update_button_rect ( ), eraseBackground = False <TAB> <TAB> <TAB> )",False,was_pressed != self.corner_button_pressed,was_pressed,0.6516283750534058
|
||
|
4265,"def run_sanity_check ( self, ref_model ) : <TAB> using_val_step = ref_model. val_dataloader is not None and is_overridden ( <TAB> <TAB> ""validation_step"", ref_model <TAB> ) <TAB> should_sanity_check = ( <TAB> <TAB> using_val_step and self. num_sanity_val_steps > 0 and self. limit_val_batches > 0 <TAB> ) <TAB> <TAB> <TAB> if should_sanity_check : <TAB> <TAB> self. reset_val_dataloader ( ref_model ) <TAB> <TAB> self. num_sanity_val_batches = [ <TAB> <TAB> <TAB> min ( self. num_sanity_val_steps, val_batches ) <TAB> <TAB> <TAB> for val_batches in self. num_val_batches <TAB> <TAB> ] <TAB> <TAB> <TAB> <TAB> self. running_sanity_check = True <TAB> <TAB> self. on_sanity_check_start ( ) <TAB> <TAB> <TAB> <TAB> _, eval_results = self. run_evaluation ( max_batches = self. num_sanity_val_batches ) <TAB> <TAB> <TAB> <TAB> if eval_results is not None and len ( eval_results ) > 0 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> eval_results = eval_results [ - 1 ] <TAB> <TAB> <TAB> _, _, _, callback_metrics, _ = self. process_dict_result ( eval_results ) <TAB> <TAB> <TAB> self. logger_connector. callback_metrics = callback_metrics <TAB> <TAB> self. on_sanity_check_end ( ) <TAB> <TAB> self. running_sanity_check = False",False,"isinstance(eval_results, list)",len(eval_results) > 0,0.6518199443817139
|
||
|
4266,"def expand_elements_from ( target_or_item ) : <TAB> elements_from = target_or_item. get ( ""elements_from"", None ) <TAB> items = None <TAB> if elements_from : <TAB> <TAB> if elements_from == ""archive"" : <TAB> <TAB> <TAB> decompressed_directory = _decompress_target ( upload_config, target_or_item ) <TAB> <TAB> <TAB> items = _directory_to_items ( decompressed_directory ) <TAB> <TAB> elif elements_from == ""bagit"" : <TAB> <TAB> <TAB> _, elements_from_path = _has_src_to_path ( <TAB> <TAB> <TAB> <TAB> upload_config, target_or_item, is_dataset = False <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> items = _bagit_to_items ( elements_from_path ) <TAB> <TAB> elif elements_from == ""bagit_archive"" : <TAB> <TAB> <TAB> decompressed_directory = _decompress_target ( upload_config, target_or_item ) <TAB> <TAB> <TAB> items = _bagit_to_items ( decompressed_directory ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> _, elements_from_path = _has_src_to_path ( <TAB> <TAB> <TAB> <TAB> upload_config, target_or_item, is_dataset = False <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> items = _directory_to_items ( elements_from_path ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise Exception ( <TAB> <TAB> <TAB> <TAB> ""Unknown elements from type encountered [%s]"" % elements_from <TAB> <TAB> <TAB> ) <TAB> if items : <TAB> <TAB> del target_or_item [ ""elements_from"" ] <TAB> <TAB> target_or_item [ ""elements"" ] = items",False,elements_from == 'directory',elements_from_path,0.6529148817062378
|
||
|
4267,"def _visit_import_alike ( self, node : Union [ cst. Import, cst. ImportFrom ] ) -> bool : <TAB> names = node. names <TAB> if isinstance ( names, cst. ImportStar ) : <TAB> <TAB> return False <TAB> <TAB> for name in names : <TAB> <TAB> self. provider. set_metadata ( name, self. scope ) <TAB> <TAB> asname = name. asname <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> name_values = _gen_dotted_names ( cst. ensure_type ( asname. name, cst. Name ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> name_values = _gen_dotted_names ( name. name ) <TAB> <TAB> for name_value, _ in name_values : <TAB> <TAB> <TAB> self. scope. record_assignment ( name_value, node ) <TAB> return False",False,asname is not None,asname,0.6627383232116699
|
||
|
4268,"def _handle_results ( outqueue, get, cache ) : <TAB> thread = threading. current_thread ( ) <TAB> while 1 : <TAB> <TAB> try : <TAB> <TAB> <TAB> task = get ( ) <TAB> <TAB> except ( OSError, EOFError ) : <TAB> <TAB> <TAB> util. debug ( ""result handler got EOFError/OSError -- exiting"" ) <TAB> <TAB> <TAB> return <TAB> <TAB> if thread. _state : <TAB> <TAB> <TAB> assert thread. _state == TERMINATE <TAB> <TAB> <TAB> util. debug ( ""result handler found thread._state=TERMINATE"" ) <TAB> <TAB> <TAB> break <TAB> <TAB> if task is None : <TAB> <TAB> <TAB> util. debug ( ""result handler got sentinel"" ) <TAB> <TAB> <TAB> break <TAB> <TAB> job, i, obj = task <TAB> <TAB> try : <TAB> <TAB> <TAB> cache [ job ]. _set ( i, obj ) <TAB> <TAB> except KeyError : <TAB> <TAB> <TAB> pass <TAB> while cache and thread. _state!= TERMINATE : <TAB> <TAB> try : <TAB> <TAB> <TAB> task = get ( ) <TAB> <TAB> except ( OSError, EOFError ) : <TAB> <TAB> <TAB> util. debug ( ""result handler got EOFError/OSError -- exiting"" ) <TAB> <TAB> <TAB> return <TAB> <TAB> if task is None : <TAB> <TAB> <TAB> util. debug ( ""result handler ignoring extra sentinel"" ) <TAB> <TAB> <TAB> continue <TAB> <TAB> job, i, obj = task <TAB> <TAB> try : <TAB> <TAB> <TAB> cache [ job ]. _set ( i, obj ) <TAB> <TAB> except KeyError : <TAB> <TAB> <TAB> pass <TAB> if hasattr ( outqueue, ""_reader"" ) : <TAB> <TAB> util. debug ( ""ensuring that outqueue is not full"" ) <TAB> <TAB> <TAB> <TAB> <TAB",False,not outqueue._reader.poll(),thread.current_thread() == thread,0.6556485295295715
|
||
|
4269,"def __init__ ( self, width = None, lines = 1, ** kwds ) : <TAB> min = self. predict_attr ( kwds, ""min"" ) <TAB> max = self. predict_attr ( kwds, ""max"" ) <TAB> if ""format"" in kwds : <TAB> <TAB> self. format = kwds. pop ( ""format"" ) <TAB> if ""empty"" in kwds : <TAB> <TAB> self. empty = kwds. pop ( ""empty"" ) <TAB> self. editing = False <TAB> if width is None : <TAB> <TAB> w1 = w2 = """" <TAB> <TAB> if min is not None : <TAB> <TAB> <TAB> w1 = self. format_value ( min ) <TAB> <TAB> if max is not None : <TAB> <TAB> <TAB> w2 = self. format_value ( max ) <TAB> <TAB> if w2 : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> width = w1 <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> width = w2 <TAB> if width is None : <TAB> <TAB> width = 100 <TAB> if lines is None : <TAB> <TAB> lines = 1 <TAB> TextEditorWrapped. __init__ ( self, width, lines, ** kwds )",False,len(w1) > len(w2),width is None,0.6527270078659058
|
||
|
4270,"def set_bounds ( self, x, y, width, height ) : <TAB> if self. native : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> vertical_shift = self. frame. vertical_shift <TAB> <TAB> else : <TAB> <TAB> <TAB> vertical_shift = 0 <TAB> <TAB> self. native. Size = Size ( width, height ) <TAB> <TAB> self. native. Location = Point ( x, y + vertical_shift )",False,self.interface.parent is None,"hasattr(self.frame, 'vertical_shift')",0.658916711807251
|
||
|
4271,"def _inner ( * args, ** kwargs ) : <TAB> component_manager = args [ 0 ]. component_manager <TAB> for condition_name in condition_names : <TAB> <TAB> condition_result, err_msg = component_manager. evaluate_condition ( condition_name ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ComponentStartConditionNotMetError ( err_msg ) <TAB> if not component_manager. all_components_running ( * components ) : <TAB> <TAB> raise ComponentsNotStartedError ( <TAB> <TAB> <TAB> f""the following required components have not yet started: {json.dumps(components)}"" <TAB> <TAB> ) <TAB> return method ( * args, ** kwargs )",True,not condition_result,not condition_result,0.6566318273544312
|
||
|
4272,"def sanitize_event_keys ( kwargs, valid_keys ) : <TAB> <TAB> for key in list ( kwargs. keys ( ) ) : <TAB> <TAB> if key not in valid_keys : <TAB> <TAB> <TAB> kwargs. pop ( key ) <TAB> <TAB> for key in [ ""play"", ""role"", ""task"", ""playbook"" ] : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if len ( kwargs [ ""event_data"" ] [ key ] ) > 1024 : <TAB> <TAB> <TAB> <TAB> kwargs [ ""event_data"" ] [ key ] = Truncator ( kwargs [ ""event_data"" ] [ key ] ). chars ( <TAB> <TAB> <TAB> <TAB> <TAB> 1024 <TAB> <TAB> <TAB> <TAB> )",False,"isinstance(kwargs.get('event_data', {}).get(key), str)",key in kwargs,0.655011773109436
|
||
|
4273,"def _print_unix ( objects, sep, end, file, flush ) : <TAB> """"""A print_() implementation which writes bytes"""""" <TAB> encoding = _encoding <TAB> if isinstance ( sep, text_type ) : <TAB> <TAB> sep = sep. encode ( encoding, ""replace"" ) <TAB> if not isinstance ( sep, bytes ) : <TAB> <TAB> raise TypeError <TAB> if isinstance ( end, text_type ) : <TAB> <TAB> end = end. encode ( encoding, ""replace"" ) <TAB> if not isinstance ( end, bytes ) : <TAB> <TAB> raise TypeError <TAB> if end == b""\n"" : <TAB> <TAB> end = os. linesep <TAB> <TAB> if PY3 : <TAB> <TAB> <TAB> end = end. encode ( ""ascii"" ) <TAB> parts = [ ] <TAB> for obj in objects : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> obj = text_type ( obj ) <TAB> <TAB> if isinstance ( obj, text_type ) : <TAB> <TAB> <TAB> if PY2 : <TAB> <TAB> <TAB> <TAB> obj = obj. encode ( encoding, ""replace"" ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> obj = obj. encode ( encoding, ""surrogateescape"" ) <TAB> <TAB> <TAB> <TAB> except UnicodeEncodeError : <TAB> <TAB> <TAB> <TAB> <TAB> obj = obj. encode ( encoding, ""replace"" ) <TAB> <TAB> assert isinstance ( obj, bytes ) <TAB> <TAB> parts. append ( obj ) <TAB> data = sep. join ( parts ) + end <TAB> assert isinstance ( data, bytes ) <TAB> file = getattr ( file, ""buffer"", file ) <TAB> try : <TAB> <TAB> file. write ( data ) <TAB> except TypeError : <TAB> <TAB> if PY3 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> surr_data = data. decode ( encoding, ""surrogate",False,"not isinstance(obj, text_type) and (not isinstance(obj, bytes))",flush,0.6462098360061646
|
||
|
4274,"def __init__ ( self, * args, ** kwargs ) : <TAB> self. ignore_optional_for_conversion = kwargs. pop ( <TAB> <TAB> ""ignore_optional_for_conversion"", False <TAB> ) <TAB> super ( ). __init__ ( * args, ** kwargs ) <TAB> self. _help_override = kwargs. pop ( ""help_override"", None ) <TAB> self. translator = kwargs. pop ( ""i18n"", None ) <TAB> if self. parent is None : <TAB> <TAB> for name in ( self. name, * self. aliases ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise RuntimeError ( <TAB> <TAB> <TAB> <TAB> <TAB> f""The name `{name}` cannot be set as a command name. It is reserved for internal use."" <TAB> <TAB> <TAB> <TAB> ) <TAB> if len ( self. qualified_name ) > 60 : <TAB> <TAB> raise RuntimeError ( <TAB> <TAB> <TAB> f""This command ({self.qualified_name}) has an excessively long qualified name, "" <TAB> <TAB> <TAB> ""and will not be added to the bot to prevent breaking tools and menus. (limit 60)"" <TAB> <TAB> )",False,name in RESERVED_COMMAND_NAMES,self.qualified_name is None,0.6603841781616211
|
||
|
4275,"def _download_file ( url, savepath, print_progress ) : <TAB> if<mask> : <TAB> <TAB> print ( ""Connecting to {}"". format ( url ) ) <TAB> r = requests. get ( url, stream = True, timeout = 15 ) <TAB> total_length = r. headers. get ( ""content-length"" ) <TAB> if total_length is None : <TAB> <TAB> with open ( savepath, ""wb"" ) as f : <TAB> <TAB> <TAB> shutil. copyfileobj ( r. raw, f ) <TAB> else : <TAB> <TAB> with open ( savepath, ""wb"" ) as f : <TAB> <TAB> <TAB> dl = 0 <TAB> <TAB> <TAB> total_length = int ( total_length ) <TAB> <TAB> <TAB> starttime = time. time ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> print ( ""Downloading %s"" % os. path. basename ( savepath ) ) <TAB> <TAB> <TAB> for data in r. iter_content ( chunk_size = 4096 ) : <TAB> <TAB> <TAB> <TAB> dl += len ( data ) <TAB> <TAB> <TAB> <TAB> f. write ( data ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> done = int ( 50 * dl / total_length ) <TAB> <TAB> <TAB> <TAB> <TAB> progress ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""[%-50s] %.2f%%"" % ( ""="" * done, float ( 100 * dl ) / total_length ) <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> progress ( ""[%-50s] %.2f%%"" % ( ""="" * 50, 100 ), end = True )",True,print_progress,print_progress,0.6613013744354248
|
||
|
4276,"def emit ( self, batch, event = None ) : <TAB> try : <TAB> <TAB> if batch : <TAB> <TAB> <TAB> envelopes = [ self. span_data_to_envelope ( sd ) for sd in batch ] <TAB> <TAB> <TAB> envelopes = self. apply_telemetry_processors ( envelopes ) <TAB> <TAB> <TAB> result = self. _transmit ( envelopes ) <TAB> <TAB> <TAB> if result > 0 : <TAB> <TAB> <TAB> <TAB> self. storage. put ( envelopes, result ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if isinstance ( event, QueueExitEvent ) : <TAB> <TAB> <TAB> <TAB> self. _transmit_from_storage ( ) <TAB> <TAB> <TAB> event. set ( ) <TAB> <TAB> <TAB> return <TAB> <TAB> if len ( batch ) < self. options. max_batch_size : <TAB> <TAB> <TAB> self. _transmit_from_storage ( ) <TAB> except Exception : <TAB> <TAB> logger. exception ( ""Exception occurred while exporting the data."" )",False,event,event is not None,0.6912020444869995
|
||
|
4277,"def get_file_list ( path, include_files ) : <TAB> """"""Return file list for the given path."""""" <TAB> <TAB> hide_list = [ <TAB> <TAB> ""boot"", <TAB> <TAB> ""bootmgr"", <TAB> <TAB> ""cache"", <TAB> <TAB> ""config.msi"", <TAB> <TAB> ""msocache"", <TAB> <TAB> ""recovery"", <TAB> <TAB> ""$recycle.bin"", <TAB> <TAB> ""recycler"", <TAB> <TAB> ""system volume information"", <TAB> <TAB> ""temporary internet files"", <TAB> ] <TAB> hide_list += [ <TAB> <TAB> "".fseventd"", <TAB> <TAB> "".spotlight"", <TAB> <TAB> "".trashes"", <TAB> <TAB> "".vol"", <TAB> <TAB> ""cachedmessages"", <TAB> <TAB> ""caches"", <TAB> <TAB> ""trash"", <TAB> ] <TAB> hide_list += [ "".git"" ] <TAB> file_list = [ ] <TAB> for filename in os. listdir ( path ) : <TAB> <TAB> if filename. lower ( ) in hide_list : <TAB> <TAB> <TAB> continue <TAB> <TAB> full_filename = os. path. join ( path, filename ) <TAB> <TAB> is_dir = os. path. isdir ( full_filename ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> entry = { ""name"" : filename, ""path"" : full_filename } <TAB> <TAB> if not is_dir : <TAB> <TAB> <TAB> entry [ ""isFile"" ] = True <TAB> <TAB> file_list. append ( entry ) <TAB> return file_list",False,not include_files and (not is_dir),include_files and is_dir and (not is_dir),0.6483344435691833
|
||
|
4278,"def _init_export_dir ( dir ) : <TAB> util. ensure_dir ( dir ) <TAB> try : <TAB> <TAB> util. touch ( os. path. join ( dir, "".guild-nocopy"" ) ) <TAB> except IOError as e : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise RunsExportError ( ""'%s' is not a directory"" % dir ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise RunsExportError ( <TAB> <TAB> <TAB> <TAB> ""error initializing export directory '%s': %s"" % ( dir, e ) <TAB> <TAB> <TAB> )",False,e.errno == errno.ENOTDIR,os.path.isdir(dir),0.6575901508331299
|
||
|
4279,"def test_decimal_from_float ( f ) : <TAB> d = Decimal ( f ) <TAB> if isfinite ( f ) and d. is_finite ( ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> decstr = str ( d. quantize ( Decimal ( ""1.000000"" ) ) ) <TAB> <TAB> except InvalidOperation : <TAB> <TAB> <TAB> return <TAB> <TAB> try : <TAB> <TAB> <TAB> py_d = Object. parse ( decstr ) <TAB> <TAB> except RuntimeError as e : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> py_d = Object. parse ( str ( f ) ) <TAB> <TAB> assert isclose ( py_d, d, abs_tol = 1e-5 ), ( d, f. hex ( ) ) <TAB> else : <TAB> <TAB> with pytest. raises ( PdfError ) : <TAB> <TAB> <TAB> Object. parse ( str ( d ) )",False,'overflow' in str(e) or 'underflow' in str(e),e.args[0] in [TAB > 0,0.6533418297767639
|
||
|
4280,"def Execute ( self, text ) : <TAB> """"""Replace selection with text and run commands."""""" <TAB> ps1 = str ( sys. ps1 ) <TAB> ps2 = str ( sys. ps2 ) <TAB> endpos = self. GetTextLength ( ) <TAB> self. SetCurrentPos ( endpos ) <TAB> startpos = self. promptPosEnd <TAB> self. SetSelection ( startpos, endpos ) <TAB> self. ReplaceSelection ( """" ) <TAB> text = text. lstrip ( ) <TAB> text = self. fixLineEndings ( text ) <TAB> text = self. lstripPrompt ( text ) <TAB> text = text. replace ( os. linesep + ps1, ""\n"" ) <TAB> text = text. replace ( os. linesep + ps2, ""\n"" ) <TAB> text = text. replace ( os. linesep, ""\n"" ) <TAB> lines = text. split ( ""\n"" ) <TAB> commands = [ ] <TAB> command = """" <TAB> for line in lines : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> line = """" <TAB> <TAB> lstrip = line. lstrip ( ) <TAB> <TAB> if ( <TAB> <TAB> <TAB> line. strip ( )!= """" <TAB> <TAB> <TAB> and lstrip == line <TAB> <TAB> <TAB> and lstrip [ : 4 ] not in [ ""else"", ""elif"" ] <TAB> <TAB> <TAB> and lstrip [ : 6 ]!= ""except"" <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if command : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> commands. append ( command ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> command = line <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> command += ""\n"" <TAB> <TAB> <TAB> command += line <TAB> commands. append ( command ) <",False,line.strip() == ps2.strip(),self.HasTab(),0.6509056091308594
|
||
|
4281,"def describe_dict ( o ) : <TAB> sl = [ ""<dict"" ] <TAB> l = len ( o ) <TAB> sl. append ( str ( l ) ) <TAB> if l : <TAB> <TAB> sl. append ( ""-"" ) <TAB> <TAB> iterator = o. iteritems ( ) <TAB> <TAB> firstitem = True <TAB> <TAB> try : <TAB> <TAB> <TAB> while True : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> firstitem = False <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> sl. append ( "", "" ) <TAB> <TAB> <TAB> <TAB> k, v = iterator. next ( ) <TAB> <TAB> <TAB> <TAB> sl. append ( describe_object ( k ) ) <TAB> <TAB> <TAB> <TAB> sl. append ( "": "" ) <TAB> <TAB> <TAB> <TAB> sl. append ( describe_object ( v ) ) <TAB> <TAB> except StopIteration : <TAB> <TAB> <TAB> pass <TAB> sl. append ( "">"" ) <TAB> return """". join ( sl )",True,firstitem,firstitem,0.6981431245803833
|
||
|
4282,"def calculateEnableMargins ( self ) : <TAB> self. cnc. resetEnableMargins ( ) <TAB> for block in self. blocks : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> CNC. vars [ ""xmin"" ] = min ( CNC. vars [ ""xmin"" ], block. xmin ) <TAB> <TAB> <TAB> CNC. vars [ ""ymin"" ] = min ( CNC. vars [ ""ymin"" ], block. ymin ) <TAB> <TAB> <TAB> CNC. vars [ ""zmin"" ] = min ( CNC. vars [ ""zmin"" ], block. zmin ) <TAB> <TAB> <TAB> CNC. vars [ ""xmax"" ] = max ( CNC. vars [ ""xmax"" ], block. xmax ) <TAB> <TAB> <TAB> CNC. vars [ ""ymax"" ] = max ( CNC. vars [ ""ymax"" ], block. ymax ) <TAB> <TAB> <TAB> CNC. vars [ ""zmax"" ] = max ( CNC. vars [ ""zmax"" ], block. zmax )",False,block.enable,block.depth > 0,0.6705944538116455
|
||
|
4283,"def test_attrs_arrays ( Layer, data, ndim ) : <TAB> """"""Test layer attributes and arrays."""""" <TAB> np. random. seed ( 0 ) <TAB> layer = Layer ( data ) <TAB> <TAB> assert layer. ndim == ndim <TAB> properties = layer. _get_state ( ) <TAB> <TAB> signature = callsignature ( Layer ) <TAB> for prop in properties. keys ( ) : <TAB> <TAB> assert prop in signature. parameters <TAB> <TAB> <TAB> assert len ( properties ) == len ( signature. parameters ) - 1 <TAB> <TAB> new_layer = Layer ( ** properties ) <TAB> <TAB> for prop in properties. keys ( ) : <TAB> <TAB> <TAB> <TAB> if isinstance ( getattr ( layer, prop ), list ) : <TAB> <TAB> <TAB> assert np. all ( <TAB> <TAB> <TAB> <TAB> [ <TAB> <TAB> <TAB> <TAB> <TAB> np. all ( ol == nl ) <TAB> <TAB> <TAB> <TAB> <TAB> for ol, nl in zip ( getattr ( layer, prop ), getattr ( new_layer, prop ) ) <TAB> <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> assert np. all ( <TAB> <TAB> <TAB> <TAB> [ <TAB> <TAB> <TAB> <TAB> <TAB> np. all ( value == getattr ( new_layer, prop ) [ key ] ) <TAB> <TAB> <TAB> <TAB> <TAB> for key, value in getattr ( layer, prop ). items ( ) <TAB> <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> assert np. all ( getattr ( layer, prop ) == getattr ( new_layer, prop ) )",False,"isinstance(getattr(layer, prop), dict)","isinstance(layer, layer, dict)",0.6544009447097778
|
||
|
4284,"def __call__ ( self ) : <TAB> dmin, dmax = self. viewlim_to_dt ( ) <TAB> ymin = self. base. le ( dmin. year ) <TAB> ymax = self. base. ge ( dmax. year ) <TAB> ticks = [ dmin. replace ( year = ymin, ** self. replaced ) ] <TAB> while 1 : <TAB> <TAB> dt = ticks [ - 1 ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return date2num ( ticks ) <TAB> <TAB> year = dt. year + self. base. get_base ( ) <TAB> <TAB> ticks. append ( dt. replace ( year = year, ** self. replaced ) )",False,dt.year >= ymax,dt.year + self.base.get_base() < dmin,0.6773662567138672
|
||
|
4285,"def create_admin ( username, password ) : <TAB> if len ( password ) < 8 : <TAB> <TAB> click. echo ( ""Password length too short"" ) <TAB> <TAB> return False <TAB> else : <TAB> <TAB> user = User ( username = username, password = password, is_admin = True ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> click. echo ( f""User {username} successfully created."" ) <TAB> <TAB> <TAB> return True <TAB> <TAB> else : <TAB> <TAB> <TAB> click. echo ( ""User with given username already exists."" ) <TAB> <TAB> <TAB> return False",False,user.insert(),user.is_admin(),0.6606122255325317
|
||
|
4286,"def what ( self, page, args ) : <TAB> only_existing = args. get ( ""existing"", False ) <TAB> exclude_current = args. get ( ""excludecurrent"", False ) <TAB> <TAB> <TAB> <TAB> trailing_path = """" <TAB> request = args. get ( ""request"", None ) <TAB> if request : <TAB> <TAB> <TAB> <TAB> trailing_path = request. _feincms_extra_context. get ( ""extra_path"", """" ) [ 1 : ] <TAB> translations = dict ( ( t. language, t ) for t in page. available_translations ( ) ) <TAB> translations [ page. language ] = page <TAB> links = [ ] <TAB> for key, name in settings. LANGUAGES : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> if key in translations : <TAB> <TAB> <TAB> links. append ( <TAB> <TAB> <TAB> <TAB> ( key, name, translations [ key ]. get_absolute_url ( ) + trailing_path ) <TAB> <TAB> <TAB> ) <TAB> <TAB> elif not only_existing : <TAB> <TAB> <TAB> links. append ( ( key, name, None ) ) <TAB> return links",False,exclude_current and key == page.language,exclude_current and key not in translations,0.6525720357894897
|
||
|
4287,"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 ftype == TType. STRUCT : <TAB> <TAB> <TAB> <TAB> self. success = evernote. edam. type. ttypes. User ( ) <TAB> <TAB> <TAB> <TAB> self. success. read ( iprot ) <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. userException = evernote. edam. error. ttypes. EDAMUserException ( ) <TAB> <TAB> <TAB> <TAB> self. userException. read ( iprot ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> if ftype == TType. STRUCT : <TAB> <TAB> <TAB> <TAB> self. systemException = evernote. edam. error. ttypes. EDAMSystemException ( ) <TAB> <TAB> <TAB> <TAB> self. systemException. read ( iprot ) <TAB> <TAB> <TAB>",True,fid == 2,fid == 2,0.6798498630523682
|
||
|
4288,"def update ( self, frame_no ) : <TAB> self. _draw_label ( ) <TAB> <TAB> self. _start_column = min ( self. _start_column, self. _column ) <TAB> self. _start_column += _find_min_start ( <TAB> <TAB> self. _value [ self. _start_column : self. _column + 1 ], <TAB> <TAB> self. width, <TAB> <TAB> self. _frame. canvas. unicode_aware, <TAB> <TAB> self. _column >= self. string_len ( self. _value ), <TAB> ) <TAB> <TAB> ( colour, attr, bg ) = self. _pick_colours ( <TAB> <TAB> ""readonly"" if self. _readonly else ""edit_text"" <TAB> ) <TAB> text = self. _value [ self. _start_column : ] <TAB> text = _enforce_width ( text, self. width, self. _frame. canvas. unicode_aware ) <TAB> if self. _hide_char : <TAB> <TAB> text = self. _hide_char [ 0 ] * len ( text ) <TAB> text += "" "" * ( self. width - self. string_len ( text ) ) <TAB> self. _frame. canvas. print_at ( text, self. _x + self. _offset, self. _y, colour, attr, bg ) <TAB> <TAB> <TAB> if self. _has_focus : <TAB> <TAB> text_width = self. string_len ( text [ : self. _column - self. _start_column ] ) <TAB> <TAB> self. _draw_cursor ( <TAB> <TAB> <TAB> "" "" <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> else self. _hide_char [ 0 ] <TAB> <TAB> <TAB> if self. _hide_char <TAB> <TAB> <TAB> else self. _value [ self. _column ], <TAB> <TAB> <TAB> frame_no, <TAB> <TAB> <TAB> self. _x + self. _offset + text_width, <TAB> <",False,self._column >= len(self._value),self._hide_char,0.6521285772323608
|
||
|
4289,"def ShowTimelineMenu ( self, position, layer_id ) : <TAB> log. info ( ""ShowTimelineMenu: position: %s, layer: %s"" % ( position, layer_id ) ) <TAB> <TAB> _ = get_app ( ). _tr <TAB> <TAB> <TAB> clipboard_clip_ids = [ k for k, v in self. copy_clipboard. items ( ) if v. get ( ""id"" ) ] <TAB> clipboard_tran_ids = [ <TAB> <TAB> k for k, v in self. copy_transition_clipboard. items ( ) if v. get ( ""id"" ) <TAB> ] <TAB> <TAB> if self. copy_clipboard or self. copy_transition_clipboard : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> menu = QMenu ( self ) <TAB> <TAB> <TAB> Paste_Clip = menu. addAction ( _ ( ""Paste"" ) ) <TAB> <TAB> <TAB> Paste_Clip. setShortcut ( <TAB> <TAB> <TAB> <TAB> QKeySequence ( self. window. getShortcutByName ( ""pasteAll"" ) ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> Paste_Clip. triggered. connect ( <TAB> <TAB> <TAB> <TAB> partial ( <TAB> <TAB> <TAB> <TAB> <TAB> self. Paste_Triggered, <TAB> <TAB> <TAB> <TAB> <TAB> MENU_PASTE, <TAB> <TAB> <TAB> <TAB> <TAB> float ( position ), <TAB> <TAB> <TAB> <TAB> <TAB> int ( layer_id ), <TAB> <TAB> <TAB> <TAB> <TAB> [ ], <TAB> <TAB> <TAB> <TAB> <TAB> [ ], <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> return menu. popup ( QCursor. pos ( ) )",False,len(clipboard_clip_ids) + len(clipboard_tran_ids) > 0,len(clipboard_clip_ids) > 0,0.6501489877700806
|
||
|
4290,"def _validate_pandas ( <TAB> self, <TAB> actual_column_type, <TAB> expected_type, ) : <TAB> if expected_type is None : <TAB> <TAB> success = True <TAB> else : <TAB> <TAB> comp_types = [ ] <TAB> <TAB> try : <TAB> <TAB> <TAB> comp_types. append ( np. dtype ( expected_type ). type ) <TAB> <TAB> except TypeError : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> pd_type = getattr ( pd, expected_type ) <TAB> <TAB> <TAB> <TAB> if isinstance ( pd_type, type ) : <TAB> <TAB> <TAB> <TAB> <TAB> comp_types. append ( pd_type ) <TAB> <TAB> <TAB> except AttributeError : <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> pd_type = getattr ( pd. core. dtypes. dtypes, expected_type ) <TAB> <TAB> <TAB> <TAB> if isinstance ( pd_type, type ) : <TAB> <TAB> <TAB> <TAB> <TAB> comp_types. append ( pd_type ) <TAB> <TAB> <TAB> except AttributeError : <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> native_type = _native_type_type_map ( expected_type ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> comp_types. extend ( native_type ) <TAB> <TAB> success = actual_column_type. type in comp_types <TAB> return { <TAB> <TAB> ""success"" : success, <TAB> <TAB> ""result"" : { ""observed_value"" : actual_column_type. type. __name__ }, <TAB> }",True,native_type is not None,native_type is not None,0.6611142754554749
|
||
|
4291,"def test_pretrained_distilbert_models ( wo_valid_len ) : <TAB> models = [ ""distilbert_6_768_12"" ] <TAB> pretrained_datasets = [ ""distilbert_book_corpus_wiki_en_uncased"" ] <TAB> vocab_size = { ""distilbert_book_corpus_wiki_en_uncased"" : 30522 } <TAB> special_tokens = [ ""[UNK]"", ""[PAD]"", ""[SEP]"", ""[CLS]"", ""[MASK]"" ] <TAB> ones = mx. nd. ones ( ( 2, 10 ) ) <TAB> valid_length = mx. nd. ones ( ( 2, ) ) <TAB> for model_name in models : <TAB> <TAB> for dataset in pretrained_datasets : <TAB> <TAB> <TAB> eprint ( ""testing forward for %s on %s"" % ( model_name, dataset ) ) <TAB> <TAB> <TAB> model, vocab = nlp. model. get_model ( <TAB> <TAB> <TAB> <TAB> model_name, <TAB> <TAB> <TAB> <TAB> dataset_name = dataset, <TAB> <TAB> <TAB> <TAB> pretrained = True, <TAB> <TAB> <TAB> <TAB> root = ""tests/data/model/"", <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> assert len ( vocab ) == vocab_size [ dataset ] <TAB> <TAB> <TAB> for token in special_tokens : <TAB> <TAB> <TAB> <TAB> assert token in vocab, ""Token %s not found in the vocab"" % token <TAB> <TAB> <TAB> assert vocab [ ""RandomWordByHaibin"" ] == vocab [ vocab. unknown_token ] <TAB> <TAB> <TAB> assert vocab. padding_token == ""[PAD]"" <TAB> <TAB> <TAB> assert vocab. unknown_token == ""[UNK]"" <TAB> <TAB> <TAB> model. hybridize ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> output = model ( ones ) <TAB> <TAB> <TAB>",False,wo_valid_len,pretrained,0.6612242460250854
|
||
|
4292,"def create_child ( self, value = None, _id = None ) : <TAB> with atomic ( savepoint = False ) : <TAB> <TAB> child_key = self. get_next_child_key ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> value = child_key <TAB> <TAB> child = self. __class__. objects. create ( id = _id, key = child_key, value = value ) <TAB> <TAB> return child",False,value is None,value is None and child_key and (child_key not in value),0.6629682779312134
|
||
|
4293,"def on_bt_search_clicked ( self, widget ) : <TAB> if self. current_provider is None : <TAB> <TAB> return <TAB> query = self. en_query. get_text ( ) <TAB> @ self. obtain_podcasts_with <TAB> def load_data ( ) : <TAB> <TAB> if self. current_provider. kind == directory. Provider. PROVIDER_SEARCH : <TAB> <TAB> <TAB> return self. current_provider. on_search ( query ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> return self. current_provider. on_url ( query ) <TAB> <TAB> elif self. current_provider. kind == directory. Provider. PROVIDER_FILE : <TAB> <TAB> <TAB> return self. current_provider. on_file ( query )",False,self.current_provider.kind == directory.Provider.PROVIDER_URL,self.current_provider.kind == directory.Provider.SCHEME_URL,0.6515692472457886
|
||
|
4294,"def testPartExecutor ( self, test_case, is_setup_or_teardown = False ) : <TAB> old_success = self. success <TAB> self. success = True <TAB> try : <TAB> <TAB> yield <TAB> except KeyboardInterrupt : <TAB> <TAB> raise <TAB> except unittest. SkipTest as e : <TAB> <TAB> self. success = False <TAB> <TAB> self. skipped. append ( ( test_case, str ( e ) ) ) <TAB> except _ShouldStop : <TAB> <TAB> pass <TAB> except unittest. case. _ExpectedFailure as e : <TAB> <TAB> self. success = False <TAB> <TAB> self. expecting_failure = True <TAB> <TAB> self. expectedFailure = e. exc_info <TAB> except unittest. case. _UnexpectedSuccess : <TAB> <TAB> self. expecting_failure = True <TAB> <TAB> <TAB> except : <TAB> <TAB> self. success = False <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. errors_setup_and_teardown. append ( ( test_case, sys. exc_info ( ) ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. errors. append ( ( test_case, sys. exc_info ( ) ) ) <TAB> else : <TAB> <TAB> if self. result_supports_subtests and self. success : <TAB> <TAB> <TAB> self. errors. append ( ( test_case, None ) ) <TAB> finally : <TAB> <TAB> self. success = self. success and old_success",True,is_setup_or_teardown,is_setup_or_teardown,0.6469103097915649
|
||
|
4295,"def init_weights ( self ) : <TAB> for m in self. modules ( ) : <TAB> <TAB> if isinstance ( m, nn. Linear ) : <TAB> <TAB> <TAB> normal_init ( m, std = 0.01 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> xavier_init ( m, distribution = ""uniform"" ) <TAB> <TAB> if isinstance ( m, nn. BatchNorm3d ) : <TAB> <TAB> <TAB> constant_init ( m, 1 )",True,"isinstance(m, nn.Conv3d)","isinstance(m, nn.Conv3d)",0.6551833152770996
|
||
|
4296,"def _set_ref ( self, value ) : <TAB> if value : <TAB> <TAB> if not self. _flags & 4 : <TAB> <TAB> <TAB> return <TAB> <TAB> if self. _flags & 2 : <TAB> <TAB> <TAB> self. loop. ref ( ) <TAB> <TAB> self. _flags &= ~ 6 <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return <TAB> <TAB> self. _flags |= 4 <TAB> <TAB> if not self. _flags & 2 and libev. ev_is_active ( self. _watcher ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. loop. unref ( ) <TAB> <TAB> <TAB> self. _flags |= 2",False,self._flags & 4,value,0.6662853956222534
|
||
|
4297,"def _Dynamic_Put ( self, put_request, put_response ) : <TAB> """"""Send a put request to the datastore server."""""" <TAB> put_request. set_trusted ( self. __trusted ) <TAB> ent_kinds = [ ] <TAB> for ent in put_request. entity_list ( ) : <TAB> <TAB> last_path = ent. key ( ). path ( ). element_list ( ) [ - 1 ] <TAB> <TAB> if last_path. type ( ) not in ent_kinds : <TAB> <TAB> <TAB> ent_kinds. append ( last_path. type ( ) ) <TAB> for kind in ent_kinds : <TAB> <TAB> indexes = self. __index_cache. get ( kind ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> for index in indexes : <TAB> <TAB> <TAB> <TAB> new_composite = put_request. add_composite_index ( ) <TAB> <TAB> <TAB> <TAB> new_composite. CopyFrom ( index ) <TAB> self. _RemoteSend ( put_request, put_response, ""Put"" ) <TAB> return put_response",True,indexes,indexes,0.7012069225311279
|
||
|
4298,"def observe ( self, message, * args ) : <TAB> if len ( args ) > 0 : <TAB> <TAB> return <TAB> if self. _handleException ( message ) : <TAB> <TAB> return <TAB> if self. _handleScriptError ( message ) : <TAB> <TAB> return <TAB> try : <TAB> <TAB> messagetext = message. message <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. log. debug ( ""FILTERED: %s"", messagetext ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. log. info ( ""%s"", messagetext ) <TAB> except Exception : <TAB> <TAB> self. log. error ( <TAB> <TAB> <TAB> ""Exception occurred while handling logging message. Failing gracefully."" <TAB> <TAB> ) <TAB> <TAB> return",False,any((x in messagetext for x in self.ignored_error_strings)),self.log.getEffectiveLevel() == logging.DEBUG,0.6573004722595215
|
||
|
4299,"def GenerateMethods ( ag ) : <TAB> global counter <TAB> tg = ag. DefineType ( ""Abomination"" ) <TAB> system_assembly = clr. LoadAssemblyByName ( <TAB> <TAB> ""System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"" <TAB> ) <TAB> mscorlib_assembly = clr. LoadAssemblyByName ( <TAB> <TAB> ""mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"" <TAB> ) <TAB> for ref in ( system_assembly, mscorlib_assembly ) : <TAB> <TAB> for t in ref. GetExportedTypes ( ) : <TAB> <TAB> <TAB> if t. ContainsGenericParameters or t. FullName in skipTypes : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if trace : <TAB> <TAB> <TAB> <TAB> print ( counter, t. FullName ) <TAB> <TAB> <TAB> EmitTestMethod ( tg, ""Test_%d"" % counter, t ) <TAB> <TAB> <TAB> EmitTestMethod ( tg, ""TestRef_%d"" % counter, t. MakeByRefType ( ) ) <TAB> <TAB> <TAB> counter += 1 <TAB> return tg. CreateType ( )",False,supportsIsByRefLike and t.IsByRefLike,t.IsGenericParameters(),0.6508224606513977
|
||
|
4300,"def get_snpeff_files ( data ) : <TAB> try : <TAB> <TAB> snpeff_db, datadir = get_db ( data ) <TAB> except ValueError : <TAB> <TAB> snpeff_db = None <TAB> if snpeff_db : <TAB> <TAB> <TAB> <TAB> clean_snpeff_db = snpeff_db. replace ( ""."", ""_"" ) <TAB> <TAB> snpeff_files = glob. glob ( os. path. join ( datadir, snpeff_db, ""*"" ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> base_files = [ <TAB> <TAB> <TAB> <TAB> x for x in snpeff_files if x. endswith ( ""/snpEffectPredictor.bin"" ) <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> assert len ( base_files ) == 1, base_files <TAB> <TAB> <TAB> del snpeff_files [ snpeff_files. index ( base_files [ 0 ] ) ] <TAB> <TAB> <TAB> return { ""base"" : base_files [ 0 ], ""indexes"" : snpeff_files } <TAB> else : <TAB> <TAB> return { }",True,len(snpeff_files) > 0,len(snpeff_files) > 0,0.6556860208511353
|
||
|
4301,"def _generate_samples ( self ) : <TAB> if not self. _samples : <TAB> <TAB> self. _inject_default_sample_section ( ) <TAB> output = """" <TAB> eval_scope = self. _generate_eval_scope ( ) <TAB> for sample in self. _samples : <TAB> <TAB> command = _command_template. format ( method = self. _method, kwargs = sample. kwargs ) <TAB> <TAB> validator = SampleCodeValidator ( command ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> msg = ( <TAB> <TAB> <TAB> <TAB> ""Invalid code elements detected. Sample generation will be "" <TAB> <TAB> <TAB> <TAB> ""skipped for method `{method}` with arguments `{kwargs}`."" <TAB> <TAB> <TAB> ). format ( <TAB> <TAB> <TAB> <TAB> method = self. _method, <TAB> <TAB> <TAB> <TAB> kwargs = sample. kwargs, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> self. _log_warning ( msg ) <TAB> <TAB> <TAB> continue <TAB> <TAB> try : <TAB> <TAB> <TAB> Faker. seed ( sample. seed ) <TAB> <TAB> <TAB> results = ""\n"". join ( <TAB> <TAB> <TAB> <TAB> [ <TAB> <TAB> <TAB> <TAB> <TAB> self. _stringify_result ( eval ( command, eval_scope ) ) <TAB> <TAB> <TAB> <TAB> <TAB> for _ in range ( sample. size ) <TAB> <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> ) <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> msg = ""Sample generation failed for method `{method}` with arguments `{kwargs}`."". format ( <TAB> <TAB> <TAB> <TAB> method = self. _method, <TAB> <TAB> <TAB> <TAB> kwargs = sample. kwargs, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> self. _log_warning ( msg ) <TAB>",False,validator.errors,validator.raise_error,0.6785060167312622
|
||
|
4302,"def test_open_read_bytes ( self, sftp ) : <TAB> """"""Test reading bytes from a file"""""" <TAB> f = None <TAB> try : <TAB> <TAB> self. _create_file ( ""file"", ""xxx"" ) <TAB> <TAB> f = yield from sftp. open ( ""file"", ""rb"" ) <TAB> <TAB> self. assertEqual ( ( yield from f. read ( ) ), b""xxx"" ) <TAB> finally : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> yield from f. close ( ) <TAB> <TAB> remove ( ""file"" )",True,f,f,0.6892582774162292
|
||
|
4303,"def delete_all ( path ) : <TAB> ppath = os. getcwd ( ) <TAB> os. chdir ( path ) <TAB> for fn in glob. glob ( ""*"" ) : <TAB> <TAB> fn_full = os. path. join ( path, fn ) <TAB> <TAB> if os. path. isdir ( fn ) : <TAB> <TAB> <TAB> delete_all ( fn_full ) <TAB> <TAB> elif fn. endswith ( "".png"" ) : <TAB> <TAB> <TAB> os. remove ( fn_full ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> os. remove ( fn_full ) <TAB> <TAB> elif DELETE_ALL_OLD : <TAB> <TAB> <TAB> os. remove ( fn_full ) <TAB> os. chdir ( ppath ) <TAB> os. rmdir ( path )",False,fn.endswith('.md'),delete_ALL_OLD,0.6463217735290527
|
||
|
4304,"def main ( ) : <TAB> argv = sys. argv <TAB> if len ( argv ) == 1 : <TAB> <TAB> sys. argv. append ( ""-h"" ) <TAB> <TAB> read_config ( ) <TAB> <TAB> sys. exit ( ) <TAB> try : <TAB> <TAB> config, args = read_config ( ) <TAB> <TAB> if config [ ""pelinker_fname"" ] : <TAB> <TAB> <TAB> load_linker_sequences ( config [ ""pelinker_fname"" ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise RuntimeError ( ""No SFF file given?"" ) <TAB> <TAB> extract_reads_from_sff ( config, args ) <TAB> except ( OSError, IOError, RuntimeError ) as errval : <TAB> <TAB> print ( errval ) <TAB> <TAB> return 1 <TAB> if stern_warning : <TAB> <TAB> return 1 <TAB> return 0",False,len(args) == 0,not args[0],0.6616754531860352
|
||
|
4305,"def CollectImage ( self, responses ) : <TAB> """"""Collect the image and store it into the database."""""" <TAB> <TAB> for response in responses : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> for log in response. logs : <TAB> <TAB> <TAB> <TAB> self. Log ( log ) <TAB> if not responses. success : <TAB> <TAB> raise flow_base. FlowError ( <TAB> <TAB> <TAB> ""Failed to dump the flash image: {0}"". format ( responses. status ) <TAB> <TAB> ) <TAB> elif not responses. First ( ). path : <TAB> <TAB> self. Log ( ""No path returned. Skipping host."" ) <TAB> <TAB> return <TAB> else : <TAB> <TAB> image_path = responses. First ( ). path <TAB> <TAB> self. CallFlow ( <TAB> <TAB> <TAB> transfer. MultiGetFile. __name__, <TAB> <TAB> <TAB> pathspecs = [ image_path ], <TAB> <TAB> <TAB> request_data = { ""image_path"" : image_path }, <TAB> <TAB> <TAB> next_state = compatibility. GetName ( self. DeleteTemporaryImage ), <TAB> <TAB> )",False,"hasattr(response, 'logs')",response.status == 200,0.6537551879882812
|
||
|
4306,"def _resize_img ( self, results ) : <TAB> """"""Resize images with ``results['scale']``."""""" <TAB> for key in results. get ( ""img_fields"", [ ""img"" ] ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> img, scale_factor = mmcv. imrescale ( <TAB> <TAB> <TAB> <TAB> results [ key ], results [ ""scale"" ], return_scale = True, backend = self. backend <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> new_h, new_w = img. shape [ : 2 ] <TAB> <TAB> <TAB> h, w = results [ key ]. shape [ : 2 ] <TAB> <TAB> <TAB> w_scale = new_w / w <TAB> <TAB> <TAB> h_scale = new_h / h <TAB> <TAB> else : <TAB> <TAB> <TAB> img, w_scale, h_scale = mmcv. imresize ( <TAB> <TAB> <TAB> <TAB> results [ key ], results [ ""scale"" ], return_scale = True, backend = self. backend <TAB> <TAB> <TAB> ) <TAB> <TAB> results [ key ] = img <TAB> <TAB> scale_factor = np. array ( [ w_scale, h_scale, w_scale, h_scale ], dtype = np. float32 ) <TAB> <TAB> results [ ""img_shape"" ] = img. shape <TAB> <TAB> <TAB> <TAB> results [ ""pad_shape"" ] = img. shape <TAB> <TAB> results [ ""scale_factor"" ] = scale_factor <TAB> <TAB> results [ ""keep_ratio"" ] = self. keep_ratio",False,self.keep_ratio,key in results,0.6535025835037231
|
||
|
4307,"def format_amounts ( amounts, link ) : <TAB> ret = [ ] <TAB> for chain_id in chain_ids : <TAB> <TAB> chain = chains [ chain_id ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> ret += [ "", "" ] <TAB> <TAB> ret += [ format_satoshis ( amounts [ chain_id ], chain ), "" "", escape ( chain [ ""code3"" ] ) ] <TAB> <TAB> if link : <TAB> <TAB> <TAB> other = hash_to_address ( chain [ ""address_version"" ], binaddr ) <TAB> <TAB> <TAB> if other!= address : <TAB> <TAB> <TAB> <TAB> ret [ - 1 ] = [ <TAB> <TAB> <TAB> <TAB> <TAB> '<a href=""', <TAB> <TAB> <TAB> <TAB> <TAB> page [ ""dotdot"" ], <TAB> <TAB> <TAB> <TAB> <TAB> ""address/"", <TAB> <TAB> <TAB> <TAB> <TAB> other, <TAB> <TAB> <TAB> <TAB> <TAB> '"">', <TAB> <TAB> <TAB> <TAB> <TAB> ret [ - 1 ], <TAB> <TAB> <TAB> <TAB> <TAB> ""</a>"", <TAB> <TAB> <TAB> <TAB> ] <TAB> return ret",False,chain_id != chain_ids[0],chain,0.6586318612098694
|
||
|
4308,"def delete_revision ( request, document_path, revision_id ) : <TAB> """"""Delete a revision."""""" <TAB> document_locale, document_slug, needs_redirect = locale_and_slug_from_path ( <TAB> <TAB> document_path, request <TAB> ) <TAB> revision = get_object_or_404 ( Revision, pk = revision_id, document__slug = document_slug ) <TAB> document = revision. document <TAB> if request. method == ""GET"" : <TAB> <TAB> <TAB> <TAB> return render ( <TAB> <TAB> <TAB> request, <TAB> <TAB> <TAB> ""wiki/confirm_revision_delete.html"", <TAB> <TAB> <TAB> { ""revision"" : revision, ""document"" : document }, <TAB> <TAB> ) <TAB> <TAB> log. warning ( ""User %s is deleting revision with id=%s"" % ( request. user, revision. id ) ) <TAB> Revision. objects. filter ( based_on = revision ). update ( based_on = None ) <TAB> if document. current_revision == revision : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> revs = document. revisions. filter ( is_approved = True ). order_by ( ""-created"" ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> rev = revs [ 1 ] <TAB> <TAB> <TAB> rev. make_current ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> document. delete ( ) <TAB> <TAB> <TAB> return redirect ( ""wiki.all_documents"" ) <TAB> revision. delete ( ) <TAB> return HttpResponseRedirect ( <TAB> <TAB> reverse ( ""wiki.document_revisions"", args = [ document. full_path ] ) <TAB> )",False,len(revs) > 1,revs,0.6525915265083313
|
||
|
4309,"def saveFile ( self, event ) : <TAB> """"""Prompt for the name of a file and put the body text of the selected node into it.."""""" <TAB> c = self. c <TAB> w = self. editWidget ( event ) <TAB> if not w : <TAB> <TAB> return <TAB> fileName = g. app. gui. runSaveFileDialog ( <TAB> <TAB> c, <TAB> <TAB> initialfile = None, <TAB> <TAB> title = ""save-file"", <TAB> <TAB> filetypes = [ ( ""Text"", ""*.txt"" ), ( ""All files"", ""*"" ) ], <TAB> <TAB> defaultextension = "".txt"", <TAB> ) <TAB> if fileName : <TAB> <TAB> try : <TAB> <TAB> <TAB> f = open ( fileName, ""w"" ) <TAB> <TAB> <TAB> s = w. getAllText ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> s = g. toEncodedString ( s, encoding = ""utf-8"", reportErrors = True ) <TAB> <TAB> <TAB> f. write ( s ) <TAB> <TAB> <TAB> f. close ( ) <TAB> <TAB> except IOError : <TAB> <TAB> <TAB> g. es ( ""can not create"", fileName )",False,not g.isPython3,s,0.6498782634735107
|
||
|
4310,"def _serialize ( self, stream ) : <TAB> write = stream. write <TAB> write ( ( ""tree %s\n"" % self. tree ). encode ( ""ascii"" ) ) <TAB> for p in self. parents : <TAB> <TAB> write ( ( ""parent %s\n"" % p ). encode ( ""ascii"" ) ) <TAB> a = self. author <TAB> aname = a. name <TAB> c = self. committer <TAB> fmt = ""%s %s <%s> %s %s\n"" <TAB> write ( <TAB> <TAB> ( <TAB> <TAB> <TAB> fmt <TAB> <TAB> <TAB> % ( <TAB> <TAB> <TAB> <TAB> ""author"", <TAB> <TAB> <TAB> <TAB> aname, <TAB> <TAB> <TAB> <TAB> a. email, <TAB> <TAB> <TAB> <TAB> self. authored_date, <TAB> <TAB> <TAB> <TAB> altz_to_utctz_str ( self. author_tz_offset ), <TAB> <TAB> <TAB> ) <TAB> <TAB> ). encode ( self. encoding ) <TAB> ) <TAB> <TAB> aname = c. name <TAB> write ( <TAB> <TAB> ( <TAB> <TAB> <TAB> fmt <TAB> <TAB> <TAB> % ( <TAB> <TAB> <TAB> <TAB> ""committer"", <TAB> <TAB> <TAB> <TAB> aname, <TAB> <TAB> <TAB> <TAB> c. email, <TAB> <TAB> <TAB> <TAB> self. committed_date, <TAB> <TAB> <TAB> <TAB> altz_to_utctz_str ( self. committer_tz_offset ), <TAB> <TAB> <TAB> ) <TAB> <TAB> ). encode ( self. encoding ) <TAB> ) <TAB> if self. encoding!= self. default_encoding : <TAB> <TAB> write ( ( ""encoding %s\n"" % self. encoding ). encode ( ""ascii"" ) ) <TAB> try : <TAB> <TAB>",False,self.__getattribute__('gpgsig') is not None,self.encoding == 'utf-8',0.6501185894012451
|
||
|
4311,"def disconnect ( exiting_interpreter = False ) : <TAB> """"""Disconnect this worker from the raylet and object store."""""" <TAB> <TAB> <TAB> <TAB> <TAB> worker = global_worker <TAB> if worker. connected : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> worker. threads_stopped. set ( ) <TAB> <TAB> if hasattr ( worker, ""import_thread"" ) : <TAB> <TAB> <TAB> worker. import_thread. join_import_thread ( ) <TAB> <TAB> if hasattr ( worker, ""listener_thread"" ) : <TAB> <TAB> <TAB> worker. listener_thread. join ( ) <TAB> <TAB> if hasattr ( worker, ""printer_thread"" ) : <TAB> <TAB> <TAB> worker. printer_thread. join ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> worker. logger_thread. join ( ) <TAB> <TAB> worker. threads_stopped. clear ( ) <TAB> <TAB> worker. _session_index += 1 <TAB> worker. node = None <TAB> worker. cached_functions_to_run = [ ] <TAB> worker. serialization_context_map. clear ( ) <TAB> try : <TAB> <TAB> ray_actor = ray. actor <TAB> except AttributeError : <TAB> <TAB> ray_actor = None <TAB> if ray_actor is not None : <TAB> <TAB> ray_actor. ActorClassMethodMetadata. reset_cache ( )",True,"hasattr(worker, 'logger_thread')","hasattr(worker, 'logger_thread')",0.6539206504821777
|
||
|
4312,"def main ( _ ) : <TAB> problem_name = FLAGS. problem <TAB> if ""video"" not in problem_name and ""gym"" not in problem_name : <TAB> <TAB> print ( ""This tool only works for video problems."" ) <TAB> <TAB> return <TAB> mode = tf. estimator. ModeKeys. TRAIN <TAB> hparams = trainer_lib. create_hparams ( <TAB> <TAB> FLAGS. hparams_set, <TAB> <TAB> FLAGS. hparams, <TAB> <TAB> data_dir = os. path. expanduser ( FLAGS. data_dir ), <TAB> <TAB> problem_name = problem_name, <TAB> ) <TAB> dataset = hparams. problem. input_fn ( mode, hparams ) <TAB> features = dataset. make_one_shot_iterator ( ). get_next ( ) <TAB> tf. gfile. MakeDirs ( FLAGS. output_dir ) <TAB> base_template = os. path. join ( FLAGS. output_dir, FLAGS. problem ) <TAB> count = 0 <TAB> with tf. train. MonitoredTrainingSession ( ) as sess : <TAB> <TAB> while not sess. should_stop ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> data, _ = sess. run ( features ) <TAB> <TAB> <TAB> video_batch = np. concatenate ( ( data [ ""inputs"" ], data [ ""targets"" ] ), axis = 1 ) <TAB> <TAB> <TAB> for video in video_batch : <TAB> <TAB> <TAB> <TAB> print ( ""Saving {}/{}"". format ( count, FLAGS. num_samples ) ) <TAB> <TAB> <TAB> <TAB> name = ""%s_%05d"" % ( base_template, count ) <TAB> <TAB> <TAB> <TAB> decoding. save_video ( video, name + ""_{:05d}.png"" ) <TAB> <TAB> <TAB> <TAB> create_gif ( name ) <TAB> <TAB> <TAB> <TAB> count += 1 <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> sys. exit ( 0 )",False,count == FLAGS.num_samples,count > 3,0.6560604572296143
|
||
|
4313,"def dump ( self ) : <TAB> """"""Write the cached history to external storage."""""" <TAB> opts = builtins. __xonsh__. env. get ( ""HISTCONTROL"" ) <TAB> last_inp = None <TAB> cmds = [ ] <TAB> for cmd in self. buffer : <TAB> <TAB> if ""ignoredups"" in opts and cmd [ ""inp"" ] == last_inp : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. skip ( 1 ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if ""ignoreerr"" in opts and cmd [ ""rtn"" ]!= 0 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. skip ( 1 ) <TAB> <TAB> <TAB> continue <TAB> <TAB> cmds. append ( cmd ) <TAB> <TAB> last_inp = cmd [ ""inp"" ] <TAB> with open ( self. filename, ""r"", newline = ""\n"" ) as f : <TAB> <TAB> hist = xlj. LazyJSON ( f ). load ( ) <TAB> load_hist_len = len ( hist [ ""cmds"" ] ) <TAB> hist [ ""cmds"" ]. extend ( cmds ) <TAB> if self. at_exit : <TAB> <TAB> hist [ ""ts"" ] [ 1 ] = time. time ( ) <TAB> <TAB> hist [ ""locked"" ] = False <TAB> if not builtins. __xonsh__. env. get ( ""XONSH_STORE_STDOUT"", False ) : <TAB> <TAB> [ cmd. pop ( ""out"" ) for cmd in hist [ ""cmds"" ] [ load_hist_len : ] if ""out"" in cmd ] <TAB> with open ( self. filename, ""w"", newline = ""\n"" ) as f : <TAB> <TAB> xlj. ljdump ( hist, f, sort_keys = True )",False,self.skip is not None,"""skip"" in opts and cmd[ 'rtn""] == 0",0.6496889591217041
|
||
|
4314,"def target_function ( self, running, data ) : <TAB> while running. is_set ( ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> username, password = data. next ( ). split ( "":"" ) <TAB> <TAB> except StopIteration : <TAB> <TAB> <TAB> break <TAB> <TAB> else : <TAB> <TAB> <TAB> ftp_client = self. ftp_create ( ) <TAB> <TAB> <TAB> if ftp_client. connect ( retries = 3 ) is None : <TAB> <TAB> <TAB> <TAB> print_error ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Too many connections problems. Quiting..."", verbose = self. verbosity <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> if ftp_client. login ( username, password ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> running. clear ( ) <TAB> <TAB> <TAB> self. credentials. append ( <TAB> <TAB> <TAB> <TAB> ( self. target, self. port, self. target_protocol, username, password ) <TAB> <TAB> <TAB> ) <TAB> ftp_client. close ( )",False,self.stop_on_success,running.is_set(),0.65102219581604
|
||
|
4315,"def _group_by_commit_and_time ( self, hits ) : <TAB> result = { } <TAB> for hit in hits : <TAB> <TAB> source_hit = hit [ ""_source"" ] <TAB> <TAB> key = ""%s_%s"" % ( source_hit [ ""commit_info"" ] [ ""id"" ], source_hit [ ""datetime"" ] ) <TAB> <TAB> benchmark = self. _benchmark_from_es_record ( source_hit ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> result [ key ] [ ""benchmarks"" ]. append ( benchmark ) <TAB> <TAB> else : <TAB> <TAB> <TAB> run_info = self. _run_info_from_es_record ( source_hit ) <TAB> <TAB> <TAB> run_info [ ""benchmarks"" ] = [ benchmark ] <TAB> <TAB> <TAB> result [ key ] = run_info <TAB> return result",True,key in result,key in result,0.6747679710388184
|
||
|
4316,"def get_num ( line, char_ptr, num_chars ) : <TAB> char_ptr = char_ptr + 1 <TAB> numstr = """" <TAB> good = ""-.0123456789"" <TAB> while char_ptr < num_chars : <TAB> <TAB> digit = line [ char_ptr ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> numstr = numstr + digit <TAB> <TAB> <TAB> char_ptr = char_ptr + 1 <TAB> <TAB> else : <TAB> <TAB> <TAB> break <TAB> return numstr",False,good.find(digit) != -1,digit.lower() == good,0.6536663770675659
|
||
|
4317,"def save_graph_base ( <TAB> net, file_name, graph_name = ""net"", op_only = True, blob_rename_func = None ) : <TAB> graph = None <TAB> ops = net. op <TAB> if blob_rename_func is not None : <TAB> <TAB> ops = _modify_blob_names ( ops, blob_rename_func ) <TAB> if not op_only : <TAB> <TAB> graph = net_drawer. GetPydotGraph ( ops, graph_name, rankdir = ""TB"" ) <TAB> else : <TAB> <TAB> graph = net_drawer. GetPydotGraphMinimal ( <TAB> <TAB> <TAB> ops, graph_name, rankdir = ""TB"", minimal_dependency = True <TAB> <TAB> ) <TAB> try : <TAB> <TAB> par_dir = os. path. dirname ( file_name ) <TAB> <TAB> if not os. path. exists ( par_dir ) : <TAB> <TAB> <TAB> os. makedirs ( par_dir ) <TAB> <TAB> format = os. path. splitext ( os. path. basename ( file_name ) ) [ - 1 ] <TAB> <TAB> if format == "".png"" : <TAB> <TAB> <TAB> graph. write_png ( file_name ) <TAB> <TAB> elif format == "".pdf"" : <TAB> <TAB> <TAB> graph. write_pdf ( file_name ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> graph. write_svg ( file_name ) <TAB> <TAB> else : <TAB> <TAB> <TAB> print ( ""Incorrect format {}"". format ( format ) ) <TAB> except Exception as e : <TAB> <TAB> print ( ""Error when writing graph to image {}"". format ( e ) ) <TAB> return graph",True,format == '.svg',format == '.svg',0.6618694067001343
|
||
|
4318,"def _execute_for_all_tables ( self, app, bind, operation, skip_tables = False ) : <TAB> app = self. get_app ( app ) <TAB> if bind == ""__all__"" : <TAB> <TAB> binds = [ None ] + list ( app. config. get ( ""SQLALCHEMY_BINDS"" ) or ( ) ) <TAB> elif isinstance ( bind, string_types ) or bind is None : <TAB> <TAB> binds = [ bind ] <TAB> else : <TAB> <TAB> binds = bind <TAB> for bind in binds : <TAB> <TAB> extra = { } <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> tables = self. get_tables_for_bind ( bind ) <TAB> <TAB> <TAB> extra [ ""tables"" ] = tables <TAB> <TAB> op = getattr ( self. Model. metadata, operation ) <TAB> <TAB> op ( bind = self. get_engine ( app, bind ), ** extra )",False,not skip_tables,skip_tables,0.6631405353546143
|
||
|
4319,"def _check_presale_dates ( self ) : <TAB> if self. event. presale_start and self. now_dt < self. event. presale_start : <TAB> <TAB> raise CartError ( error_messages [ ""not_started"" ] ) <TAB> if self. event. presale_has_ended : <TAB> <TAB> raise CartError ( error_messages [ ""ended"" ] ) <TAB> if not self. event. has_subevents : <TAB> <TAB> tlv = self. event. settings. get ( ""payment_term_last"", as_type = RelativeDateWrapper ) <TAB> <TAB> if tlv : <TAB> <TAB> <TAB> term_last = make_aware ( <TAB> <TAB> <TAB> <TAB> datetime. combine ( <TAB> <TAB> <TAB> <TAB> <TAB> tlv. datetime ( self. event ). date ( ), time ( hour = 23, minute = 59, second = 59 ) <TAB> <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> <TAB> self. event. timezone, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise CartError ( error_messages [ ""payment_ended"" ] )",False,term_last < self.now_dt,self.event.settings.get('payment_ended_timestamp') and self.event.settings.get('payment_term_last') and self.event.settings.get('payment_term_last'),0.6537894010543823
|
||
|
4320,"def action_delete ( self, ids ) : <TAB> try : <TAB> <TAB> query = tools. get_query_for_ids ( self. get_query ( ), self. model, ids ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> count = query. delete ( synchronize_session = False ) <TAB> <TAB> else : <TAB> <TAB> <TAB> count = 0 <TAB> <TAB> <TAB> for m in query. all ( ) : <TAB> <TAB> <TAB> <TAB> if self. delete_model ( m ) : <TAB> <TAB> <TAB> <TAB> <TAB> count += 1 <TAB> <TAB> self. session. commit ( ) <TAB> <TAB> flash ( <TAB> <TAB> <TAB> ngettext ( <TAB> <TAB> <TAB> <TAB> ""Record was successfully deleted."", <TAB> <TAB> <TAB> <TAB> ""%(count)s records were successfully deleted."", <TAB> <TAB> <TAB> <TAB> count, <TAB> <TAB> <TAB> <TAB> count = count, <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> ""success"", <TAB> <TAB> ) <TAB> except Exception as ex : <TAB> <TAB> if not self. handle_view_exception ( ex ) : <TAB> <TAB> <TAB> raise <TAB> <TAB> flash ( gettext ( ""Failed to delete records. %(error)s"", error = str ( ex ) ), ""error"" )",False,self.fast_mass_delete,self.synchronize,0.6512268781661987
|
||
|
4321,"def __init__ ( self, raw ) : <TAB> ticker_ticks = { } <TAB> for tick in raw [ ""results"" ] : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> ticker_ticks [ tick [ ""T"" ] ]. append ( tick ) <TAB> <TAB> else : <TAB> <TAB> <TAB> ticker_ticks [ tick [ ""T"" ] ] = [ tick ] <TAB> super ( ). __init__ ( <TAB> <TAB> { ticker : Aggsv2 ( { ""results"" : ticks } ) for ticker, ticks in ticker_ticks. items ( ) } <TAB> )",False,ticker_ticks.get(tick['T']),tick['T'] in ticker_ticks,0.6608593463897705
|
||
|
4322,"def onMessage ( self, message, metadata ) : <TAB> if ""tags"" not in message : <TAB> <TAB> return ( message, metadata ) <TAB> if ""githubeventsqs"" not in message [ ""tags"" ] : <TAB> <TAB> return ( message, metadata ) <TAB> newmessage = { } <TAB> newmessage [ ""details"" ] = { } <TAB> newmessage [ ""category"" ] = ""github"" <TAB> newmessage [ ""tags"" ] = [ ""github"", ""webhook"" ] <TAB> newmessage [ ""eventsource"" ] = ""githubeventsqs"" <TAB> if ""event"" in message [ ""details"" ] : <TAB> <TAB> newmessage [ ""source"" ] = message [ ""details"" ] [ ""event"" ] <TAB> else : <TAB> <TAB> newmessage [ ""source"" ] = ""UNKNOWN"" <TAB> if ""request_id"" in message [ ""details"" ] : <TAB> <TAB> newmessage [ ""details"" ] [ ""request_id"" ] = message [ ""details"" ] [ ""request_id"" ] <TAB> else : <TAB> <TAB> newmessage [ ""details"" ] [ ""request_id"" ] = ""UNKNOWN"" <TAB> <TAB> if newmessage [ ""source"" ] in self. eventtypes : <TAB> <TAB> for key in self. yap [ newmessage [ ""source"" ] ] : <TAB> <TAB> <TAB> mappedvalue = jmespath. search ( self. yap [ newmessage [ ""source"" ] ] [ key ], message ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if mappedvalue is not None : <TAB> <TAB> <TAB> <TAB> newmessage [ ""details"" ] [ key ] = mappedvalue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> newmessage [ ""timestamp"" ] = newmessage [ ""details"" ] [ ""commit_ts"" ] <TAB> <TAB> <TAB> newmessage [ ""utctimestamp"" ] = toUTC ( <TAB> <TAB> <TAB> <TAB> newmessage [ ""details"" ] [ ""commit_ts"" ] <TAB> <TAB> <TAB> ). isoformat ( ) <",False,'commit_ts' in newmessage['details'],self.timestamp is not None,0.6526157259941101
|
||
|
4323,"def git_get_keywords ( versionfile_abs ) : <TAB> """"""Extract version information from the given file."""""" <TAB> <TAB> <TAB> <TAB> <TAB> keywords = { } <TAB> try : <TAB> <TAB> f = open ( versionfile_abs, ""r"" ) <TAB> <TAB> for line in f. readlines ( ) : <TAB> <TAB> <TAB> if line. strip ( ). startswith ( ""git_refnames ="" ) : <TAB> <TAB> <TAB> <TAB> mo = re. search ( r'=\s*""(.*)""', line ) <TAB> <TAB> <TAB> <TAB> if mo : <TAB> <TAB> <TAB> <TAB> <TAB> keywords [ ""refnames"" ] = mo. group ( 1 ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> mo = re. search ( r'=\s*""(.*)""', line ) <TAB> <TAB> <TAB> <TAB> if mo : <TAB> <TAB> <TAB> <TAB> <TAB> keywords [ ""full"" ] = mo. group ( 1 ) <TAB> <TAB> f. close ( ) <TAB> except EnvironmentError : <TAB> <TAB> pass <TAB> return keywords",False,line.strip().startswith('git_full ='),not keywords,0.6470040082931519
|
||
|
4324,"def _optimize_unicode ( charset, fixup ) : <TAB> try : <TAB> <TAB> import array <TAB> except ImportError : <TAB> <TAB> return charset <TAB> charmap = [ 0 ] * 65536 <TAB> negate = 0 <TAB> try : <TAB> <TAB> for op, av in charset : <TAB> <TAB> <TAB> if op is NEGATE : <TAB> <TAB> <TAB> <TAB> negate = 1 <TAB> <TAB> <TAB> elif op is LITERAL : <TAB> <TAB> <TAB> <TAB> charmap [ fixup ( av ) ] = 1 <TAB> <TAB> <TAB> elif op is RANGE : <TAB> <TAB> <TAB> <TAB> for i in xrange ( fixup ( av [ 0 ] ), fixup ( av [ 1 ] ) + 1 ) : <TAB> <TAB> <TAB> <TAB> <TAB> charmap [ i ] = 1 <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return charset <TAB> except IndexError : <TAB> <TAB> <TAB> <TAB> return charset <TAB> if negate : <TAB> <TAB> if sys. maxunicode!= 65535 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return charset <TAB> <TAB> for i in xrange ( 65536 ) : <TAB> <TAB> <TAB> charmap [ i ] = not charmap [ i ] <TAB> comps = { } <TAB> mapping = [ 0 ] * 256 <TAB> block = 0 <TAB> data = [ ] <TAB> for i in xrange ( 256 ) : <TAB> <TAB> chunk = tuple ( charmap [ i * 256 : ( i + 1 ) * 256 ] ) <TAB> <TAB> new = comps. setdefault ( chunk, block ) <TAB> <TAB> mapping [ i ] = new <TAB> <TAB> if new == block : <TAB> <TAB> <TAB> block = block + 1 <TAB> <TAB> <TAB> data = data + _mk_bitmap ( chunk ) <TAB> header = [ block ] <TAB> if _sre. CODESIZE ==",False,op is CATEGORY,len(charset) == 0,0.6826099157333374
|
||
|
4325,"def _verify_layer_file ( self, structure, layer_id ) : <TAB> """"""Verify layer file in repository"""""" <TAB> ( layer_algorithm, layer_hash ) = self. _split_layer_id ( layer_id ) <TAB> layer_f = structure [ ""repolayers"" ] [ layer_id ] [ ""layer_f"" ] <TAB> if not ( os. path. exists ( layer_f ) and os. path. islink ( layer_f ) ) : <TAB> <TAB> Msg ( ). err ( ""Error: layer data file symbolic link not found"", layer_id ) <TAB> <TAB> return False <TAB> if not os. path. exists ( self. cur_tagdir + ""/"" + os. readlink ( layer_f ) ) : <TAB> <TAB> Msg ( ). err ( ""Error: layer data file not found"" ) <TAB> <TAB> return False <TAB> if ""gzip"" in GuestInfo ( ""/"" ). get_filetype ( layer_f ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> Msg ( ). err ( ""Error: layer tar verify failed:"", layer_f ) <TAB> <TAB> <TAB> return False <TAB> if layer_algorithm : <TAB> <TAB> layer_f_chksum = ChkSUM ( ). hash ( layer_f, layer_algorithm ) <TAB> <TAB> if layer_f_chksum and layer_f_chksum!= layer_hash : <TAB> <TAB> <TAB> Msg ( ). err ( ""Error: layer file chksum failed:"", layer_f ) <TAB> <TAB> <TAB> return False <TAB> return True",False,not FileUtil(layer_f).verify_tar(),not os.path.exists(layer_f),0.6477632522583008
|
||
|
4326,"def TryMerge ( self, d ) : <TAB> while d. avail ( ) > 0 : <TAB> <TAB> tt = d. getVarInt32 ( ) <TAB> <TAB> if tt == 8 : <TAB> <TAB> <TAB> self. set_hits ( d. getVarUint64 ( ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if tt == 16 : <TAB> <TAB> <TAB> self. set_misses ( d. getVarUint64 ( ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if tt == 24 : <TAB> <TAB> <TAB> self. set_byte_hits ( d. getVarUint64 ( ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. set_items ( d. getVarUint64 ( ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if tt == 40 : <TAB> <TAB> <TAB> self. set_bytes ( d. getVarUint64 ( ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if tt == 53 : <TAB> <TAB> <TAB> self. set_oldest_item_age ( d. get32 ( ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if tt == 0 : <TAB> <TAB> <TAB> raise ProtocolBuffer. ProtocolBufferDecodeError <TAB> <TAB> d. skipData ( tt )",False,tt == 32,tt == 50,0.6858094930648804
|
||
|
4327,"def prepare_request ( next_link = None ) : <TAB> <TAB> header_parameters = { } <TAB> header_parameters [ ""Accept"" ] = self. _serialize. header ( ""accept"", accept, ""str"" ) <TAB> if not next_link : <TAB> <TAB> <TAB> <TAB> url = self. list_at_scope. metadata [ ""url"" ] <TAB> <TAB> path_format_arguments = { <TAB> <TAB> <TAB> ""scope"" : self. _serialize. url ( ""scope"", scope, ""str"", skip_quote = True ), <TAB> <TAB> } <TAB> <TAB> url = self. _client. format_url ( url, ** path_format_arguments ) <TAB> <TAB> <TAB> <TAB> query_parameters = { } <TAB> <TAB> if filter is not None : <TAB> <TAB> <TAB> query_parameters [ ""$filter"" ] = self. _serialize. query ( ""filter"", filter, ""str"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> query_parameters [ ""$top"" ] = self. _serialize. query ( ""top"", top, ""int"" ) <TAB> <TAB> query_parameters [ ""api-version"" ] = self. _serialize. query ( <TAB> <TAB> <TAB> ""api_version"", api_version, ""str"" <TAB> <TAB> ) <TAB> <TAB> request = self. _client. get ( url, query_parameters, header_parameters ) <TAB> else : <TAB> <TAB> url = next_link <TAB> <TAB> query_parameters = { } <TAB> <TAB> request = self. _client. get ( url, query_parameters, header_parameters ) <TAB> return request",True,top is not None,top is not None,0.6696810722351074
|
||
|
4328,"def put ( self, var, val, throw = False ) : <TAB> if self. prototype is None : <TAB> <TAB> desc = self. own. get ( var ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. par. put ( var, val, False ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if desc [ ""writable"" ] : <TAB> <TAB> <TAB> <TAB> desc [ ""value"" ] = val <TAB> else : <TAB> <TAB> if self. is_with_scope : <TAB> <TAB> <TAB> if self. own. has_property ( var ) : <TAB> <TAB> <TAB> <TAB> return self. own. put ( var, val, throw = throw ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> return self. prototype. put ( var, val ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> elif var in self. own : <TAB> <TAB> <TAB> self. own [ var ] = val <TAB> <TAB> <TAB> return val <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return self. prototype. put ( var, val )",False,desc is None,desc,0.6736911535263062
|
||
|
4329,"def _yield_minibatches_idx ( self, rgen, n_batches, data_ary, shuffle = True ) : <TAB> indices = np. arange ( data_ary. shape [ 0 ] ) <TAB> if shuffle : <TAB> <TAB> indices = rgen. permutation ( indices ) <TAB> if n_batches > 1 : <TAB> <TAB> remainder = data_ary. shape [ 0 ] % n_batches <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> minis = np. array_split ( indices [ : - remainder ], n_batches ) <TAB> <TAB> <TAB> minis [ - 1 ] = np. concatenate ( ( minis [ - 1 ], indices [ - remainder : ] ), axis = 0 ) <TAB> <TAB> else : <TAB> <TAB> <TAB> minis = np. array_split ( indices, n_batches ) <TAB> else : <TAB> <TAB> minis = ( indices, ) <TAB> for idx_batch in minis : <TAB> <TAB> yield idx_batch",False,remainder,remainder > 0,0.6923081874847412
|
||
|
4330,"def create_uas ( self, at_uas, root ) : <TAB> """"""Recreate uA's from the @ua nodes in the @uas tree."""""" <TAB> <TAB> <TAB> d = { } <TAB> for p in root. self_and_subtree ( copy = False ) : <TAB> <TAB> d [ p. v. gnx ] = p. copy ( ) <TAB> <TAB> for at_ua in at_uas. children ( ) : <TAB> <TAB> h, b = at_ua. h, at_ua. b <TAB> <TAB> gnx = h [ 4 : ]. strip ( ) <TAB> <TAB> if b and gnx and g. match_word ( h, 0, ""@ua"" ) : <TAB> <TAB> <TAB> p = d. get ( gnx ) <TAB> <TAB> <TAB> if p : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> lines = g. splitLines ( b ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> unl, ua = lines <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> unl, ua = None, b <TAB> <TAB> <TAB> <TAB> if ua. startswith ( ""ua:"" ) : <TAB> <TAB> <TAB> <TAB> <TAB> ua = ua [ 3 : ] <TAB> <TAB> <TAB> <TAB> if ua : <TAB> <TAB> <TAB> <TAB> <TAB> ua = self. unpickle ( ua ) <TAB> <TAB> <TAB> <TAB> <TAB> p. v. u = ua <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> g. trace ( ""Can not unpickle uA in"", p. h, repr ( unl ), type ( ua ), ua [ : 40 ] )",False,b.startswith('unl:') and len(lines) == 2,lines,0.6494481563568115
|
||
|
4331,"def get ( self, request, organization, team, project, rule_id = None ) : <TAB> if rule_id : <TAB> <TAB> try : <TAB> <TAB> <TAB> rule = Rule. objects. get ( project = project, id = rule_id ) <TAB> <TAB> except Rule. DoesNotExist : <TAB> <TAB> <TAB> path = reverse ( <TAB> <TAB> <TAB> <TAB> ""sentry-project-rules"", args = [ organization. slug, project. slug ] <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> return self. redirect ( path ) <TAB> else : <TAB> <TAB> rule = Rule ( project = project ) <TAB> action_list = [ ] <TAB> condition_list = [ ] <TAB> <TAB> for rule_type, rule_cls in rules : <TAB> <TAB> node = rule_cls ( project ) <TAB> <TAB> context = { <TAB> <TAB> <TAB> ""id"" : node. id, <TAB> <TAB> <TAB> ""label"" : node. label, <TAB> <TAB> <TAB> ""html"" : node. render_form ( ), <TAB> <TAB> } <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> condition_list. append ( context ) <TAB> <TAB> elif rule_type. startswith ( ""action/"" ) : <TAB> <TAB> <TAB> action_list. append ( context ) <TAB> context = { <TAB> <TAB> ""rule"" : rule, <TAB> <TAB> ""page"" : ""rules"", <TAB> <TAB> ""action_list"" : json. dumps ( action_list ), <TAB> <TAB> ""condition_list"" : json. dumps ( condition_list ), <TAB> } <TAB> return self. respond ( ""sentry/projects/rules/new.html"", context )",False,rule_type.startswith('condition/'),rule_type.startswith('action/'),0.6489495038986206
|
||
|
4332,"def __init__ ( self, factor, type, state, num_columns = None, categories = None ) : <TAB> self. factor = factor <TAB> self. type = type <TAB> if self. type not in [ ""numerical"", ""categorical"" ] : <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> ""FactorInfo.type must be "" <TAB> <TAB> <TAB> ""'numerical' or 'categorical', not %r"" % ( self. type, ) <TAB> <TAB> ) <TAB> self. state = state <TAB> if self. type == ""numerical"" : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( ""For numerical factors, num_columns "" ""must be an integer"" ) <TAB> <TAB> if categories is not None : <TAB> <TAB> <TAB> raise ValueError ( ""For numerical factors, categories "" ""must be None"" ) <TAB> else : <TAB> <TAB> assert self. type == ""categorical"" <TAB> <TAB> if num_columns is not None : <TAB> <TAB> <TAB> raise ValueError ( ""For categorical factors, num_columns "" ""must be None"" ) <TAB> <TAB> categories = tuple ( categories ) <TAB> self. num_columns = num_columns <TAB> self. categories = categories",False,"not isinstance(num_columns, six.integer_types)",num_columns is not None and num_columns is not None,0.650429368019104
|
||
|
4333,"def _bytecode_filenames ( self, py_filenames ) : <TAB> bytecode_files = [ ] <TAB> for py_file in py_filenames : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ext = os. path. splitext ( os. path. normcase ( py_file ) ) [ 1 ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> if self. compile : <TAB> <TAB> <TAB> bytecode_files. append ( py_file + ""c"" ) <TAB> <TAB> if self. optimize > 0 : <TAB> <TAB> <TAB> bytecode_files. append ( py_file + ""o"" ) <TAB> return bytecode_files",False,ext != PYTHON_SOURCE_EXTENSION,"ext.lower() in ['.c', '.c']",0.6576303243637085
|
||
|
4334,"def parse_enums ( html_dir, html_filename, enum_dict ) : <TAB> PARSE_ENUM_NAME = re. compile ( r""\s*enum\s+(\w+)\s*{"", re. I ). match <TAB> PARSE_ENUM_VALUE = re. compile ( r""\s*=\s+([0-9]+)\s*(?::\s*(.*))?"" ). match <TAB> tree = etree. parse ( os. path. join ( html_dir, html_filename ) ) <TAB> enums = find_enums ( tree ) <TAB> for enum in enums : <TAB> <TAB> enum_name = PARSE_ENUM_NAME ( collect_text ( enum ) ) <TAB> <TAB> if not enum_name : <TAB> <TAB> <TAB> continue <TAB> <TAB> enum_name = enum_name. group ( 1 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> print ( ""Found enum"", enum_name ) <TAB> <TAB> entries = [ ] <TAB> <TAB> for child in enum : <TAB> <TAB> <TAB> name = child. text <TAB> <TAB> <TAB> match = PARSE_ENUM_VALUE ( child. tail ) <TAB> <TAB> <TAB> if not match : <TAB> <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Ignoring enum %s (failed to parse field '%s')"" % ( enum_name, name ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> value, descr = match. groups ( ) <TAB> <TAB> <TAB> entries. append ( ( name, int ( value ), descr ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> enum_dict [ enum_name ] = entries <TAB> return enum_dict",False,enum_name not in ENUM_MAP,enum_name in enum_dict,0.6601797342300415
|
||
|
4335,"def newickize ( clade ) : <TAB> """"""Convert a node tree to a Newick tree string, recursively."""""" <TAB> label = clade. name or """" <TAB> if label : <TAB> <TAB> unquoted_label = re. match ( token_dict [ ""unquoted node label"" ], label ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> label = ""'%s'"" % label. replace ( ""\\"", ""\\\\"" ). replace ( ""'"", ""\\'"" ) <TAB> if clade. is_terminal ( ) : <TAB> <TAB> return label + make_info_string ( clade, terminal = True ) <TAB> else : <TAB> <TAB> subtrees = ( newickize ( sub ) for sub in clade ) <TAB> <TAB> return ""(%s)%s"" % ( "","". join ( subtrees ), label + make_info_string ( clade ) )",False,not unquoted_label or unquoted_label.end() < len(label),unquoted_label,0.6508289575576782
|
||
|
4336,"def fullmodname ( path ) : <TAB> """"""Return a plausible module name for the path."""""" <TAB> <TAB> <TAB> <TAB> <TAB> comparepath = os. path. normcase ( path ) <TAB> longest = """" <TAB> for dir in sys. path : <TAB> <TAB> dir = os. path. normcase ( dir ) <TAB> <TAB> if comparepath. startswith ( dir ) and comparepath [ len ( dir ) ] == os. sep : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> longest = dir <TAB> if longest : <TAB> <TAB> base = path [ len ( longest ) + 1 : ] <TAB> else : <TAB> <TAB> base = path <TAB> <TAB> drive, base = os. path. splitdrive ( base ) <TAB> base = base. replace ( os. sep, ""."" ) <TAB> if os. altsep : <TAB> <TAB> base = base. replace ( os. altsep, ""."" ) <TAB> filename, ext = os. path. splitext ( base ) <TAB> return filename. lstrip ( ""."" )",False,len(dir) > len(longest),path.startswith(dir),0.6505472660064697
|
||
|
4337,"def do ( self ) : <TAB> self. emit ( ""resolution-finding-start"" ) <TAB> try : <TAB> <TAB> logger. info ( ""Looking for resolution of device [%s]"" % ( self. __devid ) ) <TAB> <TAB> device = pyinsane. Scanner ( name = self. __devid ) <TAB> <TAB> sys. stdout. flush ( ) <TAB> <TAB> resolutions = device. options [ ""resolution"" ]. constraint <TAB> <TAB> logger. info ( ""Resolutions found: %s"" % str ( resolutions ) ) <TAB> <TAB> sys. stdout. flush ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> interval = resolutions [ 2 ] <TAB> <TAB> <TAB> if interval < 50 : <TAB> <TAB> <TAB> <TAB> interval = 50 <TAB> <TAB> <TAB> res_array = [ ] <TAB> <TAB> <TAB> for res in range ( resolutions [ 0 ], resolutions [ 1 ] + 1, interval ) : <TAB> <TAB> <TAB> <TAB> res_array. append ( res ) <TAB> <TAB> <TAB> resolutions = res_array <TAB> <TAB> for resolution in resolutions : <TAB> <TAB> <TAB> name = self. __get_resolution_name ( resolution ) <TAB> <TAB> <TAB> self. emit ( <TAB> <TAB> <TAB> <TAB> ""resolution-found"", <TAB> <TAB> <TAB> <TAB> name, <TAB> <TAB> <TAB> <TAB> resolution, <TAB> <TAB> <TAB> <TAB> ( resolution == self. __selected_resolution ), <TAB> <TAB> <TAB> ) <TAB> finally : <TAB> <TAB> self. emit ( ""resolution-finding-end"" )",False,"isinstance(resolutions, tuple)",resolutions[0] == self.__selected_resolution,0.656102180480957
|
||
|
4338,"def sendall ( self, data, flags = 0 ) : <TAB> if self. _sslobj : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""non-zero flags not allowed in calls to sendall() on %s"" <TAB> <TAB> <TAB> <TAB> % self. __class__ <TAB> <TAB> <TAB> ) <TAB> <TAB> amount = len ( data ) <TAB> <TAB> count = 0 <TAB> <TAB> while count < amount : <TAB> <TAB> <TAB> v = self. send ( data [ count : ] ) <TAB> <TAB> <TAB> count += v <TAB> <TAB> return amount <TAB> else : <TAB> <TAB> return socket. sendall ( self, data, flags )",True,flags != 0,flags != 0,0.6722278594970703
|
||
|
4339,"def get_local_wheel_metadata ( wheel_file ) : <TAB> <TAB> parsed_metadata = None <TAB> with io. open ( wheel_file, ""rb"" ) as fh : <TAB> <TAB> with zipfile. ZipFile ( fh, mode = ""r"", compression = zipfile. ZIP_DEFLATED ) as zf : <TAB> <TAB> <TAB> metadata = None <TAB> <TAB> <TAB> for fn in zf. namelist ( ) : <TAB> <TAB> <TAB> <TAB> if os. path. basename ( fn ) == ""METADATA"" : <TAB> <TAB> <TAB> <TAB> <TAB> metadata = fn <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise RuntimeError ( ""No metadata found in wheel: {0}"". format ( wheel_file ) ) <TAB> <TAB> <TAB> with zf. open ( metadata, ""r"" ) as metadata_fh : <TAB> <TAB> <TAB> <TAB> parsed_metadata = distlib. metadata. Metadata ( fileobj = metadata_fh ) <TAB> return parsed_metadata",True,metadata is None,metadata is None,0.6644433736801147
|
||
|
4340,"def _apply_abs_paths ( data, script_dir ) : <TAB> for flag_data in data. values ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> default = flag_data. get ( ""default"" ) <TAB> <TAB> if ( <TAB> <TAB> <TAB> not default <TAB> <TAB> <TAB> or not isinstance ( default, six. string_types ) <TAB> <TAB> <TAB> or os. path. sep not in default <TAB> <TAB> ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> abs_path = os. path. join ( script_dir, default ) <TAB> <TAB> if os. path. exists ( abs_path ) : <TAB> <TAB> <TAB> flag_data [ ""default"" ] = abs_path",False,"not isinstance(flag_data, dict)",'default' not in flag_data,0.647739052772522
|
||
|
4341,"def get_object ( self ) : <TAB> settings_qs = self. get_queryset ( ) <TAB> registered_settings = settings_registry. get_registered_settings ( <TAB> <TAB> category_slug = self. category_slug, <TAB> ) <TAB> all_settings = { } <TAB> for setting in settings_qs : <TAB> <TAB> all_settings [ setting. key ] = setting. value <TAB> for key in registered_settings : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> try : <TAB> <TAB> <TAB> field = settings_registry. get_setting_field ( <TAB> <TAB> <TAB> <TAB> key, for_user = bool ( self. category_slug == ""user"" ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> all_settings [ key ] = field. get_default ( ) <TAB> <TAB> except serializers. SkipField : <TAB> <TAB> <TAB> all_settings [ key ] = None <TAB> all_settings [ ""user"" ] = self. request. user if self. category_slug == ""user"" else None <TAB> obj = type ( ""Settings"", ( object, ), all_settings ) ( ) <TAB> self. check_object_permissions ( self. request, obj ) <TAB> return obj",False,key in all_settings or self.category_slug == 'changed',key in settings_registry.get_setting_keys(),0.6515622735023499
|
||
|
4342,"def exists ( self, hash, want_source = False ) : <TAB> """"""Return nonempty if the object exists in the index files."""""" <TAB> global _total_searches, _total_steps <TAB> _total_searches += 1 <TAB> want = str ( hash ) <TAB> el = extract_bits ( want, self. bits ) <TAB> if el : <TAB> <TAB> start = self. _fanget ( el - 1 ) <TAB> <TAB> startv = el << ( 32 - self. bits ) <TAB> else : <TAB> <TAB> start = 0 <TAB> <TAB> startv = 0 <TAB> end = self. _fanget ( el ) <TAB> endv = ( el + 1 ) << ( 32 - self. bits ) <TAB> _total_steps += 1 <TAB> hashv = _helpers. firstword ( hash ) <TAB> <TAB> while start < end : <TAB> <TAB> _total_steps += 1 <TAB> <TAB> <TAB> <TAB> mid = start + ( hashv - startv ) * ( end - start - 1 ) / ( endv - startv ) <TAB> <TAB> <TAB> <TAB> v = self. _get ( mid ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> start = mid + 1 <TAB> <TAB> <TAB> startv = _helpers. firstword ( v ) <TAB> <TAB> elif v > want : <TAB> <TAB> <TAB> end = mid <TAB> <TAB> <TAB> endv = _helpers. firstword ( v ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return want_source and self. _get_idxname ( mid ) or True <TAB> return None",False,v < want,v > want,0.6707136631011963
|
||
|
4343,"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. request = TDropPrivilegesRequest ( ) <TAB> <TAB> <TAB> <TAB> self. request. 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 ( )",False,ftype == TType.STRUCT,self.request is not None,0.6621614694595337
|
||
|
4344,"def update_decoder_attention_history ( cache ) : <TAB> """"""Save attention weights in cache, e.g., for vizualization."""""" <TAB> for k in [ <TAB> <TAB> x <TAB> <TAB> for x in self. attention_weights <TAB> <TAB> if ""decoder"" in x and ""self"" not in x and ""logits"" not in x <TAB> ] : <TAB> <TAB> idx = k. find ( ""layer_"" ) <TAB> <TAB> if idx < 0 : <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> layer_nbr = k [ idx + 6 : ] <TAB> <TAB> idx = 0 <TAB> <TAB> while idx + 1 < len ( layer_nbr ) and layer_nbr [ : idx + 1 ]. isdigit ( ) : <TAB> <TAB> <TAB> idx += 1 <TAB> <TAB> layer_nbr = ""layer_%d"" % int ( layer_nbr [ : idx ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> cache [ ""attention_history"" ] [ layer_nbr ] = tf. concat ( <TAB> <TAB> <TAB> <TAB> [ cache [ ""attention_history"" ] [ layer_nbr ], self. attention_weights [ k ] ], <TAB> <TAB> <TAB> <TAB> axis = 2, <TAB> <TAB> <TAB> )",False,layer_nbr in cache['attention_history'],layer_nbr in cache,0.6555109024047852
|
||
|
4345,"def set_with_index_array ( self, item, value, check_units ) : <TAB> variable = self. variable <TAB> if check_units : <TAB> <TAB> fail_for_dimension_mismatch ( <TAB> <TAB> <TAB> variable. dim, value, ""Incorrect unit for setting variable %s"" % self. name <TAB> <TAB> ) <TAB> if variable. scalar : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise IndexError ( <TAB> <TAB> <TAB> <TAB> ( ""Illegal index for variable %s, it is a "" ""scalar variable."" ) <TAB> <TAB> <TAB> <TAB> % self. name <TAB> <TAB> <TAB> ) <TAB> <TAB> indices = 0 <TAB> elif isinstance ( item, slice ) and item == slice ( None ) and self. index_var == ""_idx"" : <TAB> <TAB> indices = slice ( None ) <TAB> else : <TAB> <TAB> indices = self. indexing ( item, self. index_var ) <TAB> <TAB> q = Quantity ( value, copy = False ) <TAB> <TAB> if len ( q. shape ) : <TAB> <TAB> <TAB> if not len ( q. shape ) == 1 or len ( q )!= 1 and len ( q )!= len ( indices ) : <TAB> <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> <TAB> ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""Provided values do not match the size "" <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""of the indices, "" <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""%d!= %d."" <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> % ( len ( q ), len ( indices ) ) <TAB> <TAB> <TAB> <TAB> ) <TAB> variable. get_value ( ) [ indices ] = value",False,"not (isinstance(item, slice) and item == slice(None))",variable.get_value() is None,0.6586532592773438
|
||
|
4346,"def add_callback ( self, callback, * args, ** kwargs ) : <TAB> if thread. get_ident ( )!= self. _thread_ident : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> with self. _callback_lock : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> list_empty = not self. _callbacks <TAB> <TAB> <TAB> self. _callbacks. append ( <TAB> <TAB> <TAB> <TAB> functools. partial ( stack_context. wrap ( callback ), * args, ** kwargs ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if list_empty : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _waker. wake ( ) <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _callbacks. append ( <TAB> <TAB> <TAB> functools. partial ( stack_context. wrap ( callback ), * args, ** kwargs ) <TAB> <TAB> )",False,self._closing,self._callbacks is None,0.676455557346344
|
||
|
4347,"def getoutput ( self ) : <TAB> """"""convert the dtd entity back to string form"""""" <TAB> lines = [ ] <TAB> lines. extend ( [ comment for commenttype, comment in self. comments ] ) <TAB> lines. extend ( self. unparsedlines ) <TAB> if self. isnull ( ) : <TAB> <TAB> result = """". join ( lines ) <TAB> <TAB> return result. rstrip ( ) + ""\n"" <TAB> <TAB> <TAB> <TAB> <TAB> if len ( self. entity ) > 0 : <TAB> <TAB> if getattr ( self, ""entitytype"", None ) == ""external"" : <TAB> <TAB> <TAB> entityline = ( <TAB> <TAB> <TAB> <TAB> ""<!ENTITY % "" <TAB> <TAB> <TAB> <TAB> + self. entity <TAB> <TAB> <TAB> <TAB> + "" "" <TAB> <TAB> <TAB> <TAB> + self. entityparameter <TAB> <TAB> <TAB> <TAB> + "" "" <TAB> <TAB> <TAB> <TAB> + self. definition <TAB> <TAB> <TAB> <TAB> + self. closing <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> entityline = ( <TAB> <TAB> <TAB> <TAB> ""<!ENTITY"" <TAB> <TAB> <TAB> <TAB> + self. space_pre_entity <TAB> <TAB> <TAB> <TAB> + self. entity <TAB> <TAB> <TAB> <TAB> + self. space_pre_definition <TAB> <TAB> <TAB> <TAB> + self. definition <TAB> <TAB> <TAB> <TAB> + self. closing <TAB> <TAB> <TAB> ) <TAB> <TAB> if getattr ( self, ""hashprefix"", None ) : <TAB> <TAB> <TAB> entityline = self. hashprefix + "" "" + entityline <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> entityline = entityline. encode ( ""UTF-8"" ) <TAB> <TAB> lines. append ( entityline + ""\n"" ) <",True,"isinstance(entityline, unicode)","isinstance(entityline, unicode)",0.649613618850708
|
||
|
4348,"def get_all_hashes ( self ) : <TAB> event_hashes = [ ] <TAB> sample_hashes = [ ] <TAB> for a in self. event. attributes : <TAB> <TAB> h = None <TAB> <TAB> if a. type in ( ""md5"", ""sha1"", ""sha256"" ) : <TAB> <TAB> <TAB> h = a. value <TAB> <TAB> <TAB> event_hashes. append ( h ) <TAB> <TAB> elif a. type in ( ""filename|md5"", ""filename|sha1"", ""filename|sha256"" ) : <TAB> <TAB> <TAB> h = a. value. split ( ""|"" ) [ 1 ] <TAB> <TAB> <TAB> event_hashes. append ( h ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> h = a. value. split ( ""|"" ) [ 1 ] <TAB> <TAB> <TAB> sample_hashes. append ( h ) <TAB> return event_hashes, sample_hashes",False,a.type == 'malware-sample',"a.type in ( ""sample_hash""",0.6484647989273071
|
||
|
4349,"def sortModules ( self ) : <TAB> super ( NeuronDecomposableNetwork, self ). sortModules ( ) <TAB> self. _constructParameterInfo ( ) <TAB> <TAB> self. decompositionIndices = { } <TAB> for neuron in self. _neuronIterator ( ) : <TAB> <TAB> self. decompositionIndices [ neuron ] = [ ] <TAB> for w in range ( self. paramdim ) : <TAB> <TAB> inneuron, outneuron = self. paramInfo [ w ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. decompositionIndices [ inneuron ]. append ( w ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. decompositionIndices [ outneuron ]. append ( w )",False,self.espStyleDecomposition and outneuron[0] in self.outmodules,inneuron in self.decompositionIndices,0.6543204188346863
|
||
|
4350,"def _updateCache ( request_headers, response_headers, content, cache, cachekey ) : <TAB> if cachekey : <TAB> <TAB> cc = _parse_cache_control ( request_headers ) <TAB> <TAB> cc_response = _parse_cache_control ( response_headers ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> cache. delete ( cachekey ) <TAB> <TAB> else : <TAB> <TAB> <TAB> info = email. Message. Message ( ) <TAB> <TAB> <TAB> for key, value in response_headers. iteritems ( ) : <TAB> <TAB> <TAB> <TAB> if key not in [ ""status"", ""content-encoding"", ""transfer-encoding"" ] : <TAB> <TAB> <TAB> <TAB> <TAB> info [ key ] = value <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> vary = response_headers. get ( ""vary"", None ) <TAB> <TAB> <TAB> if vary : <TAB> <TAB> <TAB> <TAB> vary_headers = vary. lower ( ). replace ( "" "", """" ). split ( "","" ) <TAB> <TAB> <TAB> <TAB> for header in vary_headers : <TAB> <TAB> <TAB> <TAB> <TAB> key = ""-varied-%s"" % header <TAB> <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> info [ key ] = request_headers [ header ] <TAB> <TAB> <TAB> <TAB> <TAB> except KeyError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> status = response_headers. status <TAB> <TAB> <TAB> if status == 304 : <TAB> <TAB> <TAB> <TAB> status = 200 <TAB> <TAB> <TAB> status_header = ""status: %d\r\n"" % status <TAB> <TAB> <TAB> header_str = info. as_string ( ) <TAB> <TAB> <TAB>",False,cc.has_key('no-store') or cc_response.has_key('no-store'),cachekey,0.6491734981536865
|
||
|
4351,"def _conv_layer ( self, sess, bottom, name, trainable = True, padding = ""SAME"", relu = True ) : <TAB> with tf. variable_scope ( name ) as scope : <TAB> <TAB> filt = self. _get_conv_filter ( sess, name, trainable = trainable ) <TAB> <TAB> conv_biases = self. _get_bias ( sess, name, trainable = trainable ) <TAB> <TAB> conv = tf. nn. conv2d ( bottom, filt, [ 1, 1, 1, 1 ], padding = padding ) <TAB> <TAB> bias = tf. nn. bias_add ( conv, conv_biases ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> bias = tf. nn. relu ( bias ) <TAB> <TAB> return bias",True,relu,relu,0.680166482925415
|
||
|
4352,"def _set_transform ( self ) : <TAB> ax = self. ax <TAB> if self. units in ( ""x"", ""y"" ) : <TAB> <TAB> if self. units == ""x"" : <TAB> <TAB> <TAB> dx0 = ax. viewLim. width <TAB> <TAB> <TAB> dx1 = ax. bbox. width <TAB> <TAB> else : <TAB> <TAB> <TAB> dx0 = ax. viewLim. height <TAB> <TAB> <TAB> dx1 = ax. bbox. height <TAB> <TAB> dx = dx1 / dx0 <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> dx = ax. bbox. width <TAB> <TAB> elif self. units == ""height"" : <TAB> <TAB> <TAB> dx = ax. bbox. height <TAB> <TAB> elif self. units == ""dots"" : <TAB> <TAB> <TAB> dx = 1.0 <TAB> <TAB> elif self. units == ""inches"" : <TAB> <TAB> <TAB> dx = ax. figure. dpi <TAB> <TAB> else : <TAB> <TAB> <TAB> raise ValueError ( ""unrecognized units"" ) <TAB> trans = transforms. Affine2D ( ). scale ( dx ) <TAB> self. set_transform ( trans ) <TAB> return trans",True,self.units == 'width',self.units == 'width',0.6595195531845093
|
||
|
4353,"def disconnect_application ( self ) : <TAB> if not self. is_app_running ( self. APP_BACKDROP ) : <TAB> <TAB> self. socket. send ( commands. CloseCommand ( destination_id = False ) ) <TAB> <TAB> start_time = time. time ( ) <TAB> <TAB> while not self. is_app_running ( None ) : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> self. socket. send_and_wait ( commands. StatusCommand ( ) ) <TAB> <TAB> <TAB> except cast_socket. ConnectionTerminatedException : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> current_time = time. time ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise TimeoutException ( ) <TAB> <TAB> <TAB> time. sleep ( self. WAIT_INTERVAL ) <TAB> else : <TAB> <TAB> logger. debug ( ""Closing not necessary. Backdrop is running..."" )",False,current_time - start_time > self.timeout,current_time - start_time > self.WAIT_INTERVAL,0.6519465446472168
|
||
|
4354,"def cleanDataCmd ( cmd ) : <TAB> newcmd = ""AbracadabrA ** <?php "" <TAB> if cmd [ : 6 ]!= ""php://"" : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> cmds = cmd. split ( ""&"" ) <TAB> <TAB> <TAB> for c in cmds : <TAB> <TAB> <TAB> <TAB> if len ( c ) > 0 : <TAB> <TAB> <TAB> <TAB> <TAB> newcmd += ""system('%s');"" % c <TAB> <TAB> else : <TAB> <TAB> <TAB> b64cmd = base64. b64encode ( cmd ) <TAB> <TAB> <TAB> newcmd += ""system(base64_decode('%s'));"" % b64cmd <TAB> else : <TAB> <TAB> newcmd += cmd [ 6 : ] <TAB> newcmd += ""?> **"" <TAB> return newcmd",False,reverseConn not in cmd,len(cmd) > 0,0.6773138046264648
|
||
|
4355,"def main ( args ) : <TAB> cfg = setup ( args ) <TAB> <TAB> <TAB> PathManager. set_strict_kwargs_checking ( False ) <TAB> if args. eval_only : <TAB> <TAB> model = Trainer. build_model ( cfg ) <TAB> <TAB> DensePoseCheckpointer ( model, save_dir = cfg. OUTPUT_DIR ). resume_or_load ( <TAB> <TAB> <TAB> cfg. MODEL. WEIGHTS, resume = args. resume <TAB> <TAB> ) <TAB> <TAB> res = Trainer. test ( cfg, model ) <TAB> <TAB> if cfg. TEST. AUG. ENABLED : <TAB> <TAB> <TAB> res. update ( Trainer. test_with_TTA ( cfg, model ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> verify_results ( cfg, res ) <TAB> <TAB> return res <TAB> trainer = Trainer ( cfg ) <TAB> trainer. resume_or_load ( resume = args. resume ) <TAB> if cfg. TEST. AUG. ENABLED : <TAB> <TAB> trainer. register_hooks ( <TAB> <TAB> <TAB> [ hooks. EvalHook ( 0, lambda : trainer. test_with_TTA ( cfg, trainer. model ) ) ] <TAB> <TAB> ) <TAB> return trainer. train ( )",False,comm.is_main_process(),res is not None,0.6495720744132996
|
||
|
4356,"def handle ( self, context, sign, * args ) : <TAB> if context. rounding in ( ROUND_HALF_UP, ROUND_HALF_EVEN, ROUND_HALF_DOWN, ROUND_UP ) : <TAB> <TAB> return Infsign [ sign ] <TAB> if sign == 0 : <TAB> <TAB> if context. rounding == ROUND_CEILING : <TAB> <TAB> <TAB> return Infsign [ sign ] <TAB> <TAB> return Decimal ( ( sign, ( 9, ) * context. prec, context. Emax - context. prec + 1 ) ) <TAB> if sign == 1 : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return Infsign [ sign ] <TAB> <TAB> return Decimal ( ( sign, ( 9, ) * context. prec, context. Emax - context. prec + 1 ) )",False,context.rounding == ROUND_FLOOR,context.rounding == ROUND_CEILING_TAB,0.6555569171905518
|
||
|
4357,"def findChapterNameForPosition ( self, p ) : <TAB> """"""Return the name of a chapter containing p or None if p does not exist."""""" <TAB> cc, c = self, self. c <TAB> if not p or not c. positionExists ( p ) : <TAB> <TAB> return None <TAB> for name in cc. chaptersDict : <TAB> <TAB> if name!= ""main"" : <TAB> <TAB> <TAB> theChapter = cc. chaptersDict. get ( name ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return name <TAB> return ""main""",False,theChapter.positionIsInChapter(p),theChapter and theChapter.nameExists(p),0.6569643020629883
|
||
|
4358,"def validate_matrix ( matrix ) : <TAB> if not matrix : <TAB> <TAB> return None <TAB> for key, value in matrix. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValidationError ( <TAB> <TAB> <TAB> <TAB> ""`{}` defines a non uniform distribution, "" <TAB> <TAB> <TAB> <TAB> ""and it cannot be used with bayesian optimization."". format ( key ) <TAB> <TAB> <TAB> ) <TAB> return matrix",False,value.is_distribution and (not value.is_uniform),"not (isinstance(value, torch.Tensor) and value.is_uniform)",0.6517713069915771
|
||
|
4359,"def master_param_to_train_param ( master_params_grads, params_grads, main_prog ) : <TAB> for idx, m_p_g in enumerate ( master_params_grads ) : <TAB> <TAB> train_p, _ = params_grads [ idx ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> with main_prog. _optimized_guard ( [ m_p_g [ 0 ], m_p_g [ 1 ] ] ) : <TAB> <TAB> <TAB> append_cast_op ( m_p_g [ 0 ], train_p, main_prog )",False,train_p.name.find('layer_norm') > -1,train_p.name.startswith('feature_preprocessor:tnn.nn.Conv1d),0.6489761471748352
|
||
|
4360,"def get_recursively_referenced_fragments ( self, operation ) : <TAB> assert isinstance ( operation, OperationDefinition ) <TAB> fragments = self. _recursively_referenced_fragments. get ( operation ) <TAB> if not fragments : <TAB> <TAB> fragments = [ ] <TAB> <TAB> collected_names = set ( ) <TAB> <TAB> nodes_to_visit = [ operation. selection_set ] <TAB> <TAB> while nodes_to_visit : <TAB> <TAB> <TAB> node = nodes_to_visit. pop ( ) <TAB> <TAB> <TAB> spreads = self. get_fragment_spreads ( node ) <TAB> <TAB> <TAB> for spread in spreads : <TAB> <TAB> <TAB> <TAB> frag_name = spread. name. value <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> collected_names. add ( frag_name ) <TAB> <TAB> <TAB> <TAB> <TAB> fragment = self. get_fragment ( frag_name ) <TAB> <TAB> <TAB> <TAB> <TAB> if fragment : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> fragments. append ( fragment ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> nodes_to_visit. append ( fragment. selection_set ) <TAB> <TAB> self. _recursively_referenced_fragments [ operation ] = fragments <TAB> return fragments",True,frag_name not in collected_names,frag_name not in collected_names,0.657961368560791
|
||
|
4361,"def hold ( self ) : <TAB> dire = 1 <TAB> while True : <TAB> <TAB> try : <TAB> <TAB> <TAB> if time == None : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> time. sleep ( 0.05 ) <TAB> <TAB> <TAB> tasks = TaskManager. get ( ) <TAB> <TAB> <TAB> if len ( tasks ) == 0 : <TAB> <TAB> <TAB> <TAB> if self. pro_bar. IsShown ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> wx. CallAfter ( self. set_progress, - 1 ) <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> arr = [ i. prgs for i in tasks ] <TAB> <TAB> <TAB> if ( None, 1 ) in arr : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> dire = 1 <TAB> <TAB> <TAB> <TAB> if self. pro_bar. GetValue ( ) >= 100 : <TAB> <TAB> <TAB> <TAB> <TAB> dire = - 1 <TAB> <TAB> <TAB> <TAB> v = self. pro_bar. GetValue ( ) + dire * 5 <TAB> <TAB> <TAB> <TAB> wx. CallAfter ( self. set_progress, v ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> v = max ( [ ( i [ 0 ] + 1 ) * 100.0 / i [ 1 ] for i in arr ] ) <TAB> <TAB> <TAB> <TAB> wx. CallAfter ( self. set_progress, v ) <TAB> <TAB> except : <TAB> <TAB> <TAB> pass",False,self.pro_bar.GetValue() <= 0,dire == None,0.6528546810150146
|
||
|
4362,"def test_wrong_bind ( ) : <TAB> N = 1024 <TAB> A = te. placeholder ( ( N, N - 1 ), name = ""A"" ) <TAB> B = te. compute ( ( N, N - 1 ), lambda i, j : A [ i, j ] ) <TAB> s = te. create_schedule ( [ B. op ] ) <TAB> <TAB> s [ B ]. bind ( s [ B ]. op. axis [ 0 ], te. thread_axis ( ""threadIdx.x"" ) ) <TAB> s [ B ]. bind ( s [ B ]. op. axis [ 1 ], te. thread_axis ( ""threadIdx.x"" ) ) <TAB> for target in [ ""opencl"", ""cuda"" ] : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> valid = [ None ] <TAB> <TAB> with tvm. transform. PassContext ( <TAB> <TAB> <TAB> config = { <TAB> <TAB> <TAB> <TAB> ""tir.add_lower_pass"" : [ <TAB> <TAB> <TAB> <TAB> <TAB> ( 2, get_verify_pass ( valid, max_threads_per_block = N * N ) ) <TAB> <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> } <TAB> <TAB> ) : <TAB> <TAB> <TAB> tvm. build ( s, [ A, B ], target ) <TAB> <TAB> assert not valid [ 0 ]",False,not tvm.testing.device_enabled(target),"target in ['cl', 'tir.connect', 'tir.connect', 'connect']",0.6482490301132202
|
||
|
4363,"def librato_record ( name, value ) : <TAB> global _librato, _librato_lock, _librato_aggregator, _librato_timer, _librato_start <TAB> if _librato is None : <TAB> <TAB> return <TAB> try : <TAB> <TAB> name = ""."". join ( [ env. APP, env. NAME, name ] ) <TAB> <TAB> with _librato_lock : <TAB> <TAB> <TAB> _librato_cancel_timer ( ) <TAB> <TAB> <TAB> if _librato_aggregator is None : <TAB> <TAB> <TAB> <TAB> _librato_aggregator = Aggregator ( _librato, source = env. HOST ) <TAB> <TAB> <TAB> <TAB> _librato_start = time. time ( ) <TAB> <TAB> <TAB> _librato_aggregator. add ( name, value ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> librato_submit ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> _librato_timer = threading. Timer ( <TAB> <TAB> <TAB> <TAB> <TAB> LIBRATO_MIN_AGGREGATION_PERIOD, librato_submit <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> _librato_timer. start ( ) <TAB> except : <TAB> <TAB> report_exception ( )",False,time.time() - _librato_start > LIBRATO_MAX_AGGREGATION_PERIOD,_librato_start - _librato_start > 0,0.6539208889007568
|
||
|
4364,"def scan_resource_conf ( self, conf ) : <TAB> if ""policy"" in conf. keys ( ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> policy_block = json. loads ( conf [ ""policy"" ] [ 0 ] ) <TAB> <TAB> <TAB> if ""Statement"" in policy_block. keys ( ) : <TAB> <TAB> <TAB> <TAB> for statement in force_list ( policy_block [ ""Statement"" ] ) : <TAB> <TAB> <TAB> <TAB> <TAB> if ""Action"" in statement : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> effect = statement. get ( ""Effect"", ""Allow"" ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> action = force_list ( statement. get ( ""Action"", [ """" ] ) ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> resource = force_list ( statement. get ( ""Resource"", [ """" ] ) ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return CheckResult. FAILED <TAB> <TAB> except : <TAB> <TAB> <TAB> pass <TAB> return CheckResult. PASSED",False,effect == 'Allow' and '*' in action and ('*' in resource),resource is not None and self.has_resource(resource),0.6546757817268372
|
||
|
4365,"def pickPath ( self, color ) : <TAB> self. path [ color ] = ( ) <TAB> currentPos = self. starts [ color ] <TAB> while True : <TAB> <TAB> minDist = None <TAB> <TAB> minGuide = None <TAB> <TAB> for guide in self. guides [ color ] : <TAB> <TAB> <TAB> guideDist = dist ( currentPos, guide ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> minDist = guideDist <TAB> <TAB> <TAB> <TAB> minGuide = guide <TAB> <TAB> if dist ( currentPos, self. ends [ color ] ) == 1 : <TAB> <TAB> <TAB> return <TAB> <TAB> if minGuide == None : <TAB> <TAB> <TAB> return <TAB> <TAB> self. path [ color ] = self. path [ color ] + ( minGuide, ) <TAB> <TAB> currentPos = minGuide <TAB> <TAB> self. guides [ color ]. remove ( minGuide )",False,minDist == None or guideDist < minDist,minDist == None,0.6549274325370789
|
||
|
4366,"def __new__ ( metacls, typename, bases, namespace ) : <TAB> annotations = namespace. get ( ""__annotations__"", { } ) <TAB> for t in annotations. values ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> for ut in t. __args__ : <TAB> <TAB> <TAB> <TAB> _assert_tensorizer_type ( ut ) <TAB> <TAB> else : <TAB> <TAB> <TAB> _assert_tensorizer_type ( t ) <TAB> return super ( ). __new__ ( metacls, typename, bases, namespace )",False,"getattr(t, '__origin__', '') is Union","hasattr(t, '__args__')",0.6505976915359497
|
||
|
4367,"def stage_node_label ( stage ) : <TAB> """"""Return a html format label for the given stage."""""" <TAB> rows = max ( 1, max ( len ( stage [ ""output_tensors"" ] ), len ( stage [ ""input_tensors"" ] ) ) ) <TAB> label = '<<TABLE BORDER=""0"" CELLBORDER=""1"" CELLSPACING=""0""''CELLPADDING=""4"">' <TAB> for i in range ( rows ) : <TAB> <TAB> label += ""<TR>"" <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> port_id = get_port_id ( True, i ) <TAB> <TAB> <TAB> label += ( <TAB> <TAB> <TAB> <TAB> '<TD BGCOLOR=""lightgrey"" COLSPAN=""2"" PORT=""' <TAB> <TAB> <TAB> <TAB> + port_id <TAB> <TAB> <TAB> <TAB> + '"">' <TAB> <TAB> <TAB> <TAB> + str ( i ) <TAB> <TAB> <TAB> <TAB> + ""</TD>"" <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> label += '<TD BGCOLOR=""white"" COLSPAN=""2""></TD>' <TAB> <TAB> if i == 0 : <TAB> <TAB> <TAB> label += ( <TAB> <TAB> <TAB> <TAB> '<TD BGCOLOR=""white"" COLSPAN=""2"" ROWSPAN=""' <TAB> <TAB> <TAB> <TAB> + str ( rows ) <TAB> <TAB> <TAB> <TAB> + '"">' <TAB> <TAB> <TAB> <TAB> + stage_label ( stage ) <TAB> <TAB> <TAB> <TAB> + ""</TD>"" <TAB> <TAB> <TAB> ) <TAB> <TAB> if i < len ( stage [ ""output_tensors"" ] ) : <TAB> <TAB> <TAB> port_id = get_port_id ( False, i ) <TAB> <TAB> <TAB> label += ( <TAB> <TAB> <TAB> <TAB> '<TD BGCOLOR=""lightgrey"" COLSPAN",False,i < len(stage['input_tensors']),"i < len(stage[""output_tensors'])",0.6572393178939819
|
||
|
4368,"def _send_closing_frame ( self, ignore_send_errors = False, close_data = None ) : <TAB> if self. version in ( 8, 13 ) and not self. websocket_closed : <TAB> <TAB> if close_data is not None : <TAB> <TAB> <TAB> status, msg = close_data <TAB> <TAB> <TAB> if isinstance ( msg, six. text_type ) : <TAB> <TAB> <TAB> <TAB> msg = msg. encode ( ""utf-8"" ) <TAB> <TAB> <TAB> data = struct. pack ( ""!H"", status ) + msg <TAB> <TAB> else : <TAB> <TAB> <TAB> data = """" <TAB> <TAB> try : <TAB> <TAB> <TAB> self. send ( data, control_code = 8 ) <TAB> <TAB> except SocketError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise <TAB> <TAB> self. websocket_closed = True",False,not ignore_send_errors,ignore_send_errors,0.652285099029541
|
||
|
4369,"def calcPolygonRect ( pointArray ) : <TAB> """"""receives a point list and returns the rect that contains them as a tupple -> tuple left, top, right, bottom"""""" <TAB> <TAB> l, t, r, b = 10000000, 10000000, - 10000000, - 10000000 <TAB> <TAB> <TAB> <TAB> <TAB> for n in pointArray : <TAB> <TAB> if n [ 0 ] < l : <TAB> <TAB> <TAB> l = n [ 0 ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> r = n [ 0 ] <TAB> <TAB> if n [ 1 ] < t : <TAB> <TAB> <TAB> t = n [ 1 ] <TAB> <TAB> if n [ 1 ] > b : <TAB> <TAB> <TAB> b = n [ 1 ] <TAB> return l, t, r, b",False,n[0] > r,n[0] < r,0.6681976914405823
|
||
|
4370,"def decode ( self, ids ) : <TAB> ids = pad_decr ( ids ) <TAB> tokens = [ ] <TAB> for int_id in ids : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> tokens. append ( self. _vocab_list [ int_id ] ) <TAB> <TAB> else : <TAB> <TAB> <TAB> tokens. append ( self. _oov_token ) <TAB> return self. _decode_token_separator. join ( tokens )",False,int_id < len(self._vocab_list),int_id in self._vocab_list,0.6535089015960693
|
||
|
4371,"def edit_file ( self, filename ) : <TAB> import subprocess <TAB> editor = self. get_editor ( ) <TAB> if self. env : <TAB> <TAB> environ = os. environ. copy ( ) <TAB> <TAB> environ. update ( self. env ) <TAB> else : <TAB> <TAB> environ = None <TAB> try : <TAB> <TAB> c = subprocess. Popen ( '%s ""%s""' % ( editor, filename ), env = environ, shell = True ) <TAB> <TAB> exit_code = c. wait ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ClickException ( ""%s: Editing failed!"" % editor ) <TAB> except OSError as e : <TAB> <TAB> raise ClickException ( ""%s: Editing failed: %s"" % ( editor, e ) )",True,exit_code != 0,exit_code != 0,0.6593523025512695
|
||
|
4372,"def is_valid ( self ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> import lfs. shipping. utils <TAB> if isinstance ( self. content, ShippingMethod ) : <TAB> <TAB> is_shipping_method = True <TAB> else : <TAB> <TAB> is_shipping_method = False <TAB> if ( not is_shipping_method ) and ( self. operator == self. IS_SELECTED ) : <TAB> <TAB> shipping_method = lfs. shipping. utils. get_selected_shipping_method ( self. request ) <TAB> <TAB> return shipping_method in self. value. all ( ) <TAB> elif ( not is_shipping_method ) and ( self. operator == self. IS_NOT_SELECTED ) : <TAB> <TAB> shipping_method = lfs. shipping. utils. get_selected_shipping_method ( self. request ) <TAB> <TAB> return shipping_method not in self. value. all ( ) <TAB> elif self. operator == self. IS_VALID : <TAB> <TAB> for sm in self. value. all ( ) : <TAB> <TAB> <TAB> if not lfs. criteria. utils. is_valid ( self. request, sm, self. product ) : <TAB> <TAB> <TAB> <TAB> return False <TAB> <TAB> return True <TAB> elif self. operator == self. IS_NOT_VALID : <TAB> <TAB> for sm in self. value. all ( ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return False <TAB> <TAB> return True <TAB> else : <TAB> <TAB> return False",False,"lfs.criteria.utils.is_valid(self.request, sm, self.product)",not lfs.criteria.is_valid(sm),0.6466974020004272
|
||
|
4373,"def GenerateVector ( self, hits, vector, level ) : <TAB> """"""Generate possible hit vectors which match the rules."""""" <TAB> for item in hits. get ( level, [ ] ) : <TAB> <TAB> if vector : <TAB> <TAB> <TAB> if item < vector [ - 1 ] : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if item > self. max_separation + vector [ - 1 ] : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> new_vector = vector + [ item ] <TAB> <TAB> if level + 1 == len ( hits ) : <TAB> <TAB> <TAB> yield new_vector <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> for result in self. GenerateVector ( hits, new_vector, level + 1 ) : <TAB> <TAB> <TAB> <TAB> yield result",False,level + 1 < len(hits),level + 1 == len(new_vector),0.6656036376953125
|
||
|
4374,def run ( self ) : <TAB> <TAB> <TAB> for _ in range ( 10 ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> break <TAB> <TAB> self. spawn_i3status ( ) <TAB> <TAB> <TAB> <TAB> if not self. ready : <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> self. lock. wait ( 5 ),False,not self.py3_wrapper.running,not self.ready,0.6537695527076721
|
||
|
4375,"def add_history ( <TAB> self, source, description = None, first_seen = None, last_seen = None, active = False ) : <TAB> last_seen = last_seen or datetime. utcnow ( ) <TAB> first_seen = first_seen or datetime. utcnow ( ) <TAB> <TAB> if active : <TAB> <TAB> active_history = self. get_active ( description ) <TAB> <TAB> if active_history and last_seen > active_history. last_seen : <TAB> <TAB> <TAB> active_history. last_seen = last_seen <TAB> <TAB> <TAB> self. save ( validate = False ) <TAB> <TAB> <TAB> return self <TAB> <TAB> else : <TAB> <TAB> _, overlapping_history = self. _get_overlapping ( <TAB> <TAB> <TAB> description, first_seen, last_seen <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if source not in overlapping_history. sources : <TAB> <TAB> <TAB> <TAB> overlapping_history. sources. append ( source ) <TAB> <TAB> <TAB> overlapping_history. first_seen = min ( <TAB> <TAB> <TAB> <TAB> overlapping_history. first_seen, first_seen <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> overlapping_history. last_seen = max ( <TAB> <TAB> <TAB> <TAB> overlapping_history. last_seen, last_seen <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> self. save ( validate = False ) <TAB> <TAB> <TAB> return self <TAB> <TAB> return self. modify ( <TAB> <TAB> push__history = LinkHistory ( <TAB> <TAB> <TAB> description = description, <TAB> <TAB> <TAB> first_seen = first_seen or datetime. utcnow ( ), <TAB> <TAB> <TAB> last_seen = last_seen or datetime. utcnow ( ), <TAB> <TAB> <TAB> active = active, <TAB> <TAB> <TAB> sources = [ source ], <",True,overlapping_history,overlapping_history,0.6643914580345154
|
||
|
4376,"def get_pointers_to_add_remove ( self, pointers, new_pointers ) : <TAB> diff = relationship_diff ( <TAB> <TAB> current_items = { pointer. _id : pointer for pointer in pointers }, <TAB> <TAB> new_items = { val [ ""_id"" ] : val for val in new_pointers }, <TAB> ) <TAB> nodes_to_add = [ ] <TAB> for node_id in diff [ ""add"" ] : <TAB> <TAB> node = AbstractNode. load ( node_id ) or Preprint. load ( node_id ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise exceptions. NotFound ( <TAB> <TAB> <TAB> <TAB> detail = 'Node with id ""{}"" was not found'. format ( node_id ) <TAB> <TAB> <TAB> ) <TAB> <TAB> nodes_to_add. append ( node ) <TAB> return nodes_to_add, diff [ ""remove"" ]. values ( )",False,not node,node.has_id(),0.6688798666000366
|
||
|
4377,"def __process_eval_epoch_end_results_and_log_legacy ( self, eval_results ) : <TAB> if self. trainer. running_sanity_check : <TAB> <TAB> return <TAB> if eval_results is not None and len ( eval_results ) > 0 : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> eval_results = [ eval_results ] <TAB> <TAB> num_loaders : int = self. trainer. evaluation_loop. num_dataloaders <TAB> <TAB> prog_bar_metrics, log_metrics, callback_metrics = { }, { }, { } <TAB> <TAB> for result_idx, result in enumerate ( eval_results ) : <TAB> <TAB> <TAB> ( <TAB> <TAB> <TAB> <TAB> _, <TAB> <TAB> <TAB> <TAB> prog_bar_metrics, <TAB> <TAB> <TAB> <TAB> log_metrics, <TAB> <TAB> <TAB> <TAB> callback_metrics, <TAB> <TAB> <TAB> <TAB> _, <TAB> <TAB> <TAB> ) = self. trainer. process_dict_result ( result ) <TAB> <TAB> <TAB> if num_loaders > 1 : <TAB> <TAB> <TAB> <TAB> self. __process_eval_epoch_end_results_and_log_legacy_update ( <TAB> <TAB> <TAB> <TAB> <TAB> prog_bar_metrics, log_metrics, callback_metrics <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> if num_loaders == 1 : <TAB> <TAB> <TAB> self. __process_eval_epoch_end_results_and_log_legacy_update ( <TAB> <TAB> <TAB> <TAB> prog_bar_metrics, log_metrics, callback_metrics <TAB> <TAB> <TAB> )",False,"not isinstance(eval_results, list)",len(eval_results) == 1,0.6571638584136963
|
||
|
4378,"def text_value_changed ( self, widget, param, value = None ) : <TAB> try : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> value = widget. toPlainText ( ) <TAB> except : <TAB> <TAB> pass <TAB> <TAB> if param. get ( ""category"" ) == ""Keyboard"" : <TAB> <TAB> previous_value = value <TAB> <TAB> value = QKeySequence ( value ). toString ( ) <TAB> <TAB> log. info ( <TAB> <TAB> <TAB> ""Parsing keyboard mapping via QKeySequence from %s to %s"" <TAB> <TAB> <TAB> % ( previous_value, value ) <TAB> <TAB> ) <TAB> <TAB> self. s. set ( param [ ""setting"" ], value ) <TAB> log. info ( value ) <TAB> <TAB> self. check_for_restart ( param )",False,not value,value is None,0.6716938018798828
|
||
|
4379,"def _get_table_info ( self, table_name ) : <TAB> table_addr = self. addr_space. profile. get_symbol ( table_name ) <TAB> table_size = self. _get_table_info_distorm ( ) <TAB> if<mask> : <TAB> <TAB> table_size = self. _get_table_info_other ( table_addr, table_name ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> debug. error ( ""Unable to get system call table size"" ) <TAB> return [ table_addr, table_size ]",False,table_size == 0,table_size is None,0.6630326509475708
|
||
|
4380,"def renderSubplot ( self, subplot ) : <TAB> self. figure. subplots_adjust ( left = 0.15 ) <TAB> xValues = [ ] <TAB> yValues = [ ] <TAB> i = 0 <TAB> for row in self. data : <TAB> <TAB> if len ( row ) < 2 : <TAB> <TAB> <TAB> raise GraphException ( ""Need at least two points for a graph data object!"" ) <TAB> <TAB> x = row [ 0 ] <TAB> <TAB> y = row [ 1 ] <TAB> <TAB> xValues. append ( x ) <TAB> <TAB> yValues. append ( y ) <TAB> xValues. sort ( ) <TAB> yValues. sort ( ) <TAB> for row in self. data : <TAB> <TAB> x = row [ 0 ] <TAB> <TAB> y = row [ 1 ] <TAB> <TAB> marker = self. marker <TAB> <TAB> color = self. nextColor ( ) <TAB> <TAB> alpha = self. alpha <TAB> <TAB> markersize = self. markersize <TAB> <TAB> if len ( row ) >= 3 : <TAB> <TAB> <TAB> displayData = row [ 2 ] <TAB> <TAB> <TAB> if ""color"" in displayData : <TAB> <TAB> <TAB> <TAB> color = displayData [ ""color"" ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> marker = displayData [ ""marker"" ] <TAB> <TAB> <TAB> if ""alpha"" in displayData : <TAB> <TAB> <TAB> <TAB> alpha = displayData [ ""alpha"" ] <TAB> <TAB> <TAB> if ""markersize"" in displayData : <TAB> <TAB> <TAB> <TAB> markersize = displayData [ ""markersize"" ] <TAB> <TAB> subplot. plot ( <TAB> <TAB> <TAB> x, y, marker = marker, color = color, alpha = alpha, markersize = markersize <TAB> <TAB> ) <TAB> <TAB> i += 1 <TAB> <TAB> if not self. axisRangeHasBeenSet [ ""y"" ] : <TAB>",False,'marker' in displayData,'mmarker' in displayData,0.6606918573379517
|
||
|
4381,"def loadHandler ( self, human, values, strict ) : <TAB> if values [ 0 ] == ""background"" : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> side = values [ 1 ] <TAB> <TAB> <TAB> img_filename = values [ 2 ] <TAB> <TAB> <TAB> i = 0 <TAB> <TAB> <TAB> while ( <TAB> <TAB> <TAB> <TAB> img_filename <TAB> <TAB> <TAB> <TAB> and not any ( <TAB> <TAB> <TAB> <TAB> <TAB> [ img_filename. lower ( ). endswith ( ex ) for ex in self. extensions ] <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> and ( len ( values ) - ( i + 2 ) ) >= 6 <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> i += 1 <TAB> <TAB> <TAB> <TAB> img_filename = img_filename + "" "" + values [ 2 + i ] <TAB> <TAB> <TAB> img_filename = getpath. thoroughFindFile ( <TAB> <TAB> <TAB> <TAB> img_filename, self. backgroundsFolders <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if not os. path. isfile ( img_filename ) : <TAB> <TAB> <TAB> <TAB> log. warning ( ""Background file %s not found"", img_filename ) <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> aspect = float ( values [ 3 + i ] ) <TAB> <TAB> <TAB> trans = ( float ( values [ 4 + i ] ), float ( values [ 5 + i ] ) ) <TAB> <TAB> <TAB> scale = float ( values [ 6 + i ] ) <TAB> <TAB> <TAB> self. filenames [ side ] = ( img_filename, aspect ) <TAB> <TAB> <TAB> self. transformations [ side ] = [ trans, scale ] <TAB> <TAB> elif len ( values ) >= 3 and values [ 1 ] == ""enabled"" : <TAB>",False,len(values) >= 7,len(values) > 2,0.6532894968986511
|
||
|
4382,"def _pprint_key_entries ( <TAB> user, key_fn, key_entries, hash_meth = ""sha256"", prefix = ""ci-info: "" ) : <TAB> if not key_entries : <TAB> <TAB> message = ""%sno authorized SSH keys fingerprints found for user %s.\n"" % ( <TAB> <TAB> <TAB> prefix, <TAB> <TAB> <TAB> user, <TAB> <TAB> ) <TAB> <TAB> util. multi_log ( message ) <TAB> <TAB> return <TAB> tbl_fields = [ ""Keytype"", ""Fingerprint (%s)"" % ( hash_meth ), ""Options"", ""Comment"" ] <TAB> tbl = SimpleTable ( tbl_fields ) <TAB> for entry in key_entries : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> row = [ <TAB> <TAB> <TAB> <TAB> entry. keytype or ""-"", <TAB> <TAB> <TAB> <TAB> _gen_fingerprint ( entry. base64, hash_meth ) or ""-"", <TAB> <TAB> <TAB> <TAB> entry. options or ""-"", <TAB> <TAB> <TAB> <TAB> entry. comment or ""-"", <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> tbl. add_row ( row ) <TAB> authtbl_s = tbl. get_string ( ) <TAB> authtbl_lines = authtbl_s. splitlines ( ) <TAB> max_len = len ( max ( authtbl_lines, key = len ) ) <TAB> lines = [ <TAB> <TAB> util. center ( <TAB> <TAB> <TAB> ""Authorized keys from %s for user %s"" % ( key_fn, user ), ""+"", max_len <TAB> <TAB> ), <TAB> ] <TAB> lines. extend ( authtbl_lines ) <TAB> for line in lines : <TAB> <TAB> util. multi_log ( text = ""%s%s\n"" % ( prefix, line ), stderr = False, console = True )",False,_is_printable_key(entry),entry.has_key,0.6478855609893799
|
||
|
4383,"def overrideCommand ( self, commandName, func ) : <TAB> <TAB> k = self <TAB> d = k. masterBindingsDict <TAB> for key in d : <TAB> <TAB> d2 = d. get ( key ) <TAB> <TAB> for key2 in d2 : <TAB> <TAB> <TAB> bi = d2. get ( key2 ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> bi. func = func <TAB> <TAB> <TAB> <TAB> d2 [ key2 ] = bi",False,bi.commandName == commandName,not bi,0.6691148281097412
|
||
|
4384,"def results_iter ( self ) : <TAB> if self. connection. ops. oracle : <TAB> <TAB> from django. db. models. fields import DateTimeField <TAB> <TAB> fields = [ DateTimeField ( ) ] <TAB> else : <TAB> <TAB> needs_string_cast = self. connection. features. needs_datetime_string_cast <TAB> offset = len ( self. query. extra_select ) <TAB> for rows in self. execute_sql ( MULTI ) : <TAB> <TAB> for row in rows : <TAB> <TAB> <TAB> date = row [ offset ] <TAB> <TAB> <TAB> if self. connection. ops. oracle : <TAB> <TAB> <TAB> <TAB> date = self. resolve_columns ( row, fields ) [ offset ] <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> date = typecast_timestamp ( str ( date ) ) <TAB> <TAB> <TAB> yield date",False,needs_string_cast,self.connection.ops.needs_datetime_string_cast,0.6630522012710571
|
||
|
4385,"def main ( ) : <TAB> pygame. init ( ) <TAB> if hasattr ( eventmodule, ""init"" ) : <TAB> <TAB> eventmodule. init ( ) <TAB> screen = pygame. display. set_mode ( ( 300, 300 ) ) <TAB> <TAB> reactor. interleave ( postTwistedEvent ) <TAB> <TAB> <TAB> <TAB> shouldQuit = [ ] <TAB> reactor. addSystemEventTrigger ( ""after"", ""shutdown"", shouldQuit. append, True ) <TAB> for event in eventIterator ( ) : <TAB> <TAB> if event. type == TWISTEDEVENT : <TAB> <TAB> <TAB> event. iterateTwisted ( ) <TAB> <TAB> <TAB> if shouldQuit : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> elif event. type == QUIT : <TAB> <TAB> <TAB> reactor. stop ( ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> reactor. stop ( ) <TAB> pygame. quit ( )",False,event.type == KEYDOWN and event.key == K_ESCAPE,event.type == KILL,0.6541868448257446
|
||
|
4386,"def load_profiles ( profile_path ) : <TAB> ""Load the stored profiles"" <TAB> profiles = { } <TAB> for profile in os. listdir ( profile_path ) : <TAB> <TAB> config_name = os. path. join ( profile_path, profile, ""config"" ) <TAB> <TAB> setup_name = os. path. join ( profile_path, profile, ""setup"" ) <TAB> <TAB> if not os. path. isfile ( config_name ) or not os. path. isfile ( setup_name ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> edids = dict ( <TAB> <TAB> <TAB> [ <TAB> <TAB> <TAB> <TAB> x. split ( ) <TAB> <TAB> <TAB> <TAB> for x in ( y. strip ( ) for y in open ( setup_name ). readlines ( ) ) <TAB> <TAB> <TAB> <TAB> if x and x [ 0 ]!= ""#"" <TAB> <TAB> <TAB> ] <TAB> <TAB> ) <TAB> <TAB> config = { } <TAB> <TAB> buffer = [ ] <TAB> <TAB> for line in chain ( open ( config_name ). readlines ( ), [ ""output"" ] ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> config [ buffer [ 0 ]. strip ( ). split ( ) [ - 1 ] ] = XrandrOutput. from_config_file ( <TAB> <TAB> <TAB> <TAB> <TAB> edids, """". join ( buffer ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> buffer = [ line ] <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> buffer. append ( line ) <TAB> <TAB> for output_name in list ( config. keys ( ) ) : <TAB> <TAB> <TAB> if config [ output_name ]. edid is None : <TAB> <TAB> <TAB> <TAB> del config [ output_name ] <TAB> <TAB> profiles [ profile ] = { <TAB> <TAB",False,line[:6] == 'output' and buffer,buffer,0.6519148945808411
|
||
|
4387,"def append_scan_summary_info ( self, ip_addresses ) : <TAB> if not ip_addresses : <TAB> <TAB> return <TAB> delta = timezone. now ( ) - datetime. timedelta ( days = 1 ) <TAB> for ip_address in ip_addresses : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> job = rq. job. Job. fetch ( <TAB> <TAB> <TAB> <TAB> <TAB> ip_address. scan_summary. job_id, <TAB> <TAB> <TAB> <TAB> <TAB> django_rq. get_connection ( ), <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> except rq. exceptions. NoSuchJobError : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> ip_address. scan_summary. changed = job. meta. get ( <TAB> <TAB> <TAB> <TAB> <TAB> ""changed"", <TAB> <TAB> <TAB> <TAB> <TAB> False, <TAB> <TAB> <TAB> <TAB> )",False,ip_address.scan_summary and ip_address.scan_summary.modified > delta,delta - ip_address.ip_address < self.ip_address + self.scan_summary.time,0.649268627166748
|
||
|
4388,"def countbox ( self ) : <TAB> self. box = [ 1000, 1000, - 1000, - 1000 ] <TAB> for x, y in self. body : <TAB> <TAB> if x < self. box [ 0 ] : <TAB> <TAB> <TAB> self. box [ 0 ] = x <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. box [ 2 ] = x <TAB> <TAB> if y < self. box [ 1 ] : <TAB> <TAB> <TAB> self. box [ 1 ] = y <TAB> <TAB> if y > self. box [ 3 ] : <TAB> <TAB> <TAB> self. box [ 3 ] = y",False,x > self.box[2],y < self.box[2],0.661747932434082
|
||
|
4389,"def run_cron ( self ) -> None : <TAB> n = datetime. now ( ) <TAB> job_futures = set ( ) <TAB> for cron_job in self. cron_jobs : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if cron_job. run_at_startup : <TAB> <TAB> <TAB> <TAB> cron_job. next_run = n <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> cron_job. set_next ( n ) <TAB> <TAB> next_run = cast ( datetime, cron_job. next_run ) <TAB> <TAB> if n >= next_run : <TAB> <TAB> <TAB> job_id = ( <TAB> <TAB> <TAB> <TAB> f""{cron_job.name}:{to_unix_ms(next_run)}"" if cron_job. unique else None <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> job_futures. add ( <TAB> <TAB> <TAB> <TAB> self. pool. enqueue_job ( <TAB> <TAB> <TAB> <TAB> <TAB> cron_job. name, _job_id = job_id, _queue_name = self. queue_name <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> cron_job. set_next ( n ) <TAB> job_futures and await asyncio. gather ( * job_futures )",False,cron_job.next_run is None,n > 0,0.6521590948104858
|
||
|
4390,"def set_indentation_params ( self, ispythonsource, guess = 1 ) : <TAB> if guess and ispythonsource : <TAB> <TAB> i = self. guess_indent ( ) <TAB> <TAB> if 2 <= i <= 8 : <TAB> <TAB> <TAB> self. indentwidth = i <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. usetabs = 0 <TAB> self. editwin. set_tabwidth ( self. tabwidth )",False,self.indentwidth != self.tabwidth,self.usetabs and guess,0.6541339755058289
|
||
|
4391,"def batch_act_and_train ( self, batch_obs ) : <TAB> xp = self. xp <TAB> b_state = self. batch_states ( batch_obs, xp, self. phi ) <TAB> if self. obs_normalizer : <TAB> <TAB> b_state = self. obs_normalizer ( b_state, update = False ) <TAB> num_envs = len ( batch_obs ) <TAB> if self. batch_last_episode is None : <TAB> <TAB> self. _initialize_batch_variables ( num_envs ) <TAB> assert len ( self. batch_last_episode ) == num_envs <TAB> assert len ( self. batch_last_state ) == num_envs <TAB> assert len ( self. batch_last_action ) == num_envs <TAB> <TAB> with chainer. using_config ( ""train"", False ), chainer. no_backprop_mode ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> assert self. train_prev_recurrent_states is None <TAB> <TAB> <TAB> self. train_prev_recurrent_states = self. train_recurrent_states <TAB> <TAB> <TAB> ( action_distrib, batch_value ), self. train_recurrent_states = self. model ( <TAB> <TAB> <TAB> <TAB> b_state, self. train_prev_recurrent_states <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> action_distrib, batch_value = self. model ( b_state ) <TAB> <TAB> batch_action = chainer. cuda. to_cpu ( action_distrib. sample ( ). array ) <TAB> <TAB> self. entropy_record. extend ( chainer. cuda. to_cpu ( action_distrib. entropy. array ) ) <TAB> <TAB> self. value_record. extend ( chainer. cuda. to_cpu ( ( batch_value. array ) ) ) <TAB> self. batch_last_state = list ( batch_obs ) <TAB> self. batch_last_action = list ( batch_action ) <TAB>",False,self.recurrent,self.model is not None,0.653032660484314
|
||
|
4392,"def __init__ ( self, meters_count ) : <TAB> w = SLOT_W * meters_count <TAB> h = METER_SLOT_H <TAB> self. widget = cairoarea. CairoDrawableArea2 ( w, h, self. _draw ) <TAB> self. audio_meters = [ ] <TAB> for i in range ( 0, meters_count ) : <TAB> <TAB> meter = AudioMeter ( METER_HEIGHT ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> meter. right_channel. draw_dB = True <TAB> <TAB> self. audio_meters. append ( meter )",False,i != meters_count - 1,meters_count == 1,0.668961763381958
|
||
|
4393,"def rx ( ) : <TAB> while True : <TAB> <TAB> rx_i = rep. recv ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> rep. send ( b""done"" ) <TAB> <TAB> <TAB> break <TAB> <TAB> rep. send ( b""i"" )",False,rx_i == b'1000',rx_i == 0,0.6606658697128296
|
||
|
4394,"def _expand_requires_extra ( re ) : <TAB> for extra, reqs in sorted ( re. items ( ) ) : <TAB> <TAB> for req in reqs : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> name, envmark = req. split ( "";"", 1 ) <TAB> <TAB> <TAB> <TAB> yield '{} ; extra == ""{}"" and ({})'. format ( name, extra, envmark ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> yield '{} ; extra == ""{}""'. format ( req, extra )",False,';' in req,len(req) > 0,0.678476095199585
|
||
|
4395,"def recvfds ( sock, size ) : <TAB> """"""Receive an array of fds over an AF_UNIX socket."""""" <TAB> a = array. array ( ""i"" ) <TAB> bytes_size = a. itemsize * size <TAB> msg, ancdata, flags, addr = sock. recvmsg ( <TAB> <TAB> 1, <TAB> <TAB> socket. CMSG_LEN ( bytes_size ), <TAB> ) <TAB> if not msg and not ancdata : <TAB> <TAB> raise EOFError <TAB> try : <TAB> <TAB> if ACKNOWLEDGE : <TAB> <TAB> <TAB> sock. send ( b""A"" ) <TAB> <TAB> if len ( ancdata )!= 1 : <TAB> <TAB> <TAB> raise RuntimeError ( <TAB> <TAB> <TAB> <TAB> ""received %d items of ancdata"" % len ( ancdata ), <TAB> <TAB> <TAB> ) <TAB> <TAB> cmsg_level, cmsg_type, cmsg_data = ancdata [ 0 ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if len ( cmsg_data ) % a. itemsize!= 0 : <TAB> <TAB> <TAB> <TAB> raise ValueError <TAB> <TAB> <TAB> a. frombytes ( cmsg_data ) <TAB> <TAB> <TAB> assert len ( a ) % 256 == msg [ 0 ] <TAB> <TAB> <TAB> return list ( a ) <TAB> except ( ValueError, IndexError ) : <TAB> <TAB> pass <TAB> raise RuntimeError ( ""Invalid data received"" )",False,cmsg_level == socket.SOL_SOCKET and cmsg_type == socket.SCM_RIGHTS,cmsg_level and cmsg_data,0.6512272357940674
|
||
|
4396,"def get_filtered_observation_space ( <TAB> self, input_observation_space : ObservationSpace ) -> ObservationSpace : <TAB> axis_size = input_observation_space. shape [ self. axis_origin ] <TAB> input_observation_space. shape = np. delete ( <TAB> <TAB> input_observation_space. shape, self. axis_origin <TAB> ) <TAB> if self. axis_target == - 1 : <TAB> <TAB> input_observation_space. shape = np. append ( <TAB> <TAB> <TAB> input_observation_space. shape, axis_size <TAB> <TAB> ) <TAB> elif self. axis_target < - 1 : <TAB> <TAB> input_observation_space. shape = np. insert ( <TAB> <TAB> <TAB> input_observation_space. shape, self. axis_target + 1, axis_size <TAB> <TAB> ) <TAB> else : <TAB> <TAB> input_observation_space. shape = np. insert ( <TAB> <TAB> <TAB> input_observation_space. shape, self. axis_target, axis_size <TAB> <TAB> ) <TAB> <TAB> if isinstance ( input_observation_space, PlanarMapsObservationSpace ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> input_observation_space. channels_axis = self. axis_target <TAB> <TAB> elif input_observation_space. channels_axis == self. axis_target : <TAB> <TAB> <TAB> input_observation_space. channels_axis = self. axis_origin <TAB> <TAB> elif ( <TAB> <TAB> <TAB> self. axis_origin < input_observation_space. channels_axis < self. axis_target <TAB> <TAB> ) : <TAB> <TAB> <TAB> input_observation_space. channels_axis -= 1 <TAB> <TAB> elif ( <TAB> <TAB> <TAB> self. axis_target < input_observation_space. channels_axis < self. axis_origin <TAB> <TAB> ) : <TAB> <TAB> <TAB> input_observation_space. channels_axis += 1 <TAB> return input_observation_",True,input_observation_space.channels_axis == self.axis_origin,input_observation_space.channels_axis == self.axis_origin,0.6516085863113403
|
||
|
4397,"def __iadd__ ( self, other ) : <TAB> if safe_mode and self. _parent_expr : <TAB> <TAB> raise EntangledExpressionError ( self, other ) <TAB> _type = other. __class__ <TAB> if _type in native_numeric_types : <TAB> <TAB> if other : <TAB> <TAB> <TAB> self. _args. append ( other ) <TAB> <TAB> return self <TAB> try : <TAB> <TAB> _other_expr = other. is_expression ( ) <TAB> except AttributeError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> other = as_numeric ( other ) <TAB> <TAB> _other_expr = other. is_expression ( ) <TAB> if _other_expr : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise EntangledExpressionError ( self, other ) <TAB> <TAB> if _type is _SumExpression : <TAB> <TAB> <TAB> self. _args. extend ( other. _args ) <TAB> <TAB> <TAB> other. _args = [ ] <TAB> <TAB> <TAB> return self <TAB> <TAB> if safe_mode : <TAB> <TAB> <TAB> other. _parent_expr = bypass_backreference or ref ( self ) <TAB> elif other. is_indexed ( ) : <TAB> <TAB> raise TypeError ( <TAB> <TAB> <TAB> ""Argument for expression '%s' is an indexed numeric "" <TAB> <TAB> <TAB> ""value\nspecified without an index:\n\t%s\nIs this "" <TAB> <TAB> <TAB> ""value defined over an index that you did not specify?"" <TAB> <TAB> <TAB> % ( <TAB> <TAB> <TAB> <TAB> etype, <TAB> <TAB> <TAB> <TAB> other. cname ( True ), <TAB> <TAB> <TAB> ) <TAB> <TAB> ) <TAB> elif other. is_constant ( ) : <TAB> <TAB> other = other ( ) <TAB> self. _args. append",False,safe_mode and other._parent_expr,not other.is_numeric(),0.6553704738616943
|
||
|
4398,"def _importZippedFiles ( self, srcPath, parentPath, parent_id ) : <TAB> import zipfile, tempfile <TAB> zf = zipfile. ZipFile ( srcPath, ""r"" ) <TAB> try : <TAB> <TAB> zipped_files = zf. namelist ( ) <TAB> <TAB> for fname in zipped_files : <TAB> <TAB> <TAB> if fname. startswith ( ""/"" ) : <TAB> <TAB> <TAB> <TAB> raise Exception ( ""filename in zip file is an absolute path: %s"", fname ) <TAB> <TAB> <TAB> elif self. _up_dir_re. search ( fname ) : <TAB> <TAB> <TAB> <TAB> raise Exception ( ""filename in zip file contains a '..': %s"", fname ) <TAB> <TAB> koDirSvc = components. classes [ ""@activestate.com/koDirs;1"" ]. getService ( ) <TAB> <TAB> userDataDir = koDirSvc. userDataDir <TAB> <TAB> extractDir = join ( userDataDir, ""extracted-kpz"" ) <TAB> <TAB> zipExtractDir = tempfile. mkdtemp ( suffix = ""_zip"", prefix = ""tools_"", dir = extractDir ) <TAB> <TAB> zf. extractall ( zipExtractDir ) <TAB> finally : <TAB> <TAB> zf. close ( ) <TAB> try : <TAB> <TAB> newFiles = [ ] <TAB> <TAB> for fname in os. listdir ( zipExtractDir ) : <TAB> <TAB> <TAB> path = join ( zipExtractDir, fname ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. importDirectory ( parentPath, path ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> newFiles. append ( path ) <TAB> <TAB> if newFiles : <TAB> <TAB> <TAB> self. importFiles ( parentPath, newFiles ) <TAB> finally : <TAB> <TAB> shutil. rmtree ( zipExtractDir )",False,os.path.isdir(path),path,0.6441490650177002
|
||
|
4399,"def test_prod_without_zeros_default_acc_dtype ( self ) : <TAB> <TAB> <TAB> axes = [ None, 0, 1, [ ], [ 0 ], [ 1 ], [ 0, 1 ] ] <TAB> for idx, dtype in enumerate ( imap ( str, theano. scalar. all_types ) ) : <TAB> <TAB> axis = axes [ idx % len ( axes ) ] <TAB> <TAB> x = tensor. matrix ( dtype = dtype ) <TAB> <TAB> p = ProdWithoutZeros ( axis = axis ) ( x ) <TAB> <TAB> assert p. owner. op. acc_dtype == dict ( <TAB> <TAB> <TAB> bool = ""int64"", <TAB> <TAB> <TAB> int8 = ""int64"", <TAB> <TAB> <TAB> int16 = ""int64"", <TAB> <TAB> <TAB> int32 = ""int64"", <TAB> <TAB> <TAB> uint8 = ""uint64"", <TAB> <TAB> <TAB> uint16 = ""uint64"", <TAB> <TAB> <TAB> uint32 = ""uint64"", <TAB> <TAB> <TAB> float16 = ""float32"", <TAB> <TAB> <TAB> float32 = ""float64"", <TAB> <TAB> <TAB> complex64 = ""complex128"", <TAB> <TAB> ). get ( dtype, dtype ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> f = theano. function ( [ x ], p ) <TAB> <TAB> data = np. random. rand ( 2, 3 ) * 3 <TAB> <TAB> data = data. astype ( dtype ) <TAB> <TAB> f ( data )",False,'complex' in dtype,x is None,0.6661911010742188
|
||
|
4400,"def forward ( self, g, feats ) : <TAB> with g. local_scope ( ) : <TAB> <TAB> init_feats = feats <TAB> <TAB> <TAB> <TAB> degs = g. in_degrees ( ). float ( ). clamp ( min = 1 ) <TAB> <TAB> norm = torch. pow ( degs, - 0.5 ). to ( feats. device ). unsqueeze ( 1 ) <TAB> <TAB> output = None <TAB> <TAB> for k in range ( self. K ) : <TAB> <TAB> <TAB> feats = init_feats <TAB> <TAB> <TAB> for t in range ( self. T ) : <TAB> <TAB> <TAB> <TAB> feats = feats * norm <TAB> <TAB> <TAB> <TAB> g. ndata [ ""h"" ] = feats <TAB> <TAB> <TAB> <TAB> g. update_all ( fn. copy_u ( ""h"", ""m"" ), fn. sum ( ""m"", ""h"" ) ) <TAB> <TAB> <TAB> <TAB> feats = g. ndata. pop ( ""h"" ) <TAB> <TAB> <TAB> <TAB> feats = feats * norm <TAB> <TAB> <TAB> <TAB> if t == 0 : <TAB> <TAB> <TAB> <TAB> <TAB> feats = self. w_0 [ str ( k ) ] ( feats ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> feats = self. w [ str ( k ) ] ( feats ) <TAB> <TAB> <TAB> <TAB> feats += self. dropout ( self. v [ str ( k ) ] ( init_feats ) ) <TAB> <TAB> <TAB> <TAB> feats += self. v [ str ( k ) ] ( self. dropout ( init_feats ) ) <TAB> <TAB> <TAB> <TAB> if self. bias is not None : <TAB> <TAB> <TAB> <TAB> <TAB> feats += self. bias [ k ] [ t ] <TAB> <TAB",False,output is None,self.output,0.6649282574653625
|
||
|
4401,"def _model_to_prospective_search_schema ( model, add_entry ) : <TAB> """"""Produce SchemaEntries from db.Model class."""""" <TAB> from google. appengine. ext import db <TAB> for name, model_property in model. properties ( ). iteritems ( ) : <TAB> <TAB> model_class = model_property. __class__ <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> model_class = _GetModelTypeForListPropertyType ( model_property. item_type ) <TAB> <TAB> _add_schema_entry ( model_class, name, add_entry )",False,"issubclass(model_class, db.ListProperty)","hasattr(model_class, 'item_type')",0.6546720862388611
|
||
|
4402,"def workflows_using_aw ( dirpath ) : <TAB> """"""Yield bundle IDs of workflows using AW."""""" <TAB> for root, _, filenames in os. walk ( dirpath ) : <TAB> <TAB> for filename in filenames : <TAB> <TAB> <TAB> if not filename. endswith ( "".alfredworkflow"" ) : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> path = os. path. join ( root, filename ) <TAB> <TAB> <TAB> with ZipFile ( path ) as z : <TAB> <TAB> <TAB> <TAB> uses_alfred_workflow = False <TAB> <TAB> <TAB> <TAB> for name in z. namelist ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> if name in ( b""workflow/workflow.py"", b""workflow.zip"" ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> uses_alfred_workflow = True <TAB> <TAB> <TAB> <TAB> <TAB> elif match_zip ( name ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> uses_alfred_workflow = True <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> bundle = os. path. basename ( os. path. dirname ( path ) ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> yield bundle",False,uses_alfred_workflow,uses_alfred_workflow and (not uses_alfred_workflow),0.6552683115005493
|
||
|
4403,"def read_headers ( cls, fp ) : <TAB> headers = httputil. HeaderMap ( ) <TAB> while True : <TAB> <TAB> line = fp. readline ( ) <TAB> <TAB> if not line : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> raise EOFError ( u""Illegal end of headers."" ) <TAB> <TAB> if line == ""\r\n"" : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> if not line. endswith ( ""\r\n"" ) : <TAB> <TAB> <TAB> raise ValueError ( u""MIME requires CRLF terminators: %r"" % line ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> v = line. strip ( ). decode ( u""ISO-8859-1"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> k, v = line. split ( "":"", 1 ) <TAB> <TAB> <TAB> k = k. strip ( ). decode ( u""ISO-8859-1"" ) <TAB> <TAB> <TAB> v = v. strip ( ). decode ( u""ISO-8859-1"" ) <TAB> <TAB> existing = headers. get ( k ) <TAB> <TAB> if existing : <TAB> <TAB> <TAB> v = u"", "". join ( ( existing, v ) ) <TAB> <TAB> headers [ k ] = v <TAB> return headers",False,line[0] in '\t',len(line) == 2,0.6547127962112427
|
||
|
4404,"def _yield_unescaped ( self, string ) : <TAB> while ""\\"" in string : <TAB> <TAB> finder = EscapeFinder ( string ) <TAB> <TAB> yield finder. before + finder. backslashes <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> yield self. _unescape ( finder. text ) <TAB> <TAB> else : <TAB> <TAB> <TAB> yield finder. text <TAB> <TAB> string = finder. after <TAB> yield string",False,finder.escaped and finder.text,finder.after,0.6596453189849854
|
||
|
4405,"def test_files ( self ) : <TAB> <TAB> dist_dir = os. path. join ( os. path. dirname ( __file__ ), os. pardir, os. pardir ) <TAB> names = [ ] <TAB> for d in self. test_directories : <TAB> <TAB> test_dir = os. path. join ( dist_dir, d ) <TAB> <TAB> for n in os. listdir ( test_dir ) : <TAB> <TAB> <TAB> if n. endswith ( "".py"" ) and not n. startswith ( ""bad"" ) : <TAB> <TAB> <TAB> <TAB> names. append ( os. path. join ( test_dir, n ) ) <TAB> for filename in names : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> print ( ""Testing %s"" % filename ) <TAB> <TAB> source = read_pyfile ( filename ) <TAB> <TAB> self. check_roundtrip ( source )",False,test_support.verbose,filename.endswith('.py'),0.6524229049682617
|
||
|
4406,"def _adjust_self_columns_for_partial_reordering ( self ) : <TAB> pairs = set ( ) <TAB> col_by_idx = list ( self. columns ) <TAB> if self. partial_reordering : <TAB> <TAB> for tuple_ in self. partial_reordering : <TAB> <TAB> <TAB> for index, elem in enumerate ( tuple_ ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> pairs. add ( ( tuple_ [ index - 1 ], elem ) ) <TAB> else : <TAB> <TAB> for index, elem in enumerate ( self. existing_ordering ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> pairs. add ( ( col_by_idx [ index - 1 ], elem ) ) <TAB> pairs. update ( self. add_col_ordering ) <TAB> <TAB> <TAB> <TAB> pairs = [ p for p in pairs if p [ 0 ]!= p [ 1 ] ] <TAB> sorted_ = list ( topological. sort ( pairs, col_by_idx, deterministic_order = True ) ) <TAB> self. columns = OrderedDict ( ( k, self. columns [ k ] ) for k in sorted_ ) <TAB> self. column_transfers = OrderedDict ( ( k, self. column_transfers [ k ] ) for k in sorted_ )",False,index > 0,col_by_idx[index - 1] != elem[0],0.6684260368347168
|
||
|
4407,"def print_map ( node, l ) : <TAB> if node. title not in l : <TAB> <TAB> l [ node. title ] = [ ] <TAB> for n in node. children : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> w = { n. title : [ ] } <TAB> <TAB> <TAB> l [ node. title ]. append ( w ) <TAB> <TAB> <TAB> print_map ( n, w ) <TAB> <TAB> else : <TAB> <TAB> <TAB> l [ node. title ]. append ( n. title )",False,len(n.children) > 0,n.title,0.6533650159835815
|
||
|
4408,"def check_options ( <TAB> url, <TAB> cmd, <TAB> cve, <TAB> check_header, <TAB> filename, <TAB> os_shell_option, <TAB> http_request_method, <TAB> go_back, <TAB> go_back_again, ) : <TAB> if os_shell_option == False : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return False <TAB> <TAB> else : <TAB> <TAB> <TAB> return True <TAB> <TAB> elif os_shell_option == ""back"" : <TAB> <TAB> go_back = True <TAB> <TAB> return go_back, go_back_again <TAB> <TAB> elif os_shell_option == ""os_shell"" : <TAB> <TAB> warn_msg = ""You are already into the '"" + os_shell_option + ""' mode."" <TAB> <TAB> print ( settings. print_warning_msg ( warn_msg ) ) + ""\n"" <TAB> <TAB> elif os_shell_option == ""bind_tcp"" : <TAB> <TAB> go_back, go_back_again = bind_tcp_config ( <TAB> <TAB> <TAB> url, <TAB> <TAB> <TAB> cmd, <TAB> <TAB> <TAB> cve, <TAB> <TAB> <TAB> check_header, <TAB> <TAB> <TAB> filename, <TAB> <TAB> <TAB> os_shell_option, <TAB> <TAB> <TAB> http_request_method, <TAB> <TAB> <TAB> go_back, <TAB> <TAB> <TAB> go_back_again, <TAB> <TAB> ) <TAB> <TAB> return go_back, go_back_again <TAB> <TAB> elif os_shell_option == ""reverse_tcp"" : <TAB> <TAB> go_back, go_back_again = reverse_tcp_config ( <TAB> <TAB> <TAB> url, <TAB> <TAB> <TAB> cmd, <TAB> <TAB> <TAB> cve, <TAB> <TAB> <TAB> check_header, <TAB> <TAB> <",False,no_result == True,os_shell_option == 'no_tabs',0.6603779792785645
|
||
|
4409,"def _parse_inputs ( self, skip = ( ) ) : <TAB> """"""validate spm normalize options if set to None ignore"""""" <TAB> einputs = super ( Normalize12, self ). _parse_inputs ( skip = ( ""jobtype"", ""apply_to_files"" ) ) <TAB> if isdefined ( self. inputs. apply_to_files ) : <TAB> <TAB> inputfiles = deepcopy ( self. inputs. apply_to_files ) <TAB> <TAB> if isdefined ( self. inputs. image_to_align ) : <TAB> <TAB> <TAB> inputfiles. extend ( [ self. inputs. image_to_align ] ) <TAB> <TAB> einputs [ 0 ] [ ""subj"" ] [ ""resample"" ] = scans_for_fnames ( inputfiles ) <TAB> jobtype = self. inputs. jobtype <TAB> if jobtype in [ ""estwrite"", ""write"" ] : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if isdefined ( self. inputs. image_to_align ) : <TAB> <TAB> <TAB> <TAB> einputs [ 0 ] [ ""subj"" ] [ ""resample"" ] = scans_for_fname ( <TAB> <TAB> <TAB> <TAB> <TAB> self. inputs. image_to_align <TAB> <TAB> <TAB> <TAB> ) <TAB> return [ { ""%s"" % ( jobtype ) : einputs [ 0 ] } ]",False,not isdefined(self.inputs.apply_to_files),"jobtype in [None, 'skip']",0.6445922255516052
|
||
|
4410,"def _cbCommand ( self, result ) : <TAB> if result is not None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> result = result. encode ( ""utf-8"" ) <TAB> <TAB> self. _writeToTransport ( result ) <TAB> <TAB> if not result. endswith ( b""\n"" ) : <TAB> <TAB> <TAB> self. _writeToTransport ( b""\n"" ) <TAB> self. _newLine ( )",False,"isinstance(result, str)","isinstance(result, textBase)",0.6542553901672363
|
||
|
4411,"def _feedErrorsToResult ( self, result, errors, setup_or_teardown = False ) : <TAB> if setup_or_teardown : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for test, exc_info in errors : <TAB> <TAB> <TAB> result. addError ( test, exc_info ) <TAB> else : <TAB> <TAB> for test, exc_info in errors : <TAB> <TAB> <TAB> if isinstance ( test, _SubTest ) : <TAB> <TAB> <TAB> <TAB> result. addSubTest ( test. test_case, test, exc_info ) <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> if issubclass ( exc_info [ 0 ], self. failureException ) : <TAB> <TAB> <TAB> <TAB> <TAB> result. addFailure ( test, exc_info ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> result. addError ( test, exc_info )",False,exc_info is not None,"isinstance(exc_info, _Error)",0.661678671836853
|
||
|
4412,def function_arg ( self ) : <TAB> if self. ql. ostype in ( QL_OS_POSIX ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return ARMFunctionArg ( self. ql ) <TAB> <TAB> <TAB> <TAB> elif self. ql. archtype == QL_ARCH. MIPS : <TAB> <TAB> <TAB> return MIPS32FunctionArg ( self. ql ) <TAB> <TAB> <TAB> <TAB> elif self. ql. archtype == QL_ARCH. ARM64 : <TAB> <TAB> <TAB> return ARM64FunctionArg ( self. ql ) <TAB> <TAB> <TAB> <TAB> elif self. ql. archtype == QL_ARCH. X86 : <TAB> <TAB> <TAB> return X86FunctionArg ( self. ql ) <TAB> <TAB> <TAB> <TAB> elif self. ql. archtype == QL_ARCH. X8664 : <TAB> <TAB> <TAB> return X64FunctionArg ( self. ql ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise,True,self.ql.archtype == QL_ARCH.ARM,self.ql.archtype == QL_ARCH.ARM,0.6662028431892395
|
||
|
4413,"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. req = TGetTableTypesReq ( ) <TAB> <TAB> <TAB> <TAB> self. req. 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 ( )",False,fid == 1,fid == TType.START,0.6721340417861938
|
||
|
4414,"def sub_paragraph ( self, li ) : <TAB> """"""Search for checkbox in sub-paragraph."""""" <TAB> found = False <TAB> if len ( li ) : <TAB> <TAB> first = list ( li ) [ 0 ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> m = RE_CHECKBOX. match ( first. text ) <TAB> <TAB> <TAB> if m is not None : <TAB> <TAB> <TAB> <TAB> first. text = self. markdown. htmlStash. store ( <TAB> <TAB> <TAB> <TAB> <TAB> get_checkbox ( m. group ( ""state"" ) ), safe = True <TAB> <TAB> <TAB> <TAB> ) + m. group ( ""line"" ) <TAB> <TAB> <TAB> <TAB> found = True <TAB> return found",False,first.tag == 'p' and first.text is not None,first.text,0.6502739787101746
|
||
|
4415,"def wrapper ( ) : <TAB> for epoch_index in range ( epoch ) : <TAB> <TAB> if shuffle : <TAB> <TAB> <TAB> random. shuffle ( examples ) <TAB> <TAB> if phase == ""train"" : <TAB> <TAB> <TAB> self. current_train_epoch = epoch_index <TAB> <TAB> <TAB> features = self. get_features ( examples, is_training = True ) <TAB> <TAB> else : <TAB> <TAB> <TAB> features = self. get_features ( examples, is_training = False ) <TAB> <TAB> all_dev_batches = [ ] <TAB> <TAB> for batch_insts in batch_reader ( features, batch_size ) : <TAB> <TAB> <TAB> batch_data = prepare_batch_data ( batch_insts ) <TAB> <TAB> <TAB> if len ( all_dev_batches ) < dev_count : <TAB> <TAB> <TAB> <TAB> all_dev_batches. append ( batch_data ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> for batch in all_dev_batches : <TAB> <TAB> <TAB> <TAB> <TAB> yield batch <TAB> <TAB> <TAB> <TAB> all_dev_batches = [ ]",True,len(all_dev_batches) == dev_count,len(all_dev_batches) == dev_count,0.648054838180542
|
||
|
4416,"def banbks ( a, m1, m2, al, indx, b ) : <TAB> n, m = a. shape <TAB> mm = m1 + m2 + 1 <TAB> l = m1 <TAB> for k in range ( n ) : <TAB> <TAB> i = indx [ k ] <TAB> <TAB> if i!= k : <TAB> <TAB> <TAB> tmp = b [ k ] <TAB> <TAB> <TAB> b [ k ] = b [ i ] <TAB> <TAB> <TAB> b [ i ] = tmp <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> l += 1 <TAB> <TAB> for i in range ( k + 1, l ) : <TAB> <TAB> <TAB> b [ i ] -= al [ k, i - k - 1 ] * b [ k ] <TAB> l = 1 <TAB> for i in range ( n - 1, - 1, - 1 ) : <TAB> <TAB> dum = b [ i ] <TAB> <TAB> for k in range ( 1, l ) : <TAB> <TAB> <TAB> dum -= a [ i, k ] * b [ k + i ] <TAB> <TAB> b [ i ] = dum / a [ i, 0 ] <TAB> <TAB> if l < mm : <TAB> <TAB> <TAB> l += 1",False,l < n,l < mm,0.6870582103729248
|
||
|
4417,"def _add_stack_elements_to_sequence ( stack, sequence_e, timeline_range, br_map ) : <TAB> _append_new_sub_element ( sequence_e, ""name"", text = stack. name ) <TAB> _append_new_sub_element ( <TAB> <TAB> sequence_e, ""duration"", text = ""{:.0f}"". format ( timeline_range. duration. value ) <TAB> ) <TAB> sequence_e. append ( _build_rate ( timeline_range. start_time. rate ) ) <TAB> track_rate = timeline_range. start_time. rate <TAB> media_e = _get_or_create_subelement ( sequence_e, ""media"" ) <TAB> video_e = _get_or_create_subelement ( media_e, ""video"" ) <TAB> audio_e = _get_or_create_subelement ( media_e, ""audio"" ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> media_e. clear ( ) <TAB> media_e. extend ( [ video_e, audio_e ] ) <TAB> for track in stack : <TAB> <TAB> track_elements = _build_top_level_track ( track, track_rate, br_map ) <TAB> <TAB> if track. kind == schema. TrackKind. Video : <TAB> <TAB> <TAB> video_e. append ( track_elements ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> audio_e. append ( track_elements ) <TAB> for marker in stack. markers : <TAB> <TAB> sequence_e. append ( _build_marker ( marker ) )",False,track.kind == schema.TrackKind.Audio,track.kind == schema.TrackKind.audio,0.6495248079299927
|
||
|
4418,def __next__ ( self ) : <TAB> self. _offset += 1 <TAB> if self. _offset >= len ( self. _results ) : <TAB> <TAB> if self. _results_left is False : <TAB> <TAB> <TAB> raise StopIteration ( ) <TAB> <TAB> self. fetch_more ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> while not len ( self. _results ) and self. _results_left : <TAB> <TAB> <TAB> self. fetch_more ( ) <TAB> if self. _offset < len ( self. _results ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _limit -= 1 <TAB> <TAB> <TAB> if self. _limit < 0 : <TAB> <TAB> <TAB> <TAB> raise StopIteration ( ) <TAB> <TAB> return self. _results [ self. _offset ] <TAB> else : <TAB> <TAB> raise StopIteration ( ),False,self._limit is not None,self._limit > 0,0.6658344268798828
|
||
|
4419,"def unsubscribe ( self ) : <TAB> for signum, handler in self. _previous_handlers. items ( ) : <TAB> <TAB> signame = self. signals [ signum ] <TAB> <TAB> if handler is None : <TAB> <TAB> <TAB> self. bus. log ( ""Restoring %s handler to SIG_DFL."" % signame ) <TAB> <TAB> <TAB> handler = _signal. SIG_DFL <TAB> <TAB> else : <TAB> <TAB> <TAB> self. bus. log ( ""Restoring %s handler %r."" % ( signame, handler ) ) <TAB> <TAB> try : <TAB> <TAB> <TAB> our_handler = _signal. signal ( signum, handler ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. bus. log ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Restored old %s handler %r, but our "" <TAB> <TAB> <TAB> <TAB> <TAB> ""handler was not registered."" % ( signame, handler ), <TAB> <TAB> <TAB> <TAB> <TAB> level = 30, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> self. bus. log ( <TAB> <TAB> <TAB> <TAB> ""Unable to restore %s handler %r."" % ( signame, handler ), <TAB> <TAB> <TAB> <TAB> level = 40, <TAB> <TAB> <TAB> <TAB> traceback = True, <TAB> <TAB> <TAB> )",False,our_handler is None,our_handler,0.6618780493736267
|
||
|
4420,"def get_party_total ( self, args ) : <TAB> self. party_total = frappe. _dict ( ) <TAB> for d in self. receivables : <TAB> <TAB> self. init_party_total ( d ) <TAB> <TAB> <TAB> <TAB> for k in list ( self. party_total [ d. party ] ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. party_total [ d. party ] [ k ] += d. get ( k, 0.0 ) <TAB> <TAB> <TAB> <TAB> self. set_party_details ( d )",False,"k not in ['currency', 'sales_person']",k in args,0.6559187173843384
|
||
|
4421,"def get_editops ( self ) : <TAB> if not self. _editops : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _editops = editops ( self. _opcodes, self. _str1, self. _str2 ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. _editops = editops ( self. _str1, self. _str2 ) <TAB> return self. _editops",False,self._opcodes,self.has_opcodes,0.6684092879295349
|
||
|
4422,"def get_allele_frequency ( self, pop_pos, locus_name ) : <TAB> """"""Calculate the allele frequency for a certain locus on a population."""""" <TAB> if len ( self. __allele_frequency ) == 0 : <TAB> <TAB> geno_freqs = self. _controller. calc_allele_genotype_freqs ( self. _fname ) <TAB> <TAB> pop_iter, loc_iter = geno_freqs <TAB> <TAB> for locus_info in loc_iter : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. __allele_frequency [ locus_info [ 0 ] ] = None, None <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. __allele_frequency [ locus_info [ 0 ] ] = locus_info [ 1 : ] <TAB> info = self. __allele_frequency [ locus_name ] <TAB> pop_name, freqs, total = info [ 1 ] [ pop_pos ] <TAB> allele_freq = { } <TAB> alleles = info [ 0 ] <TAB> for i, allele in enumerate ( alleles ) : <TAB> <TAB> allele_freq [ allele ] = freqs [ i ] <TAB> return total, allele_freq",False,locus_info[0] is None,locus_name == 'None',0.6565197110176086
|
||
|
4423,"def validate_on_or_after ( not_on_or_after, slack ) : <TAB> if not_on_or_after : <TAB> <TAB> now = time_util. utc_now ( ) <TAB> <TAB> nooa = calendar. timegm ( time_util. str_to_time ( not_on_or_after ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ResponseLifetimeExceed ( <TAB> <TAB> <TAB> <TAB> ""Can't use it, it's too old %d > %d"" % ( now - slack, nooa ) <TAB> <TAB> <TAB> ) <TAB> <TAB> return nooa <TAB> else : <TAB> <TAB> return False",False,now > nooa + slack,now - slack > nooa,0.6659272909164429
|
||
|
4424,"def print_path ( path ) : <TAB> for i, step in enumerate ( path ) : <TAB> <TAB> <TAB> <TAB> next = path [ ( i + 1 ) % len ( path ) ] <TAB> <TAB> outstream. write ( "" %s -- "" % str ( type ( step ) ) ) <TAB> <TAB> if isinstance ( step, dict ) : <TAB> <TAB> <TAB> for key, val in step. items ( ) : <TAB> <TAB> <TAB> <TAB> if val is next : <TAB> <TAB> <TAB> <TAB> <TAB> outstream. write ( ""[%s]"" % repr ( key ) ) <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> outstream. write ( ""[key] = %s"" % repr ( val ) ) <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> elif isinstance ( step, list ) : <TAB> <TAB> <TAB> outstream. write ( ""[%d]"" % step. index ( next ) ) <TAB> <TAB> elif isinstance ( step, tuple ) : <TAB> <TAB> <TAB> outstream. write ( ""( tuple )"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> outstream. write ( repr ( step ) ) <TAB> <TAB> outstream. write ( "" ->\n"" ) <TAB> outstream. write ( ""\n"" )",False,key is next,"isinstance(val, dict)",0.6659658551216125
|
||
|
4425,"def read_triple ( self, path, mode, skip_first_line = False, format = [ 0, 1, 2 ] ) : <TAB> <TAB> if path is None : <TAB> <TAB> return None <TAB> print ( ""Reading {} triples...."". format ( mode ) ) <TAB> heads = [ ] <TAB> tails = [ ] <TAB> rels = [ ] <TAB> with open ( path ) as f : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> _ = f. readline ( ) <TAB> <TAB> for line in f : <TAB> <TAB> <TAB> triple = line. strip ( ). split ( ""\t"" ) <TAB> <TAB> <TAB> h, r, t = triple [ format [ 0 ] ], triple [ format [ 1 ] ], triple [ format [ 2 ] ] <TAB> <TAB> <TAB> heads. append ( self. entity2id [ h ] ) <TAB> <TAB> <TAB> rels. append ( self. relation2id [ r ] ) <TAB> <TAB> <TAB> tails. append ( self. entity2id [ t ] ) <TAB> heads = np. array ( heads, dtype = np. int64 ) <TAB> tails = np. array ( tails, dtype = np. int64 ) <TAB> rels = np. array ( rels, dtype = np. int64 ) <TAB> print ( ""Finished. Read {} {} triples."". format ( len ( heads ), mode ) ) <TAB> return ( heads, rels, tails )",True,skip_first_line,skip_first_line,0.6486442685127258
|
||
|
4426,"def write_results_json ( self ) : <TAB> """"""Write test results into a json-formatted file"""""" <TAB> results = OrderedDict ( <TAB> <TAB> [ <TAB> <TAB> <TAB> ( ""tester_host"", self. hostname ), <TAB> <TAB> <TAB> ( ""start_time"", self. start_time ), <TAB> <TAB> <TAB> ( ""elapsed_time"", self. elapsed_time ), <TAB> <TAB> <TAB> ( ""tests"", OrderedDict ( ) ), <TAB> <TAB> ] <TAB> ) <TAB> for status, test, reason in self. all_results ( ) : <TAB> <TAB> test_result = OrderedDict ( <TAB> <TAB> <TAB> [ <TAB> <TAB> <TAB> <TAB> ( ""name"", test. name ), <TAB> <TAB> <TAB> <TAB> ( ""description"", test. shortDescription ( ) ), <TAB> <TAB> <TAB> <TAB> ( ""status"", status ), <TAB> <TAB> <TAB> <TAB> ( ""start_time"", test. start_time ), <TAB> <TAB> <TAB> <TAB> ( ""elapsed_time"", test. elapsed_time ), <TAB> <TAB> <TAB> <TAB> ( ""measurements"", test. measurements ), <TAB> <TAB> <TAB> ] <TAB> <TAB> ) <TAB> <TAB> if status in ( ""ERROR"", ""FAILURE"", ""EXPECTED_FAILURE"" ) : <TAB> <TAB> <TAB> test_result [ ""message"" ] = str ( test. err [ 1 ] ) <TAB> <TAB> <TAB> test_result [ ""err_type"" ] = test. err [ 0 ]. __name__ <TAB> <TAB> <TAB> test_result [ ""err_output"" ] = reason <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> test_result [ ""message"" ] = reason <TAB> <TAB> results [ ""tests"" ] [ test. name ] = test_result <TAB> with open ( os. path. join ( self. out_dir, ""results.json"" )",False,reason,"status in ('SUCCESS', 'FAIL', 'ERROR')",0.6961096525192261
|
||
|
4427,"def filter ( self, lexer, stream ) : <TAB> current_type = None <TAB> current_value = None <TAB> for ttype, value in stream : <TAB> <TAB> if ttype is current_type : <TAB> <TAB> <TAB> current_value += value <TAB> <TAB> else : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> yield current_type, current_value <TAB> <TAB> <TAB> current_type = ttype <TAB> <TAB> <TAB> current_value = value <TAB> if<mask> : <TAB> <TAB> yield current_type, current_value",False,current_type is not None,current_type is None,0.6527062058448792
|
||
|
4428,"def _tearDownPreviousClass ( self, test, result ) : <TAB> <TAB> super ( TestSuite, self ). _tearDownPreviousClass ( test, result ) <TAB> previousClass = getattr ( result, ""_previousTestClass"", None ) <TAB> currentClass = test. __class__ <TAB> if currentClass == previousClass : <TAB> <TAB> return <TAB> <TAB> if previousClass and getattr ( previousClass, ""tearDownClass"", None ) : <TAB> <TAB> prerun_class_attributes = getattr ( <TAB> <TAB> <TAB> previousClass, ""_prerun_class_attributes"", None <TAB> <TAB> ) <TAB> <TAB> if prerun_class_attributes is not None : <TAB> <TAB> <TAB> previousClass. _prerun_class_attributes = None <TAB> <TAB> <TAB> del previousClass. _prerun_class_attributes <TAB> <TAB> <TAB> for attr in prerun_class_attributes : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> attr_value = getattr ( previousClass, attr, None ) <TAB> <TAB> <TAB> <TAB> <TAB> if attr_value is None : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> <TAB> if isinstance ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> attr_value, ( bool, ) + six. string_types + six. integer_types <TAB> <TAB> <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> setattr ( previousClass, attr, None ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> <TAB> log. warning ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""Deleting extra class attribute after test run: %s.%s(%s). "" <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""Please consider using '",True,"hasattr(previousClass, attr)","hasattr(previousClass, attr)",0.6533479690551758
|
||
|
4429,"def listClasses ( module = None ) : <TAB> if module : <TAB> <TAB> __import__ ( module ) <TAB> <TAB> pkg = sys. modules [ module ] <TAB> <TAB> print ( ""Available Interfaces:"" ) <TAB> <TAB> for k, v in sorted ( list ( pkg. __dict__. items ( ) ) ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> print ( ""\t%s"" % k )",False,"inspect.isclass(v) and issubclass(v, Interface)",v,0.649504542350769
|
||
|
4430,"def get_cur_window ( self ) : <TAB> i = 0 <TAB> while True : <TAB> <TAB> try : <TAB> <TAB> <TAB> cur_window = self. sniffer. the_display. get_input_focus ( ). focus <TAB> <TAB> <TAB> cur_class = None <TAB> <TAB> <TAB> cur_name = None <TAB> <TAB> <TAB> while cur_class is None and cur_class is None : <TAB> <TAB> <TAB> <TAB> if type ( cur_window ) is int : <TAB> <TAB> <TAB> <TAB> <TAB> return None, None, None <TAB> <TAB> <TAB> <TAB> cur_name = cur_window. get_wm_name ( ) <TAB> <TAB> <TAB> <TAB> cur_class = cur_window. get_wm_class ( ) <TAB> <TAB> <TAB> <TAB> if cur_class is None : <TAB> <TAB> <TAB> <TAB> <TAB> cur_window = cur_window. query_tree ( ). parent <TAB> <TAB> except Xlib. error. XError : <TAB> <TAB> <TAB> i += 1 <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return None, None, None <TAB> <TAB> <TAB> continue <TAB> <TAB> break <TAB> return cur_class [ 1 ], cur_window, cur_name",False,i >= 10,i > 2,0.6876682639122009
|
||
|
4431,"def _compare_dirs ( self, dir1, dir2 ) : <TAB> <TAB> <TAB> diff = [ ] <TAB> for root, dirs, files in os. walk ( dir1 ) : <TAB> <TAB> for file_ in files : <TAB> <TAB> <TAB> path = os. path. join ( root, file_ ) <TAB> <TAB> <TAB> target_path = os. path. join ( dir2, os. path. split ( path ) [ - 1 ] ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> diff. append ( file_ ) <TAB> return diff",False,not os.path.exists(target_path),os.path.exists(target_path),0.6455015540122986
|
||
|
4432,"def _ ( column, pivotValue ) : <TAB> if column == colList [ 0 ] : <TAB> <TAB> query = dumpNode. query. replace ( <TAB> <TAB> <TAB> ""'%s'"" if unescaper. escape ( pivotValue, False )!= pivotValue else ""%s"", ""%s"" <TAB> <TAB> ) % ( <TAB> <TAB> <TAB> agent. preprocessField ( table, column ), <TAB> <TAB> <TAB> table, <TAB> <TAB> <TAB> agent. preprocessField ( table, column ), <TAB> <TAB> <TAB> unescaper. escape ( pivotValue, False ), <TAB> <TAB> ) <TAB> else : <TAB> <TAB> query = dumpNode. query2. replace ( <TAB> <TAB> <TAB> ""'%s'"" if unescaper. escape ( pivotValue, False )!= pivotValue else ""%s"", ""%s"" <TAB> <TAB> ) % ( <TAB> <TAB> <TAB> agent. preprocessField ( table, column ), <TAB> <TAB> <TAB> table, <TAB> <TAB> <TAB> agent. preprocessField ( table, colList [ 0 ] ), <TAB> <TAB> <TAB> unescaper. escape ( pivotValue, False ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> else pivotValue, <TAB> <TAB> ) <TAB> query = agent. whereQuery ( query ) <TAB> return unArrayizeValue ( <TAB> <TAB> inject. getValue ( <TAB> <TAB> <TAB> query, blind = blind, time = blind, union = not blind, error = not blind <TAB> <TAB> ) <TAB> )",False,SINGLE_QUOTE_MARKER not in dumpNode.query2,pivotValue == False,0.6576843857765198
|
||
|
4433,"def save ( self, * args, ** kwargs ) : <TAB> ""Process form"" <TAB> if self. instance : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if self. cleaned_data [ ""active"" ] == ""active"" : <TAB> <TAB> <TAB> <TAB> self. instance. active = True <TAB> <TAB> <TAB> if self. cleaned_data [ ""active"" ] == ""inactive"" : <TAB> <TAB> <TAB> <TAB> self. instance. active = False <TAB> <TAB> <TAB> self. instance. save ( )",False,self.is_valid(),self.cleaned_data.get('active'),0.6517860889434814
|
||
|
4434,"def import_til ( self ) : <TAB> log ( ""Importing type libraries..."" ) <TAB> cur = self. db_cursor ( ) <TAB> sql = ""select name from diff.program_data where type = 'til'"" <TAB> cur. execute ( sql ) <TAB> for row in cur. fetchall ( ) : <TAB> <TAB> til = row [ ""name"" ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> til = til. decode ( ""utf-8"" ) <TAB> <TAB> try : <TAB> <TAB> <TAB> add_default_til ( til ) <TAB> <TAB> except : <TAB> <TAB> <TAB> log ( ""Error loading til %s: %s"" % ( row [ ""name"" ], str ( sys. exc_info ( ) [ 1 ] ) ) ) <TAB> cur. close ( ) <TAB> auto_wait ( )",False,type(til) is bytes,til,0.6544854640960693
|
||
|
4435,"def get_identity ( self ) : <TAB> """"""The assertion can contain zero or one attributeStatements"""""" <TAB> ava = { } <TAB> for _assertion in self. assertions : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if _assertion. advice. assertion : <TAB> <TAB> <TAB> <TAB> for tmp_assertion in _assertion. advice. assertion : <TAB> <TAB> <TAB> <TAB> <TAB> if tmp_assertion. attribute_statement : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> assert len ( tmp_assertion. attribute_statement ) == 1 <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ava. update ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. read_attribute_statement ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> tmp_assertion. attribute_statement [ 0 ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> if _assertion. attribute_statement : <TAB> <TAB> <TAB> assert len ( _assertion. attribute_statement ) == 1 <TAB> <TAB> <TAB> _attr_statem = _assertion. attribute_statement [ 0 ] <TAB> <TAB> <TAB> ava. update ( self. read_attribute_statement ( _attr_statem ) ) <TAB> <TAB> if not ava : <TAB> <TAB> <TAB> logger. error ( ""Missing Attribute Statement"" ) <TAB> return ava",True,_assertion.advice,_assertion.advice,0.6740684509277344
|
||
|
4436,"def maybe_move ( self, spec, dist_filename, setup_base ) : <TAB> dst = os. path. join ( self. build_directory, spec. key ) <TAB> if os. path. exists ( dst ) : <TAB> <TAB> msg = ""%r already exists in %s; build directory %s will not be kept"" <TAB> <TAB> log. warn ( msg, spec. key, self. build_directory, setup_base ) <TAB> <TAB> return setup_base <TAB> if os. path. isdir ( dist_filename ) : <TAB> <TAB> setup_base = dist_filename <TAB> else : <TAB> <TAB> if os. path. dirname ( dist_filename ) == setup_base : <TAB> <TAB> <TAB> os. unlink ( dist_filename ) <TAB> <TAB> contents = os. listdir ( setup_base ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> dist_filename = os. path. join ( setup_base, contents [ 0 ] ) <TAB> <TAB> <TAB> if os. path. isdir ( dist_filename ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> setup_base = dist_filename <TAB> ensure_directory ( dst ) <TAB> shutil. move ( setup_base, dst ) <TAB> return dst",False,len(contents) == 1,len(contents) > 0,0.6538456678390503
|
||
|
4437,"def __str__ ( self ) : <TAB> reps = [ ] <TAB> for index, layer in enumerate ( self ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> rep = inspect. getsource ( layer ). strip ( ). rstrip ( "","" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> rep = str ( layer ) <TAB> <TAB> <TAB> <TAB> rep = ""({index}): {rep},"". format ( index = index, rep = rep ) <TAB> <TAB> for line in rep. splitlines ( ) : <TAB> <TAB> <TAB> reps. append ( "" {line}\n"". format ( line = line ) ) <TAB> reps = """". join ( reps ) <TAB> if reps : <TAB> <TAB> reps = ""\n"" + reps <TAB> return ""{cls}({layers})"". format ( <TAB> <TAB> cls = self. __class__. __name__, <TAB> <TAB> layers = reps, <TAB> )",False,"getattr(layer, '__name__', None) == '<lambda>'","isinstance(layer, str)",0.6475077867507935
|
||
|
4438,"def debug_tree ( tree ) : <TAB> l = [ ] <TAB> for elt in tree : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> l. append ( _names. get ( elt, elt ) ) <TAB> <TAB> elif isinstance ( elt, str ) : <TAB> <TAB> <TAB> l. append ( elt ) <TAB> <TAB> else : <TAB> <TAB> <TAB> l. append ( debug_tree ( elt ) ) <TAB> return l",False,"isinstance(elt, (int, long))","isinstance(elt, int)",0.6580402851104736
|
||
|
4439,"def export_as_search_index ( self ) -> Dict [ str, Any ] : <TAB> """"""Get the search index DTO from this transaction"""""" <TAB> <TAB> search_indexes = { <TAB> <TAB> ""timestamp"" : int ( self. timestamp ), <TAB> <TAB> ""tag"" : self. tag, <TAB> <TAB> ""block_id"" : int ( self. block_id ), <TAB> } <TAB> if self. invoker : <TAB> <TAB> search_indexes [ ""invoker"" ] = self. invoker <TAB> reserved_keywords = search_indexes. keys ( ) <TAB> for key, value in self. custom_indexed_data. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> search_indexes [ key ] = value <TAB> <TAB> else : <TAB> <TAB> <TAB> _log. error ( <TAB> <TAB> <TAB> <TAB> f""Requested field name: {key} is a reserved keyword. Will not index"" <TAB> <TAB> <TAB> ) <TAB> return search_indexes",False,key not in reserved_keywords,key in reserved_keywords,0.6650009155273438
|
||
|
4440,"def load ( self, session, * args, ** kwargs ) : <TAB> from mailpile. plugins. core import Rescan <TAB> <TAB> <TAB> <TAB> random. seed ( os. urandom ( 8 ) ) <TAB> keep_lockdown = self. sys. lockdown <TAB> with self. _lock : <TAB> <TAB> rv = self. _unlocked_load ( session, * args, ** kwargs ) <TAB> if not kwargs. get ( ""public_only"" ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> from mailpile. plugins. setup_magic import Setup <TAB> <TAB> <TAB> Setup ( session, ""setup"" ). run ( ) <TAB> <TAB> <TAB> <TAB> Rescan ( session, ""rescan"" ). _idx ( wait = False ) <TAB> <TAB> <TAB> <TAB> self. gnupghome = GnuPG ( self ). gnupghome ( ) <TAB> if keep_lockdown : <TAB> <TAB> self. sys. lockdown = keep_lockdown <TAB> return rv",False,self.version != APPVER,rv,0.6569525599479675
|
||
|
4441,"def prune_constraints ( self, constraints, a ) : <TAB> <TAB> <TAB> <TAB> <TAB> if self. inactive_window == 0 : <TAB> <TAB> return <TAB> k = 0 <TAB> for i, sample in enumerate ( constraints ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> n_old_constraints_sample = len ( self. last_active [ i ] ) <TAB> <TAB> if n_old_constraints_sample < len ( sample ) : <TAB> <TAB> <TAB> self. last_active [ i ] = np. hstack ( [ self. last_active [ i ], [ 0 ] ] ) <TAB> <TAB> <TAB> <TAB> inactive_this = a [ k : k + len ( sample ) ] < self. inactive_threshold * self. C <TAB> <TAB> self. last_active [ i ] [ inactive_this ] += 1 <TAB> <TAB> k += len ( sample ) <TAB> <TAB> assert len ( sample ) == len ( self. last_active [ i ] ) <TAB> <TAB> <TAB> <TAB> to_remove = self. last_active [ i ] > self. inactive_window <TAB> <TAB> self. last_active [ i ] = self. last_active [ i ] [ ~ to_remove ] <TAB> <TAB> for j in np. where ( to_remove ) [ 0 ] [ : : - 1 ] : <TAB> <TAB> <TAB> del sample [ j ] <TAB> <TAB> assert len ( sample ) == len ( self. last_active [ i ] )",False,not len(sample),self.last_active[i] == 0,0.6522111296653748
|
||
|
4442,"def _process_template_configs ( name, implementation, configs, rules ) : <TAB> from jinja2. exceptions import TemplateNotFound <TAB> counters = defaultdict ( lambda : 1 ) <TAB> includes = defaultdict ( list ) <TAB> for config in configs : <TAB> <TAB> if not isinstance ( config, dict ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> if ""type"" not in config : <TAB> <TAB> <TAB> continue <TAB> <TAB> template_type = config [ ""type"" ] <TAB> <TAB> del config [ ""type"" ] <TAB> <TAB> if template_type not in rules : <TAB> <TAB> <TAB> continue <TAB> <TAB> rule = rules [ template_type ] <TAB> <TAB> data = _process_template_config ( <TAB> <TAB> <TAB> name, implementation, rule, config = config, counter = counters [ template_type ] <TAB> <TAB> ) <TAB> <TAB> if data is None : <TAB> <TAB> <TAB> continue <TAB> <TAB> includes [ template_type ]. append ( rule [ ""to_entry"" ] ( data ) ) <TAB> <TAB> counters [ template_type ] += 1 <TAB> for template_type in rules : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> rule = rules [ template_type ] <TAB> <TAB> <TAB> data = _process_template_config ( name, implementation, rule ) <TAB> <TAB> <TAB> if data is not None : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> app. jinja_env. get_or_select_template ( data [ ""template"" ] ) <TAB> <TAB> <TAB> <TAB> except TemplateNotFound : <TAB> <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> <TAB> <TAB> _logger. exception ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""Error in template {}, not going to",False,len(includes[template_type]) == 0,template_type in rules,0.6547961831092834
|
||
|
4443,"def set_meta ( self, dataset, overwrite = True, ** kwd ) : <TAB> super ( ). set_meta ( dataset, overwrite = overwrite, ** kwd ) <TAB> try : <TAB> <TAB> if dataset and zipfile. is_zipfile ( dataset. file_name ) : <TAB> <TAB> <TAB> with zipfile. ZipFile ( dataset. file_name ) as tempzip : <TAB> <TAB> <TAB> <TAB> if ""searchgui.properties"" in tempzip. namelist ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> with tempzip. open ( ""searchgui.properties"" ) as fh : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for line in io. TextIOWrapper ( fh ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> version = line. split ( ""="" ) [ 1 ]. strip ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> dataset. metadata. searchgui_version = version <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> dataset. metadata. searchgui_major_version = ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> version. split ( ""."" ) [ 0 ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> except Exception as e : <TAB> <TAB> log. warning ( ""%s, set_meta Exception: %s"", self, e )",False,line.startswith('searchgui.version'),line.startswith(b'<'),0.648409903049469
|
||
|
4444,"def _key_name ( self, key_code ) : <TAB> """"""Return a normalized key name for key_code."""""" <TAB> if isinstance ( key_code, int ) : <TAB> <TAB> if key_code in key_map. keys ( ) : <TAB> <TAB> <TAB> return key_map [ key_code ] <TAB> curs_key_name = self. _curses_key_name ( key_code ) <TAB> if curs_key_name : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return key_map [ curs_key_name ] <TAB> <TAB> self. is_typeable = ( <TAB> <TAB> <TAB> True <TAB> <TAB> ) <TAB> <TAB> return curs_key_name <TAB> else : <TAB> <TAB> char = None <TAB> <TAB> if key_code in key_map. keys ( ) : <TAB> <TAB> <TAB> return key_map [ key_code ] <TAB> <TAB> if sys. version_info [ 0 ] >= 3 : <TAB> <TAB> <TAB> if isinstance ( key_code, str ) : <TAB> <TAB> <TAB> <TAB> self. is_typeable = True <TAB> <TAB> <TAB> <TAB> return key_code <TAB> <TAB> try : <TAB> <TAB> <TAB> char = chr ( key_code ) <TAB> <TAB> except : <TAB> <TAB> <TAB> pass <TAB> <TAB> if char is not None : <TAB> <TAB> <TAB> self. is_typeable = True <TAB> <TAB> <TAB> return char <TAB> return False",False,curs_key_name in key_map.keys(),key_code in key_map.keys(),0.6498466730117798
|
||
|
4445,"def _document_params ( self, section, value, comments, path, shape ) : <TAB> param_section = section. add_new_section ( ""param-values"" ) <TAB> self. _start_nested_value ( param_section, ""("" ) <TAB> for key, val in value. items ( ) : <TAB> <TAB> path. append ( "".%s"" % key ) <TAB> <TAB> item_section = param_section. add_new_section ( key ) <TAB> <TAB> item_section. style. new_line ( ) <TAB> <TAB> item_comment = self. _get_comment ( path, comments ) <TAB> <TAB> if item_comment : <TAB> <TAB> <TAB> item_section. write ( item_comment ) <TAB> <TAB> <TAB> item_section. style. new_line ( ) <TAB> <TAB> item_section. write ( key + ""="" ) <TAB> <TAB> <TAB> <TAB> item_shape = None <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> item_shape = shape. members. get ( key ) <TAB> <TAB> self. _document ( item_section, val, comments, path, item_shape ) <TAB> <TAB> path. pop ( ) <TAB> param_section_end = param_section. add_new_section ( ""ending-parenthesis"" ) <TAB> self. _end_nested_value ( param_section_end, "")"" )",False,shape,shape is not None,0.6855771541595459
|
||
|
4446,"def __init__ ( self, * args, ** kw ) : <TAB> for i, ( name, typ ) in enumerate ( self. _fields_ ) : <TAB> <TAB> def_arg = None <TAB> <TAB> if i < len ( args ) : <TAB> <TAB> <TAB> def_arg = args [ i ] <TAB> <TAB> if name in kw : <TAB> <TAB> <TAB> def_arg = kw [ name ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if not isinstance ( def_arg, tuple ) : <TAB> <TAB> <TAB> <TAB> def_arg = ( def_arg, ) <TAB> <TAB> else : <TAB> <TAB> <TAB> def_arg = ( ) <TAB> <TAB> if len ( def_arg ) == 1 and isinstance ( def_arg [ 0 ], typ ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> def_val = def_arg [ 0 ] <TAB> <TAB> else : <TAB> <TAB> <TAB> def_val = typ ( * def_arg ) <TAB> <TAB> setattr ( self, name, def_val )",False,def_arg is not None,def_arg is None,0.6618744134902954
|
||
|
4447,"def _is_legacy_mode ( self, node ) : <TAB> """"""Checks if the ``ast.Call`` node's keywords signal using legacy mode."""""" <TAB> script_mode = False <TAB> py_version = ""py2"" <TAB> for kw in node. keywords : <TAB> <TAB> if kw. arg == ""script_mode"" : <TAB> <TAB> <TAB> script_mode = ( <TAB> <TAB> <TAB> <TAB> bool ( kw. value. value ) if isinstance ( kw. value, ast. NameConstant ) else True <TAB> <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> py_version = kw. value. s if isinstance ( kw. value, ast. Str ) else ""py3"" <TAB> return not ( py_version. startswith ( ""py3"" ) or script_mode )",False,kw.arg == 'py_version',kw.arg == 'py2',0.6535788774490356
|
||
|
4448,"def create ( ) : <TAB> image_shape = height, width, colors <TAB> kw = dict ( parse_fn = parse_fn ) <TAB> datasets = dict ( <TAB> <TAB> train = core. DataSet. from_files ( train_files, image_shape, ** kw ). skip ( valid ), <TAB> <TAB> valid = core. DataSet. from_files ( train_files, image_shape, ** kw ). take ( valid ), <TAB> <TAB> test = { <TAB> <TAB> <TAB> key : core. DataSet. from_files ( value, image_shape, ** kw ) <TAB> <TAB> <TAB> for key, value in test_files. items ( ) <TAB> <TAB> }, <TAB> ) <TAB> if cache : <TAB> <TAB> cached_datasets = { } <TAB> <TAB> for key, value in datasets. items ( ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> cached_datasets [ key ] = { k : v. cache ( ) for k, v in value. items ( ) } <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> cached_datasets [ key ] = value. cache ( ) <TAB> <TAB> datasets = cached_datasets <TAB> return cls ( name + ""-"" + str ( valid ), nclass = nclass, ** datasets )",False,"isinstance(value, dict)",value is not None,0.6478612422943115
|
||
|
4449,"def chat ( self, gpg_args, callback, * args, ** kwargs ) : <TAB> """"""This lets a callback have a chat with the GPG process..."""""" <TAB> gpg_args = ( <TAB> <TAB> self. common_args ( interactive = True, will_send_passphrase = True ) <TAB> <TAB> + [ <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""--no-tty"", <TAB> <TAB> <TAB> ""--command-fd=0"", <TAB> <TAB> <TAB> ""--status-fd=1"", <TAB> <TAB> ] <TAB> <TAB> + ( gpg_args or [ ] ) <TAB> ) <TAB> proc = None <TAB> try : <TAB> <TAB> <TAB> <TAB> self. debug ( ""Running %s"" % "" "". join ( gpg_args ) ) <TAB> <TAB> self. event. update_args ( gpg_args ) <TAB> <TAB> proc = Popen ( <TAB> <TAB> <TAB> gpg_args, stdin = PIPE, stdout = PIPE, stderr = PIPE, bufsize = 0, long_running = True <TAB> <TAB> ) <TAB> <TAB> return callback ( proc, * args, ** kwargs ) <TAB> finally : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> proc. stdin. close ( ) <TAB> <TAB> if proc : <TAB> <TAB> <TAB> self. event. update_return_code ( proc. wait ( ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. event. update_return_code ( - 1 )",False,proc and proc.stdin,proc,0.659489095211029
|
||
|
4450,"def alter_list_data_to_serialize ( self, request, data ) : <TAB> data = super ( TaskTemplateResource, self ). alter_list_data_to_serialize ( request, data ) <TAB> user_model = get_user_model ( ) <TAB> user = request. user <TAB> collected_templates = ( <TAB> <TAB> user_model. objects. get ( username = user. username ) <TAB> <TAB>. tasktemplate_set. all ( ) <TAB> <TAB>. values_list ( ""id"", flat = True ) <TAB> ) <TAB> template_ids = [ bundle. obj. id for bundle in data [ ""objects"" ] ] <TAB> templates_labels = TemplateLabelRelation. objects. fetch_templates_labels ( <TAB> <TAB> template_ids <TAB> ) <TAB> for bundle in data [ ""objects"" ] : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> bundle. data [ ""is_add"" ] = 1 <TAB> <TAB> else : <TAB> <TAB> <TAB> bundle. data [ ""is_add"" ] = 0 <TAB> <TAB> bundle. data [ ""template_labels"" ] = templates_labels. get ( bundle. obj. id, [ ] ) <TAB> return data",False,bundle.obj.id in collected_templates,'is_add' not in bundle.data,0.6549702882766724
|
||
|
4451,"def _continue ( self ) : <TAB> <TAB> <TAB> <TAB> <TAB> while True : <TAB> <TAB> try : <TAB> <TAB> <TAB> value = unwrap ( self. _last_value ) <TAB> <TAB> <TAB> error = None <TAB> <TAB> except BaseException as e : <TAB> <TAB> <TAB> value = None <TAB> <TAB> <TAB> error = e <TAB> <TAB> try : <TAB> <TAB> <TAB> self. _accept_yield_result ( self. _continue_on_generator ( value, error ) ) <TAB> <TAB> except StopIteration as error : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return_value = error. value <TAB> <TAB> <TAB> except AttributeError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return_value = None <TAB> <TAB> <TAB> self. _queue_exit ( return_value ) <TAB> <TAB> except GeneratorExit as error : <TAB> <TAB> <TAB> error_type = type ( error ) <TAB> <TAB> <TAB> if error_type is AsyncTaskResult : <TAB> <TAB> <TAB> <TAB> self. _queue_exit ( error. result ) <TAB> <TAB> <TAB> elif error_type is AsyncTaskCancelledError : <TAB> <TAB> <TAB> <TAB> self. _accept_error ( error ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. _queue_exit ( None ) <TAB> <TAB> except BaseException as error : <TAB> <TAB> <TAB> self. _accept_error ( error ) <TAB> <TAB> if self. is_computed ( ) : <TAB> <TAB> <TAB> return <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return",False,len(self._dependencies) > 0,self.is_generator(),0.6588523387908936
|
||
|
4452,"def _Determine_Do ( self ) : <TAB> self. applicable = 1 <TAB> self. value = os. environ. get ( self. name, None ) <TAB> if self. value is None and black. configure. items. has_key ( ""buildType"" ) : <TAB> <TAB> buildType = black. configure. items [ ""buildType"" ]. Get ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. value = ""warn"" <TAB> <TAB> else : <TAB> <TAB> <TAB> self. value = None <TAB> self. determined = 1",False,buildType == 'debug',buildType and buildType.Get() == 'warn',0.6556507349014282
|
||
|
4453,"def validate_precedence ( self ) : <TAB> preclist = [ ] <TAB> if self. prec : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. log. error ( ""precedence must be a list or tuple"" ) <TAB> <TAB> <TAB> self. error = 1 <TAB> <TAB> <TAB> return <TAB> <TAB> for level, p in enumerate ( self. prec ) : <TAB> <TAB> <TAB> if not isinstance ( p, ( list, tuple ) ) : <TAB> <TAB> <TAB> <TAB> self. log. error ( ""Bad precedence table"" ) <TAB> <TAB> <TAB> <TAB> self. error = 1 <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> if len ( p ) < 2 : <TAB> <TAB> <TAB> <TAB> self. log. error ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Malformed precedence entry %s. Must be (assoc, term,..., term)"", p <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> self. error = 1 <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> assoc = p [ 0 ] <TAB> <TAB> <TAB> if not isinstance ( assoc, str ) : <TAB> <TAB> <TAB> <TAB> self. log. error ( ""precedence associativity must be a string"" ) <TAB> <TAB> <TAB> <TAB> self. error = 1 <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> for term in p [ 1 : ] : <TAB> <TAB> <TAB> <TAB> if not isinstance ( term, str ) : <TAB> <TAB> <TAB> <TAB> <TAB> self. log. error ( ""precedence items must be strings"" ) <TAB> <TAB> <TAB> <TAB> <TAB> self. error = 1 <TAB> <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> <TAB> preclist. append ( ( term",False,"not isinstance(self.prec, (list, tuple))","not isinstance(self.prec, list)",0.6559296250343323
|
||
|
4454,"def from_introspection ( cls, table_name, trigger_data ) : <TAB> ( <TAB> <TAB> id, <TAB> <TAB> name, <TAB> <TAB> proc, <TAB> <TAB> constraint, <TAB> <TAB> granularity, <TAB> <TAB> timing, <TAB> <TAB> events, <TAB> <TAB> definition, <TAB> <TAB> metadata, <TAB> ) = trigger_data <TAB> if metadata : <TAB> <TAB> metadata = json. loads ( metadata ) <TAB> else : <TAB> <TAB> metadata = { } <TAB> condition = None <TAB> if definition : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> when_off = definition. find ( ""WHEN ("" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> pos = when_off + 6 <TAB> <TAB> <TAB> brackets = 1 <TAB> <TAB> <TAB> while brackets : <TAB> <TAB> <TAB> <TAB> if definition [ pos ] == "")"" : <TAB> <TAB> <TAB> <TAB> <TAB> brackets -= 1 <TAB> <TAB> <TAB> <TAB> elif definition [ pos ] == ""("" : <TAB> <TAB> <TAB> <TAB> <TAB> brackets += 1 <TAB> <TAB> <TAB> <TAB> pos += 1 <TAB> <TAB> <TAB> condition = definition [ when_off + 6 : pos - 1 ] <TAB> trg = cls ( <TAB> <TAB> name = name, <TAB> <TAB> table_name = table_name, <TAB> <TAB> events = events, <TAB> <TAB> timing = timing, <TAB> <TAB> granularity = granularity, <TAB> <TAB> procedure = proc, <TAB> <TAB> condition = condition, <TAB> <TAB> is_constraint = bool ( constraint ), <TAB> <TAB> metadata = metadata, <TAB> ) <TAB> return trg",False,when_off != -1,when_off > -1,0.6642345786094666
|
||
|
4455,"def run ( self, edit ) : <TAB> if not self. has_selection ( ) : <TAB> <TAB> region = sublime. Region ( 0, self. view. size ( ) ) <TAB> <TAB> originalBuffer = self. view. substr ( region ) <TAB> <TAB> prefixed = self. prefix ( originalBuffer ) <TAB> <TAB> if prefixed : <TAB> <TAB> <TAB> self. view. replace ( edit, region, prefixed ) <TAB> <TAB> return <TAB> for region in self. view. sel ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> originalBuffer = self. view. substr ( region ) <TAB> <TAB> prefixed = self. prefix ( originalBuffer ) <TAB> <TAB> if prefixed : <TAB> <TAB> <TAB> self. view. replace ( edit, region, prefixed )",False,region.empty(),originalBuffer == '',0.6561012268066406
|
||
|
4456,"def format_errors ( messages ) : <TAB> errors = { } <TAB> for k, v in messages. items ( ) : <TAB> <TAB> key = camelize ( k, uppercase_first_letter = False ) <TAB> <TAB> if isinstance ( v, dict ) : <TAB> <TAB> <TAB> errors [ key ] = format_errors ( v ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> errors [ key ] = v [ 0 ] <TAB> return errors",True,"isinstance(v, list)","isinstance(v, list)",0.6535281538963318
|
||
|
4457,"def poll_authorizations ( self, orderr, deadline ) : <TAB> """"""Poll Order Resource for status."""""" <TAB> responses = [ ] <TAB> for url in orderr. body. authorizations : <TAB> <TAB> while datetime. datetime. now ( ) < deadline : <TAB> <TAB> <TAB> authzr = self. _authzr_from_response ( self. _post_as_get ( url ), uri = url ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> responses. append ( authzr ) <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> time. sleep ( 1 ) <TAB> <TAB> <TAB> if len ( responses ) < len ( orderr. body. authorizations ) : <TAB> <TAB> raise errors. TimeoutError ( ) <TAB> failed = [ ] <TAB> for authzr in responses : <TAB> <TAB> if authzr. body. status!= messages. STATUS_VALID : <TAB> <TAB> <TAB> for chall in authzr. body. challenges : <TAB> <TAB> <TAB> <TAB> if chall. error is not None : <TAB> <TAB> <TAB> <TAB> <TAB> failed. append ( authzr ) <TAB> if failed : <TAB> <TAB> raise errors. ValidationError ( failed ) <TAB> return orderr. update ( authorizations = responses )",False,authzr.body.status != messages.STATUS_PENDING,response,0.6537234783172607
|
||
|
4458,"def load_params ( self ) : <TAB> path = str ( self. load_path. with_suffix ( "".json"" ). resolve ( ) ) <TAB> log. info ( ""[loading parameters from {}]"". format ( path ) ) <TAB> with open ( path, ""r"", encoding = ""utf8"" ) as fp : <TAB> <TAB> params = json. load ( fp ) <TAB> for p in self. GRAPH_PARAMS : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if p in ( ""kb_embedding_control_sum"" ) and ( <TAB> <TAB> <TAB> <TAB> math. abs ( self. opt. get ( p, 0.0 ) - params. get ( p, 0.0 ) ) < 1e-3 <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> raise ConfigError ( <TAB> <TAB> <TAB> <TAB> ""`{}` parameter must be equal to saved model"" <TAB> <TAB> <TAB> <TAB> "" parameter value `{}`, but is equal to `{}`"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> p, params. get ( p ), self. opt. get ( p ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> )",False,self.opt.get(p) != params.get(p),p in params,0.6498596668243408
|
||
|
4459,"def _prepare_artifact ( <TAB> self, <TAB> artifact_or_path : Union [ wandb_artifacts. Artifact, str ], <TAB> name : Optional [ str ] = None, <TAB> type : Optional [ str ] = None, <TAB> aliases : Optional [ List [ str ] ] = None, ) -> Tuple [ wandb_artifacts. Artifact, List [ str ] ] : <TAB> aliases = aliases or [ ""latest"" ] <TAB> if isinstance ( artifact_or_path, str ) : <TAB> <TAB> if name is None : <TAB> <TAB> <TAB> name = ""run-%s-%s"" % ( self. id, os. path. basename ( artifact_or_path ) ) <TAB> <TAB> artifact = wandb. Artifact ( name, type ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> artifact. add_file ( artifact_or_path ) <TAB> <TAB> elif os. path. isdir ( artifact_or_path ) : <TAB> <TAB> <TAB> artifact. add_dir ( artifact_or_path ) <TAB> <TAB> elif ""://"" in artifact_or_path : <TAB> <TAB> <TAB> artifact. add_reference ( artifact_or_path ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""path must be a file, directory or external"" <TAB> <TAB> <TAB> <TAB> ""reference like s3://bucket/path"" <TAB> <TAB> <TAB> ) <TAB> else : <TAB> <TAB> artifact = artifact_or_path <TAB> if not isinstance ( artifact, wandb. Artifact ) : <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> ""You must pass an instance of wandb.Artifact or a "" <TAB> <TAB> <TAB> ""valid file path to log_artifact"" <TAB> <TAB> ) <TAB> if isinstance ( aliases, str ) : <TAB> <TAB> aliases = [ aliases ] <TAB> artifact. finalize ( ) <TAB> return artifact, aliases",True,os.path.isfile(artifact_or_path),os.path.isfile(artifact_or_path),0.6475059986114502
|
||
|
4460,"def __call__ ( self, data ) : <TAB> degree = math. pi * random. uniform ( * self. degrees ) / 180.0 <TAB> sin, cos = math. sin ( degree ), math. cos ( degree ) <TAB> if data. pos. size ( - 1 ) == 2 : <TAB> <TAB> matrix = [ [ cos, sin ], [ - sin, cos ] ] <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> matrix = [ [ 1, 0, 0 ], [ 0, cos, sin ], [ 0, - sin, cos ] ] <TAB> <TAB> elif self. axis == 1 : <TAB> <TAB> <TAB> matrix = [ [ cos, 0, - sin ], [ 0, 1, 0 ], [ sin, 0, cos ] ] <TAB> <TAB> else : <TAB> <TAB> <TAB> matrix = [ [ cos, sin, 0 ], [ - sin, cos, 0 ], [ 0, 0, 1 ] ] <TAB> return LinearTransformation ( torch. tensor ( matrix ) ) ( data )",True,self.axis == 0,self.axis == 0,0.6647530794143677
|
||
|
4461,def logic ( ) : <TAB> <TAB> if goRight == ACTIVE : <TAB> <TAB> dir. next = DirType. RIGHT <TAB> <TAB> run. next = True <TAB> elif goLeft == ACTIVE : <TAB> <TAB> dir. next = DirType. LEFT <TAB> <TAB> run. next = True <TAB> <TAB> if stop == ACTIVE : <TAB> <TAB> run. next = False <TAB> <TAB> if run : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> q. next [ 4 : 1 ] = q [ 3 : ] <TAB> <TAB> <TAB> q. next [ 0 ] = not q [ 3 ] <TAB> <TAB> else : <TAB> <TAB> <TAB> q. next [ 3 : ] = q [ 4 : 1 ] <TAB> <TAB> <TAB> q. next [ 3 ] = not q [ 0 ],False,dir == DirType.LEFT,next,0.6672411561012268
|
||
|
4462,"def reassembleTree ( self, tree ) : <TAB> root_id = None <TAB> root_elt = None <TAB> self. ids_from_idref = { } <TAB> self. elts_from_id = { } <TAB> for elt in tree. getiterator ( ) : <TAB> <TAB> attribs = elt. attrib <TAB> <TAB> id = attribs. get ( ""id"", None ) <TAB> <TAB> if id is None : <TAB> <TAB> <TAB> log. error ( ""No id attribute for element %r"", elt ) <TAB> <TAB> <TAB> continue <TAB> <TAB> idref = attribs. get ( ""idref"", None ) <TAB> <TAB> if idref is None : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> log. error ( ""Root should be %r, but found another:%r"", root_elt, elt ) <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> root_id = id <TAB> <TAB> <TAB> root_elt = elt <TAB> <TAB> else : <TAB> <TAB> <TAB> self. ids_from_idref. setdefault ( idref, [ ] ). append ( id ) <TAB> <TAB> self. elts_from_id [ id ] = elt <TAB> newTree = TreeNode ( root_elt ) <TAB> self. treeBuilder ( newTree, root_id ) <TAB> return newTree",False,root_id is not None,root_elt is None,0.6568630933761597
|
||
|
4463,"def set ( self, interface, listen_port = None, fwmark = None, private_key = None, peer = None ) : <TAB> msg = wgmsg ( ) <TAB> msg [ ""attrs"" ]. append ( [ ""WGDEVICE_A_IFNAME"", interface ] ) <TAB> if private_key is not None : <TAB> <TAB> self. _wg_test_key ( private_key ) <TAB> <TAB> msg [ ""attrs"" ]. append ( [ ""WGDEVICE_A_PRIVATE_KEY"", private_key ] ) <TAB> if listen_port is not None : <TAB> <TAB> msg [ ""attrs"" ]. append ( [ ""WGDEVICE_A_LISTEN_PORT"", listen_port ] ) <TAB> if fwmark is not None : <TAB> <TAB> msg [ ""attrs"" ]. append ( [ ""WGDEVICE_A_FWMARK"", fwmark ] ) <TAB> if peer is not None : <TAB> <TAB> self. _wg_set_peer ( msg, peer ) <TAB> <TAB> msg [ ""cmd"" ] = WG_CMD_SET_DEVICE <TAB> msg [ ""version"" ] = WG_GENL_VERSION <TAB> msg [ ""header"" ] [ ""type"" ] = self. prid <TAB> msg [ ""header"" ] [ ""flags"" ] = NLM_F_REQUEST | NLM_F_ACK <TAB> msg [ ""header"" ] [ ""pid"" ] = self. pid <TAB> msg. encode ( ) <TAB> self. sendto ( msg. data, ( 0, 0 ) ) <TAB> msg = self. get ( ) [ 0 ] <TAB> err = msg [ ""header"" ]. get ( ""error"", None ) <TAB> if err is not None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> logging. error ( ""Generic netlink protocol %s not found"" % self. prid ) <TAB> <TAB> <TAB> logging. error ( ""Please check if the protocol module is loaded"" ) <TAB> <TAB> raise err <TAB> return msg",False,"hasattr(err, 'code') and err.code == errno.ENOENT",self.prid is None,0.6485620141029358
|
||
|
4464,"def test_policy_gradient_cartpole ( self ) : <TAB> """"""Trains a policy on cartpole."""""" <TAB> task = rl_task. RLTask ( ""CartPole-v0"", max_steps = 200 ) <TAB> lr = lambda : lr_schedules. multifactor ( constant = 1e-2, factors = ""constant"" ) <TAB> max_avg_returns = - math. inf <TAB> for _ in range ( 2 ) : <TAB> <TAB> agent = training. PolicyGradient ( <TAB> <TAB> <TAB> task, <TAB> <TAB> <TAB> model_fn = self. _model_fn, <TAB> <TAB> <TAB> optimizer = opt. Adam, <TAB> <TAB> <TAB> lr_schedule = lr, <TAB> <TAB> <TAB> batch_size = 128, <TAB> <TAB> <TAB> eval_temperatures = [ 0.0, 0.5 ], <TAB> <TAB> <TAB> n_eval_episodes = 1, <TAB> <TAB> <TAB> n_trajectories_per_epoch = 2, <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for ep in range ( 200 ) : <TAB> <TAB> <TAB> agent. run ( 1 ) <TAB> <TAB> <TAB> self. assertEqual ( agent. current_epoch, ep + 1 ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> for eval_t in agent. _eval_temperatures : <TAB> <TAB> <TAB> <TAB> <TAB> self. assertEqual ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> len ( agent. _avg_returns_temperatures [ eval_t ] [ 200 ] ), <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> len ( agent. avg_returns ), <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> max_avg_returns = max ( max_avg_returns, agent.",False,agent.avg_returns[-1] == 200.0,"hasattr(agent, '_eval_temperatures')",0.6594438552856445
|
||
|
4465,"def scan ( scope ) : <TAB> for s in scope. children : <TAB> <TAB> if s. start_pos <= position <= s. end_pos : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return scan ( s ) or s <TAB> <TAB> <TAB> elif s. type in ( ""suite"", ""decorated"" ) : <TAB> <TAB> <TAB> <TAB> return scan ( s ) <TAB> return None",False,"isinstance(s, (tree.Scope, tree.Flow))","s.type in ('test', 'notest')",0.6469538807868958
|
||
|
4466,"def mail_migrator ( app, schema_editor ) : <TAB> Event_SettingsStore = app. get_model ( ""pretixbase"", ""Event_SettingsStore"" ) <TAB> for ss in Event_SettingsStore. objects. filter ( <TAB> <TAB> key__in = [ <TAB> <TAB> <TAB> ""mail_text_order_approved"", <TAB> <TAB> <TAB> ""mail_text_order_placed"", <TAB> <TAB> <TAB> ""mail_text_order_placed_require_approval"", <TAB> <TAB> ] <TAB> ) : <TAB> <TAB> chgd = ss. value. replace ( ""{date}"", ""{expire_date}"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> ss. value = chgd <TAB> <TAB> <TAB> ss. save ( ) <TAB> <TAB> <TAB> cache. delete ( ""hierarkey_{}_{}"". format ( ""event"", ss. object_id ) )",False,chgd != ss.value,chgd,0.6664128303527832
|
||
|
4467,"def read_until_regexp ( self, regexp_list ) : <TAB> current_out = self. current_output <TAB> for rgx in regexp_list : <TAB> <TAB> match = rgx. search ( current_out ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _update_buffer ( current_out [ match. end ( ) : ] ) <TAB> <TAB> <TAB> return current_out [ : match. end ( ) ] <TAB> return None",True,match,match,0.6698912382125854
|
||
|
4468,"def PackLVCOLUMN ( fmt = None, cx = None, text = None, subItem = None, image = None, order = None ) : <TAB> extra = [ ] <TAB> mask = 0 <TAB> mask, fmt = _GetMaskAndVal ( fmt, 0, mask, commctrl. LVCF_FMT ) <TAB> mask, cx = _GetMaskAndVal ( cx, 0, mask, commctrl. LVCF_WIDTH ) <TAB> mask, text = _GetMaskAndVal ( text, None, mask, commctrl. LVCF_TEXT ) <TAB> mask, subItem = _GetMaskAndVal ( subItem, 0, mask, commctrl. LVCF_SUBITEM ) <TAB> mask, image = _GetMaskAndVal ( image, 0, mask, commctrl. LVCF_IMAGE ) <TAB> mask, order = _GetMaskAndVal ( order, 0, mask, commctrl. LVCF_ORDER ) <TAB> if text is None : <TAB> <TAB> text_addr = text_len = 0 <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> text = text. encode ( ""mbcs"" ) <TAB> <TAB> text_buffer = array. array ( ""c"", text + ""\0"" ) <TAB> <TAB> extra. append ( text_buffer ) <TAB> <TAB> text_addr, text_len = text_buffer. buffer_info ( ) <TAB> format = ""iiiiiiii"" <TAB> buf = struct. pack ( <TAB> <TAB> format, mask, fmt, cx, text_addr, text_len, subItem, image, order <TAB> ) <TAB> return array. array ( ""c"", buf ), extra",False,"isinstance(text, unicode)","isinstance(text, str)",0.6465867757797241
|
||
|
4469,"def mouseDragEvent ( self, ev ) : <TAB> if self. movable and ev. button ( ) == QtCore. Qt. LeftButton : <TAB> <TAB> if ev. isStart ( ) : <TAB> <TAB> <TAB> self. moving = True <TAB> <TAB> <TAB> self. cursorOffset = self. pos ( ) - self. mapToParent ( ev. buttonDownPos ( ) ) <TAB> <TAB> <TAB> self. startPosition = self. pos ( ) <TAB> <TAB> ev. accept ( ) <TAB> <TAB> if not self. moving : <TAB> <TAB> <TAB> return <TAB> <TAB> self. setPos ( self. cursorOffset + self. mapToParent ( ev. pos ( ) ) ) <TAB> <TAB> self. sigDragged. emit ( self ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. moving = False <TAB> <TAB> <TAB> self. sigPositionChangeFinished. emit ( self )",False,ev.isFinish(),self.moving,0.6657177209854126
|
||
|
4470,"def moveto ( self, other ) : <TAB> if isinstance ( self, File ) and isinstance ( other, Folder ) : <TAB> <TAB> other = other. file ( self. basename ) <TAB> if not isinstance ( other, MockFSObjectBase ) : <TAB> <TAB> raise NotImplementedError ( ""TODO: support cross object type move"" ) <TAB> if other. isequal ( self ) : <TAB> <TAB> if other. path == self. path : <TAB> <TAB> <TAB> raise ValueError ( ""Cannot move file or folder to self"" ) <TAB> <TAB> <TAB> <TAB> parentnode = self. _fs. stat ( self. pathnames [ : - 1 ] ) <TAB> <TAB> parentnode. data [ other. basename ] = parentnode. data. pop ( self. basename ) <TAB> <TAB> parentnode. on_changed ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. watcher. emit ( ""moved"", self, other ) <TAB> else : <TAB> <TAB> self. _mock_copyto ( other ) <TAB> <TAB> self. _remove ( removechildren = True ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. watcher. emit ( ""moved"", self, other ) <TAB> <TAB> self. _cleanup ( ) <TAB> return other",False,self.watcher,removechildren,0.6671056151390076
|
||
|
4471,"def kron_mmprod ( self, A, B ) : <TAB> count = 0 <TAB> D = len ( A ) <TAB> for b in B. T : <TAB> <TAB> x = b <TAB> <TAB> N = 1 <TAB> <TAB> G = np. zeros ( D, dtype = np. int_ ) <TAB> <TAB> for d in range ( D ) : <TAB> <TAB> <TAB> G [ d ] = len ( A [ d ] ) <TAB> <TAB> N = np. prod ( G ) <TAB> <TAB> for d in range ( D - 1, - 1, - 1 ) : <TAB> <TAB> <TAB> X = np. reshape ( x, ( G [ d ], int ( np. round ( N / G [ d ] ) ) ), order = ""F"" ) <TAB> <TAB> <TAB> Z = np. dot ( A [ d ], X ) <TAB> <TAB> <TAB> Z = Z. T <TAB> <TAB> <TAB> x = np. reshape ( Z, ( - 1, 1 ), order = ""F"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> result = x <TAB> <TAB> else : <TAB> <TAB> <TAB> result = np. column_stack ( ( result, x ) ) <TAB> <TAB> count += 1 <TAB> return result",False,count == 0,count > 1,0.6703968048095703
|
||
|
4472,"def generate_digits_file ( <TAB> source_path : str, <TAB> target_path : str, <TAB> line_count : int = 100, <TAB> line_length : int = 9, <TAB> sort_target : bool = False, <TAB> line_count_empty : int = 0, <TAB> seed = 13, ) : <TAB> assert line_count_empty <= line_count <TAB> random_gen = random. Random ( seed ) <TAB> with open ( source_path, ""w"" ) as source_out, open ( target_path, ""w"" ) as target_out : <TAB> <TAB> all_digits = [ ] <TAB> <TAB> for _ in range ( line_count - line_count_empty ) : <TAB> <TAB> <TAB> digits = [ <TAB> <TAB> <TAB> <TAB> random_gen. choice ( _DIGITS ) <TAB> <TAB> <TAB> <TAB> for _ in range ( random_gen. randint ( 1, line_length ) ) <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> all_digits. append ( digits ) <TAB> <TAB> for _ in range ( line_count_empty ) : <TAB> <TAB> <TAB> all_digits. append ( [ ] ) <TAB> <TAB> random_gen. shuffle ( all_digits ) <TAB> <TAB> for digits in all_digits : <TAB> <TAB> <TAB> print ( C. TOKEN_SEPARATOR. join ( digits ), file = source_out ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> digits. sort ( ) <TAB> <TAB> <TAB> print ( C. TOKEN_SEPARATOR. join ( digits ), file = target_out )",True,sort_target,sort_target,0.6609206199645996
|
||
|
4473,"def list_plugins ( ) : <TAB> result = ""\n\tSupported Plugin Commands:\n\n"" <TAB> cmds = registry. get_plugin_classes ( commands. Command, lower = True ) <TAB> profs = registry. get_plugin_classes ( obj. Profile ) <TAB> if config. PROFILE == None : <TAB> <TAB> config. update ( ""PROFILE"", ""WinXPSP2x86"" ) <TAB> if config. PROFILE not in profs : <TAB> <TAB> raise BaseException ( ""Invalid profile "" + config. PROFILE + "" selected"" ) <TAB> profile = profs [ config. PROFILE ] ( ) <TAB> wrongprofile = """" <TAB> for cmdname in sorted ( cmds ) : <TAB> <TAB> command = cmds [ cmdname ] <TAB> <TAB> helpline = command. help ( ) or """" <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for line in helpline. splitlines ( ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> helpline = line <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> if command. is_valid_profile ( profile ) : <TAB> <TAB> <TAB> result += ""\t\t{0:15}\t{1}\n"". format ( cmdname, helpline ) <TAB> <TAB> else : <TAB> <TAB> <TAB> wrongprofile += ""\t\t{0:15}\t{1}\n"". format ( cmdname, helpline ) <TAB> if wrongprofile and config. VERBOSE : <TAB> <TAB> result += ""\n\tPlugins requiring a different profile:\n\n"" <TAB> <TAB> result += wrongprofile <TAB> return result",False,line,helpline and line[0] == 'h',0.6807525157928467
|
||
|
4474,"def _delete_chunks_after_reshape_single_sample ( self, sample, sample_shape, new_shape ) : <TAB> if ( sample_shape <= new_shape ). all ( ) : <TAB> <TAB> return <TAB> shapes = sample_shape <TAB> assert len ( shapes. shape ) + 1 == len ( self. shape ) <TAB> chunks = self. _storage_tensor. chunks [ 1 : ] <TAB> div = np. ceil ( shapes / chunks ). astype ( ""int32"" ) <TAB> for index in np. ndindex ( * div. tolist ( ) ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> del self [ ""."". join ( ( sample, ) + index ) ] <TAB> <TAB> <TAB> except KeyError : <TAB> <TAB> <TAB> <TAB> pass",False,np.array(index) * chunks >= new_shape).any(,index.isValid(),0.6501710414886475
|
||
|
4475,"def _maybe_signal_recovery_end ( ) -> None : <TAB> if self. in_recovery and not self. active_remaining_total ( ) : <TAB> <TAB> <TAB> <TAB> self. flush_buffers ( ) <TAB> <TAB> self. _set_recovery_ended ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _actives_span. set_tag ( ""Actives-Ready"", True ) <TAB> <TAB> self. signal_recovery_end. set ( )",False,self._actives_span is not None,self.actives_span is not None,0.6567281484603882
|
||
|
4476,"def get_auto_complete_terms ( cls, keyword, max_terms, limit = 10 ) : <TAB> if not keyword : <TAB> <TAB> return [ ] <TAB> with db_session : <TAB> <TAB> result = cls. search_keyword ( '""' + keyword + '""*', lim = limit ) [ : ] <TAB> titles = [ g. title. lower ( ) for g in result ] <TAB> <TAB> all_terms = set ( ) <TAB> for line in titles : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> break <TAB> <TAB> i1 = line. find ( keyword ) <TAB> <TAB> i2 = line. find ( "" "", i1 + len ( keyword ) ) <TAB> <TAB> term = line [ i1 : i2 ] if i2 >= 0 else line [ i1 : ] <TAB> <TAB> if term!= keyword : <TAB> <TAB> <TAB> all_terms. add ( term ) <TAB> return list ( all_terms )",False,len(all_terms) >= max_terms,len(line) < lim,0.6520348191261292
|
||
|
4477,"def process_file ( file_name ) : <TAB> content = read_file ( file_name ) <TAB> urls = URL_PATTERN. findall ( content ) <TAB> <TAB> content = re. sub ( HEADER_PATTERN, r""\g<level> \g<header>"", content ) <TAB> directory = ""/"". join ( normalize_path ( file_name ). split ( ""/"" ) [ : - 1 ] ) <TAB> paths = set ( ) <TAB> md_paths = MD_PATH_PATTERN. findall ( content ) <TAB> for md_path in md_paths : <TAB> <TAB> path = md_path. lstrip ( ""/"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> path = ROOT_DIR / directory / path <TAB> <TAB> else : <TAB> <TAB> <TAB> path = ROOT_DIR / path <TAB> <TAB> path = path. resolve ( ). relative_to ( ROOT_DIR ) <TAB> <TAB> paths. add ( normalize_path ( path ) ) <TAB> <TAB> content = content. replace ( ""("" + md_path + "")"", normalize_path ( path ) ) <TAB> for url in urls : <TAB> <TAB> path = url [ len ( GITHUB_URL ) : ] <TAB> <TAB> paths. add ( path ) <TAB> <TAB> content = content. replace ( url, normalize_path ( os. path. relpath ( path, directory ) ) ) <TAB> output_path = ROOT_DIR / ""docs"" / file_name <TAB> if not output_path. parent. is_dir ( ) : <TAB> <TAB> os. makedirs ( output_path. parent ) <TAB> with output_path. open ( ""w+"" ) as output_file : <TAB> <TAB> output_file. write ( content ) <TAB> PROCESSED_PATHS. add ( normalize_path ( file_name ) ) <TAB> for path in paths : <TAB> <TAB> if path not in PROCESSED_PATHS : <TAB> <TAB> <TAB> process_file ( normalize_path ( path ) )",False,ROOT_DIR / directory / path).exists(,path.is_dir(),0.6505041122436523
|
||
|
4478,"def update ( self, update_tracks = True ) : <TAB> self. enable_update_metadata_images ( False ) <TAB> old_album_title = self. metadata [ ""album"" ] <TAB> self. metadata [ ""album"" ] = config. setting [ ""nat_name"" ] <TAB> for track in self. tracks : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> track. metadata [ ""album"" ] = self. metadata [ ""album"" ] <TAB> <TAB> for file in track. linked_files : <TAB> <TAB> <TAB> track. update_file_metadata ( file ) <TAB> self. enable_update_metadata_images ( True ) <TAB> super ( ). update ( update_tracks )",False,old_album_title == track.metadata['album'],track.old_album_title == old_album_title,0.6523239612579346
|
||
|
4479,"def test_set_pycache_prefix ( self ) : <TAB> <TAB> <TAB> NO_VALUE = object ( ) <TAB> cases = [ <TAB> <TAB> <TAB> <TAB> ( None, None, None ), <TAB> <TAB> ( ""foo"", None, ""foo"" ), <TAB> <TAB> ( None, ""bar"", ""bar"" ), <TAB> <TAB> ( ""foo"", ""bar"", ""bar"" ), <TAB> <TAB> ( ""foo"", """", None ), <TAB> <TAB> ( ""foo"", NO_VALUE, None ), <TAB> ] <TAB> for envval, opt, expected in cases : <TAB> <TAB> exp_clause = ""is None"" if expected is None else f'== ""{expected}""' <TAB> <TAB> code = f""import sys; sys.exit(not sys.pycache_prefix {exp_clause})"" <TAB> <TAB> args = [ ""-c"", code ] <TAB> <TAB> env = { } if envval is None else { ""PYTHONPYCACHEPREFIX"" : envval } <TAB> <TAB> if opt is NO_VALUE : <TAB> <TAB> <TAB> args [ : 0 ] = [ ""-X"", ""pycache_prefix"" ] <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> args [ : 0 ] = [ ""-X"", f""pycache_prefix={opt}"" ] <TAB> <TAB> with self. subTest ( envval = envval, opt = opt ) : <TAB> <TAB> <TAB> with support. temp_cwd ( ) : <TAB> <TAB> <TAB> <TAB> assert_python_ok ( * args, ** env )",True,opt is not None,opt is not None,0.6585860848426819
|
||
|
4480,"def checked_reader ( fd, n ) : <TAB> while n > 0 : <TAB> <TAB> rl, _, _ = select. select ( [ fd ], [ ], [ ] ) <TAB> <TAB> assert rl [ 0 ] == fd <TAB> <TAB> buf = os. read ( fd, n ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise Exception ( ""Unexpected EOF reading %d more bytes"" % n ) <TAB> <TAB> yield buf <TAB> <TAB> n -= len ( buf )",False,not buf,len(buf) > n,0.6856896281242371
|
||
|
4481,"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<mask> : <TAB> <TAB> <TAB> break <TAB> <TAB> if fid == 1 : <TAB> <TAB> <TAB> if ftype == TType. STRUCT : <TAB> <TAB> <TAB> <TAB> self. query = Query ( ) <TAB> <TAB> <TAB> <TAB> self. query. read ( iprot ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif fid == 2 : <TAB> <TAB> <TAB> if ftype == TType. STRING : <TAB> <TAB> <TAB> <TAB> self. clientCtx = 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.STOP,fid == 0,0.6604976058006287
|
||
|
4482,"def pickline ( file, key, casefold = 1 ) : <TAB> try : <TAB> <TAB> f = open ( file, ""r"" ) <TAB> except IOError : <TAB> <TAB> return None <TAB> pat = re. escape ( key ) + "":"" <TAB> prog = re. compile ( pat, casefold and re. IGNORECASE ) <TAB> while 1 : <TAB> <TAB> line = f. readline ( ) <TAB> <TAB> if not line : <TAB> <TAB> <TAB> break <TAB> <TAB> if prog. match ( line ) : <TAB> <TAB> <TAB> text = line [ len ( key ) + 1 : ] <TAB> <TAB> <TAB> while 1 : <TAB> <TAB> <TAB> <TAB> line = f. readline ( ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> text = text + line <TAB> <TAB> <TAB> return text. strip ( ) <TAB> return None",False,not line or not line[0].isspace(),not text,0.6500121355056763
|
||
|
4483,"def is_upgradeable_proxy ( self ) -> bool : <TAB> from slither. core. cfg. node import NodeType <TAB> from slither. slithir. operations import LowLevelCall <TAB> if self. _is_upgradeable_proxy is None : <TAB> <TAB> self. _is_upgradeable_proxy = False <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _is_upgradeable_proxy = True <TAB> <TAB> <TAB> return True <TAB> <TAB> for f in self. functions : <TAB> <TAB> <TAB> if f. is_fallback : <TAB> <TAB> <TAB> <TAB> for node in f. all_nodes ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> for ir in node. irs : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> isinstance ( ir, LowLevelCall ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> and ir. function_name == ""delegatecall"" <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _is_upgradeable_proxy = True <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return self. _is_upgradeable_proxy <TAB> <TAB> <TAB> <TAB> <TAB> if node. type == NodeType. ASSEMBLY : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> inline_asm = node. inline_asm <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if inline_asm : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if ""delegatecall"" in inline_asm : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _is_upgradeable_proxy = True <TAB> <TAB> <TAB> <TAB>",False,'Proxy' in self.name,self.has_fallback,0.6601525545120239
|
||
|
4484,"def current_dict ( cursor_offset, line ) : <TAB> """"""If in dictionary completion, return the dict that should be used"""""" <TAB> for m in current_dict_re. finditer ( line ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return LinePart ( m. start ( 1 ), m. end ( 1 ), m. group ( 1 ) ) <TAB> return None",False,m.start(2) <= cursor_offset and m.end(2) >= cursor_offset,m.group(1) == cursor_offset,0.6473796963691711
|
||
|
4485,"def _get_required_scripts ( self, script, force = False ) : <TAB> required_dls = [ <TAB> <TAB> ( url, self. _required_url_to_file_path ( url ) ) for url in script. requires <TAB> ] <TAB> if not force : <TAB> <TAB> required_dls = [ <TAB> <TAB> <TAB> ( url, path ) for ( url, path ) in required_dls if not os. path. exists ( path ) <TAB> <TAB> ] <TAB> if not required_dls : <TAB> <TAB> <TAB> <TAB> self. _add_script_with_requires ( script, quiet = True ) <TAB> <TAB> return <TAB> download_manager = objreg. get ( ""qtnetwork-download-manager"" ) <TAB> for url, target_path in required_dls : <TAB> <TAB> target = downloads. FileDownloadTarget ( target_path, force_overwrite = True ) <TAB> <TAB> download = download_manager. get ( QUrl ( url ), target = target, auto_remove = True ) <TAB> <TAB> download. requested_url = url <TAB> <TAB> self. _in_progress_dls. append ( download ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _on_required_download_finished ( script, download ) <TAB> <TAB> else : <TAB> <TAB> <TAB> download. finished. connect ( <TAB> <TAB> <TAB> <TAB> functools. partial ( self. _on_required_download_finished, script, download ) <TAB> <TAB> <TAB> )",False,download.successful,download.finished,0.6651439666748047
|
||
|
4486,"def dumps ( self ) : <TAB> sections = [ ] <TAB> for name, env_info in self. _dependencies_. items ( ) : <TAB> <TAB> sections. append ( ""[ENV_%s]"" % name ) <TAB> <TAB> for var, values in sorted ( env_info. vars. items ( ) ) : <TAB> <TAB> <TAB> tmp = ""%s="" % var <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> tmp += ""[%s]"" % "","". join ( [ '""%s""' % val for val in values ] ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> tmp += ""%s"" % values <TAB> <TAB> <TAB> sections. append ( tmp ) <TAB> return ""\n"". join ( sections )",True,"isinstance(values, list)","isinstance(values, list)",0.6556833386421204
|
||
|
4487,"def func_named ( self, arg ) : <TAB> result = None <TAB> target = ""do_"" + arg <TAB> if target in dir ( self ) : <TAB> <TAB> result = target <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> funcs = [ fname for fname in self. keywords if fname. startswith ( arg ) ] <TAB> <TAB> <TAB> if len ( funcs ) == 1 : <TAB> <TAB> <TAB> <TAB> result = ""do_"" + funcs [ 0 ] <TAB> return result",False,self.abbrev,arg in self.keywords,0.6775655746459961
|
||
|
4488,"def _list_cases ( suite ) : <TAB> for test in suite : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> _list_cases ( test ) <TAB> <TAB> elif isinstance ( test, unittest. TestCase ) : <TAB> <TAB> <TAB> if support. match_test ( test ) : <TAB> <TAB> <TAB> <TAB> print ( test. id ( ) )",False,"isinstance(test, unittest.TestSuite)","isinstance(test, list)",0.6493837833404541
|
||
|
4489,"def generate_auto_complete ( self, base, iterable_var ) : <TAB> sugg = [ ] <TAB> for entry in iterable_var : <TAB> <TAB> compare_entry = entry <TAB> <TAB> compare_base = base <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> compare_entry = compare_entry. lower ( ) <TAB> <TAB> <TAB> compare_base = compare_base. lower ( ) <TAB> <TAB> if self. compare_entries ( compare_entry, compare_base ) : <TAB> <TAB> <TAB> if entry not in sugg : <TAB> <TAB> <TAB> <TAB> sugg. append ( entry ) <TAB> return sugg",False,self.settings.get(IGNORE_CASE_SETTING),compare_entry and compare_base,0.6510764360427856
|
||
|
4490,"def checkStates ( self, fit, base ) : <TAB> pyfalog. debug ( ""Check states for fit ID: {0}"", fit ) <TAB> changedMods = { } <TAB> changedProjMods = { } <TAB> changedProjDrones = { } <TAB> for pos, mod in enumerate ( fit. modules ) : <TAB> <TAB> if mod is not base : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> canHaveState = mod. canHaveState ( mod. state ) <TAB> <TAB> <TAB> if canHaveState is not True : <TAB> <TAB> <TAB> <TAB> changedMods [ pos ] = mod. state <TAB> <TAB> <TAB> <TAB> mod. state = canHaveState <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> changedMods [ pos ] = mod. state <TAB> <TAB> <TAB> <TAB> mod. state = FittingModuleState. ONLINE <TAB> for pos, mod in enumerate ( fit. projectedModules ) : <TAB> <TAB> <TAB> <TAB> canHaveState = mod. canHaveState ( mod. state, fit ) <TAB> <TAB> if canHaveState is not True : <TAB> <TAB> <TAB> changedProjMods [ pos ] = mod. state <TAB> <TAB> <TAB> mod. state = canHaveState <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> changedProjMods [ pos ] = mod. state <TAB> <TAB> <TAB> mod. state = FittingModuleState. OFFLINE <TAB> for pos, drone in enumerate ( fit. projectedDrones ) : <TAB> <TAB> if drone. amountActive > 0 and not drone. canBeApplied ( fit ) : <TAB> <TAB> <TAB> changedProjDrones [ pos ] = drone. amountActive <TAB> <TAB> <TAB> drone. amountActive = 0 <TAB> return changedMods, changedProjMods, changedProjDrones",False,not mod.isValidState(mod.state),len(fit.projectedModules) > 0,0.6494564414024353
|
||
|
4491,"def reset_parameters ( self ) : <TAB> <TAB> if self. opt [ ""tune_partial"" ] > 0 : <TAB> <TAB> offset = self. opt [ ""tune_partial"" ] + 2 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. network. embedding. weight. data [ offset : ] = self. network. fixed_embedding",False,offset < self.network.embedding.weight.data.size(0),self.opt[offset] > 0,0.6542505621910095
|
||
|
4492,"def test_mask ( ) : <TAB> numpy. random. seed ( 42 ) <TAB> image = numpy. random. uniform ( size = ( 10, 30 ) ) <TAB> mask = numpy. zeros ( image. shape, bool ) <TAB> mask [ :, : 20 ] = True <TAB> labels = numpy. ones ( ( 10, 30 ), int ) <TAB> workspace, module = make_workspace ( image, labels, mask = mask ) <TAB> module. run ( workspace ) <TAB> m = workspace. measurements <TAB> workspace, module = make_workspace ( image [ :, : 20 ], labels [ :, : 20 ] ) <TAB> module. run ( workspace ) <TAB> me = workspace. measurements <TAB> for f in m. get_feature_names ( INPUT_OBJECTS_NAME ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> values = m. get_current_measurement ( INPUT_OBJECTS_NAME, f ) <TAB> <TAB> <TAB> expected = me. get_current_measurement ( INPUT_OBJECTS_NAME, f ) <TAB> <TAB> <TAB> assert values == expected",False,f.startswith(cellprofiler.modules.measuretexture.TEXTURE),f in me.get_feature_names(INPUT_OBJECTS_NAME),0.6475114822387695
|
||
|
4493,"def catching_iter ( self, app_iter, environ ) : <TAB> if not app_iter : <TAB> <TAB> raise StopIteration <TAB> error_on_close = False <TAB> try : <TAB> <TAB> for v in app_iter : <TAB> <TAB> <TAB> yield v <TAB> <TAB> if hasattr ( app_iter, ""close"" ) : <TAB> <TAB> <TAB> error_on_close = True <TAB> <TAB> <TAB> app_iter. close ( ) <TAB> except : <TAB> <TAB> response = self. exception_handler ( sys. exc_info ( ), environ ) <TAB> <TAB> if not error_on_close and hasattr ( app_iter, ""close"" ) : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> app_iter. close ( ) <TAB> <TAB> <TAB> except : <TAB> <TAB> <TAB> <TAB> close_response = self. exception_handler ( sys. exc_info ( ), environ ) <TAB> <TAB> <TAB> <TAB> response += ""<hr noshade>Error in.close():<br>%s"" % close_response <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> response = response. encode ( ""utf8"" ) <TAB> <TAB> yield response",False,six.PY3,"isinstance(response, unicode_type)",0.6592411994934082
|
||
|
4494,"def should_include ( service ) : <TAB> for f in filt : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> state = filt [ f ] <TAB> <TAB> <TAB> containers = project. containers ( [ service. name ], stopped = True ) <TAB> <TAB> <TAB> if not has_container_with_state ( containers, state ) : <TAB> <TAB> <TAB> <TAB> return False <TAB> <TAB> elif f == ""source"" : <TAB> <TAB> <TAB> source = filt [ f ] <TAB> <TAB> <TAB> if source == ""image"" or source == ""build"" : <TAB> <TAB> <TAB> <TAB> if source not in service. options : <TAB> <TAB> <TAB> <TAB> <TAB> return False <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> raise UserError ( ""Invalid value for source filter: %s"" % source ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise UserError ( ""Invalid filter: %s"" % f ) <TAB> return True",False,f == 'status',f == 'project',0.664634108543396
|
||
|
4495,"def _append ( self, other ) : <TAB> assert ( <TAB> <TAB> self. _remote_init_builder is None <TAB> ), ""We don't support append if data in the frame is mapped from a remote server."" <TAB> <TAB> if self. num_rows == 0 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _columns = { key : Column. create ( data ) for key, data in other. items ( ) } <TAB> else : <TAB> <TAB> <TAB> <TAB> for key, col in self. items ( ) : <TAB> <TAB> <TAB> if key in other : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> scheme = col. scheme <TAB> <TAB> <TAB> ctx = F. context ( col. data ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. _set_zero_default_initializer ( ) <TAB> <TAB> <TAB> initializer = self. get_initializer ( key ) <TAB> <TAB> <TAB> new_data = initializer ( <TAB> <TAB> <TAB> <TAB> ( other. num_rows, ) + scheme. shape, <TAB> <TAB> <TAB> <TAB> scheme. dtype, <TAB> <TAB> <TAB> <TAB> ctx, <TAB> <TAB> <TAB> <TAB> slice ( self. _num_rows, self. _num_rows + other. num_rows ), <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> other [ key ] = new_data <TAB> <TAB> <TAB> <TAB> for key, col in other. items ( ) : <TAB> <TAB> <TAB> if key not in self. _columns : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. add_column ( key, col. scheme, F. context ( col. data ) ) <TAB> <TAB> <TAB> self. _columns [ key ]. extend ( col. data, col. scheme )",False,self.get_initializer(key) is None,self._remote_init_builder is None,0.6512762904167175
|
||
|
4496,"def get_recommendation_from_result ( result, keys_to_apply ) : <TAB> rec = { } <TAB> for key in keys_to_apply : <TAB> <TAB> val = result. get ( key ) <TAB> <TAB> if not val or val == NULL : <TAB> <TAB> <TAB> continue <TAB> <TAB> if key == ""cpus"" : <TAB> <TAB> <TAB> rec [ ""cpus"" ] = float ( val ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> rec [ ""cpu_burst_add"" ] = min ( 1, float ( val ) ) <TAB> <TAB> elif key == ""mem"" : <TAB> <TAB> <TAB> rec [ ""mem"" ] = max ( 128, round ( float ( val ) ) ) <TAB> <TAB> elif key == ""disk"" : <TAB> <TAB> <TAB> rec [ ""disk"" ] = max ( 128, round ( float ( val ) ) ) <TAB> <TAB> elif key == ""hacheck_cpus"" : <TAB> <TAB> <TAB> hacheck_cpus_value = max ( 0.1, min ( float ( val ), 1 ) ) <TAB> <TAB> <TAB> rec [ ""sidecar_resource_requirements"" ] = { <TAB> <TAB> <TAB> <TAB> ""hacheck"" : { <TAB> <TAB> <TAB> <TAB> <TAB> ""requests"" : { <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""cpu"" : hacheck_cpus_value, <TAB> <TAB> <TAB> <TAB> <TAB> }, <TAB> <TAB> <TAB> <TAB> <TAB> ""limits"" : { <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""cpu"" : hacheck_cpus_value, <TAB> <TAB> <TAB> <TAB> <TAB> }, <TAB> <TAB> <TAB> <TAB> }, <TAB> <TAB> <TAB> } <TAB> return rec",True,key == 'cpu_burst_add',key == 'cpu_burst_add',0.6572980880737305
|
||
|
4497,"def theme_path ( self ) : <TAB> """"""Read 'theme' setting and return path to gutter icons."""""" <TAB> theme = self. get ( ""theme"" ) <TAB> if not theme : <TAB> <TAB> theme = ""Default.gitgutter-theme"" <TAB> <TAB> if theme!= os. path. basename ( self. _theme_path ) : <TAB> <TAB> if ST3 : <TAB> <TAB> <TAB> themes = sublime. find_resources ( theme ) <TAB> <TAB> <TAB> self. _theme_path = ( <TAB> <TAB> <TAB> <TAB> os. path. dirname ( themes [ - 1 ] ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> else self. _PACKAGE_THEMES + ""/Default"" <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> theme, _ = os. path. splitext ( theme ) <TAB> <TAB> <TAB> self. _theme_path = ""/"". join ( ( self. _PACKAGE_THEMES, theme ) ) <TAB> return self. _theme_path",False,themes,not self._theme_path,0.6987696886062622
|
||
|
4498,"def MissingExtraStringTest ( windows ) : <TAB> ""Return the errors from running the test"" <TAB> bugs = [ ] <TAB> for win in windows : <TAB> <TAB> if not win. ref : <TAB> <TAB> <TAB> continue <TAB> <TAB> for char in CharsToCheck : <TAB> <TAB> <TAB> missing_extra = """" <TAB> <TAB> <TAB> if win. WindowText ( ). count ( char ) > win. ref. WindowText ( ). count ( char ) : <TAB> <TAB> <TAB> <TAB> missing_extra = ""ExtraCharacters"" <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> missing_extra = ""MissingCharacters"" <TAB> <TAB> <TAB> if missing_extra : <TAB> <TAB> <TAB> <TAB> bugs. append ( <TAB> <TAB> <TAB> <TAB> <TAB> ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> [ <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> win, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ], <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> { ""MissingOrExtra"" : missing_extra, ""MissingOrExtraText"" : char }, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> testname, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> 0, <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> ) <TAB> return bugs",False,win.WindowText().count(char) < win.ref.WindowText().count(char),not missing_extra,0.6506792306900024
|
||
|
4499,"def get_display_price ( <TAB> base : Union [ TaxedMoney, TaxedMoneyRange ], display_gross : bool = False ) -> Money : <TAB> """"""Return the price amount that should be displayed based on settings."""""" <TAB> if not display_gross : <TAB> <TAB> display_gross = display_gross_prices ( ) <TAB> if isinstance ( base, TaxedMoneyRange ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> base = MoneyRange ( start = base. start. gross, stop = base. stop. gross ) <TAB> <TAB> else : <TAB> <TAB> <TAB> base = MoneyRange ( start = base. start. net, stop = base. stop. net ) <TAB> if isinstance ( base, TaxedMoney ) : <TAB> <TAB> base = base. gross if display_gross else base. net <TAB> return base",True,display_gross,display_gross,0.6664857268333435
|
||
|
4500,"def decode_image ( im_file, im_info, label_info ) : <TAB> if im_info is None : <TAB> <TAB> im_info = dict ( ) <TAB> if isinstance ( im_file, np. ndarray ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise Exception ( <TAB> <TAB> <TAB> <TAB> ""im should be 3-dimensions, but now is {}-dimensions"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> len ( im_file. shape ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> im = im_file <TAB> else : <TAB> <TAB> try : <TAB> <TAB> <TAB> im = cv2. imread ( im_file ). astype ( ""float32"" ) <TAB> <TAB> except : <TAB> <TAB> <TAB> raise TypeError ( ""Can't read The image file {}!"". format ( im_file ) ) <TAB> im = cv2. cvtColor ( im, cv2. COLOR_BGR2RGB ) <TAB> <TAB> im_info [ ""im_resize_info"" ] = np. array ( <TAB> <TAB> [ im. shape [ 0 ], im. shape [ 1 ], 1.0 ], dtype = np. float32 <TAB> ) <TAB> im_info [ ""image_shape"" ] = np. array ( [ im. shape [ 0 ], im. shape [ 1 ] ] ). astype ( ""int32"" ) <TAB> if not self. use_mixup : <TAB> <TAB> if ""mixup"" in im_info : <TAB> <TAB> <TAB> del im_info [ ""mixup"" ] <TAB> <TAB> if ""mixup"" in im_info : <TAB> <TAB> im_info [ ""mixup"" ] = decode_image ( <TAB> <TAB> <TAB> im_info [ ""mixup"" ] [ 0 ], im_info [ ""mixup"" ] [ 1 ], im_info [ ""mixup"" ] [ 2 ] <TAB> <TAB> ) <TAB> if label",True,len(im_file.shape) != 3,len(im_file.shape) != 3,0.6551808714866638
|
||
|
4501,"def pair_up ( self, rel_list, step ) : <TAB> result = [ ] <TAB> item = """" <TAB> for word in rel_list [ : ] : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> if word. replace ( "" [styv]"", """" ) in _cousin_level : <TAB> <TAB> <TAB> if item : <TAB> <TAB> <TAB> <TAB> result. append ( item ) <TAB> <TAB> <TAB> <TAB> item = """" <TAB> <TAB> <TAB> result. append ( word ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if item : <TAB> <TAB> <TAB> if word == ""syster"" : <TAB> <TAB> <TAB> <TAB> item = item [ 0 : - 1 ] <TAB> <TAB> <TAB> <TAB> word = ""ster"" <TAB> <TAB> <TAB> elif word == ""dotter"" and item == ""bror"" : <TAB> <TAB> <TAB> <TAB> item = ""brors"" <TAB> <TAB> <TAB> result. append ( item + word ) <TAB> <TAB> <TAB> item = """" <TAB> <TAB> else : <TAB> <TAB> <TAB> item = word <TAB> if item : <TAB> <TAB> result. append ( item ) <TAB> gen_result = [ item + ""s"" for item in result [ 0 : - 1 ] ] <TAB> gen_result = "" "". join ( gen_result + result [ - 1 : ] ) <TAB> <TAB> if len ( rel_list ) > 1 and step!= """" and not gen_result. rfind ( "" [styv]"" ) : <TAB> <TAB> gen_result = gen_result + "" [styv]"" <TAB> return gen_result",False,not word,"step != '' and word.find('[styv]', '')",0.6785291433334351
|
||
|
4502,"def get_next_video_frame ( self, skip_empty_frame = True ) : <TAB> if not self. video_format : <TAB> <TAB> return <TAB> while True : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> video_packet = self. _get_video_packet ( ) <TAB> <TAB> if video_packet. image == 0 : <TAB> <TAB> <TAB> self. _decode_video_packet ( video_packet ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> break <TAB> if _debug : <TAB> <TAB> print ( ""Returning"", video_packet ) <TAB> return video_packet. image",False,video_packet.image is not None or not skip_empty_frame,video_packet.image == skip_empty_frame,0.6496666669845581
|
||
|
4503,"def _run_interface ( self, runtime ) : <TAB> mpars = np. loadtxt ( self. inputs. in_file ) <TAB> mpars = np. apply_along_axis ( <TAB> <TAB> func1d = normalize_mc_params, <TAB> <TAB> axis = 1, <TAB> <TAB> arr = mpars, <TAB> <TAB> source = self. inputs. parameter_source, <TAB> ) <TAB> diff = mpars [ : - 1, : 6 ] - mpars [ 1 :, : 6 ] <TAB> diff [ :, 3 : 6 ] *= self. inputs. radius <TAB> fd_res = np. abs ( diff ). sum ( axis = 1 ) <TAB> self. _results = { <TAB> <TAB> ""out_file"" : op. abspath ( self. inputs. out_file ), <TAB> <TAB> ""fd_average"" : float ( fd_res. mean ( ) ), <TAB> } <TAB> np. savetxt ( <TAB> <TAB> self. inputs. out_file, fd_res, header = ""FramewiseDisplacement"", comments = """" <TAB> ) <TAB> if self. inputs. save_plot : <TAB> <TAB> tr = None <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> tr = self. inputs. series_tr <TAB> <TAB> if self. inputs. normalize and tr is None : <TAB> <TAB> <TAB> IFLOGGER. warn ( ""FD plot cannot be normalized if TR is not set"" ) <TAB> <TAB> self. _results [ ""out_figure"" ] = op. abspath ( self. inputs. out_figure ) <TAB> <TAB> fig = plot_confound ( <TAB> <TAB> <TAB> fd_res, <TAB> <TAB> <TAB> self. inputs. figsize, <TAB> <TAB> <TAB> ""FD"", <TAB> <TAB> <TAB> units = ""mm"", <TAB> <TAB> <TAB> series_tr = tr, <TAB> <TAB> <TAB> normalize = self. inputs. normalize, <TAB> <TAB> ) <TAB> <TAB> fig. savefig ( <TAB",False,isdefined(self.inputs.series_tr),self.inputs.series_tr is not None,0.6485890746116638
|
||
|
4504,"def _download ( self, *, url : str, path : Path ) -> None : <TAB> async with aiohttp_session ( auth = self. auth ) as session : <TAB> <TAB> async with session. get ( url ) as response : <TAB> <TAB> <TAB> response. raise_for_status ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if aiofiles is not None : <TAB> <TAB> <TAB> <TAB> async with aiofiles. open ( str ( path ), mode = ""wb"" ) as stream : <TAB> <TAB> <TAB> <TAB> <TAB> while True : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> chunk = await response. content. read ( 1024 ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> await stream. write ( chunk ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> with path. open ( mode = ""wb"" ) as stream : <TAB> <TAB> <TAB> <TAB> <TAB> while True : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> chunk = await response. content. read ( 1024 ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> stream. write ( chunk )",False,not chunk,len(chunk) > 0,0.6757445931434631
|
||
|
4505,"def finalize_options ( self ) : <TAB> install. finalize_options ( self ) <TAB> if self. init_system and isinstance ( self. init_system, str ) : <TAB> <TAB> self. init_system = self. init_system. split ( "","" ) <TAB> if len ( self. init_system ) == 0 and not platform. system ( ). endswith ( ""BSD"" ) : <TAB> <TAB> self. init_system = [ ""systemd"" ] <TAB> bad = [ f for f in self. init_system if f not in INITSYS_TYPES ] <TAB> if len ( bad )!= 0 : <TAB> <TAB> raise DistutilsArgError ( ""Invalid --init-system: %s"" % ( "","". join ( bad ) ) ) <TAB> for system in self. init_system : <TAB> <TAB> <TAB> <TAB> datakeys = [ k for k in INITSYS_ROOTS if k. partition ( ""."" ) [ 0 ] == system ] <TAB> <TAB> for k in datakeys : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> self. distribution. data_files. append ( ( INITSYS_ROOTS [ k ], INITSYS_FILES [ k ] ) ) <TAB> <TAB> self. distribution. reinitialize_command ( ""install_data"", True )",False,not INITSYS_FILES[k],k not in INITSYS_ROOTS,0.6623057723045349
|
||
|
4506,"def _collect_manual_intervention_nodes ( pipeline_tree ) : <TAB> for act in pipeline_tree [ ""activities"" ]. values ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> _collect_manual_intervention_nodes ( act [ ""pipeline"" ] ) <TAB> <TAB> elif act [ ""component"" ] [ ""code"" ] in MANUAL_INTERVENTION_COMP_CODES : <TAB> <TAB> <TAB> manual_intervention_nodes. add ( act [ ""id"" ] )",False,act['type'] == 'SubProcess',act['pipeline'] in MANUAL_INTERVENTION_pipeline_CODES,0.6533069610595703
|
||
|
4507,"def menu_export_online_user_bookmark ( opisvalid, args, options ) : <TAB> __log__. info ( ""Export Bookmark mode (m)."" ) <TAB> member_id = """" <TAB> filename = ""export-user.txt"" <TAB> if opisvalid and len ( args ) > 0 : <TAB> <TAB> arg = args [ 0 ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> filename = args [ 1 ] <TAB> <TAB> else : <TAB> <TAB> <TAB> filename = f""export-user-{arg}.txt"" <TAB> else : <TAB> <TAB> filename = input ( ""Filename: "" ). rstrip ( ""\r"" ) or filename <TAB> <TAB> arg = input ( ""Member Id: "" ). rstrip ( ""\r"" ) or """" <TAB> <TAB> arg = arg. lower ( ) <TAB> if arg. isdigit ( ) : <TAB> <TAB> member_id = arg <TAB> else : <TAB> <TAB> print ( ""Invalid args: "", arg ) <TAB> PixivBookmarkHandler. export_bookmark ( <TAB> <TAB> sys. modules [ __name__ ], __config__, filename, ""n"", 1, 0, member_id <TAB> )",False,len(args) > 1,opisvalid and args[1] > 0,0.6524175405502319
|
||
|
4508,"def on_enter_frame ( self, scene, context ) : <TAB> if not self. height : <TAB> <TAB> return <TAB> colors = { <TAB> <TAB> ""normal"" : self. style. get_color ( gtk. StateFlags. NORMAL ), <TAB> <TAB> ""normal_bg"" : self. style. get_background_color ( gtk. StateFlags. NORMAL ), <TAB> <TAB> ""selected"" : self. style. get_color ( gtk. StateFlags. SELECTED ), <TAB> <TAB> ""selected_bg"" : self. style. get_background_color ( gtk. StateFlags. SELECTED ), <TAB> } <TAB> g = graphics. Graphics ( context ) <TAB> g. set_line_style ( 1 ) <TAB> g. translate ( 0.5, 0.5 ) <TAB> for row, y in zip ( self. rows, self. row_positions ) : <TAB> <TAB> g. save_context ( ) <TAB> <TAB> g. translate ( 0, y ) <TAB> <TAB> color, bg = colors [ ""normal"" ], colors [ ""normal_bg"" ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> color, bg = colors [ ""selected"" ], colors [ ""selected_bg"" ] <TAB> <TAB> <TAB> g. fill_area ( 0, 0, self. width, self. row_height, bg ) <TAB> <TAB> label = row. label <TAB> <TAB> if row. description : <TAB> <TAB> <TAB> description_color = graphics. Colors. mix ( bg, color, 0.75 ) <TAB> <TAB> <TAB> description_color_str = graphics. Colors. hex ( description_color ) <TAB> <TAB> <TAB> label = '{} <span color=""{}"">[{}]</span>'. format ( <TAB> <TAB> <TAB> <TAB> label, description_color_str, row. description <TAB> <TAB> <TAB> ) <TAB> <TAB> self. label. show ( g, label, color = color ) <TAB> <TAB> g. restore_context ( )",False,row == self.current_row,row.selected,0.6570982933044434
|
||
|
4509,def gettext ( rv ) : <TAB> for child in rv. childNodes : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> yield child. nodeValue <TAB> <TAB> if child. nodeType == child. ELEMENT_NODE : <TAB> <TAB> <TAB> for item in gettext ( child ) : <TAB> <TAB> <TAB> <TAB> yield item,False,child.nodeType == child.TEXT_NODE,child.nodeType == child.ELEMENT_NODE,0.6621392965316772
|
||
|
4510,"def _get_field_mapping ( pb, dict_value, strict ) : <TAB> field_mapping = [ ] <TAB> for key, value in dict_value. items ( ) : <TAB> <TAB> if key == EXTENSION_CONTAINER : <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if strict : <TAB> <TAB> <TAB> <TAB> raise KeyError ( ""%s does not have a field called %s"" % ( pb, key ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> field_mapping. append ( <TAB> <TAB> <TAB> ( pb. DESCRIPTOR. fields_by_name [ key ], value, getattr ( pb, key, None ) ) <TAB> <TAB> ) <TAB> for ext_num, ext_val in dict_value. get ( EXTENSION_CONTAINER, { } ). items ( ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> ext_num = int ( ext_num ) <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> raise ValueError ( ""Extension keys must be integers."" ) <TAB> <TAB> if ext_num not in pb. _extensions_by_number : <TAB> <TAB> <TAB> if strict : <TAB> <TAB> <TAB> <TAB> raise KeyError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""%s does not have a extension with number %s. Perhaps you forgot to import it?"" <TAB> <TAB> <TAB> <TAB> <TAB> % ( pb, key ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> continue <TAB> <TAB> ext_field = pb. _extensions_by_number [ ext_num ] <TAB> <TAB> pb_val = None <TAB> <TAB> pb_val = pb. Extensions [ ext_field ] <TAB> <TAB> field_mapping. append ( ( ext_field, ext_val, pb_val ) ) <TAB> return field_mapping",False,key not in pb.DESCRIPTOR.fields_by_name,pb.has_field(key),0.6539187431335449
|
||
|
4511,"def remove_selected ( self ) : <TAB> """"""Removes selected items from list."""""" <TAB> to_delete = [ ] <TAB> for i in range ( len ( self ) ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> to_delete. append ( i ) <TAB> to_delete. reverse ( ) <TAB> for i in to_delete : <TAB> <TAB> self. pop ( i ) <TAB> if len ( to_delete ) > 0 : <TAB> <TAB> first_to_delete = to_delete [ - 1 ] <TAB> <TAB> if first_to_delete == 0 and len ( self ) > 0 : <TAB> <TAB> <TAB> self [ 0 ]. selected = True <TAB> <TAB> elif first_to_delete > 0 : <TAB> <TAB> <TAB> self [ first_to_delete - 1 ]. selected = True",False,self[i].selected,self.get(i),0.6593027114868164
|
||
|
4512,"def write ( self, s ) : <TAB> if self. interactive : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. active_mode. write ( s ) <TAB> <TAB> else : <TAB> <TAB> <TAB> component. get ( ""CmdLine"" ). add_line ( s, False ) <TAB> <TAB> <TAB> self. events. append ( s ) <TAB> else : <TAB> <TAB> print ( colors. strip_colors ( s ) )",False,"isinstance(self.active_mode, deluge.ui.console.modes.cmdline.CmdLine)","hasattr(self, 'active_mode')",0.6495927572250366
|
||
|
4513,"def access_api_server ( self ) : <TAB> config = get_config ( ) <TAB> logger. debug ( f""Passive Hunter is attempting to access the API at {self.path}"" ) <TAB> try : <TAB> <TAB> r = requests. get ( <TAB> <TAB> <TAB> f""{self.path}/api"", <TAB> <TAB> <TAB> headers = self. headers, <TAB> <TAB> <TAB> verify = False, <TAB> <TAB> <TAB> timeout = config. network_timeout, <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return r. content <TAB> except requests. exceptions. ConnectionError : <TAB> <TAB> pass <TAB> return False",False,r.status_code == 200 and r.content,timeout and r.status_code == 200,0.654805064201355
|
||
|
4514,"def name_match ( self, name, name1 ) : <TAB> if not name1 or not name : <TAB> <TAB> return 0 <TAB> srn1 = get_surnames ( name ) <TAB> sfx1 = name. get_suffix ( ) <TAB> srn2 = get_surnames ( name1 ) <TAB> sfx2 = name1. get_suffix ( ) <TAB> if not self. name_compare ( srn1, srn2 ) : <TAB> <TAB> return - 1 <TAB> if sfx1!= sfx2 : <TAB> <TAB> if sfx1!= """" and sfx2!= """" : <TAB> <TAB> <TAB> return - 1 <TAB> if name. get_first_name ( ) == name1. get_first_name ( ) : <TAB> <TAB> return 1 <TAB> else : <TAB> <TAB> list1 = name. get_first_name ( ). split ( ) <TAB> <TAB> list2 = name1. get_first_name ( ). split ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return self. list_reduce ( list1, list2 ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return self. list_reduce ( list2, list1 )",False,len(list1) < len(list2),len(list1) > len(list2),0.648535966873169
|
||
|
4515,"def _authenticate_plain ( self, domain, username, password ) : <TAB> """"""PLAIN ZAP authentication"""""" <TAB> allowed = False <TAB> reason = b"""" <TAB> if self. passwords : <TAB> <TAB> <TAB> <TAB> if not domain : <TAB> <TAB> <TAB> domain = ""*"" <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if username in self. passwords [ domain ] : <TAB> <TAB> <TAB> <TAB> if password == self. passwords [ domain ] [ username ] : <TAB> <TAB> <TAB> <TAB> <TAB> allowed = True <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> reason = b""Invalid password"" <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> reason = b""Invalid username"" <TAB> <TAB> else : <TAB> <TAB> <TAB> reason = b""Invalid domain"" <TAB> <TAB> if allowed : <TAB> <TAB> <TAB> self. log. debug ( <TAB> <TAB> <TAB> <TAB> ""ALLOWED (PLAIN) domain=%s username=%s password=%s"", <TAB> <TAB> <TAB> <TAB> domain, <TAB> <TAB> <TAB> <TAB> username, <TAB> <TAB> <TAB> <TAB> password, <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. log. debug ( ""DENIED %s"", reason ) <TAB> else : <TAB> <TAB> reason = b""No passwords defined"" <TAB> <TAB> self. log. debug ( ""DENIED (PLAIN) %s"", reason ) <TAB> return allowed, reason",False,domain in self.passwords,domain in self.password,0.662284255027771
|
||
|
4516,"def print_implementation_coverage ( coverage ) : <TAB> for service_name in sorted ( coverage ) : <TAB> <TAB> implemented = coverage. get ( service_name ) [ ""implemented"" ] <TAB> <TAB> not_implemented = coverage. get ( service_name ) [ ""not_implemented"" ] <TAB> <TAB> operations = sorted ( implemented + not_implemented ) <TAB> <TAB> if implemented and not_implemented : <TAB> <TAB> <TAB> percentage_implemented = int ( <TAB> <TAB> <TAB> <TAB> 100.0 * len ( implemented ) / ( len ( implemented ) + len ( not_implemented ) ) <TAB> <TAB> <TAB> ) <TAB> <TAB> elif implemented : <TAB> <TAB> <TAB> percentage_implemented = 100 <TAB> <TAB> else : <TAB> <TAB> <TAB> percentage_implemented = 0 <TAB> <TAB> print ( """" ) <TAB> <TAB> print ( ""## {}\n"". format ( service_name ) ) <TAB> <TAB> print ( ""{}% implemented\n"". format ( percentage_implemented ) ) <TAB> <TAB> for op in operations : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> print ( ""- [X] {}"". format ( op ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> print ( ""- [ ] {}"". format ( op ) )",False,op in implemented,not_implemented,0.6711909770965576
|
||
|
4517,"def append_row ( self, row ) : <TAB> self. allocate_future_payments ( row ) <TAB> self. set_invoice_details ( row ) <TAB> self. set_party_details ( row ) <TAB> self. set_ageing ( row ) <TAB> if self. filters. get ( ""group_by_party"" ) : <TAB> <TAB> self. update_sub_total_row ( row, row. party ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. append_subtotal_row ( self. previous_party ) <TAB> <TAB> self. previous_party = row. party <TAB> self. data. append ( row )",False,self.previous_party and self.previous_party != row.party,self.previous_party is not None,0.6525278091430664
|
||
|
4518,"def __all_links_rec ( self ) : <TAB> pieces = [ ] <TAB> temp = [ ( idx, tag ) for tag, idx in self. _supbook_xref. items ( ) ] <TAB> temp. sort ( ) <TAB> for idx, tag in temp : <TAB> <TAB> stype, snum = tag <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> rec = BIFFRecords. InternalReferenceSupBookRecord ( <TAB> <TAB> <TAB> <TAB> len ( self. __worksheets ) <TAB> <TAB> <TAB> ). get ( ) <TAB> <TAB> <TAB> pieces. append ( rec ) <TAB> <TAB> elif stype == ""xcall"" : <TAB> <TAB> <TAB> rec = BIFFRecords. XcallSupBookRecord ( ). get ( ) <TAB> <TAB> <TAB> pieces. append ( rec ) <TAB> <TAB> <TAB> temp = [ ( idx, name ) for name, idx in self. _xcall_xref. items ( ) ] <TAB> <TAB> <TAB> temp. sort ( ) <TAB> <TAB> <TAB> for idx, name in temp : <TAB> <TAB> <TAB> <TAB> rec = BIFFRecords. ExternnameRecord ( <TAB> <TAB> <TAB> <TAB> <TAB> options = 0, index = 0, name = name, fmla = ""\x02\x00\x1c\x17"" <TAB> <TAB> <TAB> <TAB> ). get ( ) <TAB> <TAB> <TAB> <TAB> pieces. append ( rec ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise Exception ( ""unknown supbook stype %r"" % stype ) <TAB> if len ( self. __sheet_refs ) > 0 : <TAB> <TAB> <TAB> <TAB> temp = [ ( idx, ref ) for ref, idx in self. __sheet_refs. items ( ) ] <TAB> <TAB> temp. sort ( ) <TAB> <TAB> temp = [ ref for idx, ref in temp ] <TAB> <TAB> externsheet_record = BIFFRecords. ExternSheetRecord ( temp )",False,stype == 'ownbook',stype == 'supbook',0.6609514355659485
|
||
|
4519,"def _call ( self, pyfunction, args ) : <TAB> if isinstance ( pyfunction, pyobjects. PyFunction ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> before = self. _parameter_objects ( pyfunction ) <TAB> <TAB> self. pycore. object_info. function_called ( <TAB> <TAB> <TAB> pyfunction, args. get_arguments ( pyfunction. get_param_names ( ) ) <TAB> <TAB> ) <TAB> <TAB> pyfunction. _set_parameter_pyobjects ( None ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> after = self. _parameter_objects ( pyfunction ) <TAB> <TAB> <TAB> if after!= before : <TAB> <TAB> <TAB> <TAB> self. follow ( pyfunction ) <TAB> <TAB> if isinstance ( pyfunction, rope. base. builtins. BuiltinFunction ) : <TAB> <TAB> pyfunction. get_returned_object ( args )",False,self.follow is not None,self.has_last_parameter,0.6551228761672974
|
||
|
4520,"def post ( self, request, * args, ** kwargs ) : <TAB> <TAB> <TAB> if ( <TAB> <TAB> ""id"" not in request. data <TAB> <TAB> and ""name"" in request. data <TAB> <TAB> and ""organization"" in request. data <TAB> ) : <TAB> <TAB> existing = models. Label. objects. filter ( <TAB> <TAB> <TAB> name = request. data [ ""name"" ], organization_id = request. data [ ""organization"" ] <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> existing = existing [ 0 ] <TAB> <TAB> <TAB> request. data [ ""id"" ] = existing. id <TAB> <TAB> <TAB> del request. data [ ""name"" ] <TAB> <TAB> <TAB> del request. data [ ""organization"" ] <TAB> if ( <TAB> <TAB> models. Label. objects. filter ( unifiedjobtemplate_labels = self. kwargs [ ""pk"" ] ). count ( ) <TAB> <TAB> > 100 <TAB> ) : <TAB> <TAB> return Response ( <TAB> <TAB> <TAB> dict ( <TAB> <TAB> <TAB> <TAB> msg = _ ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Maximum number of labels for {} reached."". format ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. parent_model. _meta. verbose_name_raw <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> status = status. HTTP_400_BAD_REQUEST, <TAB> <TAB> ) <TAB> return super ( JobTemplateLabelList, self ). post ( request, * args, ** kwargs )",False,existing.exists(),existing,0.6642444729804993
|
||
|
4521,"def load_annotations ( self ) : <TAB> """"""Load annotation file to get video information."""""" <TAB> if self. ann_file. endswith ( "".json"" ) : <TAB> <TAB> return self. load_json_annotations ( ) <TAB> video_infos = [ ] <TAB> with open ( self. ann_file, ""r"" ) as fin : <TAB> <TAB> for line in fin : <TAB> <TAB> <TAB> line_split = line. strip ( ). split ( ) <TAB> <TAB> <TAB> video_info = { } <TAB> <TAB> <TAB> idx = 0 <TAB> <TAB> <TAB> filename = line_split [ idx ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> if not filename. endswith ( self. suffix ) : <TAB> <TAB> <TAB> <TAB> <TAB> filename = osp. join ( self. data_prefix, filename + self. suffix ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> filename = osp. join ( self. data_prefix, filename ) <TAB> <TAB> <TAB> video_info [ ""audio_path"" ] = filename <TAB> <TAB> <TAB> idx += 1 <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> video_info [ ""total_frames"" ] = int ( line_split [ idx ] ) <TAB> <TAB> <TAB> idx += 1 <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> label = [ int ( x ) for x in line_split [ idx : ] ] <TAB> <TAB> <TAB> assert label, f""missing label in line: {line}"" <TAB> <TAB> <TAB> if self. multi_class : <TAB> <TAB> <TAB> <TAB> assert self. num_classes is not None <TAB> <TAB> <TAB> <TAB> onehot = torch. zeros ( self. num_classes ) <TAB> <TAB> <TAB> <TAB> onehot [ label ] = 1.0 <TAB> <TAB> <TAB> <TAB> video_info [ """,False,self.data_prefix is not None,self.data_prefix,0.6556156277656555
|
||
|
4522,"def PyJs_clear_1474_ ( this, arguments, var = var ) : <TAB> var = Scope ( <TAB> <TAB> { u""this"" : this, u""clear"" : PyJs_clear_1474_, u""arguments"" : arguments }, var <TAB> ) <TAB> var. registers ( [ u""entry"", u""data"", u""that"" ] ) <TAB> <TAB> var. put ( u""that"", var. get ( u""this"" ) ) <TAB> var. put ( u""data"", var. get ( u""that"" ). get ( u""_i"" ) ) <TAB> var. put ( u""entry"", var. get ( u""that"" ). get ( u""_f"" ) ) <TAB> while var. get ( u""entry"" ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> var. get ( u""entry"" ). put ( u""r"", var. get ( u""true"" ) ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> var. get ( u""entry"" ). put ( <TAB> <TAB> <TAB> <TAB> <TAB> u""p"", var. get ( u""entry"" ). get ( u""p"" ). put ( u""n"", var. get ( u""undefined"" ) ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> var. get ( u""data"" ). delete ( var. get ( u""entry"" ). get ( u""i"" ) ) <TAB> <TAB> finally : <TAB> <TAB> <TAB> var. put ( u""entry"", var. get ( u""entry"" ). get ( u""n"" ) ) <TAB> var. get ( u""that"" ). put ( u""_f"", var. get ( u""that"" ). put ( u""_l"", var. get ( u""undefined"" ) ) ) <TAB> var. get ( u""that"" ). put ( var. get ( u""SIZE"" ), Js ( 0.0 ) )",False,var.get(u'entry').get(u'p'),"var.get(u""undefined')",0.6490271687507629
|
||
|
4523,"def _get_user_from_file ( self, wanted_user ) : <TAB> """"""Get user from a passwd file"""""" <TAB> wanted_uid = """" <TAB> if isinstance ( wanted_user, ( int, long ) ) or re. match ( ""^\\d+$"", wanted_user ) : <TAB> <TAB> wanted_uid = str ( wanted_user ) <TAB> <TAB> wanted_user = """" <TAB> try : <TAB> <TAB> inpasswd = open ( self. passwd_file ) <TAB> except ( IOError, OSError ) : <TAB> <TAB> return ( """", """", """", """", """", """" ) <TAB> else : <TAB> <TAB> for line in inpasswd : <TAB> <TAB> <TAB> ( user, dummy, uid, gid, gecos, home, shell ) = line. strip ( ). split ( "":"" ) <TAB> <TAB> <TAB> if wanted_user and user == wanted_user : <TAB> <TAB> <TAB> <TAB> return ( user, uid, gid, gecos, home, shell ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return ( user, uid, gid, gecos, home, shell ) <TAB> <TAB> inpasswd. close ( ) <TAB> <TAB> return ( """", """", """", """", """", """" )",False,wanted_uid and uid == wanted_uid,not inpasswd,0.6569399237632751
|
||
|
4524,"def _execute_fetch ( <TAB> self, <TAB> sql : str, <TAB> parameters : Iterable = None, <TAB> read_only = False, <TAB> fetch_all : bool = False, ) -> List [ dict ] : <TAB> read_only_fn = run_read_only_fetchall if fetch_all else run_read_only_fetchone <TAB> parameters = parameters if parameters is not None else [ ] <TAB> still_waiting = False <TAB> urgent_read = False <TAB> if read_only : <TAB> <TAB> self. waiting_reads_metric. inc ( ) <TAB> <TAB> self. read_count_metric. inc ( ) <TAB> <TAB> try : <TAB> <TAB> <TAB> while ( <TAB> <TAB> <TAB> <TAB> self. writers and not self. _closing <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. urgent_read_done. clear ( ) <TAB> <TAB> <TAB> <TAB> <TAB> urgent_read = True <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> await self. read_ready. wait ( ) <TAB> <TAB> <TAB> <TAB> still_waiting = True <TAB> <TAB> <TAB> if self. _closing : <TAB> <TAB> <TAB> <TAB> raise asyncio. CancelledError <TAB> <TAB> <TAB> return await asyncio. get_event_loop ( ). run_in_executor ( <TAB> <TAB> <TAB> <TAB> self. reader_executor, read_only_fn, sql, parameters <TAB> <TAB> <TAB> ) <TAB> <TAB> finally : <TAB> <TAB> <TAB> if urgent_read : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. urgent_read_done. set ( ) <TAB> <TAB> <TAB> self. waiting",False,not urgent_read and still_waiting and self.urgent_read_done.is_set(),still_waiting,0.6498017311096191
|
||
|
4525,"def add_cascade ( self, parent, label, menu, underline ) : <TAB> """"""Create a menu with the given parent menu."""""" <TAB> <TAB> if parent : <TAB> <TAB> <TAB> <TAB> keys = { ""label"" : label, ""underline"" : underline } <TAB> <TAB> ch, label = self. createAccelLabel ( keys ) <TAB> <TAB> id = wx. NewId ( ) <TAB> <TAB> parent. AppendMenu ( id, label, menu, label ) <TAB> <TAB> accel = None <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. createAccelData ( menu, ch, accel, id, label ) <TAB> else : <TAB> <TAB> <TAB> <TAB> self. menuBar. Append ( menu, label )",False,ch,accel,0.6832994222640991
|
||
|
4526,"def target_function ( self, running, creds ) : <TAB> while running. is_set ( ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> username, password = creds. next ( ). split ( "":"" ) <TAB> <TAB> <TAB> tcp_client = self. tcp_create ( ) <TAB> <TAB> <TAB> tcp_sock = tcp_client. connect ( ) <TAB> <TAB> <TAB> apiros = ApiRosClient ( tcp_sock ) <TAB> <TAB> <TAB> output = apiros. login ( username, password ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> if self. stop_on_success : <TAB> <TAB> <TAB> <TAB> <TAB> running. clear ( ) <TAB> <TAB> <TAB> <TAB> print_success ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Authentication Succeed - Username: '{}' Password: '{}'"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> username, password <TAB> <TAB> <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> <TAB> <TAB> verbose = self. verbosity, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> self. credentials. append ( <TAB> <TAB> <TAB> <TAB> <TAB> ( self. target, self. port, self. target_protocol, username, password ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> print_error ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Authentication Failed - Username: '{}' Password: '{}'"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> username, password <TAB> <TAB> <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> <TAB> <TAB> verbose = self. verbosity, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> tcp_",False,output[0][0] == '!done',self.username and password,0.6539021730422974
|
||
|
4527,"def saveDirectories ( self, ** kwargs ) : <TAB> for kw in LIST_DIRPAGE + LIST_BOOL_DIRPAGE : <TAB> <TAB> value = kwargs. get ( kw ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if kw in ( ""complete_dir"", ""dirscan_dir"" ) : <TAB> <TAB> <TAB> <TAB> msg = config. get_config ( ""misc"", kw ). set ( value, create = True ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> msg = config. get_config ( ""misc"", kw ). set ( value ) <TAB> <TAB> <TAB> if msg : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return badParameterResponse ( msg, kwargs. get ( ""ajax"" ) ) <TAB> if not sabnzbd. check_incomplete_vs_complete ( ) : <TAB> <TAB> return badParameterResponse ( <TAB> <TAB> <TAB> T ( <TAB> <TAB> <TAB> <TAB> ""The Completed Download Folder cannot be the same or a subfolder of the Temporary Download Folder"" <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> kwargs. get ( ""ajax"" ), <TAB> <TAB> ) <TAB> config. save_config ( ) <TAB> if kwargs. get ( ""ajax"" ) : <TAB> <TAB> return sabnzbd. api. report ( ""json"" ) <TAB> else : <TAB> <TAB> raise Raiser ( self. __root )",False,value is not None or kw in LIST_BOOL_DIRPAGE,value,0.6585636734962463
|
||
|
4528,"def wait ( self, seconds = None ) : <TAB> readers = self. listeners [ READ ] <TAB> writers = self. listeners [ WRITE ] <TAB> if not readers and not writers : <TAB> <TAB> if seconds : <TAB> <TAB> <TAB> time. sleep ( seconds ) <TAB> <TAB> return <TAB> all_fds = list ( readers ) + list ( writers ) <TAB> try : <TAB> <TAB> r, w, er = select. select ( readers. keys ( ), writers. keys ( ), all_fds, seconds ) <TAB> except select. error as e : <TAB> <TAB> if get_errno ( e ) == errno. EINTR : <TAB> <TAB> <TAB> return <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> self. _remove_bad_fds ( ) <TAB> <TAB> <TAB> return <TAB> <TAB> else : <TAB> <TAB> <TAB> raise <TAB> for fileno in er : <TAB> <TAB> readers. get ( fileno, noop ). cb ( fileno ) <TAB> <TAB> writers. get ( fileno, noop ). cb ( fileno ) <TAB> for listeners, events in ( ( readers, r ), ( writers, w ) ) : <TAB> <TAB> for fileno in events : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> listeners. get ( fileno, noop ). cb ( fileno ) <TAB> <TAB> <TAB> except self. SYSTEM_EXCEPTIONS : <TAB> <TAB> <TAB> <TAB> raise <TAB> <TAB> <TAB> except : <TAB> <TAB> <TAB> <TAB> self. squelch_exception ( fileno, sys. exc_info ( ) ) <TAB> <TAB> <TAB> <TAB> clear_sys_exc_info ( )",False,get_errno(e) in BAD_SOCK,get_errno(e) == errno.EBADF,0.6540961265563965
|
||
|
4529,"def do ( server, handler, config, args ) : <TAB> if args. command == ""list"" : <TAB> <TAB> result = [ ] <TAB> <TAB> for section in config. sections ( ) : <TAB> <TAB> <TAB> if args. section and args. section!= section : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> result. append ( ""[{}]"". format ( section ) ) <TAB> <TAB> <TAB> if args. sections : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> for variable in config. options ( section ) : <TAB> <TAB> <TAB> <TAB> result. append ( ""{} = {}"". format ( variable, config. get ( section, variable ) ) ) <TAB> <TAB> <TAB> result. append ( """" ) <TAB> <TAB> handler. display ( Pygment ( IniLexer ( ), ""\n"". join ( result ) ) ) <TAB> elif args. command == ""set"" : <TAB> <TAB> try : <TAB> <TAB> <TAB> value = args. value <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> value += "" "" <TAB> <TAB> <TAB> <TAB> value += "" "". join ( args. args ) <TAB> <TAB> <TAB> config. set ( args. section, args. key, value ) <TAB> <TAB> <TAB> config. save ( project = args. write_project, user = args. write_user ) <TAB> <TAB> except config. NoSectionError : <TAB> <TAB> <TAB> handler. display ( Error ( args. section, ""No section"" ) ) <TAB> elif args. command == ""unset"" : <TAB> <TAB> try : <TAB> <TAB> <TAB> if args. keys : <TAB> <TAB> <TAB> <TAB> for key in args. keys : <TAB> <TAB> <TAB> <TAB> <TAB> config. remove_option ( args. section, key ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> to_remove",True,args.args,args.args,0.6710091233253479
|
||
|
4530,"def run ( ) : <TAB> <TAB> global ar2 <TAB> get_args ( ) <TAB> if not ar2 : <TAB> <TAB> <TAB> <TAB> usage ( ) <TAB> <TAB> dump_opts ( ) <TAB> elif ar2 in data : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> do_step ( ar2 ) <TAB> <TAB> save_data ( ) <TAB> if ar2 == ""next"" : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for item in order : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> do_step ( item ) <TAB> <TAB> <TAB> <TAB> save_data ( ) <TAB> <TAB> <TAB> <TAB> break <TAB> if ar2 == ""steps"" : <TAB> <TAB> <TAB> <TAB> print ( """" ) <TAB> <TAB> dump_opts ( ) <TAB> if ar2 == ""show"" : <TAB> <TAB> <TAB> <TAB> for item in order : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> print ( ""\n{}: {}\n"". format ( item, data [ item ] [ 1 ] ) ) <TAB> <TAB> <TAB> <TAB> break <TAB> if ar2 == ""restart"" : <TAB> <TAB> <TAB> <TAB> if exists ( DATA_FILE ) : <TAB> <TAB> <TAB> unlink ( DATA_FILE ) <TAB> if ar2 == ""commands"" : <TAB> <TAB> <TAB> <TAB> print ( cmds )",False,data[item][2] == False,item in data,0.6567115783691406
|
||
|
4531,"def run ( self, ips, imgs, para = None ) : <TAB> k, unit = ips. unit <TAB> strc = generate_binary_structure ( 3, 1 if para [ ""con"" ] == ""4-connect"" else 2 ) <TAB> lab, n = label ( imgs == 0 if para [ ""inv"" ] else imgs, strc, output = np. uint32 ) <TAB> idx = ( np. ones ( n + 1 ) * ( 0 if para [ ""inv"" ] else para [ ""front"" ] ) ). astype ( np. uint8 ) <TAB> ls = regionprops ( lab ) <TAB> for i in ls : <TAB> <TAB> if para [ ""vol"" ] == 0 : <TAB> <TAB> <TAB> break <TAB> <TAB> if para [ ""vol"" ] > 0 : <TAB> <TAB> <TAB> if i. area * k ** 3 < para [ ""vol"" ] : <TAB> <TAB> <TAB> <TAB> idx [ i. label ] = para [ ""back"" ] <TAB> <TAB> if para [ ""vol"" ] < 0 : <TAB> <TAB> <TAB> if i. area * k ** 3 >= - para [ ""vol"" ] : <TAB> <TAB> <TAB> <TAB> idx [ i. label ] = para [ ""back"" ] <TAB> for i in ls : <TAB> <TAB> if para [ ""dia"" ] == 0 : <TAB> <TAB> <TAB> break <TAB> <TAB> d = norm ( np. array ( i. bbox [ : 3 ] ) - np. array ( i. bbox [ 3 : ] ) ) <TAB> <TAB> if para [ ""dia"" ] > 0 : <TAB> <TAB> <TAB> if d * k < para [ ""dia"" ] : <TAB> <TAB> <TAB> <TAB> idx [ i. label ] = para [ ""back"" ] <TAB> <TAB> if para [ ""dia"" ] < 0 : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> idx [ i. label ] = para [ ""back"" ] <TAB> idx [ 0 ] = para [ ""front"" ] if para",False,d * k >= -para['dia'],i.area * k * k < para['front'],0.663841962814331
|
||
|
4532,"def populate_stats_and_pop ( <TAB> self, <TAB> unused_slice_key : slicer. SliceKeyType, <TAB> combine_metrics : Dict [ Text, Any ], <TAB> output_metrics : Dict [ Text, metrics_pb2. MetricValue ], ) -> None : <TAB> matrices = combine_metrics. pop ( <TAB> <TAB> self. _metric_key ( metric_keys. CONFUSION_MATRIX_AT_THRESHOLDS_MATRICES ) <TAB> ) <TAB> thresholds = combine_metrics. pop ( <TAB> <TAB> self. _metric_key ( metric_keys. CONFUSION_MATRIX_AT_THRESHOLDS_THRESHOLDS ) <TAB> ) <TAB> <TAB> if len ( matrices )!= len ( thresholds ) : <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> ""matrices should have the same length as thresholds, but lengths "" <TAB> <TAB> <TAB> ""were: matrices: %d, thresholds: %d"" % ( len ( matrices ), len ( thresholds ) ) <TAB> <TAB> ) <TAB> for threshold, matrix in zip ( thresholds, matrices ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> threshold = threshold. unsampled_value <TAB> <TAB> ( <TAB> <TAB> <TAB> output_metrics [ self. _metric_key ( metric_keys. CONFUSION_MATRIX_AT_THRESHOLDS ) ] <TAB> <TAB> <TAB>. confusion_matrix_at_thresholds. matrices. add ( ) <TAB> <TAB> <TAB>. CopyFrom ( _create_confusion_matrix_proto ( matrix, threshold ) ) <TAB> <TAB> )",False,"isinstance(threshold, types.ValueWithTDistribution)",threshold is not None,0.6496580839157104
|
||
|
4533,"def topsorted_shapes_first ( outputs, node2shape ) : <TAB> <TAB> <TAB> <TAB> marks = { } <TAB> out = [ ] <TAB> stack = [ ] <TAB> for x in outputs : <TAB> <TAB> stack. append ( ( x, 0 ) ) <TAB> <TAB> while stack : <TAB> <TAB> <TAB> ( i, jidx ) = stack. pop ( ) <TAB> <TAB> <TAB> if jidx == 0 : <TAB> <TAB> <TAB> <TAB> m = marks. get ( i, 0 ) <TAB> <TAB> <TAB> <TAB> if m == 0 : <TAB> <TAB> <TAB> <TAB> <TAB> marks [ i ] = 1 <TAB> <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> raise ValueError ( ""not a dag"" ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> ps = i. parents <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if i. ndim > 0 and not i. is_input ( ) and i. op. return_type == ""byref"" : <TAB> <TAB> <TAB> <TAB> if i in node2shape : <TAB> <TAB> <TAB> <TAB> <TAB> shpels = node2shape [ i ] <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> raise core. Unreachable <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ps = ps + shpels <TAB> <TAB> <TAB> elif is_tuple ( i ) : <TAB> <TAB> <TAB> <TAB> for arrshp in node2shape [ i ] : <TAB> <TAB> <TAB> <TAB> <TAB> ps = ps + arrshp <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if jidx == len ( ps ) : <TAB> <TAB",False,m == 1,m > len(out),0.6847740411758423
|
||
|
4534,"def match_uri_to_workspace ( uri, workspaces ) : <TAB> if uri is None : <TAB> <TAB> return None <TAB> max_len, chosen_workspace = - 1, None <TAB> path = pathlib. Path ( uri ). parts <TAB> for workspace in workspaces : <TAB> <TAB> try : <TAB> <TAB> <TAB> workspace_parts = pathlib. Path ( workspace ). parts <TAB> <TAB> except TypeError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> workspace_parts = pathlib. Path ( unicode ( workspace ) ). parts <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> match_len = 0 <TAB> <TAB> for workspace_part, path_part in zip ( workspace_parts, path ) : <TAB> <TAB> <TAB> if workspace_part == path_part : <TAB> <TAB> <TAB> <TAB> match_len += 1 <TAB> <TAB> if match_len > 0 : <TAB> <TAB> <TAB> if match_len > max_len : <TAB> <TAB> <TAB> <TAB> max_len = match_len <TAB> <TAB> <TAB> <TAB> chosen_workspace = workspace <TAB> return chosen_workspace",False,len(workspace_parts) > len(path),len(workspace_parts) > max_len,0.6503225564956665
|
||
|
4535,"def _read ( self, last_pass = False ) : <TAB> lines = self. file. get_lines ( size = 1024 * 1024, last_pass = last_pass ) <TAB> for line in lines : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. skipped_header = True <TAB> <TAB> <TAB> continue <TAB> <TAB> log_vals = [ val. strip ( ) for val in line. split ( ""\t"" ) ] <TAB> <TAB> _error = None <TAB> <TAB> _rstatus = None <TAB> <TAB> _url = self. url_label <TAB> <TAB> _concur = self. concurrency <TAB> <TAB> _tstamp = int ( log_vals [ 1 ] ) <TAB> <TAB> _con_time = float ( log_vals [ 2 ] ) / 1000.0 <TAB> <TAB> _etime = float ( log_vals [ 4 ] ) / 1000.0 <TAB> <TAB> _latency = float ( log_vals [ 5 ] ) / 1000.0 <TAB> <TAB> _bytes = None <TAB> <TAB> yield _tstamp, _url, _concur, _etime, _con_time, _latency, _rstatus, _error, """", _bytes",False,not self.skipped_header,line == last_pass,0.6564524173736572
|
||
|
4536,"def testExactlyOneInvalid ( self ) : <TAB> with SetBotoConfigForTest ( <TAB> <TAB> [ <TAB> <TAB> <TAB> ( ""Credentials"", ""gs_oauth2_refresh_token"", ""foo"" ), <TAB> <TAB> <TAB> ( ""Credentials"", ""gs_service_client_id"", None ), <TAB> <TAB> <TAB> ( ""Credentials"", ""gs_service_key_file"", None ), <TAB> <TAB> ] <TAB> ) : <TAB> <TAB> succeeded = False <TAB> <TAB> try : <TAB> <TAB> <TAB> GcsJsonApi ( None, self. logger ) <TAB> <TAB> <TAB> succeeded = True <TAB> <TAB> except : <TAB> <TAB> <TAB> warning_messages = self. log_handler. messages [ ""warning"" ] <TAB> <TAB> <TAB> self. assertEquals ( 1, len ( warning_messages ) ) <TAB> <TAB> <TAB> self. assertIn ( ""credentials are invalid"", warning_messages [ 0 ] ) <TAB> <TAB> <TAB> self. assertIn ( CredTypes. OAUTH2_USER_ACCOUNT, warning_messages [ 0 ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. fail ( ""Succeeded with invalid credentials, one configured."" )",False,succeeded,not succeeded,0.7072144746780396
|
||
|
4537,"def run ( self, edit, target_level = 0 ) : <TAB> view = self. view <TAB> view. run_command ( ""unfold_all"" ) <TAB> section_start = - 1 <TAB> section_end = view. size ( ) <TAB> n_sections = 0 <TAB> for ( title_begin, title_end, level ) in all_headings ( view ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if section_start > 0 : <TAB> <TAB> <TAB> <TAB> section_end = title_begin - 1 <TAB> <TAB> <TAB> <TAB> reg = sublime. Region ( section_start, section_end ) <TAB> <TAB> <TAB> <TAB> view. fold ( reg ) <TAB> <TAB> <TAB> <TAB> n_sections += 1 <TAB> <TAB> <TAB> <TAB> section_start = - 1 <TAB> <TAB> if target_level == 0 or level == target_level : <TAB> <TAB> <TAB> section_start = title_end <TAB> if section_start >= 0 : <TAB> <TAB> reg = sublime. Region ( section_start, view. size ( ) ) <TAB> <TAB> view. fold ( reg ) <TAB> <TAB> n_sections += 1 <TAB> if len ( view. sel ( ) ) > 0 : <TAB> <TAB> for sel in view. sel ( ) : <TAB> <TAB> <TAB> if getFoldedRegion ( view, sel ) == None : <TAB> <TAB> <TAB> <TAB> view. show ( sel ) <TAB> else : <TAB> <TAB> view. show ( sublime. Region ( 0, 0 ) ) <TAB> sublime. status_message ( <TAB> <TAB> ""%d region%s folded"" % ( n_sections, ""s"" if n_sections > 1 else """" ) <TAB> )",False,target_level == 0 or level <= target_level,level == 0,0.6517579555511475
|
||
|
4538,"def scaffold_directories ( cls, base_dir ) : <TAB> """"""Safely create GE directories for a new project."""""" <TAB> os. makedirs ( base_dir, exist_ok = True ) <TAB> open ( os. path. join ( base_dir, "".gitignore"" ), ""w"" ). write ( ""uncommitted/"" ) <TAB> for directory in cls. BASE_DIRECTORIES : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> plugins_dir = os. path. join ( base_dir, directory ) <TAB> <TAB> <TAB> os. makedirs ( plugins_dir, exist_ok = True ) <TAB> <TAB> <TAB> os. makedirs ( os. path. join ( plugins_dir, ""custom_data_docs"" ), exist_ok = True ) <TAB> <TAB> <TAB> os. makedirs ( <TAB> <TAB> <TAB> <TAB> os. path. join ( plugins_dir, ""custom_data_docs"", ""views"" ), <TAB> <TAB> <TAB> <TAB> exist_ok = True, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> os. makedirs ( <TAB> <TAB> <TAB> <TAB> os. path. join ( plugins_dir, ""custom_data_docs"", ""renderers"" ), <TAB> <TAB> <TAB> <TAB> exist_ok = True, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> os. makedirs ( <TAB> <TAB> <TAB> <TAB> os. path. join ( plugins_dir, ""custom_data_docs"", ""styles"" ), <TAB> <TAB> <TAB> <TAB> exist_ok = True, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> cls. scaffold_custom_data_docs ( plugins_dir ) <TAB> <TAB> else : <TAB> <TAB> <TAB> os. makedirs ( os. path. join ( base_dir, directory ), exist_ok = True ) <TAB> uncommitted_dir = os. path. join ( base_dir, cls. GE_UNCOMMITTED_DIR ) <TAB> for",False,directory == 'plugins',exist_ok,0.656913161277771
|
||
|
4539,"def cli_print_upgradeable ( ) -> None : <TAB> args = parse_args ( ) <TAB> updates : List [ InstallInfo ] = [ ] <TAB> if not args. repo : <TAB> <TAB> aur_updates, _not_found_aur_pkgs = find_aur_updates ( ) <TAB> <TAB> updates += aur_updates <TAB> if not args. aur : <TAB> <TAB> updates += find_repo_upgradeable ( ) <TAB> if not updates : <TAB> <TAB> return <TAB> for pkg in updates [ : ] : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> updates. remove ( pkg ) <TAB> <TAB> <TAB> print_ignored_package ( package_name = pkg. name ) <TAB> if args. quiet : <TAB> <TAB> print_stdout ( ""\n"". join ( [ pkg_update. name for pkg_update in updates ] ) ) <TAB> else : <TAB> <TAB> print_stdout ( <TAB> <TAB> <TAB> pretty_format_upgradeable ( <TAB> <TAB> <TAB> <TAB> updates, print_repo = PikaurConfig ( ). sync. AlwaysShowPkgOrigin. get_bool ( ) <TAB> <TAB> <TAB> ) <TAB> <TAB> )",False,"pkg.name in args.ignore + PacmanConfig().options.get('IgnorePkg', [])",pkg.name in _not_found_aur_pkgs,0.658341646194458
|
||
|
4540,"def write ( self, text ) : <TAB> try : <TAB> <TAB> if self. _hConsole is None : <TAB> <TAB> <TAB> if isinstance ( text, unicode ) : <TAB> <TAB> <TAB> <TAB> text = text. encode ( ""utf-8"" ) <TAB> <TAB> <TAB> self. _stream. write ( text ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> text = bytes ( text ). decode ( ""utf-8"" ) <TAB> <TAB> <TAB> remaining = len ( text ) <TAB> <TAB> <TAB> while remaining > 0 : <TAB> <TAB> <TAB> <TAB> n = DWORD ( 0 ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> retval = WriteConsoleW ( <TAB> <TAB> <TAB> <TAB> <TAB> self. _hConsole, text, min ( remaining, 10000 ), byref ( n ), None <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> if retval == 0 or n. value == 0 : <TAB> <TAB> <TAB> <TAB> <TAB> raise IOError ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""WriteConsoleW returned %r, n.value = %r"" % ( retval, n. value ) <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> remaining -= n. value <TAB> <TAB> <TAB> <TAB> if remaining == 0 : <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> text = text [ n. value : ] <TAB> except Exception as e : <TAB> <TAB> _complain ( ""%s.write: %r"" % ( self. name, e ) ) <TAB> <TAB> raise",False,"not isinstance(text, unicode)","isinstance(text, bytes)",0.6489019393920898
|
||
|
4541,"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. STRING : <TAB> <TAB> <TAB> <TAB> self. key = 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. count = iprot. readI32 ( ) <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.I32,fid == 3,0.6586172580718994
|
||
|
4542,"def __new__ ( cls, typename, bases, ns ) : <TAB> assert bases [ 0 ] is _NamedTuple <TAB> types = ns. get ( ""__annotations__"", { } ) <TAB> default_names = [ ] <TAB> for field_name in types : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> default_names. append ( field_name ) <TAB> <TAB> elif default_names : <TAB> <TAB> <TAB> raise TypeError ( <TAB> <TAB> <TAB> <TAB> f""Non-default namedtuple field {field_name} "" <TAB> <TAB> <TAB> <TAB> f""cannot follow default field"" <TAB> <TAB> <TAB> <TAB> f""{'s' if len(default_names) > 1 else ''} "" <TAB> <TAB> <TAB> <TAB> f""{', '.join(default_names)}"" <TAB> <TAB> <TAB> ) <TAB> nm_tpl = _make_nmtuple ( <TAB> <TAB> typename, <TAB> <TAB> types. items ( ), <TAB> <TAB> defaults = [ ns [ n ] for n in default_names ], <TAB> <TAB> module = ns [ ""__module__"" ], <TAB> ) <TAB> <TAB> for key in ns : <TAB> <TAB> if key in _prohibited : <TAB> <TAB> <TAB> raise AttributeError ( ""Cannot overwrite NamedTuple attribute "" + key ) <TAB> <TAB> elif key not in _special and key not in nm_tpl. _fields : <TAB> <TAB> <TAB> setattr ( nm_tpl, key, ns [ key ] ) <TAB> return nm_tpl",False,field_name in ns,field_name in types,0.6673007607460022
|
||
|
4543,"def wait_for_completion ( self, job_id, offset, max_results, start_time, timeout ) : <TAB> """"""Wait for job completion and return the first page."""""" <TAB> while True : <TAB> <TAB> result = self. get_query_results ( <TAB> <TAB> <TAB> job_id = job_id, page_token = None, start_index = offset, max_results = max_results <TAB> <TAB> ) <TAB> <TAB> if result [ ""jobComplete"" ] : <TAB> <TAB> <TAB> return result <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise Exception ( <TAB> <TAB> <TAB> <TAB> ""Timeout: the query doesn't finish within %d seconds."" % timeout <TAB> <TAB> <TAB> ) <TAB> <TAB> time. sleep ( 1 )",False,time.time() - start_time > timeout,timeout is None or time.time() - start_time > timeout,0.6540282964706421
|
||
|
4544,"def _resolve_oauth_config ( name, local_namespace, config, * variables ) : <TAB> presets = PRESETS. get ( name, { } ) <TAB> output = [ ] <TAB> for variable in variables : <TAB> <TAB> value = local_namespace. get ( variable, None ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> value = config. get ( ""OAUTH_{}_{}"". format ( name, variable ). upper ( ), None ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> value = presets. get ( variable, None ) <TAB> <TAB> output. append ( value ) <TAB> return output",True,value is None,value is None,0.6602245569229126
|
||
|
4545,"def __init__ ( self, pyversions, coverage_service ) : <TAB> build_matrix = """" <TAB> for version in pyversions : <TAB> <TAB> build_matrix += ""\n {},"". format ( <TAB> <TAB> <TAB> version <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> else ""py{}"". format ( """". join ( version. split ( ""."" ) ) ) <TAB> <TAB> ) <TAB> coverage_package = """" <TAB> if coverage_service : <TAB> <TAB> coverage_package += ""\n {}"". format ( coverage_service. package ) <TAB> coverage_package += ""\n"" <TAB> super ( Tox, self ). __init__ ( <TAB> <TAB> ""tox.ini"", <TAB> <TAB> TEMPLATE. format ( build_matrix = build_matrix, coverage_package = coverage_package ), <TAB> )",False,version.startswith('pypy'),version,0.6474045515060425
|
||
|
4546,"def check_settings ( self ) : <TAB> if self. settings_dict [ ""TIME_ZONE"" ] is not None : <TAB> <TAB> if not settings. USE_TZ : <TAB> <TAB> <TAB> raise ImproperlyConfigured ( <TAB> <TAB> <TAB> <TAB> ""Connection '%s' cannot set TIME_ZONE because USE_TZ is "" <TAB> <TAB> <TAB> <TAB> ""False."" % self. alias <TAB> <TAB> <TAB> ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> raise ImproperlyConfigured ( <TAB> <TAB> <TAB> <TAB> ""Connection '%s' cannot set TIME_ZONE because its engine "" <TAB> <TAB> <TAB> <TAB> ""handles time zones conversions natively."" % self. alias <TAB> <TAB> <TAB> )",False,self.features.supports_timezones,settings.TIME_ZONE is None,0.6623598337173462
|
||
|
4547,"def canonicalize ( path ) : <TAB> """"""Makes all paths start at top left, and go clockwise first."""""" <TAB> <TAB> path = [ [ x [ 0 ] ] + list ( map ( float, x [ 1 : ] ) ) for x in path ] <TAB> <TAB> new_substructures = [ ] <TAB> for subpath in _separate_substructures ( path ) : <TAB> <TAB> leftmost_point, leftmost_idx = _get_leftmost_point ( subpath ) <TAB> <TAB> reordered = ( <TAB> <TAB> <TAB> [ [ ""M"", leftmost_point [ 0 ], leftmost_point [ 1 ] ] ] <TAB> <TAB> <TAB> + subpath [ leftmost_idx + 1 : ] <TAB> <TAB> <TAB> + subpath [ 1 : leftmost_idx + 1 ] <TAB> <TAB> ) <TAB> <TAB> new_substructures. append ( ( reordered, leftmost_point ) ) <TAB> new_path = [ ] <TAB> first_substructure_done = False <TAB> should_flip_cardinality = False <TAB> for sp, _ in sorted ( new_substructures, key = lambda x : ( x [ 1 ] [ 1 ], x [ 1 ] [ 0 ] ) ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> should_flip_cardinality = not _is_clockwise ( sp ) <TAB> <TAB> <TAB> first_substructure_done = True <TAB> <TAB> if should_flip_cardinality : <TAB> <TAB> <TAB> sp = _make_clockwise ( sp ) <TAB> <TAB> new_path. extend ( sp ) <TAB> <TAB> path = [ [ x [ 0 ] ] + list ( map ( str, x [ 1 : ] ) ) for x in new_path ] <TAB> return path",False,not first_substructure_done,first_substructure_done,0.6481825709342957
|
||
|
4548,"def __init__ ( self, info ) : <TAB> <TAB> <TAB> if isinstance ( info, http. client. HTTPResponse ) : <TAB> <TAB> for key, value in info. getheaders ( ) : <TAB> <TAB> <TAB> key = key. lower ( ) <TAB> <TAB> <TAB> prev = self. get ( key ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> value = "", "". join ( ( prev, value ) ) <TAB> <TAB> <TAB> self [ key ] = value <TAB> <TAB> self. status = info. status <TAB> <TAB> self [ ""status"" ] = str ( self. status ) <TAB> <TAB> self. reason = info. reason <TAB> <TAB> self. version = info. version <TAB> elif isinstance ( info, email. message. Message ) : <TAB> <TAB> for key, value in list ( info. items ( ) ) : <TAB> <TAB> <TAB> self [ key. lower ( ) ] = value <TAB> <TAB> self. status = int ( self [ ""status"" ] ) <TAB> else : <TAB> <TAB> for key, value in info. items ( ) : <TAB> <TAB> <TAB> self [ key. lower ( ) ] = value <TAB> <TAB> self. status = int ( self. get ( ""status"", self. status ) )",False,prev is not None,prev,0.6594246625900269
|
||
|
4549,"def connect_to_printer ( self, port, baud, dtr ) : <TAB> try : <TAB> <TAB> self. p. connect ( port, baud, dtr ) <TAB> except SerialException as e : <TAB> <TAB> <TAB> <TAB> if e. errno == 2 : <TAB> <TAB> <TAB> self. logError ( _ ( ""Error: You are trying to connect to a non-existing port."" ) ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> self. logError ( _ ( ""Error: You don't have permission to open %s."" ) % port ) <TAB> <TAB> <TAB> self. logError ( _ ( ""You might need to add yourself to the dialout group."" ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. logError ( traceback. format_exc ( ) ) <TAB> <TAB> <TAB> <TAB> return False <TAB> except OSError as e : <TAB> <TAB> if e. errno == 2 : <TAB> <TAB> <TAB> self. logError ( _ ( ""Error: You are trying to connect to a non-existing port."" ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. logError ( traceback. format_exc ( ) ) <TAB> <TAB> return False <TAB> self. statuscheck = True <TAB> self. status_thread = threading. Thread ( <TAB> <TAB> target = self. statuschecker, name = ""status thread"" <TAB> ) <TAB> self. status_thread. start ( ) <TAB> return True",False,e.errno == 8,e.errno == 1,0.6720011234283447
|
||
|
4550,"def _test_set_metadata ( self, metadata, mask = None ) : <TAB> header = ofproto. OXM_OF_METADATA <TAB> match = OFPMatch ( ) <TAB> if mask is None : <TAB> <TAB> match. set_metadata ( metadata ) <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> header = ofproto. OXM_OF_METADATA_W <TAB> <TAB> match. set_metadata_masked ( metadata, mask ) <TAB> <TAB> metadata &= mask <TAB> self. _test_serialize_and_parser ( match, header, metadata, mask )",False,mask + 1 >> 64 != 1,header is None,0.6779102683067322
|
||
|
4551,"def detect ( <TAB> cls, <TAB> standalone : bool, <TAB> namespace : Optional [ str ], <TAB> name : Optional [ str ], <TAB> ** kwargs : Any, ) -> Optional [ ""Peer"" ] : <TAB> if standalone : <TAB> <TAB> return None <TAB> if name : <TAB> <TAB> if await Peer. _is_peering_exist ( name, namespace = namespace ) : <TAB> <TAB> <TAB> return cls ( name = name, namespace = namespace, ** kwargs ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> return cls ( name = name, namespace = namespace, legacy = True, ** kwargs ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise Exception ( f""The peering {name!r} was not found"" ) <TAB> if await Peer. _is_peering_exist ( name = PEERING_DEFAULT_NAME, namespace = namespace ) : <TAB> <TAB> return cls ( name = PEERING_DEFAULT_NAME, namespace = namespace, ** kwargs ) <TAB> elif await Peer. _is_peering_legacy ( name = PEERING_DEFAULT_NAME, namespace = namespace ) : <TAB> <TAB> return cls ( <TAB> <TAB> <TAB> name = PEERING_DEFAULT_NAME, namespace = namespace, legacy = True, ** kwargs <TAB> <TAB> ) <TAB> logger. warning ( <TAB> <TAB> f""Default peering object not found, falling back to the standalone mode."" <TAB> ) <TAB> return None",False,"await Peer._is_peering_legacy(name, namespace=namespace)",await peer.has_default_name(name),0.651797354221344
|
||
|
4552,"def extract ( self, real ) : <TAB> version = real [ ""version"" ]. value <TAB> if ""metadata"" in real : <TAB> <TAB> self. useMetadata ( real [ ""metadata"" ] ) <TAB> self. useRoot ( real ) <TAB> self. format_version = ""Real audio version %s"" % version <TAB> if version == 3 : <TAB> <TAB> size = getValue ( real, ""data_size"" ) <TAB> elif ""filesize"" in real and ""headersize"" in real : <TAB> <TAB> size = ( real [ ""filesize"" ]. value + 40 ) - ( real [ ""headersize"" ]. value + 16 ) <TAB> else : <TAB> <TAB> size = None <TAB> if size : <TAB> <TAB> size *= 8 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> sec = float ( size ) / self. get ( ""bit_rate"" ) <TAB> <TAB> <TAB> self. duration = timedelta ( seconds = sec ) <TAB> <TAB> computeComprRate ( self, size )",False,self.has('bit_rate'),self.get('bit_rate'),0.648869514465332
|
||
|
4553,"def _remove_visual_c_ref ( self, manifest_file ) : <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> manifest_f = open ( manifest_file ) <TAB> <TAB> try : <TAB> <TAB> <TAB> manifest_buf = manifest_f. read ( ) <TAB> <TAB> finally : <TAB> <TAB> <TAB> manifest_f. close ( ) <TAB> <TAB> pattern = re. compile ( <TAB> <TAB> <TAB> r""""""<assemblyIdentity.*?name=(""|')Microsoft\."""""" <TAB> <TAB> <TAB> r""""""VC\d{2}\.CRT(""|').*?(/>|</assemblyIdentity>)"""""", <TAB> <TAB> <TAB> re. DOTALL, <TAB> <TAB> ) <TAB> <TAB> manifest_buf = re. sub ( pattern, """", manifest_buf ) <TAB> <TAB> pattern = ""<dependentAssembly>\s*</dependentAssembly>"" <TAB> <TAB> manifest_buf = re. sub ( pattern, """", manifest_buf ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> pattern = re. compile ( <TAB> <TAB> <TAB> r""""""<assemblyIdentity.*?name=(?:""|')(.+?)(?:""|')"""""" <TAB> <TAB> <TAB> r"""""".*?(?:/>|</assemblyIdentity>)"""""", <TAB> <TAB> <TAB> re. DOTALL, <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return None <TAB> <TAB> manifest_f = open ( manifest_file, ""w"" ) <TAB> <TAB> try : <TAB> <TAB> <TAB> manifest_f. write ( manifest_buf ) <TAB> <TAB> <TAB> return manifest_file <TAB> <TAB> finally : <TAB> <TAB> <TAB> manifest_f. close ( ) <TAB> except IOError : <TAB> <TAB> pass",False,"re.search(pattern, manifest_buf) is None",not manifest_file,0.6473808288574219
|
||
|
4554,"def _grid_configure ( self, command, index, cnf, kw ) : <TAB> """"""Internal function."""""" <TAB> if type ( cnf ) is StringType and not kw : <TAB> <TAB> if cnf [ - 1 : ] == ""_"" : <TAB> <TAB> <TAB> cnf = cnf [ : - 1 ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> cnf = ""-"" + cnf <TAB> <TAB> options = ( cnf, ) <TAB> else : <TAB> <TAB> options = self. _options ( cnf, kw ) <TAB> if not options : <TAB> <TAB> return _splitdict ( <TAB> <TAB> <TAB> self. tk, <TAB> <TAB> <TAB> self. tk. call ( ""grid"", command, self. _w, index ), <TAB> <TAB> <TAB> conv = self. _gridconvvalue, <TAB> <TAB> ) <TAB> res = self. tk. call ( ( ""grid"", command, self. _w, index ) + options ) <TAB> if len ( options ) == 1 : <TAB> <TAB> return self. _gridconvvalue ( res )",False,cnf[:1] != '-',command == 'grid',0.6899287104606628
|
||
|
4555,"def run ( self, paths = [ ] ) : <TAB> try : <TAB> <TAB> origin = view_locations_stack [ - 2 ] <TAB> <TAB> items = [ ] <TAB> <TAB> for item in SideBarSelection ( paths ). getSelectedItems ( ) : <TAB> <TAB> <TAB> items. append ( item. path ( ) ) <TAB> <TAB> temp = [ ] <TAB> <TAB> for index in range ( len ( items ) ) : <TAB> <TAB> <TAB> if not os. path. samefile ( items [ index ], origin ) : <TAB> <TAB> <TAB> <TAB> temp. append ( <TAB> <TAB> <TAB> <TAB> <TAB> os. path. join ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""."", os. path. relpath ( items [ index ], os. path. dirname ( origin ) ) <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> items = temp <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> sublime. set_clipboard ( ""\n"". join ( items ) ) <TAB> <TAB> <TAB> if len ( items ) > 1 : <TAB> <TAB> <TAB> <TAB> sublime. status_message ( ""Items copied"" ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> sublime. status_message ( ""Item copied"" ) <TAB> except : <TAB> <TAB> pass",True,len(items) > 0,len(items) > 0,0.659581184387207
|
||
|
4556,"def add_all_onion_services ( self ) : <TAB> if self. tor_conn is None : <TAB> <TAB> return <TAB> hostname_key_list = yield list_onion_service_info ( ) <TAB> for tid, hostname, key, old_hostname, old_key in hostname_key_list : <TAB> <TAB> if hostname and hostname not in self. hs_map : <TAB> <TAB> <TAB> yield self. add_onion_service ( tid, hostname, key ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> yield self. add_onion_service ( tid, old_hostname, old_key )",False,old_hostname and old_hostname not in self.hs_map,old_hostname and old_key not in self.hs_map,0.6539573669433594
|
||
|
4557,"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 = CacheFileMetadataResult ( ) <TAB> <TAB> <TAB> <TAB> self. success. 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 ( )",False,ftype == TType.STRUCT,self.success is not None,0.6610006093978882
|
||
|
4558,"def func_wrapper ( * args, ** kwargs ) : <TAB> warnings. simplefilter ( ""always"", DeprecationWarning ) <TAB> for old, new in arg_mapping. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> warnings. warn ( <TAB> <TAB> <TAB> <TAB> f""Keyword argument '{old}' has been "" <TAB> <TAB> <TAB> <TAB> f""deprecated in favour of '{new}'. "" <TAB> <TAB> <TAB> <TAB> f""'{old}' will be removed in a future version."", <TAB> <TAB> <TAB> <TAB> category = DeprecationWarning, <TAB> <TAB> <TAB> <TAB> stacklevel = 2, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> val = kwargs. pop ( old ) <TAB> <TAB> <TAB> kwargs [ new ] = val <TAB> <TAB> warnings. simplefilter ( ""default"", DeprecationWarning ) <TAB> return func ( * args, ** kwargs )",True,old in kwargs,old in kwargs,0.6772074699401855
|
||
|
4559,"def send ( self, subject, body ) : <TAB> for field in filter ( <TAB> <TAB> lambda x : self. notification_class. init_parameters [ x ] [ ""type"" ] == ""password"", <TAB> <TAB> self. notification_class. init_parameters, <TAB> ) : <TAB> <TAB> if field in self. notification_configuration : <TAB> <TAB> <TAB> self. notification_configuration [ field ] = decrypt_field ( <TAB> <TAB> <TAB> <TAB> self, ""notification_configuration"", subfield = field <TAB> <TAB> <TAB> ) <TAB> recipients = self. notification_configuration. pop ( <TAB> <TAB> self. notification_class. recipient_parameter <TAB> ) <TAB> if not isinstance ( recipients, list ) : <TAB> <TAB> recipients = [ recipients ] <TAB> sender = self. notification_configuration. pop ( <TAB> <TAB> self. notification_class. sender_parameter, None <TAB> ) <TAB> notification_configuration = deepcopy ( self. notification_configuration ) <TAB> for field, params in self. notification_class. init_parameters. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if ""default"" in params : <TAB> <TAB> <TAB> <TAB> notification_configuration [ field ] = params [ ""default"" ] <TAB> backend_obj = self. notification_class ( ** notification_configuration ) <TAB> notification_obj = EmailMessage ( <TAB> <TAB> subject, backend_obj. format_body ( body ), sender, recipients <TAB> ) <TAB> with set_environ ( ** settings. AWX_TASK_ENV ) : <TAB> <TAB> return backend_obj. send_messages ( [ notification_obj ] )",False,field not in notification_configuration,field in self.notification_class,0.6579693555831909
|
||
|
4560,"def _get ( self ) : <TAB> fut = item = None <TAB> with self. _mutex : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> fut = Future ( ) <TAB> <TAB> <TAB> fut. add_done_callback ( <TAB> <TAB> <TAB> <TAB> lambda f : self. _get_complete ( ) if not f. cancelled ( ) else None <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> self. _getters. append ( fut ) <TAB> <TAB> else : <TAB> <TAB> <TAB> item = self. _get_item ( ) <TAB> <TAB> <TAB> self. _get_complete ( ) <TAB> return item, fut",False,not self._queue or self._getters,self._getters is not None,0.6624019145965576
|
||
|
4561,"def run_server ( self, sock ) : <TAB> <TAB> with sock : <TAB> <TAB> [ client, _ ] = sock. accept ( ) <TAB> with contextlib. ExitStack ( ) as cleanup : <TAB> <TAB> cleanup. enter_context ( client ) <TAB> <TAB> reader = cleanup. enter_context ( client. makefile ( ""rb"" ) ) <TAB> <TAB> client. sendall ( b""200 Server ready\r\n"" ) <TAB> <TAB> while True : <TAB> <TAB> <TAB> cmd = reader. readline ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> client. sendall ( <TAB> <TAB> <TAB> <TAB> <TAB> b""101 Capability list:\r\n"" <TAB> <TAB> <TAB> <TAB> <TAB> b""VERSION 2\r\n"" <TAB> <TAB> <TAB> <TAB> <TAB> b""STARTTLS\r\n"" <TAB> <TAB> <TAB> <TAB> <TAB> b"".\r\n"" <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> elif cmd == b""STARTTLS\r\n"" : <TAB> <TAB> <TAB> <TAB> reader. close ( ) <TAB> <TAB> <TAB> <TAB> client. sendall ( b""382 Begin TLS negotiation now\r\n"" ) <TAB> <TAB> <TAB> <TAB> context = ssl. SSLContext ( ) <TAB> <TAB> <TAB> <TAB> context. load_cert_chain ( certfile ) <TAB> <TAB> <TAB> <TAB> client = context. wrap_socket ( client, server_side = True ) <TAB> <TAB> <TAB> <TAB> cleanup. enter_context ( client ) <TAB> <TAB> <TAB> <TAB> reader = cleanup. enter_context ( client. makefile ( ""rb"" ) ) <TAB> <TAB> <TAB> elif cmd == b""QUIT\r\n"" : <TAB> <TAB> <TAB> <TAB> client. sendall ( b""205 Bye!\",False,cmd == b'CAPABILITIES\r\n',cmd == b'QUIT\r\n',0.6551171541213989
|
||
|
4562,"def sanityCheck ( self ) : <TAB> if not self. col. basicCheck ( ) : <TAB> <TAB> return ""failed basic check"" <TAB> for t in ""cards"", ""notes"", ""revlog"", ""graves"" : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return ""%s had usn = -1"" % t <TAB> for g in self. col. decks. all ( ) : <TAB> <TAB> if g [ ""usn"" ] == - 1 : <TAB> <TAB> <TAB> return ""deck had usn = -1"" <TAB> for t, usn in self. col. tags. allItems ( ) : <TAB> <TAB> if usn == - 1 : <TAB> <TAB> <TAB> return ""tag had usn = -1"" <TAB> found = False <TAB> for m in self. col. models. all ( ) : <TAB> <TAB> if self. col. server : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if m [ ""usn"" ] < 0 : <TAB> <TAB> <TAB> <TAB> m [ ""usn"" ] = 0 <TAB> <TAB> <TAB> <TAB> found = True <TAB> <TAB> else : <TAB> <TAB> <TAB> if m [ ""usn"" ] == - 1 : <TAB> <TAB> <TAB> <TAB> return ""model had usn = -1"" <TAB> if found : <TAB> <TAB> self. col. models. save ( ) <TAB> self. col. sched. reset ( ) <TAB> <TAB> self. col. sched. deckDueList ( ) <TAB> <TAB> return [ <TAB> <TAB> list ( self. col. sched. counts ( ) ), <TAB> <TAB> self. col. db. scalar ( ""select count() from cards"" ), <TAB> <TAB> self. col. db. scalar ( ""select count() from notes"" ), <TAB> <TAB> self. col. db. scalar ( ""select count() from revlog"" ), <TAB> <TAB> self. col. db. scalar ( ""select count",False,self.col.db.scalar('select count() from %s where usn = -1' % t),t in self.col.tags,0.6543831825256348
|
||
|
4563,"def test_delete_model ( self ) : <TAB> session_factory = self. replay_flight_data ( ""test_sagemaker_delete_model"" ) <TAB> p = self. load_policy ( <TAB> <TAB> { <TAB> <TAB> <TAB> ""name"" : ""delete-invalid-sagemaker-model"", <TAB> <TAB> <TAB> ""resource"" : ""sagemaker-model"", <TAB> <TAB> <TAB> ""filters"" : [ { ""tag:DeleteMe"" : ""present"" } ], <TAB> <TAB> <TAB> ""actions"" : [ { ""type"" : ""delete"" } ], <TAB> <TAB> }, <TAB> <TAB> session_factory = session_factory, <TAB> ) <TAB> resources = p. run ( ) <TAB> self. assertEqual ( len ( resources ), 1 ) <TAB> client = session_factory ( ). client ( ""sagemaker"" ) <TAB> try : <TAB> <TAB> client. describe_model ( ModelName = resources [ 0 ] [ ""ModelName"" ] ) <TAB> except b_exc. ClientError as e : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. fail ( ""Bad Error:"" + e. response [ ""Error"" ] [ ""Code"" ] ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. assertEqual ( e. response [ ""Error"" ] [ ""Code"" ], ""ValidationException"" ) <TAB> else : <TAB> <TAB> self. fail ( ""Resource still exists"" )",False,e.response['Error']['Code'] != 'ValidationException',e.response[0]['Code'] in _ERROR_MAP,0.6592837572097778
|
||
|
4564,"def update ( self, preds, maxvals, score, imgid, * args, ** kwargs ) : <TAB> <TAB> num_joints = preds. shape [ 1 ] <TAB> in_vis_thresh = self. _in_vis_thresh <TAB> for idx, kpt in enumerate ( preds ) : <TAB> <TAB> kpt = [ ] <TAB> <TAB> kpt_score = 0 <TAB> <TAB> count = 0 <TAB> <TAB> for i in range ( num_joints ) : <TAB> <TAB> <TAB> kpt += preds [ idx ] [ i ]. asnumpy ( ). tolist ( ) <TAB> <TAB> <TAB> mval = float ( maxvals [ idx ] [ i ]. asscalar ( ) ) <TAB> <TAB> <TAB> kpt. append ( mval ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> kpt_score += mval <TAB> <TAB> <TAB> <TAB> count += 1 <TAB> <TAB> if count > 0 : <TAB> <TAB> <TAB> kpt_score /= count <TAB> <TAB> rescore = kpt_score * score [ idx ]. asscalar ( ) <TAB> <TAB> self. _results. append ( <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> ""image_id"" : int ( imgid [ idx ]. asscalar ( ) ), <TAB> <TAB> <TAB> <TAB> ""category_id"" : 1, <TAB> <TAB> <TAB> <TAB> ""keypoints"" : kpt, <TAB> <TAB> <TAB> <TAB> ""score"" : rescore, <TAB> <TAB> <TAB> } <TAB> <TAB> ) <TAB> <TAB> self. _recorded_ids [ int ( imgid [ idx ]. asscalar ( ) ) ] = True",False,mval > in_vis_thresh,count > 0,0.6619218587875366
|
||
|
4565,"def stats ( self ) : <TAB> logger. info ( ""total conversations: {}"". format ( len ( self. catalog ) ) ) <TAB> if self. bot. memory. exists ( [ ""user_data"" ] ) : <TAB> <TAB> count_user = 0 <TAB> <TAB> count_user_cached = 0 <TAB> <TAB> count_user_cached_definitive = 0 <TAB> <TAB> for chat_id in self. bot. memory [ ""user_data"" ] : <TAB> <TAB> <TAB> count_user = count_user + 1 <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> count_user_cached = count_user_cached + 1 <TAB> <TAB> <TAB> <TAB> if self. bot. memory [ ""user_data"" ] [ chat_id ] [ ""_hangups"" ] [ ""is_definitive"" ] : <TAB> <TAB> <TAB> <TAB> <TAB> count_user_cached_definitive = count_user_cached_definitive + 1 <TAB> <TAB> logger. info ( <TAB> <TAB> <TAB> ""total users: {} cached: {} definitive (at start): {}"". format ( <TAB> <TAB> <TAB> <TAB> count_user, count_user_cached, count_user_cached_definitive <TAB> <TAB> <TAB> ) <TAB> <TAB> )",False,'_hangups' in self.bot.memory['user_data'][chat_id],self.bot.memory['user_data'],0.6499892473220825
|
||
|
4566,"def word_range ( word ) : <TAB> for ind in range ( len ( word ) ) : <TAB> <TAB> temp = word [ ind ] <TAB> <TAB> for c in [ chr ( x ) for x in range ( ord ( ""a"" ), ord ( ""z"" ) + 1 ) ] : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> yield word [ : ind ] + c + word [ ind + 1 : ]",False,c != temp,temp,0.677412748336792
|
||
|
4567,"def check ( conf, token, prev, next, nextnext, context ) : <TAB> if prev and isinstance ( prev, yaml. tokens. TagToken ) : <TAB> <TAB> return <TAB> if conf [ ""forbid-implicit-octal"" ] : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if not token. style : <TAB> <TAB> <TAB> <TAB> val = token. value <TAB> <TAB> <TAB> <TAB> if ( <TAB> <TAB> <TAB> <TAB> <TAB> val. isdigit ( ) <TAB> <TAB> <TAB> <TAB> <TAB> and len ( val ) > 1 <TAB> <TAB> <TAB> <TAB> <TAB> and val [ 0 ] == ""0"" <TAB> <TAB> <TAB> <TAB> <TAB> and _is_octal_number ( val [ 1 : ] ) <TAB> <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> <TAB> yield LintProblem ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> token. start_mark. line + 1, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> token. end_mark. column + 1, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> 'forbidden implicit octal value ""%s""' % token. value, <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> if conf [ ""forbid-explicit-octal"" ] : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if not token. style : <TAB> <TAB> <TAB> <TAB> val = token. value <TAB> <TAB> <TAB> <TAB> if len ( val ) > 2 and val [ : 2 ] == ""0o"" and _is_octal_number ( val [ 2 : ] ) : <TAB> <TAB> <TAB> <TAB> <TAB> yield LintProblem ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> token. start_mark. line + 1, <TAB> <TAB> <TAB>",False,"isinstance(token, yaml.tokens.ScalarToken)",token.start_mark,0.6518650650978088
|
||
|
4568,"def __init__ ( self, * args, ** kwargs ) : <TAB> super ( ProjectForm, self ). __init__ ( * args, ** kwargs ) <TAB> if self. instance. id : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. fields [ ""localfiletype"" ]. widget. attrs [ ""disabled"" ] = True <TAB> <TAB> <TAB> self. fields [ ""localfiletype"" ]. required = False <TAB> <TAB> if ( <TAB> <TAB> <TAB> self. instance. treestyle!= ""auto"" <TAB> <TAB> <TAB> and self. instance. translationproject_set. count ( ) <TAB> <TAB> <TAB> and self. instance. treestyle == self. instance. _detect_treestyle ( ) <TAB> <TAB> ) : <TAB> <TAB> <TAB> self. fields [ ""treestyle"" ]. widget. attrs [ ""disabled"" ] = True <TAB> <TAB> <TAB> self. fields [ ""treestyle"" ]. required = False",False,Store.objects.filter(translation_project__project=self.instance).count(),self.instance.treestyle == 'auto',0.6506452560424805
|
||
|
4569,"def _get_s3_files ( local_dir, file_info, params ) : <TAB> """"""Retrieve s3 files to local directory, handling STORMSeq inputs."""""" <TAB> assert len ( file_info ) == 1 <TAB> files = file_info. values ( ) [ 0 ] <TAB> fnames = [ ] <TAB> for k in [ ""1"", ""2"" ] : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> fnames. append ( files [ k ] ) <TAB> out = [ ] <TAB> for fname in fnames : <TAB> <TAB> bucket, key = fname. replace ( ""s3://"", """" ). split ( ""/"", 1 ) <TAB> <TAB> if params [ ""access_key_id"" ] == ""TEST"" : <TAB> <TAB> <TAB> out. append ( os. path. join ( local_dir, os. path. basename ( key ) ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> out. append ( s3. get_file ( local_dir, bucket, key, params ) ) <TAB> return out",False,files[k] not in fnames,files[k],0.658602774143219
|
||
|
4570,"def __exit__ ( self, exc_type, exc_val, exc_tb ) : <TAB> saved_values = self. saved_values <TAB> del self. saved_values <TAB> <TAB> support. gc_collect ( ) <TAB> <TAB> self. changed |= support. environment_altered <TAB> for name, get, restore in self. resource_info ( ) : <TAB> <TAB> current = get ( ) <TAB> <TAB> original = saved_values. pop ( name ) <TAB> <TAB> <TAB> <TAB> if current!= original : <TAB> <TAB> <TAB> self. changed = True <TAB> <TAB> <TAB> restore ( original ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> print_warning ( f""{name} was modified by {self.testname}"" ) <TAB> <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> <TAB> f"" Before: {original}\n After: {current} "", <TAB> <TAB> <TAB> <TAB> <TAB> file = sys. stderr, <TAB> <TAB> <TAB> <TAB> <TAB> flush = True, <TAB> <TAB> <TAB> <TAB> ) <TAB> return False",False,not self.quiet and (not self.pgo),self.changed,0.6564649343490601
|
||
|
4571,"def recvExact ( self, size ) : <TAB> buf = b"""" <TAB> s = self. socket <TAB> while len ( buf )!= size : <TAB> <TAB> x = s. recv ( size - len ( buf ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise CobraClosedException ( ""Socket closed in recvExact..."" ) <TAB> <TAB> buf += x <TAB> return buf",False,len(x) == 0,not x,0.6578380465507507
|
||
|
4572,"def perform ( self, node, inp, out_ ) : <TAB> x, i = inp <TAB> ( out, ) = out_ <TAB> <TAB> if out [ 0 ] is not None and out [ 0 ]. shape == ( len ( i ), ) + x. shape [ 1 : ] : <TAB> <TAB> o = out [ 0 ] <TAB> else : <TAB> <TAB> o = None <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if i. dtype!= np. intp : <TAB> <TAB> i_ = theano. _asarray ( i, dtype = np. intp ) <TAB> <TAB> if not np. can_cast ( i. dtype, np. intp ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise IndexError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""index contains values that are bigger "" <TAB> <TAB> <TAB> <TAB> <TAB> ""than the maximum array size on this system."", <TAB> <TAB> <TAB> <TAB> <TAB> i, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> i = i_ <TAB> out [ 0 ] = x. take ( i, axis = 0, out = o )",False,np.any(i != i_),i_ < TAB > -1,0.6542114019393921
|
||
|
4573,"def fake_db_group ( ** updates ) : <TAB> db_group = { <TAB> <TAB> ""id"" : fake. GROUP_ID, <TAB> <TAB> ""name"" : ""group-1"", <TAB> <TAB> ""status"" : ""available"", <TAB> <TAB> ""user_id"" : fake. USER_ID, <TAB> <TAB> ""project_id"" : fake. PROJECT_ID, <TAB> <TAB> ""group_type_id"" : fake. GROUP_TYPE_ID, <TAB> <TAB> ""group_snapshot_id"" : None, <TAB> <TAB> ""source_group_id"" : None, <TAB> } <TAB> for name, field in objects. Group. fields. items ( ) : <TAB> <TAB> if name in db_group : <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> db_group [ name ] = None <TAB> <TAB> elif field. default!= fields. UnspecifiedDefault : <TAB> <TAB> <TAB> db_group [ name ] = field. default <TAB> <TAB> else : <TAB> <TAB> <TAB> raise Exception ( ""fake_db_group needs help with %s."" % name ) <TAB> if updates : <TAB> <TAB> db_group. update ( updates ) <TAB> return db_group",False,field.nullable,field.default == fields.UnspecifiedDefault,0.65875244140625
|
||
|
4574,"def extract_conditions ( self, quals ) : <TAB> """"""Build an imap search criteria string from a list of quals"""""" <TAB> conditions = [ ] <TAB> for qual in quals : <TAB> <TAB> <TAB> <TAB> if qual. list_any_or_all == ANY : <TAB> <TAB> <TAB> values = [ <TAB> <TAB> <TAB> <TAB> ""(%s)"" % self. _make_condition ( qual. field_name, qual. operator [ 0 ], value ) <TAB> <TAB> <TAB> <TAB> for value in qual. value <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> conditions. append ( make_or ( values ) ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> conditions. extend ( <TAB> <TAB> <TAB> <TAB> [ <TAB> <TAB> <TAB> <TAB> <TAB> self. _make_condition ( qual. field_name, qual. operator [ 0 ], value ) <TAB> <TAB> <TAB> <TAB> <TAB> for value in qual. value <TAB> <TAB> <TAB> <TAB> ] <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> conditions. append ( <TAB> <TAB> <TAB> <TAB> self. _make_condition ( qual. field_name, qual. operator, qual. value ) <TAB> <TAB> <TAB> ) <TAB> conditions = [ x for x in conditions if x not in ( None, ""()"" ) ] <TAB> return conditions",False,qual.list_any_or_all == ALL,qual.list_any_or_all == EMPTY,0.6547175645828247
|
||
|
4575,"def intersect_face ( pt ) : <TAB> <TAB> nonlocal vis_faces2D <TAB> for f, vs in vis_faces2D : <TAB> <TAB> v0 = vs [ 0 ] <TAB> <TAB> for v1, v2 in iter_pairs ( vs [ 1 : ], False ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return f <TAB> return None",False,"intersect_point_tri_2d(pt, v0, v1, v2)",v0 == v2 and pt.contains(v1),0.6490888595581055
|
||
|
4576,"def merge_from_file ( metrics_file ) : <TAB> """"""Merge metrics recorded in another file into the current metrics."""""" <TAB> for metric in load_all ( metrics_file ) : <TAB> <TAB> existing = _registered_metrics. get ( metric. name ) <TAB> <TAB> if existing is None : <TAB> <TAB> <TAB> _validate_metric_name ( metric. name ) <TAB> <TAB> <TAB> _registered_metrics [ metric. name ] = metric <TAB> <TAB> else : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise TypeError ( ""Cannot merge metrics of different types."" ) <TAB> <TAB> <TAB> existing. _merge ( metric )",False,type(metric) != type(existing),"hasattr(existing, 'type') and isinstance(existing.type, types.MultiMetrics)",0.6543618440628052
|
||
|
4577,"def init_weights ( self ) : <TAB> for module in self. modules ( ) : <TAB> <TAB> if isinstance ( module, nn. Conv2d ) : <TAB> <TAB> <TAB> kernel_height, kernel_width = module. kernel_size <TAB> <TAB> <TAB> out_channels = module. out_channels <TAB> <TAB> <TAB> fan_out = kernel_height * kernel_width * out_channels <TAB> <TAB> <TAB> nn. init. normal_ ( module. weight, mean = 0.0, std = math. sqrt ( 2.0 / fan_out ) ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> nn. init. constant_ ( module. bias, 0 ) <TAB> <TAB> elif isinstance ( module, nn. Linear ) : <TAB> <TAB> <TAB> init_range = 1.0 / math. sqrt ( module. out_features ) <TAB> <TAB> <TAB> nn. init. uniform_ ( module. weight, - init_range, init_range ) <TAB> <TAB> elif isinstance ( module, nn. BatchNorm2d ) : <TAB> <TAB> <TAB> nn. init. constant_ ( module. weight, 1 ) <TAB> <TAB> <TAB> nn. init. constant_ ( module. bias, 0 )",False,module.bias is not None,"isinstance(module, nn.Conv2d)",0.6594460010528564
|
||
|
4578,"def _on_queue_feeder_error ( self, e, obj ) : <TAB> if isinstance ( obj, _CallItem ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raised_error = RuntimeError ( <TAB> <TAB> <TAB> <TAB> ""The task could not be sent to the workers as it is too "" <TAB> <TAB> <TAB> <TAB> ""large for `send_bytes`."" <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raised_error = PicklingError ( <TAB> <TAB> <TAB> <TAB> ""Could not pickle the task to send it to the workers."" <TAB> <TAB> <TAB> ) <TAB> <TAB> tb = traceback. format_exception ( type ( e ), e, getattr ( e, ""__traceback__"", None ) ) <TAB> <TAB> raised_error = set_cause ( raised_error, _RemoteTraceback ( """". join ( tb ) ) ) <TAB> <TAB> work_item = self. pending_work_items. pop ( obj. work_id, None ) <TAB> <TAB> self. running_work_items. remove ( obj. work_id ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if work_item is not None : <TAB> <TAB> <TAB> work_item. future. set_exception ( raised_error ) <TAB> <TAB> <TAB> del work_item <TAB> <TAB> self. thread_wakeup. wakeup ( ) <TAB> else : <TAB> <TAB> super ( _SafeQueue, self ). _on_queue_feeder_error ( e, obj )",False,"isinstance(e, struct.error)",len(self.pending_work_items) > 10,0.6490083932876587
|
||
|
4579,"def fetch_last_known_offsets ( self, partitions = None ) : <TAB> if self. group is None : <TAB> <TAB> raise ValueError ( ""SimpleClient.group must not be None"" ) <TAB> if partitions is None : <TAB> <TAB> partitions = self. client. get_partition_ids_for_topic ( self. topic ) <TAB> responses = self. client. send_offset_fetch_request ( <TAB> <TAB> self. group, <TAB> <TAB> [ OffsetFetchRequestPayload ( self. topic, p ) for p in partitions ], <TAB> <TAB> fail_on_error = False, <TAB> ) <TAB> for resp in responses : <TAB> <TAB> try : <TAB> <TAB> <TAB> check_error ( resp ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> except UnknownTopicOrPartitionError : <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. offsets [ resp. partition ] = 0 <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> self. offsets [ resp. partition ] = resp. offset",False,resp.offset == -1,fail_on_error,0.6565616130828857
|
||
|
4580,"def update ( self, E = None, ** F ) : <TAB> if E : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for k in E : <TAB> <TAB> <TAB> <TAB> self [ k ] = E [ k ] <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for ( k, v ) in E : <TAB> <TAB> <TAB> <TAB> self [ k ] = v <TAB> <TAB> for k in F : <TAB> <TAB> self [ k ] = F [ k ]",False,"hasattr(E, 'keys')",len(F) == 0,0.6543835401535034
|
||
|
4581,"def mirror ( url, response ) : <TAB> if response!= ""dummy"" : <TAB> <TAB> clean_url = url. replace ( ""http://"", """" ). replace ( ""https://"", """" ). rstrip ( ""/"" ) <TAB> <TAB> parts = clean_url. split ( ""?"" ) [ 0 ]. split ( ""/"" ) <TAB> <TAB> root = parts [ 0 ] <TAB> <TAB> webpage = parts [ - 1 ] <TAB> <TAB> parts. remove ( root ) <TAB> <TAB> try : <TAB> <TAB> <TAB> parts. remove ( webpage ) <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> pass <TAB> <TAB> prefix = root + ""_mirror"" <TAB> <TAB> try : <TAB> <TAB> <TAB> os. mkdir ( prefix ) <TAB> <TAB> except OSError : <TAB> <TAB> <TAB> pass <TAB> <TAB> suffix = """" <TAB> <TAB> if parts : <TAB> <TAB> <TAB> for directory in parts : <TAB> <TAB> <TAB> <TAB> suffix += directory + ""/"" <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> os. mkdir ( prefix + ""/"" + suffix ) <TAB> <TAB> <TAB> <TAB> except OSError : <TAB> <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> path = prefix + ""/"" + suffix <TAB> <TAB> trail = """" <TAB> <TAB> if ""."" not in webpage : <TAB> <TAB> <TAB> trail += "".html"" <TAB> <TAB> if webpage == root : <TAB> <TAB> <TAB> name = ""index.html"" <TAB> <TAB> else : <TAB> <TAB> <TAB> name = webpage <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> trail += ""?"" + url. split ( ""?"" ) [ 1 ] <TAB> <TAB> with open ( path + name + trail, ""w+"" ) as out_file : <TAB> <TAB> <TAB> out_file. write ( response. encode ( ""utf-8"" ) )",False,len(url.split('?')) > 1,url[-1],0.6556983590126038
|
||
|
4582,"def add_constraint ( self, cn, strength = None, weight = None ) : <TAB> if strength or weight : <TAB> <TAB> cn = cn. clone ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> cn. strength = strength <TAB> <TAB> if weight : <TAB> <TAB> <TAB> cn. weight = weight <TAB> <TAB> expr, eplus, eminus, prev_edit_constant = self. new_expression ( cn ) <TAB> if not self. try_adding_directly ( expr ) : <TAB> <TAB> self. add_with_artificial_variable ( expr ) <TAB> self. needs_solving = True <TAB> if cn. is_edit_constraint : <TAB> <TAB> i = len ( self. edit_var_map ) <TAB> <TAB> self. edit_var_map [ cn. variable ] = EditInfo ( <TAB> <TAB> <TAB> cn, eplus, eminus, prev_edit_constant, i <TAB> <TAB> ) <TAB> if self. auto_solve : <TAB> <TAB> self. optimize ( self. objective ) <TAB> <TAB> self. set_external_variables ( ) <TAB> return cn",True,strength,strength,0.7020074129104614
|
||
|
4583,"def wrapped ( self, request ) : <TAB> try : <TAB> <TAB> return self. _finished <TAB> except AttributeError : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if not request. session. shouldfail and not request. session. shouldstop : <TAB> <TAB> <TAB> <TAB> log. debug ( <TAB> <TAB> <TAB> <TAB> <TAB> ""%s is still going to be used, not terminating it. "" <TAB> <TAB> <TAB> <TAB> <TAB> ""Still in use on:\n%s"", <TAB> <TAB> <TAB> <TAB> <TAB> self, <TAB> <TAB> <TAB> <TAB> <TAB> pprint. pformat ( list ( self. node_ids ) ), <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> log. debug ( ""Finish called on %s"", self ) <TAB> <TAB> try : <TAB> <TAB> <TAB> return func ( request ) <TAB> <TAB> finally : <TAB> <TAB> <TAB> self. _finished = True",False,self.node_ids,self._finished,0.6619959473609924
|
||
|
4584,"def update ( self, pbar ) : <TAB> context = { } <TAB> for name, ( key, transform ) in self. mapping. items ( ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> value = getattr ( pbar, key ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> context [ name ] = value <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> context [ name ] = transform ( value ) <TAB> <TAB> except : <TAB> <TAB> <TAB> pass <TAB> return self. format % context",True,transform is None,transform is None,0.6706781387329102
|
||
|
4585,"def pytest_collection_modifyitems ( items ) : <TAB> for item in items : <TAB> <TAB> if item. nodeid. startswith ( ""tests/params"" ) : <TAB> <TAB> <TAB> if ""stage"" not in item. keywords : <TAB> <TAB> <TAB> <TAB> item. add_marker ( pytest. mark. stage ( ""unit"" ) ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> item. add_marker ( pytest. mark. init ( rng_seed = 123 ) )",False,'init' not in item.keywords,'rng' not in item.keywords,0.6545066237449646
|
||
|
4586,"def _compile_dialect ( self, execute_observed ) : <TAB> if self. dialect == ""default"" : <TAB> <TAB> return DefaultDialect ( ) <TAB> else : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> params = { ""implicit_returning"" : True } <TAB> <TAB> else : <TAB> <TAB> <TAB> params = { } <TAB> <TAB> return url. URL ( self. dialect ). get_dialect ( ) ( ** params )",False,self.dialect == 'postgresql',execute_observed,0.6592318415641785
|
||
|
4587,"def backward_impl ( self, inputs, outputs, prop_down, accum ) : <TAB> <TAB> <TAB> <TAB> axis = self. forward_func. info. args [ ""axis"" ] <TAB> <TAB> y0 = inputs [ 0 ]. data <TAB> dz = inputs [ 2 ]. data <TAB> <TAB> dy0 = outputs [ 0 ]. data <TAB> <TAB> g_y0 = inputs [ 0 ]. grad <TAB> g_dz = inputs [ 2 ]. grad <TAB> <TAB> g_dy0 = outputs [ 0 ]. grad <TAB> <TAB> if prop_down [ 0 ] : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> g_y0 += g_dy0 * dz * F. pow_scalar ( y0, - 2.0 ) <TAB> <TAB> else : <TAB> <TAB> <TAB> g_y0. copy_from ( g_dy0 * dz * F. pow_scalar ( y0, - 2.0 ) ) <TAB> if prop_down [ 2 ] : <TAB> <TAB> if accum [ 2 ] : <TAB> <TAB> <TAB> g_dz -= F. sum ( g_dy0 * F. pow_scalar ( y0, - 1.0 ), axis, True ) <TAB> <TAB> else : <TAB> <TAB> <TAB> g_dz. copy_from ( - F. sum ( g_dy0 * F. pow_scalar ( y0, - 1.0 ), axis, True ) )",True,accum[0],accum[0],0.6588469743728638
|
||
|
4588,"def _on_set_new_release_check ( self, key, value ) : <TAB> if value : <TAB> <TAB> log. debug ( ""Checking for new release.."" ) <TAB> <TAB> threading. Thread ( target = self. core. get_new_release ). start ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. new_release_timer. stop ( ) <TAB> <TAB> <TAB> <TAB> self. new_release_timer = LoopingCall ( <TAB> <TAB> <TAB> self. _on_set_new_release_check, ""new_release_check"", True <TAB> <TAB> ) <TAB> <TAB> self. new_release_timer. start ( 72 * 60 * 60, False ) <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. new_release_timer. stop ( )",False,self.new_release_timer and self.new_release_timer.running,key in ['TAB > or key in ['TAB > or value,0.6491657495498657
|
||
|
4589,"def add ( self, path ) : <TAB> with self. get_lock ( path ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. entries [ path ] = { } <TAB> <TAB> <TAB> self. entries [ path ] [ ""lock"" ] = self. new_locks [ path ] <TAB> <TAB> <TAB> del self. new_locks [ path ] <TAB> <TAB> <TAB> self. lru. append ( path )",False,not path in self.entries,path not in self.entries,0.6666389107704163
|
||
|
4590,"def _read_ready ( self ) : <TAB> try : <TAB> <TAB> data = self. _sock. recv ( self. max_size ) <TAB> except ( BlockingIOError, InterruptedError ) : <TAB> <TAB> pass <TAB> except Exception as exc : <TAB> <TAB> self. _fatal_error ( exc, ""Fatal read error on socket transport"" ) <TAB> else : <TAB> <TAB> if data : <TAB> <TAB> <TAB> self. _protocol. data_received ( data ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if self. _loop. get_debug ( ) : <TAB> <TAB> <TAB> <TAB> logger. debug ( ""%r received EOF"", self ) <TAB> <TAB> <TAB> keep_open = self. _protocol. eof_received ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _loop. remove_reader ( self. _sock_fd ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. close ( )",True,keep_open,keep_open,0.6637880802154541
|
||
|
4591,"def send_samples ( self ) : <TAB> if self. sampler : <TAB> <TAB> samples = self. sampler. samples <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. send ( self. master, UpdateSamples ( self. client_id, samples ) ) <TAB> <TAB> return samples <TAB> return None",False,len(samples) > 0,self.master,0.6631576418876648
|
||
|
4592,"def encode_string ( self, encoding ) : <TAB> """"""Encode a buffered response body."""""" <TAB> if encoding in self. attempted_charsets : <TAB> <TAB> return False <TAB> self. attempted_charsets. add ( encoding ) <TAB> body = [ ] <TAB> for chunk in self. body : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> chunk = chunk. encode ( encoding, self. errors ) <TAB> <TAB> <TAB> except ( LookupError, UnicodeError ) : <TAB> <TAB> <TAB> <TAB> return False <TAB> <TAB> body. append ( chunk ) <TAB> self. body = body <TAB> return True",False,"isinstance(chunk, six.text_type)","hasattr(chunk, 'encode')",0.6466336846351624
|
||
|
4593,"def repair_item ( href, item, seen_uids, repair_unsafe_uid ) : <TAB> if item. parsed is None : <TAB> <TAB> raise IrreparableItem ( ) <TAB> new_item = item <TAB> if not item. uid : <TAB> <TAB> logger. warning ( ""No UID, assigning random UID."" ) <TAB> <TAB> new_item = item. with_uid ( generate_href ( ) ) <TAB> elif item. uid in seen_uids : <TAB> <TAB> logger. warning ( ""Duplicate UID, assigning random UID."" ) <TAB> <TAB> new_item = item. with_uid ( generate_href ( ) ) <TAB> elif not href_safe ( item. uid ) or not href_safe ( basename ( href ) ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> logger. warning ( <TAB> <TAB> <TAB> <TAB> ""UID may cause problems, add "" ""--repair-unsafe-uid to repair."" <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> logger. warning ( ""UID or href is unsafe, assigning random UID."" ) <TAB> <TAB> <TAB> new_item = item. with_uid ( generate_href ( ) ) <TAB> if not new_item. uid : <TAB> <TAB> raise IrreparableItem ( ) <TAB> return new_item",False,not repair_unsafe_uid,repair_unsafe_uid,0.6574409604072571
|
||
|
4594,"def local_mul_s_d ( node ) : <TAB> if node. op == sparse. mul_s_d : <TAB> <TAB> x, y = node. inputs <TAB> <TAB> x_is_sparse_variable = _is_sparse_variable ( x ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> svar = x <TAB> <TAB> <TAB> dvar = y <TAB> <TAB> else : <TAB> <TAB> <TAB> svar = y <TAB> <TAB> <TAB> dvar = x <TAB> <TAB> if dvar. type. ndim!= 2 : <TAB> <TAB> <TAB> return False <TAB> <TAB> if svar. type. format == ""csc"" : <TAB> <TAB> <TAB> CSx = sparse. CSC <TAB> <TAB> <TAB> mul_s_d_csx = mul_s_d_csc <TAB> <TAB> elif svar. type. format == ""csr"" : <TAB> <TAB> <TAB> CSx = sparse. CSR <TAB> <TAB> <TAB> mul_s_d_csx = mul_s_d_csr <TAB> <TAB> else : <TAB> <TAB> <TAB> raise NotImplementedError <TAB> <TAB> if x. dtype!= y. dtype : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> c_data = mul_s_d_csx ( <TAB> <TAB> <TAB> sparse. csm_data ( svar ), <TAB> <TAB> <TAB> sparse. csm_indices ( svar ), <TAB> <TAB> <TAB> sparse. csm_indptr ( svar ), <TAB> <TAB> <TAB> dvar, <TAB> <TAB> ) <TAB> <TAB> return [ <TAB> <TAB> <TAB> CSx ( <TAB> <TAB> <TAB> <TAB> c_data, <TAB> <TAB> <TAB> <TAB> sparse. csm_indices ( svar ), <TAB> <TAB> <TAB> <TAB> sparse. csm_indptr (",True,x_is_sparse_variable,x_is_sparse_variable,0.6508723497390747
|
||
|
4595,"def initialize ( self ) : <TAB> self. session = Session ( ) <TAB> self. session. headers [ ""User-Agent"" ] = ""Subliminal/{}"". format ( __version__ ) <TAB> <TAB> if self. username is not None and self. password is not None : <TAB> <TAB> logger. info ( ""Logging in"" ) <TAB> <TAB> params = { <TAB> <TAB> <TAB> ""username"" : self. username, <TAB> <TAB> <TAB> ""password"" : self. password, <TAB> <TAB> <TAB> ""apikey"" : self. apikey, <TAB> <TAB> } <TAB> <TAB> r = self. session. get ( self. server_url + ""users/login"", params = params, timeout = 10 ) <TAB> <TAB> root = etree. fromstring ( r. content ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise AuthenticationError ( root. find ( ""error/message"" ). text ) <TAB> <TAB> self. auth_code = root. find ( ""data/user/authcode"" ). text <TAB> <TAB> data = { <TAB> <TAB> <TAB> ""username"" : self. username, <TAB> <TAB> <TAB> ""passwd"" : self. password, <TAB> <TAB> <TAB> ""remember"" : ""yes"", <TAB> <TAB> <TAB> ""option"" : ""com_user"", <TAB> <TAB> <TAB> ""task"" : ""login"", <TAB> <TAB> <TAB> ""silent"" : ""true"", <TAB> <TAB> } <TAB> <TAB> r = self. session. post ( <TAB> <TAB> <TAB> ""http://www.italiansubs.net/index.php"", data = data, timeout = 30 <TAB> <TAB> ) <TAB> <TAB> r. raise_for_status ( ) <TAB> <TAB> self. logged_in = True",False,root.find('status').text == 'fail',root.find('data/user/login') is None,0.6484965085983276
|
||
|
4596,"def OnEndDrag ( self, event ) : <TAB> self. StopDragging ( ) <TAB> dropTarget = event. GetItem ( ) <TAB> if not dropTarget : <TAB> <TAB> dropTarget = self. GetRootItem ( ) <TAB> if self. IsValidDropTarget ( dropTarget ) : <TAB> <TAB> self. UnselectAll ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. SelectItem ( dropTarget ) <TAB> <TAB> self. OnDrop ( dropTarget, self. _dragItem )",False,dropTarget != self.GetRootItem(),self.IsValidDropTarget(dropTarget),0.6531848907470703
|
||
|
4597,"def get_min_vertical_scroll ( ) -> int : <TAB> <TAB> <TAB> used_height = 0 <TAB> prev_lineno = ui_content. cursor_position. y <TAB> for lineno in range ( ui_content. cursor_position. y, - 1, - 1 ) : <TAB> <TAB> used_height += get_line_height ( lineno ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return prev_lineno <TAB> <TAB> else : <TAB> <TAB> <TAB> prev_lineno = lineno <TAB> return 0",False,used_height > height - scroll_offsets_bottom,used_height == 0,0.6475968360900879
|
||
|
4598,"def handle_replace ( self, request, fileobj ) : <TAB> """"""Replace file content with uploaded one."""""" <TAB> filecopy = fileobj. read ( ) <TAB> fileobj. close ( ) <TAB> fileobj = BytesIOMode ( fileobj. name, filecopy ) <TAB> with self. component. repository. lock : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. component. commit_pending ( ""replace file"", request. user ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. commit_pending ( ""replace file"", request. user ) <TAB> <TAB> <TAB> <TAB> store2 = self. load_store ( fileobj ) <TAB> <TAB> store2. check_valid ( ) <TAB> <TAB> <TAB> <TAB> self. store. save_atomic ( <TAB> <TAB> <TAB> self. store. storefile, lambda handle : handle. write ( filecopy ) <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> previous_revision = ( self. component. repository. last_revision, ) <TAB> <TAB> if self. git_commit ( <TAB> <TAB> <TAB> request. user, request. user. get_author_name ( ), store_hash = False <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. drop_store_cache ( ) <TAB> <TAB> <TAB> self. handle_store_change ( <TAB> <TAB> <TAB> <TAB> request, <TAB> <TAB> <TAB> <TAB> request. user, <TAB> <TAB> <TAB> <TAB> previous_revision, <TAB> <TAB> <TAB> <TAB> change = Change. ACTION_REPLACE_UPLOAD, <TAB> <TAB> <TAB> ) <TAB> return ( 0, 0, self. unit_set. count ( ), len ( list ( store2. content_units ) ) )",False,self.is_source,self.component.repository.last_revision > 0,0.6528895497322083
|
||
|
4599,"def decode ( self, text : str ) -> typing. List [ str ] : <TAB> lines = [ ] <TAB> if text and self. buffer and self. buffer [ - 1 ] == ""\r"" : <TAB> <TAB> if text. startswith ( ""\n"" ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> lines. append ( self. buffer [ : - 1 ] + ""\n"" ) <TAB> <TAB> <TAB> self. buffer = """" <TAB> <TAB> <TAB> text = text [ 1 : ] <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> lines. append ( self. buffer [ : - 1 ] + ""\n"" ) <TAB> <TAB> <TAB> self. buffer = """" <TAB> while text : <TAB> <TAB> num_chars = len ( text ) <TAB> <TAB> for idx in range ( num_chars ) : <TAB> <TAB> <TAB> char = text [ idx ] <TAB> <TAB> <TAB> next_char = None if idx + 1 == num_chars else text [ idx + 1 ] <TAB> <TAB> <TAB> if char == ""\n"" : <TAB> <TAB> <TAB> <TAB> lines. append ( self. buffer + text [ : idx + 1 ] ) <TAB> <TAB> <TAB> <TAB> self. buffer = """" <TAB> <TAB> <TAB> <TAB> text = text [ idx + 1 : ] <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> lines. append ( self. buffer + text [ : idx ] + ""\n"" ) <TAB> <TAB> <TAB> <TAB> self. buffer = """" <TAB> <TAB> <TAB> <TAB> text = text [ idx + 2 : ] <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> elif char == ""\r"" and next_char is not None : <TAB> <TAB> <TAB> <TAB> lines. append ( self",False,char == '\r' and next_char == '\n',char == '\r',0.6518829464912415
|
||
|
4600,"def delete ( self ) : <TAB> from weblate. trans. models import Change, Suggestion, Vote <TAB> fast_deletes = [ ] <TAB> for item in self. fast_deletes : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> fast_deletes. append ( Vote. objects. filter ( suggestion__in = item ) ) <TAB> <TAB> <TAB> fast_deletes. append ( Change. objects. filter ( suggestion__in = item ) ) <TAB> <TAB> fast_deletes. append ( item ) <TAB> self. fast_deletes = fast_deletes <TAB> return super ( ). delete ( )",False,item.model is Suggestion,item,0.6620023250579834
|
||
|
4601,"def post ( self ) : <TAB> """"""Handle modifying actions and redirect to a GET page."""""" <TAB> if self. request. get ( ""action:flush_memcache"" ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> message = ""Cache flushed, all keys dropped."" <TAB> <TAB> else : <TAB> <TAB> <TAB> message = ""Flushing the cache failed. Please try again."" <TAB> <TAB> self. redirect ( <TAB> <TAB> <TAB> self. _construct_url ( <TAB> <TAB> <TAB> <TAB> remove = [ ""action:flush_memcache"" ], add = { ""message"" : message } <TAB> <TAB> <TAB> ) <TAB> <TAB> ) <TAB> elif self. request. get ( ""action:delete_entities"" ) : <TAB> <TAB> entity_keys = self. request. params. getall ( ""entity_key"" ) <TAB> <TAB> db. delete ( entity_keys ) <TAB> <TAB> self. redirect ( <TAB> <TAB> <TAB> self. _construct_url ( <TAB> <TAB> <TAB> <TAB> remove = [ ""action:delete_entities"" ], <TAB> <TAB> <TAB> <TAB> add = { ""message"" : ""%d entities deleted"" % len ( entity_keys ) }, <TAB> <TAB> <TAB> ) <TAB> <TAB> ) <TAB> else : <TAB> <TAB> self. error ( 404 )",False,memcache.flush_all(),self.cache_failed,0.6533583402633667
|
||
|
4602,"def main ( ) : <TAB> env_path = os. path. join ( <TAB> <TAB> os. path. dirname ( os. path. realpath ( __file__ ) ), "".."", "".."", ""wr.env"" <TAB> ) <TAB> with open ( env_path, ""r+"" ) as fh : <TAB> <TAB> buff = fh. read ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> print ( ""No Env"" ) <TAB> <TAB> <TAB> return <TAB> <TAB> buff = buff. replace ( ""WEBAGG_HOST"", ""WARCSERVER_HOST"" ) <TAB> <TAB> buff = buff. replace ( ""http://webagg"", ""http://warcserver"" ) <TAB> <TAB> fh. seek ( 0 ) <TAB> <TAB> fh. write ( buff ) <TAB> <TAB> print ( ""Updated wr.env"" )",True,not buff,not buff,0.68404620885849
|
||
|
4603,"def handle ( self, * args : Any, ** options : Any ) -> None : <TAB> num_processes = int ( options [ ""processes"" ] ) <TAB> if num_processes < 1 : <TAB> <TAB> raise CommandError ( ""You must have at least one process."" ) <TAB> subdomain = options [ ""subdomain"" ] <TAB> if options [ ""destroy_rebuild_database"" ] : <TAB> <TAB> print ( ""Rebuilding the database!"" ) <TAB> <TAB> db_name = settings. DATABASES [ ""default"" ] [ ""NAME"" ] <TAB> <TAB> self. do_destroy_and_rebuild_database ( db_name ) <TAB> elif options [ ""import_into_nonempty"" ] : <TAB> <TAB> print ( ""NOTE: The argument 'import_into_nonempty' is now the default behavior."" ) <TAB> check_subdomain_available ( subdomain, from_management_command = True ) <TAB> paths = [ ] <TAB> for path in options [ ""export_paths"" ] : <TAB> <TAB> path = os. path. realpath ( os. path. expanduser ( path ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise CommandError ( f""Directory not found: '{path}'"" ) <TAB> <TAB> if not os. path. isdir ( path ) : <TAB> <TAB> <TAB> raise CommandError ( <TAB> <TAB> <TAB> <TAB> ""Export file should be folder; if it's a "" <TAB> <TAB> <TAB> <TAB> ""tarball, please unpack it first."" <TAB> <TAB> <TAB> ) <TAB> <TAB> paths. append ( path ) <TAB> for path in paths : <TAB> <TAB> print ( f""Processing dump: {path}..."" ) <TAB> <TAB> realm = do_import_realm ( path, subdomain, num_processes ) <TAB> <TAB> print ( ""Checking the system bots."" ) <TAB> <TAB> do_import_system_bots ( realm )",False,not os.path.exists(path),not os.path.isdir(path),0.6469482183456421
|
||
|
4604,"def _read_bytes ( self, num_bytes ) : <TAB> self. _sock. settimeout ( self. _read_timeout ) <TAB> while True : <TAB> <TAB> try : <TAB> <TAB> <TAB> data = self. _rfile. read ( num_bytes ) <TAB> <TAB> <TAB> break <TAB> <TAB> except ( IOError, OSError ) as e : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> self. _force_close ( ) <TAB> <TAB> <TAB> raise err. OperationalError ( <TAB> <TAB> <TAB> <TAB> CR. CR_SERVER_LOST, <TAB> <TAB> <TAB> <TAB> ""Lost connection to MySQL server during query (%s)"" % ( e, ), <TAB> <TAB> <TAB> ) <TAB> <TAB> except BaseException : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _force_close ( ) <TAB> <TAB> <TAB> raise <TAB> if len ( data ) < num_bytes : <TAB> <TAB> self. _force_close ( ) <TAB> <TAB> raise err. OperationalError ( <TAB> <TAB> <TAB> CR. CR_SERVER_LOST, ""Lost connection to MySQL server during query"" <TAB> <TAB> ) <TAB> return data",False,e.errno == errno.EINTR,len(data) < num_bytes,0.6541719436645508
|
||
|
4605,"def set ( self, item, data ) : <TAB> if not type ( item ) is slice : <TAB> <TAB> item = slice ( item, item + len ( data ), None ) <TAB> virt_item = self. item2virtitem ( item ) <TAB> if not virt_item : <TAB> <TAB> return <TAB> off = 0 <TAB> for s, n_item in virt_item : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> i = slice ( off, n_item. stop + off - n_item. start, n_item. step ) <TAB> <TAB> <TAB> data_slice = data. __getitem__ ( i ) <TAB> <TAB> <TAB> s. content. __setitem__ ( n_item, data_slice ) <TAB> <TAB> <TAB> off = i. stop <TAB> <TAB> else : <TAB> <TAB> <TAB> raise ValueError ( ""TODO XXX"" ) <TAB> return",False,"isinstance(s, ProgBits)",n_item.start <= 0 < s.stop,0.6470135450363159
|
||
|
4606,"def _write_source ( self, file = None ) : <TAB> if file is not None : <TAB> <TAB> self. _write_source_to ( file ) <TAB> else : <TAB> <TAB> <TAB> <TAB> f = NativeIO ( ) <TAB> <TAB> self. _write_source_to ( f ) <TAB> <TAB> source_data = f. getvalue ( ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> with open ( self. sourcefilename, ""r"" ) as fp : <TAB> <TAB> <TAB> <TAB> needs_written = not ( fp. read ( ) == source_data ) <TAB> <TAB> else : <TAB> <TAB> <TAB> needs_written = True <TAB> <TAB> <TAB> <TAB> if needs_written : <TAB> <TAB> <TAB> _ensure_dir ( self. sourcefilename ) <TAB> <TAB> <TAB> with open ( self. sourcefilename, ""w"" ) as fp : <TAB> <TAB> <TAB> <TAB> fp. write ( source_data ) <TAB> <TAB> <TAB> <TAB> self. _has_source = True",False,os.path.exists(self.sourcefilename),self.sourcefilename,0.6495925188064575
|
||
|
4607,"def ip_label ( tokeniser, afi, safi ) : <TAB> ipmask = prefix ( tokeniser ) <TAB> nlri = Label ( afi, safi, 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<mask> : <TAB> <TAB> <TAB> break <TAB> <TAB> action = AnnounceLabel. action. get ( command, """" ) <TAB> <TAB> if action == ""attribute-add"" : <TAB> <TAB> <TAB> change. attributes. add ( AnnounceLabel. known [ command ] ( tokeniser ) ) <TAB> <TAB> elif action == ""nlri-set"" : <TAB> <TAB> <TAB> change. nlri. assign ( <TAB> <TAB> <TAB> <TAB> AnnounceLabel. assign [ command ], AnnounceLabel. known [ command ] ( tokeniser ) <TAB> <TAB> <TAB> ) <TAB> <TAB> elif action == ""nexthop-and-attribute"" : <TAB> <TAB> <TAB> nexthop, attribute = AnnounceLabel. known [ command ] ( tokeniser ) <TAB> <TAB> <TAB> change. nlri. nexthop = nexthop <TAB> <TAB> <TAB> change. attributes. add ( attribute ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise ValueError ( 'route: unknown command ""%s""' % command ) <TAB> return [ change ]",False,not command,command == 'delete',0.6864778995513916
|
||
|
4608,"def python_matches ( self, text ) : <TAB> """"""Match attributes or global python names"""""" <TAB> <TAB> if ""."" in text : <TAB> <TAB> try : <TAB> <TAB> <TAB> matches = self. attr_matches ( text ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> if self. omit__names == 1 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> no__name = lambda txt : re. match ( r"".*\.__.*?__"", txt ) is None <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> no__name = ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> lambda txt : re. match ( r""\._.*?"", txt [ txt. rindex ( ""."" ) : ] ) is None <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> matches = filter ( no__name, matches ) <TAB> <TAB> except NameError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> matches = [ ] <TAB> else : <TAB> <TAB> matches = self. global_matches ( text ) <TAB> return matches",False,text.endswith('.') and self.omit__names,len(matches) == 0,0.653357744216919
|
||
|
4609,"def _shadow_mapping_pass ( self, scene, light_node, flags ) : <TAB> light = light_node. light <TAB> <TAB> self. _configure_shadow_mapping_viewport ( light, flags ) <TAB> <TAB> V, P = self. _get_light_cam_matrices ( scene, light_node, flags ) <TAB> <TAB> for node in self. _sorted_mesh_nodes ( scene ) : <TAB> <TAB> mesh = node. mesh <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> for primitive in mesh. primitives : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> program = self. _get_primitive_program ( primitive, flags, ProgramFlags. NONE ) <TAB> <TAB> <TAB> program. _bind ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> program. set_uniform ( ""V"", V ) <TAB> <TAB> <TAB> program. set_uniform ( ""P"", P ) <TAB> <TAB> <TAB> program. set_uniform ( <TAB> <TAB> <TAB> <TAB> ""cam_pos"", scene. get_pose ( scene. main_camera_node ) [ : 3, 3 ] <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _bind_and_draw_primitive ( <TAB> <TAB> <TAB> <TAB> primitive = primitive, <TAB> <TAB> <TAB> <TAB> pose = scene. get_pose ( node ), <TAB> <TAB> <TAB> <TAB> program = program, <TAB> <TAB> <TAB> <TAB> flags = RenderFlags. DEPTH_ONLY, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> self. _reset_active_textures ( ) <TAB> <TAB> if program is not None : <TAB> <TAB> program. _unbind ( ) <TAB> glFlush ( )",False,not mesh.is_visible,mesh.is_empty,0.6562389135360718
|
||
|
4610,"def run ( self ) : <TAB> args = self. _parse_args ( ) <TAB> self. _parse_compose_file ( ) <TAB> podman_path = args. podman_path <TAB> if podman_path!= ""podman"" : <TAB> <TAB> if os. path. isfile ( podman_path ) and os. access ( podman_path, os. X_OK ) : <TAB> <TAB> <TAB> podman_path = os. path. realpath ( podman_path ) <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise IOError ( ""Binary {} has not been found."". format ( podman_path ) ) <TAB> self. podman = Podman ( self, podman_path, args. dry_run ) <TAB> cmd_name = args. command <TAB> cmd = self. commands [ cmd_name ] <TAB> cmd ( self, args )",False,dry_run == False,not os.path.exists(podman_path),0.6627120971679688
|
||
|
4611,"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. req = TFetchResultsReq ( ) <TAB> <TAB> <TAB> <TAB> self. req. 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 ( )",False,fid == 1,fid == TType.START,0.6721687316894531
|
||
|
4612,"def test_decorator_order ( self ) : <TAB> for action, func in api_call_map. items ( ) : <TAB> <TAB> func = getattr ( self. service_connection, func ) <TAB> <TAB> decs = [ func. __name__ ] <TAB> <TAB> while func : <TAB> <TAB> <TAB> i = 0 <TAB> <TAB> <TAB> if not hasattr ( func, ""__closure__"" ) : <TAB> <TAB> <TAB> <TAB> func = getattr ( func, ""__wrapped__"", None ) <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> while i < len ( func. __closure__ ) : <TAB> <TAB> <TAB> <TAB> value = func. __closure__ [ i ]. cell_contents <TAB> <TAB> <TAB> <TAB> if hasattr ( value, ""__call__"" ) : <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. assertTrue ( not decs or decs [ - 1 ] == ""requires"" ) <TAB> <TAB> <TAB> <TAB> <TAB> decs. append ( value. __name__ ) <TAB> <TAB> <TAB> <TAB> i += 1 <TAB> <TAB> <TAB> func = getattr ( func, ""__wrapped__"", None )",False,'requires' == value.__name__,decs,0.6711407899856567
|
||
|
4613,"def _get_name ( key_tuple, annotations ) : <TAB> annotation = None if annotations is None else annotations. get ( key_tuple ) <TAB> CELL_PREFIX = ""<td%s>"" % ( """" if annotation is None else'class=""%s""' % annotation ) <TAB> seq_name = unicode_data. get_emoji_sequence_name ( key_tuple ) <TAB> if seq_name == None : <TAB> <TAB> if key_tuple == ( 0x20E3, ) : <TAB> <TAB> <TAB> seq_name = ""(combining enlosing keycap)"" <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> seq_name = ""(unknown flag PUA codepoint)"" <TAB> <TAB> else : <TAB> <TAB> <TAB> print ( ""no name for %s"" % unicode_data. seq_to_string ( key_tuple ) ) <TAB> <TAB> <TAB> seq_name = ""(oops)"" <TAB> return CELL_PREFIX + seq_name",False,"key_tuple == (1042475,)","key_tuple == (16579,)",0.6547436118125916
|
||
|
4614,"def scrub_data ( data ) : <TAB> if isinstance ( data, dict ) : <TAB> <TAB> for k, v in data. items ( ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> key = k. decode ( ""utf-8"", ""replace"" ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> key = k <TAB> <TAB> <TAB> key = key. lower ( ) <TAB> <TAB> <TAB> data [ k ] = scrub_data ( v ) <TAB> <TAB> <TAB> for blk in KEYS : <TAB> <TAB> <TAB> <TAB> if blk in key : <TAB> <TAB> <TAB> <TAB> <TAB> data [ k ] = MASK <TAB> elif isinstance ( data, list ) : <TAB> <TAB> for i, l in enumerate ( list ( data ) ) : <TAB> <TAB> <TAB> data [ i ] = scrub_data ( l ) <TAB> elif isinstance ( data, str ) : <TAB> <TAB> if ""="" in data : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if ""&"" in data : <TAB> <TAB> <TAB> <TAB> delimiter = ""&"" <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> delimiter = "";"" <TAB> <TAB> <TAB> qd = scrub_data ( <TAB> <TAB> <TAB> <TAB> OrderedDict ( <TAB> <TAB> <TAB> <TAB> <TAB> e. split ( ""="", 1 ) if ""="" in e else ( e, None ) <TAB> <TAB> <TAB> <TAB> <TAB> for e in data. split ( delimiter ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> return delimiter. join ( <TAB> <TAB> <TAB> <TAB> ( k + ""="" + v if v is not None else k ) for k, v in qd. items ( ) <TAB> <TAB> <TAB> )",True,"isinstance(k, bytes)","isinstance(k, bytes)",0.6504049301147461
|
||
|
4615,"def scan_block_scalar_indentation ( self ) : <TAB> <TAB> chunks = [ ] <TAB> max_indent = 0 <TAB> end_mark = self. get_mark ( ) <TAB> while self. peek ( ) in "" \r\n\x85\u2028\u2029"" : <TAB> <TAB> if self. peek ( )!= "" "" : <TAB> <TAB> <TAB> chunks. append ( self. scan_line_break ( ) ) <TAB> <TAB> <TAB> end_mark = self. get_mark ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. forward ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> max_indent = self. column <TAB> return chunks, max_indent, end_mark",True,self.column > max_indent,self.column > max_indent,0.653872549533844
|
||
|
4616,"def _produce ( self ) : <TAB> headers = self. msg. getHeaders ( True ) <TAB> boundary = None <TAB> if self. msg. isMultipart ( ) : <TAB> <TAB> content = headers. get ( ""content-type"" ) <TAB> <TAB> parts = [ x. split ( ""="", 1 ) for x in content. split ( "";"" ) [ 1 : ] ] <TAB> <TAB> parts = { k. lower ( ). strip ( ) : v for ( k, v ) in parts } <TAB> <TAB> boundary = parts. get ( ""boundary"" ) <TAB> <TAB> if boundary is None : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> boundary = ""----={}"". format ( self. _uuid4 ( ). hex ) <TAB> <TAB> <TAB> headers [ ""content-type"" ] += '; boundary=""{}""'. format ( boundary ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> boundary = boundary [ 1 : - 1 ] <TAB> <TAB> boundary = networkString ( boundary ) <TAB> self. write ( _formatHeaders ( headers ) ) <TAB> self. write ( b""\r\n"" ) <TAB> if self. msg. isMultipart ( ) : <TAB> <TAB> for p in subparts ( self. msg ) : <TAB> <TAB> <TAB> self. write ( b""\r\n--"" + boundary + b""\r\n"" ) <TAB> <TAB> <TAB> yield MessageProducer ( p, self. buffer, self. scheduler ). beginProducing ( None ) <TAB> <TAB> self. write ( b""\r\n--"" + boundary + b""--\r\n"" ) <TAB> else : <TAB> <TAB> f = self. msg. getBodyFile ( ) <TAB> <TAB> while True : <TAB> <TAB> <TAB> b = f. read ( self. CHUNK_SIZE ) <TAB> <TAB> <TAB> if b : <TAB> <TAB> <TAB> <TAB> self. buffer. write ( b ) <TAB> <TAB> <TAB> <TAB> yield None <TAB>",False,"boundary.startswith('""') and boundary.endswith('""')",len(boundary) > 0,0.646588921546936
|
||
|
4617,def _get_directory_size_in_bytes ( directory ) : <TAB> total = 0 <TAB> try : <TAB> <TAB> for entry in os. scandir ( directory ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> total += entry. stat ( ). st_size <TAB> <TAB> <TAB> elif entry. is_dir ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> total += _get_directory_size_in_bytes ( entry. path ) <TAB> except NotADirectoryError : <TAB> <TAB> <TAB> <TAB> return os. path. getsize ( directory ) <TAB> except PermissionError : <TAB> <TAB> <TAB> <TAB> return 0 <TAB> return total,True,entry.is_file(),entry.is_file(),0.6555038094520569
|
||
|
4618,"def on_event ( self, c, button, data ) : <TAB> if self. rvGestureGrab. get_reveal_child ( ) : <TAB> <TAB> if button == ""A"" and data [ 0 ] == 0 : <TAB> <TAB> <TAB> self. use ( ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> self. start_over ( )",False,button == 'Y' and data[0] == 0,button == 'C' and data[0] == 1,0.6543787717819214
|
||
|
4619,"def _fc_layer ( self, sess, bottom, name, trainable = True, relu = True ) : <TAB> with tf. variable_scope ( name ) as scope : <TAB> <TAB> shape = bottom. get_shape ( ). as_list ( ) <TAB> <TAB> dim = 1 <TAB> <TAB> for d in shape [ 1 : ] : <TAB> <TAB> <TAB> dim *= d <TAB> <TAB> x = tf. reshape ( bottom, [ - 1, dim ] ) <TAB> <TAB> weight = self. _get_fc_weight ( sess, name, trainable = trainable ) <TAB> <TAB> bias = self. _get_bias ( sess, name, trainable = trainable ) <TAB> <TAB> fc = tf. nn. bias_add ( tf. matmul ( x, weight ), bias ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> fc = tf. nn. relu ( fc ) <TAB> <TAB> return fc",True,relu,relu,0.6798250675201416
|
||
|
4620,"def terminate_subprocess ( proc, timeout = 0.1, log = None ) : <TAB> if proc. poll ( ) is None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> log. info ( ""Sending SIGTERM to %r"", proc ) <TAB> <TAB> proc. terminate ( ) <TAB> <TAB> timeout_time = time. time ( ) + timeout <TAB> <TAB> while proc. poll ( ) is None and time. time ( ) < timeout_time : <TAB> <TAB> <TAB> time. sleep ( 0.02 ) <TAB> <TAB> if proc. poll ( ) is None : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> log. info ( ""Sending SIGKILL to %r"", proc ) <TAB> <TAB> <TAB> proc. kill ( ) <TAB> return proc. returncode",True,log,log,0.6794155240058899
|
||
|
4621,"def bounds_check ( cls, el1, el2, msg = None ) : <TAB> lbrt1 = el1. bounds. lbrt ( ) <TAB> lbrt2 = el2. bounds. lbrt ( ) <TAB> try : <TAB> <TAB> for v1, v2 in zip ( lbrt1, lbrt2 ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> v1 = dt_to_int ( v1 ) <TAB> <TAB> <TAB> if isinstance ( v2, datetime_types ) : <TAB> <TAB> <TAB> <TAB> v2 = dt_to_int ( v2 ) <TAB> <TAB> <TAB> cls. assert_array_almost_equal_fn ( v1, v2 ) <TAB> except AssertionError : <TAB> <TAB> raise cls. failureException ( <TAB> <TAB> <TAB> ""BoundingBoxes are mismatched: %s!= %s."" <TAB> <TAB> <TAB> % ( el1. bounds. lbrt ( ), el2. bounds. lbrt ( ) ) <TAB> <TAB> )",True,"isinstance(v1, datetime_types)","isinstance(v1, datetime_types)",0.6481517553329468
|
||
|
4622,"def _init_components ( self, mode = ""train"", version = 1, ** kwargs ) : <TAB> if not self. dsl : <TAB> <TAB> raise DSLNotExistError ( """" ) <TAB> components = self. dsl. get ( ""components"" ) <TAB> if components is None : <TAB> <TAB> raise ComponentFieldNotExistError ( ) <TAB> for name in components : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ModuleFieldNotExistError ( component = name ) <TAB> <TAB> module = components [ name ] [ ""module"" ] <TAB> <TAB> new_component = Component ( ) <TAB> <TAB> new_component. set_name ( name ) <TAB> <TAB> new_component. set_module ( module ) <TAB> <TAB> self. component_name_index [ name ] = len ( self. component_name_index ) <TAB> <TAB> self. components. append ( new_component ) <TAB> if version == 2 or mode == ""train"" : <TAB> <TAB> self. _check_component_valid_names ( )",False,'module' not in components[name],name not in self.components,0.6564379334449768
|
||
|
4623,"def ant_map ( m ) : <TAB> tmp = ""rows %s\ncols %s\n"" % ( len ( m ), len ( m [ 0 ] ) ) <TAB> players = { } <TAB> for row in m : <TAB> <TAB> tmp += ""m "" <TAB> <TAB> for col in row : <TAB> <TAB> <TAB> if col == LAND : <TAB> <TAB> <TAB> <TAB> tmp += ""."" <TAB> <TAB> <TAB> elif col == BARRIER : <TAB> <TAB> <TAB> <TAB> tmp += ""%"" <TAB> <TAB> <TAB> elif col == FOOD : <TAB> <TAB> <TAB> <TAB> tmp += ""*"" <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> tmp += ""?"" <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> players [ col ] = True <TAB> <TAB> <TAB> <TAB> tmp += chr ( col + 97 ) <TAB> <TAB> tmp += ""\n"" <TAB> tmp = ( ""players %s\n"" % len ( players ) ) + tmp <TAB> return tmp",False,col == UNSEEN,col == PLAYERS,0.6728885769844055
|
||
|
4624,"def apply_offers ( self, basket, offers ) : <TAB> applications = OfferApplications ( ) <TAB> for offer in offers : <TAB> <TAB> num_applications = 0 <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> while num_applications < offer. get_max_applications ( basket. owner ) : <TAB> <TAB> <TAB> result = offer. apply_benefit ( basket ) <TAB> <TAB> <TAB> num_applications += 1 <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> applications. add ( offer, result ) <TAB> <TAB> <TAB> if result. is_final : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> basket. offer_applications = applications",False,not result.is_successful,result.has_application,0.6553521156311035
|
||
|
4625,"def testIndexListToLabelsMissedPoint ( self ) : <TAB> clusters = [ [ 0, 1, 2, 3 ], [ 4, 5, 6 ] ] <TAB> data = [ <TAB> <TAB> [ 5.1, 5.2 ], <TAB> <TAB> [ 5.2, 5.1 ], <TAB> <TAB> [ 5.4, 5.2 ], <TAB> <TAB> [ 5.1, 5.0 ], <TAB> <TAB> [ 8.1, 8.0 ], <TAB> <TAB> [ 8.4, 8.2 ], <TAB> <TAB> [ 8.3, 8.4 ], <TAB> <TAB> [ 8.5, 8.5 ], <TAB> ] <TAB> encoder = cluster_encoder ( <TAB> <TAB> type_encoding. CLUSTER_INDEX_LIST_SEPARATION, clusters, data <TAB> ) <TAB> encoder. set_encoding ( type_encoding. CLUSTER_INDEX_LABELING ) <TAB> expected = [ 0, 0, 0, 0, 1, 1, 1, float ( ""NaN"" ) ] <TAB> actual = encoder. get_clusters ( ) <TAB> self. assertEqual ( len ( expected ), len ( actual ) ) <TAB> for i in range ( len ( expected ) ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. assertTrue ( math. isnan ( actual [ i ] ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. assertEqual ( expected [ i ], actual [ i ] )",False,math.isnan(expected[i]) is True,"isinstance(actual[i], float)",0.6509243249893188
|
||
|
4626,"def _update_handler ( self, event : Event ) : <TAB> if self. payload_off and event. data [ ""name"" ] == self. payload_off : <TAB> <TAB> if self. _unsub_turn_off : <TAB> <TAB> <TAB> self. _unsub_turn_off ( ) <TAB> <TAB> if self. _is_on : <TAB> <TAB> <TAB> self. _is_on = False <TAB> <TAB> <TAB> self. schedule_update_ha_state ( ) <TAB> elif event. data [ ""name"" ] == self. trigger : <TAB> <TAB> if self. _unsub_turn_off : <TAB> <TAB> <TAB> self. _unsub_turn_off ( ) <TAB> <TAB> if self. timeout : <TAB> <TAB> <TAB> self. _unsub_turn_off = async_call_later ( <TAB> <TAB> <TAB> <TAB> self. hass, self. timeout, self. _turn_off <TAB> <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _is_on = True <TAB> <TAB> <TAB> self. schedule_update_ha_state ( )",False,not self._is_on,self._is_on,0.6595999002456665
|
||
|
4627,"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. STRUCT : <TAB> <TAB> <TAB> <TAB> self. sessionHandle = TSessionHandle ( ) <TAB> <TAB> <TAB> <TAB> self. sessionHandle. read ( iprot ) <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. catalogName = 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. schemaName = iprot. readString ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif fid == 4 : <TAB> <TAB> <TAB> if ftype == TType. STRING : <TAB> <TAB> <TAB> <TAB> self. functionName = iprot. readString ( ) <TAB> <TAB",True,fid == 2,fid == 2,0.6788910627365112
|
||
|
4628,"def find_scintilla_constants ( f ) : <TAB> lexers = [ ] <TAB> states = [ ] <TAB> for name in f. order : <TAB> <TAB> v = f. features [ name ] <TAB> <TAB> if v [ ""Category"" ]!= ""Deprecated"" : <TAB> <TAB> <TAB> if v [ ""FeatureType"" ] == ""val"" : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> states. append ( ( name, v [ ""Value"" ] ) ) <TAB> <TAB> <TAB> <TAB> elif name. startswith ( ""SCLEX_"" ) : <TAB> <TAB> <TAB> <TAB> <TAB> lexers. append ( ( name, v [ ""Value"" ] ) ) <TAB> return ( lexers, states )",False,name.startswith('SCE_'),name.startswith(b'SCLEX_'),0.6534950733184814
|
||
|
4629,"def addInPlace ( self, value1, value2 ) : <TAB> for group in value2 : <TAB> <TAB> for key in value2 [ group ] : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> value1 [ group ] [ key ] = value2 [ group ] [ key ] <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> value1 [ group ] [ key ] += value2 [ group ] [ key ] <TAB> return value1",False,key not in value1[group],key not in self,0.6536213159561157
|
||
|
4630,"def add_value ( self, stats_key, stats_value, timestamp, reset_values = False ) : <TAB> utc_timestamp = convert_timestamp_to_utc ( timestamp ) <TAB> try : <TAB> <TAB> ms = MonitoringStats ( utc_timestamp, stats_key, stats_value ) <TAB> <TAB> self. session. add ( ms ) <TAB> <TAB> self. session. commit ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. session. query ( MonitoringStats ). filter ( <TAB> <TAB> <TAB> <TAB> and_ ( <TAB> <TAB> <TAB> <TAB> <TAB> MonitoringStats. stats_key == stats_key, <TAB> <TAB> <TAB> <TAB> <TAB> MonitoringStats. timestamp < utc_timestamp, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ). delete ( ) <TAB> <TAB> <TAB> self. session. commit ( ) <TAB> except Exception as exx : <TAB> <TAB> log. error ( u""exception {0!r}"". format ( exx ) ) <TAB> <TAB> log. error ( u""DATA: {0!s} -> {1!s}"". format ( stats_key, stats_value ) ) <TAB> <TAB> log. debug ( u""{0!s}"". format ( traceback. format_exc ( ) ) ) <TAB> <TAB> self. session. rollback ( ) <TAB> finally : <TAB> <TAB> self. session. close ( )",True,reset_values,reset_values,0.6642947196960449
|
||
|
4631,"def process_goodreads_csv ( i ) : <TAB> import csv <TAB> csv_payload = i. csv if isinstance ( i. csv, str ) else i. csv. decode ( ) <TAB> csv_file = csv. reader ( csv_payload. splitlines ( ), delimiter = "","", quotechar = '""' ) <TAB> header = next ( csv_file ) <TAB> books = { } <TAB> books_wo_isbns = { } <TAB> for book in list ( csv_file ) : <TAB> <TAB> _book = dict ( zip ( header, book ) ) <TAB> <TAB> isbn = _book [ ""ISBN"" ] = _book [ ""ISBN"" ]. replace ( '""', """" ). replace ( ""="", """" ) <TAB> <TAB> isbn_13 = _book [ ""ISBN13"" ] = _book [ ""ISBN13"" ]. replace ( '""', """" ). replace ( ""="", """" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> books [ isbn ] = _book <TAB> <TAB> elif isbn_13!= """" : <TAB> <TAB> <TAB> books [ isbn_13 ] = _book <TAB> <TAB> <TAB> books [ isbn_13 ] [ ""ISBN"" ] = isbn_13 <TAB> <TAB> else : <TAB> <TAB> <TAB> books_wo_isbns [ _book [ ""Book Id"" ] ] = _book <TAB> return books, books_wo_isbns",True,isbn != '',isbn != '',0.6774961352348328
|
||
|
4632,"def wrapper ( api, * args, ** kwargs ) : <TAB> try : <TAB> <TAB> old_curdir = os. getcwd ( ) <TAB> except EnvironmentError : <TAB> <TAB> old_curdir = None <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> cache = ClientCache ( api. cache_folder, api. out ) <TAB> <TAB> with environment_append ( cache. config. env_vars ) : <TAB> <TAB> <TAB> return f ( api, * args, ** kwargs ) <TAB> except Exception as exc : <TAB> <TAB> msg = exception_message_safe ( exc ) <TAB> <TAB> try : <TAB> <TAB> <TAB> api. out. error ( ""{} ({})"". format ( str ( exc. __class__. __name__ ), msg ) ) <TAB> <TAB> except BaseException : <TAB> <TAB> <TAB> pass <TAB> <TAB> raise <TAB> finally : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> os. chdir ( old_curdir )",False,old_curdir,old_curdir is not None,0.6626431941986084
|
||
|
4633,"def _load_custom_sections ( self ) -> None : <TAB> if self. _config. napoleon_custom_sections is not None : <TAB> <TAB> for entry in self. _config. napoleon_custom_sections : <TAB> <TAB> <TAB> if isinstance ( entry, str ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _sections [ entry. lower ( ) ] = self. _parse_custom_generic_section <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> self. _sections [ <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> entry [ 0 ]. lower ( ) <TAB> <TAB> <TAB> <TAB> <TAB> ] = self. _parse_custom_params_style_section <TAB> <TAB> <TAB> <TAB> elif entry [ 1 ] == ""returns_style"" : <TAB> <TAB> <TAB> <TAB> <TAB> self. _sections [ <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> entry [ 0 ]. lower ( ) <TAB> <TAB> <TAB> <TAB> <TAB> ] = self. _parse_custom_returns_style_section <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _sections [ entry [ 0 ]. lower ( ) ] = self. _sections. get ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> entry [ 1 ]. lower ( ), self. _parse_custom_generic_section <TAB> <TAB> <TAB> <TAB> <TAB> )",False,entry[1] == 'params_style',entry[0] == 'params_style',0.6554086208343506
|
||
|
4634,"def load_directory ( self, rulepath ) : <TAB> <TAB> <TAB> for f in os. listdir ( rulepath ) : <TAB> <TAB> full_path = f""{rulepath}/{f}"" <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> if ( <TAB> <TAB> <TAB> <TAB> <TAB> full_path. endswith ( "".yar"" ) <TAB> <TAB> <TAB> <TAB> <TAB> or full_path. endswith ( "".yara"" ) <TAB> <TAB> <TAB> <TAB> <TAB> or full_path. endswith ( "".rule"" ) <TAB> <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> <TAB> self. ruleset. append ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> full_path, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> yara. compile ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> full_path, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> externals = { ""filename"" : self. filename }, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> elif full_path. endswith ( "".yas"" ) : <TAB> <TAB> <TAB> <TAB> <TAB> self. ruleset. append ( ( full_path, yara. load ( full_path ) ) ) <TAB> <TAB> <TAB> except yara. SyntaxError as e : <TAB> <TAB> <TAB> <TAB> logger. warning ( f""Rule {full_path} "" f""has a syntax error {e}"" ) <TAB>",False,os.path.isfile(full_path),os.path.exists(full_path),0.6456151604652405
|
||
|
4635,"def test_expanduser ( self ) : <TAB> self. assertEqual ( posixpath. expanduser ( ""foo"" ), ""foo"" ) <TAB> self. assertEqual ( posixpath. expanduser ( b""foo"" ), b""foo"" ) <TAB> try : <TAB> <TAB> import pwd <TAB> except ImportError : <TAB> <TAB> pass <TAB> else : <TAB> <TAB> self. assertIsInstance ( posixpath. expanduser ( ""~/"" ), str ) <TAB> <TAB> self. assertIsInstance ( posixpath. expanduser ( b""~/"" ), bytes ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. assertEqual ( <TAB> <TAB> <TAB> <TAB> posixpath. expanduser ( ""~"" ) + ""/"", posixpath. expanduser ( ""~/"" ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> self. assertEqual ( <TAB> <TAB> <TAB> <TAB> posixpath. expanduser ( b""~"" ) + b""/"", posixpath. expanduser ( b""~/"" ) <TAB> <TAB> <TAB> ) <TAB> <TAB> self. assertIsInstance ( posixpath. expanduser ( ""~root/"" ), str ) <TAB> <TAB> self. assertIsInstance ( posixpath. expanduser ( ""~foo/"" ), str ) <TAB> <TAB> self. assertIsInstance ( posixpath. expanduser ( b""~root/"" ), bytes ) <TAB> <TAB> self. assertIsInstance ( posixpath. expanduser ( b""~foo/"" ), bytes ) <TAB> <TAB> with support. EnvironmentVarGuard ( ) as env : <TAB> <TAB> <TAB> env [ ""HOME"" ] = ""/"" <TAB> <TAB> <TAB> self. assertEqual ( posixpath. expanduser ( ""~"" ), ""/"" ) <TAB> <TAB> <TAB> self. assertEqual ( posixpath. expanduser ( ""~/foo"" ), ""/foo"" ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> del env [ ""HOME"" ] <TAB> <TAB> <TAB> home = pwd. getpwuid ( os. getuid ( ) ). pw_dir <TAB> <TAB>",False,posixpath.expanduser('~') != '/',os.getuid() == 0,0.6564404368400574
|
||
|
4636,"def prefetch ( sq, * subqueries ) : <TAB> if not subqueries : <TAB> <TAB> return sq <TAB> fixed_queries = prefetch_add_subquery ( sq, subqueries ) <TAB> deps = { } <TAB> rel_map = { } <TAB> for prefetch_result in reversed ( fixed_queries ) : <TAB> <TAB> query_model = prefetch_result. model <TAB> <TAB> if prefetch_result. field : <TAB> <TAB> <TAB> rel_map. setdefault ( prefetch_result. rel_model, [ ] ) <TAB> <TAB> <TAB> rel_map [ prefetch_result. rel_model ]. append ( prefetch_result ) <TAB> <TAB> deps [ query_model ] = { } <TAB> <TAB> id_map = deps [ query_model ] <TAB> <TAB> has_relations = bool ( rel_map. get ( query_model ) ) <TAB> <TAB> for instance in prefetch_result. query : <TAB> <TAB> <TAB> if prefetch_result. field : <TAB> <TAB> <TAB> <TAB> prefetch_result. store_instance ( instance, id_map ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> for rel in rel_map [ query_model ] : <TAB> <TAB> <TAB> <TAB> <TAB> rel. populate_instance ( instance, deps [ rel. model ] ) <TAB> return prefetch_result. query",True,has_relations,has_relations,0.6722928285598755
|
||
|
4637,"def extract_node_solution ( tree_node ) : <TAB> solution = { } <TAB> for variable_id in tree_node. _standard_variable_ids : <TAB> <TAB> varname, index = tree_node. _variable_ids [ variable_id ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if varname not in solution : <TAB> <TAB> <TAB> solution [ varname ] = [ ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> solution [ varname ]. append ( ( index, tree_node. _solution [ variable_id ] ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> name, index = tree_node. _variable_ids [ variable_id ] <TAB> <TAB> <TAB> full_name = name + indexToString ( index ) <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> ""%s: node solution missing for variable with scenario tree "" <TAB> <TAB> <TAB> <TAB> ""id %s (%s)"" % ( tree_node. name, variable_id, full_name ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> return None <TAB> for varname in list ( solution. keys ( ) ) : <TAB> <TAB> solution [ varname ] = sorted ( solution [ varname ], key = lambda x : x [ 0 ] ) <TAB> return solution",False,variable_id in tree_node._solution,variable_node.has_solution[variable_id],0.655394434928894
|
||
|
4638,"def fix_path_string ( all_info, current_path, path_to_value ) : <TAB> <TAB> while True : <TAB> <TAB> dynamic_path = re_get_value_at. findall ( path_to_value ) <TAB> <TAB> if len ( dynamic_path ) == 0 : <TAB> <TAB> <TAB> break <TAB> <TAB> for dp in dynamic_path : <TAB> <TAB> <TAB> tmp = dp <TAB> <TAB> <TAB> while True : <TAB> <TAB> <TAB> <TAB> nested = re_nested_get_value_at. findall ( tmp ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> tmp = nested [ 0 ]. replace ( ""_GET_VALUE_AT_("", """", 1 ) <TAB> <TAB> <TAB> dv = get_value_at ( all_info, current_path, tmp ) <TAB> <TAB> <TAB> path_to_value = path_to_value. replace ( ""_GET_VALUE_AT_(%s)"" % tmp, dv ) <TAB> return path_to_value",False,len(nested) == 0,nested == 0,0.6581918001174927
|
||
|
4639,"def genstats_cov_thresholds ( self, dist_data, threshs, hidden_threshs ) : <TAB> data = defaultdict ( OrderedDict ) <TAB> for s_name, d in dist_data. items ( ) : <TAB> <TAB> dist_subset = { t : data for t, data in d. items ( ) if t in threshs } <TAB> <TAB> for t in threshs : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> data [ s_name ] [ ""{}_x_pc"". format ( t ) ] = dist_subset [ t ] <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> data [ s_name ] [ ""{}_x_pc"". format ( t ) ] = 0 <TAB> headers = OrderedDict ( ) <TAB> for t in threshs : <TAB> <TAB> headers [ ""{}_x_pc"". format ( t ) ] = { <TAB> <TAB> <TAB> ""title"" : ""≥ {}X"". format ( t ), <TAB> <TAB> <TAB> ""description"" : ""Fraction of genome with at least {}X coverage"". format ( t ), <TAB> <TAB> <TAB> ""max"" : 100, <TAB> <TAB> <TAB> ""min"" : 0, <TAB> <TAB> <TAB> ""suffix"" : ""%"", <TAB> <TAB> <TAB> ""scale"" : ""RdYlGn"", <TAB> <TAB> <TAB> ""hidden"" : t in hidden_threshs, <TAB> <TAB> } <TAB> self. general_stats_addcols ( data, headers )",False,int(t) in dist_subset,t in dist_subset,0.6564961075782776
|
||
|
4640,"def _flush_renames ( self, old_hash = None, limit = 0 ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if limit and len ( self. _pending_renames ) < 2 * limit : <TAB> <TAB> return <TAB> fi_input, fi_output = self. _import_pipes <TAB> while self. _pending_renames : <TAB> <TAB> orig_id, ignore = self. _pending_renames. popitem ( last = False ) <TAB> <TAB> new_id = fi_output. readline ( ). rstrip ( ) <TAB> <TAB> self. _commit_renames [ orig_id ] = new_id <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return <TAB> <TAB> if limit and len ( self. _pending_renames ) < limit : <TAB> <TAB> <TAB> return",False,old_hash == orig_id,not ignore,0.6536868810653687
|
||
|
4641,"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. requestorUserName = iprot. readString ( ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> iprot. skip ( ftype ) <TAB> <TAB> elif fid == 3 : <TAB> <TAB> <TAB> if ftype == TType. STRUCT : <TAB> <TAB> <TAB> <TAB> self. authorizable = TSentryAuthorizable ( ) <TAB> <TAB> <TAB> <TAB> self. authorizable. 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 == 2,fid == 2,0.677743136882782
|
||
|
4642,"def test_to_instance_dicts ( <TAB> self, feature_spec, instances, feed_dict, feed_eager_tensors ) : <TAB> if feed_eager_tensors : <TAB> <TAB> test_case. skip_if_not_tf2 ( ""Tensorflow 2.x required"" ) <TAB> schema = schema_utils. schema_from_feature_spec ( feature_spec ) <TAB> feed_dict_local = copy. copy ( feed_dict ) <TAB> if feed_eager_tensors : <TAB> <TAB> for key, value in six. iteritems ( feed_dict_local ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> feed_dict_local [ key ] = tf. sparse. SparseTensor. from_value ( value ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> feed_dict_local [ key ] = tf. constant ( value ) <TAB> result = impl_helper. to_instance_dicts ( schema, feed_dict_local ) <TAB> np. testing. assert_equal ( instances, result )",False,"isinstance(value, tf.compat.v1.SparseTensorValue)",instances[key],0.6484865546226501
|
||
|
4643,"def add_hook ( self, hook, name, timing ) : <TAB> """"""Adds a hook function."""""" <TAB> if not callable ( hook ) : <TAB> <TAB> raise TypeError ( ""hook function must be callable"" ) <TAB> if timing not in ( ""pre"", ""post"", ""auto"" ) : <TAB> <TAB> raise ValueError ( ""timing must be one of ('pre', 'post', 'auto')"" ) <TAB> if timing == ""auto"" : <TAB> <TAB> timing = getattr ( hook, ""timing"", ""pre"" ) <TAB> <TAB> if timing not in ( ""pre"", ""post"" ) and self. _invalid_timing_fallback : <TAB> <TAB> <TAB> warnings. warn ( <TAB> <TAB> <TAB> <TAB> ""Hook timing attribute not in ('pre', 'post'), "" <TAB> <TAB> <TAB> <TAB> ""defaulting timing to 'pre'."" <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> timing = ""pre"" <TAB> if<mask> : <TAB> <TAB> name = getattr ( hook, ""name"", getattr ( hook, ""__name__"", None ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( ""the name of the hook function is not specified"" ) <TAB> if name in self. _pre_update_hooks or name in self. _post_update_hooks : <TAB> <TAB> raise KeyError ( 'hook ""{}"" already exists'. format ( name ) ) <TAB> if timing == ""pre"" : <TAB> <TAB> self. _pre_update_hooks [ name ] = hook <TAB> else : <TAB> <TAB> self. _post_update_hooks [ name ] = hook",True,name is None,name is None,0.6623499393463135
|
||
|
4644,"def update_service_key ( kid, name = None, metadata = None ) : <TAB> try : <TAB> <TAB> with db_transaction ( ) : <TAB> <TAB> <TAB> key = db_for_update ( ServiceKey. select ( ). where ( ServiceKey. kid == kid ) ). get ( ) <TAB> <TAB> <TAB> if name is not None : <TAB> <TAB> <TAB> <TAB> key. name = name <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> key. metadata. update ( metadata ) <TAB> <TAB> <TAB> key. save ( ) <TAB> except ServiceKey. DoesNotExist : <TAB> <TAB> raise ServiceKeyDoesNotExist",True,metadata is not None,metadata is not None,0.6653944849967957
|
||
|
4645,"def set_study_directions ( <TAB> self, study_id : int, directions : Sequence [ StudyDirection ] ) -> None : <TAB> with self. _lock : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> current_directions = self. _studies [ study_id ]. directions <TAB> <TAB> <TAB> if directions == current_directions : <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> elif ( <TAB> <TAB> <TAB> <TAB> len ( current_directions ) == 1 <TAB> <TAB> <TAB> <TAB> and current_directions [ 0 ] == StudyDirection. NOT_SET <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> self. _studies [ study_id ]. directions = list ( directions ) <TAB> <TAB> <TAB> <TAB> self. _backend. set_study_directions ( study_id, directions ) <TAB> <TAB> <TAB> <TAB> return <TAB> self. _backend. set_study_directions ( study_id, directions )",True,study_id in self._studies,study_id in self._studies,0.6583038568496704
|
||
|
4646,"def param ( self ) : <TAB> if not self. _param : <TAB> <TAB> multi_text = """" <TAB> <TAB> if self. multiple : <TAB> <TAB> <TAB> multi_text ='multiple=""True""' <TAB> <TAB> optional_text = """" <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> optional_text = 'optional=""True""' <TAB> <TAB> options_text = self. options_xml <TAB> <TAB> data_ref_text = """" <TAB> <TAB> if self. set_data_ref : <TAB> <TAB> <TAB> data_ref_text = 'data_ref=""input_bam""' <TAB> <TAB> template_xml = """"""<param name=""my_name"" type=""%s"" %s %s %s>%s</param>"""""" <TAB> <TAB> param_str = template_xml % ( <TAB> <TAB> <TAB> self. type, <TAB> <TAB> <TAB> data_ref_text, <TAB> <TAB> <TAB> multi_text, <TAB> <TAB> <TAB> optional_text, <TAB> <TAB> <TAB> options_text, <TAB> <TAB> ) <TAB> <TAB> self. _param = self. _parameter_for ( xml = param_str ) <TAB> return self. _param",True,self.optional,self.optional,0.6671499013900757
|
||
|
4647,"def test_multipolygons ( self ) : <TAB> ""Testing MultiPolygon objects."" <TAB> prev = fromstr ( ""POINT (0 0)"" ) <TAB> for mp in self. geometries. multipolygons : <TAB> <TAB> mpoly = fromstr ( mp. wkt ) <TAB> <TAB> self. assertEqual ( mpoly. geom_type, ""MultiPolygon"" ) <TAB> <TAB> self. assertEqual ( mpoly. geom_typeid, 6 ) <TAB> <TAB> self. assertEqual ( mp. valid, mpoly. valid ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. assertEqual ( mp. num_geom, mpoly. num_geom ) <TAB> <TAB> <TAB> self. assertEqual ( mp. n_p, mpoly. num_coords ) <TAB> <TAB> <TAB> self. assertEqual ( mp. num_geom, len ( mpoly ) ) <TAB> <TAB> <TAB> self. assertRaises ( GEOSIndexError, mpoly. __getitem__, len ( mpoly ) ) <TAB> <TAB> <TAB> for p in mpoly : <TAB> <TAB> <TAB> <TAB> self. assertEqual ( p. geom_type, ""Polygon"" ) <TAB> <TAB> <TAB> <TAB> self. assertEqual ( p. geom_typeid, 3 ) <TAB> <TAB> <TAB> <TAB> self. assertEqual ( p. valid, True ) <TAB> <TAB> <TAB> self. assertEqual ( <TAB> <TAB> <TAB> <TAB> mpoly. wkt, MultiPolygon ( * tuple ( poly. clone ( ) for poly in mpoly ) ). wkt <TAB> <TAB> <TAB> )",False,mp.valid,mp.num_coords != mpoly.num_coords,0.6669692993164062
|
||
|
4648,"def update_api_apivs ( <TAB> instance, <TAB> versioning_scheme = None, <TAB> description = None, <TAB> display_name = None, <TAB> version_header_name = None, <TAB> version_query_name = None, ) : <TAB> """"""Updates the details of the Api VersionSet specified by its identifier."""""" <TAB> if display_name is not None : <TAB> <TAB> instance. display_name = display_name <TAB> if versioning_scheme is not None : <TAB> <TAB> instance. versioning_scheme = versioning_scheme <TAB> <TAB> if versioning_scheme == VersioningScheme. header : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise CLIError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Please specify version header name while using 'header' as version scheme."" <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> instance. version_header_name = version_header_name <TAB> <TAB> <TAB> instance. version_query_name = None <TAB> <TAB> if versioning_scheme == VersioningScheme. query : <TAB> <TAB> <TAB> if version_query_name is None : <TAB> <TAB> <TAB> <TAB> raise CLIError ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Please specify version query name while using 'query' as version scheme."" <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> instance. version_query_name = version_query_name <TAB> <TAB> <TAB> instance. version_header_name = None <TAB> if description is None : <TAB> <TAB> instance. description = description <TAB> return instance",True,version_header_name is None,version_header_name is None,0.6575341820716858
|
||
|
4649,"def createDirectories ( self, path, permissions ) : <TAB> if not self. _lock. acquire ( blocking = False ) : <TAB> <TAB> self. _raiseServerException ( <TAB> <TAB> <TAB> ""Could not acquire remote connection lock. Multi-threaded access detected!"" <TAB> <TAB> ) <TAB> try : <TAB> <TAB> self. do_verifyConnected ( ) <TAB> <TAB> self. log. debug ( ""createDirectories %s, %r"", path, permissions ) <TAB> <TAB> orig_path = path <TAB> <TAB> make_dir_paths = [ ] <TAB> <TAB> last_path = None <TAB> <TAB> rfinfo = self. list ( path ) <TAB> <TAB> while rfinfo is None : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. _raiseServerException ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Could not find any parent directory for %r"", orig_path <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> make_dir_paths. append ( path ) <TAB> <TAB> <TAB> path = self. do_getParentPath ( path ) <TAB> <TAB> <TAB> rfinfo = self. list ( path ) <TAB> <TAB> <TAB> last_path = path <TAB> <TAB> for path in make_dir_paths : <TAB> <TAB> <TAB> self. do_createDirectory ( name, permissions ) <TAB> finally : <TAB> <TAB> self. _lock. release ( )",False,not path or path == last_path,not self.hasParentPath(path),0.6520031690597534
|
||
|
4650,"def expand_extensions ( existing ) : <TAB> for name in extension_names : <TAB> <TAB> ext = ( <TAB> <TAB> <TAB> im ( ""lizard_ext.lizard"" + name. lower ( ) ). LizardExtension ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> else name <TAB> <TAB> ) <TAB> <TAB> existing. insert ( <TAB> <TAB> <TAB> len ( existing ) if not hasattr ( ext, ""ordering_index"" ) else ext. ordering_index, <TAB> <TAB> <TAB> ext, <TAB> <TAB> ) <TAB> return existing",False,"isinstance(name, str)","not hasattr(existing, name)",0.6540394425392151
|
||
|
4651,"def things ( self, query ) : <TAB> limit = query. pop ( ""limit"", 100 ) <TAB> offset = query. pop ( ""offset"", 0 ) <TAB> keys = set ( self. docs ) <TAB> for k, v in query. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> flat = common. flatten_dict ( v ) [ 0 ] <TAB> <TAB> <TAB> k += ""."" + web. rstrips ( flat [ 0 ], "".key"" ) <TAB> <TAB> <TAB> v = flat [ 1 ] <TAB> <TAB> keys = set ( k for k in self. filter_index ( self. index, k, v ) if k in keys ) <TAB> keys = sorted ( keys ) <TAB> return keys [ offset : offset + limit ]",True,"isinstance(v, dict)","isinstance(v, dict)",0.6516493558883667
|
||
|
4652,"def send_animation ( <TAB> token, <TAB> chat_id, <TAB> data, <TAB> duration = None, <TAB> caption = None, <TAB> reply_to_message_id = None, <TAB> reply_markup = None, <TAB> parse_mode = None, <TAB> disable_notification = None, <TAB> timeout = None, <TAB> thumb = None, ) : <TAB> method_url = r""sendAnimation"" <TAB> payload = { ""chat_id"" : chat_id } <TAB> files = None <TAB> if not util. is_string ( data ) : <TAB> <TAB> files = { ""animation"" : data } <TAB> else : <TAB> <TAB> payload [ ""animation"" ] = data <TAB> if duration : <TAB> <TAB> payload [ ""duration"" ] = duration <TAB> if caption : <TAB> <TAB> payload [ ""caption"" ] = caption <TAB> if reply_to_message_id : <TAB> <TAB> payload [ ""reply_to_message_id"" ] = reply_to_message_id <TAB> if reply_markup : <TAB> <TAB> payload [ ""reply_markup"" ] = _convert_markup ( reply_markup ) <TAB> if parse_mode : <TAB> <TAB> payload [ ""parse_mode"" ] = parse_mode <TAB> if disable_notification is not None : <TAB> <TAB> payload [ ""disable_notification"" ] = disable_notification <TAB> if timeout : <TAB> <TAB> payload [ ""connect-timeout"" ] = timeout <TAB> if thumb : <TAB> <TAB> if not util. is_string ( thumb ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> files [ ""thumb"" ] = thumb <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> files = { ""thumb"" : thumb } <TAB> <TAB> else : <TAB> <TAB> <TAB> payload [ ""thumb"" ] = thumb <TAB> return _make_request ( token, method_url, params = payload, files = files, method = ""post"" )",False,files,thumb <TAB> <TAB> <TAB> or _is_valid_thumb(thumb),0.6814186573028564
|
||
|
4653,"def test_slice_variants ( self ) : <TAB> """"""Simple slices using different start/end values."""""" <TAB> for start in list ( range ( - 30, 30 ) ) + [ None ] : <TAB> <TAB> for end in list ( range ( - 30, 30 ) ) + [ None ] : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> rec = self. record [ start : end ] <TAB> <TAB> <TAB> seq = self. record. seq [ start : end ] <TAB> <TAB> <TAB> seq_str = str ( self. record. seq ) [ start : end ] <TAB> <TAB> <TAB> self. assertEqual ( seq_str, str ( seq ) ) <TAB> <TAB> <TAB> self. assertEqual ( seq_str, str ( rec. seq ) ) <TAB> <TAB> <TAB> self. assertEqual ( ""X"" * len ( seq_str ), rec. letter_annotations [ ""fake"" ] )",False,start is None and end is None,start == end,0.657306432723999
|
||
|
4654,"def _route_db ( self, model, ** hints ) : <TAB> chosen_db = None <TAB> for router in self. routers : <TAB> <TAB> try : <TAB> <TAB> <TAB> method = getattr ( router, action ) <TAB> <TAB> except AttributeError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> else : <TAB> <TAB> <TAB> chosen_db = method ( model, ** hints ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return chosen_db <TAB> try : <TAB> <TAB> return hints [ ""instance"" ]. _state. db or DEFAULT_DB_ALIAS <TAB> except KeyError : <TAB> <TAB> return DEFAULT_DB_ALIAS",True,chosen_db,chosen_db,0.6685689687728882
|
||
|
4655,"def _resolve_relative_config ( dir, config ) : <TAB> <TAB> <TAB> icon = config. get ( ""icon"" ) <TAB> if icon : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> icon = File ( icon ) <TAB> <TAB> else : <TAB> <TAB> <TAB> icon = dir. resolve_file ( icon ) <TAB> <TAB> document_root = config. get ( ""document_root"" ) <TAB> if document_root : <TAB> <TAB> if zim. fs. isabs ( document_root ) or not dir : <TAB> <TAB> <TAB> document_root = Dir ( document_root ) <TAB> <TAB> else : <TAB> <TAB> <TAB> document_root = dir. resolve_dir ( document_root ) <TAB> return icon, document_root",False,zim.fs.isabs(icon) or not dir,zim.fs.isfile(icon),0.6516158580780029
|
||
|
4656,"def process_tag ( self ) : <TAB> tag = self. event. tag <TAB> if isinstance ( self. event, ScalarEvent ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. style = self. choose_scalar_style ( ) <TAB> <TAB> if ( not self. canonical or tag is None ) and ( <TAB> <TAB> <TAB> ( self. style == """" and self. event. implicit [ 0 ] ) <TAB> <TAB> <TAB> or ( self. style!= """" and self. event. implicit [ 1 ] ) <TAB> <TAB> ) : <TAB> <TAB> <TAB> self. prepared_tag = None <TAB> <TAB> <TAB> return <TAB> <TAB> if self. event. implicit [ 0 ] and tag is None : <TAB> <TAB> <TAB> tag = u""!"" <TAB> <TAB> <TAB> self. prepared_tag = None <TAB> else : <TAB> <TAB> if ( not self. canonical or tag is None ) and self. event. implicit : <TAB> <TAB> <TAB> self. prepared_tag = None <TAB> <TAB> <TAB> return <TAB> if tag is None : <TAB> <TAB> raise EmitterError ( ""tag is not specified"" ) <TAB> if self. prepared_tag is None : <TAB> <TAB> self. prepared_tag = self. prepare_tag ( tag ) <TAB> if self. prepared_tag : <TAB> <TAB> self. write_indicator ( self. prepared_tag, True ) <TAB> self. prepared_tag = None",False,self.style is None,tag is None,0.6569838523864746
|
||
|
4657,"def updateGroupStats ( light ) : <TAB> for group in bridge_config [ ""groups"" ] : <TAB> <TAB> if light in bridge_config [ ""groups"" ] [ group ] [ ""lights"" ] : <TAB> <TAB> <TAB> for key, value in bridge_config [ ""lights"" ] [ light ] [ ""state"" ]. iteritems ( ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> bridge_config [ ""groups"" ] [ group ] [ ""action"" ] [ key ] = value <TAB> <TAB> <TAB> any_on = False <TAB> <TAB> <TAB> all_on = True <TAB> <TAB> <TAB> bri = 0 <TAB> <TAB> <TAB> for group_light in bridge_config [ ""groups"" ] [ group ] [ ""lights"" ] : <TAB> <TAB> <TAB> <TAB> if bridge_config [ ""lights"" ] [ light ] [ ""state"" ] [ ""on"" ] == True : <TAB> <TAB> <TAB> <TAB> <TAB> any_on = True <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> all_on = False <TAB> <TAB> <TAB> <TAB> bri += bridge_config [ ""lights"" ] [ light ] [ ""state"" ] [ ""bri"" ] <TAB> <TAB> <TAB> avg_bri = bri / len ( bridge_config [ ""groups"" ] [ group ] [ ""lights"" ] ) <TAB> <TAB> <TAB> bridge_config [ ""groups"" ] [ group ] [ ""state"" ] = { <TAB> <TAB> <TAB> <TAB> ""any_on"" : any_on, <TAB> <TAB> <TAB> <TAB> ""all_on"" : all_on, <TAB> <TAB> <TAB> <TAB> ""bri"" : avg_bri, <TAB> <TAB> <TAB> <TAB> ""lastupdated"" : datetime. utcnow ( ). strftime ( ""%Y-%m-%dT%H:%M:%S"" ),",False,"key not in ['on', 'reachable']",key in bridge_config[group],0.6551306247711182
|
||
|
4658,"def get_read_write_funcs ( parsed_code ) : <TAB> allids = set ( [ ] ) <TAB> read = set ( [ ] ) <TAB> write = set ( [ ] ) <TAB> funcs = set ( [ ] ) <TAB> for node in ast. walk ( parsed_code ) : <TAB> <TAB> if node. __class__ is ast. Name : <TAB> <TAB> <TAB> allids. add ( node. id ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> write. add ( node. id ) <TAB> <TAB> <TAB> elif node. ctx. __class__ is ast. Load : <TAB> <TAB> <TAB> <TAB> read. add ( node. id ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> raise SyntaxError <TAB> <TAB> elif node. __class__ is ast. Call : <TAB> <TAB> <TAB> funcs. add ( node. func. id ) <TAB> read = read - funcs <TAB> <TAB> if funcs. intersection ( write ) : <TAB> <TAB> raise SyntaxError ( ""Cannot assign to functions in abstract code"" ) <TAB> return allids, read, write, funcs",False,node.ctx.__class__ is ast.Store,node.ctx.__class__ is ast.Write,0.6554673910140991
|
||
|
4659,"def setup ( self, ctxt ) : <TAB> LOG. info ( ""Initiating connection to IBM DS8K storage system."" ) <TAB> connection_type = self. configuration. safe_get ( ""connection_type"" ) <TAB> replication_devices = self. configuration. safe_get ( ""replication_device"" ) <TAB> if connection_type == storage. XIV_CONNECTION_TYPE_FC : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _helper = helper. DS8KCommonHelper ( <TAB> <TAB> <TAB> <TAB> self. configuration, self. _connector_obj <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. _helper = helper. DS8KReplicationSourceHelper ( <TAB> <TAB> <TAB> <TAB> self. configuration, self. _connector_obj <TAB> <TAB> <TAB> ) <TAB> elif connection_type == storage. XIV_CONNECTION_TYPE_FC_ECKD : <TAB> <TAB> self. _helper = helper. DS8KECKDHelper ( self. configuration, self. _connector_obj ) <TAB> else : <TAB> <TAB> raise exception. InvalidParameterValue ( <TAB> <TAB> <TAB> err = ( _ ( ""Param [connection_type] %s is invalid."" ) % connection_type ) <TAB> <TAB> ) <TAB> if replication_devices : <TAB> <TAB> self. _do_replication_setup ( replication_devices, self. _helper ) <TAB> <TAB> self. _check_async_cloned_volumes ( )",False,not replication_devices,replication_devices,0.6599441766738892
|
||
|
4660,"def assert_traceback ( self, tb, files ) : <TAB> deduped_files = [ ] <TAB> while tb : <TAB> <TAB> code = tb. tb_frame. f_code <TAB> <TAB> fn = code. co_filename <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> deduped_files. append ( fn ) <TAB> <TAB> tb = tb. tb_next <TAB> self. assertEqual ( len ( deduped_files ), len ( files ), deduped_files ) <TAB> for fn, pat in zip ( deduped_files, files ) : <TAB> <TAB> self. assertIn ( pat, fn )",False,not deduped_files or fn != deduped_files[-1],fn not in deduped_files,0.6565097570419312
|
||
|
4661,"def url_rewrite ( self, task, entry ) : <TAB> try : <TAB> <TAB> <TAB> <TAB> txheaders = { ""User-agent"" : ""Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)"" } <TAB> <TAB> page = task. requests. get ( entry [ ""url"" ], headers = txheaders ) <TAB> <TAB> soup = get_soup ( page. text ) <TAB> <TAB> results = soup. find_all ( ""a"", attrs = { ""class"" : ""l"" } ) <TAB> <TAB> if not results : <TAB> <TAB> <TAB> raise UrlRewritingError ( ""No results"" ) <TAB> <TAB> for res in results : <TAB> <TAB> <TAB> url = res. get ( ""href"" ) <TAB> <TAB> <TAB> url = url. replace ( ""/interstitial?url="", """" ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> regexp = "".*"". join ( [ x. contents [ 0 ] for x in res. find_all ( ""em"" ) ] ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> log. debug ( ""resolved, found with %s"" % regexp ) <TAB> <TAB> <TAB> <TAB> entry [ ""url"" ] = url <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> raise UrlRewritingError ( ""Unable to resolve"" ) <TAB> except Exception as e : <TAB> <TAB> raise UrlRewritingError ( e )",False,"re.match(regexp, entry['title'])",self.has_regex(regexp),0.6453467607498169
|
||
|
4662,"def trakt_episode_data_generate ( self, data ) : <TAB> <TAB> uniqueSeasons = [ ] <TAB> for season, episode in data : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> uniqueSeasons. append ( season ) <TAB> <TAB> seasonsList = [ ] <TAB> for searchedSeason in uniqueSeasons : <TAB> <TAB> episodesList = [ ] <TAB> <TAB> for season, episode in data : <TAB> <TAB> <TAB> if season == searchedSeason : <TAB> <TAB> <TAB> <TAB> episodesList. append ( { ""number"" : episode } ) <TAB> <TAB> seasonsList. append ( { ""number"" : searchedSeason, ""episodes"" : episodesList } ) <TAB> post_data = { ""seasons"" : seasonsList } <TAB> return post_data",False,season not in uniqueSeasons,season == season,0.6704022884368896
|
||
|
4663,"def process_response ( self, request, response ) : <TAB> language = get_language ( ) <TAB> if hasattr ( request, ""session"" ) : <TAB> <TAB> session_language = request. session. get ( LANGUAGE_SESSION_KEY, None ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> request. session [ LANGUAGE_SESSION_KEY ] = language <TAB> <TAB> <TAB> request. session. save ( ) <TAB> if ( <TAB> <TAB> settings. LANGUAGE_COOKIE_NAME in request. COOKIES <TAB> <TAB> and request. COOKIES [ settings. LANGUAGE_COOKIE_NAME ] == language <TAB> ) : <TAB> <TAB> return response <TAB> max_age = 365 * 24 * 60 * 60 <TAB> expires = datetime. datetime. utcnow ( ) + datetime. timedelta ( seconds = max_age ) <TAB> response. set_cookie ( settings. LANGUAGE_COOKIE_NAME, language, expires = expires ) <TAB> return response",False,session_language and (not session_language == language),session_language is not None,0.6548347473144531
|
||
|
4664,"def rename_references ( app, what, name, obj, options, lines, reference_offset = [ 0 ] ) : <TAB> <TAB> references = [ ] <TAB> for line in lines : <TAB> <TAB> line = line. strip ( ) <TAB> <TAB> m = re. match ( <TAB> <TAB> <TAB> sixu ( ""^.. \\[(%s)\\]"" ) % app. config. numpydoc_citation_re, line, re. I <TAB> <TAB> ) <TAB> <TAB> if m : <TAB> <TAB> <TAB> references. append ( m. group ( 1 ) ) <TAB> if references : <TAB> <TAB> for i, line in enumerate ( lines ) : <TAB> <TAB> <TAB> for r in references : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> new_r = sixu ( ""R%d"" ) % ( reference_offset [ 0 ] + int ( r ) ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> new_r = sixu ( ""%s%d"" ) % ( r, reference_offset [ 0 ] ) <TAB> <TAB> <TAB> <TAB> lines [ i ] = lines [ i ]. replace ( sixu ( ""[%s]_"" ) % r, sixu ( ""[%s]_"" ) % new_r ) <TAB> <TAB> <TAB> <TAB> lines [ i ] = lines [ i ]. replace ( <TAB> <TAB> <TAB> <TAB> <TAB> sixu ( "".. [%s]"" ) % r, sixu ( "".. [%s]"" ) % new_r <TAB> <TAB> <TAB> <TAB> ) <TAB> reference_offset [ 0 ] += len ( references )",False,"re.match(sixu('^\\d+$'), r)",r in line,0.6543307304382324
|
||
|
4665,"def getsource ( obj ) : <TAB> """"""Wrapper around inspect.getsource"""""" <TAB> try : <TAB> <TAB> try : <TAB> <TAB> <TAB> src = encoding. to_unicode ( inspect. getsource ( obj ) ) <TAB> <TAB> except TypeError : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> src = encoding. to_unicode ( inspect. getsource ( obj. __class__ ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> src = getdoc ( obj ) <TAB> <TAB> return src <TAB> except ( TypeError, IOError ) : <TAB> <TAB> return",True,"hasattr(obj, '__class__')","hasattr(obj, '__class__')",0.6569093465805054
|
||
|
4666,"def onmove ( self, event ) : <TAB> ""on motion notify event if box/line is wanted"" <TAB> if self. eventpress is None or self. ignore ( event ) : <TAB> <TAB> return <TAB> x, y = event. xdata, event. ydata <TAB> <TAB> if self. drawtype == ""box"" : <TAB> <TAB> minx, maxx = self. eventpress. xdata, x <TAB> <TAB> miny, maxy = self. eventpress. ydata, y <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> minx, maxx = maxx, minx <TAB> <TAB> if miny > maxy : <TAB> <TAB> <TAB> miny, maxy = maxy, miny <TAB> <TAB> self. to_draw. set_x ( minx ) <TAB> <TAB> self. to_draw. set_y ( miny ) <TAB> <TAB> self. to_draw. set_width ( maxx - minx ) <TAB> <TAB> self. to_draw. set_height ( maxy - miny ) <TAB> <TAB> self. update ( ) <TAB> <TAB> return False <TAB> if self. drawtype == ""line"" : <TAB> <TAB> self. to_draw. set_data ( [ self. eventpress. xdata, x ], [ self. eventpress. ydata, y ] ) <TAB> <TAB> self. update ( ) <TAB> <TAB> return False",True,minx > maxx,minx > maxx,0.6709022521972656
|
||
|
4667,"def POP ( cpu, * regs ) : <TAB> for reg in regs : <TAB> <TAB> val = cpu. stack_pop ( cpu. address_bit_size // 8 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> cpu. _set_mode_by_val ( val ) <TAB> <TAB> <TAB> val = val & ~ 0x1 <TAB> <TAB> reg. write ( val )",False,"reg.reg in ('PC', 'R15')",val & 1 < TAB > 1,0.6497471332550049
|
||
|
4668,"def ad_readout ( self, data ) : <TAB> cnt_idx = self. cnt - len ( data ) + 1 <TAB> idx = 0 <TAB> while idx < 14 : <TAB> <TAB> if idx == 2 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> idx += 2 <TAB> <TAB> value = ( data [ idx ] << 8 ) | data [ idx + 1 ] <TAB> <TAB> name = AD_READOUTS. get ( idx, ""..."" ) <TAB> <TAB> if value!= 0 : <TAB> <TAB> <TAB> if idx == 0 : <TAB> <TAB> <TAB> <TAB> self. annotate ( <TAB> <TAB> <TAB> <TAB> <TAB> name, self. to_temp ( value ), cnt_idx + idx, cnt_idx + idx + 1 <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> elif idx == 4 : <TAB> <TAB> <TAB> <TAB> self. annotate ( <TAB> <TAB> <TAB> <TAB> <TAB> name, self. to_current ( value ), cnt_idx + idx, cnt_idx + idx + 1 <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> self. annotate ( <TAB> <TAB> <TAB> <TAB> <TAB> name, self. to_power ( value ), cnt_idx + idx, cnt_idx + idx + 1 <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. annotate ( name, str ( value ), cnt_idx + idx, cnt_idx + idx + 1 ) <TAB> <TAB> idx += 2",False,"idx in (6, 8)",idx == 8,0.6576352119445801
|
||
|
4669,"def get_bb_vars ( variables = None, target = None, postconfig = None ) : <TAB> """"""Get values of multiple bitbake variables"""""" <TAB> bbenv = get_bb_env ( target, postconfig = postconfig ) <TAB> if variables is not None : <TAB> <TAB> variables = list ( variables ) <TAB> var_re = re. compile ( r'^(export )?(?P<var>\w+(_.*)?)=""(?P<value>.*)""$' ) <TAB> unset_re = re. compile ( r""^unset (?P<var>\w+)$"" ) <TAB> lastline = None <TAB> values = { } <TAB> for line in bbenv. splitlines ( ) : <TAB> <TAB> match = var_re. match ( line ) <TAB> <TAB> val = None <TAB> <TAB> if match : <TAB> <TAB> <TAB> val = match. group ( ""value"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> match = unset_re. match ( line ) <TAB> <TAB> <TAB> if match : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> val = lastline. split ( '""' ) [ 1 ] <TAB> <TAB> if val : <TAB> <TAB> <TAB> var = match. group ( ""var"" ) <TAB> <TAB> <TAB> if variables is None : <TAB> <TAB> <TAB> <TAB> values [ var ] = val <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> if var in variables : <TAB> <TAB> <TAB> <TAB> <TAB> values [ var ] = val <TAB> <TAB> <TAB> <TAB> <TAB> variables. remove ( var ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if not variables : <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> lastline = line <TAB> if variables : <TAB> <TAB> <TAB> <TAB",False,"lastline.startswith('# ""')",lastline,0.6534137725830078
|
||
|
4670,"def get_column_declaration_sql ( self, name, field ) : <TAB> if ""column_definition"" in field : <TAB> <TAB> column_def = self. get_custom_type_declaration_sql ( field ) <TAB> else : <TAB> <TAB> default = self. get_default_value_declaration_sql ( field ) <TAB> <TAB> charset = field. get ( ""charset"", """" ) <TAB> <TAB> if charset : <TAB> <TAB> <TAB> charset = "" "" + self. get_column_charset_declaration_sql ( charset ) <TAB> <TAB> collation = field. get ( ""collation"", """" ) <TAB> <TAB> if charset : <TAB> <TAB> <TAB> charset = "" "" + self. get_column_collation_declaration_sql ( charset ) <TAB> <TAB> notnull = field. get ( ""notnull"", """" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> notnull = "" NOT NULL"" <TAB> <TAB> else : <TAB> <TAB> <TAB> notnull = """" <TAB> <TAB> unique = field. get ( ""unique"", """" ) <TAB> <TAB> if unique : <TAB> <TAB> <TAB> unique = "" "" + self. get_unique_field_declaration_sql ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> unique = """" <TAB> <TAB> check = field. get ( ""check"", """" ) <TAB> <TAB> type_decl = self. get_sql_type_declaration ( field ) <TAB> <TAB> column_def = ( <TAB> <TAB> <TAB> type_decl + charset + default + notnull + unique + check + collation <TAB> <TAB> ) <TAB> return name + "" "" + column_def",True,notnull,notnull,0.6692383885383606
|
||
|
4671,"def test_basic ( self ) : <TAB> <TAB> <TAB> <TAB> for a in range ( 3 ) : <TAB> <TAB> for b in range ( 3 ) : <TAB> <TAB> <TAB> for typea in ( int, Number ) : <TAB> <TAB> <TAB> <TAB> for typeb in ( int, Number ) : <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> <TAB> ta = typea ( a ) <TAB> <TAB> <TAB> <TAB> <TAB> tb = typeb ( b ) <TAB> <TAB> <TAB> <TAB> <TAB> for ops in opmap. values ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for op in ops : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> realoutcome = op ( a, b ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> testoutcome = op ( ta, tb ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. assertEqual ( realoutcome, testoutcome )",False,typea == typeb == int,typea is None and b is None,0.6660654544830322
|
||
|
4672,"def iterate_list ( self, form_data ) : <TAB> provider_names = dict ( get_all_payment_providers ( ) ) <TAB> payments = OrderPayment. objects. filter ( <TAB> <TAB> order__event__in = self. events, state__in = form_data. get ( ""payment_states"", [ ] ) <TAB> ). order_by ( ""created"" ) <TAB> refunds = OrderRefund. objects. filter ( <TAB> <TAB> order__event__in = self. events, state__in = form_data. get ( ""refund_states"", [ ] ) <TAB> ). order_by ( ""created"" ) <TAB> objs = sorted ( list ( payments ) + list ( refunds ), key = lambda o : o. created ) <TAB> headers = [ <TAB> <TAB> _ ( ""Event slug"" ), <TAB> <TAB> _ ( ""Order"" ), <TAB> <TAB> _ ( ""Payment ID"" ), <TAB> <TAB> _ ( ""Creation date"" ), <TAB> <TAB> _ ( ""Completion date"" ), <TAB> <TAB> _ ( ""Status"" ), <TAB> <TAB> _ ( ""Status code"" ), <TAB> <TAB> _ ( ""Amount"" ), <TAB> <TAB> _ ( ""Payment method"" ), <TAB> ] <TAB> yield headers <TAB> yield self. ProgressSetTotal ( total = len ( objs ) ) <TAB> for obj in objs : <TAB> <TAB> tz = pytz. timezone ( obj. order. event. settings. timezone ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> d2 = obj. payment_date. astimezone ( tz ). date ( ). strftime ( ""%Y-%m-%d"" ) <TAB> <TAB> elif isinstance ( obj, OrderRefund ) and obj. execution_date : <TAB> <TAB> <TAB> d2 = obj. execution_date. astimezone ( tz ). date ( ). strftime ( ""%Y-%m-%d"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> d2 = """" <TAB> <TAB> row = [ <TAB> <TAB> <",False,"isinstance(obj, OrderPayment) and obj.payment_date","isinstance(obj, OrderPayment)",0.6484655141830444
|
||
|
4673,"def process ( self, resources ) : <TAB> wafs = self. manager. get_resource_manager ( ""waf"" ). resources ( ) <TAB> waf_name_id_map = { w [ ""Name"" ] : w [ ""WebACLId"" ] for w in wafs } <TAB> target_acl = self. data. get ( ""web-acl"" ) <TAB> target_acl_id = waf_name_id_map. get ( target_acl, target_acl ) <TAB> if target_acl_id not in waf_name_id_map. values ( ) : <TAB> <TAB> raise ValueError ( ""invalid web acl: %s"" % ( target_acl_id ) ) <TAB> client = local_session ( self. manager. session_factory ). client ( ""cloudfront"" ) <TAB> force = self. data. get ( ""force"", False ) <TAB> for r in resources : <TAB> <TAB> if r. get ( ""WebACLId"" ) and not force : <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> result = client. get_distribution_config ( Id = r [ ""Id"" ] ) <TAB> <TAB> config = result [ ""DistributionConfig"" ] <TAB> <TAB> config [ ""WebACLId"" ] = target_acl_id <TAB> <TAB> self. retry ( <TAB> <TAB> <TAB> client. update_distribution, <TAB> <TAB> <TAB> Id = r [ ""Id"" ], <TAB> <TAB> <TAB> DistributionConfig = config, <TAB> <TAB> <TAB> IfMatch = result [ ""ETag"" ], <TAB> <TAB> )",False,r.get('WebACLId') == target_acl_id,r.get('NoSuchDistributionId') and force,0.6697400808334351
|
||
|
4674,"def test_launches_cluster_with_telemetry_client_timeout_enabled ( self ) : <TAB> cfg = config. Config ( ) <TAB> cfg. add ( config. Scope. application, ""client"", ""hosts"", self. test_host ) <TAB> cfg. add ( config. Scope. application, ""client"", ""options"", self. client_options ) <TAB> cfg. add ( config. Scope. application, ""mechanic"", ""telemetry.devices"", [ ] ) <TAB> cfg. add ( config. Scope. application, ""mechanic"", ""telemetry.params"", { } ) <TAB> cfg. add ( config. Scope. application, ""mechanic"", ""preserve.install"", False ) <TAB> cluster_launcher = launcher. ClusterLauncher ( <TAB> <TAB> cfg, MockMetricsStore ( ), client_factory_class = MockClientFactory <TAB> ) <TAB> cluster = cluster_launcher. start ( ) <TAB> for telemetry_device in cluster. telemetry. devices : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for _, client in telemetry_device. clients. items ( ) : <TAB> <TAB> <TAB> <TAB> self. assertDictEqual ( <TAB> <TAB> <TAB> <TAB> <TAB> { ""retry-on-timeout"" : True, ""timeout"" : 60 }, client. client_options <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. assertDictEqual ( <TAB> <TAB> <TAB> <TAB> { ""retry-on-timeout"" : True, ""timeout"" : 60 }, <TAB> <TAB> <TAB> <TAB> telemetry_device. client. client_options, <TAB> <TAB> <TAB> )",False,"hasattr(telemetry_device, 'clients')",telemetry_device.clients,0.6493241190910339
|
||
|
4675,"def setup_key_pair ( self, context ) : <TAB> key_name = ""%s%s"" % ( context. project_id, FLAGS. vpn_key_suffix ) <TAB> try : <TAB> <TAB> result = cloud. _gen_key ( context, context. user_id, key_name ) <TAB> <TAB> private_key = result [ ""private_key"" ] <TAB> <TAB> key_dir = os. path. join ( FLAGS. keys_path, context. user_id ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> os. makedirs ( key_dir ) <TAB> <TAB> key_path = os. path. join ( key_dir, ""%s.pem"" % key_name ) <TAB> <TAB> with open ( key_path, ""w"" ) as f : <TAB> <TAB> <TAB> f. write ( private_key ) <TAB> except ( exception. Duplicate, os. error, IOError ) : <TAB> <TAB> pass <TAB> return key_name",True,not os.path.exists(key_dir),not os.path.exists(key_dir),0.6468414068222046
|
||
|
4676,"def mouse_move ( self, ips, x, y, btn, ** key ) : <TAB> if ips. roi == None : <TAB> <TAB> return <TAB> lim = 5.0 / key [ ""canvas"" ]. get_scale ( ) <TAB> if btn == None : <TAB> <TAB> self. cursor = wx. CURSOR_CROSS <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. cursor = wx. CURSOR_HAND <TAB> elif btn == 1 : <TAB> <TAB> if self. doing : <TAB> <TAB> <TAB> self. helper. addpoint ( ( x, y ) ) <TAB> <TAB> elif self. curobj : <TAB> <TAB> <TAB> ips. roi. draged ( self. odx, self. ody, x, y, ips. cur, self. curobj ) <TAB> <TAB> ips. update ( ) <TAB> self. odx, self. ody = x, y",False,"ips.roi.snap(x, y, ips.cur, lim) != None",self.handshaker,0.660293698310852
|
||
|
4677,"def get_files ( self, dirname ) : <TAB> if not self. _data. has_key ( dirname ) : <TAB> <TAB> self. _create ( dirname ) <TAB> else : <TAB> <TAB> new_time = self. _changed ( dirname ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _update ( dirname, new_time ) <TAB> <TAB> <TAB> dcLog. debug ( ""==> "" + ""\t\n"". join ( self. _data [ dirname ] [ ""flist"" ] ) ) <TAB> return self. _data [ dirname ] [ ""flist"" ]",True,new_time,new_time,0.6736978888511658
|
||
|
4678,"def findControlPointsInMesh ( glyph, va, subsegments ) : <TAB> controlPointIndices = np. zeros ( ( len ( va ), 1 ) ) <TAB> index = 0 <TAB> for i, c in enumerate ( subsegments ) : <TAB> <TAB> segmentCount = len ( glyph. contours [ i ]. segments ) - 1 <TAB> <TAB> for j, s in enumerate ( c ) : <TAB> <TAB> <TAB> if j < segmentCount : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> controlPointIndices [ index ] = 1 <TAB> <TAB> <TAB> index += s [ 1 ] <TAB> return controlPointIndices",False,glyph.contours[i].segments[j].type == 'line',index >= len(s),0.6512120962142944
|
||
|
4679,"def deleteItem ( self, path_id, cu = None ) : <TAB> with self. connect ( commit = True, cu = cu ) as cu : <TAB> <TAB> stmt = ""select path_id from hierarchy where parent_path_id =?"" <TAB> <TAB> cu. execute ( stmt, ( path_id, ) ) <TAB> <TAB> children = cu. fetchall ( ) <TAB> <TAB> for child_id in children : <TAB> <TAB> <TAB> self. deleteItem ( child_id [ 0 ], cu ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> path = self. getPath ( path_id, cu ) <TAB> <TAB> tableNames = [ <TAB> <TAB> <TAB> ""common_details"", <TAB> <TAB> <TAB> ""common_tool_details"", <TAB> <TAB> <TAB> ""misc_properties"", <TAB> <TAB> <TAB> ""hierarchy"", <TAB> <TAB> <TAB> ""favorites"", <TAB> <TAB> ] <TAB> <TAB> res = self. getValuesFromTableByKey ( <TAB> <TAB> <TAB> ""common_details"", [ ""type"" ], ""path_id"", path_id, cu <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> tool_type = res [ 0 ] <TAB> <TAB> <TAB> if tool_type in [ <TAB> <TAB> <TAB> <TAB> ""snippet"", <TAB> <TAB> <TAB> <TAB> ""macro"", <TAB> <TAB> <TAB> <TAB> ""command"", <TAB> <TAB> <TAB> <TAB> ""menu"", <TAB> <TAB> <TAB> <TAB> ""toolbar"", <TAB> <TAB> <TAB> <TAB> ""tutorial"", <TAB> <TAB> <TAB> ] : <TAB> <TAB> <TAB> <TAB> tableNames. append ( tool_type ) <TAB> <TAB> for t in tableNames : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> cu. execute (",True,res,res,0.6974622011184692
|
||
|
4680,"def apply_upstream_proxy_settings ( ) : <TAB> <TAB> if config. SOCKS5_HOST and config. SOCKS5_PORT : <TAB> <TAB> import socks <TAB> <TAB> print_err ( <TAB> <TAB> <TAB> ""Socket-proxy mode activated, it is incompatible with advertising and uvloop"" <TAB> <TAB> ) <TAB> <TAB> socks. set_default_proxy ( <TAB> <TAB> <TAB> socks. PROXY_TYPE_SOCKS5, <TAB> <TAB> <TAB> config. SOCKS5_HOST, <TAB> <TAB> <TAB> config. SOCKS5_PORT, <TAB> <TAB> <TAB> username = config. SOCKS5_USER, <TAB> <TAB> <TAB> password = config. SOCKS5_PASS, <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> socket. origsocket = socket. socket <TAB> <TAB> <TAB> socket. socket = socks. socksocket <TAB> elif hasattr ( socket, ""origsocket"" ) : <TAB> <TAB> socket. socket = socket. origsocket <TAB> <TAB> del socket. origsocket",False,"not hasattr(socket, 'origsocket')","hasattr(socket, 'sock')",0.6515005826950073
|
||
|
4681,"def populate_pillars_to_tests ( ) : <TAB> for pillar in PILLARS : <TAB> <TAB> for test, test_info in list ( TESTS_MAP. items ( ) ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> PILLARS_TO_TESTS [ pillar ]. append ( test )",False,pillar in test_info[PILLARS_KEY],test_info and test_info['test'],0.656973659992218
|
||
|
4682,"def _SkipGroup ( buffer, pos, end ) : <TAB> """"""Skip sub-group. Returns the new position."""""" <TAB> while 1 : <TAB> <TAB> ( tag_bytes, pos ) = ReadTag ( buffer, pos ) <TAB> <TAB> new_pos = SkipField ( buffer, pos, end, tag_bytes ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return pos <TAB> <TAB> pos = new_pos",False,new_pos == -1,new_pos > pos,0.6604567170143127
|
||
|
4683,"def filter_tasks ( self, task_types = None, task_states = None, task_text = None ) : <TAB> tasks = self. api. tasks ( self. id ). get ( ""tasks"", { } ) <TAB> if tasks and tasks. get ( ""task"" ) : <TAB> <TAB> return [ <TAB> <TAB> <TAB> Task ( self, task ) <TAB> <TAB> <TAB> for task in tasks. get ( ""task"", [ ] ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> and ( not task_states or task [ ""state"" ]. lower ( ) in task_states ) <TAB> <TAB> <TAB> and ( not task_text or task_text. lower ( ) in str ( task ). lower ( ) ) <TAB> <TAB> ] <TAB> else : <TAB> <TAB> return [ ]",False,not task_types or task['type'].lower() in task_types,task_types and task_states,0.6549599170684814
|
||
|
4684,"def better_default_encoder ( o ) : <TAB> if isinstance ( o, uuid. UUID ) : <TAB> <TAB> return o. hex <TAB> if isinstance ( o, datetime. datetime ) : <TAB> <TAB> return o. strftime ( ""%Y-%m-%dT%H:%M:%S.%fZ"" ) <TAB> if isinstance ( o, datetime. date ) : <TAB> <TAB> return o. isoformat ( ) <TAB> if isinstance ( o, datetime. time ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( ""JSON can't represent timezone-aware times."" ) <TAB> <TAB> r = o. isoformat ( ) <TAB> <TAB> if o. microsecond : <TAB> <TAB> <TAB> r = r [ : 12 ] <TAB> <TAB> return r <TAB> if isinstance ( o, ( set, frozenset ) ) : <TAB> <TAB> return list ( o ) <TAB> if isinstance ( o, decimal. Decimal ) : <TAB> <TAB> return str ( o ) <TAB> if isinstance ( o, Enum ) : <TAB> <TAB> return o. value <TAB> if callable ( o ) : <TAB> <TAB> return ""<function>"" <TAB> raise TypeError ( repr ( o ) + "" is not JSON serializable"" )",False,is_aware(o),o.tzinfo,0.654313325881958
|
||
|
4685,"def _api_change_cat ( name, output, kwargs ) : <TAB> """"""API: accepts output, value(=nzo_id), value2(=category)"""""" <TAB> value = kwargs. get ( ""value"" ) <TAB> value2 = kwargs. get ( ""value2"" ) <TAB> if value and value2 : <TAB> <TAB> nzo_id = value <TAB> <TAB> cat = value2 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> cat = None <TAB> <TAB> result = sabnzbd. NzbQueue. change_cat ( nzo_id, cat ) <TAB> <TAB> return report ( output, keyword = ""status"", data = bool ( result > 0 ) ) <TAB> else : <TAB> <TAB> return report ( output, _MSG_NO_VALUE )",False,cat == 'None',cat,0.6571664810180664
|
||
|
4686,"def build ( cls, path = None ) : <TAB> """"""Build config instance."""""" <TAB> loader = get_yaml_loader ( ) <TAB> with resource_stream ( ""knowit"", ""defaults.yml"" ) as stream : <TAB> <TAB> cfgs = [ yaml. load ( stream, Loader = loader ) ] <TAB> if path : <TAB> <TAB> with open ( path, ""r"" ) as stream : <TAB> <TAB> <TAB> cfgs. append ( yaml. load ( stream, Loader = loader ) ) <TAB> profiles_data = { } <TAB> for cfg in cfgs : <TAB> <TAB> if ""profiles"" in cfg : <TAB> <TAB> <TAB> profiles_data. update ( cfg [ ""profiles"" ] ) <TAB> knowledge_data = { } <TAB> for cfg in cfgs : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> knowledge_data. update ( cfg [ ""knowledge"" ] ) <TAB> data = { ""general"" : { } } <TAB> for class_name, data_map in knowledge_data. items ( ) : <TAB> <TAB> data. setdefault ( class_name, { } ) <TAB> <TAB> for code, detection_values in data_map. items ( ) : <TAB> <TAB> <TAB> alias_map = ( profiles_data. get ( class_name ) or { } ). get ( code ) or { } <TAB> <TAB> <TAB> alias_map. setdefault ( ""code"", code ) <TAB> <TAB> <TAB> alias_map. setdefault ( ""default"", alias_map [ ""code"" ] ) <TAB> <TAB> <TAB> alias_map. setdefault ( ""human"", alias_map [ ""default"" ] ) <TAB> <TAB> <TAB> alias_map. setdefault ( ""technical"", alias_map [ ""human"" ] ) <TAB> <TAB> <TAB> value = _Value ( <TAB> <TAB> <TAB> <TAB> ** { k : v for k, v in alias_map. items ( ) if k in _valid_aliases } <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB>",True,'knowledge' in cfg,'knowledge' in cfg,0.66872638463974
|
||
|
4687,"def extend_nodelist ( self, nodelist, node, token ) : <TAB> if node. must_be_first and nodelist : <TAB> <TAB> try : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise AttributeError <TAB> <TAB> except AttributeError : <TAB> <TAB> <TAB> raise TemplateSyntaxError ( <TAB> <TAB> <TAB> <TAB> ""%r must be the first tag in the template."" % node <TAB> <TAB> <TAB> ) <TAB> if isinstance ( nodelist, NodeList ) and not isinstance ( node, TextNode ) : <TAB> <TAB> nodelist. contains_nontext = True <TAB> nodelist. append ( node )",False,nodelist.contains_nontext,token.tag != token.tag,0.6596221923828125
|
||
|
4688,"def make_append ( bases, cols, calls, glyph ) : <TAB> names = ( ""_{0}"". format ( i ) for i in count ( ) ) <TAB> inputs = list ( bases ) + list ( cols ) <TAB> signature = [ next ( names ) for i in inputs ] <TAB> arg_lk = dict ( zip ( inputs, signature ) ) <TAB> local_lk = { } <TAB> namespace = { } <TAB> body = [ ] <TAB> ndims = glyph. ndims <TAB> if ndims is not None : <TAB> <TAB> subscript = "", "". join ( [ ""i"" + str ( n ) for n in range ( ndims ) ] ) <TAB> else : <TAB> <TAB> subscript = None <TAB> for func, bases, cols, temps in calls : <TAB> <TAB> local_lk. update ( zip ( temps, ( next ( names ) for i in temps ) ) ) <TAB> <TAB> func_name = next ( names ) <TAB> <TAB> namespace [ func_name ] = func <TAB> <TAB> args = [ arg_lk [ i ] for i in bases ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> args. extend ( ""{0}"". format ( arg_lk [ i ] ) for i in cols ) <TAB> <TAB> else : <TAB> <TAB> <TAB> args. extend ( ""{0}[{1}]"". format ( arg_lk [ i ], subscript ) for i in cols ) <TAB> <TAB> args. extend ( [ local_lk [ i ] for i in temps ] ) <TAB> <TAB> body. append ( ""{0}(x, y, {1})"". format ( func_name, "", "". join ( args ) ) ) <TAB> body = [ <TAB> <TAB> ""{0} = {1}[y, x]"". format ( name, arg_lk [ agg ] ) for agg, name in local_lk. items ( ) <TAB> ] + body <TAB> if<mask> : <TAB> <TAB> code = ( ""def append(x, y, {0}):\n"" "" {1}"" ). format ( <TAB> <TAB",False,ndims is None,cols > 0,0.6740870475769043
|
||
|
4689,"def translate ( ) : <TAB> assert Lex. next ( ) is AttributeList <TAB> reader. read ( ) <TAB> attrs = { } <TAB> d = AttributeList. match. groupdict ( ) <TAB> for k, v in d. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if k == ""attrlist"" : <TAB> <TAB> <TAB> <TAB> v = subs_attrs ( v ) <TAB> <TAB> <TAB> <TAB> if v : <TAB> <TAB> <TAB> <TAB> <TAB> parse_attributes ( v, attrs ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> AttributeList. attrs [ k ] = v <TAB> AttributeList. subs ( attrs ) <TAB> AttributeList. attrs. update ( attrs )",False,v is not None,k in [TAB>,0.6594157218933105
|
||
|
4690,"def parse_changelog ( ) : <TAB> with open ( ""CHANGES"" ) as f : <TAB> <TAB> lineiter = iter ( f ) <TAB> <TAB> for line in lineiter : <TAB> <TAB> <TAB> match = re. search ( ""^Version\s+(.*)"", line. strip ( ) ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> version = match. group ( 1 ). strip ( ) <TAB> <TAB> <TAB> if lineiter. next ( ). count ( ""-"" )!= len ( match. group ( 0 ) ) : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> while 1 : <TAB> <TAB> <TAB> <TAB> change_info = lineiter. next ( ). strip ( ) <TAB> <TAB> <TAB> <TAB> if change_info : <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> match = re. search ( r""Released on (\w+\s+\d+,\s+\d+)"", change_info ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> datestr = match. groups ( ) [ 0 ] <TAB> <TAB> <TAB> return version, parse_date ( datestr )",False,match is None,not match,0.6621959209442139
|
||
|
4691,"def setinfo ( self, path, info ) : <TAB> <TAB> self. check ( ) <TAB> _path = self. validatepath ( path ) <TAB> sys_path = self. _to_sys_path ( _path ) <TAB> if not os. path. exists ( sys_path ) : <TAB> <TAB> raise errors. ResourceNotFound ( path ) <TAB> if ""details"" in info : <TAB> <TAB> details = info [ ""details"" ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> _accessed = typing. cast ( int, details. get ( ""accessed"" ) ) <TAB> <TAB> <TAB> _modified = typing. cast ( int, details. get ( ""modified"", _accessed ) ) <TAB> <TAB> <TAB> accessed = int ( _modified if _accessed is None else _accessed ) <TAB> <TAB> <TAB> modified = int ( _modified ) <TAB> <TAB> <TAB> if accessed is not None or modified is not None : <TAB> <TAB> <TAB> <TAB> with convert_os_errors ( ""setinfo"", path ) : <TAB> <TAB> <TAB> <TAB> <TAB> os. utime ( sys_path, ( accessed, modified ) )",False,'accessed' in details or 'modified' in details,details,0.6547573804855347
|
||
|
4692,"def main ( ) : <TAB> filenames = ParseArguments ( sys. argv [ 1 : ] ) <TAB> backup_err = sys. stderr <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> sys. stderr = codecs. StreamReader ( sys. stderr, ""replace"" ) <TAB> <TAB> _cpplint_state. ResetErrorCounts ( ) <TAB> <TAB> for filename in filenames : <TAB> <TAB> <TAB> ProcessFile ( filename, _cpplint_state. verbose_level ) <TAB> <TAB> _cpplint_state. PrintErrorCounts ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> sys. stderr. write ( _cpplint_state. FormatJUnitXML ( ) ) <TAB> finally : <TAB> <TAB> sys. stderr = backup_err <TAB> sys. exit ( _cpplint_state. error_count > 0 )",False,_cpplint_state.output_format == 'junit',backup_err,0.6491585969924927
|
||
|
4693,"def write ( self, text ) : <TAB> if not isinstance ( text, bytes ) : <TAB> <TAB> if not isinstance ( text, text_type ) : <TAB> <TAB> <TAB> msg = ""You can only write str to a Response.body_file, not %s"" <TAB> <TAB> <TAB> raise TypeError ( msg % type ( text ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> msg = ""You can only write text to Response if charset has "" ""been set"" <TAB> <TAB> <TAB> raise TypeError ( msg ) <TAB> <TAB> text = text. encode ( self. charset ) <TAB> app_iter = self. _app_iter <TAB> if not isinstance ( app_iter, list ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> new_app_iter = self. _app_iter = list ( app_iter ) <TAB> <TAB> finally : <TAB> <TAB> <TAB> iter_close ( app_iter ) <TAB> <TAB> app_iter = new_app_iter <TAB> <TAB> self. content_length = sum ( len ( chunk ) for chunk in app_iter ) <TAB> app_iter. append ( text ) <TAB> if self. content_length is not None : <TAB> <TAB> self. content_length += len ( text )",False,not self.charset,self.charset is None,0.6643362045288086
|
||
|
4694,"def leaveISP ( self ) : <TAB> if self. serial is not None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ispBase. IspError ( ""Failed to leave programming mode"" ) <TAB> <TAB> ret = self. serial <TAB> <TAB> self. serial = None <TAB> <TAB> return ret <TAB> return None",False,"self.sendMessage([17]) != [17, 0]",self.serial != None and self.serial != None,0.6541696786880493
|
||
|
4695,"def clean_items ( event, items, variations ) : <TAB> for item in items : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValidationError ( _ ( ""One or more items do not belong to this event."" ) ) <TAB> <TAB> if item. has_variations : <TAB> <TAB> <TAB> if not any ( var. item == item for var in variations ) : <TAB> <TAB> <TAB> <TAB> raise ValidationError ( <TAB> <TAB> <TAB> <TAB> <TAB> _ ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""One or more items has variations but none of these are in the variations list."" <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> )",False,event != item.event,event.type != item.type,0.6605589389801025
|
||
|
4696,"def handle ( self, ** options ) : <TAB> <TAB> from django. conf import settings, Settings, global_settings <TAB> <TAB> settings. _setup ( ) <TAB> user_settings = module_to_dict ( settings. _wrapped ) <TAB> default = options [ ""default"" ] <TAB> default_settings = module_to_dict ( Settings ( default ) if default else global_settings ) <TAB> output = [ ] <TAB> for key in sorted ( user_settings ) : <TAB> <TAB> if key not in default_settings : <TAB> <TAB> <TAB> output. append ( ""%s = %s ###"" % ( key, user_settings [ key ] ) ) <TAB> <TAB> elif user_settings [ key ]!= default_settings [ key ] : <TAB> <TAB> <TAB> output. append ( ""%s = %s"" % ( key, user_settings [ key ] ) ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> output. append ( ""### %s = %s"" % ( key, user_settings [ key ] ) ) <TAB> return ""\n"". join ( output )",False,options['all'],user_settings[key] != default_settings[key],0.6573597192764282
|
||
|
4697,"def bprop_slice ( self, x, S, Q, padding, stride, dilation ) : <TAB> qs = x - ( dilation * ( S - 1 ) - padding ) <TAB> f1 = None <TAB> for s in range ( S ) : <TAB> <TAB> q = qs + s * dilation <TAB> <TAB> if q % stride == 0 : <TAB> <TAB> <TAB> q //= stride <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> if f1 is None : <TAB> <TAB> <TAB> <TAB> <TAB> f1 = s <TAB> <TAB> <TAB> <TAB> <TAB> x1 = q <TAB> <TAB> <TAB> <TAB> f2 = s <TAB> <TAB> <TAB> <TAB> x2 = q <TAB> if f1 is None : <TAB> <TAB> return ( slice ( 0, 0, 1 ), slice ( 0, 0, 1 ), 0 ) <TAB> f_step = 1 <TAB> while ( ( f_step * dilation ) % stride )!= 0 : <TAB> <TAB> f_step += 1 <TAB> x_step = ( f_step * dilation ) // stride <TAB> return ( slice ( f1, f2 + 1, f_step ), slice ( x1, x2 + 1, x_step ), 0 )",False,q >= 0 and q < Q,q % stride == 0,0.6630949378013611
|
||
|
4698,"def find_symbol ( self, r, globally = False ) : <TAB> query = self. view. substr ( self. view. word ( r ) ) <TAB> fname = self. view. file_name ( ). replace ( ""\\"", ""/"" ) <TAB> locations = self. view. window ( ). lookup_symbol_in_index ( query ) <TAB> if not locations : <TAB> <TAB> return <TAB> try : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> location = [ hit [ 2 ] for hit in locations if fname. endswith ( hit [ 1 ] ) ] [ 0 ] <TAB> <TAB> <TAB> return location [ 0 ] - 1, location [ 1 ] - 1 <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return locations [ 0 ] <TAB> except IndexError : <TAB> <TAB> return",False,not globally,globally,0.6732712984085083
|
||
|
4699,"def put ( self, session ) : <TAB> with sess_lock : <TAB> <TAB> self. parent. put ( session ) <TAB> <TAB> <TAB> <TAB> for sp in self. skip_paths : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> if session. sid in self. _cache : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> del self. _cache [ session. sid ] <TAB> <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> self. _cache [ session. sid ] = session <TAB> self. _normalize ( )",False,request.path.startswith(sp),"sp in [sp, sp.TAB]",0.647872805595398
|
||
|
4700,"def prepare_wrap ( self, msg ) : <TAB> obscured = self. obscured_headers <TAB> wrapped = self. wrapped_headers <TAB> obscured_set = set ( [ ] ) <TAB> to_delete = { } <TAB> for ( h, header_value ) in msg. items ( ) : <TAB> <TAB> if not header_value : <TAB> <TAB> <TAB> continue <TAB> <TAB> hl = h. lower ( ) <TAB> <TAB> if hl == ""mime-version"" : <TAB> <TAB> <TAB> to_delete [ h ] = True <TAB> <TAB> elif not hl. startswith ( ""content-"" ) : <TAB> <TAB> <TAB> if hl in obscured : <TAB> <TAB> <TAB> <TAB> obscured_set. add ( h ) <TAB> <TAB> <TAB> <TAB> oh = obscured [ hl ] ( header_value ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> self. container. add_header ( h, oh ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. container. add_header ( h, header_value ) <TAB> <TAB> <TAB> if hl not in wrapped and hl not in obscured : <TAB> <TAB> <TAB> <TAB> to_delete [ h ] = True <TAB> for h in to_delete : <TAB> <TAB> while h in msg : <TAB> <TAB> <TAB> del msg [ h ] <TAB> if hasattr ( msg, ""signature_info"" ) : <TAB> <TAB> self. container. signature_info = msg. signature_info <TAB> <TAB> self. container. encryption_info = msg. encryption_info <TAB> return self. force_display_headers ( msg, obscured_set )",False,oh,h in wrapped,0.7205325365066528
|
||
|
4701,"def _resolve_register_argument ( self, call_stmt, arg_loc ) : <TAB> size = arg_loc. size <TAB> offset = arg_loc. _fix_offset ( None, size, arch = self. project. arch ) <TAB> if self. _reaching_definitions is not None : <TAB> <TAB> <TAB> <TAB> ins_addr = call_stmt. tags [ ""ins_addr"" ] <TAB> <TAB> try : <TAB> <TAB> <TAB> rd = self. _reaching_definitions. get_reaching_definitions_by_insn ( <TAB> <TAB> <TAB> <TAB> ins_addr, OP_BEFORE <TAB> <TAB> <TAB> ) <TAB> <TAB> except KeyError : <TAB> <TAB> <TAB> rd = None <TAB> <TAB> if rd is not None : <TAB> <TAB> <TAB> defs = rd. register_definitions. get_variables_by_offset ( offset ) <TAB> <TAB> <TAB> if not defs : <TAB> <TAB> <TAB> <TAB> l. warning ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Did not find any reaching definition for register %s at instruction %x."", <TAB> <TAB> <TAB> <TAB> <TAB> arg_loc, <TAB> <TAB> <TAB> <TAB> <TAB> ins_addr, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> elif len ( defs ) > 1 : <TAB> <TAB> <TAB> <TAB> l. warning ( <TAB> <TAB> <TAB> <TAB> <TAB> ""TODO: More than one reaching definition are found at instruction %x."", <TAB> <TAB> <TAB> <TAB> <TAB> ins_addr, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> def_ = next ( iter ( defs ) ) <TAB> <TAB> <TAB> <TAB> var_or_value = self. _find_variable_from_definition (",False,var_or_value is not None,len(defs) > 0,0.6555719971656799
|
||
|
4702,"def test_async_iterator ( app ) : <TAB> async with new_stream ( app ) as stream : <TAB> <TAB> for i in range ( 100 ) : <TAB> <TAB> <TAB> await stream. channel. deliver ( message ( key = i, value = i ) ) <TAB> <TAB> received = 0 <TAB> <TAB> async for value in stream : <TAB> <TAB> <TAB> assert value == received <TAB> <TAB> <TAB> received += 1 <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> assert await channel_empty ( stream. channel )",False,received >= 100,received >= 6,0.6845225095748901
|
||
|
4703,"def emit_default ( self ) : <TAB> """"""emit the action taken when we did not hit a valid hash table entry"""""" <TAB> actions = [ ] <TAB> for action in self. default_actions : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> s = ""return %s"" % action. get_str_value ( ) <TAB> <TAB> <TAB> actions. append ( s ) <TAB> <TAB> if action. is_field_binding ( ) : <TAB> <TAB> <TAB> val = action. get_str_value ( ) <TAB> <TAB> <TAB> fb = action. field_name. lower ( ) <TAB> <TAB> <TAB> s = ""%s_set_%s(%s,%s)"" % ( <TAB> <TAB> <TAB> <TAB> self. strings_dict [ ""op_accessor"" ], <TAB> <TAB> <TAB> <TAB> fb, <TAB> <TAB> <TAB> <TAB> self. strings_dict [ ""obj_str"" ], <TAB> <TAB> <TAB> <TAB> val, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> actions. append ( s ) <TAB> return actions",False,action.is_return(),action.is_hash_table(),0.6543012261390686
|
||
|
4704,"def check_messages ( messages ) : <TAB> for message_type in messages : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> error_list. append ( <TAB> <TAB> <TAB> <TAB> _ ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Message type '{}' invalid, must be either'message' or 'body'"" <TAB> <TAB> <TAB> <TAB> ). format ( message_type ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> continue <TAB> <TAB> message = messages [ message_type ] <TAB> <TAB> if message is None : <TAB> <TAB> <TAB> continue <TAB> <TAB> if not isinstance ( message, str ) : <TAB> <TAB> <TAB> error_list. append ( <TAB> <TAB> <TAB> <TAB> _ ( ""Expected string for '{}', found {}, "" ). format ( <TAB> <TAB> <TAB> <TAB> <TAB> message_type, type ( message ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if message_type == ""message"" : <TAB> <TAB> <TAB> if ""\n"" in message : <TAB> <TAB> <TAB> <TAB> error_list. append ( <TAB> <TAB> <TAB> <TAB> <TAB> _ ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""Messages cannot contain newlines (found newline in {} event)"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> event <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> collected_messages. append ( message )",False,"message_type not in ('message', 'body')",message_type == 'body',0.6541242599487305
|
||
|
4705,"def get_project_dir ( env ) : <TAB> project_file = workon_home / env / "".project"" <TAB> if project_file. exists ( ) : <TAB> <TAB> with project_file. open ( ) as f : <TAB> <TAB> <TAB> project_dir = f. readline ( ). strip ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return project_dir <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> err ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Corrupted or outdated:"", <TAB> <TAB> <TAB> <TAB> <TAB> project_file, <TAB> <TAB> <TAB> <TAB> <TAB> ""\nDirectory"", <TAB> <TAB> <TAB> <TAB> <TAB> project_dir, <TAB> <TAB> <TAB> <TAB> <TAB> ""doesn't exist."", <TAB> <TAB> <TAB> <TAB> )",False,os.path.exists(project_dir),project_dir.exists(),0.6498926877975464
|
||
|
4706,"def build_packages ( targeted_packages, distribution_directory, is_dev_build = False ) : <TAB> <TAB> for package_root in targeted_packages : <TAB> <TAB> service_hierarchy = os. path. join ( os. path. basename ( package_root ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> verify_update_package_requirement ( package_root ) <TAB> <TAB> print ( ""Generating Package Using Python {}"". format ( sys. version ) ) <TAB> <TAB> run_check_call ( <TAB> <TAB> <TAB> [ <TAB> <TAB> <TAB> <TAB> sys. executable, <TAB> <TAB> <TAB> <TAB> build_packing_script_location, <TAB> <TAB> <TAB> <TAB> ""--dest"", <TAB> <TAB> <TAB> <TAB> os. path. join ( distribution_directory, service_hierarchy ), <TAB> <TAB> <TAB> <TAB> package_root, <TAB> <TAB> <TAB> ], <TAB> <TAB> <TAB> root_dir, <TAB> <TAB> )",True,is_dev_build,is_dev_build,0.6523603796958923
|
||
|
4707,"def _setResultsName ( self, name, listAllMatches = False ) : <TAB> if __diag__. warn_name_set_on_empty_Forward : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> warnings. warn ( <TAB> <TAB> <TAB> <TAB> ""{0}: setting results name {0!r} on {1} expression "" <TAB> <TAB> <TAB> <TAB> ""that has no contained expression"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> ""warn_name_set_on_empty_Forward"", name, type ( self ). __name__ <TAB> <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> <TAB> stacklevel = 3, <TAB> <TAB> <TAB> ) <TAB> return super ( Forward, self ). _setResultsName ( name, listAllMatches )",True,self.expr is None,self.expr is None,0.6563916206359863
|
||
|
4708,"def kill ( self, message = """" ) : <TAB> """"""Kills the frame"""""" <TAB> log. info ( ""Request recieved: kill"" ) <TAB> if self. frameAttendantThread is None : <TAB> <TAB> log. warning ( <TAB> <TAB> <TAB> ""Kill requested before frameAttendantThread is created "" <TAB> <TAB> <TAB> ""for: %s"" % self. frameId <TAB> <TAB> ) <TAB> elif self. frameAttendantThread. isAlive ( ) and self. pid is None : <TAB> <TAB> log. warning ( ""Kill requested before pid is available for: %s"" % self. frameId ) <TAB> elif self. frameAttendantThread. isAlive ( ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> if not self. killMessage and message : <TAB> <TAB> <TAB> <TAB> self. killMessage = message <TAB> <TAB> <TAB> rqd. rqutil. permissionsHigh ( ) <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> subprocess. Popen ( ""taskkill /F /T /PID %i"" % self. pid, shell = True ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> os. killpg ( self. pid, rqd. rqconstants. KILL_SIGNAL ) <TAB> <TAB> <TAB> finally : <TAB> <TAB> <TAB> <TAB> rqd. rqutil. permissionsLow ( ) <TAB> <TAB> except OSError as e : <TAB> <TAB> <TAB> log. warning ( <TAB> <TAB> <TAB> <TAB> ""kill() tried to kill a non-existant pid for: %s "" <TAB> <TAB> <TAB> <TAB> ""Error: %s"" % ( self. frameId, e ) <TAB> <TAB> <TAB> ) <TAB> <TAB> except Exception as e : <TAB> <TAB> <TAB> log. warning ( ""kill() encountered an unknown error: %",False,platform.system() == 'Windows',self.pid is not None,0.6574522256851196
|
||
|
4709,"def __init__ ( <TAB> self, <TAB> entity, <TAB> mapper, <TAB> selectable, <TAB> name, <TAB> with_polymorphic_mappers, <TAB> polymorphic_on, <TAB> _base_alias, <TAB> _use_mapper_path, <TAB> adapt_on_names, <TAB> represents_outer_join, ) : <TAB> self. entity = entity <TAB> self. mapper = mapper <TAB> self. selectable = selectable <TAB> self. name = name <TAB> self. with_polymorphic_mappers = with_polymorphic_mappers <TAB> self. polymorphic_on = polymorphic_on <TAB> self. _base_alias = _base_alias or self <TAB> self. _use_mapper_path = _use_mapper_path <TAB> self. represents_outer_join = represents_outer_join <TAB> self. _adapter = sql_util. ColumnAdapter ( <TAB> <TAB> selectable, <TAB> <TAB> equivalents = mapper. _equivalent_columns, <TAB> <TAB> adapt_on_names = adapt_on_names, <TAB> <TAB> anonymize_labels = True, <TAB> ) <TAB> self. _adapt_on_names = adapt_on_names <TAB> self. _target = mapper. class_ <TAB> for poly in self. with_polymorphic_mappers : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> setattr ( <TAB> <TAB> <TAB> <TAB> self. entity, <TAB> <TAB> <TAB> <TAB> poly. class_. __name__, <TAB> <TAB> <TAB> <TAB> AliasedClass ( <TAB> <TAB> <TAB> <TAB> <TAB> poly. class_, <TAB> <TAB> <TAB> <TAB> <TAB> selectable, <TAB> <TAB> <TAB> <TAB> <TAB> base_alias = self, <TAB> <TAB> <TAB> <TAB> <TAB> adapt_on_names = adapt_on_names, <TAB> <TAB> <TAB> <TAB> <TAB> use_mapper_path = _use_mapper_path",False,poly is not mapper,"hasattr(self, 'entity')",0.6842032670974731
|
||
|
4710,"def process_routine ( rootElt, obj, name, callables ) : <TAB> if inspect. isfunction ( obj ) : <TAB> <TAB> if _gIsPy3 : <TAB> <TAB> <TAB> argspec = inspect. getfullargspec ( obj ) <TAB> <TAB> else : <TAB> <TAB> <TAB> argspec = inspect. getargspec ( obj ) <TAB> <TAB> sig = name + inspect. formatargspec ( * argspec ) <TAB> else : <TAB> <TAB> sig = """" <TAB> doc = getdoc ( obj ) or None <TAB> call_sig_lines, description_lines = parsePyFuncDoc ( doc, [ sig ] ) <TAB> if description_lines : <TAB> <TAB> doc = ""\n"". join ( parseDocSummary ( description_lines ) ) <TAB> if call_sig_lines : <TAB> <TAB> signature = ""\n"". join ( call_sig_lines ) <TAB> else : <TAB> <TAB> signature = sig <TAB> if name == ""__init__"" : <TAB> <TAB> if doc == obj. __init__. __doc__ : <TAB> <TAB> <TAB> doc = None <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> signature = None <TAB> funcElt = SubElement ( rootElt, ""scope"", ilk = ""function"", name = name ) <TAB> if doc : <TAB> <TAB> funcElt. set ( ""doc"", doc ) <TAB> if signature : <TAB> <TAB> funcElt. set ( ""signature"", signature ) <TAB> callables [ name ] = funcElt",False,signature == obj.__init__.__doc__,rootElt,0.6579796075820923
|
||
|
4711,"def _pre_get_table ( self, _ctx, table_name ) : <TAB> vsctl_table = self. _get_table ( table_name ) <TAB> schema_helper = self. schema_helper <TAB> schema_helper. register_table ( vsctl_table. table_name ) <TAB> for row_id in vsctl_table. row_ids : <TAB> <TAB> if row_id. table : <TAB> <TAB> <TAB> schema_helper. register_table ( row_id. table ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> schema_helper. register_columns ( row_id. table, [ row_id. name_column ] ) <TAB> <TAB> if row_id. uuid_column : <TAB> <TAB> <TAB> schema_helper. register_columns ( row_id. table, [ row_id. uuid_column ] ) <TAB> return vsctl_table",True,row_id.name_column,row_id.name_column,0.6544754505157471
|
||
|
4712,"def polygons_to_edges_np ( obj, unique_edges = False, output_numpy = False ) : <TAB> result = [ ] <TAB> for pols in obj : <TAB> <TAB> if len ( pols ) == 0 : <TAB> <TAB> <TAB> result. append ( [ ] ) <TAB> <TAB> <TAB> continue <TAB> <TAB> regular_mesh = True <TAB> <TAB> try : <TAB> <TAB> <TAB> np_pols = array ( pols, dtype = int32 ) <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> regular_mesh = False <TAB> <TAB> if not regular_mesh : <TAB> <TAB> <TAB> if output_numpy : <TAB> <TAB> <TAB> <TAB> result. append ( pols_to_edges_irregular_mesh ( pols, unique_edges ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> result. append ( pols_to_edges_irregular_mesh ( pols, unique_edges ). tolist ( ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> edges = empty ( list ( np_pols. shape ) + [ 2 ], ""i"" ) <TAB> <TAB> <TAB> edges [ :, :, 0 ] = np_pols <TAB> <TAB> <TAB> edges [ :, 1 :, 1 ] = np_pols [ :, : - 1 ] <TAB> <TAB> <TAB> edges [ :, 0, 1 ] = np_pols [ :, - 1 ] <TAB> <TAB> <TAB> edges = edges. reshape ( - 1, 2 ) <TAB> <TAB> <TAB> if output_numpy : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> result. append ( unique ( sort ( edges ), axis = 0 ) ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> result. append ( edges ) <TAB> <TAB> <TAB> else : <TAB> <TAB",True,unique_edges,unique_edges,0.6735135316848755
|
||
|
4713,"def visible_settings ( self ) : <TAB> __settings__ = super ( EnhanceOrSuppressFeatures, self ). visible_settings ( ) <TAB> __settings__ += [ self. method ] <TAB> if self. method == ENHANCE : <TAB> <TAB> __settings__ += [ self. enhance_method ] <TAB> <TAB> self. object_size. min_value = 2 <TAB> <TAB> if self. enhance_method == E_DARK_HOLES : <TAB> <TAB> <TAB> __settings__ += [ self. hole_size ] <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> __settings__ += [ self. smoothing ] <TAB> <TAB> elif self. enhance_method == E_DIC : <TAB> <TAB> <TAB> __settings__ += [ self. smoothing, self. angle, self. decay ] <TAB> <TAB> elif self. enhance_method == E_NEURITES : <TAB> <TAB> <TAB> __settings__ += [ self. neurite_choice ] <TAB> <TAB> <TAB> if self. neurite_choice == N_GRADIENT : <TAB> <TAB> <TAB> <TAB> __settings__ += [ self. object_size ] <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> __settings__ += [ self. smoothing ] <TAB> <TAB> <TAB> __settings__ += [ self. wants_rescale ] <TAB> <TAB> elif self. enhance_method == E_SPECKLES : <TAB> <TAB> <TAB> __settings__ += [ self. object_size, self. speckle_accuracy ] <TAB> <TAB> <TAB> self. object_size. min_value = 3 <TAB> <TAB> else : <TAB> <TAB> <TAB> __settings__ += [ self. object_size ] <TAB> else : <TAB> <TAB> __settings__ += [ self. object_size ] <TAB> return __settings__",False,self.enhance_method == E_TEXTURE,self.enhance_method == E_TARK,0.6664944887161255
|
||
|
4714,"def parse_constraints_from_args ( args ) : <TAB> if not args. constraints : <TAB> <TAB> return [ ] <TAB> _constraints = [ ] <TAB> for constraint in args. constraints : <TAB> <TAB> if ARGS_SPLIT_TOKEN in constraint : <TAB> <TAB> <TAB> constraint_name, params = constraint. split ( ARGS_SPLIT_TOKEN ) <TAB> <TAB> <TAB> if constraint_name not in CONSTRAINT_CLASS_NAMES : <TAB> <TAB> <TAB> <TAB> raise ValueError ( f""Error: unsupported constraint {constraint_name}"" ) <TAB> <TAB> <TAB> _constraints. append ( <TAB> <TAB> <TAB> <TAB> eval ( f""{CONSTRAINT_CLASS_NAMES[constraint_name]}({params})"" ) <TAB> <TAB> <TAB> ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> _constraints. append ( eval ( f""{CONSTRAINT_CLASS_NAMES[constraint]}()"" ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise ValueError ( f""Error: unsupported constraint {constraint}"" ) <TAB> return _constraints",False,constraint in CONSTRAINT_CLASS_NAMES,constraint not inCONSTRAINT_CLASS_NAMES,0.6736607551574707
|
||
|
4715,"def on_pre_output_coercion ( <TAB> directive_args : Dict [ str, Any ], <TAB> next_directive : Callable, <TAB> value : Any, <TAB> ctx : Optional [ Any ], <TAB> info : ""ResolveInfo"", ) : <TAB> value = await next_directive ( value, ctx, info ) <TAB> if value is None : <TAB> <TAB> return value <TAB> try : <TAB> <TAB> py_enum = _ENUM_MAP [ directive_args [ ""name"" ] ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return [ None if item is None else py_enum ( item ). name for item in value ] <TAB> <TAB> return py_enum ( value ). name <TAB> except Exception : <TAB> <TAB> pass <TAB> return value",True,"isinstance(value, list)","isinstance(value, list)",0.6546279191970825
|
||
|
4716,"def cardsWithTags ( self, tagStr, search = ""and"" ) : <TAB> tagIds = [ ] <TAB> <TAB> for tag in tagStr. split ( "" "" ) : <TAB> <TAB> tag = tag. replace ( ""*"", ""%"" ) <TAB> <TAB> if ""%"" in tag : <TAB> <TAB> <TAB> ids = self. s. column0 ( ""select id from tags where tag like :tag"", tag = tag ) <TAB> <TAB> <TAB> if search == ""and"" and not ids : <TAB> <TAB> <TAB> <TAB> return [ ] <TAB> <TAB> <TAB> tagIds. append ( ids ) <TAB> <TAB> else : <TAB> <TAB> <TAB> id = self. s. scalar ( ""select id from tags where tag = :tag"", tag = tag ) <TAB> <TAB> <TAB> if search == ""and"" and not id : <TAB> <TAB> <TAB> <TAB> return [ ] <TAB> <TAB> <TAB> tagIds. append ( id ) <TAB> <TAB> if search == ""or"" : <TAB> <TAB> return self. s. column0 ( <TAB> <TAB> <TAB> ""select cardId from cardTags where tagId in %s"" % ids2str ( tagIds ) <TAB> <TAB> ) <TAB> else : <TAB> <TAB> <TAB> <TAB> l = [ ] <TAB> <TAB> for ids in tagIds : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> l. append ( ""select cardId from cardTags where tagId in %s"" % ids2str ( ids ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> l. append ( ""select cardId from cardTags where tagId = %d"" % ids ) <TAB> <TAB> q = "" intersect "". join ( l ) <TAB> <TAB> return self. s. column0 ( q )",False,"isinstance(ids, types.ListType)",ids,0.6511952877044678
|
||
|
4717,def remove_last_statement ( node ) : <TAB> stmt = None <TAB> if type ( node ) is CodeNode : <TAB> <TAB> stmt = remove_last_statement ( node. node ) <TAB> elif type ( node ) is ailment. Block : <TAB> <TAB> stmt = node. statements [ - 1 ] <TAB> <TAB> node. statements = node. statements [ : - 1 ] <TAB> elif type ( node ) is MultiNode : <TAB> <TAB> if node. nodes : <TAB> <TAB> <TAB> stmt = remove_last_statement ( node. nodes [ - 1 ] ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> node. nodes = node. nodes [ : - 1 ] <TAB> elif type ( node ) is SequenceNode : <TAB> <TAB> if node. nodes : <TAB> <TAB> <TAB> stmt = remove_last_statement ( node. nodes [ - 1 ] ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> node. nodes = node. nodes [ : - 1 ] <TAB> else : <TAB> <TAB> raise NotImplementedError ( ) <TAB> return stmt,False,BaseNode.test_empty_node(node.nodes[-1]),node.nodes,0.6514387726783752
|
||
|
4718,"def update_streaming_endpoint_setter ( <TAB> client, <TAB> resource_group_name, <TAB> account_name, <TAB> streaming_endpoint_name, <TAB> parameters, <TAB> no_wait, ) : <TAB> if ( <TAB> <TAB> parameters. access_control is not None <TAB> <TAB> and parameters. access_control. ip is not None <TAB> <TAB> and parameters. access_control. ip. allow <TAB> ) : <TAB> <TAB> ips = list ( <TAB> <TAB> <TAB> map ( <TAB> <TAB> <TAB> <TAB> lambda x : create_ip_range ( streaming_endpoint_name, x ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> else x, <TAB> <TAB> <TAB> <TAB> parameters. access_control. ip. allow, <TAB> <TAB> <TAB> ) <TAB> <TAB> ) <TAB> <TAB> parameters. access_control. ip. allow = ips <TAB> return sdk_no_wait ( <TAB> <TAB> no_wait, <TAB> <TAB> client. update, <TAB> <TAB> resource_group_name = resource_group_name, <TAB> <TAB> account_name = account_name, <TAB> <TAB> streaming_endpoint_name = streaming_endpoint_name, <TAB> <TAB> parameters = parameters, <TAB> )",False,"isinstance(x, str)",parameters.access_control.ip is None or x is None,0.6509113907814026
|
||
|
4719,"def safe_parse_date ( date_hdr ) : <TAB> """"""Parse a Date: or Received: header into a unix timestamp."""""" <TAB> try : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> date_hdr = date_hdr. split ( "";"" ) [ - 1 ]. strip ( ) <TAB> <TAB> msg_ts = long ( rfc822. mktime_tz ( rfc822. parsedate_tz ( date_hdr ) ) ) <TAB> <TAB> if ( msg_ts > ( time. time ( ) + 24 * 3600 ) ) or ( msg_ts < 1 ) : <TAB> <TAB> <TAB> return None <TAB> <TAB> else : <TAB> <TAB> <TAB> return msg_ts <TAB> except ( ValueError, TypeError, OverflowError ) : <TAB> <TAB> return None",False,';' in date_hdr,"isinstance(date_hdr, basestring)",0.6635328531265259
|
||
|
4720,"def setup ( self, modes, current_mode ) : <TAB> self. setMinimumSize ( 600, 400 ) <TAB> self. setWindowTitle ( _ ( ""Select Mode"" ) ) <TAB> widget_layout = QVBoxLayout ( ) <TAB> label = QLabel ( <TAB> <TAB> _ ( <TAB> <TAB> <TAB> 'Please select the desired mode then click ""OK"".'<TAB> <TAB> <TAB> 'Otherwise, click ""Cancel"".' <TAB> <TAB> ) <TAB> ) <TAB> label. setWordWrap ( True ) <TAB> widget_layout. addWidget ( label ) <TAB> self. setLayout ( widget_layout ) <TAB> self. mode_list = QListWidget ( ) <TAB> self. mode_list. itemDoubleClicked. connect ( self. select_and_accept ) <TAB> widget_layout. addWidget ( self. mode_list ) <TAB> self. mode_list. setIconSize ( QSize ( 48, 48 ) ) <TAB> for name, item in modes. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> litem = ModeItem ( item. name, item. description, item. icon, self. mode_list ) <TAB> <TAB> <TAB> if item. icon == current_mode : <TAB> <TAB> <TAB> <TAB> self. mode_list. setCurrentItem ( litem ) <TAB> self. mode_list. sortItems ( ) <TAB> instructions = QLabel ( <TAB> <TAB> _ ( <TAB> <TAB> <TAB> ""Change mode at any time by clicking "" <TAB> <TAB> <TAB> 'the ""Mode"" button containing Mu\'s logo.' <TAB> <TAB> ) <TAB> ) <TAB> instructions. setWordWrap ( True ) <TAB> widget_layout. addWidget ( instructions ) <TAB> button_box = QDialogButtonBox ( QDialogButtonBox. Ok | QDialogButtonBox. Cancel ) <TAB> button_box. accepted. connect ( self. accept ) <TAB> button_box. rejected. connect ( self. reject ) <TAB> widget_layout. addWidget ( button_box )",False,not item.is_debugger,item.name,0.6513662338256836
|
||
|
4721,"def python_value ( self, value ) : <TAB> if value : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> pp = lambda x : x. time ( ) <TAB> <TAB> <TAB> return format_date_time ( value, self. formats, pp ) <TAB> <TAB> elif isinstance ( value, datetime. datetime ) : <TAB> <TAB> <TAB> return value. time ( ) <TAB> if value is not None and isinstance ( value, datetime. timedelta ) : <TAB> <TAB> return ( datetime. datetime. min + value ). time ( ) <TAB> return value",False,"isinstance(value, basestring)","isinstance(value, string_types)",0.6505071520805359
|
||
|
4722,"def process ( self ) : <TAB> """"""Do processing necessary, storing result in feature."""""" <TAB> summation = 0 <TAB> histo = self. data [ ""flat.notes.quarterLengthHistogram"" ] <TAB> if not histo : <TAB> <TAB> raise NativeFeatureException ( ""input lacks notes"" ) <TAB> maxKey = 0 <TAB> for key in histo : <TAB> <TAB> <TAB> <TAB> if histo [ key ] > 0 : <TAB> <TAB> <TAB> summation += histo [ key ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> maxKey = histo [ key ] <TAB> self. feature. vector [ 0 ] = maxKey / summation",False,histo[key] >= maxKey,summation > maxKey,0.6675178408622742
|
||
|
4723,"def download_config ( client, bucket, prefix, account_id, region, day, store, rtypes = ( ) ) : <TAB> config_prefix = ""%sAWSLogs/%s/Config/%s/%s/ConfigHistory/"" % ( <TAB> <TAB> prefix, <TAB> <TAB> account_id, <TAB> <TAB> region, <TAB> <TAB> day. strftime ( ""%Y/%-m/%-d"" ), <TAB> ) <TAB> results = client. list_objects_v2 ( Bucket = bucket, Prefix = config_prefix ) <TAB> if not os. path. exists ( store ) : <TAB> <TAB> os. makedirs ( store ) <TAB> files = [ ] <TAB> downloads = Counter ( ) <TAB> for k in results. get ( ""Contents"", ( ) ) : <TAB> <TAB> found = False <TAB> <TAB> for rt in rtypes : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> found = True <TAB> <TAB> if not found : <TAB> <TAB> <TAB> continue <TAB> <TAB> fname = k [ ""Key"" ]. rsplit ( ""/"", 1 ) [ - 1 ] <TAB> <TAB> fpath = os. path. join ( store, fname ) <TAB> <TAB> files. append ( fpath ) <TAB> <TAB> if os. path. exists ( fpath ) : <TAB> <TAB> <TAB> downloads [ ""Cached"" ] += 1 <TAB> <TAB> <TAB> downloads [ ""CacheSize"" ] += k [ ""Size"" ] <TAB> <TAB> <TAB> continue <TAB> <TAB> downloads [ ""Downloads"" ] += 1 <TAB> <TAB> downloads [ ""DownloadSize"" ] += k [ ""Size"" ] <TAB> <TAB> client. download_file ( bucket, k [ ""Key"" ], fpath ) <TAB> log. debug ( <TAB> <TAB> ""Downloaded:%d Size:%d Cached:%d Size:%s Prefix:%s"", <TAB> <TAB> downloads [ ""Downloads"" ], <TAB> <TAB> downloads [ ""DownloadSize"" ], <TAB> <TAB> downloads [ ""Cached"" ], <TAB> <TAB>",False,rt in k['Key'],rt in files,0.6663093566894531
|
||
|
4724,"def get_latest_from_github ( package_path = ""azure-cli"" ) : <TAB> try : <TAB> <TAB> import requests <TAB> <TAB> git_url = ""https://raw.githubusercontent.com/Azure/azure-cli/master/src/{}/setup.py"". format ( <TAB> <TAB> <TAB> package_path <TAB> <TAB> ) <TAB> <TAB> response = requests. get ( git_url, timeout = 10 ) <TAB> <TAB> if response. status_code!= 200 : <TAB> <TAB> <TAB> logger. info ( <TAB> <TAB> <TAB> <TAB> ""Failed to fetch the latest version from '%s' with status code '%s' and reason '%s'"", <TAB> <TAB> <TAB> <TAB> git_url, <TAB> <TAB> <TAB> <TAB> response. status_code, <TAB> <TAB> <TAB> <TAB> response. reason, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> return None <TAB> <TAB> for line in response. iter_lines ( ) : <TAB> <TAB> <TAB> txt = line. decode ( ""utf-8"", errors = ""ignore"" ) <TAB> <TAB> <TAB> if txt. startswith ( ""VERSION"" ) : <TAB> <TAB> <TAB> <TAB> match = re. search ( r""VERSION = \""(.*)\""$"", txt ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> return match. group ( 1 ) <TAB> except Exception as ex : <TAB> <TAB> logger. info ( ""Failed to get the latest version from '%s'. %s"", git_url, str ( ex ) ) <TAB> <TAB> return None",True,match,match,0.6739219427108765
|
||
|
4725,"def removeItem ( self, event ) : <TAB> """"""Double Left Click - remove module"""""" <TAB> if event. GetModifiers ( ) == wx. MOD_CONTROL : <TAB> <TAB> return <TAB> row, _ = self. HitTest ( event. Position ) <TAB> if row!= - 1 and row not in self. blanks and isinstance ( self. mods [ row ], Module ) : <TAB> <TAB> col = self. getColumn ( event. Position ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> mod = self. mods [ row ] <TAB> <TAB> <TAB> except IndexError : <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> if not isinstance ( mod, Module ) or mod. isEmpty : <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> if event. GetModifiers ( ) == wx. MOD_ALT : <TAB> <TAB> <TAB> <TAB> fit = Fit. getInstance ( ). getFit ( self. activeFitID ) <TAB> <TAB> <TAB> <TAB> positions = getSimilarModPositions ( fit. modules, mod ) <TAB> <TAB> <TAB> <TAB> self. mainFrame. command. Submit ( <TAB> <TAB> <TAB> <TAB> <TAB> cmd. GuiRemoveLocalModuleCommand ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> fitID = self. activeFitID, positions = positions <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. removeModule ( mod ) <TAB> <TAB> else : <TAB> <TAB> <TAB> if ""wxMSW"" in wx. PlatformInfo : <TAB> <TAB> <TAB> <TAB> self. click ( event )",False,col != self.getColIndex(State),col != -1,0.6589416265487671
|
||
|
4726,"def times ( self, value : int ) : <TAB> if value is None : <TAB> <TAB> self. _times = None <TAB> else : <TAB> <TAB> try : <TAB> <TAB> <TAB> candidate = int ( value ) <TAB> <TAB> except ValueError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> raise BarException ( f""cannot set repeat times to: {value!r}"" ) <TAB> <TAB> if candidate < 0 : <TAB> <TAB> <TAB> raise BarException ( <TAB> <TAB> <TAB> <TAB> f""cannot set repeat times to a value less than zero: {value}"" <TAB> <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise BarException ( ""cannot set repeat times on a start Repeat"" ) <TAB> <TAB> self. _times = candidate",False,self.direction == 'start',self._times is None,0.6541805267333984
|
||
|
4727,"def out ( parent, attr, indent = 0 ) : <TAB> val = getattr ( parent, attr ) <TAB> prefix = ""%s%s:"" % ( "" "" * indent, attr. replace ( ""_"", ""-"" ) ) <TAB> if val is None : <TAB> <TAB> cli. out ( prefix ) <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> val = [ flag_util. encode_flag_val ( c. value ) for c in val ] <TAB> <TAB> cli. out ( ""%s %s"" % ( prefix, flag_util. encode_flag_val ( val ) ) )",False,attr == 'choices',"isinstance(val, bool)",0.6655404567718506
|
||
|
4728,"def execute ( self, context ) : <TAB> try : <TAB> <TAB> bpy. context. window. cursor_set ( ""WAIT"" ) <TAB> <TAB> ng = context. space_data. node_tree <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> build_update_list ( ng ) <TAB> <TAB> <TAB> process_tree ( ng ) <TAB> except : <TAB> <TAB> pass <TAB> finally : <TAB> <TAB> bpy. context. window. cursor_set ( ""DEFAULT"" ) <TAB> return { ""FINISHED"" }",True,ng,ng,0.6923580169677734
|
||
|
4729,"def updateAutoSIPrefix ( self ) : <TAB> if self. label. isVisible ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> _range = 10 ** np. array ( self. range ) <TAB> <TAB> else : <TAB> <TAB> <TAB> _range = self. range <TAB> <TAB> ( scale, prefix ) = fn. siScale ( <TAB> <TAB> <TAB> max ( abs ( _range [ 0 ] * self. scale ), abs ( _range [ 1 ] * self. scale ) ) <TAB> <TAB> ) <TAB> <TAB> if self. labelUnits == """" and prefix in [ <TAB> <TAB> <TAB> ""k"", <TAB> <TAB> <TAB> ""m"", <TAB> <TAB> ] : <TAB> <TAB> <TAB> scale = 1.0 <TAB> <TAB> <TAB> prefix = """" <TAB> <TAB> self. autoSIPrefixScale = scale <TAB> <TAB> self. labelUnitPrefix = prefix <TAB> else : <TAB> <TAB> self. autoSIPrefixScale = 1.0 <TAB> self. _updateLabel ( )",False,self.logMode,self.autoSIPrefixScale == 0.0,0.6592258214950562
|
||
|
4730,"def python_unique ( data ) : <TAB> unique = [ data [ 0 ] ] <TAB> unique_indices = [ 0 ] <TAB> unique_inverse = [ 0 ] <TAB> unique_count = [ 1 ] <TAB> for index, d in enumerate ( data [ 1 : ] ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> idx = unique. index ( d ) <TAB> <TAB> <TAB> unique_inverse. append ( idx ) <TAB> <TAB> <TAB> unique_count [ idx ] += 1 <TAB> <TAB> else : <TAB> <TAB> <TAB> unique. append ( d ) <TAB> <TAB> <TAB> unique_indices. append ( index ) <TAB> <TAB> <TAB> unique_inverse. append ( len ( unique ) - 1 ) <TAB> <TAB> <TAB> unique_count. append ( 1 ) <TAB> return unique, unique_indices, unique_inverse, unique_count",True,d in unique,d in unique,0.6762837171554565
|
||
|
4731,"def validate ( self ) : <TAB> if not super ( GroupForm, self ). validate ( ) : <TAB> <TAB> return False <TAB> result = True <TAB> permission_fields = ( <TAB> <TAB> self. editpost, <TAB> <TAB> self. deletepost, <TAB> <TAB> self. deletetopic, <TAB> <TAB> self. posttopic, <TAB> <TAB> self. postreply, <TAB> <TAB> self. mod_edituser, <TAB> <TAB> self. mod_banuser, <TAB> <TAB> self. viewhidden, <TAB> <TAB> self. makehidden, <TAB> ) <TAB> group_fields = [ self. admin, self. super_mod, self. mod, self. banned, self. guest ] <TAB> <TAB> if self. guest. data : <TAB> <TAB> for field in permission_fields : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> field. errors. append ( _ ( ""Can't assign any permissions to this group."" ) ) <TAB> <TAB> <TAB> <TAB> result = False <TAB> checked = [ ] <TAB> for field in group_fields : <TAB> <TAB> if field. data and field. data in checked : <TAB> <TAB> <TAB> if len ( checked ) > 1 : <TAB> <TAB> <TAB> <TAB> field. errors. append ( ""A group can't have multiple group types."" ) <TAB> <TAB> <TAB> <TAB> result = False <TAB> <TAB> else : <TAB> <TAB> <TAB> checked. append ( field. data ) <TAB> return result",True,field.data,field.data,0.6623830795288086
|
||
|
4732,"def anonymize_batch_kwargs ( self, batch_kwargs ) : <TAB> anonymized_batch_kwarg_keys = [ ] <TAB> for batch_kwarg_key in batch_kwargs. keys ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> anonymized_batch_kwarg_keys. append ( batch_kwarg_key ) <TAB> <TAB> else : <TAB> <TAB> <TAB> anonymized_batch_kwarg_keys. append ( self. anonymize ( batch_kwarg_key ) ) <TAB> return anonymized_batch_kwarg_keys",False,batch_kwarg_key in self._ge_batch_kwarg_keys,batch_kwarg_key in ['TAB >,0.6509423851966858
|
||
|
4733,"def format_help ( self ) : <TAB> extension_version = None <TAB> extension_name = None <TAB> try : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> extension_name = self. command_source. extension_name <TAB> <TAB> <TAB> extension_version = get_extension ( <TAB> <TAB> <TAB> <TAB> self. command_source. extension_name <TAB> <TAB> <TAB> ). version <TAB> except Exception : <TAB> <TAB> pass <TAB> telemetry. set_command_details ( <TAB> <TAB> command = self. prog [ 3 : ], <TAB> <TAB> extension_name = extension_name, <TAB> <TAB> extension_version = extension_version, <TAB> ) <TAB> telemetry. set_success ( summary = ""show help"" ) <TAB> super ( AzCliCommandParser, self ). format_help ( )",False,"isinstance(self.command_source, ExtensionCommandSource)","hasattr(self.command_source, 'extension_name')",0.6508350372314453
|
||
|
4734,"def on_press_release ( x ) : <TAB> """"""Keyboard callback function."""""" <TAB> global is_recording, enable_trigger_record <TAB> press = keyboard. KeyboardEvent ( ""down"", 28, ""space"" ) <TAB> release = keyboard. KeyboardEvent ( ""up"", 28, ""space"" ) <TAB> if x. event_type == ""down"" and x. name == press. name : <TAB> <TAB> if ( not is_recording ) and enable_trigger_record : <TAB> <TAB> <TAB> sys. stdout. write ( ""Start Recording... "" ) <TAB> <TAB> <TAB> sys. stdout. flush ( ) <TAB> <TAB> <TAB> is_recording = True <TAB> if x. event_type == ""up"" and x. name == release. name : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> is_recording = False",False,is_recording == True,enable_trigger_record,0.6579296588897705
|
||
|
4735,"def process_webhook_prop ( namespace ) : <TAB> if not isinstance ( namespace. webhook_properties, list ) : <TAB> <TAB> return <TAB> result = { } <TAB> for each in namespace. webhook_properties : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if ""="" in each : <TAB> <TAB> <TAB> <TAB> key, value = each. split ( ""="", 1 ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> key, value = each, """" <TAB> <TAB> <TAB> result [ key ] = value <TAB> namespace. webhook_properties = result",True,each,each,0.6774806976318359
|
||
|
4736,"def get ( self, name, default = None ) : <TAB> """"""returns the value of an attribute or some default value if the attribute was not set"""""" <TAB> if name in self. required_properties : <TAB> <TAB> return self. __dict__ [ name ] <TAB> <TAB> model_instances = self. _var_name_to_model_instances. get ( <TAB> <TAB> name, self. _additional_properties_model_instances <TAB> ) <TAB> values = [ ] <TAB> <TAB> <TAB> <TAB> <TAB> if model_instances : <TAB> <TAB> for model_instance in model_instances : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> v = model_instance. _data_store [ name ] <TAB> <TAB> <TAB> <TAB> if v not in values : <TAB> <TAB> <TAB> <TAB> <TAB> values. append ( v ) <TAB> len_values = len ( values ) <TAB> if len_values == 0 : <TAB> <TAB> return default <TAB> elif len_values == 1 : <TAB> <TAB> return values [ 0 ] <TAB> elif len_values > 1 : <TAB> <TAB> raise ApiValueError ( <TAB> <TAB> <TAB> ""Values stored for property {0} in {1} differ when looking "" <TAB> <TAB> <TAB> ""at self and self's composed instances. All values must be "" <TAB> <TAB> <TAB> ""the same"". format ( name, type ( self ). __name__ ), <TAB> <TAB> <TAB> [ e for e in [ self. _path_to_item, name ] if e ], <TAB> <TAB> )",True,name in model_instance._data_store,name in model_instance._data_store,0.6559637784957886
|
||
|
4737,"def _wrapped ( * args, ** kwargs ) : <TAB> try : <TAB> <TAB> return func ( * args, ** kwargs ) <TAB> except Exception : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> now = time. time ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> logger. exception ( ""failed to emit log to external aggregator"" ) <TAB> <TAB> <TAB> self. last_log_emit = now <TAB> <TAB> raise",False,now - self.last_log_emit > 10,self.last_log_emit > now,0.6558755040168762
|
||
|
4738,"def aiter_cogs ( cls ) -> AsyncIterator [ Tuple [ str, str ] ] : <TAB> yield ""Core"", ""0"" <TAB> for _dir in data_manager. cog_data_path ( ). iterdir ( ) : <TAB> <TAB> fpath = _dir / ""settings.json"" <TAB> <TAB> if not fpath. exists ( ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> with fpath. open ( ) as f : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> data = json. load ( f ) <TAB> <TAB> <TAB> except json. JSONDecodeError : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> cog_name = _dir. stem <TAB> <TAB> for cog_id, inner in data. items ( ) : <TAB> <TAB> <TAB> if not isinstance ( inner, dict ) : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> yield cog_name, cog_id",True,"not isinstance(data, dict)","not isinstance(data, dict)",0.654529333114624
|
||
|
4739,"def start ( self, foreground = False ) : <TAB> log. info ( ""Starting"" ) <TAB> if not Platform. is_windows ( ) : <TAB> <TAB> pid = self. pid ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if is_my_process ( pid ) : <TAB> <TAB> <TAB> <TAB> log. error ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Not starting, another instance is already running"" <TAB> <TAB> <TAB> <TAB> <TAB> "" (using pidfile {0})"". format ( self. pidfile ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> sys. exit ( 1 ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> log. warn ( <TAB> <TAB> <TAB> <TAB> <TAB> ""pidfile doesn't contain the pid of an agent process."" <TAB> <TAB> <TAB> <TAB> <TAB> "" Starting normally"" <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> if not foreground : <TAB> <TAB> <TAB> self. daemonize ( ) <TAB> <TAB> self. write_pidfile ( ) <TAB> else : <TAB> <TAB> log. debug ( ""Skipping pidfile check for Windows"" ) <TAB> self. run ( )",True,pid,pid,0.7102892398834229
|
||
|
4740,"def _save_loop ( self ) : <TAB> """"""Helper method for the saving thread to wait and execute save requests."""""" <TAB> while True : <TAB> <TAB> with self. _save_condition_variable : <TAB> <TAB> <TAB> while not self. _export_dir : <TAB> <TAB> <TAB> <TAB> self. _save_condition_variable. wait ( ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> if self. _saving_checkpoint : <TAB> <TAB> <TAB> <TAB> logging. info ( ""Saving checkpoint to %s"", self. _export_dir ) <TAB> <TAB> <TAB> <TAB> self. _policy_saver. save_checkpoint ( self. _export_dir ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> logging. info ( ""Saving policy to %s"", self. _export_dir ) <TAB> <TAB> <TAB> <TAB> self. _policy_saver. save ( self. _export_dir ) <TAB> <TAB> <TAB> self. _export_dir = None <TAB> <TAB> <TAB> self. _save_condition_variable. notify ( )",False,self._join_save_thread,self._export_dir is None,0.6570258140563965
|
||
|
4741,"def _extract_tagstyle_docs_raises ( self ) : <TAB> """""" """""" <TAB> data = ""\n"". join ( <TAB> <TAB> [ <TAB> <TAB> <TAB> d. rstrip ( ). replace ( self. docs [ ""out"" ] [ ""spaces"" ], """", 1 ) <TAB> <TAB> <TAB> for d in self. docs [ ""in"" ] [ ""raw"" ]. splitlines ( ) <TAB> <TAB> ] <TAB> ) <TAB> listed = 0 <TAB> loop = True <TAB> maxi = 10000 <TAB> i = 0 <TAB> while loop : <TAB> <TAB> i += 1 <TAB> <TAB> if i > maxi : <TAB> <TAB> <TAB> loop = False <TAB> <TAB> start, end = self. dst. get_raise_indexes ( data ) <TAB> <TAB> if start >= 0 : <TAB> <TAB> <TAB> param = data [ start : end ] <TAB> <TAB> <TAB> desc = """" <TAB> <TAB> <TAB> start, end = self. dst. get_raise_description_indexes ( data, prev = end ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> desc = data [ start : end ]. strip ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. docs [ ""in"" ] [ ""raises"" ]. append ( ( param, desc ) ) <TAB> <TAB> <TAB> data = data [ end : ] <TAB> <TAB> <TAB> listed += 1 <TAB> <TAB> else : <TAB> <TAB> <TAB> loop = False <TAB> if i > maxi : <TAB> <TAB> print ( <TAB> <TAB> <TAB> ""WARNING: an infinite loop was reached while extracting docstring parameters (>10000). This should never happen!!!"" <TAB> <TAB> )",False,start > 0,start >= 0,0.6678239703178406
|
||
|
4742,"def items ( self ) : <TAB> dict = { } <TAB> for userdir in self. XDG_DIRS. keys ( ) : <TAB> <TAB> prefix = self. get ( userdir ). strip ( '""' ). split ( ""/"" ) [ 0 ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> path = ( <TAB> <TAB> <TAB> <TAB> os. getenv ( ""HOME"" ) <TAB> <TAB> <TAB> <TAB> + ""/"" <TAB> <TAB> <TAB> <TAB> + ""/"". join ( self. get ( userdir ). strip ( '""' ). split ( ""/"" ) [ 1 : ] ) <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> path = self. get ( userdir ). strip ( '""' ) <TAB> <TAB> dict [ userdir ] = path <TAB> return dict. items ( )",False,prefix,prefix.startswith(prefix),0.6821005940437317
|
||
|
4743,"def create_new_runtime_config ( ) : <TAB> conf_dict = { } <TAB> with open ( conf_path, ""r"" ) as fin : <TAB> <TAB> conf_dict = json. loads ( fin. read ( ) ) <TAB> if not conf_dict : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> <TAB> ""config file {} dose not exist, please check!"". format ( conf_path ) <TAB> <TAB> <TAB> ) <TAB> <TAB> raise ValueError ( ""{} "" ) <TAB> conf_dict [ ""initiator"" ] [ ""party_id"" ] = guest_party_id <TAB> conf_dict [ ""job_parameters"" ] [ ""work_mode"" ] = work_mode <TAB> conf_dict [ ""job_parameters"" ] [ ""backend"" ] = backend <TAB> conf_dict [ ""role"" ] [ ""guest"" ] = [ guest_party_id ] <TAB> conf_dict [ ""role"" ] [ ""host"" ] = [ host_party_id ] <TAB> new_config_path = gen_unique_path ( ) <TAB> with open ( new_config_path, ""w"" ) as fout : <TAB> <TAB> json_str = json. dumps ( conf_dict, indent = 1 ) <TAB> <TAB> fout. write ( json_str + ""\n"" ) <TAB> return new_config_path",False,not os.path.isfile(conf_dict),not os.path.exists(conf_path),0.6466238498687744
|
||
|
4744,"def add ( request ) : <TAB> Document = get_document_model ( ) <TAB> DocumentForm = get_document_form ( Document ) <TAB> if request. method == ""POST"" : <TAB> <TAB> doc = Document ( uploaded_by_user = request. user ) <TAB> <TAB> form = DocumentForm ( <TAB> <TAB> <TAB> request. POST, request. FILES, instance = doc, user = request. user <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> doc. file_size = doc. file. size <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> doc. file. seek ( 0 ) <TAB> <TAB> <TAB> doc. _set_file_hash ( doc. file. read ( ) ) <TAB> <TAB> <TAB> doc. file. seek ( 0 ) <TAB> <TAB> <TAB> form. save ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> search_index. insert_or_update_object ( doc ) <TAB> <TAB> <TAB> messages. success ( <TAB> <TAB> <TAB> <TAB> request, <TAB> <TAB> <TAB> <TAB> _ ( ""Document '{0}' added."" ). format ( doc. title ), <TAB> <TAB> <TAB> <TAB> buttons = [ <TAB> <TAB> <TAB> <TAB> <TAB> messages. button ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> reverse ( ""wagtaildocs:edit"", args = ( doc. id, ) ), _ ( ""Edit"" ) <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> ], <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> return redirect ( ""wagtaildocs:index"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> messages. error ( request, _ ( ""The document could not be saved due to errors."" ) ) <TAB> else : <TAB> <TAB> form = DocumentForm ( user = request.",False,form.is_valid(),doc.id >= 0,0.650469958782196
|
||
|
4745,"def test_suite ( ) : <TAB> suite = unittest. TestSuite ( ) <TAB> for fn in os. listdir ( here ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> modname = ""distutils.tests."" + fn [ : - 3 ] <TAB> <TAB> <TAB> __import__ ( modname ) <TAB> <TAB> <TAB> module = sys. modules [ modname ] <TAB> <TAB> <TAB> suite. addTest ( module. test_suite ( ) ) <TAB> return suite",False,fn.startswith('test') and fn.endswith('.py'),fn.endswith('.tests'),0.6471507549285889
|
||
|
4746,"def check_status ( self ) : <TAB> try : <TAB> <TAB> du = psutil. disk_usage ( ""/"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ServiceWarning ( <TAB> <TAB> <TAB> <TAB> ""{host} {percent}% disk usage exceeds {disk_usage}%"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> host = host, percent = du. percent, disk_usage = DISK_USAGE_MAX <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> except ValueError as e : <TAB> <TAB> self. add_error ( ServiceReturnedUnexpectedResult ( ""ValueError"" ), e )",False,DISK_USAGE_MAX and du.percent >= DISK_USAGE_MAX,not du,0.6570388674736023
|
||
|
4747,"def parse_hpk_response ( self, lines ) : <TAB> results = { } <TAB> lines = [ x. strip ( ). split ( "":"" ) for x in lines ] <TAB> curpub = None <TAB> for line in lines : <TAB> <TAB> if line [ 0 ] == ""info"" : <TAB> <TAB> <TAB> pass <TAB> <TAB> elif line [ 0 ] == ""pub"" : <TAB> <TAB> <TAB> curpub = line [ 1 ] <TAB> <TAB> <TAB> validity = line [ 6 ] <TAB> <TAB> <TAB> if line [ 5 ] : <TAB> <TAB> <TAB> <TAB> if int ( line [ 5 ] ) < time. time ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> validity += ""e"" <TAB> <TAB> <TAB> results [ curpub ] = { <TAB> <TAB> <TAB> <TAB> ""created"" : datetime. fromtimestamp ( int ( line [ 4 ] ) ), <TAB> <TAB> <TAB> <TAB> ""keytype_name"" : _ ( openpgp_algorithms. get ( int ( line [ 2 ] ), ""Unknown"" ) ), <TAB> <TAB> <TAB> <TAB> ""keysize"" : line [ 3 ], <TAB> <TAB> <TAB> <TAB> ""validity"" : validity, <TAB> <TAB> <TAB> <TAB> ""uids"" : [ ], <TAB> <TAB> <TAB> <TAB> ""fingerprint"" : curpub, <TAB> <TAB> <TAB> } <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> email, name, comment = parse_uid ( urllib. unquote ( line [ 1 ] ) ) <TAB> <TAB> <TAB> results [ curpub ] [ ""uids"" ]. append ( <TAB> <TAB> <TAB> <TAB> { ""name"" : name, ""email"" : email, ""comment"" : comment } <TAB> <TAB> <TAB> ) <TAB> return results",False,line[0] == 'uid',line[1],0.6540929079055786
|
||
|
4748,"def on_strokes_edited ( self ) : <TAB> strokes = self. _strokes ( ) <TAB> if strokes : <TAB> <TAB> translation = self. _engine. raw_lookup ( strokes ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> fmt = _ ( ""{strokes} maps to {translation}"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> fmt = _ ( ""{strokes} is not in the dictionary"" ) <TAB> <TAB> info = self. _format_label ( fmt, ( strokes, ), translation ) <TAB> else : <TAB> <TAB> info = """" <TAB> self. strokes_info. setText ( info )",False,translation is not None,translation,0.6673803329467773
|
||
|
4749,"def _set_xflux_setting ( self, ** kwargs ) : <TAB> for key, value in kwargs. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if key == ""color"" : <TAB> <TAB> <TAB> <TAB> self. _set_xflux_screen_color ( value ) <TAB> <TAB> <TAB> <TAB> self. _current_color = str ( value ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if self. state == self. states [ ""PAUSED"" ] : <TAB> <TAB> <TAB> <TAB> <TAB> self. state = self. states [ ""RUNNING"" ] <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. _xflux. sendline ( self. _settings_map [ key ] + str ( value ) ) <TAB> <TAB> <TAB> self. _c ( )",True,key in self._settings_map,key in self._settings_map,0.6530376076698303
|
||
|
4750,"def autoformat_filter_conv2d ( fsize, in_depth, out_depth ) : <TAB> if isinstance ( fsize, int ) : <TAB> <TAB> return [ fsize, fsize, in_depth, out_depth ] <TAB> elif isinstance ( fsize, ( tuple, list, tf. TensorShape ) ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return [ fsize [ 0 ], fsize [ 1 ], in_depth, out_depth ] <TAB> <TAB> else : <TAB> <TAB> <TAB> raise Exception ( <TAB> <TAB> <TAB> <TAB> ""filter length error: "" <TAB> <TAB> <TAB> <TAB> + str ( len ( fsize ) ) <TAB> <TAB> <TAB> <TAB> + "", only a length of 2 is supported."" <TAB> <TAB> <TAB> ) <TAB> else : <TAB> <TAB> raise Exception ( ""filter format error: "" + str ( type ( fsize ) ) )",True,len(fsize) == 2,len(fsize) == 2,0.6572926044464111
|
||
|
4751,"def get_jmx_checks ( confd_path = None, auto_conf = False ) : <TAB> jmx_checks = [ ] <TAB> if not confd_path : <TAB> <TAB> confd_path = get_confd_path ( ) <TAB> if auto_conf : <TAB> <TAB> path = confd_path + ""/auto_conf"" <TAB> else : <TAB> <TAB> path = confd_path <TAB> for conf in glob. glob ( os. path. join ( path, ""*.yaml"" ) ) : <TAB> <TAB> filename = os. path. basename ( conf ) <TAB> <TAB> check_name = filename. split ( ""."" ) [ 0 ] <TAB> <TAB> if os. path. exists ( conf ) : <TAB> <TAB> <TAB> with open ( conf, ""r"" ) as f : <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> check_config = yaml. load ( f. read ( ), Loader = yLoader ) <TAB> <TAB> <TAB> <TAB> <TAB> assert check_config is not None <TAB> <TAB> <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> <TAB> <TAB> log. error ( ""Unable to parse yaml config in %s"" % conf ) <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> init_config = check_config. get ( ""init_config"", { } ) or { } <TAB> <TAB> if init_config. get ( ""is_jmx"" ) or check_name in JMX_CHECKS : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if auto_conf : <TAB> <TAB> <TAB> <TAB> jmx_checks. append ( check_name ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> jmx_checks. append ( <TAB> <TAB> <TAB> <TAB> <TAB> { <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""check_config"" : check_",False,check not in jmx_checks,jmx_checks,0.6584567427635193
|
||
|
4752,"def get_netrc_auth ( url, raise_errors = False ) : <TAB> """"""Returns the Requests tuple auth for a given url from netrc."""""" <TAB> try : <TAB> <TAB> from netrc import netrc, NetrcParseError <TAB> <TAB> netrc_path = None <TAB> <TAB> for f in NETRC_FILES : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> loc = os. path. expanduser ( ""~/{0}"". format ( f ) ) <TAB> <TAB> <TAB> except KeyError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> if os. path. exists ( loc ) : <TAB> <TAB> <TAB> <TAB> netrc_path = loc <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> if netrc_path is None : <TAB> <TAB> <TAB> return <TAB> <TAB> ri = urlparse ( url ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> splitstr = b"":"" <TAB> <TAB> if isinstance ( url, str ) : <TAB> <TAB> <TAB> splitstr = splitstr. decode ( ""ascii"" ) <TAB> <TAB> host = ri. netloc. split ( splitstr ) [ 0 ] <TAB> <TAB> try : <TAB> <TAB> <TAB> _netrc = netrc ( netrc_path ). authenticators ( host ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> login_i = 0 if _netrc [ 0 ] else 1 <TAB> <TAB> <TAB> <TAB> return ( _netrc [ login_i ], _netrc [ 2 ] ) <TAB> <TAB> except ( NetrcParseError, IOError ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB>",False,_netrc,raise_errors,0.6724086999893188
|
||
|
4753,"def execute_calls ( self, calls ) : <TAB> results = [ ] <TAB> start_time = time. time ( ) <TAB> max_processes = scheduler_config. config. max_transfer_processes <TAB> for method_call in calls : <TAB> <TAB> results. append ( method_call. execute_on ( self ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _wait_for_some_async_commands ( ) <TAB> self. wait_for_all_async_commands ( ) <TAB> duration = time. time ( ) - start_time <TAB> if duration > self. _WARNING_DURATION : <TAB> <TAB> self. _report_long_execution ( calls, duration ) <TAB> warnings = self. warnings <TAB> self. warnings = [ ] <TAB> return dict ( results = results, warnings = warnings )",False,len(self._subcommands) >= max_processes,max_processes > 0,0.6498922109603882
|
||
|
4754,"def compare_version ( self, other : Union [ None, ""Software"", str ] ) -> int : <TAB> <TAB> if other is None : <TAB> <TAB> return 1 <TAB> if isinstance ( other, Software ) : <TAB> <TAB> other = ""{}{}"". format ( other. version, other. patch or """" ) <TAB> else : <TAB> <TAB> other = str ( other ) <TAB> mx = re. match ( r""^([\d\.]+\d+)(.*)$"", other ) <TAB> if mx is not None : <TAB> <TAB> oversion, opatch = mx. group ( 1 ), mx. group ( 2 ). strip ( ) <TAB> else : <TAB> <TAB> oversion, opatch = other, """" <TAB> if self. version < oversion : <TAB> <TAB> return - 1 <TAB> elif self. version > oversion : <TAB> <TAB> return 1 <TAB> spatch = self. patch or """" <TAB> if self. product == Product. DropbearSSH : <TAB> <TAB> if not re. match ( r""^test\d.*$"", opatch ) : <TAB> <TAB> <TAB> opatch = ""z{}"". format ( opatch ) <TAB> <TAB> if not re. match ( r""^test\d.*$"", spatch ) : <TAB> <TAB> <TAB> spatch = ""z{}"". format ( spatch ) <TAB> elif self. product == Product. OpenSSH : <TAB> <TAB> mx1 = re. match ( r""^p(\d).*"", opatch ) <TAB> <TAB> mx2 = re. match ( r""^p(\d).*"", spatch ) <TAB> <TAB> if not ( bool ( mx1 ) and bool ( mx2 ) ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> opatch = mx1. group ( 1 ) <TAB> <TAB> <TAB> if mx2 is not None : <TAB> <TAB> <TAB> <TAB> spatch = mx2. group ( 1 ) <TAB> <TAB> <TAB> <TAB> if ( ( spatch == """" ) and ( op",True,mx1 is not None,mx1 is not None,0.6599274277687073
|
||
|
4755,"def accept ( self, node : Union [ Statement, Expression ] ) -> Optional [ Value ] : <TAB> """"""Transform an expression or a statement."""""" <TAB> with self. catch_errors ( node. line ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> res = node. accept ( self. visitor ) <TAB> <TAB> <TAB> <TAB> res = self. coerce ( res, self. node_type ( node ), node. line ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> except UnsupportedException : <TAB> <TAB> <TAB> <TAB> res = Register ( self. node_type ( node ) ) <TAB> <TAB> <TAB> return res <TAB> <TAB> else : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> node. accept ( self. visitor ) <TAB> <TAB> <TAB> except UnsupportedException : <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> return None",False,"isinstance(node, Expression)",self.node_type(node),0.6584411263465881
|
||
|
4756,"def get_summary_writer ( <TAB> self, name = ""DeepSpeedJobName"", base = os. path. join ( os. environ [ ""HOME"" ], ""tensorboard"" ) ) : <TAB> if self. tensorboard_output_path ( ) : <TAB> <TAB> base_dir = self. tensorboard_output_path ( ) <TAB> <TAB> job_name = self. tensorboard_job_name ( ) <TAB> <TAB> log_dir = os. path. join ( base_dir, job_name ) <TAB> else : <TAB> <TAB> if self. tensorboard_job_name ( ) : <TAB> <TAB> <TAB> name = self. tensorboard_job_name ( ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> infra_job_id = os. environ [ ""DLWS_JOB_ID"" ] <TAB> <TAB> elif ""DLTS_JOB_ID"" in os. environ : <TAB> <TAB> <TAB> infra_job_id = os. environ [ ""DLTS_JOB_ID"" ] <TAB> <TAB> else : <TAB> <TAB> <TAB> infra_job_id = ""unknown-job-id"" <TAB> <TAB> summary_writer_dir_name = os. path. join ( infra_job_id, ""logs"" ) <TAB> <TAB> log_dir = os. path. join ( base, summary_writer_dir_name, name ) <TAB> os. makedirs ( log_dir, exist_ok = True ) <TAB> return SummaryWriter ( log_dir = log_dir )",True,'DLWS_JOB_ID' in os.environ,'DLWS_JOB_ID' in os.environ,0.6545872688293457
|
||
|
4757,"def get_map ( self, map_filename ) : <TAB> map_file = os. path. join ( server_info [ ""maps_path"" ], map_filename ) <TAB> if not os. path. exists ( map_file ) : <TAB> <TAB> data = self. cloud. get_map ( map_filename ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise Exception ( ""map"", ""Could not download map from main server."" ) <TAB> <TAB> map_dir = os. path. split ( map_file ) [ 0 ] <TAB> <TAB> if not os. path. exists ( map_dir ) : <TAB> <TAB> <TAB> os. makedirs ( map_dir ) <TAB> <TAB> f = open ( map_file, ""w"" ) <TAB> <TAB> f. write ( data ) <TAB> <TAB> f. close ( ) <TAB> else : <TAB> <TAB> f = open ( map_file, ""r"" ) <TAB> <TAB> data = f. read ( ) <TAB> <TAB> f. close ( ) <TAB> return data",False,data == None,not data,0.6683326959609985
|
||
|
4758,"def read_blob ( self ) : <TAB> r = """" <TAB> while 1 : <TAB> <TAB> s = self. peekn ( 2 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> r += self. getn ( 2 ) <TAB> <TAB> elif viml_eqregh ( s, ""^\\.[0-9A-Fa-f]$"" ) : <TAB> <TAB> <TAB> r += self. getn ( 1 ) <TAB> <TAB> elif viml_eqregh ( s, ""^[0-9A-Fa-f][^0-9A-Fa-f]$"" ) : <TAB> <TAB> <TAB> raise VimLParserException ( <TAB> <TAB> <TAB> <TAB> Err ( <TAB> <TAB> <TAB> <TAB> <TAB> ""E973: Blob literal should have an even number of hex characters:"" <TAB> <TAB> <TAB> <TAB> <TAB> + s, <TAB> <TAB> <TAB> <TAB> <TAB> self. getpos ( ), <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> break <TAB> return r",False,"viml_eqregh(s, '^[0-9A-Fa-f][0-9A-Fa-f]$')",s == '',0.6515358686447144
|
||
|
4759,"def fave_slices ( <TAB> self, user_id : Optional [ int ] = None ) -> FlaskResponse : <TAB> """"""Favorite slices for a user"""""" <TAB> if not user_id : <TAB> <TAB> user_id = g. user. id <TAB> qry = ( <TAB> <TAB> db. session. query ( Slice, models. FavStar. dttm ) <TAB> <TAB>. join ( <TAB> <TAB> <TAB> models. FavStar, <TAB> <TAB> <TAB> and_ ( <TAB> <TAB> <TAB> <TAB> models. FavStar. user_id == user_id, <TAB> <TAB> <TAB> <TAB> models. FavStar. class_name == ""slice"", <TAB> <TAB> <TAB> <TAB> Slice. id == models. FavStar. obj_id, <TAB> <TAB> <TAB> ), <TAB> <TAB> ) <TAB> <TAB>. order_by ( models. FavStar. dttm. desc ( ) ) <TAB> ) <TAB> payload = [ ] <TAB> for o in qry. all ( ) : <TAB> <TAB> dash = { <TAB> <TAB> <TAB> ""id"" : o. Slice. id, <TAB> <TAB> <TAB> ""title"" : o. Slice. slice_name, <TAB> <TAB> <TAB> ""url"" : o. Slice. slice_url, <TAB> <TAB> <TAB> ""dttm"" : o. dttm, <TAB> <TAB> <TAB> ""viz_type"" : o. Slice. viz_type, <TAB> <TAB> } <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> user = o. Slice. created_by <TAB> <TAB> <TAB> dash [ ""creator"" ] = str ( user ) <TAB> <TAB> <TAB> dash [ ""creator_url"" ] = ""/superset/profile/{}/"". format ( user. username ) <TAB> <TAB> payload. append ( dash ) <TAB> return json_success ( json. dumps ( payload, default = utils. json_int_dttm_ser",False,o.Slice.created_by,dash,0.6600077152252197
|
||
|
4760,"def test_error_operator ( self ) : <TAB> FO = FermionOperator <TAB> terms = [ ] <TAB> for i in range ( 4 ) : <TAB> <TAB> terms. append ( FO ( ( ( i, 1 ), ( i, 0 ) ), 0.018505508252042547 ) ) <TAB> <TAB> terms. append ( FO ( ( ( i, 1 ), ( ( i + 1 ) % 4, 0 ) ), - 0.012337005501361697 ) ) <TAB> <TAB> terms. append ( FO ( ( ( i, 1 ), ( ( i + 2 ) % 4, 0 ) ), 0.0061685027506808475 ) ) <TAB> <TAB> terms. append ( FO ( ( ( i, 1 ), ( ( i + 3 ) % 4, 0 ) ), - 0.012337005501361697 ) ) <TAB> <TAB> terms. append ( <TAB> <TAB> <TAB> normal_ordered ( <TAB> <TAB> <TAB> <TAB> FO ( <TAB> <TAB> <TAB> <TAB> <TAB> ( ( i, 1 ), ( ( i + 1 ) % 4, 1 ), ( i, 0 ), ( ( i + 1 ) % 4, 0 ) ), <TAB> <TAB> <TAB> <TAB> <TAB> 3.1830988618379052, <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> terms. append ( <TAB> <TAB> <TAB> <TAB> normal_ordered ( <TAB> <TAB> <TAB> <TAB> <TAB> FO ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ( ( i, 1 ), ( ( i + 2 ) % 4, 1 ), ( i, 0 ), ( ( i + 2 ) % 4, 0 ) ), <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> 22.281692032865351, <TAB> <TAB> <TAB> <",False,i // 2,len(self.tabs) > 0,0.6683347225189209
|
||
|
4761,"def _get_data ( self, root, mode, ** kwargs ) : <TAB> default_root = DATA_HOME <TAB> filename, data_hash, field_indices, num_discard_samples = self. SPLITS [ mode ] <TAB> fullname = ( <TAB> <TAB> os. path. join ( default_root, filename ) <TAB> <TAB> if root is None <TAB> <TAB> else os. path. join ( os. path. expanduser ( root ), filename ) <TAB> ) <TAB> if not os. path. exists ( fullname ) or ( <TAB> <TAB> data_hash and not md5file ( fullname ) == data_hash <TAB> ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> warnings. warn ( <TAB> <TAB> <TAB> <TAB> ""md5 check failed for {}, download {} data to {}"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> filename, self. __class__. __name__, default_root <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> path = get_path_from_url ( self. URL, default_root, self. MD5 ) <TAB> <TAB> fullname = os. path. join ( default_root, filename ) <TAB> super ( LCQMC, self ). __init__ ( <TAB> <TAB> fullname, <TAB> <TAB> field_indices = field_indices, <TAB> <TAB> num_discard_samples = num_discard_samples, <TAB> <TAB> ** kwargs <TAB> )",False,root is not None,md5file(fullname)!= 'TESTS_TAB > [DEFAULT_DATA],0.6573939919471741
|
||
|
4762,"def post_config_hook ( self ) : <TAB> if not self. py3. check_commands ( ""thunderbird"" ) : <TAB> <TAB> raise Exception ( STRING_NOT_INSTALLED ) <TAB> <TAB> if not self. profile : <TAB> <TAB> directory = Path ( ""~/.thunderbird"" ). expanduser ( ) <TAB> <TAB> profile_ini = directory / ""profiles.ini"" <TAB> <TAB> profile = [ ] <TAB> <TAB> with profile_ini. open ( ) as f : <TAB> <TAB> <TAB> for line in f : <TAB> <TAB> <TAB> <TAB> if line. startswith ( ""Path="" ) : <TAB> <TAB> <TAB> <TAB> <TAB> profile. append ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""{}/{}"". format ( directory, line. split ( ""Path="" ) [ - 1 ]. strip ( ) ) <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise Exception ( STRING_NO_PROFILE ) <TAB> <TAB> self. profile = profile [ 0 ] <TAB> self. profile = Path ( self. profile ). expanduser ( ) <TAB> self. path = self. profile / ""calendar-data/local.sqlite"" <TAB> self. init_datetimes = [ ] <TAB> for word in self. format_datetime : <TAB> <TAB> if ( self. py3. format_contains ( self. format_todo, word ) ) and ( <TAB> <TAB> <TAB> word in self. format_datetime <TAB> <TAB> ) : <TAB> <TAB> <TAB> self. init_datetimes. append ( word ) <TAB> self. thresholds_init = { } <TAB> for name in [ ""format"", ""format_todo"" ] : <TAB> <TAB> self. thresholds_init [ name ] = self. py3. get_color_names_list ( getattr ( self, name ) )",False,not len(profile),self.profile is None,0.6559419631958008
|
||
|
4763,"def get_dataset ( dataset, args ) : <TAB> if dataset. lower ( ) == ""coco"" : <TAB> <TAB> train_dataset = gdata. COCOInstance ( splits = ""instances_train2017"" ) <TAB> <TAB> val_dataset = gdata. COCOInstance ( splits = ""instances_val2017"", skip_empty = False ) <TAB> <TAB> starting_id = 0 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> length = len ( val_dataset ) <TAB> <TAB> <TAB> shard_len = length // hvd. size ( ) <TAB> <TAB> <TAB> rest = length % hvd. size ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> starting_id = shard_len * hvd. rank ( ) + min ( hvd. rank ( ), rest ) <TAB> <TAB> val_metric = COCOInstanceMetric ( <TAB> <TAB> <TAB> val_dataset, <TAB> <TAB> <TAB> args. save_prefix + ""_eval"", <TAB> <TAB> <TAB> use_ext = args. use_ext, <TAB> <TAB> <TAB> starting_id = starting_id, <TAB> <TAB> ) <TAB> else : <TAB> <TAB> raise NotImplementedError ( ""Dataset: {} not implemented."". format ( dataset ) ) <TAB> if<mask> : <TAB> <TAB> val_dataset = val_dataset. shard ( hvd. size ( ), hvd. rank ( ) ) <TAB> return train_dataset, val_dataset, val_metric",False,args.horovod and MPI,use_ext,0.6542540192604065
|
||
|
4764,"def __init__ ( self, client, job_id, callback = None ) : <TAB> self. client = client <TAB> self. job_id = job_id <TAB> <TAB> <TAB> <TAB> <TAB> with client. _jobs_lock : <TAB> <TAB> job = client. _jobs. get ( job_id ) <TAB> <TAB> self. event = None <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. event = job. get ( ""__ready"" ) <TAB> <TAB> if self. event is None : <TAB> <TAB> <TAB> self. event = job [ ""__ready"" ] = Event ( ) <TAB> <TAB> job [ ""__callback"" ] = callback",False,job,self.event is None,0.7116715908050537
|
||
|
4765,"def lutime ( f, times ) : <TAB> <TAB> <TAB> <TAB> if os. utime in os. supports_follow_symlinks : <TAB> <TAB> <TAB> <TAB> os. utime ( f, times, follow_symlinks = False ) <TAB> elif not os. path. islink ( f ) : <TAB> <TAB> <TAB> <TAB> os. utime ( f, times ) <TAB> else : <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> fmt_time = lambda sec : datetime. fromtimestamp ( sec ). strftime ( <TAB> <TAB> <TAB> <TAB> <TAB> ""%Y%m%d%H%M.%S"" <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> atime, mtime = times <TAB> <TAB> <TAB> <TAB> sp. check_call ( [ ""touch"", ""-h"", f, ""-a"", ""-t"", fmt_time ( atime ) ] ) <TAB> <TAB> <TAB> <TAB> sp. check_call ( [ ""touch"", ""-h"", f, ""-m"", ""-t"", fmt_time ( mtime ) ] ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> sp. check_call ( [ ""touch"", ""-h"", f ] ) <TAB> <TAB> except sp. CalledProcessError : <TAB> <TAB> <TAB> pass <TAB> <TAB> <TAB> <TAB> logger. warning ( <TAB> <TAB> <TAB> ""Unable to set utime on symlink {}. Your Python build does not support it."". format ( <TAB> <TAB> <TAB> <TAB> f <TAB> <TAB> <TAB> ) <TAB> <TAB> ) <TAB> <TAB> return None",False,times,os.path.isfile(f),0.7118969559669495
|
||
|
4766,"def getDefaultCompletion ( tree, node, lang ) : <TAB> if lang == ""XSLT"" : <TAB> <TAB> if node is not None and not tree. namespace ( node ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> output = tree. tags. get ( ""http://www.w3.org/1999/XSL/Transform"", [ ] ). get ( <TAB> <TAB> <TAB> <TAB> ""output"" <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> lang = output. attrib. get ( ""method"" ). upper ( ) <TAB> <TAB> <TAB> <TAB> publicId = output. attrib. get ( ""doctype-public"" ) <TAB> <TAB> <TAB> <TAB> systemId = output. attrib. get ( ""doctype-system"" ) <TAB> <TAB> <TAB> <TAB> default_dataset_info = default_completion. get ( lang ) <TAB> <TAB> <TAB> <TAB> if publicId or systemId : <TAB> <TAB> <TAB> <TAB> <TAB> default_dataset_info = ( publicId, systemId, default_dataset_info [ 2 ] ) <TAB> <TAB> <TAB> return default_dataset_info <TAB> <TAB> return None <TAB> return default_completion. get ( lang )",False,output is not None,output,0.6627018451690674
|
||
|
4767,"def _fractional_part ( self, n, expr, evaluation ) : <TAB> n_sympy = n. to_sympy ( ) <TAB> if n_sympy. is_constant ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> positive_integer_part = ( <TAB> <TAB> <TAB> <TAB> Expression ( ""Floor"", n ). evaluate ( evaluation ). to_python ( ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> result = n - positive_integer_part <TAB> <TAB> else : <TAB> <TAB> <TAB> negative_integer_part = ( <TAB> <TAB> <TAB> <TAB> Expression ( ""Ceiling"", n ). evaluate ( evaluation ). to_python ( ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> result = n - negative_integer_part <TAB> else : <TAB> <TAB> return expr <TAB> return from_python ( result )",False,n_sympy >= 0,expr.is_python(),0.6639846563339233
|
||
|
4768,"def todict ( obj ) : <TAB> <TAB> if isinstance ( obj, dict ) : <TAB> <TAB> return { k : todict ( v ) for k, v in obj. items ( ) } <TAB> <TAB> elif hasattr ( obj, ""__slots__"" ) : <TAB> <TAB> return { k : todict ( getattr ( obj, k ) ) for k in obj. __slots__ } <TAB> <TAB> elif hasattr ( obj, ""__iter__"" ) and not isinstance ( obj, str ) : <TAB> <TAB> return type ( obj ) ( todict ( v ) for v in obj ) <TAB> <TAB> elif hasattr ( obj, ""__dict__"" ) : <TAB> <TAB> return { <TAB> <TAB> <TAB> k : todict ( v ) <TAB> <TAB> <TAB> for k, v in obj. __dict__. items ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> } <TAB> <TAB> else : <TAB> <TAB> return obj",False,not callable(v) and (not k.startswith('_')),"hasattr(obj, '__iter__')",0.6522979140281677
|
||
|
4769,"def get_current_events_users ( calendar ) : <TAB> now = timezone. make_aware ( datetime. now ( ), timezone. get_current_timezone ( ) ) <TAB> result = [ ] <TAB> day = Day ( calendar. events. all ( ), now ) <TAB> for o in day. get_occurrences ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> usernames = o. event. title. split ( "","" ) <TAB> <TAB> <TAB> for username in usernames : <TAB> <TAB> <TAB> <TAB> result. append ( User. objects. get ( username = username. strip ( ) ) ) <TAB> return result",False,o.start <= now <= o.end,o.event,0.6572772264480591
|
||
|
4770,"def import_suffix_generator ( a_block, datatype = False ) : <TAB> if datatype is False : <TAB> <TAB> for name, suffix in iteritems ( a_block. component_map ( Suffix ) ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> yield name, suffix <TAB> else : <TAB> <TAB> for name, suffix in iteritems ( a_block. component_map ( Suffix ) ) : <TAB> <TAB> <TAB> if ( suffix. import_enabled ( ) is True ) and ( <TAB> <TAB> <TAB> <TAB> suffix. get_datatype ( ) is datatype <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> yield name, suffix",False,suffix.import_enabled() is True,datatype is False,0.6510511636734009
|
||
|
4771,"def action_delete ( self, ids ) : <TAB> try : <TAB> <TAB> count = 0 <TAB> <TAB> <TAB> <TAB> for pk in ids : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> count += 1 <TAB> <TAB> flash ( <TAB> <TAB> <TAB> ngettext ( <TAB> <TAB> <TAB> <TAB> ""Record was successfully deleted."", <TAB> <TAB> <TAB> <TAB> ""%(count)s records were successfully deleted."", <TAB> <TAB> <TAB> <TAB> count, <TAB> <TAB> <TAB> <TAB> count = count, <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> ""success"", <TAB> <TAB> ) <TAB> except Exception as ex : <TAB> <TAB> flash ( gettext ( ""Failed to delete records. %(error)s"", error = str ( ex ) ), ""error"" )",False,self.delete_model(self.get_one(pk)),"self.delete_record(pk, count)",0.6515241861343384
|
||
|
4772,"def from_csv ( fp, field_names = None, ** kwargs ) : <TAB> fmtparams = { } <TAB> for param in [ <TAB> <TAB> ""delimiter"", <TAB> <TAB> ""doublequote"", <TAB> <TAB> ""escapechar"", <TAB> <TAB> ""lineterminator"", <TAB> <TAB> ""quotechar"", <TAB> <TAB> ""quoting"", <TAB> <TAB> ""skipinitialspace"", <TAB> <TAB> ""strict"", <TAB> ] : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> fmtparams [ param ] = kwargs. pop ( param ) <TAB> if fmtparams : <TAB> <TAB> reader = csv. reader ( fp, ** fmtparams ) <TAB> else : <TAB> <TAB> dialect = csv. Sniffer ( ). sniff ( fp. read ( 1024 ) ) <TAB> <TAB> fp. seek ( 0 ) <TAB> <TAB> reader = csv. reader ( fp, dialect ) <TAB> table = PrettyTable ( ** kwargs ) <TAB> if field_names : <TAB> <TAB> table. field_names = field_names <TAB> else : <TAB> <TAB> if py3k : <TAB> <TAB> <TAB> table. field_names = [ x. strip ( ) for x in next ( reader ) ] <TAB> <TAB> else : <TAB> <TAB> <TAB> table. field_names = [ x. strip ( ) for x in reader. next ( ) ] <TAB> for row in reader : <TAB> <TAB> table. add_row ( [ x. strip ( ) for x in row ] ) <TAB> return table",True,param in kwargs,param in kwargs,0.6698812246322632
|
||
|
4773,"def _bootstrap ( self ) : <TAB> marker = self. _get_export_marker_from_db ( ) <TAB> LOG. info ( ""Using marker %s..."" % marker ) <TAB> missed_executions = self. _get_missed_executions_from_db ( export_marker = marker ) <TAB> LOG. info ( ""Found %d executions not exported yet..."", len ( missed_executions ) ) <TAB> for missed_execution in missed_executions : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> execution_api = ActionExecutionAPI. from_model ( <TAB> <TAB> <TAB> missed_execution, mask_secrets = True <TAB> <TAB> ) <TAB> <TAB> try : <TAB> <TAB> <TAB> LOG. debug ( ""Missed execution %s"", execution_api ) <TAB> <TAB> <TAB> self. pending_executions. put_nowait ( execution_api ) <TAB> <TAB> except : <TAB> <TAB> <TAB> LOG. exception ( ""Failed adding execution to in-memory queue."" ) <TAB> <TAB> <TAB> continue <TAB> LOG. info ( ""Bootstrapped executions..."" )",False,missed_execution.status not in COMPLETION_STATUSES,missed_execution == export_marker,0.6549334526062012
|
||
|
4774,"def print_resolutions ( <TAB> self, *, part_name : str, stage_packages_exist : bool, echoer ) -> None : <TAB> if not self. _stage_packages_dependencies and not self. _unhandled_dependencies : <TAB> <TAB> return <TAB> if self. _stage_packages_dependencies : <TAB> <TAB> stage_packages_list = _get_formatted_list ( self. _stage_packages_dependencies ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> echoer. warning ( <TAB> <TAB> <TAB> <TAB> _MSG_EXTEND_STAGE_PACKAGES. format ( <TAB> <TAB> <TAB> <TAB> <TAB> part_name = part_name, stage_packages = stage_packages_list <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> echoer. warning ( <TAB> <TAB> <TAB> <TAB> _MSG_ADD_STAGE_PACKAGES. format ( <TAB> <TAB> <TAB> <TAB> <TAB> part_name = part_name, stage_packages = stage_packages_list <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> if self. _unhandled_dependencies : <TAB> <TAB> unhandled_list = _get_formatted_list ( self. _unhandled_dependencies ) <TAB> <TAB> echoer. warning ( <TAB> <TAB> <TAB> _MSG_UNHANDLED_DEPENDENCIES. format ( <TAB> <TAB> <TAB> <TAB> part_name = part_name, unhandled_list = unhandled_list <TAB> <TAB> <TAB> ) <TAB> <TAB> )",True,stage_packages_exist,stage_packages_exist,0.6587600111961365
|
||
|
4775,"def __init__ ( self, * args, ** kwargs ) : <TAB> super ( ). __init__ ( * args, ** kwargs ) <TAB> self. custom_fields = [ ] <TAB> self. obj_type = ContentType. objects. get_for_model ( self. model ) <TAB> <TAB> custom_fields = CustomField. objects. filter ( content_types = self. obj_type ) <TAB> for cf in custom_fields : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. nullable_fields. append ( cf. name ) <TAB> <TAB> self. fields [ cf. name ] = cf. to_form_field ( <TAB> <TAB> <TAB> set_initial = False, enforce_required = False <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> self. custom_fields. append ( cf. name )",False,not cf.required,cf.nullable,0.6583252549171448
|
||
|
4776,"def on_key_press ( self, k, m ) : <TAB> if self. paused : <TAB> <TAB> return False <TAB> if self. used_key : <TAB> <TAB> return False <TAB> if k in ( key. LEFT, key. RIGHT, key. DOWN, key. UP, key. SPACE ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. model. block_left ( ) <TAB> <TAB> elif k == key. RIGHT : <TAB> <TAB> <TAB> self. model. block_right ( ) <TAB> <TAB> elif k == key. DOWN : <TAB> <TAB> <TAB> self. model. block_down ( ) <TAB> <TAB> elif k == key. UP : <TAB> <TAB> <TAB> self. model. block_rotate ( ) <TAB> <TAB> elif k == key. SPACE : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. elapsed = 0 <TAB> <TAB> <TAB> self. model. block_drop ( ) <TAB> <TAB> self. used_key = True <TAB> <TAB> return True <TAB> return False",True,k == key.LEFT,k == key.LEFT,0.6671327352523804
|
||
|
4777,"def save ( self, session = None, to = None, pickler = None ) : <TAB> if to and pickler : <TAB> <TAB> self. _save_to = ( pickler, to ) <TAB> if self. _save_to and len ( self ) > 0 : <TAB> <TAB> with self. _lock : <TAB> <TAB> <TAB> pickler, fn = self. _save_to <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> session. ui. mark ( _ ( ""Saving %s state to %s"" ) % ( self, fn ) ) <TAB> <TAB> <TAB> pickler ( self, fn )",True,session,session,0.6814517974853516
|
||
|
4778,"def visit_FunctionCall ( self, node : qlast. FunctionCall ) -> None : <TAB> if isinstance ( node. func, tuple ) : <TAB> <TAB> self. write ( f""{ident_to_str(node.func[0])}::{ident_to_str(node.func[1])}"" ) <TAB> else : <TAB> <TAB> self. write ( ident_to_str ( node. func ) ) <TAB> self. write ( ""("" ) <TAB> for i, arg in enumerate ( node. args ) : <TAB> <TAB> if i > 0 : <TAB> <TAB> <TAB> self. write ( "", "" ) <TAB> <TAB> self. visit ( arg ) <TAB> if node. kwargs : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. write ( "", "" ) <TAB> <TAB> for i, ( name, arg ) in enumerate ( node. kwargs. items ( ) ) : <TAB> <TAB> <TAB> if i > 0 : <TAB> <TAB> <TAB> <TAB> self. write ( "", "" ) <TAB> <TAB> <TAB> self. write ( f""{edgeql_quote.quote_ident(name)} := "" ) <TAB> <TAB> <TAB> self. visit ( arg ) <TAB> self. write ( "")"" ) <TAB> if node. window : <TAB> <TAB> self. write ( "" OVER ("" ) <TAB> <TAB> self. _block_ws ( 1 ) <TAB> <TAB> if node. window. partition : <TAB> <TAB> <TAB> self. write ( ""PARTITION BY "" ) <TAB> <TAB> <TAB> self. visit_list ( node. window. partition, newlines = False ) <TAB> <TAB> <TAB> self. new_lines = 1 <TAB> <TAB> if node. window. orderby : <TAB> <TAB> <TAB> self. write ( ""ORDER BY "" ) <TAB> <TAB> <TAB> self. visit_list ( node. window. orderby, separator = "" THEN"" ) <TAB> <TAB> self. _block_ws ( - 1 ) <TAB> <TAB> self. write ( "")"" )",False,node.args,len(node.kwargs.items()) > 0,0.6687539219856262
|
||
|
4779,"def list_entries ( self, order = False, only_servers = False ) : <TAB> config_data = self. ssh_config. config_data <TAB> <TAB> if only_servers : <TAB> <TAB> new_config_data = [ ] <TAB> <TAB> for index, value in enumerate ( config_data ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> new_config_data. append ( value ) <TAB> <TAB> config_data = new_config_data <TAB> if order : <TAB> <TAB> config_data = sorted ( config_data, key = itemgetter ( ""host"" ) ) <TAB> return config_data",False,value.get('type') == 'entry' and value.get('host') != '*',index in only_servers,0.6496244668960571
|
||
|
4780,"def process ( self, resources, event = None ) : <TAB> client = local_session ( self. manager. session_factory ). client ( <TAB> <TAB> ""shield"", region_name = ""us-east-1"" <TAB> ) <TAB> protections = get_type_protections ( client, self. manager. get_model ( ) ) <TAB> protected_resources = { p [ ""ResourceArn"" ] for p in protections } <TAB> state = self. data. get ( ""state"", False ) <TAB> results = [ ] <TAB> for arn, r in zip ( self. manager. get_arns ( resources ), resources ) : <TAB> <TAB> r [ ""c7n:ShieldProtected"" ] = shielded = arn in protected_resources <TAB> <TAB> if shielded and state : <TAB> <TAB> <TAB> results. append ( r ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> results. append ( r ) <TAB> return results",False,not shielded and (not state),not shielded and state,0.654679536819458
|
||
|
4781,"def handle_exception_and_die ( e ) : <TAB> if hasattr ( e, ""kind"" ) : <TAB> <TAB> if e. kind == ""die"" : <TAB> <TAB> <TAB> sys. stderr. write ( ""ABORT: "" + e. msg + ""\n"" ) <TAB> <TAB> <TAB> sys. exit ( e. value ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> sys. stderr. write ( ""EXITING\n"" ) <TAB> <TAB> <TAB> sys. exit ( e. value ) <TAB> else : <TAB> <TAB> print ( str ( e ) ) <TAB> <TAB> sys. exit ( 1 )",False,e.kind == 'exit',e.kind == 'error',0.6578645706176758
|
||
|
4782,"def checkPlugs ( graphComponent ) : <TAB> if isinstance ( <TAB> <TAB> graphComponent, Gaffer. Plug <TAB> ) and not graphComponent. getName ( ). startswith ( ""__"" ) : <TAB> <TAB> description = Gaffer. Metadata. value ( graphComponent, ""description"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> undocumentedPlugs. append ( graphComponent. fullName ( ) ) <TAB> if not isinstance ( graphComponent, terminalPlugTypes ) : <TAB> <TAB> for plug in graphComponent. children ( Gaffer. Plug ) : <TAB> <TAB> <TAB> checkPlugs ( plug )",False,not description or description.isspace(),description,0.6551336646080017
|
||
|
4783,"def inc_grad ( self, model_id : int, name : str, value : FloatsXd ) -> None : <TAB> key = ( model_id, name ) <TAB> if self. proxy is not None : <TAB> <TAB> self. proxy. inc_grad ( model_id, name, value ) <TAB> elif not self. has_grad ( model_id, name ) : <TAB> <TAB> if hasattr ( value, ""copy"" ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _grads [ key ] = value. copy ( ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> xp = get_array_module ( value ) <TAB> <TAB> <TAB> self. _grads [ ( model_id, name ) ] = xp. ascontiguousarray ( value ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. _grads [ ( model_id, name ) ] = value <TAB> else : <TAB> <TAB> self. _grads [ ( model_id, name ) ] += value",False,not value.flags['C_CONTIGUOUS'],"hasattr(value, 'ascontiguousarray')",0.6503852605819702
|
||
|
4784,"def __call__ ( self, trainer ) : <TAB> if self. available ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> import matplotlib. pyplot as plt <TAB> else : <TAB> <TAB> return <TAB> xp = backend. get_array_module ( self. _vars [ 0 ]. data ) <TAB> stats = xp. zeros ( self. _data_shape, dtype = xp. float32 ) <TAB> for i, k in enumerate ( self. _keys ) : <TAB> <TAB> xs = [ ] <TAB> <TAB> for var in self. _vars : <TAB> <TAB> <TAB> x = getattr ( var, k, None ) <TAB> <TAB> <TAB> if x is not None : <TAB> <TAB> <TAB> <TAB> xs. append ( x. ravel ( ) ) <TAB> <TAB> if xs : <TAB> <TAB> <TAB> stat_dict = self. _statistician ( xp. concatenate ( xs, axis = 0 ), axis = 0, xp = xp ) <TAB> <TAB> <TAB> stat_list = [ ] <TAB> <TAB> <TAB> if self. _plot_mean : <TAB> <TAB> <TAB> <TAB> stat_list. append ( xp. atleast_1d ( stat_dict [ ""mean"" ] ) ) <TAB> <TAB> <TAB> if self. _plot_std : <TAB> <TAB> <TAB> <TAB> stat_list. append ( xp. atleast_1d ( stat_dict [ ""std"" ] ) ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> stat_list. append ( xp. atleast_1d ( stat_dict [ ""percentile"" ] ) ) <TAB> <TAB> <TAB> stats [ i ] = xp. concatenate ( stat_list, axis = 0 ) <TAB> if xp == cuda. cupy : <TAB> <TAB> stats = cuda. to_cpu ( stats ) <TAB> self. _samples. add ( stats, idx = trainer. updater. iteration ) <TAB> if self. _trigger ( trainer ) : <TAB> <TAB> file_path = os. path",True,self._plot_percentile,self._plot_percentile,0.6723756194114685
|
||
|
4785,"def _windows_extra_app_paths ( app_paths : List [ Path ] ) -> List [ Path ] : <TAB> <TAB> <TAB> <TAB> <TAB> app_paths_output = app_paths. copy ( ) <TAB> for app_path in app_paths : <TAB> <TAB> win_app_path = app_path. parent / ( app_path. stem + ""-script.py"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> app_paths_output. append ( win_app_path ) <TAB> <TAB> win_app_path = app_path. parent / ( app_path. stem + "".exe.manifest"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> app_paths_output. append ( win_app_path ) <TAB> return app_paths_output",False,win_app_path.exists(),os.path.exists(win_app_path),0.6511099338531494
|
||
|
4786,"def evolve_sequence ( sequence, substitution_probability, indel_probability ) : <TAB> result = [ ] <TAB> sequence_length = len ( sequence ) <TAB> insertion_choices = list ( sequence. nondegenerate_chars ) <TAB> result = [ ] <TAB> i = 0 <TAB> while i < sequence_length : <TAB> <TAB> current_char = sequence [ i ] <TAB> <TAB> if random. random ( ) < substitution_probability : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> substituted_base = random. choice ( <TAB> <TAB> <TAB> <TAB> [ r for r in sequence. nondegenerate_chars if r!= current_char ] <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> result. append ( substituted_base ) <TAB> <TAB> <TAB> i += 1 <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> length = int ( np. random. triangular ( 1, 1, 10 ) ) <TAB> <TAB> <TAB> if np. random. binomial ( 1, 0.5 ) == 0 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> result. extend ( np. random. choice ( insertion_choices, size = length ) ) <TAB> <TAB> <TAB> <TAB> i += 1 <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> i += length <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> result. append ( str ( current_char ) ) <TAB> <TAB> <TAB> i += 1 <TAB> return sequence. __class__ ( """". join ( result ) )",False,random.random() < indel_probability,np.random.random() < indel_probability,0.6520761251449585
|
||
|
4787,"def _parse_update ( client, update : ""raw.types.UpdateMessagePoll"" ) : <TAB> if update. poll is not None : <TAB> <TAB> return Poll. _parse ( client, update ) <TAB> results = update. results. results <TAB> chosen_option = None <TAB> options = [ ] <TAB> for i, result in enumerate ( results ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> chosen_option = i <TAB> <TAB> options. append ( <TAB> <TAB> <TAB> types. PollOption ( <TAB> <TAB> <TAB> <TAB> text = """", voter_count = result. voters, data = result. option, client = client <TAB> <TAB> <TAB> ) <TAB> <TAB> ) <TAB> return Poll ( <TAB> <TAB> id = str ( update. poll_id ), <TAB> <TAB> question = """", <TAB> <TAB> options = options, <TAB> <TAB> total_voter_count = update. results. total_voters, <TAB> <TAB> is_closed = False, <TAB> <TAB> chosen_option = chosen_option, <TAB> <TAB> client = client, <TAB> )",False,result.chosen,result.is_closed,0.6621267795562744
|
||
|
4788,"def get_nvd_identifiers ( self, _nvd_cls, _cpe_cls ) : <TAB> cves = [ ] <TAB> try : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> cves = [ self. id ] <TAB> <TAB> if self. metadata_json and self. metadata_json. get ( ""CVE"", [ ] ) : <TAB> <TAB> <TAB> for cve_el in self. metadata_json. get ( ""CVE"", [ ] ) : <TAB> <TAB> <TAB> <TAB> if type ( cve_el ) == dict : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> cve_id = cve_el. get ( ""Name"", None ) <TAB> <TAB> <TAB> <TAB> elif type ( cve_el ) == str : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> cve_id = cve_el <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> cve_id = None <TAB> <TAB> <TAB> <TAB> if cve_id and cve_id not in cves : <TAB> <TAB> <TAB> <TAB> <TAB> cves. append ( cve_id ) <TAB> except Exception as err : <TAB> <TAB> log. warn ( <TAB> <TAB> <TAB> ""failed to gather NVD information for vulnerability due to exception: {}"". format ( <TAB> <TAB> <TAB> <TAB> str ( err ) <TAB> <TAB> <TAB> ) <TAB> <TAB> ) <TAB> return cves",False,self.id.startswith('CVE-'),self.id in self.ids,0.6551922559738159
|
||
|
4789,"def handle ( self, * args, ** options ) : <TAB> from django. conf import settings <TAB> style = color_style ( ) <TAB> template_dirs = set ( get_template_setting ( ""DIRS"" ) ) <TAB> template_dirs |= set ( options. get ( ""includes"", [ ] ) ) <TAB> template_dirs |= set ( <TAB> <TAB> getattr ( settings, ""VALIDATE_TEMPLATES_EXTRA_TEMPLATE_DIRS"", [ ] ) <TAB> ) <TAB> <TAB> <TAB> if hasattr ( settings, ""TEMPLATES"" ) : <TAB> <TAB> settings. TEMPLATES [ 0 ] [ ""DIRS"" ] = list ( template_dirs ) <TAB> else : <TAB> <TAB> settings. TEMPLATE_DIRS = list ( template_dirs ) <TAB> settings. TEMPLATE_DEBUG = True <TAB> verbosity = int ( options. get ( ""verbosity"", 1 ) ) <TAB> errors = 0 <TAB> for template_dir in template_dirs : <TAB> <TAB> for root, dirs, filenames in os. walk ( template_dir ) : <TAB> <TAB> <TAB> for filename in filenames : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> if filename. endswith ( ""~"" ) : <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> filepath = os. path. join ( root, filename ) <TAB> <TAB> <TAB> <TAB> if verbosity > 1 : <TAB> <TAB> <TAB> <TAB> <TAB> print ( filepath ) <TAB> <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> <TAB> get_template ( filepath ) <TAB> <TAB> <TAB> <TAB> except Exception as e : <TAB> <TAB> <TAB> <TAB> <TAB> errors += 1 <TAB> <TAB> <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""%s: %s"" <TAB> <TAB>",False,filename.endswith('.swp'),filename.endswith('.yaml'),0.6570688486099243
|
||
|
4790,"def get_all_function_symbols ( self, module = ""kernel"" ) : <TAB> """"""Gets all the function tuples for the given module"""""" <TAB> ret = [ ] <TAB> symtable = self. type_map <TAB> if module in symtable : <TAB> <TAB> mod = symtable [ module ] <TAB> <TAB> for ( addr, ( name, _sym_types ) ) in mod. items ( ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> addr = addr + self. shift_address <TAB> <TAB> <TAB> ret. append ( [ name, addr ] ) <TAB> else : <TAB> <TAB> debug. info ( ""All symbols requested for non-existent module %s"" % module ) <TAB> return ret",False,self.shift_address and addr,addr in self.shift_address,0.6546943783760071
|
||
|
4791,"def parse_until_text ( self, * text ) : <TAB> startpos = self. match_position <TAB> text_re = r""|"". join ( text ) <TAB> brace_level = 0 <TAB> while True : <TAB> <TAB> match = self. match ( r""#.*\n"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> match = self. match ( r""(\""\""\""|\'\'\'|\""|\')((?<!\\)\\\1|.)*?\1"", re. S ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> match = self. match ( r""(%s)"" % text_re ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if match. group ( 1 ) == ""}"" and brace_level > 0 : <TAB> <TAB> <TAB> <TAB> brace_level -= 1 <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> return self. text [ <TAB> <TAB> <TAB> <TAB> startpos : self. match_position - len ( match. group ( 1 ) ) <TAB> <TAB> <TAB> ], match. group ( 1 ) <TAB> <TAB> match = self. match ( r""(.*?)(?=\""|\'|#|%s)"" % text_re, re. S ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> brace_level += match. group ( 1 ). count ( ""{"" ) <TAB> <TAB> <TAB> brace_level -= match. group ( 1 ). count ( ""}"" ) <TAB> <TAB> <TAB> continue <TAB> <TAB> raise exceptions. SyntaxException ( <TAB> <TAB> <TAB> ""Expected: %s"" % "","". join ( text ), ** self. exception_kwargs <TAB> <TAB> )",False,match,not match,0.6712772250175476
|
||
|
4792,"def get_amount ( ref_doc, payment_account = None ) : <TAB> """"""get amount based on doctype"""""" <TAB> dt = ref_doc. doctype <TAB> if dt in [ ""Sales Order"", ""Purchase Order"" ] : <TAB> <TAB> grand_total = flt ( ref_doc. grand_total ) - flt ( ref_doc. advance_paid ) <TAB> elif dt in [ ""Sales Invoice"", ""Purchase Invoice"" ] : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> grand_total = flt ( ref_doc. outstanding_amount ) <TAB> <TAB> else : <TAB> <TAB> <TAB> grand_total = flt ( ref_doc. outstanding_amount ) / ref_doc. conversion_rate <TAB> elif dt == ""POS Invoice"" : <TAB> <TAB> for pay in ref_doc. payments : <TAB> <TAB> <TAB> if pay. type == ""Phone"" and pay. account == payment_account : <TAB> <TAB> <TAB> <TAB> grand_total = pay. amount <TAB> <TAB> <TAB> <TAB> break <TAB> elif dt == ""Fees"" : <TAB> <TAB> grand_total = ref_doc. outstanding_amount <TAB> if grand_total > 0 : <TAB> <TAB> return grand_total <TAB> else : <TAB> <TAB> frappe. throw ( _ ( ""Payment Entry is already created"" ) )",False,ref_doc.party_account_currency == ref_doc.currency,dt == 'Tank',0.6511203050613403
|
||
|
4793,"def main ( client, user_id ) : <TAB> <TAB> user_team_association_service = client. GetService ( <TAB> <TAB> ""UserTeamAssociationService"", version = ""v202005"" <TAB> ) <TAB> <TAB> statement = ( <TAB> <TAB> ad_manager. StatementBuilder ( version = ""v202005"" ) <TAB> <TAB>. Where ( ""userId = :userId"" ) <TAB> <TAB>. WithBindVariable ( ""userId"", int ( user_id ) ) <TAB> ) <TAB> <TAB> <TAB> while True : <TAB> <TAB> response = user_team_association_service. getUserTeamAssociationsByStatement ( <TAB> <TAB> <TAB> statement. ToStatement ( ) <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> for user_team_association in response [ ""results"" ] : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> <TAB> 'User team association with user ID ""%d"" and team ID ""%d"" was'<TAB> <TAB> <TAB> <TAB> <TAB> ""found.\n"" <TAB> <TAB> <TAB> <TAB> <TAB> % ( user_team_association [ ""userId"" ], user_team_association [ ""teamId"" ] ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> statement. offset += statement. limit <TAB> <TAB> else : <TAB> <TAB> <TAB> break <TAB> print ( ""\nNumber of results found: %s"" % response [ ""totalResultSetSize"" ] )",False,'results' in response and len(response['results']),response[0] == 'results',0.6563087105751038
|
||
|
4794,"def _format_entry ( entry, src ) : <TAB> if entry : <TAB> <TAB> result = [ ] <TAB> <TAB> for x in entry. split ( "","" ) : <TAB> <TAB> <TAB> x = x. strip ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> result. append ( relpath ( os. path. join ( src, x ), src ) ) <TAB> <TAB> <TAB> elif os. path. exists ( x ) : <TAB> <TAB> <TAB> <TAB> result. append ( relpath ( os. path. abspath ( x ), src ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> raise RuntimeError ( ""No entry script %s found"" % x ) <TAB> <TAB> return "","". join ( result )",False,"os.path.exists(os.path.join(src, x))",os.path.exists(x),0.6534078121185303
|
||
|
4795,"def register ( <TAB> self, <TAB> stats : Dict [ str, Optional [ Union [ Num, Dict [ str, Num ] ] ] ], <TAB> weight : Num = None, ) -> None : <TAB> assert check_argument_types ( ) <TAB> if self. _finished : <TAB> <TAB> raise RuntimeError ( ""Already finished"" ) <TAB> if len ( self. _seen_keys_in_the_step ) == 0 : <TAB> <TAB> <TAB> <TAB> self. total_count += 1 <TAB> <TAB> self. count += 1 <TAB> for key2, v in stats. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise RuntimeError ( f""{key2} is reserved."" ) <TAB> <TAB> if key2 in self. _seen_keys_in_the_step : <TAB> <TAB> <TAB> raise RuntimeError ( f""{key2} is registered twice."" ) <TAB> <TAB> if v is None : <TAB> <TAB> <TAB> v = np. nan <TAB> <TAB> r = to_reported_value ( v, weight ) <TAB> <TAB> if key2 not in self. stats : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> nan = to_reported_value ( np. nan, None if weight is None else 0 ) <TAB> <TAB> <TAB> self. stats [ key2 ]. extend ( <TAB> <TAB> <TAB> <TAB> r if i == self. count - 1 else nan for i in range ( self. count ) <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. stats [ key2 ]. append ( r ) <TAB> <TAB> self. _seen_keys_in_the_step. add ( key2 )",False,key2 in _reserved,key2 in self.reserved,0.6625944375991821
|
||
|
4796,"def __init__ ( self, proxy ) : <TAB> KeepAliveHandler. __init__ ( self ) <TAB> urllib2. HTTPSHandler. __init__ ( self, debuglevel = 0 ) <TAB> self. _proxy = proxy <TAB> try : <TAB> <TAB> host, port = self. _proxy. split ( "":"" ) <TAB> except : <TAB> <TAB> msg = ( <TAB> <TAB> <TAB> ""The proxy you are specifying (%s) is invalid! The expected"" <TAB> <TAB> <TAB> "" format is <ip_address>:<port> is expected."" <TAB> <TAB> ) <TAB> <TAB> raise BaseFrameworkException ( msg % proxy ) <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _proxy = None",False,not host or not port,proxy is None,0.6612662076950073
|
||
|
4797,"def cmd_query ( self, host, name ) : <TAB> """"""implementation of the ``query`` command"""""" <TAB> name = name. upper ( ) <TAB> self. logger. debug ( ""querying for %r"", name ) <TAB> if name not in self. services : <TAB> <TAB> self. logger. debug ( ""no such service"" ) <TAB> <TAB> return ( ) <TAB> oldest = time. time ( ) - self. pruning_timeout <TAB> all_servers = sorted ( self. services [ name ]. items ( ), key = lambda x : x [ 1 ] ) <TAB> servers = [ ] <TAB> for addrinfo, t in all_servers : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. logger. debug ( ""discarding stale %s:%s"", * addrinfo ) <TAB> <TAB> <TAB> self. _remove_service ( name, addrinfo ) <TAB> <TAB> else : <TAB> <TAB> <TAB> servers. append ( addrinfo ) <TAB> self. logger. debug ( ""replying with %r"", servers ) <TAB> return tuple ( servers )",False,t < oldest,oldest,0.6760469675064087
|
||
|
4798,"def _attach_field_to_tree ( field, subtree ) : <TAB> splitted_field = field. split ( ""."", 1 ) <TAB> if len ( splitted_field ) == 1 : <TAB> <TAB> new_parts = list ( subtree [ LEAF_MARKER ] ) <TAB> <TAB> new_parts. extend ( splitted_field ) <TAB> <TAB> subtree [ LEAF_MARKER ] = list ( set ( new_parts ) ) <TAB> else : <TAB> <TAB> node, remainder = splitted_field <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> subtree [ node ] = defaultdict ( dict, LEAF_CONSTRAINT ) <TAB> <TAB> _attach_field_to_tree ( remainder, subtree [ node ] )",True,node not in subtree,node not in subtree,0.6730892658233643
|
||
|
4799,"def _files_to_data ( req_args : dict ) -> List [ BinaryIO ] : <TAB> open_files = [ ] <TAB> files = req_args. pop ( ""files"", None ) <TAB> if files is not None : <TAB> <TAB> for k, v in files. items ( ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> f = open ( v. encode ( ""utf-8"", ""ignore"" ), ""rb"" ) <TAB> <TAB> <TAB> <TAB> open_files. append ( f ) <TAB> <TAB> <TAB> <TAB> req_args [ ""data"" ]. update ( { k : f } ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> req_args [ ""data"" ]. update ( { k : v } ) <TAB> return open_files",False,"isinstance(v, str)","isinstance(v, unicode)",0.6523703336715698
|
||
|
4800,"def get_prompt_tokens ( ) -> List [ Tuple [ str, str ] ] : <TAB> tokens = [ ] <TAB> tokens. append ( ( ""class:qmark"", qmark ) ) <TAB> tokens. append ( ( ""class:question"", "" {} "". format ( message ) ) ) <TAB> if ic. is_answered : <TAB> <TAB> nbr_selected = len ( ic. selected_options ) <TAB> <TAB> if nbr_selected == 0 : <TAB> <TAB> <TAB> tokens. append ( ( ""class:answer"", ""done"" ) ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> if isinstance ( ic. get_selected_values ( ) [ 0 ]. title, list ) : <TAB> <TAB> <TAB> <TAB> ts = ic. get_selected_values ( ) [ 0 ]. title <TAB> <TAB> <TAB> <TAB> tokens. append ( <TAB> <TAB> <TAB> <TAB> <TAB> ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""class:answer"", <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> """". join ( [ token [ 1 ] for token in ts ] ), <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> tokens. append ( <TAB> <TAB> <TAB> <TAB> <TAB> ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""class:answer"", <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""[{}]"". format ( ic. get_selected_values ( ) [ 0 ]. title ), <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> tokens. append ( ( ""class:answer"", ""done ({} selections)"". format ( nbr_selected ) ) ) <TAB> else : <TAB> <TAB",True,nbr_selected == 1,nbr_selected == 1,0.6680488586425781
|
||
|
4801,"def browse ( self, ** kw ) : <TAB> for url in self. urls : <TAB> <TAB> if url. endswith ( ""/%exchange_id"" ) or ""/receipts/"" in url : <TAB> <TAB> <TAB> continue <TAB> <TAB> url = url. replace ( <TAB> <TAB> <TAB> ""/team/invoices/%invoice_id"", ""/org/invoices/%s"" % self. invoice_id <TAB> <TAB> ) <TAB> <TAB> url = url. replace ( ""/%invoice_id"", ""/%s"" % self. invoice_id ) <TAB> <TAB> assert ""/%"" not in url <TAB> <TAB> try : <TAB> <TAB> <TAB> r = self. client. GET ( url, ** kw ) <TAB> <TAB> except Response as e : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise <TAB> <TAB> <TAB> r = e <TAB> <TAB> assert r. code!= 404 <TAB> <TAB> assert r. code < 500 <TAB> <TAB> assert not overescaping_re. search ( r. text )",False,e.code == 404 or e.code >= 500,e.code != 200,0.666318416595459
|
||
|
4802,"def onClicked ( event ) : <TAB> if not self. path : <TAB> <TAB> if not os. path. exists ( mh. getPath ( ""render"" ) ) : <TAB> <TAB> <TAB> os. makedirs ( mh. getPath ( ""render"" ) ) <TAB> <TAB> self. path = mh. getPath ( ""render"" ) <TAB> filename, ftype = mh. getSaveFileName ( <TAB> <TAB> os. path. splitext ( self. path ) [ 0 ], <TAB> <TAB> ""PNG Image (*.png);;JPEG Image (*.jpg);;Thumbnail (*.thumb);;All files (*.*)"", <TAB> ) <TAB> if filename : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. image. save ( filename, iformat = ""PNG"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. image. save ( filename ) <TAB> <TAB> self. path = os. path. dirname ( filename )",False,'Thumbnail' in ftype,self.image.isOpen(filename),0.6626404523849487
|
||
|
4803,"def get_or_create_intersection_pointer ( <TAB> schema : s_schema. Schema, <TAB> ptrname : str, <TAB> source : s_objtypes. ObjectType, <TAB> components : Iterable [ Pointer ], <TAB> *, <TAB> modname : Optional [ str ] = None, ) -> Tuple [ s_schema. Schema, Pointer ] : <TAB> components = list ( components ) <TAB> if len ( components ) == 1 : <TAB> <TAB> return schema, components [ 0 ] <TAB> targets = list ( filter ( None, [ p. get_target ( schema ) for p in components ] ) ) <TAB> schema, target = utils. get_intersection_type ( schema, targets, module = modname ) <TAB> cardinality = qltypes. SchemaCardinality. ONE <TAB> for component in components : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> cardinality = qltypes. SchemaCardinality. MANY <TAB> <TAB> <TAB> break <TAB> metacls = type ( components [ 0 ] ) <TAB> default_base_name = metacls. get_default_base_name ( ) <TAB> assert default_base_name is not None <TAB> genptr = schema. get ( default_base_name, type = Pointer ) <TAB> schema, result = genptr. get_derived ( <TAB> <TAB> schema, <TAB> <TAB> source, <TAB> <TAB> target, <TAB> <TAB> derived_name_base = sn. Name ( module = ""__"", name = ptrname ), <TAB> <TAB> attrs = { <TAB> <TAB> <TAB> ""intersection_of"" : so. ObjectSet. create ( schema, components ), <TAB> <TAB> <TAB> ""cardinality"" : cardinality, <TAB> <TAB> }, <TAB> ) <TAB> return schema, result",False,component.get_cardinality(schema) is qltypes.SchemaCardinality.MANY,len(components) == 1,0.653479814529419
|
||
|
4804,"def ensure_tool_run_response_okay ( submit_response_object, request_desc, inputs = None ) : <TAB> if submit_response_object. status_code!= 200 : <TAB> <TAB> message = None <TAB> <TAB> dynamic_param_error = False <TAB> <TAB> try : <TAB> <TAB> <TAB> err_response = submit_response_object. json ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> param_errors = err_response [ ""param_errors"" ] <TAB> <TAB> <TAB> <TAB> if ""dbkey"" in param_errors : <TAB> <TAB> <TAB> <TAB> <TAB> dbkey_err_obj = param_errors [ ""dbkey"" ] <TAB> <TAB> <TAB> <TAB> <TAB> dbkey_val = dbkey_err_obj. get ( ""parameter_value"" ) <TAB> <TAB> <TAB> <TAB> <TAB> message = ""Invalid dbkey specified [%s]"" % dbkey_val <TAB> <TAB> <TAB> <TAB> for key, val in param_errors. items ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> if isinstance ( val, dict ) and val. get ( ""is_dynamic"" ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> dynamic_param_error = True <TAB> <TAB> <TAB> if message is None : <TAB> <TAB> <TAB> <TAB> message = err_response. get ( ""err_msg"" ) or None <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> if message is None : <TAB> <TAB> <TAB> template = ""Request to %s failed - invalid JSON content returned from Galaxy server [%s]"" <TAB> <TAB> <TAB> message = template % ( request_desc, submit_response_object. text ) <TAB> <TAB> raise RunToolException ( message, inputs, dynamic_param_error = dynamic_param_error ) <TAB> submit_response = submit_response_",True,'param_errors' in err_response,'param_errors' in err_response,0.6534022688865662
|
||
|
4805,def _push_w_to_instances ( self ) : <TAB> for scenario in self. _scenario_tree. _scenarios : <TAB> <TAB> scenario. push_w_to_instance ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _problem_states. objective_updated [ scenario. _name ] = True,False,self._problem_states.has_ph_objective_weight_terms[scenario._name],scenario.isValid(),0.6521754264831543
|
||
|
4806,"def build ( self, input_shape ) : <TAB> if isinstance ( input_shape, list ) and len ( input_shape ) == 2 : <TAB> <TAB> self. data_mode = ""disjoint"" <TAB> <TAB> self. F = input_shape [ 0 ] [ - 1 ] <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. data_mode = ""single"" <TAB> <TAB> else : <TAB> <TAB> <TAB> self. data_mode = ""batch"" <TAB> <TAB> self. F = input_shape [ - 1 ]",False,len(input_shape) == 2,"isinstance(input_shape, list)",0.6551178693771362
|
||
|
4807,"def untokenize ( self, iterable ) : <TAB> for t in iterable : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. compat ( t, iterable ) <TAB> <TAB> <TAB> break <TAB> <TAB> tok_type, token, start, end, line = t <TAB> <TAB> self. add_whitespace ( start ) <TAB> <TAB> self. tokens. append ( token ) <TAB> <TAB> self. prev_row, self. prev_col = end <TAB> <TAB> if tok_type in ( NEWLINE, NL ) : <TAB> <TAB> <TAB> self. prev_row += 1 <TAB> <TAB> <TAB> self. prev_col = 0 <TAB> return """". join ( self. tokens )",False,len(t) == 2,t in EMPTY_tokens,0.6574805974960327
|
||
|
4808,"def destroy ( self, wipe = False ) : <TAB> if wipe : <TAB> <TAB> self. depl. logger. warn ( ""wipe is not supported"" ) <TAB> try : <TAB> <TAB> node = self. node ( ) <TAB> <TAB> question = ""are you sure you want to destroy {0}?"" <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return False <TAB> <TAB> known_hosts. remove ( self. public_ipv4, self. public_host_key ) <TAB> <TAB> self. log ( ""destroying the GCE machine..."" ) <TAB> <TAB> node. destroy ( ) <TAB> except libcloud. common. google. ResourceNotFoundError : <TAB> <TAB> self. warn ( ""seems to have been destroyed already"" ) <TAB> self. _node_deleted ( ) <TAB> <TAB> for k, v in self. block_device_mapping. items ( ) : <TAB> <TAB> if v. get ( ""deleteOnTermination"", False ) : <TAB> <TAB> <TAB> self. _delete_volume ( v [ ""disk_name"" ], v [ ""region"" ] ) <TAB> <TAB> self. update_block_device_mapping ( k, None ) <TAB> return True",False,not self.depl.logger.confirm(question.format(self.full_name)),not node.exists(),0.6497131586074829
|
||
|
4809,"def access_entry_point_target ( self, trans, entry_point_id ) : <TAB> entry_point = trans. sa_session. query ( model. InteractiveToolEntryPoint ). get ( <TAB> <TAB> entry_point_id <TAB> ) <TAB> if self. app. interactivetool_manager. can_access_entry_point ( trans, entry_point ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return self. target_if_active ( trans, entry_point ) <TAB> <TAB> elif entry_point. deleted : <TAB> <TAB> <TAB> raise exceptions. MessageException ( <TAB> <TAB> <TAB> <TAB> ""InteractiveTool has ended. You will have to start a new one."" <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise exceptions. MessageException ( <TAB> <TAB> <TAB> <TAB> ""InteractiveTool is not active. If you recently launched this tool it may not be ready yet, please wait a moment and refresh this page."" <TAB> <TAB> <TAB> ) <TAB> raise exceptions. ItemAccessibilityException ( <TAB> <TAB> ""You do not have access to this InteractiveTool entry point."" <TAB> )",False,entry_point.active,entry_point.id,0.6568092703819275
|
||
|
4810,"def run ( self ) : <TAB> """"""Process queries from task queue, stop if processor is None."""""" <TAB> while True : <TAB> <TAB> try : <TAB> <TAB> <TAB> processor, iprot, oprot, otrans, callback = self. queue. get ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> processor. process ( iprot, oprot ) <TAB> <TAB> <TAB> callback ( True, otrans. getvalue ( ) ) <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> logging. exception ( ""Exception while processing request"" ) <TAB> <TAB> <TAB> callback ( False, """" )",True,processor is None,processor is None,0.6669086217880249
|
||
|
4811,"def create_resource ( self, name, ** kwargs ) : <TAB> temp_dir = os. path. join ( tempfile. gettempdir ( ), self. random_name ) <TAB> if not os. path. exists ( temp_dir ) : <TAB> <TAB> os. mkdir ( temp_dir ) <TAB> with open ( os. path. join ( temp_dir, ""readme"" ), ""w"" ) as f : <TAB> <TAB> f. write ( <TAB> <TAB> <TAB> ""This directory contains test files generated by Azure CLI storage command "" <TAB> <TAB> <TAB> ""module tests."" <TAB> <TAB> ) <TAB> for folder_name in [ ""apple"", ""butter"", ""butter/charlie"", ""duff/edward"" ] : <TAB> <TAB> for file_index in range ( 10 ) : <TAB> <TAB> <TAB> file_path = os. path. join ( temp_dir, folder_name, ""file_%s"" % file_index ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> os. makedirs ( os. path. dirname ( file_path ) ) <TAB> <TAB> <TAB> with open ( file_path, ""w"" ) as f : <TAB> <TAB> <TAB> <TAB> f. write ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Azure CLI storage command module test sample file. origin:"" <TAB> <TAB> <TAB> <TAB> <TAB> "" %s"" % file_path <TAB> <TAB> <TAB> <TAB> ) <TAB> setattr ( self, ""_temp_dir"", temp_dir ) <TAB> return { self. parameter_name : temp_dir }",False,not os.path.exists(os.path.dirname(file_path)),not os.path.exists(file_path),0.6462835073471069
|
||
|
4812,"def main ( local_port = None, remote_port = None, * args ) : <TAB> server_list = [ ] + teredo_server_list <TAB> for arg in args : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> server_list. append ( arg ) <TAB> <TAB> elif isinstance ( arg, list ) : <TAB> <TAB> <TAB> server_list += arg <TAB> <TAB> elif isinstance ( arg, tuple ) : <TAB> <TAB> <TAB> server_list += list ( arg ) <TAB> prober = teredo_prober ( server_list, local_port = local_port, remote_port = remote_port ) <TAB> need_probe = recommend = None <TAB> if not prober. qualified : <TAB> <TAB> print ( ( warn_3 % prober. nat_type ) ) <TAB> <TAB> if prober. nat_type == ""symmetric"" and input ( confirm_force ). lower ( ) == ""y"" : <TAB> <TAB> <TAB> need_probe = True <TAB> <TAB> <TAB> prober. qualified = True <TAB> elif prober. nat_type == ""unknown"" : <TAB> <TAB> print ( warn_4 ) <TAB> <TAB> recommend = prober. ip2server [ prober. last_server_ip ] <TAB> else : <TAB> <TAB> print ( ( nat_type_result % prober. nat_type ) ) <TAB> <TAB> need_probe = True <TAB> if need_probe : <TAB> <TAB> qualified_list = prober. eval_servers ( ) <TAB> <TAB> for qualified, server, server_ip, cost in qualified_list : <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> ( <TAB> <TAB> <TAB> <TAB> <TAB> ""%s %s %s"" <TAB> <TAB> <TAB> <TAB> <TAB> % ( server_ip, server, ""%sms"" % cost if qualified else ""timedout"" ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB",True,"isinstance(arg, str)","isinstance(arg, str)",0.6513587236404419
|
||
|
4813,"def pre_compute ( <TAB> expr, data, comfortable_memory = None, chunksize = None, blocksize = None, ** kwargs ) : <TAB> comfortable_memory = comfortable_memory or min ( 1e9, available_memory ( ) / 4 ) <TAB> kwargs = dict ( ) <TAB> <TAB> if os. path. getsize ( data. path ) > comfortable_memory : <TAB> <TAB> do_chunk = True <TAB> <TAB> if chunksize is not None : <TAB> <TAB> <TAB> warn ( ""Deprecation warning: chunksize keyword renamed to blocksize"" ) <TAB> <TAB> <TAB> blocksize = chunksize <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> kwargs [ ""blocksize"" ] = blocksize <TAB> else : <TAB> <TAB> do_chunk = False <TAB> <TAB> oexpr = optimize ( expr, data ) <TAB> leaf = oexpr. _leaves ( ) [ 0 ] <TAB> pth = list ( path ( oexpr, leaf ) ) <TAB> if len ( pth ) >= 2 and isinstance ( pth [ - 2 ], ( Projection, Field ) ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> kwargs [ ""usecols"" ] = list ( map ( str, pth [ - 2 ]. fields ) ) <TAB> if do_chunk : <TAB> <TAB> return dd. read_csv ( data. path, ** kwargs ) <TAB> else : <TAB> <TAB> return into ( pd. DataFrame, data, dshape = leaf. dshape, ** kwargs )",True,blocksize is not None,blocksize is not None,0.6589226126670837
|
||
|
4814,"def _send_until_done ( self, data ) : <TAB> while True : <TAB> <TAB> try : <TAB> <TAB> <TAB> return self. connection. send ( data ) <TAB> <TAB> except OpenSSL. SSL. WantWriteError : <TAB> <TAB> <TAB> wr = util. wait_for_write ( self. socket, self. socket. gettimeout ( ) ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise timeout ( ) <TAB> <TAB> <TAB> continue <TAB> <TAB> except OpenSSL. SSL. SysCallError as e : <TAB> <TAB> <TAB> raise SocketError ( str ( e ) )",False,not wr,wr.returncode != 0,0.6841272115707397
|
||
|
4815,"def encode ( self, encodeFun, value, defMode, maxChunkSize ) : <TAB> substrate, isConstructed = self. encodeValue ( encodeFun, value, defMode, maxChunkSize ) <TAB> tagSet = value. getTagSet ( ) <TAB> if tagSet : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> defMode = 1 <TAB> <TAB> return ( <TAB> <TAB> <TAB> self. encodeTag ( tagSet [ - 1 ], isConstructed ) <TAB> <TAB> <TAB> + self. encodeLength ( len ( substrate ), defMode ) <TAB> <TAB> <TAB> + substrate <TAB> <TAB> <TAB> + self. _encodeEndOfOctets ( encodeFun, defMode ) <TAB> <TAB> ) <TAB> else : <TAB> <TAB> return substrate",False,not isConstructed,len(tagSet[0]) == 0,0.6596665978431702
|
||
|
4816,"def update_cluster ( <TAB> cmd, <TAB> client, <TAB> resource_group_name, <TAB> cluster_name, <TAB> client_connection_port = None, <TAB> gateway_connection_port = None, <TAB> dns_name = None, <TAB> tags = None, ) : <TAB> try : <TAB> <TAB> cluster = client. managed_clusters. get ( resource_group_name, cluster_name ) <TAB> <TAB> if client_connection_port is not None : <TAB> <TAB> <TAB> cluster. client_connection_port = client_connection_port <TAB> <TAB> if gateway_connection_port is not None : <TAB> <TAB> <TAB> cluster. http_gateway_connection_port = gateway_connection_port <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> cluster. dns_name = dns_name <TAB> <TAB> if tags is not None : <TAB> <TAB> <TAB> cluster. tags = tags <TAB> <TAB> poller = client. managed_clusters. create_or_update ( <TAB> <TAB> <TAB> resource_group_name, cluster_name, cluster <TAB> <TAB> ) <TAB> <TAB> return LongRunningOperation ( cmd. cli_ctx ) ( poller ) <TAB> except ErrorModelException as ex : <TAB> <TAB> _log_error_exception ( ex ) <TAB> <TAB> raise",True,dns_name is not None,dns_name is not None,0.6584422588348389
|
||
|
4817,"def parseCmdLine ( self ) : <TAB> self. debug = ""--debug"" in sys. argv or ""-g"" in sys. argv <TAB> if ""--gtk2"" in sys. argv : <TAB> <TAB> self. WXPORT = ""gtk2"" <TAB> if ""--gtk3"" in sys. argv : <TAB> <TAB> self. WXPORT = ""gtk3"" <TAB> <TAB> <TAB> <TAB> for key, default in Configuration. __dict__. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> for idx, arg in enumerate ( sys. argv ) : <TAB> <TAB> <TAB> if arg and arg. startswith ( key + ""="" ) : <TAB> <TAB> <TAB> <TAB> value = arg. split ( ""="", 1 ) [ 1 ] <TAB> <TAB> <TAB> <TAB> if isinstance ( default, int ) : <TAB> <TAB> <TAB> <TAB> <TAB> value = int ( value ) <TAB> <TAB> <TAB> <TAB> setattr ( self, key, value ) <TAB> <TAB> <TAB> <TAB> sys. argv [ idx ] = None <TAB> <TAB> sys. argv = [ arg for arg in sys. argv if arg is not None ]",False,key[0] < 'A' or key[0] > 'Z',key in self.__dict__,0.6565441489219666
|
||
|
4818,"def _check_previous_process ( self ) : <TAB> """"""Check if there's a process leftover and shut it down if so"""""" <TAB> if not self. pid_file or not os. path. exists ( self. pid_file ) : <TAB> <TAB> return <TAB> pid_file = os. path. abspath ( self. pid_file ) <TAB> self. log. warning ( ""Found proxy pid file: %s"", pid_file ) <TAB> try : <TAB> <TAB> with open ( pid_file, ""r"" ) as f : <TAB> <TAB> <TAB> pid = int ( f. read ( ). strip ( ) ) <TAB> except ValueError : <TAB> <TAB> self. log. warning ( ""%s did not appear to contain a pid"", pid_file ) <TAB> <TAB> self. _remove_pid_file ( ) <TAB> <TAB> return <TAB> try : <TAB> <TAB> self. _check_pid ( pid ) <TAB> except ProcessLookupError : <TAB> <TAB> self. log. warning ( ""Proxy no longer running at pid=%s"", pid ) <TAB> <TAB> self. _remove_pid_file ( ) <TAB> <TAB> return <TAB> <TAB> self. log. warning ( ""Proxy still running at pid=%s"", pid ) <TAB> if os. name!= ""nt"" : <TAB> <TAB> sig_list = [ signal. SIGTERM ] * 2 + [ signal. SIGKILL ] <TAB> for i in range ( 3 ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. _terminate_win ( pid ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> os. kill ( pid, sig_list [ i ] ) <TAB> <TAB> except ProcessLookupError : <TAB> <TAB> <TAB> break <TAB> <TAB> time. sleep ( 1 ) <TAB> <TAB> try : <TAB> <TAB> <TAB> self. _check_pid ( pid ) <TAB> <TAB> except ProcessLookupError : <TAB> <TAB> <TAB",False,os.name == 'nt',sig_list[i] is None,0.6550542116165161
|
||
|
4819,"def MissingExtraStringTest ( windows ) : <TAB> """"""Return the errors from running the test"""""" <TAB> bugs = [ ] <TAB> for win in windows : <TAB> <TAB> if not win. ref : <TAB> <TAB> <TAB> continue <TAB> <TAB> for char in CharsToCheck : <TAB> <TAB> <TAB> missing_extra = """" <TAB> <TAB> <TAB> if win. window_text ( ). count ( char ) > win. ref. window_text ( ). count ( char ) : <TAB> <TAB> <TAB> <TAB> missing_extra = u""ExtraCharacters"" <TAB> <TAB> <TAB> elif win. window_text ( ). count ( char ) < win. ref. window_text ( ). count ( char ) : <TAB> <TAB> <TAB> <TAB> missing_extra = u""MissingCharacters"" <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> bugs. append ( <TAB> <TAB> <TAB> <TAB> <TAB> ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> [ <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> win, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ], <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> { ""MissingOrExtra"" : missing_extra, ""MissingOrExtraText"" : char }, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> testname, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> 0, <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> ) <TAB> return bugs",True,missing_extra,missing_extra,0.6654960513114929
|
||
|
4820,"def get_module_comment ( self, attrname : str ) -> Optional [ List [ str ] ] : <TAB> try : <TAB> <TAB> analyzer = ModuleAnalyzer. for_module ( self. modname ) <TAB> <TAB> analyzer. analyze ( ) <TAB> <TAB> key = ( """", attrname ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return list ( analyzer. attr_docs [ key ] ) <TAB> except PycodeError : <TAB> <TAB> pass <TAB> return None",True,key in analyzer.attr_docs,key in analyzer.attr_docs,0.6665188670158386
|
||
|
4821,"def create_resource ( self, name, ** kwargs ) : <TAB> if not self. dev_setting_value : <TAB> <TAB> self. resource_group = self. _get_resource_group ( ** kwargs ) <TAB> <TAB> self. location = self. _get_resource_group_location ( ** kwargs ) <TAB> <TAB> cmd = ""az backup vault create -n {} -g {} --location {}"". format ( <TAB> <TAB> <TAB> name, self. resource_group, self. location <TAB> <TAB> ) <TAB> <TAB> execute ( self. cli_ctx, cmd ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> cmd = ""az backup vault backup-properties set -n {} -g {} --soft-delete-feature-state Disable"". format ( <TAB> <TAB> <TAB> <TAB> name, self. resource_group <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> execute ( self. cli_ctx, cmd ) <TAB> <TAB> return { self. parameter_name : name } <TAB> return { self. parameter_name : self. dev_setting_value }",False,not self.soft_delete,self.soft_delete_feature_state,0.6615732908248901
|
||
|
4822,"def move_api_keys ( self ) -> None : <TAB> """"""Move the API keys from cog stored config to core bot config if they exist."""""" <TAB> tokens = await self. config. tokens ( ) <TAB> youtube = await self. bot. get_shared_api_tokens ( ""youtube"" ) <TAB> twitch = await self. bot. get_shared_api_tokens ( ""twitch"" ) <TAB> for token_type, token in tokens. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> await self. bot. set_shared_api_tokens ( ""youtube"", api_key = token ) <TAB> <TAB> if token_type == ""TwitchStream"" and ""client_id"" not in twitch : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> await self. bot. set_shared_api_tokens ( ""twitch"", client_id = token ) <TAB> await self. config. tokens. clear ( )",False,token_type == 'YoutubeStream' and 'api_key' not in youtube,token_type == 'youtubeStream' and 'youtube_id' not in token,0.6559834480285645
|
||
|
4823,"def post_dis ( self ) : <TAB> if self. g2. value : <TAB> <TAB> for a in self. args : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> m = a. expr <TAB> <TAB> <TAB> a. expr = ExprMem ( ExprOp ( ""segm"", enc2segm [ self. g2. value ], m. ptr ), m. size ) <TAB> return self",False,"not isinstance(a.expr, ExprMem)",not a.expr,0.6519356966018677
|
||
|
4824,"def process_formdata ( self, valuelist ) : <TAB> if valuelist : <TAB> <TAB> if valuelist [ 0 ] == ""__None"" : <TAB> <TAB> <TAB> self. data = None <TAB> <TAB> else : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> self. data = None <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> obj = self. queryset. get ( pk = valuelist [ 0 ] ) <TAB> <TAB> <TAB> <TAB> self. data = obj <TAB> <TAB> <TAB> except DoesNotExist : <TAB> <TAB> <TAB> <TAB> self. data = None",False,self.queryset is None,valuelist[0] == '__TAB > <TAB > <TAB > <TAB > or self.queryset.exists(),0.663162350654602
|
||
|
4825,"def handle_starttag ( self, tag, attrs ) : <TAB> if tag == ""base"" : <TAB> <TAB> self. base_url = dict ( attrs ). get ( ""href"" ) <TAB> if self. scan_tag ( tag ) : <TAB> <TAB> for attr, value in attrs : <TAB> <TAB> <TAB> if self. scan_attr ( attr ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> value = strip_html5_whitespace ( value ) <TAB> <TAB> <TAB> <TAB> url = self. process_attr ( value ) <TAB> <TAB> <TAB> <TAB> link = Link ( url = url ) <TAB> <TAB> <TAB> <TAB> self. links. append ( link ) <TAB> <TAB> <TAB> <TAB> self. current_link = link",False,self.strip,self.html5_whitespace and value,0.6687150001525879
|
||
|
4826,"def check ( n, filename ) : <TAB> n = get_nodes_by_name ( n, name ) <TAB> if len ( n ) > 1 and not merge_multiple : <TAB> <TAB> raise ManifestException ( <TAB> <TAB> <TAB> ""Invalid manifest file: must have a single '%s' element"" % name <TAB> <TAB> ) <TAB> if n : <TAB> <TAB> values = [ ] <TAB> <TAB> for child in n : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> values. append ( """". join ( [ x. toxml ( ) for x in child. childNodes ] ) ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> values. append ( _get_text ( child. childNodes ). strip ( ) ) <TAB> <TAB> return "", "". join ( values )",False,allowXHTML,child.filename == filename,0.6734499931335449
|
||
|
4827,"def display_installed_jobs_list_page ( <TAB> self, <TAB> installed_repository, <TAB> data_manager_names = None, <TAB> strings_displayed = None, <TAB> strings_not_displayed = None, ) : <TAB> data_managers = installed_repository. metadata. get ( ""data_manager"", { } ). get ( <TAB> <TAB> ""data_managers"", { } <TAB> ) <TAB> if data_manager_names : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> data_manager_names = [ data_manager_names ] <TAB> <TAB> for data_manager_name in data_manager_names : <TAB> <TAB> <TAB> assert data_manager_name in data_managers, ( <TAB> <TAB> <TAB> <TAB> ""The requested Data Manager '%s' was not found in repository metadata."" <TAB> <TAB> <TAB> <TAB> % data_manager_name <TAB> <TAB> <TAB> ) <TAB> else : <TAB> <TAB> data_manager_name = list ( data_managers. keys ( ) ) <TAB> for data_manager_name in data_manager_names : <TAB> <TAB> params = { ""id"" : data_managers [ data_manager_name ] [ ""guid"" ] } <TAB> <TAB> self. visit_galaxy_url ( ""/data_manager/jobs_list"", params = params ) <TAB> <TAB> self. check_for_strings ( strings_displayed, strings_not_displayed )",False,"not isinstance(data_manager_names, list)","hasattr(data_managers, 'keys')",0.6504775285720825
|
||
|
4828,"def gvariant_args ( args : List [ Any ] ) -> str : <TAB> """"""Convert args into gvariant."""""" <TAB> gvariant = """" <TAB> for arg in args : <TAB> <TAB> if isinstance ( arg, bool ) : <TAB> <TAB> <TAB> gvariant += "" {}"". format ( str ( arg ). lower ( ) ) <TAB> <TAB> elif isinstance ( arg, ( int, float ) ) : <TAB> <TAB> <TAB> gvariant += f"" {arg}"" <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> gvariant += f' ""{arg}""' <TAB> <TAB> else : <TAB> <TAB> <TAB> gvariant += f"" {arg!s}"" <TAB> return gvariant. lstrip ( )",True,"isinstance(arg, str)","isinstance(arg, str)",0.6517902612686157
|
||
|
4829,"def wrapped ( request, * args, ** kwargs ) : <TAB> if not request. user. is_authenticated ( ) : <TAB> <TAB> request. session [ ""_next"" ] = request. get_full_path ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> redirect_uri = reverse ( <TAB> <TAB> <TAB> <TAB> ""sentry-auth-organization"", args = [ kwargs [ ""organization_slug"" ] ] <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> redirect_uri = get_login_url ( ) <TAB> <TAB> return HttpResponseRedirect ( redirect_uri ) <TAB> return func ( request, * args, ** kwargs )",True,'organization_slug' in kwargs,'organization_slug' in kwargs,0.6593064069747925
|
||
|
4830,"def test_get_message ( self ) : <TAB> async with self. chat_client : <TAB> <TAB> await self. _create_thread ( ) <TAB> <TAB> async with self. chat_thread_client : <TAB> <TAB> <TAB> message_id = await self. _send_message ( ) <TAB> <TAB> <TAB> message = await self. chat_thread_client. get_message ( message_id ) <TAB> <TAB> <TAB> assert message. id == message_id <TAB> <TAB> <TAB> assert message. type == ChatMessageType. TEXT <TAB> <TAB> <TAB> assert message. content. message == ""hello world"" <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> await self. chat_client. delete_chat_thread ( self. thread_id )",False,not self.is_playback(),self.thread_id,0.64799964427948
|
||
|
4831,"def update_from_cloudformation_json ( <TAB> cls, <TAB> original_resource, <TAB> new_resource_name, <TAB> cloudformation_json, <TAB> region_name, ) : <TAB> properties = cloudformation_json [ ""Properties"" ] <TAB> if cls. is_replacement_update ( properties ) : <TAB> <TAB> resource_name_property = cls. cloudformation_name_type ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> properties [ resource_name_property ] = new_resource_name <TAB> <TAB> new_resource = cls. create_from_cloudformation_json ( <TAB> <TAB> <TAB> properties [ resource_name_property ], cloudformation_json, region_name <TAB> <TAB> ) <TAB> <TAB> properties [ resource_name_property ] = original_resource. name <TAB> <TAB> cls. delete_from_cloudformation_json ( <TAB> <TAB> <TAB> original_resource. name, cloudformation_json, region_name <TAB> <TAB> ) <TAB> <TAB> return new_resource <TAB> else : <TAB> <TAB> if ""Path"" in properties : <TAB> <TAB> <TAB> original_resource. path = properties [ ""Path"" ] <TAB> <TAB> return original_resource",False,resource_name_property not in properties,resource_name_property in properties,0.657188892364502
|
||
|
4832,"def _validate_and_set_default_hyperparameters ( self ) : <TAB> """"""Placeholder docstring"""""" <TAB> <TAB> <TAB> for name, definition in self. hyperparameter_definitions. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> spec = definition [ ""spec"" ] <TAB> <TAB> <TAB> if ""DefaultValue"" in spec : <TAB> <TAB> <TAB> <TAB> self. hyperparam_dict [ name ] = spec [ ""DefaultValue"" ] <TAB> <TAB> <TAB> elif ""IsRequired"" in spec and spec [ ""IsRequired"" ] : <TAB> <TAB> <TAB> <TAB> raise ValueError ( ""Required hyperparameter: %s is not set"" % name )",False,name not in self.hyperparam_dict,'spec' in definition,0.6662430763244629
|
||
|
4833,"def get_feature_meta ( column, preprocessing_parameters ) : <TAB> if preprocessing_parameters [ ""normalization"" ] is not None : <TAB> <TAB> if preprocessing_parameters [ ""normalization"" ] == ""zscore"" : <TAB> <TAB> <TAB> return { <TAB> <TAB> <TAB> <TAB> ""mean"" : column. astype ( np. float32 ). mean ( ), <TAB> <TAB> <TAB> <TAB> ""std"" : column. astype ( np. float32 ). std ( ), <TAB> <TAB> <TAB> } <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> return { <TAB> <TAB> <TAB> <TAB> ""min"" : column. astype ( np. float32 ). min ( ), <TAB> <TAB> <TAB> <TAB> ""max"" : column. astype ( np. float32 ). max ( ), <TAB> <TAB> <TAB> } <TAB> <TAB> else : <TAB> <TAB> <TAB> logger. info ( <TAB> <TAB> <TAB> <TAB> ""Currently zscore and minmax are the only "" <TAB> <TAB> <TAB> <TAB> ""normalization strategies available. No {}"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> preprocessing_parameters [ ""normalization"" ] <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> return { } <TAB> else : <TAB> <TAB> return { }",False,preprocessing_parameters['normalization'] == 'minmax',preprocessing_parameters['normalization'] == 'max',0.6574020981788635
|
||
|
4834,"def setitem ( self, address, value ) : <TAB> if 0x0000 <= address < 0x2000 : <TAB> <TAB> self. rambank_enabled = ( value & 0b00001111 ) == 0b1010 <TAB> elif 0x2000 <= address < 0x4000 : <TAB> <TAB> value &= 0b00011111 <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> value = 1 <TAB> <TAB> self. bank_select_register1 = value <TAB> elif 0x4000 <= address < 0x6000 : <TAB> <TAB> self. bank_select_register2 = value & 0b11 <TAB> elif 0x6000 <= address < 0x8000 : <TAB> <TAB> self. memorymodel = value & 0b1 <TAB> elif 0xA000 <= address < 0xC000 : <TAB> <TAB> if self. rambanks is None : <TAB> <TAB> <TAB> logger. warning ( <TAB> <TAB> <TAB> <TAB> ""Game tries to set value 0x%0.2x at RAM address 0x%0.4x, but RAM "" <TAB> <TAB> <TAB> <TAB> ""banks are not initialized. Initializing %d RAM banks as "" <TAB> <TAB> <TAB> <TAB> ""precaution"" % ( value, address, self. external_ram_count ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> self. init_rambanks ( self. external_ram_count ) <TAB> <TAB> if self. rambank_enabled : <TAB> <TAB> <TAB> self. rambank_selected = ( <TAB> <TAB> <TAB> <TAB> self. bank_select_register2 if self. memorymodel == 1 else 0 <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> self. rambanks [ self. rambank_selected % self. external_ram_count ] [ <TAB> <TAB> <TAB> <TAB> address - 0xA000 <TAB> <TAB> <TAB> ] = value <TAB> else : <TAB",False,value == 0,self.memorymodel == 1,0.6700385808944702
|
||
|
4835,def find_stack_boundary ( addr ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> addr = pwndbg. memory. page_align ( int ( addr ) ) <TAB> try : <TAB> <TAB> while True : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> addr += pwndbg. memory. PAGE_SIZE <TAB> except gdb. MemoryError : <TAB> <TAB> pass <TAB> return addr,False,"b'\x7fELF' == pwndbg.memory.read(addr, 4)",pwndbg.memory.page_size(addr) == -1,0.654915452003479
|
||
|
4836,"def _test_randomness ( self, fn, trans, configs ) : <TAB> random_state = random. getstate ( ) <TAB> random. seed ( 42 ) <TAB> img = transforms. ToPILImage ( ) ( torch. rand ( 3, 16, 18 ) ) <TAB> for p in [ 0.5, 0.7 ] : <TAB> <TAB> for config in configs : <TAB> <TAB> <TAB> inv_img = fn ( img, ** config ) <TAB> <TAB> <TAB> num_samples = 250 <TAB> <TAB> <TAB> counts = 0 <TAB> <TAB> <TAB> for _ in range ( num_samples ) : <TAB> <TAB> <TAB> <TAB> tranformation = trans ( p = p, ** config ) <TAB> <TAB> <TAB> <TAB> tranformation. __repr__ ( ) <TAB> <TAB> <TAB> <TAB> out = tranformation ( img ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> counts += 1 <TAB> <TAB> <TAB> p_value = stats. binom_test ( counts, num_samples, p = p ) <TAB> <TAB> <TAB> random. setstate ( random_state ) <TAB> <TAB> <TAB> self. assertGreater ( p_value, 0.0001 )",False,out == inv_img,out,0.662338137626648
|
||
|
4837,"def get_ext_outputs ( self ) : <TAB> """"""Get a list of relative paths to C extensions in the output distro"""""" <TAB> all_outputs = [ ] <TAB> ext_outputs = [ ] <TAB> paths = { self. bdist_dir : """" } <TAB> for base, dirs, files in sorted_walk ( self. bdist_dir ) : <TAB> <TAB> for filename in files : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> all_outputs. append ( paths [ base ] + filename ) <TAB> <TAB> for filename in dirs : <TAB> <TAB> <TAB> paths [ os. path. join ( base, filename ) ] = paths [ base ] + filename + ""/"" <TAB> if self. distribution. has_ext_modules ( ) : <TAB> <TAB> build_cmd = self. get_finalized_command ( ""build_ext"" ) <TAB> <TAB> for ext in build_cmd. extensions : <TAB> <TAB> <TAB> if isinstance ( ext, Library ) : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> fullname = build_cmd. get_ext_fullname ( ext. name ) <TAB> <TAB> <TAB> filename = build_cmd. get_ext_filename ( fullname ) <TAB> <TAB> <TAB> if not os. path. basename ( filename ). startswith ( ""dl-"" ) : <TAB> <TAB> <TAB> <TAB> if os. path. exists ( os. path. join ( self. bdist_dir, filename ) ) : <TAB> <TAB> <TAB> <TAB> <TAB> ext_outputs. append ( filename ) <TAB> return all_outputs, ext_outputs",False,os.path.splitext(filename)[1].lower() in NATIVE_EXTENSIONS,filename in paths,0.6500164270401001
|
||
|
4838,"def get_list_installed_vs_path ( ) -> [ ] : <TAB> err = """" <TAB> items = [ ] <TAB> path_file = os. path. join ( <TAB> <TAB> get_sdk_path ( ), <TAB> <TAB> ""Kha"", <TAB> <TAB> ""Kinc"", <TAB> <TAB> ""Tools"", <TAB> <TAB> ""kincmake"", <TAB> <TAB> ""Data"", <TAB> <TAB> ""windows"", <TAB> <TAB> ""vswhere.exe"", <TAB> ) <TAB> if os. path. isfile ( path_file ) : <TAB> <TAB> <TAB> <TAB> cmd = path_file + "" -nologo -property installationPath"" <TAB> <TAB> process = subprocess. Popen ( cmd, stdout = subprocess. PIPE ) <TAB> <TAB> while True : <TAB> <TAB> <TAB> output = process. stdout. readline ( ). decode ( ""utf-8"" ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> if output : <TAB> <TAB> <TAB> <TAB> path = output. strip ( ) <TAB> <TAB> <TAB> <TAB> items. append ( path ) <TAB> else : <TAB> <TAB> err = 'File ""' + path_file + '"" not found.' <TAB> return items, err",False,len(output.strip()) == 0 and process.poll() is not None,not output,0.6503398418426514
|
||
|
4839,"def process ( self ) : <TAB> inputs, outputs = self. inputs, self. outputs <TAB> if not all ( s. is_linked for s in [ inputs [ ""vertices"" ], inputs [ ""polygons"" ] ] ) : <TAB> <TAB> return <TAB> poly_or_edge_linked = outputs [ ""edges"" ]. is_linked or outputs [ ""polygons"" ]. is_linked <TAB> if not ( outputs [ ""vertices"" ]. is_linked and poly_or_edge_linked ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return <TAB> verts = Vector_generate ( inputs [ ""vertices"" ]. sv_get ( ) ) <TAB> polys = inputs [ ""polygons"" ]. sv_get ( ) <TAB> thickness = inputs [ ""thickness"" ]. sv_get ( ) [ 0 ] <TAB> verts_out = [ ] <TAB> edges_out = [ ] <TAB> polys_out = [ ] <TAB> for v, p, t in zip ( verts, polys, repeat_last ( thickness ) ) : <TAB> <TAB> res = wireframe ( v, p, t, self ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return <TAB> <TAB> verts_out. append ( res [ 0 ] ) <TAB> <TAB> edges_out. append ( res [ 1 ] ) <TAB> <TAB> polys_out. append ( res [ 2 ] ) <TAB> outputs [ ""vertices"" ]. sv_set ( verts_out ) <TAB> outputs [ ""edges"" ]. sv_set ( edges_out ) <TAB> outputs [ ""polygons"" ]. sv_set ( polys_out )",False,not res,res is not None,0.6901425123214722
|
||
|
4840,"def _init_weights ( self, module ) : <TAB> """"""Initialize the weights."""""" <TAB> if isinstance ( module, nn. Embedding ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> nn. init. normal_ ( module. weight, mean = 0, std = self. config. embed_init_std ) <TAB> if isinstance ( module, nn. Linear ) : <TAB> <TAB> if self. config is not None and self. config. init_std is not None : <TAB> <TAB> <TAB> nn. init. normal_ ( module. weight, mean = 0, std = self. config. init_std ) <TAB> <TAB> <TAB> if hasattr ( module, ""bias"" ) and module. bias is not None : <TAB> <TAB> <TAB> <TAB> nn. init. constant_ ( module. bias, 0.0 ) <TAB> if isinstance ( module, nn. LayerNorm ) : <TAB> <TAB> module. bias. data. zero_ ( ) <TAB> <TAB> module. weight. data. fill_ ( 1.0 )",False,self.config is not None and self.config.embed_init_std is not None,self.config is not None and module.embed_init_std is not None,0.6510850787162781
|
||
|
4841,"def do_macho ( file, bits, endian ) : <TAB> <TAB> cpu_type, cpu_sub_type, file_type, n_commands, size_of_commands, flags = read_data ( <TAB> <TAB> file, endian, 6 <TAB> ) <TAB> <TAB> if bits == 64 : <TAB> <TAB> read_data ( file, endian ) <TAB> <TAB> for _ in range ( n_commands ) : <TAB> <TAB> where = file. tell ( ) <TAB> <TAB> <TAB> <TAB> cmd, cmd_size = read_data ( file, endian, 2 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> name_offset = read_data ( file, endian ) <TAB> <TAB> <TAB> file. seek ( where + name_offset, os. SEEK_SET ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> load = file. read ( cmd_size - name_offset ). decode ( ) <TAB> <TAB> <TAB> load = load [ : load. index ( ""\0"" ) ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if load == what : <TAB> <TAB> <TAB> <TAB> file. seek ( where + name_offset, os. SEEK_SET ) <TAB> <TAB> <TAB> <TAB> file. write ( value. encode ( ) + b""\0"" ) <TAB> <TAB> <TAB> <TAB> file. seek ( where + cmd_size, os. SEEK_SET )",False,cmd == LC_LOAD_DYLIB,flags & 1,0.6619106531143188
|
||
|
4842,"def notify_webhooks ( logentry_ids : list ) : <TAB> if not isinstance ( logentry_ids, list ) : <TAB> <TAB> logentry_ids = [ logentry_ids ] <TAB> qs = LogEntry. all. select_related ( ""event"", ""event__organizer"" ). filter ( <TAB> <TAB> id__in = logentry_ids <TAB> ) <TAB> _org, _at, webhooks = None, None, None <TAB> for logentry in qs : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> break <TAB> <TAB> notification_type = logentry. webhook_type <TAB> <TAB> if not notification_type : <TAB> <TAB> <TAB> break <TAB> <TAB> if ( <TAB> <TAB> <TAB> _org!= logentry. organizer <TAB> <TAB> <TAB> or _at!= logentry. action_type <TAB> <TAB> <TAB> or webhooks is None <TAB> <TAB> ) : <TAB> <TAB> <TAB> _org = logentry. organizer <TAB> <TAB> <TAB> _at = logentry. action_type <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> event_listener = WebHookEventListener. objects. filter ( <TAB> <TAB> <TAB> <TAB> webhook = OuterRef ( ""pk"" ), action_type = notification_type. action_type <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> webhooks = WebHook. objects. annotate ( has_el = Exists ( event_listener ) ). filter ( <TAB> <TAB> <TAB> <TAB> organizer = logentry. organizer, has_el = True, enabled = True <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> if logentry. event_id : <TAB> <TAB> <TAB> <TAB> webhooks = webhooks. filter ( <TAB> <TAB> <TAB> <TAB> <TAB> Q ( all_events = True ) | Q ( limit_events__pk = logentry. event_id ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <",False,not logentry.organizer,logentry.id,0.6660035848617554
|
||
|
4843,"def __init__ ( self, type_input ) : <TAB> ""Figures out the correct OGR Type based upon the input."" <TAB> if isinstance ( type_input, OGRGeomType ) : <TAB> <TAB> num = type_input. num <TAB> elif isinstance ( type_input, six. string_types ) : <TAB> <TAB> type_input = type_input. lower ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> type_input = ""unknown"" <TAB> <TAB> num = self. _str_types. get ( type_input ) <TAB> <TAB> if num is None : <TAB> <TAB> <TAB> raise GDALException ( 'Invalid OGR String Type ""%s""' % type_input ) <TAB> elif isinstance ( type_input, int ) : <TAB> <TAB> if type_input not in self. _types : <TAB> <TAB> <TAB> raise GDALException ( ""Invalid OGR Integer Type: %d"" % type_input ) <TAB> <TAB> num = type_input <TAB> else : <TAB> <TAB> raise TypeError ( ""Invalid OGR input type given."" ) <TAB> <TAB> self. num = num",False,type_input == 'geometry',type_input not in self._str_types,0.6648294925689697
|
||
|
4844,"def pre_save_task ( self, task, credentials, verrors ) : <TAB> if task [ ""attributes"" ] [ ""encryption"" ] not in ( None, """", ""AES256"" ) : <TAB> <TAB> verrors. add ( ""encryption"", 'Encryption should be null or ""AES256""' ) <TAB> if not credentials [ ""attributes"" ]. get ( ""skip_region"", False ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> response = await self. middleware. run_in_thread ( <TAB> <TAB> <TAB> <TAB> self. _get_client ( credentials ). get_bucket_location, <TAB> <TAB> <TAB> <TAB> Bucket = task [ ""attributes"" ] [ ""bucket"" ], <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> task [ ""attributes"" ] [ ""region"" ] = response [ ""LocationConstraint"" ] or ""us-east-1""",False,"not credentials['attributes'].get('region', '').strip()",self.middleware,0.6531568765640259
|
||
|
4845,"def should_exclude_with ( self, tags ) : <TAB> exclude_decision_map = { } <TAB> for category_tag in self. select_category_tags ( tags ) : <TAB> <TAB> category, value = self. parse_category_tag ( category_tag ) <TAB> <TAB> active_value = self. value_provider. get ( category, None ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> elif active_value == value : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> exclude_decision_map [ category ] = False <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if category not in exclude_decision_map : <TAB> <TAB> <TAB> <TAB> exclude_decision_map [ category ] = True <TAB> return any ( exclude_decision_map. values ( ) )",True,active_value is None,active_value is None,0.6540433168411255
|
||
|
4846,"def get ( self, episode_idx, entry_idx = None ) : <TAB> action = { } <TAB> episode = self. episodes [ episode_idx ] [ entry_idx ] <TAB> context = "" "". join ( episode [ ""text"" ]. split ( ""\n"" ) [ : - 1 ] ). replace ( <TAB> <TAB> ""\xa0"", "" "" <TAB> ) <TAB> question = episode [ ""text"" ]. split ( ""\n"" ) [ - 1 ] <TAB> label_field = ""labels"" if ""labels"" in episode else ""eval_labels"" <TAB> answers = [ ] <TAB> for answer in episode [ label_field ] : <TAB> <TAB> new_answer = answer. replace ( ""."", """" ). replace ( ""?"", """" ). replace ( ""!"", """" ) <TAB> <TAB> context = context. replace ( answer, new_answer ) <TAB> <TAB> answers. append ( new_answer ) <TAB> sentences = self. sent_tok. tokenize ( context ) <TAB> labels = [ ] <TAB> label_starts = [ ] <TAB> for sentence in sentences : <TAB> <TAB> for answer in answers : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> labels. append ( sentence ) <TAB> <TAB> <TAB> <TAB> label_starts. append ( context. index ( sentence ) ) <TAB> action = { <TAB> <TAB> ""context"" : context, <TAB> <TAB> ""text"" : question, <TAB> <TAB> label_field : labels, <TAB> <TAB> ""answer_starts"" : label_starts, <TAB> <TAB> ""label_candidates"" : sentences, <TAB> <TAB> ""episode_done"" : episode [ ""episode_done"" ], <TAB> } <TAB> if self. include_context : <TAB> <TAB> action [ ""text"" ] = action [ ""context"" ] + ""\n"" + action [ ""text"" ] <TAB> <TAB> del action [ ""context"" ] <TAB> return action",False,answer in sentence and sentence not in labels,answer,0.6633495092391968
|
||
|
4847,"def process_dir ( self, dir_path, is_train = True ) : <TAB> img_paths = glob. glob ( osp. join ( dir_path, ""*.jpg"" ) ) <TAB> pattern = re. compile ( r""([\d]+)_c(\d\d\d)"" ) <TAB> data = [ ] <TAB> for img_path in img_paths : <TAB> <TAB> pid, camid = map ( int, pattern. search ( img_path ). groups ( ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> assert 0 <= pid <= 776 <TAB> <TAB> assert 1 <= camid <= 20 <TAB> <TAB> camid -= 1 <TAB> <TAB> if is_train : <TAB> <TAB> <TAB> pid = self. dataset_name + ""_"" + str ( pid ) <TAB> <TAB> <TAB> camid = self. dataset_name + ""_"" + str ( camid ) <TAB> <TAB> data. append ( ( img_path, pid, camid ) ) <TAB> return data",False,pid == -1,pid == 0,0.6724298000335693
|
||
|
4848,"def f ( x ) : <TAB> if np. isnan ( x ). any ( ) : <TAB> <TAB> raise RuntimeError ( <TAB> <TAB> <TAB> f""{np.isnan(x).sum()} elements of the {x.size} element array "" <TAB> <TAB> <TAB> f""`x` are NaN."" <TAB> <TAB> ) <TAB> X = ( <TAB> <TAB> torch. from_numpy ( x ) <TAB> <TAB>. to ( initial_conditions ) <TAB> <TAB>. view ( shapeX ) <TAB> <TAB>. contiguous ( ) <TAB> <TAB>. requires_grad_ ( True ) <TAB> ) <TAB> X_fix = fix_features ( X = X, fixed_features = fixed_features ) <TAB> loss = - acquisition_function ( X_fix ). sum ( ) <TAB> <TAB> gradf = _arrayify ( torch. autograd. grad ( loss, X ) [ 0 ]. contiguous ( ). view ( - 1 ) ) <TAB> if np. isnan ( gradf ). any ( ) : <TAB> <TAB> msg = ( <TAB> <TAB> <TAB> f""{np.isnan(gradf).sum()} elements of the {x.size} element "" <TAB> <TAB> <TAB> ""gradient array `gradf` are NaN. This often indicates numerical issues."" <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> msg += "" Consider using `dtype=torch.double`."" <TAB> <TAB> raise RuntimeError ( msg ) <TAB> fval = loss. item ( ) <TAB> return fval, gradf",False,initial_conditions.dtype != torch.double,np.isnan(loss),0.6532289385795593
|
||
|
4849,"def dispatch ( ) : <TAB> console_stream = sys. stderr <TAB> console_handler = logging. StreamHandler ( console_stream ) <TAB> setup_logging ( console_handler ) <TAB> dispatcher = DocoptDispatcher ( <TAB> <TAB> TopLevelCommand, { ""options_first"" : True, ""version"" : get_version_info ( ""compose"" ) } <TAB> ) <TAB> options, handler, command_options = dispatcher. parse ( sys. argv [ 1 : ] ) <TAB> ansi_mode = AnsiMode. AUTO <TAB> try : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> ansi_mode = AnsiMode ( options. get ( ""--ansi"" ) ) <TAB> except ValueError : <TAB> <TAB> raise UserError ( <TAB> <TAB> <TAB> ""Invalid value for --ansi: {}. Expected one of {}."". format ( <TAB> <TAB> <TAB> <TAB> options. get ( ""--ansi"" ), "", "". join ( m. value for m in AnsiMode ) <TAB> <TAB> <TAB> ) <TAB> <TAB> ) <TAB> if options. get ( ""--no-ansi"" ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise UserError ( ""--no-ansi and --ansi cannot be combined."" ) <TAB> <TAB> log. warning ( <TAB> <TAB> <TAB> ""--no-ansi option is deprecated and will be removed in future versions."" <TAB> <TAB> ) <TAB> <TAB> ansi_mode = AnsiMode. NEVER <TAB> setup_console_handler ( <TAB> <TAB> console_handler, <TAB> <TAB> options. get ( ""--verbose"" ), <TAB> <TAB> ansi_mode. use_ansi_codes ( console_handler. stream ), <TAB> <TAB> options. get ( ""--log-level"" ), <TAB> ) <TAB> setup_parallel_logger ( ansi_mode ) <TAB> if ansi_mode is AnsiMode. NEVER : <TAB> <TAB> command_options [ ""--no-color"" ] = True <TAB> return functools. partial ( perform_command, options, handler,",False,options.get('--ansi'),options.get(--ansi'),0.6509849429130554
|
||
|
4850,"def _resolveSpecialSegment ( self, segmentB, specialResolutionMethods ) : <TAB> resolutionMethodExecutor = _compileRules ( specialResolutionMethods, 3 ) <TAB> for ( resolutionMethod, args ) in resolutionMethodExecutor [ True ] : <TAB> <TAB> iterables = [ ] <TAB> <TAB> for arg in args : <TAB> <TAB> <TAB> iterables. append ( itertools. repeat ( arg ) ) <TAB> <TAB> resolutions = map ( <TAB> <TAB> <TAB> resolutionMethod, self. allCorrectSinglePossibilities ( ), * iterables <TAB> <TAB> ) <TAB> <TAB> correctAB = zip ( self. allCorrectSinglePossibilities ( ), resolutions ) <TAB> <TAB> correctAB = filter ( <TAB> <TAB> <TAB> lambda possibAB : possibility. pitchesWithinLimit ( <TAB> <TAB> <TAB> <TAB> possibA = possibAB [ 1 ], maxPitch = segmentB. _maxPitch <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> correctAB, <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> correctAB = filter ( <TAB> <TAB> <TAB> <TAB> lambda possibAB : self. _isCorrectConsecutivePossibility ( <TAB> <TAB> <TAB> <TAB> <TAB> possibA = possibAB [ 0 ], possibB = possibAB [ 1 ] <TAB> <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> <TAB> correctAB, <TAB> <TAB> <TAB> ) <TAB> <TAB> if self. fbRules. applySinglePossibRulesToResolution : <TAB> <TAB> <TAB> segmentB. _singlePossibilityRuleChecking = _compileRules ( <TAB> <TAB> <TAB> <TAB> segmentB. singlePossibilityRules ( segmentB. fbRules ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> correctAB = filter ( <TAB> <TAB> <TAB> <TAB> lambda possibAB : segmentB. _isCorrectSinglePossibility ( <TAB> <TAB> <TAB> <TAB",False,self.fbRules.applyConsecutivePossibRulesToResolution,self.fbRules.conconclusivePossibility,0.6544584035873413
|
||
|
4851,"def _handle_rsa_enc_dec_error ( backend, key ) : <TAB> errors = backend. _consume_errors ( ) <TAB> assert errors <TAB> assert errors [ 0 ]. lib == backend. _lib. ERR_LIB_RSA <TAB> if isinstance ( key, _RSAPublicKey ) : <TAB> <TAB> assert errors [ 0 ]. reason == backend. _lib. RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> ""Data too long for key size. Encrypt less data or use a "" ""larger key size."" <TAB> <TAB> ) <TAB> else : <TAB> <TAB> decoding_errors = [ <TAB> <TAB> <TAB> backend. _lib. RSA_R_BLOCK_TYPE_IS_NOT_01, <TAB> <TAB> <TAB> backend. _lib. RSA_R_BLOCK_TYPE_IS_NOT_02, <TAB> <TAB> <TAB> backend. _lib. RSA_R_OAEP_DECODING_ERROR, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> backend. _lib. RSA_R_DATA_TOO_LARGE_FOR_MODULUS, <TAB> <TAB> ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> decoding_errors. append ( backend. _lib. RSA_R_PKCS_DECODING_ERROR ) <TAB> <TAB> assert errors [ 0 ]. reason in decoding_errors <TAB> <TAB> raise ValueError ( ""Decryption failed."" )",False,backend._lib.Cryptography_HAS_RSA_R_PKCS_DECODING_ERROR,errors[0].reason == backend._lib.RSA_R_PKCS_DECODE_ERROR,0.6530645489692688
|
||
|
4852,"def _check_choice ( self ) : <TAB> if self. type == ""choice"" : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise OptionError ( ""must supply a list of choices for type 'choice'"", self ) <TAB> <TAB> elif type ( self. choices ) not in ( types. TupleType, types. ListType ) : <TAB> <TAB> <TAB> raise OptionError ( <TAB> <TAB> <TAB> <TAB> ""choices must be a list of strings ('%s' supplied)"" <TAB> <TAB> <TAB> <TAB> % str ( type ( self. choices ) ). split ( ""'"" ) [ 1 ], <TAB> <TAB> <TAB> <TAB> self, <TAB> <TAB> <TAB> ) <TAB> elif self. choices is not None : <TAB> <TAB> raise OptionError ( ""must not supply choices for type %r"" % self. type, self )",False,self.choices is None,not self.choices,0.6720008254051208
|
||
|
4853,"def get_duplicate_box_mask ( box_list ) : <TAB> <TAB> <TAB> <TAB> max_iou = 0.35 <TAB> box_mask = np. ones ( len ( box_list ) ) <TAB> for i in range ( len ( box_list ) ) : <TAB> <TAB> if box_mask [ i ] == 0 : <TAB> <TAB> <TAB> continue <TAB> <TAB> for j in range ( i + 1, len ( box_list ) ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> box_mask [ j ] = 0.0 <TAB> filter_iou_mask = np. array ( box_mask > 0.0, dtype = ""bool"" ) <TAB> return filter_iou_mask",False,"get_intersection_over_union(box_list[i], box_list[j]) > max_iou",box_mask[j] > max_iou,0.651002824306488
|
||
|
4854,"def update_sockets_range_mode ( self, loop_in_node ) : <TAB> while len ( loop_in_node. inputs ) > len ( self. inputs ) : <TAB> <TAB> name = ""Data "" + str ( len ( self. inputs ) - 2 ) <TAB> <TAB> self. inputs. new ( ""SvStringsSocket"", name ) <TAB> <TAB> self. outputs. new ( ""SvStringsSocket"", name ) <TAB> while len ( loop_in_node. inputs ) < len ( self. inputs ) : <TAB> <TAB> self. inputs. remove ( self. inputs [ - 1 ] ) <TAB> <TAB> self. outputs. remove ( self. outputs [ - 1 ] ) <TAB> <TAB> if loop_in_node. inputs [ - 1 ]. links : <TAB> <TAB> name = ""Data "" + str ( len ( self. inputs ) - 2 ) <TAB> <TAB> self. inputs. new ( ""SvStringsSocket"", name ) <TAB> <TAB> self. outputs. new ( ""SvStringsSocket"", name ) <TAB> <TAB> for idx, socket in enumerate ( loop_in_node. inputs ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> if socket. links : <TAB> <TAB> <TAB> if type ( socket. links [ 0 ]. from_socket )!= type ( self. outputs [ socket. name ] ) : <TAB> <TAB> <TAB> <TAB> self. inputs. remove ( self. inputs [ socket. name ] ) <TAB> <TAB> <TAB> <TAB> self. inputs. new ( socket. links [ 0 ]. from_socket. bl_idname, socket. name ) <TAB> <TAB> <TAB> <TAB> self. inputs. move ( len ( self. inputs ) - 1, idx + 1 ) <TAB> <TAB> <TAB> <TAB> self. outputs. remove ( self. outputs [ socket. name ] ) <TAB> <TAB> <TAB> <TAB> self. outputs. new ( socket. links [ 0 ]. from_socket. bl_idname, socket. name ) <TAB> <TAB> <",False,idx == 0,self.has_error,0.6764886379241943
|
||
|
4855,"def prepend ( self, value ) : <TAB> """"""prepend value to nodes"""""" <TAB> root, root_text = self. _get_root ( value ) <TAB> for i, tag in enumerate ( self ) : <TAB> <TAB> if not tag. text : <TAB> <TAB> <TAB> tag. text = """" <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> root [ - 1 ]. tail = tag. text <TAB> <TAB> <TAB> tag. text = root_text <TAB> <TAB> else : <TAB> <TAB> <TAB> tag. text = root_text + tag. text <TAB> <TAB> if i > 0 : <TAB> <TAB> <TAB> root = deepcopy ( list ( root ) ) <TAB> <TAB> tag [ : 0 ] = root <TAB> <TAB> root = tag [ : len ( root ) ] <TAB> return self",False,len(root) > 0,i > 0,0.6537187099456787
|
||
|
4856,"def test_call_extern_c_fn ( self ) : <TAB> global memcmp <TAB> memcmp = cffi_support. ExternCFunction ( <TAB> <TAB> ""memcmp"", <TAB> <TAB> ( ""int memcmp ( const uint8_t * ptr1, "" ""const uint8_t * ptr2, size_t num )"" ), <TAB> ) <TAB> @ udf ( BooleanVal ( FunctionContext, StringVal, StringVal ) ) <TAB> def fn ( context, a, b ) : <TAB> <TAB> if a. is_null!= b. is_null : <TAB> <TAB> <TAB> return False <TAB> <TAB> if a is None : <TAB> <TAB> <TAB> return True <TAB> <TAB> if len ( a )!= b. len : <TAB> <TAB> <TAB> return False <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return True <TAB> <TAB> return memcmp ( a. ptr, b. ptr, a. len ) == 0",False,a.ptr == b.ptr,b is None,0.6552106738090515
|
||
|
4857,"def validate_grammar ( ) -> None : <TAB> for fn in _NONTERMINAL_CONVERSIONS_SEQUENCE : <TAB> <TAB> fn_productions = get_productions ( fn ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> production_name = fn_productions [ 0 ]. name <TAB> <TAB> <TAB> expected_name = f""convert_{production_name}"" <TAB> <TAB> <TAB> if fn. __name__!= expected_name : <TAB> <TAB> <TAB> <TAB> raise Exception ( <TAB> <TAB> <TAB> <TAB> <TAB> f""The conversion function for '{production_name}' "" <TAB> <TAB> <TAB> <TAB> <TAB> + f""must be called '{expected_name}', not '{fn.__name__}'."" <TAB> <TAB> <TAB> <TAB> )",False,all((p.name == fn_productions[0].name for p in fn_productions)),len(fn_productions) > 0,0.659351646900177
|
||
|
4858,"def _make_bom ( <TAB> bom_parts_dict : Dict [ str, float ], <TAB> csv : bool = False, ) -> str : <TAB> field_names = [ ""Description"", ""Count"", ""Unit Price"", ""Total Price"" ] <TAB> field_names += g_bom_headers <TAB> rows = [ ] <TAB> all_costs : Dict [ str, float ] = { } <TAB> for desc, elements in bom_parts_dict. items ( ) : <TAB> <TAB> row = [ ] <TAB> <TAB> count = elements [ ""Count"" ] <TAB> <TAB> currency = elements [ ""currency"" ] <TAB> <TAB> price = elements [ ""Unit Price"" ] <TAB> <TAB> if count > 0 : <TAB> <TAB> <TAB> if price : <TAB> <TAB> <TAB> <TAB> total = price * count <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> all_costs [ currency ] = 0 <TAB> <TAB> <TAB> <TAB> all_costs [ currency ] += total <TAB> <TAB> <TAB> <TAB> unit_price = _currency_str ( price, currency ) <TAB> <TAB> <TAB> <TAB> total_price = _currency_str ( total, currency ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> unit_price = total_price = """" <TAB> <TAB> <TAB> row = [ desc, count, unit_price, total_price ] <TAB> <TAB> for key in g_bom_headers : <TAB> <TAB> <TAB> value = elements [ key ] <TAB> <TAB> <TAB> row. append ( value ) <TAB> <TAB> rows. append ( row ) <TAB> <TAB> if len ( all_costs ) > 0 : <TAB> <TAB> empty_row = [ """" ] * len ( field_names ) <TAB> <TAB> rows. append ( empty_row ) <TAB> <TAB> for currency, cost in all_costs. items ( ) : <TAB> <TAB",False,currency not in all_costs,currency,0.6629311442375183
|
||
|
4859,"def export_git_objects ( self ) : <TAB> self. init_if_missing ( ) <TAB> nodes = [ self. repo. lookup ( n ) for n in self. repo ] <TAB> export = [ node for node in nodes if not hex ( node ) in self. _map_hg ] <TAB> total = len ( export ) <TAB> if total : <TAB> <TAB> self. ui. note ( _ ( ""exporting hg objects to git\n"" ) ) <TAB> <TAB> <TAB> <TAB> exporter = hg2git. IncrementalChangesetExporter ( self. repo ) <TAB> for i, rev in enumerate ( export ) : <TAB> <TAB> util. progress ( self. ui, ""exporting"", i, total = total ) <TAB> <TAB> ctx = self. repo. changectx ( rev ) <TAB> <TAB> state = ctx. extra ( ). get ( ""hg-git"", None ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. ui. debug ( ""revision %d is a part "" ""of octopus explosion\n"" % ctx. rev ( ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> self. export_hg_commit ( rev, exporter ) <TAB> util. progress ( self. ui, ""importing"", None, total = total )",False,state == 'octopus',state,0.6532425284385681
|
||
|
4860,"def check ( self, name, data, hexdigest, shake = False, ** kwargs ) : <TAB> length = len ( hexdigest ) // 2 <TAB> hexdigest = hexdigest. lower ( ) <TAB> constructors = self. constructors_to_test [ name ] <TAB> <TAB> self. assertGreaterEqual ( len ( constructors ), 2 ) <TAB> for hash_object_constructor in constructors : <TAB> <TAB> m = hash_object_constructor ( data, ** kwargs ) <TAB> <TAB> computed = m. hexdigest ( ) if not shake else m. hexdigest ( length ) <TAB> <TAB> self. assertEqual ( <TAB> <TAB> <TAB> computed, <TAB> <TAB> <TAB> hexdigest, <TAB> <TAB> <TAB> ""Hash algorithm %s constructed using %s returned hexdigest"" <TAB> <TAB> <TAB> "" %r for %d byte input data that should have hashed to %r."" <TAB> <TAB> <TAB> % ( name, hash_object_constructor, computed, len ( data ), hexdigest ), <TAB> <TAB> ) <TAB> <TAB> computed = m. digest ( ) if not shake else m. digest ( length ) <TAB> <TAB> digest = bytes. fromhex ( hexdigest ) <TAB> <TAB> self. assertEqual ( computed, digest ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. assertEqual ( len ( digest ), m. digest_size )",False,not shake,digest,0.6744714975357056
|
||
|
4861,"def fix_repeating_arguments ( self ) : <TAB> """"""Fix elements that should accumulate/increment values."""""" <TAB> either = [ list ( child. children ) for child in transform ( self ). children ] <TAB> for case in either : <TAB> <TAB> for e in [ child for child in case if case. count ( child ) > 1 ] : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> if e. value is None : <TAB> <TAB> <TAB> <TAB> <TAB> e. value = [ ] <TAB> <TAB> <TAB> <TAB> elif type ( e. value ) is not list : <TAB> <TAB> <TAB> <TAB> <TAB> e. value = e. value. split ( ) <TAB> <TAB> <TAB> if type ( e ) is Command or type ( e ) is Option and e. argcount == 0 : <TAB> <TAB> <TAB> <TAB> e. value = 0 <TAB> return self",False,type(e) is Argument or (type(e) is Option and e.argcount),e,0.6532750725746155
|
||
|
4862,"def _calcXMinMax ( self ) : <TAB> xmin = xmax = None <TAB> for line in self. line_list : <TAB> <TAB> xline_min = weeutil. weeutil. min_with_none ( line. x ) <TAB> <TAB> xline_max = weeutil. weeutil. max_with_none ( line. x ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> xline_min = xline_min - line. bar_width [ 0 ] <TAB> <TAB> xmin = weeutil. weeutil. min_with_none ( [ xmin, xline_min ] ) <TAB> <TAB> xmax = weeutil. weeutil. max_with_none ( [ xmax, xline_max ] ) <TAB> return ( xmin, xmax )",False,line.plot_type == 'bar',line.bar_width is not None,0.6531867980957031
|
||
|
4863,"def pairs ( self ) : <TAB> for path in os. listdir ( ""src"" ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> dep = join ( ""src"", path ) <TAB> <TAB> if isdir ( dep ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> yield dep, join ( build_dir, path )",False,path == '.svn',isdir(path),0.6677864789962769
|
||
|
4864,"def text2text_generate_encoded ( <TAB> sample_generator, <TAB> vocab, <TAB> targets_vocab = None, <TAB> has_inputs = True, <TAB> inputs_prefix = """", <TAB> targets_prefix = """", ) : <TAB> """"""Encode Text2Text samples from the generator with the vocab."""""" <TAB> targets_vocab = targets_vocab or vocab <TAB> for sample in sample_generator : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> sample [ ""inputs"" ] = vocab. encode ( inputs_prefix + sample [ ""inputs"" ] ) <TAB> <TAB> <TAB> sample [ ""inputs"" ]. append ( text_encoder. EOS_ID ) <TAB> <TAB> sample [ ""targets"" ] = targets_vocab. encode ( targets_prefix + sample [ ""targets"" ] ) <TAB> <TAB> sample [ ""targets"" ]. append ( text_encoder. EOS_ID ) <TAB> <TAB> yield sample",True,has_inputs,has_inputs,0.6585865616798401
|
||
|
4865,"def wrapped ( self, * args, ** kwargs ) : <TAB> """"""Calls the original method with a group name set before and after."""""" <TAB> if not base. frame_stack : <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> ""All `hk.Module`s must be initialized inside an `hk.transform`."" <TAB> <TAB> ) <TAB> frame = base. current_frame ( ) <TAB> state = base. ModuleState ( module = self, method_name = method_name ) <TAB> with frame. module ( state ), _module_method_call ( self, method_name ) : <TAB> <TAB> <TAB> <TAB> module_name = getattr ( self, ""module_name"", None ) <TAB> <TAB> f = functools. partial ( unbound_method, self ) <TAB> <TAB> f = functools. partial ( run_interceptors, f, method_name, self ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> local_name = module_name. split ( ""/"" ) [ - 1 ] <TAB> <TAB> <TAB> f = stateful. named_call ( f, name = local_name ) <TAB> <TAB> out = f ( * args, ** kwargs ) <TAB> <TAB> <TAB> <TAB> if module_name is not None : <TAB> <TAB> <TAB> for module_state in frame. module_stack : <TAB> <TAB> <TAB> <TAB> module_state. module. _submodules. add ( <TAB> <TAB> <TAB> <TAB> <TAB> module_name <TAB> <TAB> <TAB> <TAB> ) <TAB> return out",False,modules_with_named_call and module_name and (method_name == '__call__'),module_name is not None,0.6460506916046143
|
||
|
4866,"def pre_save ( self, model_instance, add ) : <TAB> value = now ( ) <TAB> if not model_instance. pk : <TAB> <TAB> for field in model_instance. _meta. get_fields ( ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> value = getattr ( model_instance, field. name ) <TAB> <TAB> <TAB> <TAB> break <TAB> setattr ( model_instance, self. attname, value ) <TAB> return value",False,"isinstance(field, AutoCreatedField)","hasattr(model_instance, field.name)",0.6514626741409302
|
||
|
4867,"def mock_whale_dir ( monkeypatch, tmp_path, request ) : <TAB> is_path_creation_enabed = request. param <TAB> for attr_name, path in { <TAB> <TAB> ""BASE_DIR"" : paths. BASE_DIR, <TAB> <TAB> ""CONFIG_DIR"" : paths. CONFIG_DIR, <TAB> <TAB> ""CONNECTION_PATH"" : paths. CONNECTION_PATH, <TAB> <TAB> ""LOGS_DIR"" : paths. LOGS_DIR, <TAB> <TAB> ""MANIFEST_DIR"" : paths. MANIFEST_DIR, <TAB> <TAB> ""MANIFEST_PATH"" : paths. MANIFEST_PATH, <TAB> <TAB> ""METRICS_PATH"" : paths. METRICS_PATH, <TAB> <TAB> ""METADATA_PATH"" : paths. METADATA_PATH, <TAB> <TAB> ""TEMPLATE_DIR"" : paths. TEMPLATE_DIR, <TAB> }. items ( ) : <TAB> <TAB> d = get_mocked_path ( tmp_path, path ) <TAB> <TAB> monkeypatch. setattr ( paths, attr_name, d ) <TAB> <TAB> if is_path_creation_enabed : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> d. parent. mkdir ( parents = True, exist_ok = True ) <TAB> <TAB> <TAB> elif d. is_file ( ) : <TAB> <TAB> <TAB> <TAB> d. touch ( exist_ok = True ) <TAB> <TAB> if attr_name in [ ""TEMPLATE_DIR"" ] : <TAB> <TAB> <TAB> monkeypatch. setattr ( sql, attr_name, d ) <TAB> return tmp_path",False,d.is_dir(),d.is_parent(),0.6537692546844482
|
||
|
4868,"def find_field_notnull_differ ( self, meta, table_description, table_name ) : <TAB> if not self. can_detect_notnull_differ : <TAB> <TAB> return <TAB> for field in all_local_fields ( meta ) : <TAB> <TAB> attname = field. db_column or field. attname <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> null = self. get_field_db_nullable ( field, table_name ) <TAB> <TAB> if field. null!= null : <TAB> <TAB> <TAB> action = field. null and ""DROP"" or ""SET"" <TAB> <TAB> <TAB> self. add_difference ( ""notnull-differ"", table_name, attname, action )",False,"(table_name, attname) in self.new_db_fields",field.nullable and field.field_description != table_description,0.6473622918128967
|
||
|
4869,"def get_doc_links ( ) : <TAB> """"""Returns a dictionary of function names -> upstream documentation link"""""" <TAB> tadoc_homepage = ""http://www.tadoc.org/"" <TAB> html_file_path = os. path. join ( INPUT_DIR, "".tadoc.org.html"" ) <TAB> if os. path. exists ( html_file_path ) : <TAB> <TAB> with open ( html_file_path, ""r"" ) as f : <TAB> <TAB> <TAB> html = f. read ( ) <TAB> else : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> from urllib2 import urlopen <TAB> <TAB> else : <TAB> <TAB> <TAB> from urllib. request import urlopen <TAB> <TAB> html = urlopen ( tadoc_homepage ). read ( ) <TAB> <TAB> with open ( html_file_path, ""wb"" ) as f : <TAB> <TAB> <TAB> f. write ( html ) <TAB> <TAB> soup = BeautifulSoup ( html, ""html.parser"" ) <TAB> links = [ a for a in soup. findAll ( ""a"" ) if ""indicator"" in a [ ""href"" ] ] <TAB> ret = { } <TAB> for a in links : <TAB> <TAB> url = """". join ( [ tadoc_homepage, a [ ""href"" ] ] ) <TAB> <TAB> func = url [ url. rfind ( ""/"" ) + 1 : url. rfind ( ""."" ) ] <TAB> <TAB> ret [ func ] = url <TAB> return ret",False,"sys.version_info < (2, 8)",os.path.exists(tadoc_homepage),0.6524540185928345
|
||
|
4870,"def split_on_length ( example ) : <TAB> """"""Split a batch of ditcs on length."""""" <TAB> x = example [ ""targets"" ] <TAB> <TAB> length_diff = chunk_length * max_chunks - tf. shape ( x ) [ 1 ] <TAB> padded_x = tf. pad ( x, [ ( 0, 0 ), ( 0, length_diff ), ( 0, 0 ), ( 0, 0 ) ] ) <TAB> chunks = [ <TAB> <TAB> padded_x [ :, i * chunk_length : ( i + 1 ) * chunk_length, :, : ] <TAB> <TAB> for i in range ( max_chunks - 1 ) <TAB> ] <TAB> chunks. append ( padded_x [ :, ( max_chunks - 1 ) * chunk_length :, :, : ] ) <TAB> new_example = { } <TAB> <TAB> new_example [ ""chunk_number"" ] = tf. concat ( <TAB> <TAB> [ tf. expand_dims ( tf. ones_like ( c ) * n, axis = 0 ) for n, c in enumerate ( chunks ) ], <TAB> <TAB> axis = 0, <TAB> ) <TAB> new_example [ ""targets"" ] = tf. concat ( <TAB> <TAB> [ tf. expand_dims ( c, axis = 0 ) for c in chunks ], axis = 0 <TAB> ) <TAB> for k in example : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> assert k!= ""chunk_number"", ( <TAB> <TAB> <TAB> <TAB> ""Chunking code expects the chunk_number feature name to be "" ""available"" <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> new_example [ k ] = tf. concat ( <TAB> <TAB> <TAB> <TAB> [ tf. expand_dims ( example [ k ], axis = 0 ) for _ in range ( max_chunks ) ], axis = 0 <TAB> <TAB> <TAB> ) <TAB> return tf. data. Dataset. from_tensor_slices ( new_example )",False,k != 'targets',k != 'chunk_number',0.6577335596084595
|
||
|
4871,"def analyze ( self, item, pub_date ) : <TAB> observable_sample = item [ ""title"" ] <TAB> context_sample = { } <TAB> context_sample [ ""description"" ] = ""ATM sample"" <TAB> context_sample [ ""date_added"" ] = pub_date <TAB> context_sample [ ""source"" ] = self. name <TAB> family = False <TAB> if "" - "" in observable_sample : <TAB> <TAB> family, observable_sample = observable_sample. split ( "" - "" ) <TAB> try : <TAB> <TAB> sample = Hash. get_or_create ( value = observable_sample ) <TAB> <TAB> sample. add_context ( context_sample ) <TAB> <TAB> sample. add_source ( self. name ) <TAB> <TAB> sample_tags = [ ""atm"" ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> sample_tags. append ( family ) <TAB> <TAB> sample. tag ( sample_tags ) <TAB> except ObservableValidationError as e : <TAB> <TAB> logging. error ( e ) <TAB> <TAB> return",True,family,family,0.6895439028739929
|
||
|
4872,"def on_treeview_button_pressed ( self, treeview, event ) : <TAB> if event. window!= treeview. get_bin_window ( ) : <TAB> <TAB> return False <TAB> role = getattr ( treeview, TreeViewHelper. ROLE ) <TAB> if role == TreeViewHelper. ROLE_EPISODES and event. button == 1 : <TAB> <TAB> <TAB> <TAB> result = treeview. get_path_at_pos ( int ( event. x ), int ( event. y ) ) <TAB> <TAB> if result is not None : <TAB> <TAB> <TAB> path, column, x, y = result <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> model = treeview. get_model ( ) <TAB> <TAB> <TAB> <TAB> cursor_episode = model. get_value ( <TAB> <TAB> <TAB> <TAB> <TAB> model. get_iter ( path ), EpisodeListModel. C_EPISODE <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> new_value = cursor_episode. is_new <TAB> <TAB> <TAB> <TAB> selected_episodes = self. get_selected_episodes ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if cursor_episode in selected_episodes : <TAB> <TAB> <TAB> <TAB> <TAB> for episode in selected_episodes : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> episode. mark ( is_played = new_value ) <TAB> <TAB> <TAB> <TAB> <TAB> self. update_episode_list_icons ( selected = True ) <TAB> <TAB> <TAB> <TAB> <TAB> self. update_podcast_list_model ( selected = True ) <TAB> <TAB> <TAB> <TAB> <TAB> return True <TAB> return event. button",False,x < self.EPISODE_LIST_ICON_WIDTH and column == treeview.get_columns()[0],path is not None,0.6538043022155762
|
||
|
4873,"def test_avg_non_zero_reducer ( self ) : <TAB> reducer = AvgNonZeroReducer ( ) <TAB> for dtype in TEST_DTYPES : <TAB> <TAB> batch_size = 100 <TAB> <TAB> embedding_size = 64 <TAB> <TAB> embeddings = torch. randn ( batch_size, embedding_size ). type ( dtype ). to ( TEST_DEVICE ) <TAB> <TAB> labels = torch. randint ( 0, 10, ( batch_size, ) ) <TAB> <TAB> pair_indices = ( <TAB> <TAB> <TAB> torch. randint ( 0, batch_size, ( batch_size, ) ), <TAB> <TAB> <TAB> torch. randint ( 0, batch_size, ( batch_size, ) ), <TAB> <TAB> ) <TAB> <TAB> triplet_indices = pair_indices + ( torch. randint ( 0, batch_size, ( batch_size, ) ), ) <TAB> <TAB> losses = torch. randn ( batch_size ). type ( dtype ). to ( TEST_DEVICE ) <TAB> <TAB> zero_losses = torch. zeros ( batch_size ). type ( dtype ). to ( TEST_DEVICE ) <TAB> <TAB> for indices, reduction_type in [ <TAB> <TAB> <TAB> ( torch. arange ( batch_size ), ""element"" ), <TAB> <TAB> <TAB> ( pair_indices, ""pos_pair"" ), <TAB> <TAB> <TAB> ( pair_indices, ""neg_pair"" ), <TAB> <TAB> <TAB> ( triplet_indices, ""triplet"" ), <TAB> <TAB> ] : <TAB> <TAB> <TAB> for L in [ losses, zero_losses ] : <TAB> <TAB> <TAB> <TAB> loss_dict = { <TAB> <TAB> <TAB> <TAB> <TAB> ""loss"" : { <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""losses"" : L, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""indices"" : indices, <TAB> <TAB> <TAB> <TAB>",False,len(filtered_L) > 0,reduction_type == 'avg_non_zero_reducer',0.650538444519043
|
||
|
4874,"def _get_volume_options_from_type ( self, type_id, default_options ) : <TAB> options = dict ( default_options. items ( ) ) <TAB> if type_id : <TAB> <TAB> admin_context = cinder_context. get_admin_context ( ) <TAB> <TAB> volume_type = volume_types. get_volume_type ( admin_context, type_id ) <TAB> <TAB> specs = dict ( volume_type ). get ( ""extra_specs"" ) <TAB> <TAB> for key, value in six. iteritems ( specs ) : <TAB> <TAB> <TAB> if key in self. VALID_VOLUME_TYPE_KEYS : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> options [ key ] = [ v. strip ( ). lower ( ) for v in value. split ( "","" ) ] <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> options [ key ] = value. lower ( ) <TAB> return options",False,key == self.DATACORE_DISK_POOLS_KEY,"isinstance(value, str)",0.6569615602493286
|
||
|
4875,"def __exit__ ( self, * args, ** kwargs ) : <TAB> self. _samples_cache = { } <TAB> if is_validation_enabled ( ) and isinstance ( self. prior, dict ) : <TAB> <TAB> extra = set ( self. prior ) - self. _param_hits <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> warnings. warn ( <TAB> <TAB> <TAB> <TAB> ""pyro.module prior did not find params ['{}']. "" <TAB> <TAB> <TAB> <TAB> ""Did you instead mean one of ['{}']?"". format ( <TAB> <TAB> <TAB> <TAB> <TAB> ""', '"". join ( extra ), ""', '"". join ( self. _param_misses ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> return super ( ). __exit__ ( * args, ** kwargs )",False,extra,len(extra) > 0,0.6900540590286255
|
||
|
4876,"def __init__ ( self, sources : List [ BuildSource ] ) -> None : <TAB> self. source_text_present = False <TAB> self. source_modules = set ( ) <TAB> self. source_paths = set ( ) <TAB> for source in sources : <TAB> <TAB> if source. text is not None : <TAB> <TAB> <TAB> self. source_text_present = True <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> self. source_paths. add ( source. path ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. source_modules. add ( source. module )",False,source.path,source.path is not None,0.6648392677307129
|
||
|
4877,"def is_open ( self ) : <TAB> if self. signup_code : <TAB> <TAB> return True <TAB> else : <TAB> <TAB> if self. signup_code_present : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> messages. add_message ( <TAB> <TAB> <TAB> <TAB> <TAB> self. request, <TAB> <TAB> <TAB> <TAB> <TAB> self. messages [ ""invalid_signup_code"" ] [ ""level"" ], <TAB> <TAB> <TAB> <TAB> <TAB> self. messages [ ""invalid_signup_code"" ] [ ""text"" ]. format ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ** { <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""code"" : self. get_code ( ), <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> } <TAB> <TAB> <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> <TAB> ) <TAB> return settings. ACCOUNT_OPEN_SIGNUP",False,self.messages.get('invalid_signup_code'),"has_message(self, 'invalid_signup_code')",0.65576171875
|
||
|
4878,"def serve_until_stopped ( self ) -> None : <TAB> while True : <TAB> <TAB> rd, wr, ex = select. select ( [ self. socket. fileno ( ) ], [ ], [ ], self. timeout ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. handle_request ( ) <TAB> <TAB> if self. event is not None and self. event. is_set ( ) : <TAB> <TAB> <TAB> break",False,rd,not ex,0.6763215065002441
|
||
|
4879,"def __on_new_workspace ( self, event ) : <TAB> """"""Handle the New Workspace menu command"""""" <TAB> if self. __dirty_workspace : <TAB> <TAB> result = wx. MessageBox ( <TAB> <TAB> <TAB> ""Do you want to save your existing project?"", <TAB> <TAB> <TAB> caption = ""Save project"", <TAB> <TAB> <TAB> style = wx. YES_NO | wx. CANCEL | wx. ICON_QUESTION, <TAB> <TAB> <TAB> parent = self. __frame, <TAB> <TAB> ) <TAB> <TAB> if result == wx. CANCEL : <TAB> <TAB> <TAB> return <TAB> <TAB> elif result == wx. YES : <TAB> <TAB> <TAB> path = get_current_workspace_path ( ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> if not self. do_save_as_workspace ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. do_save_workspace ( path ) <TAB> self. do_create_workspace ( )",True,path is None,path is None,0.6642489433288574
|
||
|
4880,"def load_cache ( filename, get_key = mangle_key ) : <TAB> cache = { } <TAB> if not os. path. exists ( filename ) : <TAB> <TAB> return cache <TAB> f = open ( filename, ""rb"" ) <TAB> l = 0 <TAB> for line in f. readlines ( ) : <TAB> <TAB> l += 1 <TAB> <TAB> fields = line. split ( b"" "" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> sys. stderr. write ( ""Invalid file format in [%s], line %d\n"" % ( filename, l ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> cache [ get_key ( fields [ 0 ] [ 1 : ] ) ] = fields [ 1 ]. split ( b""\n"" ) [ 0 ] <TAB> f. close ( ) <TAB> return cache",False,fields == None or not len(fields) == 2 or fields[0][0:1] != b':',l > 0,0.6524518132209778
|
||
|
4881,"def _parse ( self, contents ) : <TAB> entries = [ ] <TAB> hostnames_found = set ( ) <TAB> for line in contents. splitlines ( ) : <TAB> <TAB> if not len ( line. strip ( ) ) : <TAB> <TAB> <TAB> entries. append ( ( ""blank"", [ line ] ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> ( head, tail ) = chop_comment ( line. strip ( ), ""#"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> entries. append ( ( ""all_comment"", [ line ] ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> entries. append ( ( ""hostname"", [ head, tail ] ) ) <TAB> <TAB> hostnames_found. add ( head ) <TAB> if len ( hostnames_found ) > 1 : <TAB> <TAB> raise IOError ( ""Multiple hostnames (%s) found!"" % ( hostnames_found ) ) <TAB> return entries",False,not len(head),head == tail,0.6556034088134766
|
||
|
4882,"def sequence_list ( self ) : <TAB> ""Returns a list of information about all DB sequences for all models in all apps."" <TAB> from django. db import models, router <TAB> apps = models. get_apps ( ) <TAB> sequence_list = [ ] <TAB> for app in apps : <TAB> <TAB> for model in models. get_models ( app ) : <TAB> <TAB> <TAB> if not model. _meta. managed : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if model. _meta. swapped : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> if not router. allow_syncdb ( self. connection. alias, model ) : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> for f in model. _meta. local_fields : <TAB> <TAB> <TAB> <TAB> if isinstance ( f, models. AutoField ) : <TAB> <TAB> <TAB> <TAB> <TAB> sequence_list. append ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> { ""table"" : model. _meta. db_table, ""column"" : f. column } <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> for f in model. _meta. local_many_to_many : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> sequence_list. append ( { ""table"" : f. m2m_db_table ( ), ""column"" : None } ) <TAB> return sequence_list",False,f.rel.through is None,f.m2m_db_table(),0.6513980627059937
|
||
|
4883,"def load_file ( self ) : <TAB> if self. ledger. fava_options [ ""import-config"" ] : <TAB> <TAB> full_path = os. path. normpath ( <TAB> <TAB> <TAB> os. path. join ( <TAB> <TAB> <TAB> <TAB> os. path. dirname ( self. ledger. beancount_file_path ), <TAB> <TAB> <TAB> <TAB> self. ledger. fava_options [ ""import-config"" ], <TAB> <TAB> <TAB> ) <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> error = IngestError ( <TAB> <TAB> <TAB> <TAB> None, ""File does not exist: '{}'"". format ( full_path ), None <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> self. ledger. errors. append ( error ) <TAB> <TAB> else : <TAB> <TAB> <TAB> mod = runpy. run_path ( full_path ) <TAB> <TAB> <TAB> self. config = mod [ ""CONFIG"" ]",False,not os.path.exists(full_path) or os.path.isdir(full_path),not os.path.exists(full_path),0.6471632719039917
|
||
|
4884,"def execute ( self ) : <TAB> if self. _dirty or not self. _qr : <TAB> <TAB> model_class = self. model_class <TAB> <TAB> query_meta = self. get_query_meta ( ) <TAB> <TAB> if self. _tuples : <TAB> <TAB> <TAB> ResultWrapper = TuplesQueryResultWrapper <TAB> <TAB> elif self. _dicts : <TAB> <TAB> <TAB> ResultWrapper = DictQueryResultWrapper <TAB> <TAB> elif self. _naive or not self. _joins or self. verify_naive ( ) : <TAB> <TAB> <TAB> ResultWrapper = NaiveQueryResultWrapper <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> ResultWrapper = AggregateQueryResultWrapper <TAB> <TAB> else : <TAB> <TAB> <TAB> ResultWrapper = ModelQueryResultWrapper <TAB> <TAB> self. _qr = ResultWrapper ( model_class, self. _execute ( ), query_meta ) <TAB> <TAB> self. _dirty = False <TAB> <TAB> return self. _qr <TAB> else : <TAB> <TAB> return self. _qr",False,self._aggregate_rows,self.execute(),0.6812577247619629
|
||
|
4885,"def _Atom ( self, children ) : <TAB> <TAB> """"""Handles alternatives of 'atom' where there is more than one child."""""" <TAB> tok = children [ 0 ]. tok <TAB> id_ = tok. id <TAB> n = len ( children ) <TAB> if id_ == Id. Op_LParen : <TAB> <TAB> <TAB> <TAB> if n == 2 : <TAB> <TAB> <TAB> assert children [ 1 ]. tok. id == Id. Op_RParen, children [ 1 ] <TAB> <TAB> <TAB> return expr. Tuple ( [ ], expr_context_e. Store ) <TAB> <TAB> return self. _TestlistComp ( children [ 1 ], id_ ) <TAB> if id_ == Id. Op_LBracket : <TAB> <TAB> <TAB> <TAB> if n == 2 : <TAB> <TAB> <TAB> assert children [ 1 ]. tok. id == Id. Op_RBracket, children [ 1 ] <TAB> <TAB> <TAB> return expr. List ( [ ], expr_context_e. Store ) <TAB> <TAB> return self. _TestlistComp ( children [ 1 ], id_ ) <TAB> if id_ == Id. Op_LBrace : <TAB> <TAB> <TAB> <TAB> i = 1 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> i += 1 <TAB> <TAB> return self. _Dict ( children [ i ] ) <TAB> if id_ == Id. Arith_Slash : <TAB> <TAB> r = self. _Regex ( children [ 1 ] ) <TAB> <TAB> flags = [ ] <TAB> <TAB> <TAB> <TAB> trans_pref = None <TAB> <TAB> return expr. RegexLiteral ( children [ 0 ]. tok, r, flags, trans_pref ) <TAB> if id_ == Id. Expr_Func : <TAB> <TAB> <TAB> <TAB> return expr. Lambda ( [ ], expr. Implicit ( ) ) <TAB> raise NotImplementedError ( Id_str ( id_ ) )",False,children[i].tok.id == Id.Op_Newline,"isinstance(children[i], dict)",0.654444694519043
|
||
|
4886,"def __setitem__ ( self, key, value ) : <TAB> if key in self : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> existing = self [ key ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return <TAB> <TAB> if not existing. shares_lineage ( value ) : <TAB> <TAB> <TAB> util. warn ( <TAB> <TAB> <TAB> <TAB> ""Column %r on table %r being replaced by "" <TAB> <TAB> <TAB> <TAB> ""%r, which has the same key. Consider "" <TAB> <TAB> <TAB> <TAB> ""use_labels for select() statements."" <TAB> <TAB> <TAB> <TAB> % ( key, getattr ( existing, ""table"", None ), value ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> util. memoized_property. reset ( value, ""proxy_set"" ) <TAB> self. _all_columns. append ( value ) <TAB> self. _data [ key ] = value",False,existing is value,existing is None,0.6726027727127075
|
||
|
4887,"def create ( path, binary = False ) : <TAB> for i in range ( 10 ) : <TAB> <TAB> try : <TAB> <TAB> <TAB> os. makedirs ( os. path. dirname ( path ), exist_ok = True ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> return open ( path, ""wb"" ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> return open ( path, ""w"", encoding = ""utf-8"" ) <TAB> <TAB> <TAB> if i > 0 : <TAB> <TAB> <TAB> <TAB> log ( True, f""Created {path} at attempt {i + 1}"" ) <TAB> <TAB> except : <TAB> <TAB> <TAB> time. sleep ( 0.5 ) <TAB> else : <TAB> <TAB> raise Error ( f""Failed to create {path}"" )",True,binary,binary,0.6794127225875854
|
||
|
4888,"def gen_widths ( options, agi ) : <TAB> """"""Generate the oc2 operand width enumeration & width lookup function"""""" <TAB> lines = base_open_file ( options. input_widths, ""r"", ""widths input"" ). readlines ( ) <TAB> <TAB> <TAB> widths_list = refine_widths_input ( lines ) <TAB> ( cfn, hfn ) = emit_widths_enum ( options, widths_list ) <TAB> agi. add_file_name ( cfn ) <TAB> agi. add_file_name ( hfn, header = True ) <TAB> cfn_map = emit_width_lookup ( options, widths_list ) <TAB> agi. add_file_name ( cfn_map ) <TAB> agi. widths_list = widths_list <TAB> <TAB> agi. widths_dict = { } <TAB> for w in widths_list : <TAB> <TAB> agi. widths_dict [ w. name ] = w. dtype <TAB> <TAB> agi. scalable_widths = set ( ) <TAB> for w in widths_list : <TAB> <TAB> ( w8, w16, w32, w64 ) = w. widths <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> msge ( ""Adding scalable width: "" + w. name ) <TAB> <TAB> <TAB> agi. scalable_widths. add ( w. name )",False,w16 != w32 or w16 != w64 or w32 != w64,w.name not in scalable_widths,0.657873272895813
|
||
|
4889,"def shortcut ( self, input, ch_out, stride, name, if_first = False ) : <TAB> ch_in = input. shape [ 1 ] <TAB> if ch_in!= ch_out or stride!= 1 : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return self. conv_bn_layer ( input, ch_out, 1, stride, name = name ) <TAB> <TAB> else : <TAB> <TAB> <TAB> return self. conv_bn_layer_new ( input, ch_out, 1, stride, name = name ) <TAB> else : <TAB> <TAB> return input",True,if_first,if_first,0.6553119421005249
|
||
|
4890,"def test_list_users ( <TAB> self, <TAB> test_label, <TAB> username, <TAB> configure_first = True, <TAB> raises = None, <TAB> exception_message = None, ) : <TAB> if configure_first : <TAB> <TAB> self. client. auth. ldap. create_or_update_user ( <TAB> <TAB> <TAB> username = username, <TAB> <TAB> <TAB> mount_point = self. TEST_LDAP_PATH, <TAB> <TAB> ) <TAB> if raises : <TAB> <TAB> with self. assertRaises ( raises ) as cm : <TAB> <TAB> <TAB> self. client. auth. ldap. list_users ( <TAB> <TAB> <TAB> <TAB> mount_point = self. TEST_LDAP_PATH, <TAB> <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. assertIn ( <TAB> <TAB> <TAB> <TAB> member = exception_message, <TAB> <TAB> <TAB> <TAB> container = str ( cm. exception ), <TAB> <TAB> <TAB> ) <TAB> else : <TAB> <TAB> list_users_response = self. client. auth. ldap. list_users ( <TAB> <TAB> <TAB> mount_point = self. TEST_LDAP_PATH, <TAB> <TAB> ) <TAB> <TAB> self. assertDictEqual ( <TAB> <TAB> <TAB> d1 = dict ( keys = [ username ] ), <TAB> <TAB> <TAB> d2 = list_users_response [ ""data"" ], <TAB> <TAB> )",False,exception_message is not None,exception_message,0.6601938009262085
|
||
|
4891,"def __getitem__ ( self, key ) : <TAB> if isinstance ( key, slice ) : <TAB> <TAB> entries = [ ] <TAB> <TAB> start = 0 if key. start is None else key. start <TAB> <TAB> stop = len ( self ) if key. stop is None else key. stop <TAB> <TAB> step = 1 if key. step is None else key. step <TAB> <TAB> for i in range ( start, stop, step ) : <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> entry = self [ i ] <TAB> <TAB> <TAB> except IndexError : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> self. _cache [ entry. id ] <TAB> <TAB> <TAB> <TAB> entries. append ( entry ) <TAB> <TAB> return entries <TAB> <TAB> if key < 0 < abs ( key ) <= len ( self ) : <TAB> <TAB> key %= len ( self ) <TAB> for i, entry in enumerate ( self ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. _cache [ entry. id ] <TAB> <TAB> <TAB> return entry <TAB> raise IndexError",False,i == key,key < 0 < entry.id,0.6865389347076416
|
||
|
4892,"def Get_Gene ( self, id ) : <TAB> """"""Retreive the gene name (GN)."""""" <TAB> entry = self. Get ( id ) <TAB> if not entry : <TAB> <TAB> return None <TAB> GN = """" <TAB> for line in string. split ( entry, ""\n"" ) : <TAB> <TAB> if line [ 0 : 5 ] == ""GN "" : <TAB> <TAB> <TAB> GN = string. strip ( line [ 5 : ] ) <TAB> <TAB> <TAB> if GN [ - 1 ] == ""."" : <TAB> <TAB> <TAB> <TAB> GN = GN [ 0 : - 1 ] <TAB> <TAB> <TAB> return GN <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> break <TAB> return GN",False,line[0:2] == '//',GN == None,0.6516856551170349
|
||
|
4893,"def _get_running_vms ( ssh, uuid, sudo_mode = False ) : <TAB> stdin, stdout, stderr = ssh. exec_command ( <TAB> <TAB> ""{}xe vm-list resident-on={} "" <TAB> <TAB> ""params=uuid,name-label,power-state,VCPUs-number,memory-actual"". format ( <TAB> <TAB> <TAB> ""sudo "" if sudo_mode else """", <TAB> <TAB> <TAB> uuid, <TAB> <TAB> ) <TAB> ) <TAB> data = stdout. read ( ) <TAB> vms = set ( ) <TAB> for vm_data in data. split ( ""\n\n"" ) : <TAB> <TAB> info = parse. pairs ( <TAB> <TAB> <TAB> lines = [ <TAB> <TAB> <TAB> <TAB> line. replace ( ""( RO)"", """" ) <TAB> <TAB> <TAB> <TAB>. replace ( ""( RW)"", """" ) <TAB> <TAB> <TAB> <TAB>. replace ( ""(MRO)"", """" ) <TAB> <TAB> <TAB> <TAB>. strip ( ) <TAB> <TAB> <TAB> <TAB> for line in vm_data. splitlines ( ) <TAB> <TAB> <TAB> ] <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> label = info [ ""name-label"" ] <TAB> <TAB> if label. lower ( ). startswith ( ""Transfer VM for"" ) or label. lower ( ). startswith ( <TAB> <TAB> <TAB> ""Control domain on host:"" <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> power = info [ ""power-state"" ] <TAB> <TAB> if power not in { ""running"" } : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> cores = int ( info [ ""VCPUs-number"" ] ) <TAB> <TAB> memory = int ( int ( info [ ""memory-actual"" ] ) / 1024 / 1024 )",False,not info,info[0] == 'T',0.6688408851623535
|
||
|
4894,"def test_sanity_no_misaligned_entities ( CorpusType : Type [ HunerDataset ] ) : <TAB> dataset_name = CorpusType. __class__. __name__. lower ( ) <TAB> base_path = Path ( flair. cache_root ) / ""datasets"" <TAB> data_folder = base_path / dataset_name <TAB> from flair. tokenization import SciSpacyTokenizer <TAB> tokenizer = SciSpacyTokenizer ( ) <TAB> corpus = CorpusType ( ) <TAB> internal = corpus. to_internal ( data_folder ) <TAB> for doc_id, doc_text in internal. documents. items ( ) : <TAB> <TAB> misaligned_starts = [ ] <TAB> <TAB> misaligned_ends = [ ] <TAB> <TAB> token_starts = set ( ) <TAB> <TAB> token_ends = set ( ) <TAB> <TAB> for token, token_start in zip ( * tokenizer. tokenize ( doc_text ) ) : <TAB> <TAB> <TAB> token_starts. add ( token_start ) <TAB> <TAB> <TAB> token_ends. add ( token_start + len ( token ) ) <TAB> <TAB> entities = internal. entities_per_document [ doc_id ] <TAB> <TAB> entity_starts = [ i. char_span. start for i in entities ] <TAB> <TAB> entity_ends = [ i. char_span. stop for i in entities ] <TAB> <TAB> for start in entity_starts : <TAB> <TAB> <TAB> if start not in entity_starts : <TAB> <TAB> <TAB> <TAB> misaligned_starts. append ( start ) <TAB> <TAB> for end in entity_ends : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> misaligned_starts. append ( end ) <TAB> <TAB> assert len ( misaligned_starts ) <= len ( entities ) // 10 <TAB> <TAB> assert len ( misaligned_ends ) <= len ( entities ) // 10",True,end not in entity_ends,end not in entity_ends,0.6612154245376587
|
||
|
4895,"def skip_this_post ( self, time_ts ) : <TAB> """"""Check whether the post is current"""""" <TAB> <TAB> if self. stale is not None : <TAB> <TAB> _how_old = time. time ( ) - time_ts <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> log. debug ( <TAB> <TAB> <TAB> <TAB> ""%s: record %s is stale (%d > %d)."", <TAB> <TAB> <TAB> <TAB> self. protocol_name, <TAB> <TAB> <TAB> <TAB> timestamp_to_string ( time_ts ), <TAB> <TAB> <TAB> <TAB> _how_old, <TAB> <TAB> <TAB> <TAB> self. stale, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> return True <TAB> if self. post_interval is not None : <TAB> <TAB> <TAB> <TAB> _how_long = time_ts - self. lastpost <TAB> <TAB> if _how_long < self. post_interval : <TAB> <TAB> <TAB> log. debug ( <TAB> <TAB> <TAB> <TAB> ""%s: wait interval (%d < %d) has not passed for record %s"", <TAB> <TAB> <TAB> <TAB> self. protocol_name, <TAB> <TAB> <TAB> <TAB> _how_long, <TAB> <TAB> <TAB> <TAB> self. post_interval, <TAB> <TAB> <TAB> <TAB> timestamp_to_string ( time_ts ), <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> return True <TAB> self. lastpost = time_ts <TAB> return False",False,_how_old > self.stale,_how_old < self.lastpost,0.6620189547538757
|
||
|
4896,"def flingToEnd ( self, maxSwipes = 10 ) : <TAB> if self. vertical : <TAB> <TAB> for _ in range ( maxSwipes ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> print ( ""flinging to end"", file = sys. stderr ) <TAB> <TAB> <TAB> self. flingForward ( )",False,DEBUG,self.vertical,0.6839340925216675
|
||
|
4897,"def populate ( self, zone, target = False, lenient = False ) : <TAB> self. log. debug ( <TAB> <TAB> ""populate: name=%s, target=%s, lenient=%s"", zone. name, target, lenient <TAB> ) <TAB> resp = None <TAB> try : <TAB> <TAB> resp = self. _get ( ""zones/{}"". format ( zone. name ) ) <TAB> <TAB> self. log. debug ( ""populate: loaded"" ) <TAB> except HTTPError as e : <TAB> <TAB> if e. response. status_code == 401 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> raise Exception ( ""PowerDNS unauthorized host={}"". format ( self. host ) ) <TAB> <TAB> elif e. response. status_code == 422 : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> pass <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> raise <TAB> before = len ( zone. records ) <TAB> exists = False <TAB> if resp : <TAB> <TAB> exists = True <TAB> <TAB> for rrset in resp. json ( ) [ ""rrsets"" ] : <TAB> <TAB> <TAB> _type = rrset [ ""type"" ] <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> data_for = getattr ( self, ""_data_for_{}"". format ( _type ) ) <TAB> <TAB> <TAB> record_name = zone. hostname_from_fqdn ( rrset [ ""name"" ] ) <TAB> <TAB> <TAB> record = Record. new ( <TAB> <TAB> <TAB> <TAB> zone, record_name, data_for ( rrset ), source = self, lenient = lenient <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> zone. add_record ( record, lenient = lenient ) <TAB> self. log. info ( <TAB> <TAB> ""populate: ",False,_type == 'SOA',_type in ['TAB> or _type!= 'NONE',0.6545922756195068
|
||
|
4898,"def __eq__ ( self, other ) : <TAB> if not isinstance ( other, relativedelta ) : <TAB> <TAB> return False <TAB> if self. weekday or other. weekday : <TAB> <TAB> if not self. weekday or not other. weekday : <TAB> <TAB> <TAB> return False <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return False <TAB> <TAB> n1, n2 = self. weekday. n, other. weekday. n <TAB> <TAB> if n1!= n2 and not ( ( not n1 or n1 == 1 ) and ( not n2 or n2 == 1 ) ) : <TAB> <TAB> <TAB> return False <TAB> return ( <TAB> <TAB> self. years == other. years <TAB> <TAB> and self. months == other. months <TAB> <TAB> and self. days == other. days <TAB> <TAB> and self. hours == other. hours <TAB> <TAB> and self. minutes == other. minutes <TAB> <TAB> and self. seconds == other. seconds <TAB> <TAB> and self. leapdays == other. leapdays <TAB> <TAB> and self. year == other. year <TAB> <TAB> and self. month == other. month <TAB> <TAB> and self. day == other. day <TAB> <TAB> and self. hour == other. hour <TAB> <TAB> and self. minute == other. minute <TAB> <TAB> and self. second == other. second <TAB> <TAB> and self. microsecond == other. microsecond <TAB> )",False,self.weekday.weekday != other.weekday.weekday,"not isinstance(other, relativedelta)",0.6621918082237244
|
||
|
4899,"def _sort_clause ( self, query, joins, sort_field, sort_desc ) : <TAB> if isinstance ( sort_field, string_types ) : <TAB> <TAB> field = getattr ( self. model, sort_field ) <TAB> elif isinstance ( sort_field, Field ) : <TAB> <TAB> model_class = None <TAB> <TAB> try : <TAB> <TAB> <TAB> model_class = sort_field. model_class <TAB> <TAB> except AttributeError : <TAB> <TAB> <TAB> model_class = sort_field. model <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> query = self. _handle_join ( query, sort_field, joins ) <TAB> <TAB> field = sort_field <TAB> clause = field. desc ( ) if sort_desc else field. asc ( ) <TAB> return query, joins, clause",False,model_class != self.model,model_class and sort_desc and (not clause.startswith('.')),0.6589987277984619
|
||
|
4900,"def set_required_env_var ( dcos_env_vars : dict, env_var_name : str ) -> None : <TAB> env_var = os. getenv ( env_var_name ) <TAB> if env_var is None : <TAB> <TAB> print_red ( <TAB> <TAB> <TAB> ""ERROR: required environment variable '{}' is not set!"". format ( env_var_name ) <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> print_red ( ""No dcos-test-utils variables were detected in your environment."" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> print ( ""Current dcos-test-utils variables detected in your environment:"" ) <TAB> <TAB> <TAB> for k, v in dcos_env_vars. items ( ) : <TAB> <TAB> <TAB> <TAB> print ( ""{}={}"". format ( k, v ) ) <TAB> <TAB> print_red ( ""Run 'pytest --env-help' to see all environment variables to set."" ) <TAB> <TAB> sys. exit ( 1 ) <TAB> dcos_env_vars [ env_var_name ] = env_var",False,not dcos_env_vars,dcos_env_vars is None,0.6534987688064575
|
||
|
4901,"def run ( self ) : <TAB> while True : <TAB> <TAB> task = self. requestQueue. get ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> try : <TAB> <TAB> <TAB> if self. interrupted ( ) : <TAB> <TAB> <TAB> <TAB> raise SCons. Errors. BuildError ( task. targets [ 0 ], errstr = interrupt_msg ) <TAB> <TAB> <TAB> task. execute ( ) <TAB> <TAB> except : <TAB> <TAB> <TAB> task. exception_set ( ) <TAB> <TAB> <TAB> ok = False <TAB> <TAB> else : <TAB> <TAB> <TAB> ok = True <TAB> <TAB> self. resultsQueue. put ( ( task, ok ) )",True,task is None,task is None,0.6771646738052368
|
||
|
4902,"def prepare_request ( next_link = None ) : <TAB> <TAB> header_parameters = { } <TAB> header_parameters [ ""Accept"" ] = self. _serialize. header ( ""accept"", accept, ""str"" ) <TAB> if not next_link : <TAB> <TAB> <TAB> <TAB> url = self. list. metadata [ ""url"" ] <TAB> <TAB> path_format_arguments = { <TAB> <TAB> <TAB> ""subscriptionId"" : self. _serialize. url ( <TAB> <TAB> <TAB> <TAB> ""self._config.subscription_id"", self. _config. subscription_id, ""str"" <TAB> <TAB> <TAB> ), <TAB> <TAB> } <TAB> <TAB> url = self. _client. format_url ( url, ** path_format_arguments ) <TAB> <TAB> <TAB> <TAB> query_parameters = { } <TAB> <TAB> if filter is not None : <TAB> <TAB> <TAB> query_parameters [ ""$filter"" ] = self. _serialize. query ( ""filter"", filter, ""str"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> query_parameters [ ""$top"" ] = self. _serialize. query ( ""top"", top, ""int"" ) <TAB> <TAB> query_parameters [ ""api-version"" ] = self. _serialize. query ( <TAB> <TAB> <TAB> ""api_version"", api_version, ""str"" <TAB> <TAB> ) <TAB> <TAB> request = self. _client. get ( url, query_parameters, header_parameters ) <TAB> else : <TAB> <TAB> url = next_link <TAB> <TAB> query_parameters = { } <TAB> <TAB> request = self. _client. get ( url, query_parameters, header_parameters ) <TAB> return request",True,top is not None,top is not None,0.6702080965042114
|
||
|
4903,"def _format_descr ( descr, indent, box ) : <TAB> wrapper = textwrap. TextWrapper ( ) <TAB> if<mask> : <TAB> <TAB> wrapper. initial_indent = indent + "" "" <TAB> <TAB> wrapper. subsequent_indent = indent + "" "" <TAB> <TAB> wrapper. width = self. details. get ( ""width"" ) - 2 <TAB> else : <TAB> <TAB> wrapper. initial_indent = indent <TAB> <TAB> wrapper. subsequent_indent = indent <TAB> <TAB> wrapper. width = self. details. get ( ""width"" ) <TAB> new_descr = """" <TAB> for line in descr. split ( ""\n"" ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> tmp_line = wrapper. fill ( line ) <TAB> <TAB> <TAB> for single_line in tmp_line. split ( ""\n"" ) : <TAB> <TAB> <TAB> <TAB> single_line = single_line. ljust ( self. details. get ( ""width"" ), "" "" ) <TAB> <TAB> <TAB> <TAB> new_descr += ( <TAB> <TAB> <TAB> <TAB> <TAB> single_line [ : len ( indent ) ] <TAB> <TAB> <TAB> <TAB> <TAB> + self. printer. art [ ""vrt"" ] <TAB> <TAB> <TAB> <TAB> <TAB> + single_line [ ( len ( indent ) + 1 ) : ( self. details. get ( ""width"" ) - 1 ) ] <TAB> <TAB> <TAB> <TAB> <TAB> + self. printer. art [ ""vrt"" ] <TAB> <TAB> <TAB> <TAB> <TAB> + ""\n"" <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> new_descr += wrapper. fill ( line ) + ""\n"" <TAB> return new_descr. rstrip ( )",True,box,box,0.6794736385345459
|
||
|
4904,"def run ( self ) : <TAB> eid = self. start_episode ( ) <TAB> obs = self. env. reset ( ) <TAB> while True : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> action = self. env. action_space. sample ( ) <TAB> <TAB> <TAB> self. log_action ( eid, obs, action ) <TAB> <TAB> else : <TAB> <TAB> <TAB> action = self. get_action ( eid, obs ) <TAB> <TAB> obs, reward, done, info = self. env. step ( action ) <TAB> <TAB> self. log_returns ( eid, reward, info = info ) <TAB> <TAB> if done : <TAB> <TAB> <TAB> self. end_episode ( eid, obs ) <TAB> <TAB> <TAB> obs = self. env. reset ( ) <TAB> <TAB> <TAB> eid = self. start_episode ( )",False,random.random() < self.off_pol_frac,self.has_action,0.6470698714256287
|
||
|
4905,"def __init__ ( self, hwnd ) : <TAB> """"""Initialise the instance"""""" <TAB> super ( ListViewWrapper, self ). __init__ ( hwnd ) <TAB> if self. is_unicode ( ) : <TAB> <TAB> self. create_buffer = ctypes. create_unicode_buffer <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. LVCOLUMN = win32structures. LVCOLUMNW <TAB> <TAB> <TAB> self. LVITEM = win32structures. LVITEMW <TAB> <TAB> else : <TAB> <TAB> <TAB> self. LVCOLUMN = win32structures. LVCOLUMNW32 <TAB> <TAB> <TAB> self. LVITEM = win32structures. LVITEMW32 <TAB> <TAB> self. LVM_GETITEM = win32defines. LVM_GETITEMW <TAB> <TAB> self. LVM_GETCOLUMN = win32defines. LVM_GETCOLUMNW <TAB> <TAB> self. text_decode = lambda v : v <TAB> else : <TAB> <TAB> self. create_buffer = ctypes. create_string_buffer <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. LVCOLUMN = win32structures. LVCOLUMNW <TAB> <TAB> <TAB> self. LVITEM = win32structures. LVITEMW <TAB> <TAB> else : <TAB> <TAB> <TAB> self. LVCOLUMN = win32structures. LVCOLUMNW32 <TAB> <TAB> <TAB> self. LVITEM = win32structures. LVITEMW32 <TAB> <TAB> self. LVM_GETCOLUMN = win32defines. LVM_GETCOLUMNA <TAB> <TAB> self. LVM_GETITEM = win32defines. LVM_GETITEMA <TAB> <TAB> self. text_decode = lambda v : v. decode ( locale. getpreferredencoding ( ) )",False,is64bitprocess(self.process_id()) or not is_x64_Python(),self.is_ LV(locale),0.6481010317802429
|
||
|
4906,"def _convert_bbs_to_polygons_ ( cls, batch ) : <TAB> batch_contained_polygons = batch. polygons is not None <TAB> if batch. bounding_boxes is None : <TAB> <TAB> return batch, ( False, batch_contained_polygons ) <TAB> psois = [ bbsoi. to_polygons_on_image ( ) for bbsoi in batch. bounding_boxes ] <TAB> psois = [ psoi. subdivide_ ( 2 ) for psoi in psois ] <TAB> <TAB> for psoi in psois : <TAB> <TAB> for polygon in psoi. polygons : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> polygon. label = ""$$IMGAUG_BB_AS_POLYGON"" <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> polygon. label = polygon. label + "";$$IMGAUG_BB_AS_POLYGON"" <TAB> <TAB> if batch. polygons is None : <TAB> <TAB> batch. polygons = psois <TAB> else : <TAB> <TAB> for psoi, bbs_as_psoi in zip ( batch. polygons, psois ) : <TAB> <TAB> <TAB> assert psoi. shape == bbs_as_psoi. shape, ( <TAB> <TAB> <TAB> <TAB> ""Expected polygons and bounding boxes to have the same "" <TAB> <TAB> <TAB> <TAB> "".shape value, got %s and %s."" % ( psoi. shape, bbs_as_psoi. shape ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> psoi. polygons. extend ( bbs_as_psoi. polygons ) <TAB> batch. bounding_boxes = None <TAB> return batch, ( True, batch_contained_polygons )",True,polygon.label is None,polygon.label is None,0.6603285074234009
|
||
|
4907,"def _expand_env ( self, snapcraft_yaml ) : <TAB> environment_keys = [ ""name"", ""version"" ] <TAB> for key in snapcraft_yaml : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> replacements = environment_to_replacements ( <TAB> <TAB> <TAB> get_snapcraft_global_environment ( self. project ) <TAB> <TAB> ) <TAB> <TAB> snapcraft_yaml [ key ] = replace_attr ( snapcraft_yaml [ key ], replacements ) <TAB> return snapcraft_yaml",False,any((key == env_key for env_key in environment_keys)),key not in environment_keys,0.652614951133728
|
||
|
4908,"def queue_autoscan_network ( network, queue_name = None ) : <TAB> """"""Queues a pre-scan of a whole network on the right worker."""""" <TAB> if not queue_name : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise NoQueueError ( <TAB> <TAB> <TAB> <TAB> ""No discovery queue defined for network "" <TAB> <TAB> <TAB> <TAB> ""environment {0}."". format ( network ), <TAB> <TAB> <TAB> ) <TAB> <TAB> queue_name = network. environment. queue. name <TAB> queue = django_rq. get_queue ( queue_name ) <TAB> for group in _split_into_groups ( <TAB> <TAB> network. network. iterhosts ( ), <TAB> <TAB> ADDRESS_GROUP_SIZE, <TAB> ) : <TAB> <TAB> queue. enqueue_call ( <TAB> <TAB> <TAB> func = _autoscan_group, <TAB> <TAB> <TAB> args = ( group, ), <TAB> <TAB> <TAB> timeout = 90, <TAB> <TAB> <TAB> result_ttl = 0, <TAB> <TAB> ) <TAB> network. last_scan = datetime. datetime. now ( ) <TAB> network. save ( )",False,not network.environment or not network.environment.queue,not network.environment.queue,0.6490414142608643
|
||
|
4909,"def MergeFrom ( self, other ) : <TAB> if self. message_class is not None : <TAB> <TAB> if other. Parse ( self. message_class ) : <TAB> <TAB> <TAB> self. message. MergeFrom ( other. message ) <TAB> elif other. message_class is not None : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. message = other. message_class ( ) <TAB> <TAB> <TAB> self. message_class = other. message_class <TAB> <TAB> self. message. MergeFrom ( other. message ) <TAB> else : <TAB> <TAB> self. message += other. message",False,not self.Parse(other.message_class),"hasattr(other, 'message_class')",0.6524025797843933
|
||
|
4910,"def parse_headers ( obj, f ) : <TAB> """"""Return dict of HTTP headers parsed from a file object."""""" <TAB> <TAB> d = { } <TAB> while 1 : <TAB> <TAB> line = f. readline ( ) <TAB> <TAB> line = line. decode ( ""utf-8"" ) <TAB> <TAB> line = line. strip ( ) <TAB> <TAB> if not line : <TAB> <TAB> <TAB> break <TAB> <TAB> l = line. split ( None, 1 ) <TAB> <TAB> if not l [ 0 ]. endswith ( "":"" ) : <TAB> <TAB> <TAB> obj. errors. append ( dshell. core. DataError ( ""Invalid header {!r}"". format ( line ) ) ) <TAB> <TAB> k = l [ 0 ] [ : - 1 ]. lower ( ) <TAB> <TAB> v = len ( l )!= 1 and l [ 1 ] or """" <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if not type ( d [ k ] ) is list : <TAB> <TAB> <TAB> <TAB> d [ k ] = [ d [ k ] ] <TAB> <TAB> <TAB> d [ k ]. append ( v ) <TAB> <TAB> else : <TAB> <TAB> <TAB> d [ k ] = v <TAB> return d",True,k in d,k in d,0.6770328879356384
|
||
|
4911,"def sanitize_function_name ( s ) : <TAB> func = None <TAB> if s is not None : <TAB> <TAB> try : <TAB> <TAB> <TAB> valid = re. match ( r""^[\w]+\(\)"", s ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> func = re. sub ( ""[()]"", """", s ) <TAB> <TAB> except : <TAB> <TAB> <TAB> pass <TAB> return func",False,valid is not None,valid,0.6631897687911987
|
||
|
4912,"def main ( server = SERVER ) : <TAB> c = MQTTClient ( CLIENT_ID, server ) <TAB> c. connect ( ) <TAB> print ( ""Connected to %s, waiting for button presses"" % server ) <TAB> while True : <TAB> <TAB> while True : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> time. sleep_ms ( 20 ) <TAB> <TAB> print ( ""Button pressed"" ) <TAB> <TAB> c. publish ( TOPIC, b""toggle"" ) <TAB> <TAB> time. sleep_ms ( 200 ) <TAB> c. disconnect ( )",False,button.value() == 0,not c.isOpen(),0.6571131944656372
|
||
|
4913,"def OnRefresh ( self ) : <TAB> try : <TAB> <TAB> self. Clear ( ) <TAB> <TAB> self. nodes = { } <TAB> <TAB> for key in self. graph : <TAB> <TAB> <TAB> self. nodes [ key ] = self. AddNode ( [ key, self. graph [ key ] ] ) <TAB> <TAB> for key in self. relations : <TAB> <TAB> <TAB> if not key in self. nodes : <TAB> <TAB> <TAB> <TAB> self. nodes [ key ] = self. AddNode ( [ key, [ [ 0, 0, """" ] ] ] ) <TAB> <TAB> <TAB> parent_node = self. nodes [ key ] <TAB> <TAB> <TAB> for child in self. relations [ key ] : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> self. nodes [ child ] = self. AddNode ( [ child, [ [ 0, 0, """" ] ] ] ) <TAB> <TAB> <TAB> <TAB> child_node = self. nodes [ child ] <TAB> <TAB> <TAB> <TAB> self. AddEdge ( parent_node, child_node ) <TAB> <TAB> return True <TAB> except : <TAB> <TAB> print ( ""GraphViewer Error:"", sys. exc_info ( ) [ 1 ] ) <TAB> <TAB> return True",False,not child in self.nodes,child in self.nodes,0.6619868278503418
|
||
|
4914,"def find_package_names ( ) : <TAB> site_packages = sysconfig. get_python_lib ( ) <TAB> <TAB> res = { <TAB> <TAB> ""yaml"" : ""PyYAML"", <TAB> <TAB> ""Crypto"" : ""pycrypto"", <TAB> } <TAB> for pth in os. listdir ( site_packages ) : <TAB> <TAB> if not pth. endswith ( "".dist-info"" ) : <TAB> <TAB> <TAB> continue <TAB> <TAB> pkgname = pth. split ( ""-"", 1 ) [ 0 ]. replace ( ""_"", ""-"" ) <TAB> <TAB> top_level_fname = os. path. join ( site_packages, pth, ""top_level.txt"" ) <TAB> <TAB> if not os. path. exists ( top_level_fname ) : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> print ( ""ERR:"", pth, ""has not top_level.txt"" ) <TAB> <TAB> <TAB> continue <TAB> <TAB> for modname in open ( top_level_fname ). read ( ). split ( ) : <TAB> <TAB> <TAB> modname = modname. replace ( ""/"", ""."" ) <TAB> <TAB> <TAB> if modname. startswith ( r""win32\lib"" ) : <TAB> <TAB> <TAB> <TAB> modname = modname. rsplit ( ""\\"" ) [ 1 ] <TAB> <TAB> <TAB> res [ modname ] = pkgname <TAB> return res",False,pkgname not in res.values(),not os.path.exists(top_level_fname),0.6556094884872437
|
||
|
4915,"def signature ( self ) : <TAB> try : <TAB> <TAB> from hashlib import md5 <TAB> except ImportError : <TAB> <TAB> from md5 import md5 <TAB> try : <TAB> <TAB> sig = md5 ( ) <TAB> <TAB> if self. start : <TAB> <TAB> <TAB> sig. update ( self. start. encode ( ""latin-1"" ) ) <TAB> <TAB> if self. prec : <TAB> <TAB> <TAB> sig. update ( """". join ( [ """". join ( p ) for p in self. prec ] ). encode ( ""latin-1"" ) ) <TAB> <TAB> if self. tokens : <TAB> <TAB> <TAB> sig. update ( "" "". join ( self. tokens ). encode ( ""latin-1"" ) ) <TAB> <TAB> for f in self. pfuncs : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> sig. update ( f [ 3 ]. encode ( ""latin-1"" ) ) <TAB> except ( TypeError, ValueError ) : <TAB> <TAB> pass <TAB> digest = base64. b16encode ( sig. digest ( ) ) <TAB> if sys. version_info [ 0 ] >= 3 : <TAB> <TAB> digest = digest. decode ( ""latin-1"" ) <TAB> return digest",True,f[3],f[3],0.6632217764854431
|
||
|
4916,"def __init__ ( self, parent, name, columns = None, create = True, typeless = False ) : <TAB> self. parent = parent <TAB> self. name = unsafeSQLIdentificatorNaming ( name ) <TAB> self. columns = columns <TAB> if create : <TAB> <TAB> self. execute ( 'DROP TABLE IF EXISTS ""%s""' % self. name ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. execute ( <TAB> <TAB> <TAB> <TAB> 'CREATE TABLE ""%s"" (%s)' <TAB> <TAB> <TAB> <TAB> % ( <TAB> <TAB> <TAB> <TAB> <TAB> self. name, <TAB> <TAB> <TAB> <TAB> <TAB> "","". join ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> '""%s"" %s' % ( unsafeSQLIdentificatorNaming ( colname ), coltype ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for colname, coltype in self. columns <TAB> <TAB> <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. execute ( <TAB> <TAB> <TAB> <TAB> 'CREATE TABLE ""%s"" (%s)' <TAB> <TAB> <TAB> <TAB> % ( <TAB> <TAB> <TAB> <TAB> <TAB> self. name, <TAB> <TAB> <TAB> <TAB> <TAB> "","". join ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> '""%s""' % unsafeSQLIdentificatorNaming ( colname ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for colname in self. columns <TAB> <TAB> <TAB> <TAB> <TAB> ), <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> )",False,not typeless,typeless,0.6845206022262573
|
||
|
4917,"def evaluate_test_corpus ( self, corpus ) : <TAB> logger. info ( ""TEST: evaluating test corpus"" ) <TAB> if self. lda_alpha is None or self. lda_beta is None : <TAB> <TAB> self. lda_alpha, self. lda_beta = self. hdp_to_lda ( ) <TAB> score = 0.0 <TAB> total_words = 0 <TAB> for i, doc in enumerate ( corpus ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> doc_word_ids, doc_word_counts = zip ( * doc ) <TAB> <TAB> <TAB> likelihood, gamma = lda_e_step ( <TAB> <TAB> <TAB> <TAB> doc_word_ids, doc_word_counts, self. lda_alpha, self. lda_beta <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> theta = gamma / np. sum ( gamma ) <TAB> <TAB> <TAB> lda_betad = self. lda_beta [ :, doc_word_ids ] <TAB> <TAB> <TAB> log_predicts = np. log ( np. dot ( theta, lda_betad ) ) <TAB> <TAB> <TAB> doc_score = sum ( log_predicts ) / len ( doc ) <TAB> <TAB> <TAB> logger. info ( ""TEST: %6d %.5f"" % ( i, doc_score ) ) <TAB> <TAB> <TAB> score += likelihood <TAB> <TAB> <TAB> total_words += sum ( doc_word_counts ) <TAB> logger. info ( <TAB> <TAB> ""TEST: average score: %.5f, total score: %.5f, test docs: %d"" <TAB> <TAB> % ( score / total_words, score, len ( corpus ) ) <TAB> ) <TAB> return score",True,len(doc) > 0,len(doc) > 0,0.6546361446380615
|
||
|
4918,"def test_controlcharacters ( self ) : <TAB> for i in range ( 128 ) : <TAB> <TAB> c = chr ( i ) <TAB> <TAB> testString = ""string containing %s"" % c <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> plistlib. dumps ( testString, fmt = plistlib. FMT_XML ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. assertRaises ( ValueError, plistlib. dumps, testString )",False,i >= 32 or c in '\r\n\t',c == '\n',0.656378448009491
|
||
|
4919,"def __getitem__ ( self, key ) : <TAB> if key == 1 : <TAB> <TAB> return self. get_value ( ) <TAB> elif key == 0 : <TAB> <TAB> return self. cell [ 0 ] <TAB> elif isinstance ( key, slice ) : <TAB> <TAB> s = list ( self. cell. __getitem__ ( key ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> s [ s. index ( self. cell [ 1 ] ) ] = self. get_value ( ) <TAB> <TAB> return s <TAB> else : <TAB> <TAB> raise IndexError ( key )",False,self.cell[1] in s,key == self.cell[1],0.6674330830574036
|
||
|
4920,"def __init__ ( self, _inf = None, _tzinfos = None ) : <TAB> if _inf : <TAB> <TAB> self. _tzinfos = _tzinfos <TAB> <TAB> self. _utcoffset, self. _dst, self. _tzname = _inf <TAB> else : <TAB> <TAB> _tzinfos = { } <TAB> <TAB> self. _tzinfos = _tzinfos <TAB> <TAB> self. _utcoffset, self. _dst, self. _tzname = self. _transition_info [ 0 ] <TAB> <TAB> _tzinfos [ self. _transition_info [ 0 ] ] = self <TAB> <TAB> for inf in self. _transition_info [ 1 : ] : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> _tzinfos [ inf ] = self. __class__ ( inf, _tzinfos )",False,not _tzinfos.has_key(inf),inf not in _tzinfos,0.6518496870994568
|
||
|
4921,"def transform_privatedns_record_set_table_output ( result ) : <TAB> table_output = [ ] <TAB> for item in result : <TAB> <TAB> table_row = OrderedDict ( ) <TAB> <TAB> table_row [ ""Name"" ] = item [ ""name"" ] <TAB> <TAB> table_row [ ""ResourceGroup"" ] = item [ ""resourceGroup"" ] <TAB> <TAB> table_row [ ""Ttl"" ] = item [ ""ttl"" ] <TAB> <TAB> table_row [ ""Type"" ] = item [ ""type"" ]. rsplit ( ""/"", 1 ) [ 1 ] <TAB> <TAB> table_row [ ""AutoRegistered"" ] = item [ ""isAutoRegistered"" ] <TAB> <TAB> metadata = item [ ""metadata"" ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> table_row [ ""Metadata"" ] = "" "". join ( <TAB> <TAB> <TAB> <TAB> [ '{}=""{}""'. format ( x, metadata [ x ] ) for x in sorted ( metadata ) ] <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> table_row [ ""Metadata"" ] = "" "" <TAB> <TAB> table_output. append ( table_row ) <TAB> return table_output",True,metadata,metadata,0.6857409477233887
|
||
|
4922,"def generator_mode ( ) : <TAB> if description is not None : <TAB> <TAB> <TAB> <TAB> yield ""description"", ""meta"", description <TAB> <TAB> for data in fn ( * args, ** kw ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if len ( data )!= 2 : <TAB> <TAB> <TAB> yield data <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> ( key, value ) = data <TAB> <TAB> if value is None : <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> yield key, ""data"", encode ( value ) <TAB> <TAB> <TAB> yield key, ""ssz"", serialize ( value ) <TAB> <TAB> elif isinstance ( value, bytes ) : <TAB> <TAB> <TAB> yield key, ""data"", encode ( value ) <TAB> <TAB> <TAB> yield key, ""ssz"", value <TAB> <TAB> elif isinstance ( value, list ) and all ( <TAB> <TAB> <TAB> [ isinstance ( el, ( View, bytes ) ) for el in value ] <TAB> <TAB> ) : <TAB> <TAB> <TAB> for i, el in enumerate ( value ) : <TAB> <TAB> <TAB> <TAB> if isinstance ( el, View ) : <TAB> <TAB> <TAB> <TAB> <TAB> yield f""{key}_{i}"", ""data"", encode ( el ) <TAB> <TAB> <TAB> <TAB> <TAB> yield f""{key}_{i}"", ""ssz"", serialize ( el ) <TAB> <TAB> <TAB> <TAB> elif isinstance ( el, bytes ) : <TAB> <TAB> <TAB> <TAB> <TAB> yield f""{key}_{i}"", ""data"", encode ( el ) <TAB> <TAB> <TAB> <TAB> <TAB> yield f""{key}_{i}"", ""ssz"", el <TAB> <TAB> <TAB> yield f""{key}_count"", ""meta"", len ( value ) <TAB> <TAB> else : <",False,"isinstance(value, View)","isinstance(value, list)",0.6508713960647583
|
||
|
4923,"def read ( self ) : <TAB> """"""Reads data from stream and switch state."""""" <TAB> assert self. status in ( WAIT_LEN, WAIT_MESSAGE ) <TAB> if self. status == WAIT_LEN : <TAB> <TAB> self. _read_len ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> elif self. status == WAIT_MESSAGE : <TAB> <TAB> read = self. socket. recv ( self. len - len ( self. message ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> logging. error ( <TAB> <TAB> <TAB> <TAB> ""can't read frame from socket (get %d of %d bytes)"" <TAB> <TAB> <TAB> <TAB> % ( len ( self. message ), self. len ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> self. close ( ) <TAB> <TAB> <TAB> return <TAB> <TAB> self. message += read <TAB> <TAB> if len ( self. message ) == self. len : <TAB> <TAB> <TAB> self. status = WAIT_PROCESS",False,len(read) == 0,not read,0.6630752086639404
|
||
|
4924,"def posts_split_endpoint ( request, thread ) : <TAB> if not thread. acl [ ""can_move_posts"" ] : <TAB> <TAB> raise PermissionDenied ( _ ( ""You can't split posts from this thread."" ) ) <TAB> serializer = SplitPostsSerializer ( <TAB> <TAB> data = request. data, <TAB> <TAB> context = { <TAB> <TAB> <TAB> ""settings"" : request. settings, <TAB> <TAB> <TAB> ""thread"" : thread, <TAB> <TAB> <TAB> ""user_acl"" : request. user_acl, <TAB> <TAB> }, <TAB> ) <TAB> if not serializer. is_valid ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> errors = serializer. errors [ ""posts"" ] <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> errors = { ""detail"" : errors [ 0 ] } <TAB> <TAB> <TAB> except KeyError : <TAB> <TAB> <TAB> <TAB> if isinstance ( errors, dict ) : <TAB> <TAB> <TAB> <TAB> <TAB> errors = { ""detail"" : list ( errors. values ( ) ) [ 0 ] [ 0 ] } <TAB> <TAB> else : <TAB> <TAB> <TAB> errors = serializer. errors <TAB> <TAB> return Response ( errors, status = 400 ) <TAB> split_posts_to_new_thread ( request, thread, serializer. validated_data ) <TAB> return Response ( { } )",False,'posts' in serializer.errors,"hasattr(serializer.errors, 'post_post')",0.672057032585144
|
||
|
4925,"def undecorated ( o ) : <TAB> """"""Remove all decorators from a function, method or class"""""" <TAB> <TAB> if isinstance ( o, type ) : <TAB> <TAB> return o <TAB> try : <TAB> <TAB> <TAB> <TAB> closure = o. func_closure <TAB> except AttributeError : <TAB> <TAB> pass <TAB> try : <TAB> <TAB> <TAB> <TAB> closure = o. __closure__ <TAB> except AttributeError : <TAB> <TAB> return <TAB> if closure : <TAB> <TAB> for cell in closure : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if looks_like_a_decorator ( cell. cell_contents ) : <TAB> <TAB> <TAB> <TAB> undecd = undecorated ( cell. cell_contents ) <TAB> <TAB> <TAB> <TAB> if undecd : <TAB> <TAB> <TAB> <TAB> <TAB> return undecd <TAB> return o",False,cell.cell_contents is o,cell.cell_contents is None,0.6579523086547852
|
||
|
4926,"def update ( self ) : <TAB> if not self. is_available : <TAB> <TAB> return <TAB> current_measurement_value = self. reader. read_power ( ) <TAB> current_measurement_time = time. time ( ) <TAB> for m_idx, _ in enumerate ( self. last_probe ) : <TAB> <TAB> joule_used = ( <TAB> <TAB> <TAB> current_measurement_value [ m_idx ]. current - self. last_probe [ m_idx ]. current <TAB> <TAB> ) / float ( self. MICRO_JOULE_IN_JOULE ) <TAB> <TAB> self. last_probe [ m_idx ] = joule_used <TAB> <TAB> seconds_passed = current_measurement_time - self. last_probe_time <TAB> <TAB> logging. debug ( ""seconds passed %s"", seconds_passed ) <TAB> <TAB> watts_used = float ( joule_used ) / float ( seconds_passed ) <TAB> <TAB> logging. debug ( ""watts used %s"", watts_used ) <TAB> <TAB> logging. info ( ""Joule_Used %d, seconds passed, %d"", joule_used, seconds_passed ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> self. last_measurement [ m_idx ] = watts_used <TAB> <TAB> <TAB> logging. info ( ""Power reading elapsed"" ) <TAB> self. last_probe = current_measurement_value <TAB> self. last_probe_time = current_measurement_time",False,watts_used > 0,self.last_measurement is not None,0.6577527523040771
|
||
|
4927,"def resend_activation_email ( request ) : <TAB> if request. user. is_authenticated : <TAB> <TAB> return redirect ( request. GET. get ( ""next"", reverse ( ""spirit:user:update"" ) ) ) <TAB> form = ResendActivationForm ( data = post_data ( request ) ) <TAB> if is_post ( request ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> user = form. get_user ( ) <TAB> <TAB> <TAB> send_activation_email ( request, user ) <TAB> <TAB> <TAB> <TAB> messages. info ( <TAB> <TAB> <TAB> request, <TAB> <TAB> <TAB> _ ( <TAB> <TAB> <TAB> <TAB> ""If you don't receive an email, please make sure you've entered "" <TAB> <TAB> <TAB> <TAB> ""the address you registered with, and check your spam folder."" <TAB> <TAB> <TAB> ), <TAB> <TAB> ) <TAB> <TAB> return redirect ( reverse ( settings. LOGIN_URL ) ) <TAB> return render ( <TAB> <TAB> request = request, <TAB> <TAB> template_name = ""spirit/user/auth/activation_resend.html"", <TAB> <TAB> context = { ""form"" : form }, <TAB> )",False,not request.is_limited() and form.is_valid(),not form.is_valid(),0.6472569704055786
|
||
|
4928,"def testChildNamesHash ( self ) : <TAB> p = GafferScene. Plane ( ) <TAB> g1 = GafferScene. Group ( ) <TAB> g1 [ ""in"" ] [ 0 ]. setInput ( p [ ""out"" ] ) <TAB> g2 = GafferScene. Group ( ) <TAB> g2 [ ""in"" ] [ 0 ]. setInput ( p [ ""out"" ] ) <TAB> self. assertSceneHashesEqual ( g1 [ ""out"" ], g2 [ ""out"" ] ) <TAB> g2 [ ""name"" ]. setValue ( ""stuff"" ) <TAB> equivalentPaths = [ <TAB> <TAB> ( ""/"", ""/"" ), <TAB> <TAB> ( ""/group"", ""/stuff"" ), <TAB> <TAB> ( ""/group/plane"", ""/stuff/plane"" ), <TAB> ] <TAB> for path1, path2 in equivalentPaths : <TAB> <TAB> self. assertEqual ( g1 [ ""out"" ]. boundHash ( path1 ), g2 [ ""out"" ]. boundHash ( path2 ) ) <TAB> <TAB> self. assertEqual ( g1 [ ""out"" ]. transformHash ( path1 ), g2 [ ""out"" ]. transformHash ( path2 ) ) <TAB> <TAB> self. assertEqual ( g1 [ ""out"" ]. objectHash ( path1 ), g2 [ ""out"" ]. objectHash ( path2 ) ) <TAB> <TAB> self. assertEqual ( <TAB> <TAB> <TAB> g1 [ ""out"" ]. attributesHash ( path1 ), g2 [ ""out"" ]. attributesHash ( path2 ) <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. assertEqual ( <TAB> <TAB> <TAB> <TAB> g1 [ ""out"" ]. childNamesHash ( path1 ), g2 [ ""out"" ]. childNamesHash ( path2 ) <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. assertNotEqual ( <TAB> <TAB> <TAB> <TAB> g1 [ ""out",False,path1 is not '/',"hasattr(g1, 'out')",0.6571784019470215
|
||
|
4929,"def __try_auth_token ( self, auth_string ) : <TAB> if not self. __database_connection : <TAB> <TAB> return None <TAB> user_name, token = auth_string. split ( "":"", 1 ) <TAB> transaction = None <TAB> try : <TAB> <TAB> <TAB> <TAB> transaction = self. __database_connection ( ) <TAB> <TAB> auth_session = ( <TAB> <TAB> <TAB> transaction. query ( SessionRecord. token ) <TAB> <TAB> <TAB>. filter ( SessionRecord. user_name == user_name ) <TAB> <TAB> <TAB>. filter ( SessionRecord. token == token ) <TAB> <TAB> <TAB>. filter ( SessionRecord. can_expire. is_ ( False ) ) <TAB> <TAB> <TAB>. limit ( 1 ) <TAB> <TAB> <TAB>. one_or_none ( ) <TAB> <TAB> ) <TAB> <TAB> if not auth_session : <TAB> <TAB> <TAB> return False <TAB> <TAB> return auth_session <TAB> except Exception as e : <TAB> <TAB> LOG. error ( ""Couldn't check login in the database: "" ) <TAB> <TAB> LOG. error ( str ( e ) ) <TAB> finally : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> transaction. close ( )",True,transaction,transaction,0.697189211845398
|
||
|
4930,"def _collect_logs ( model ) : <TAB> page_token = None <TAB> all_logs = [ ] <TAB> while True : <TAB> <TAB> paginated_logs = model. lookup_logs ( now, later, page_token = page_token ) <TAB> <TAB> page_token = paginated_logs. next_page_token <TAB> <TAB> all_logs. extend ( paginated_logs. logs ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> break <TAB> return all_logs",False,page_token is None,page_token and page_token == 'TAB > <TAB > 'next_page_token',0.6544469594955444
|
||
|
4931,"def runTest ( self ) : <TAB> """"""This function will add domain under schema node."""""" <TAB> db_con = database_utils. connect_database ( <TAB> <TAB> self, utils. SERVER_GROUP, self. server_id, self. db_id <TAB> ) <TAB> if not db_con [ ""data"" ] [ ""connected"" ] : <TAB> <TAB> raise Exception ( ""Could not connect to database to get the domain."" ) <TAB> db_name = self. database_info [ ""db_name"" ] <TAB> schema_response = schema_utils. verify_schemas ( <TAB> <TAB> self. server, db_name, self. schema_name <TAB> ) <TAB> if not schema_response : <TAB> <TAB> raise Exception ( ""Could not find the schema to get the domain."" ) <TAB> self. domain_id = self. domain_info [ 0 ] <TAB> <TAB> if self. is_positive_test : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> response = self. get_domain_list ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> response = self. get_domain ( ) <TAB> else : <TAB> <TAB> if hasattr ( self, ""error_fetching_domain"" ) : <TAB> <TAB> <TAB> with patch ( <TAB> <TAB> <TAB> <TAB> self. mock_data [ ""function_name"" ], <TAB> <TAB> <TAB> <TAB> return_value = eval ( self. mock_data [ ""return_value"" ] ), <TAB> <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> response = self. get_domain_list ( ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> response = self. get_domain ( ) <TAB> <TAB> if hasattr ( self, ""wrong_domain_id"" ) : <TAB> <TAB> <TAB> self. domain_id = 99999 <TAB> <TAB> <TAB> response =",False,"hasattr(self, 'domain_list')",self.is_negative_test,0.6509230136871338
|
||
|
4932,"def emit ( self, record ) : <TAB> try : <TAB> <TAB> app = get_app ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> msg = self. format ( record ) <TAB> <TAB> <TAB> debug_buffer = app. layout. get_buffer_by_name ( ""debug_buffer"" ) <TAB> <TAB> <TAB> current_document = debug_buffer. document. text <TAB> <TAB> <TAB> if current_document : <TAB> <TAB> <TAB> <TAB> msg = ""\n"". join ( [ current_document, msg ] ) <TAB> <TAB> <TAB> debug_buffer. set_document ( Document ( text = msg ), bypass_readonly = True ) <TAB> <TAB> else : <TAB> <TAB> <TAB> super ( ). emit ( record ) <TAB> except : <TAB> <TAB> self. handleError ( record )",False,"app.is_running and getattr(app, 'debug', False)",app,0.6469560861587524
|
||
|
4933,"def test_getitem ( self ) : <TAB> n = 200 <TAB> d = deque ( xrange ( n ) ) <TAB> l = range ( n ) <TAB> for i in xrange ( n ) : <TAB> <TAB> d. popleft ( ) <TAB> <TAB> l. pop ( 0 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> d. append ( i ) <TAB> <TAB> <TAB> l. append ( i ) <TAB> <TAB> for j in xrange ( 1 - len ( l ), len ( l ) ) : <TAB> <TAB> <TAB> assert d [ j ] == l [ j ] <TAB> d = deque ( ""superman"" ) <TAB> self. assertEqual ( d [ 0 ], ""s"" ) <TAB> self. assertEqual ( d [ - 1 ], ""n"" ) <TAB> d = deque ( ) <TAB> self. assertRaises ( IndexError, d. __getitem__, 0 ) <TAB> self. assertRaises ( IndexError, d. __getitem__, - 1 )",False,random.random() < 0.5,len(l) > 0,0.6526885032653809
|
||
|
4934,"def set_print_format_fields ( self ) : <TAB> bank_amount = party_amount = total_amount = 0.0 <TAB> currency = bank_account_currency = party_account_currency = pay_to_recd_from = None <TAB> party_type = None <TAB> for d in self. get ( ""accounts"" ) : <TAB> <TAB> if d. party_type in [ ""Customer"", ""Supplier"" ] and d. party : <TAB> <TAB> <TAB> party_type = d. party_type <TAB> <TAB> <TAB> if not pay_to_recd_from : <TAB> <TAB> <TAB> <TAB> pay_to_recd_from = d. party <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> party_amount += ( <TAB> <TAB> <TAB> <TAB> <TAB> d. debit_in_account_currency or d. credit_in_account_currency <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> party_account_currency = d. account_currency <TAB> <TAB> elif frappe. db. get_value ( ""Account"", d. account, ""account_type"" ) in [ <TAB> <TAB> <TAB> ""Bank"", <TAB> <TAB> <TAB> ""Cash"", <TAB> <TAB> ] : <TAB> <TAB> <TAB> bank_amount += d. debit_in_account_currency or d. credit_in_account_currency <TAB> <TAB> <TAB> bank_account_currency = d. account_currency <TAB> if party_type and pay_to_recd_from : <TAB> <TAB> self. pay_to_recd_from = frappe. db. get_value ( <TAB> <TAB> <TAB> party_type, <TAB> <TAB> <TAB> pay_to_recd_from, <TAB> <TAB> <TAB> ""customer_name"" if party_type == ""Customer"" else ""supplier_name"", <TAB> <TAB> ) <TAB> <TAB> if bank",False,pay_to_recd_from and pay_to_recd_from == d.party,d.account_currency,0.6474637389183044
|
||
|
4935,def rmdir ( dirname ) : <TAB> if dirname [ - 1 ] == os. sep : <TAB> <TAB> dirname = dirname [ : - 1 ] <TAB> if os. path. islink ( dirname ) : <TAB> <TAB> return <TAB> for f in os. listdir ( dirname ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> path = dirname + os. sep + f <TAB> <TAB> if os. path. isdir ( path ) : <TAB> <TAB> <TAB> rmdir ( path ) <TAB> <TAB> else : <TAB> <TAB> <TAB> os. unlink ( path ) <TAB> os. rmdir ( dirname ),False,"f in ('.', '..')",f.endswith('.yaml'),0.6566120386123657
|
||
|
4936,"def func ( args, env = None, include_stderr = False, expect_exit = False ) : <TAB> if not env : <TAB> <TAB> env = { } <TAB> system_exit = False <TAB> with monkeypatch. context ( ) as monkeypatch_ctx : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for name, val in env. items ( ) : <TAB> <TAB> <TAB> monkeypatch_ctx. setenv ( name, val ) <TAB> <TAB> try : <TAB> <TAB> <TAB> main ( args ) <TAB> <TAB> except SystemExit : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> system_exit = True <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> raise <TAB> if<mask> : <TAB> <TAB> assert system_exit, ""Expected command to exit, but command succeeded instead"" <TAB> stdout, stderr = capsys. readouterr ( ) <TAB> if include_stderr : <TAB> <TAB> return stdout, stderr <TAB> else : <TAB> <TAB> return stdout",True,expect_exit,expect_exit,0.6620639562606812
|
||
|
4937,"def _prepare_travel_graph ( self ) : <TAB> for op in self. op_dict. values ( ) : <TAB> <TAB> op. const = False <TAB> <TAB> if op. node. op in [ ""Const"", ""Placeholder"" ] : <TAB> <TAB> <TAB> op. resolved = True <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> op. const = True <TAB> <TAB> else : <TAB> <TAB> <TAB> op. resolved = False",False,op.node.op == 'Const',"op.node.op in [_Const, _Placeholder]",0.6533916592597961
|
||
|
4938,"def _force_local ( cls, pex_file, pex_info ) : <TAB> if pex_info. code_hash is None : <TAB> <TAB> <TAB> <TAB> return pex_file <TAB> explode_dir = os. path. join ( pex_info. zip_unsafe_cache, pex_info. code_hash ) <TAB> TRACER. log ( ""PEX is not zip safe, exploding to %s"" % explode_dir ) <TAB> with atomic_directory ( explode_dir ) as explode_tmp : <TAB> <TAB> if explode_tmp : <TAB> <TAB> <TAB> with TRACER. timed ( ""Unzipping %s"" % pex_file ) : <TAB> <TAB> <TAB> <TAB> with open_zip ( pex_file ) as pex_zip : <TAB> <TAB> <TAB> <TAB> <TAB> pex_files = ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> x <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for x in pex_zip. namelist ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> and not x. startswith ( pex_info. internal_cache ) <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> pex_zip. extractall ( explode_tmp, pex_files ) <TAB> return explode_dir",False,not x.startswith(pex_builder.BOOTSTRAP_DIR),pex_info.internal_cache and pex_files,0.6468230485916138
|
||
|
4939,"def _tableGetCount ( self, db, table ) : <TAB> if not db or not table : <TAB> <TAB> return None <TAB> if Backend. getIdentifiedDbms ( ) in UPPER_CASE_DBMSES : <TAB> <TAB> db = db. upper ( ) <TAB> <TAB> table = table. upper ( ) <TAB> if Backend. getIdentifiedDbms ( ) in ( <TAB> <TAB> DBMS. SQLITE, <TAB> <TAB> DBMS. ACCESS, <TAB> <TAB> DBMS. FIREBIRD, <TAB> <TAB> DBMS. MCKOI, <TAB> <TAB> DBMS. EXTREMEDB, <TAB> ) : <TAB> <TAB> query = ""SELECT %s FROM %s"" % ( <TAB> <TAB> <TAB> queries [ Backend. getIdentifiedDbms ( ) ]. count. query % ""*"", <TAB> <TAB> <TAB> safeSQLIdentificatorNaming ( table, True ), <TAB> <TAB> ) <TAB> else : <TAB> <TAB> query = ""SELECT %s FROM %s.%s"" % ( <TAB> <TAB> <TAB> queries [ Backend. getIdentifiedDbms ( ) ]. count. query % ""*"", <TAB> <TAB> <TAB> safeSQLIdentificatorNaming ( db ), <TAB> <TAB> <TAB> safeSQLIdentificatorNaming ( table, True ), <TAB> <TAB> ) <TAB> query = agent. whereQuery ( query ) <TAB> count = inject. getValue ( <TAB> <TAB> query, expected = EXPECTED. INT, charsetType = CHARSET_TYPE. DIGITS <TAB> ) <TAB> if isNumPosStrValue ( count ) : <TAB> <TAB> if safeSQLIdentificatorNaming ( db ) not in kb. data. cachedCounts : <TAB> <TAB> <TAB> kb. data. cachedCounts [ safeSQLIdentificatorNaming ( db ) ] = { } <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> kb. data. cachedCounts [ safeSQLIdentificatorNaming ( db ) ] [ int ( count ) ]. append ( <TAB> <TAB> <TAB> <",False,int(count) in kb.data.cachedCounts[safeSQLIdentificatorNaming(db)],safeSQLIdentificatorNaming(db) in self.data.cachedCounts,0.6604896187782288
|
||
|
4940,"def run ( self ) : <TAB> pwd_found = [ ] <TAB> if constant. user_dpapi and constant. user_dpapi. unlocked : <TAB> <TAB> main_vault_directory = os. path. join ( <TAB> <TAB> <TAB> constant. profile [ ""APPDATA"" ], u"".."", u""Local"", u""Microsoft"", u""Vault"" <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> for vault_directory in os. listdir ( main_vault_directory ) : <TAB> <TAB> <TAB> <TAB> cred = constant. user_dpapi. decrypt_vault ( <TAB> <TAB> <TAB> <TAB> <TAB> os. path. join ( main_vault_directory, vault_directory ) <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> if cred : <TAB> <TAB> <TAB> <TAB> <TAB> pwd_found. append ( cred ) <TAB> return pwd_found",False,os.path.exists(main_vault_directory),os.path.isdir(main_vault_directory),0.6522239446640015
|
||
|
4941,"def __init__ ( self, * args, ** kwargs ) : <TAB> """"""Initialize the structured grid."""""" <TAB> super ( ). __init__ ( ) <TAB> if len ( args ) == 1 : <TAB> <TAB> if isinstance ( args [ 0 ], vtk. vtkStructuredGrid ) : <TAB> <TAB> <TAB> self. deep_copy ( args [ 0 ] ) <TAB> <TAB> elif isinstance ( args [ 0 ], str ) : <TAB> <TAB> <TAB> self. _from_file ( args [ 0 ] ) <TAB> elif len ( args ) == 3 : <TAB> <TAB> arg0_is_arr = isinstance ( args [ 0 ], np. ndarray ) <TAB> <TAB> arg1_is_arr = isinstance ( args [ 1 ], np. ndarray ) <TAB> <TAB> arg2_is_arr = isinstance ( args [ 2 ], np. ndarray ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _from_arrays ( args [ 0 ], args [ 1 ], args [ 2 ] )",False,"all([arg0_is_arr, arg1_is_arr, arg2_is_arr])",arg0_is_arr and arg1_is_arr and (args[2] is None),0.6527261734008789
|
||
|
4942,"def udfInjectCore ( self, udfDict ) : <TAB> written = False <TAB> for udf in udfDict. keys ( ) : <TAB> <TAB> if udf in self. createdUdf : <TAB> <TAB> <TAB> continue <TAB> <TAB> self. udfCheckAndOverwrite ( udf ) <TAB> if len ( self. udfToCreate ) > 0 : <TAB> <TAB> self. udfSetRemotePath ( ) <TAB> <TAB> checkFile ( self. udfLocalFile ) <TAB> <TAB> written = self. writeFile ( <TAB> <TAB> <TAB> self. udfLocalFile, self. udfRemoteFile, ""binary"", forceCheck = True <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> errMsg = ""there has been a problem uploading the shared library, "" <TAB> <TAB> <TAB> errMsg += ""it looks like the binary file has not been written "" <TAB> <TAB> <TAB> errMsg += ""on the database underlying file system"" <TAB> <TAB> <TAB> logger. error ( errMsg ) <TAB> <TAB> <TAB> message = ""do you want to proceed anyway? Beware that the "" <TAB> <TAB> <TAB> message += ""operating system takeover will fail [y/N] "" <TAB> <TAB> <TAB> if readInput ( message, default = ""N"", boolean = True ) : <TAB> <TAB> <TAB> <TAB> written = True <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> return False <TAB> else : <TAB> <TAB> return True <TAB> for udf, inpRet in udfDict. items ( ) : <TAB> <TAB> if udf in self. udfToCreate and udf not in self. createdUdf : <TAB> <TAB> <TAB> self. udfCreateFromSharedLib ( udf, inpRet ) <TAB> if Backend. isDbms ( DBMS. MYSQL ) : <TAB> <TAB> supportTblType = ""longtext"" <TAB> elif Backend. isDbms ( DBMS. PGSQL ) : <TAB> <TAB> supportTblType = ""text"" <TAB> self. udfCreateSupport",False,written is not True,written,0.6706836223602295
|
||
|
4943,"def TryMerge ( self, d ) : <TAB> while 1 : <TAB> <TAB> tt = d. getVarInt32 ( ) <TAB> <TAB> if tt == 132 : <TAB> <TAB> <TAB> break <TAB> <TAB> if tt == 136 : <TAB> <TAB> <TAB> self. set_dispatched_usec ( d. getVarInt64 ( ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if tt == 144 : <TAB> <TAB> <TAB> self. set_lag_usec ( d. getVarInt64 ( ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if tt == 152 : <TAB> <TAB> <TAB> self. set_elapsed_usec ( d. getVarInt64 ( ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if tt == 160 : <TAB> <TAB> <TAB> self. set_response_code ( d. getVarInt64 ( ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if tt == 218 : <TAB> <TAB> <TAB> self. set_retry_reason ( d. getPrefixedString ( ) ) <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> raise ProtocolBuffer. ProtocolBufferDecodeError <TAB> <TAB> d. skipData ( tt )",False,tt == 0,tt == 119,0.6815414428710938
|
||
|
4944,"def pytest_generate_tests ( metafunc ) : <TAB> bsz_rng = [ 1 ] <TAB> if ""refgruargs"" in metafunc. fixturenames : <TAB> <TAB> fargs = [ ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> seq_rng = [ 2, 3, 4 ] <TAB> <TAB> <TAB> inp_rng = [ 3, 5, 10 ] <TAB> <TAB> <TAB> out_rng = [ 3, 5, 10 ] <TAB> <TAB> else : <TAB> <TAB> <TAB> seq_rng = [ 3 ] <TAB> <TAB> <TAB> inp_rng = [ 5 ] <TAB> <TAB> <TAB> out_rng = [ 10 ] <TAB> <TAB> fargs = itt. product ( seq_rng, inp_rng, out_rng, bsz_rng ) <TAB> <TAB> metafunc. parametrize ( ""refgruargs"", fargs ) <TAB> if ""gradgruargs"" in metafunc. fixturenames : <TAB> <TAB> fargs = [ ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> seq_rng = [ 2, 3 ] <TAB> <TAB> <TAB> inp_rng = [ 5, 10 ] <TAB> <TAB> <TAB> out_rng = [ 3, 5, 10 ] <TAB> <TAB> else : <TAB> <TAB> <TAB> seq_rng = [ 3 ] <TAB> <TAB> <TAB> inp_rng = [ 5 ] <TAB> <TAB> <TAB> out_rng = [ 10 ] <TAB> <TAB> fargs = itt. product ( seq_rng, inp_rng, out_rng, bsz_rng ) <TAB> <TAB> metafunc. parametrize ( ""gradgruargs"", fargs )",False,metafunc.config.option.all,'avgpool' in fargs,0.6495445966720581
|
||
|
4945,"def _queue_redraw_curve ( self ) : <TAB> """"""Redraws the entire curve on all known view TDWs"""""" <TAB> self. _stop_task_queue_runner ( complete = False ) <TAB> for tdw in self. _overlays : <TAB> <TAB> model = tdw. doc <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> continue <TAB> <TAB> self. _queue_task ( self. brushwork_rollback, model ) <TAB> <TAB> self. _queue_task ( <TAB> <TAB> <TAB> self. brushwork_begin, <TAB> <TAB> <TAB> model, <TAB> <TAB> <TAB> description = _ ( ""Inking"" ), <TAB> <TAB> <TAB> abrupt = True, <TAB> <TAB> ) <TAB> <TAB> interp_state = { ""t_abs"" : self. nodes [ 0 ]. time } <TAB> <TAB> for p_1, p0, p1, p2 in gui. drawutils. spline_iter ( self. nodes ) : <TAB> <TAB> <TAB> self. _queue_task ( <TAB> <TAB> <TAB> <TAB> self. _draw_curve_segment, model, p_1, p0, p1, p2, state = interp_state <TAB> <TAB> <TAB> ) <TAB> self. _start_task_queue_runner ( )",False,len(self.nodes) < 2,complete,0.6535524129867554
|
||
|
4946,"def get_maps ( test ) : <TAB> pages = set ( ) <TAB> for addr in test [ ""pre"" ] [ ""memory"" ]. keys ( ) : <TAB> <TAB> pages. add ( addr >> 12 ) <TAB> for addr in test [ ""pos"" ] [ ""memory"" ]. keys ( ) : <TAB> <TAB> pages. add ( addr >> 12 ) <TAB> maps = [ ] <TAB> for p in sorted ( pages ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> maps [ - 1 ] = ( maps [ - 1 ] [ 0 ], maps [ - 1 ] [ 1 ] + 0x1000 ) <TAB> <TAB> else : <TAB> <TAB> <TAB> maps. append ( ( p << 12, 0x1000 ) ) <TAB> return maps",False,len(maps) > 0 and maps[-1][0] + maps[-1][1] == p << 12,p & 128,0.6528527736663818
|
||
|
4947,"def _create_group_snapshot_generic ( self, context, group_snapshot, snapshots ) : <TAB> """"""Creates a group_snapshot."""""" <TAB> model_update = { ""status"" : ""available"" } <TAB> snapshot_model_updates = [ ] <TAB> for snapshot in snapshots : <TAB> <TAB> snapshot_model_update = { ""id"" : snapshot. id } <TAB> <TAB> try : <TAB> <TAB> <TAB> driver_update = self. driver. create_snapshot ( snapshot ) <TAB> <TAB> <TAB> if driver_update : <TAB> <TAB> <TAB> <TAB> driver_update. pop ( ""id"", None ) <TAB> <TAB> <TAB> <TAB> snapshot_model_update. update ( driver_update ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> snapshot_model_update [ ""status"" ] = fields. SnapshotStatus. AVAILABLE <TAB> <TAB> except Exception : <TAB> <TAB> <TAB> snapshot_model_update [ ""status"" ] = fields. SnapshotStatus. ERROR <TAB> <TAB> <TAB> model_update [ ""status"" ] = ""error"" <TAB> <TAB> snapshot_model_updates. append ( snapshot_model_update ) <TAB> return model_update, snapshot_model_updates",False,'status' not in snapshot_model_update,snapshot_model_update['status'] == fields.SnapshotStatus.AVAILABLE,0.6547070741653442
|
||
|
4948,"def _apply_value ( self, model, iter_, cell, stamp ) : <TAB> if not stamp : <TAB> <TAB> cell. set_property ( ""text"", _ ( ""Never"" ) ) <TAB> else : <TAB> <TAB> try : <TAB> <TAB> <TAB> date = datetime. datetime. fromtimestamp ( stamp ). date ( ) <TAB> <TAB> except ( OverflowError, ValueError, OSError ) : <TAB> <TAB> <TAB> text = u"""" <TAB> <TAB> else : <TAB> <TAB> <TAB> format_setting = config. gettext ( ""settings"", ""datecolumn_timestamp_format"" ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if format_setting : <TAB> <TAB> <TAB> <TAB> format_ = format_setting <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> today = datetime. datetime. now ( ). date ( ) <TAB> <TAB> <TAB> <TAB> days = ( today - date ). days <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> format_ = ""%X"" <TAB> <TAB> <TAB> <TAB> elif days < 7 : <TAB> <TAB> <TAB> <TAB> <TAB> format_ = ""%A"" <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> format_ = ""%x"" <TAB> <TAB> <TAB> stamp = time. localtime ( stamp ) <TAB> <TAB> <TAB> text = time. strftime ( format_, stamp ) <TAB> <TAB> cell. set_property ( ""text"", text )",False,days == 0,days > 6,0.672976016998291
|
||
|
4949,"def _prepare ( ) : <TAB> try : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> client = local_client ( ) <TAB> <TAB> <TAB> client. pull ( prerequisites. image, tag = prerequisites. tag ) <TAB> <TAB> else : <TAB> <TAB> <TAB> logger. info ( ""task-api-dev mode enabled, use local images"" ) <TAB> except Exception as e : <TAB> <TAB> self. _error_occurred ( e, ""Preparing prerequisites failed."", set_status = False ) <TAB> <TAB> raise <TAB> self. _prerequisites_installed ( prerequisites ) <TAB> return True",False,not self._dev_mode,is_local_prerequisites(prerequisites.image),0.6606485843658447
|
||
|
4950,"def compare_model_state ( test_fixture, state, state2, check_heads = True ) : <TAB> for k in state [ ""model"" ] [ ""trunk"" ]. keys ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> print ( k, state [ ""model"" ] [ ""trunk"" ] [ k ], state2 [ ""model"" ] [ ""trunk"" ] [ k ] ) <TAB> <TAB> test_fixture. assertTrue ( <TAB> <TAB> <TAB> torch. allclose ( state [ ""model"" ] [ ""trunk"" ] [ k ], state2 [ ""model"" ] [ ""trunk"" ] [ k ] ) <TAB> <TAB> ) <TAB> if check_heads : <TAB> <TAB> for block, head_states in state [ ""model"" ] [ ""heads"" ]. items ( ) : <TAB> <TAB> <TAB> for head_id, states in head_states. items ( ) : <TAB> <TAB> <TAB> <TAB> for k in states. keys ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> test_fixture. assertTrue ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> torch. allclose ( <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> state [ ""model"" ] [ ""heads"" ] [ block ] [ head_id ] [ k ], <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> state2 [ ""model"" ] [ ""heads"" ] [ block ] [ head_id ] [ k ], <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> <TAB> )",False,"not torch.allclose(state['model']['trunk'][k], state2['model']['trunk'][k])",k in state2['model'],0.6602776050567627
|
||
|
4951,"def _get_codon_list ( codonseq ) : <TAB> """"""List of codons according to full_rf_table for counting (PRIVATE)."""""" <TAB> <TAB> <TAB> <TAB> full_rf_table = codonseq. get_full_rf_table ( ) <TAB> codon_lst = [ ] <TAB> for i, k in enumerate ( full_rf_table ) : <TAB> <TAB> if isinstance ( k, int ) : <TAB> <TAB> <TAB> start = k <TAB> <TAB> <TAB> try : <TAB> <TAB> <TAB> <TAB> end = int ( full_rf_table [ i + 1 ] ) <TAB> <TAB> <TAB> except IndexError : <TAB> <TAB> <TAB> <TAB> end = start + 3 <TAB> <TAB> <TAB> this_codon = str ( codonseq [ start : end ] ) <TAB> <TAB> <TAB> if len ( this_codon ) == 3 : <TAB> <TAB> <TAB> <TAB> codon_lst. append ( this_codon ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> codon_lst. append ( str ( this_codon. ungap ( ) ) ) <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> codon_lst. append ( ""---"" ) <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> codon_lst. append ( codonseq [ int ( k ) : int ( k ) + 3 ] ) <TAB> return codon_lst",False,str(codonseq[int(k):int(k) + 3]) == '---',len(arg_seq) == 2,0.6571063995361328
|
||
|
4952,"def iterations ( ) : <TAB> check_garbage ( ) <TAB> max_mem = 0 <TAB> max_mem_stable = 0 <TAB> max_mem_increasing = 0 <TAB> leak = True <TAB> m1 = 0 <TAB> for i in range ( options. max_iterations ) : <TAB> <TAB> yield i <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> if i == 3 : <TAB> <TAB> <TAB> <TAB> check_garbage ( ) <TAB> <TAB> <TAB> <TAB> helpers. record_memory_leak_status ( ) <TAB> <TAB> <TAB> if i == 4 or i == 5 : <TAB> <TAB> <TAB> <TAB> helpers. record_memory_leak_status ( print_diff = True ) <TAB> <TAB> m2 = mem ( ) <TAB> <TAB> print ( <TAB> <TAB> <TAB> ""iteration %02d/%02d: %d pages used (%+d)"" <TAB> <TAB> <TAB> % ( i + 1, options. max_iterations, m2, m2 - m1 ) <TAB> <TAB> ) <TAB> <TAB> m1 = m2 <TAB> <TAB> if m2 > max_mem : <TAB> <TAB> <TAB> max_mem = m2 <TAB> <TAB> <TAB> max_mem_stable = 0 <TAB> <TAB> <TAB> max_mem_increasing += 1 <TAB> <TAB> <TAB> if max_mem_increasing == options. required : <TAB> <TAB> <TAB> <TAB> print ( <TAB> <TAB> <TAB> <TAB> <TAB> ""maximum was always increasing for"", <TAB> <TAB> <TAB> <TAB> <TAB> max_mem_increasing, <TAB> <TAB> <TAB> <TAB> <TAB> ""iterations"", <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> else : <TAB> <TAB> <TAB> max_mem_stable += 1 <TAB> <TAB> <TAB> max",False,options.debug,i == 0,0.6570525169372559
|
||
|
4953,"def tokenize ( self, text ) : <TAB> """"""Tokenize the input string `text`, and return the tokenize result."""""" <TAB> text_len = len ( text ) <TAB> result = [ ] <TAB> i = 0 <TAB> while i < text_len : <TAB> <TAB> word = found_word = """" <TAB> <TAB> <TAB> <TAB> if self. __is_eng_char ( text [ i ] ) : <TAB> <TAB> <TAB> for j in range ( i, text_len + 1 ) : <TAB> <TAB> <TAB> <TAB> if j < text_len and self. __is_eng_char ( text [ j ] ) : <TAB> <TAB> <TAB> <TAB> <TAB> word += self. __tolower ( text [ j ] ) <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> result. append ( word ) <TAB> <TAB> <TAB> <TAB> <TAB> i = j - 1 <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> else : <TAB> <TAB> <TAB> for j in range ( i, min ( i + self. __max_word_len, text_len ) ) : <TAB> <TAB> <TAB> <TAB> word += text [ j ] <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> found_word = word <TAB> <TAB> <TAB> if len ( found_word ) > 0 : <TAB> <TAB> <TAB> <TAB> result. append ( found_word ) <TAB> <TAB> <TAB> <TAB> i += len ( found_word ) - 1 <TAB> <TAB> i += 1 <TAB> return result",False,word in self.__vocab,len(word) > 0,0.6705615520477295
|
||
|
4954,"def get_domains_up_by_filers ( <TAB> domain_type, date_from = None, date_to = None, tags = [ ], nb_obj = 28, page = 1 ) : <TAB> if not tags : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return domains_up_by_page ( domain_type, nb_obj = nb_obj, page = page ) <TAB> <TAB> else : <TAB> <TAB> <TAB> domains = sorted ( <TAB> <TAB> <TAB> <TAB> get_domains_up_by_daterange ( date_from, date_to, domain_type ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> domains = paginate_iterator ( domains, nb_obj = nb_obj, page = page ) <TAB> <TAB> <TAB> domains [ ""list_elem"" ] = create_domains_metadata_list ( <TAB> <TAB> <TAB> <TAB> domains [ ""list_elem"" ], domain_type <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> domains [ ""domain_type"" ] = domain_type <TAB> <TAB> <TAB> domains [ ""date_from"" ] = date_from <TAB> <TAB> <TAB> domains [ ""date_to"" ] = date_to <TAB> <TAB> <TAB> return domains <TAB> else : <TAB> <TAB> return None",False,not date_from and (not date_to),nb_obj > 0,0.6491000652313232
|
||
|
4955,"def GetNumberOfLines ( self ) : <TAB> text = self. GetValue ( ) <TAB> width = self. GetClientSize ( ). width <TAB> dc = wx. ClientDC ( self ) <TAB> dc. SetFont ( self. GetFont ( ) ) <TAB> count = 0 <TAB> for line in text. split ( ""\n"" ) : <TAB> <TAB> count += 1 <TAB> <TAB> w, h = dc. GetTextExtent ( line ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> count += self. _wrapLine ( line, dc, width ) <TAB> if not count : <TAB> <TAB> count = 1 <TAB> return count",False,w > width - self._getExtra(),w == -1 or h == -1,0.6556733846664429
|
||
|
4956,"def __call__ ( <TAB> self, model, output_path : str = None, epoch : int = - 1, steps : int = - 1 ) -> float : <TAB> model. eval ( ) <TAB> total = 0 <TAB> correct = 0 <TAB> if epoch!= - 1 : <TAB> <TAB> if steps == - 1 : <TAB> <TAB> <TAB> out_txt = "" after epoch {}:"". format ( epoch ) <TAB> <TAB> else : <TAB> <TAB> <TAB> out_txt = "" in epoch {} after {} steps:"". format ( epoch, steps ) <TAB> else : <TAB> <TAB> out_txt = "":"" <TAB> logger. info ( ""Evaluation on the "" + self. name + "" dataset"" + out_txt ) <TAB> self. dataloader. collate_fn = model. smart_batching_collate <TAB> for step, batch in enumerate ( tqdm ( self. dataloader, desc = ""Evaluating"" ) ) : <TAB> <TAB> features, label_ids = batch_to_device ( batch, model. device ) <TAB> <TAB> with torch. no_grad ( ) : <TAB> <TAB> <TAB> _, prediction = self. softmax_model ( features, labels = None ) <TAB> <TAB> total += prediction. size ( 0 ) <TAB> <TAB> correct += torch. argmax ( prediction, dim = 1 ). eq ( label_ids ). sum ( ). item ( ) <TAB> accuracy = correct / total <TAB> logger. info ( ""Accuracy: {:.4f} ({}/{})\n"". format ( accuracy, correct, total ) ) <TAB> if output_path is not None : <TAB> <TAB> csv_path = os. path. join ( output_path, self. csv_file ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> with open ( csv_path, mode = ""w"", encoding = ""utf-8"" ) as f : <TAB> <TAB> <TAB> <TAB> writer = csv. writer ( f ) <TAB> <TAB> <TAB> <TAB> writer. writerow ( self. csv_headers ) <TAB> <TAB> <TAB> <TAB>",False,not os.path.isfile(csv_path),os.path.exists(csv_path),0.6454676389694214
|
||
|
4957,"def build_canned_image_list ( path ) : <TAB> layers_path = get_bitbake_var ( ""BBLAYERS"" ) <TAB> canned_wks_layer_dirs = [ ] <TAB> if layers_path is not None : <TAB> <TAB> for layer_path in layers_path. split ( ) : <TAB> <TAB> <TAB> for wks_path in ( WIC_DIR, SCRIPTS_CANNED_IMAGE_DIR ) : <TAB> <TAB> <TAB> <TAB> cpath = os. path. join ( layer_path, wks_path ) <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> canned_wks_layer_dirs. append ( cpath ) <TAB> cpath = os. path. join ( path, CANNED_IMAGE_DIR ) <TAB> canned_wks_layer_dirs. append ( cpath ) <TAB> return canned_wks_layer_dirs",True,os.path.isdir(cpath),os.path.isdir(cpath),0.6465350985527039
|
||
|
4958,"def update_dict ( a, b ) : <TAB> for key, value in b. items ( ) : <TAB> <TAB> if value is None : <TAB> <TAB> <TAB> continue <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> a [ key ] = value <TAB> <TAB> elif isinstance ( a [ key ], dict ) and isinstance ( value, dict ) : <TAB> <TAB> <TAB> update_dict ( a [ key ], value ) <TAB> <TAB> elif isinstance ( a [ key ], list ) : <TAB> <TAB> <TAB> a [ key ]. append ( value ) <TAB> <TAB> else : <TAB> <TAB> <TAB> a [ key ] = [ a [ key ], value ]",True,key not in a,key not in a,0.668784499168396
|
||
|
4959,"def getSubsegments ( self ) : <TAB> for num, localdata in self. lfh. LocalData : <TAB> <TAB> for bucket, seginfo in localdata. SegmentInfo : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> continue <TAB> <TAB> <TAB> yield Win32Subsegment ( self. trace, self. heap, seginfo. ActiveSubsegment )",False,seginfo.ActiveSubsegment == 0,seginfo.ActiveSubsegment is None,0.6543750762939453
|
||
|
4960,"def map_external_uid_with_hangups_user ( self, source_uid, external_context ) : <TAB> telegram_uid = str ( source_uid ) <TAB> profilesync_keys = [ ""profilesync"", ""tg2ho"", telegram_uid ] <TAB> hangups_user = False <TAB> try : <TAB> <TAB> hangouts_map = self. bot. memory. get_by_path ( profilesync_keys ) <TAB> <TAB> if isinstance ( hangouts_map, str ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> return False <TAB> <TAB> if ""chat_id"" in hangouts_map : <TAB> <TAB> <TAB> hangouts_uid = hangouts_map [ ""chat_id"" ] <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> gplus = hangouts_map [ ""user_gplus"" ] <TAB> <TAB> <TAB> has_chat_id = re. search ( r""/(\d+)/about"", gplus ) <TAB> <TAB> <TAB> if has_chat_id : <TAB> <TAB> <TAB> <TAB> hangouts_uid = has_chat_id. group ( 1 ) <TAB> <TAB> else : <TAB> <TAB> <TAB> hangouts_uid = False <TAB> <TAB> if hangouts_uid : <TAB> <TAB> <TAB> _hangups_user = self. bot. get_hangups_user ( hangouts_uid ) <TAB> <TAB> <TAB> if _hangups_user. definitionsource : <TAB> <TAB> <TAB> <TAB> hangups_user = _hangups_user <TAB> except KeyError : <TAB> <TAB> logger. info ( ""no hangups user for {}"". format ( source_uid ) ) <TAB> return hangups_user",True,'user_gplus' in hangouts_map,'user_gplus' in hangouts_map,0.6548639535903931
|
||
|
4961,"def __saveWork ( self, work, results ) : <TAB> """"""Stores the resulting last log line to the cache with the proxy key"""""" <TAB> del work <TAB> <TAB> try : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> __cached = self. __cache [ results [ 0 ] ] <TAB> <TAB> <TAB> __cached [ self. __TIME ] = time. time ( ) <TAB> <TAB> <TAB> __cached [ self. __LINE ] = results [ 1 ] <TAB> <TAB> <TAB> __cached [ self. __LLU ] = results [ 2 ] <TAB> except KeyError as e : <TAB> <TAB> <TAB> <TAB> pass <TAB> except Exception as e : <TAB> <TAB> list ( map ( logger. warning, cuegui. Utils. exceptionOutput ( e ) ) )",False,results,len(results) >= 2,0.6823166012763977
|
||
|
4962,"def _get_items ( self, name, target = 1 ) : <TAB> all_items = self. get_items ( name ) <TAB> items = [ o for o in all_items if not o. disabled ] <TAB> if len ( items ) < target : <TAB> <TAB> if len ( all_items ) < target : <TAB> <TAB> <TAB> raise ItemNotFoundError ( ""insufficient items with name %r"" % name ) <TAB> <TAB> else : <TAB> <TAB> <TAB> raise AttributeError ( ""insufficient non-disabled items with name %s"" % name ) <TAB> on = [ ] <TAB> off = [ ] <TAB> for o in items : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> on. append ( o ) <TAB> <TAB> else : <TAB> <TAB> <TAB> off. append ( o ) <TAB> return on, off",False,o.selected,o.disabled,0.6702395677566528
|
||
|
4963,"def start ( url, command, username, password, shell = False ) : <TAB> if need_auth ( url ) : <TAB> <TAB> print ( ""[+] Node-RED requires authentication."" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> print ( ""[+] Trying default credentials."" ) <TAB> <TAB> <TAB> access_token = login ( url ) <TAB> <TAB> else : <TAB> <TAB> <TAB> print ( ""[+] Trying provided credentials."" ) <TAB> <TAB> <TAB> access_token = login ( url, username = username, password = password ) <TAB> <TAB> if access_token is None : <TAB> <TAB> <TAB> print ( ""[!] An error occured during login procedure. Wrong creds?"" ) <TAB> <TAB> <TAB> return <TAB> <TAB> else : <TAB> <TAB> <TAB> print ( ""[+] Successfully authenticated over HTTP."" ) <TAB> <TAB> <TAB> return asyncio. get_event_loop ( ). run_until_complete ( <TAB> <TAB> <TAB> <TAB> exploit ( url, command, shell, access_token ) <TAB> <TAB> <TAB> ) <TAB> else : <TAB> <TAB> print ( ""[+] Node-RED does not require authentication."" ) <TAB> <TAB> return asyncio. get_event_loop ( ). run_until_complete ( exploit ( url, command, shell ) )",False,username is None and password is None,username is None or password is None,0.6552834510803223
|
||
|
4964,"def run_with_catch ( args = None, env = None ) : <TAB> from virtualenv. config. cli. parser import VirtualEnvOptions <TAB> env = os. environ if env is None else env <TAB> options = VirtualEnvOptions ( ) <TAB> try : <TAB> <TAB> run ( args, options, env ) <TAB> except ( KeyboardInterrupt, SystemExit, Exception ) as exception : <TAB> <TAB> try : <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> raise <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> if not ( isinstance ( exception, SystemExit ) and exception. code == 0 ) : <TAB> <TAB> <TAB> <TAB> <TAB> logging. error ( ""%s: %s"", type ( exception ). __name__, exception ) <TAB> <TAB> <TAB> <TAB> code = exception. code if isinstance ( exception, SystemExit ) else 1 <TAB> <TAB> <TAB> <TAB> sys. exit ( code ) <TAB> <TAB> finally : <TAB> <TAB> <TAB> logging. shutdown ( )",False,"getattr(options, 'with_traceback', False)",exception is None,0.647743284702301
|
||
|
4965,"def downsample_seg_for_ds_transform3 ( <TAB> seg, ds_scales = ( ( 1, 1, 1 ), ( 0.5, 0.5, 0.5 ), ( 0.25, 0.25, 0.25 ) ), classes = None ) : <TAB> output = [ ] <TAB> one_hot = torch. from_numpy ( <TAB> <TAB> convert_seg_image_to_one_hot_encoding_batched ( seg, classes ) <TAB> ) <TAB> for s in ds_scales : <TAB> <TAB> if all ( [ i == 1 for i in s ] ) : <TAB> <TAB> <TAB> output. append ( torch. from_numpy ( seg ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> kernel_size = tuple ( int ( 1 / i ) for i in s ) <TAB> <TAB> <TAB> stride = kernel_size <TAB> <TAB> <TAB> pad = tuple ( ( i - 1 ) // 2 for i in kernel_size ) <TAB> <TAB> <TAB> if len ( s ) == 2 : <TAB> <TAB> <TAB> <TAB> pool_op = avg_pool2d <TAB> <TAB> <TAB> elif<mask> : <TAB> <TAB> <TAB> <TAB> pool_op = avg_pool3d <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> raise RuntimeError ( ) <TAB> <TAB> <TAB> pooled = pool_op ( <TAB> <TAB> <TAB> <TAB> one_hot, <TAB> <TAB> <TAB> <TAB> kernel_size, <TAB> <TAB> <TAB> <TAB> stride, <TAB> <TAB> <TAB> <TAB> pad, <TAB> <TAB> <TAB> <TAB> count_include_pad = False, <TAB> <TAB> <TAB> <TAB> ceil_mode = False, <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> output. append ( pooled ) <TAB> return output",True,len(s) == 3,len(s) == 3,0.6577027440071106
|
||
|
4966,"def get_args ( limit = 20 ) : <TAB> args = [ ] <TAB> any_tags_combinations = [ <TAB> <TAB> DEFAULT_ANY_TAGS, <TAB> <TAB> COMMON_AND_RARE, <TAB> <TAB> RARE_ANY_TAGS, <TAB> <TAB> COMMON_AND_RARE2, <TAB> <TAB> CITY_FIX, <TAB> <TAB> [ ], <TAB> ] <TAB> not_tags_combinations = [ MATURE_TAGS, [ ] ] <TAB> for no_fee in [ False, True ] : <TAB> <TAB> for claim_type in [ None, ""stream"", ""channel"" ] : <TAB> <TAB> <TAB> for no_totals in [ True ] : <TAB> <TAB> <TAB> <TAB> for offset in [ 0, 100 ] : <TAB> <TAB> <TAB> <TAB> <TAB> for any_tags in any_tags_combinations : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for not_tags in not_tags_combinations : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> for order_by in ORDER_BY : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> kw = { <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""order_by"" : order_by, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""offset"" : offset, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""limit"" : limit, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> ""no_totals"" : no_totals, <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> } <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB",False,any_tags,len(args) == 0,0.6757588386535645
|
||
|
4967,"def create ( cls, request = None, ** kwargs ) : <TAB> create_email = kwargs. pop ( ""create_email"", True ) <TAB> confirm_email = kwargs. pop ( ""confirm_email"", None ) <TAB> account = cls ( ** kwargs ) <TAB> if ""language"" not in kwargs : <TAB> <TAB> if request is None : <TAB> <TAB> <TAB> account. language = DEFAULT_LANGUAGE <TAB> <TAB> else : <TAB> <TAB> <TAB> account. language = translation. get_language_from_request ( <TAB> <TAB> <TAB> <TAB> request, check_path = True <TAB> <TAB> <TAB> ) <TAB> account. save ( ) <TAB> if create_email and account. user. email : <TAB> <TAB> kwargs = { ""primary"" : True } <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> kwargs [ ""confirm"" ] = confirm_email <TAB> <TAB> EmailAddress. objects. add_email ( account. user, account. user. email, ** kwargs ) <TAB> return account",False,confirm_email is not None,confirm_email,0.6583845615386963
|
||
|
4968,"def smartsplit ( code ) : <TAB> """"""Split `code` at "" symbol, only if it is not escaped."""""" <TAB> strings = [ ] <TAB> pos = 0 <TAB> while pos < len ( code ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> word = """" <TAB> <TAB> <TAB> pos += 1 <TAB> <TAB> <TAB> while pos < len ( code ) : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> if code [ pos ] == ""\\"" : <TAB> <TAB> <TAB> <TAB> <TAB> word += ""\\"" <TAB> <TAB> <TAB> <TAB> <TAB> pos += 1 <TAB> <TAB> <TAB> <TAB> word += code [ pos ] <TAB> <TAB> <TAB> <TAB> pos += 1 <TAB> <TAB> <TAB> strings. append ( '""%s""' % word ) <TAB> <TAB> pos += 1 <TAB> return strings",False,"code[pos] == '""'",code[pos] == '\\',0.661501407623291
|
||
|
4969,"def __init__ ( self, response, message ) : <TAB> self. response = response <TAB> self. status = response. status <TAB> if isinstance ( message, dict ) : <TAB> <TAB> self. code = message. get ( ""code"", 0 ) <TAB> <TAB> base = message. get ( ""message"", """" ) <TAB> <TAB> errors = message. get ( ""errors"" ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> errors = flatten_error_dict ( errors ) <TAB> <TAB> <TAB> helpful = ""\n"". join ( ""In %s: %s"" % t for t in errors. items ( ) ) <TAB> <TAB> <TAB> self. text = base + ""\n"" + helpful <TAB> <TAB> else : <TAB> <TAB> <TAB> self. text = base <TAB> else : <TAB> <TAB> self. text = message <TAB> <TAB> self. code = 0 <TAB> fmt = ""{0.status} {0.reason} (error code: {1})"" <TAB> if len ( self. text ) : <TAB> <TAB> fmt = fmt + "": {2}"" <TAB> super ( ). __init__ ( fmt. format ( self. response, self. code, self. text ) )",True,errors,errors,0.6926330327987671
|
||
|
4970,"def reverse_code ( apps : StateApps, schema_editor : DatabaseSchemaEditor ) -> None : <TAB> PreregistrationUser = apps. get_model ( ""zerver"", ""PreregistrationUser"" ) <TAB> for user in PreregistrationUser. objects. all ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> user. invited_as_admin = True <TAB> <TAB> else : <TAB> <TAB> <TAB> user. invited_as_admin = False <TAB> <TAB> user. save ( update_fields = [ ""invited_as_admin"" ] )",False,user.invited_as == 2,not user.invited,0.6565252542495728
|
||
|
4971,"def userless_histories ( self, trans, ** kwd ) : <TAB> """"""The number of userless histories and associated datasets that have not been updated for the specified number of days."""""" <TAB> params = util. Params ( kwd ) <TAB> message = """" <TAB> if params. userless_histories_days : <TAB> <TAB> userless_histories_days = int ( params. userless_histories_days ) <TAB> <TAB> cutoff_time = datetime. utcnow ( ) - timedelta ( days = userless_histories_days ) <TAB> <TAB> history_count = 0 <TAB> <TAB> dataset_count = 0 <TAB> <TAB> for history in trans. sa_session. query ( model. History ). filter ( <TAB> <TAB> <TAB> and_ ( <TAB> <TAB> <TAB> <TAB> model. History. table. c. user_id == null ( ), <TAB> <TAB> <TAB> <TAB> model. History. table. c. deleted == true ( ), <TAB> <TAB> <TAB> <TAB> model. History. table. c. update_time < cutoff_time, <TAB> <TAB> <TAB> ) <TAB> <TAB> ) : <TAB> <TAB> <TAB> for dataset in history. datasets : <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> dataset_count += 1 <TAB> <TAB> <TAB> history_count += 1 <TAB> <TAB> message = ( <TAB> <TAB> <TAB> ""%d userless histories ( including a total of %d datasets ) have not been updated for at least %d days."" <TAB> <TAB> <TAB> % ( history_count, dataset_count, userless_histories_days ) <TAB> <TAB> ) <TAB> else : <TAB> <TAB> message = ""Enter the number of days."" <TAB> return str ( userless_histories_days ), message",False,not dataset.deleted,"hasattr(dataset, 'update_time')",0.6615043878555298
|
||
|
4972,"def on_task_abort ( self, task, config ) : <TAB> if ""abort"" in config : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return <TAB> <TAB> log. debug ( ""sending abort notification"" ) <TAB> <TAB> self. send_notification ( <TAB> <TAB> <TAB> config [ ""abort"" ] [ ""title"" ], <TAB> <TAB> <TAB> config [ ""abort"" ] [ ""message"" ], <TAB> <TAB> <TAB> config [ ""abort"" ] [ ""via"" ], <TAB> <TAB> <TAB> template_renderer = task. render, <TAB> <TAB> )",False,task.silent_abort,task.cancel_on_task_abort,0.664771556854248
|
||
|
4973,"def outlineView_heightOfRowByItem_ ( self, tree, item ) -> float : <TAB> default_row_height = self. rowHeight <TAB> if item is self : <TAB> <TAB> return default_row_height <TAB> heights = [ default_row_height ] <TAB> for column in self. tableColumns : <TAB> <TAB> value = getattr ( item. attrs [ ""node"" ], str ( column. identifier ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> heights. append ( value. _impl. native. intrinsicContentSize ( ). height ) <TAB> return max ( heights )",False,"isinstance(value, toga.Widget)",value is not None,0.6557950377464294
|
||
|
4974,def close ( self ) : <TAB> if self. _sock : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _loop. remove_periodic ( self. handle_periodic ) <TAB> <TAB> <TAB> self. _loop. remove ( self. _sock ) <TAB> <TAB> self. _sock. close ( ) <TAB> <TAB> self. _sock = None,False,self._loop,self.handle_periodic,0.6718765497207642
|
||
|
4975,"def update_handler ( self, fd : Union [ int, _Selectable ], events : int ) -> None : <TAB> fd, fileobj = self. split_fd ( fd ) <TAB> if events & IOLoop. READ : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. selector_loop. add_reader ( fd, self. _handle_events, fd, IOLoop. READ ) <TAB> <TAB> <TAB> self. readers. add ( fd ) <TAB> else : <TAB> <TAB> if fd in self. readers : <TAB> <TAB> <TAB> self. selector_loop. remove_reader ( fd ) <TAB> <TAB> <TAB> self. readers. remove ( fd ) <TAB> if events & IOLoop. WRITE : <TAB> <TAB> if fd not in self. writers : <TAB> <TAB> <TAB> self. selector_loop. add_writer ( fd, self. _handle_events, fd, IOLoop. WRITE ) <TAB> <TAB> <TAB> self. writers. add ( fd ) <TAB> else : <TAB> <TAB> if fd in self. writers : <TAB> <TAB> <TAB> self. selector_loop. remove_writer ( fd ) <TAB> <TAB> <TAB> self. writers. remove ( fd )",True,fd not in self.readers,fd not in self.readers,0.6583425998687744
|
||
|
4976,"def __init__ ( <TAB> self, data, depvar, subject, within = None, between = None, aggregate_func = None ) : <TAB> self. data = data <TAB> self. depvar = depvar <TAB> self. within = within <TAB> if ""C"" in within : <TAB> <TAB> raise ValueError ( <TAB> <TAB> <TAB> ""Factor name cannot be 'C'! This is in conflict "" <TAB> <TAB> <TAB> ""with patsy's contrast function name."" <TAB> <TAB> ) <TAB> self. between = between <TAB> if between is not None : <TAB> <TAB> raise NotImplementedError ( ""Between subject effect not "" ""yet supported!"" ) <TAB> self. subject = subject <TAB> if aggregate_func == ""mean"" : <TAB> <TAB> self. aggregate_func = np. mean <TAB> else : <TAB> <TAB> self. aggregate_func = aggregate_func <TAB> if not data. equals ( data. drop_duplicates ( subset = [ subject ] + within ) ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _aggregate ( ) <TAB> <TAB> else : <TAB> <TAB> <TAB> msg = ( <TAB> <TAB> <TAB> <TAB> ""The data set contains more than one observation per "" <TAB> <TAB> <TAB> <TAB> ""subject and cell. Either aggregate the data manually, "" <TAB> <TAB> <TAB> <TAB> ""or pass the `aggregate_func` parameter."" <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> raise ValueError ( msg ) <TAB> self. _check_data_balanced ( )",False,self.aggregate_func is not None,aggregate_func is None,0.6618744730949402
|
||
|
4977,"def import_data ( self, fname ) : <TAB> """"""Import data in current namespace"""""" <TAB> if self. count ( ) : <TAB> <TAB> nsb = self. currentWidget ( ) <TAB> <TAB> nsb. refresh_table ( ) <TAB> <TAB> nsb. import_data ( fname ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. dockwidget. setVisible ( True ) <TAB> <TAB> <TAB> self. dockwidget. raise_ ( )",False,self.dockwidget and (not self.ismaximized),self.dockwidget.visible(),0.6572795510292053
|
||
|
4978,"def test_mlflow_is_not_installed_unless_specified ( ) : <TAB> if no_conda : <TAB> <TAB> pytest. skip ( ""This test requires conda."" ) <TAB> with TempDir ( chdr = True ) as tmp : <TAB> <TAB> fake_model_path = tmp. path ( ""fake_model"" ) <TAB> <TAB> fake_env_path = tmp. path ( ""fake_env.yaml"" ) <TAB> <TAB> _mlflow_conda_env ( path = fake_env_path, install_mlflow = False ) <TAB> <TAB> mlflow. pyfunc. save_model ( <TAB> <TAB> <TAB> fake_model_path, loader_module = __name__, conda_env = fake_env_path <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> p = subprocess. Popen ( <TAB> <TAB> <TAB> [ ""mlflow"", ""models"", ""predict"", ""-m"", fake_model_path ], <TAB> <TAB> <TAB> stderr = subprocess. PIPE, <TAB> <TAB> <TAB> cwd = tmp. path ( """" ), <TAB> <TAB> ) <TAB> <TAB> _, stderr = p. communicate ( ) <TAB> <TAB> stderr = stderr. decode ( ""utf-8"" ) <TAB> <TAB> print ( stderr ) <TAB> <TAB> assert p. wait ( )!= 0 <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> assert ""ModuleNotFoundError: No module named'mlflow'"" in stderr <TAB> <TAB> else : <TAB> <TAB> <TAB> assert ""ImportError: No module named mlflow.pyfunc.scoring_server"" in stderr",False,PYTHON_VERSION.startswith('3'),not install_mlflow,0.651702344417572
|
||
|
4979,"def revert ( self, context, result, flow_failures, volume, ** kwargs ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if not self. do_reschedule : <TAB> <TAB> common. error_out ( volume ) <TAB> <TAB> LOG. error ( ""Volume %s: create failed"", volume. id ) <TAB> <TAB> return False <TAB> <TAB> <TAB> for failure in flow_failures. values ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> common. error_out ( volume ) <TAB> <TAB> <TAB> LOG. error ( ""Volume %s: create failed"", volume. id ) <TAB> <TAB> <TAB> return False <TAB> <TAB> if self. reschedule_context : <TAB> <TAB> cause = list ( flow_failures. values ( ) ) [ 0 ] <TAB> <TAB> context = self. reschedule_context <TAB> <TAB> try : <TAB> <TAB> <TAB> self. _pre_reschedule ( volume ) <TAB> <TAB> <TAB> self. _reschedule ( context, cause, volume = volume, ** kwargs ) <TAB> <TAB> <TAB> self. _post_reschedule ( volume ) <TAB> <TAB> <TAB> return True <TAB> <TAB> except exception. CinderException : <TAB> <TAB> <TAB> LOG. exception ( ""Volume %s: rescheduling failed"", volume. id ) <TAB> return False",False,failure.check(*self.no_reschedule_types),failure,0.6498314142227173
|
||
|
4980,"def __init__ ( <TAB> self, <TAB> in_channels, <TAB> out_channels, <TAB> ksize, <TAB> stride = 1, <TAB> pad = 0, <TAB> dilate = 1, <TAB> nobias = False, <TAB> dw_initialW = None, <TAB> pw_initialW = None, <TAB> dw_initial_bias = None, <TAB> pw_initial_bias = None, <TAB> dw_activ = identity, <TAB> pw_activ = relu, <TAB> bn_kwargs = { }, ) : <TAB> self. dw_activ = identity if dw_activ is None else dw_activ <TAB> self. pw_activ = identity if pw_activ is None else pw_activ <TAB> super ( SeparableConv2DBNActiv, self ). __init__ ( ) <TAB> with self. init_scope ( ) : <TAB> <TAB> self. depthwise = Convolution2D ( <TAB> <TAB> <TAB> in_channels, <TAB> <TAB> <TAB> in_channels, <TAB> <TAB> <TAB> ksize = ksize, <TAB> <TAB> <TAB> stride = stride, <TAB> <TAB> <TAB> pad = pad, <TAB> <TAB> <TAB> dilate = dilate, <TAB> <TAB> <TAB> groups = in_channels, <TAB> <TAB> <TAB> nobias = nobias, <TAB> <TAB> <TAB> initialW = dw_initialW, <TAB> <TAB> ) <TAB> <TAB> self. pointwise = Convolution2D ( <TAB> <TAB> <TAB> in_channels, out_channels, 1, nobias = nobias, initialW = pw_initialW <TAB> <TAB> ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. dw_bn = MultiNodeBatchNormalization ( out_channels, ** bn_kwargs ) <TAB> <TAB> <TAB> self. pw_bn = MultiNodeBatchNormalization ( out_channels, ** bn_kwargs ) <TAB> <TAB> else : <TAB> <TAB> <TAB> self. dw_",False,'comm' in bn_kwargs,nobias,0.6524698734283447
|
||
|
4981,"def __init__ ( self, dir : str = None, validate_dir : bool = True, ** kwargs : Any ) -> None : <TAB> full_prefect_path = os. path. abspath ( config. home_dir ) <TAB> common_path = """" <TAB> try : <TAB> <TAB> if dir is not None : <TAB> <TAB> <TAB> common_path = os. path. commonpath ( [ full_prefect_path, os. path. abspath ( dir ) ] ) <TAB> except ValueError : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> pass <TAB> if dir is None or common_path == full_prefect_path : <TAB> <TAB> directory = os. path. join ( config. home_dir, ""results"" ) <TAB> else : <TAB> <TAB> directory = dir <TAB> if validate_dir : <TAB> <TAB> abs_directory = os. path. abspath ( os. path. expanduser ( directory ) ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> os. makedirs ( abs_directory ) <TAB> else : <TAB> <TAB> abs_directory = directory <TAB> self. dir = abs_directory <TAB> super ( ). __init__ ( ** kwargs )",False,not os.path.exists(abs_directory),not os.path.isdir(abs_directory),0.6466200351715088
|
||
|
4982,"def test_open_overwrite_offset_size ( self, sftp ) : <TAB> """"""Test writing data at a specific offset"""""" <TAB> f = None <TAB> try : <TAB> <TAB> self. _create_file ( ""file"", ""xxxxyyyy"" ) <TAB> <TAB> f = yield from sftp. open ( ""file"", ""r+"" ) <TAB> <TAB> yield from f. write ( ""zz"", 3 ) <TAB> <TAB> yield from f. close ( ) <TAB> <TAB> with open ( ""file"" ) as localf : <TAB> <TAB> <TAB> self. assertEqual ( localf. read ( ), ""xxxzzyyy"" ) <TAB> finally : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> yield from f. close ( ) <TAB> <TAB> remove ( ""file"" )",True,f,f,0.6864446997642517
|
||
|
4983,"def __call__ ( self, * args, ** kwargs ) -> ""CompiledExecutor"" : <TAB> is_cached : bool = kwargs. pop ( ""cached"", False ) <TAB> if is_cached : <TAB> <TAB> kwargs [ ""dest_dir"" ] = env. compiled_binary_cache_dir <TAB> <TAB> obj : ""CompiledExecutor"" = super ( ). __call__ ( * args, ** kwargs ) <TAB> obj. is_cached = is_cached <TAB> <TAB> if is_cached : <TAB> <TAB> cache_key_material = ( <TAB> <TAB> <TAB> utf8bytes ( obj. __class__. __name__ + obj. __module__ ) <TAB> <TAB> <TAB> + obj. get_binary_cache_key ( ) <TAB> <TAB> ) <TAB> <TAB> cache_key = hashlib. sha384 ( cache_key_material ). hexdigest ( ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> executor = self. compiled_binary_cache [ cache_key ] <TAB> <TAB> <TAB> assert executor. _executable is not None <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if os. path. isfile ( executor. _executable ) : <TAB> <TAB> <TAB> <TAB> obj. _executable = executor. _executable <TAB> <TAB> <TAB> <TAB> obj. _dir = executor. _dir <TAB> <TAB> <TAB> <TAB> return obj <TAB> obj. create_files ( * args, ** kwargs ) <TAB> obj. compile ( ) <TAB> if is_cached : <TAB> <TAB> self. compiled_binary_cache [ cache_key ] = obj <TAB> return obj",True,cache_key in self.compiled_binary_cache,cache_key in self.compiled_binary_cache,0.6497700810432434
|
||
|
4984,def finalize ( self ) : <TAB> if self. _started : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _queue. put ( None ) <TAB> <TAB> <TAB> self. _queue. join ( ) <TAB> <TAB> <TAB> self. _consumer. join ( ) <TAB> <TAB> self. _started = False <TAB> self. _finalized = True,False,not self._finalized,not self.consumer,0.6746705770492554
|
||
|
4985,"def __init__ ( <TAB> self, <TAB> parametrization : IntOrParameter, <TAB> budget : tp. Optional [ int ] = None, <TAB> num_workers : int = 1, ) -> None : <TAB> super ( ). __init__ ( parametrization, budget = budget, num_workers = num_workers ) <TAB> assert budget is not None <TAB> nw = num_workers // 2 <TAB> self. which_optim = [ 0 ] * nw <TAB> for i in range ( num_workers - nw ) : <TAB> <TAB> self. which_optim += [ i + 1 ] <TAB> assert len ( self. which_optim ) == num_workers <TAB> <TAB> self. optims = [ <TAB> <TAB> CMA ( self. parametrization, num_workers = nw ) <TAB> ] <TAB> for i in range ( num_workers - nw ) : <TAB> <TAB> self. optims += [ SQP ( self. parametrization, num_workers = 1 ) ] <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. optims [ - 1 ]. initial_guess = self. _rng. normal ( 0, 1, self. dimension )",False,i > 0,self.optims,0.6768208742141724
|
||
|
4986,"def expand_first ( self, seq ) : <TAB> head = """" <TAB> keys, mapped_to = self. _find_full_match ( self. state. mode, seq ) <TAB> if<mask> : <TAB> <TAB> self. state. logger. info ( <TAB> <TAB> <TAB> ""[Mappings] found full command: {0} -> {1}"". format ( keys, mapped_to ) <TAB> <TAB> ) <TAB> <TAB> return Mapping ( <TAB> <TAB> <TAB> seq, mapped_to [ ""name"" ], seq [ len ( keys ) : ], mapping_status. COMPLETE <TAB> <TAB> ) <TAB> for key in KeySequenceTokenizer ( seq ). iter_tokenize ( ) : <TAB> <TAB> head += key <TAB> <TAB> keys, mapped_to = self. _find_full_match ( self. state. mode, head ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. state. logger. info ( <TAB> <TAB> <TAB> <TAB> ""[Mappings] found full command: {0} -> {1}"". format ( keys, mapped_to ) <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> return Mapping ( <TAB> <TAB> <TAB> <TAB> head, mapped_to [ ""name"" ], seq [ len ( head ) : ], mapping_status. COMPLETE <TAB> <TAB> <TAB> ) <TAB> <TAB> else : <TAB> <TAB> <TAB> break <TAB> if self. _find_partial_match ( self. state. mode, seq ) : <TAB> <TAB> self. state. logger. info ( ""[Mappings] found partial command: {0}"". format ( seq ) ) <TAB> <TAB> return Mapping ( seq, """", """", mapping_status. INCOMPLETE ) <TAB> return None",False,keys,mapped_to,0.6694816946983337
|
||
|
4987,"def _unquote ( str ) : <TAB> <TAB> <TAB> if str is None or len ( str ) < 2 : <TAB> <TAB> return str <TAB> if str [ 0 ]!= '""' or str [ - 1 ]!= '""' : <TAB> <TAB> return str <TAB> <TAB> <TAB> <TAB> str = str [ 1 : - 1 ] <TAB> <TAB> <TAB> <TAB> <TAB> i = 0 <TAB> n = len ( str ) <TAB> res = [ ] <TAB> while 0 <= i < n : <TAB> <TAB> o_match = _OctalPatt. search ( str, i ) <TAB> <TAB> q_match = _QuotePatt. search ( str, i ) <TAB> <TAB> if not o_match and not q_match : <TAB> <TAB> <TAB> res. append ( str [ i : ] ) <TAB> <TAB> <TAB> break <TAB> <TAB> <TAB> <TAB> j = k = - 1 <TAB> <TAB> if o_match : <TAB> <TAB> <TAB> j = o_match. start ( 0 ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> k = q_match. start ( 0 ) <TAB> <TAB> if q_match and ( not o_match or k < j ) : <TAB> <TAB> <TAB> res. append ( str [ i : k ] ) <TAB> <TAB> <TAB> res. append ( str [ k + 1 ] ) <TAB> <TAB> <TAB> i = k + 2 <TAB> <TAB> else : <TAB> <TAB> <TAB> res. append ( str [ i : j ] ) <TAB> <TAB> <TAB> res. append ( chr ( int ( str [ j + 1 : j + 4 ], 8 ) ) ) <TAB> <TAB> <TAB> i = j + 4 <TAB> return _nulljoin ( res )",True,q_match,q_match,0.672800600528717
|
||
|
4988,"def git_log ( args ) : <TAB> parser = argparse. ArgumentParser ( description = ""git log arg parser"" ) <TAB> parser. add_argument ( ""-f"", ""--format"", action = ""store"", dest = ""format"", default = False ) <TAB> parser. add_argument ( <TAB> <TAB> ""-o"", <TAB> <TAB> ""--output"", <TAB> <TAB> action = ""store"", <TAB> <TAB> dest = ""output"", <TAB> <TAB> type = argparse. FileType ( ""w"" ), <TAB> <TAB> default = sys. stdout, <TAB> ) <TAB> parser. add_argument ( <TAB> <TAB> ""-l"", ""--length"", action = ""store"", type = int, dest = ""max_entries"", default = None <TAB> ) <TAB> parser. add_argument ( ""--oneline"", action = ""store_true"", dest = ""oneline"", default = False ) <TAB> results = parser. parse_args ( args ) <TAB> try : <TAB> <TAB> repo = _get_repo ( ) <TAB> <TAB> outstream = StringIO ( ) <TAB> <TAB> porcelain. log ( <TAB> <TAB> <TAB> repo. repo. path, max_entries = results. max_entries, outstream = outstream <TAB> <TAB> ) <TAB> <TAB> if not results. oneline : <TAB> <TAB> <TAB> print ( outstream. getvalue ( ) ) <TAB> <TAB> else : <TAB> <TAB> <TAB> last_commit = """" <TAB> <TAB> <TAB> last_printed = """" <TAB> <TAB> <TAB> start_message = False <TAB> <TAB> <TAB> for line in outstream. getvalue ( ). split ( ""\n"" ) : <TAB> <TAB> <TAB> <TAB> if line. startswith ( ""commit:"" ) : <TAB> <TAB> <TAB> <TAB> <TAB> tokens = line. split ( "" "" ) <TAB> <TAB> <TAB> <TAB> <TAB> last_commit = tokens [ - 1 ] [ : 7 ] <TAB> <TAB> <TAB>",False,last_commit == last_printed and start_message is True,default,0.6496603488922119
|
||
|
4989,"def update ( self, targets ) : <TAB> Section. update ( self, targets ) <TAB> outputNames = set ( ) <TAB> for target in targets : <TAB> <TAB> g = target. globals ( ) <TAB> <TAB> outputNames. update ( [ k for k in g. keys ( ) if k. startswith ( ""output:"" ) ] ) <TAB> rows = [ ] <TAB> outputNames = sorted ( outputNames ) <TAB> for outputName in outputNames : <TAB> <TAB> row = self. __rows. get ( outputName ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> row = _OutputRow ( outputName ) <TAB> <TAB> <TAB> self. __rows [ outputName ] = row <TAB> <TAB> row. update ( targets ) <TAB> <TAB> row. setAlternate ( len ( rows ) % 2 ) <TAB> <TAB> rows. append ( row ) <TAB> self. _mainColumn ( ) [ : ] = rows",True,row is None,row is None,0.6661540269851685
|
||
|
4990,"def seqSetup ( self, imin, imax, jmin = 0, jmax = None ) : <TAB> seqi = [ imin, imin, 12, 34 ] <TAB> seqj = [ jmin, 12, jmin, 34 ] <TAB> if not imax and not jmax : <TAB> <TAB> l = 2222222222222222222222222222 <TAB> <TAB> seqi. append ( l ) <TAB> <TAB> seqj. append ( l ) <TAB> <TAB> for n in range ( 100 ) : <TAB> <TAB> ifirstmax = jfirstmax = 100000 <TAB> <TAB> if imax : <TAB> <TAB> <TAB> ifirstmax = min ( imax, ifirstmax ) <TAB> <TAB> if jmax : <TAB> <TAB> <TAB> jfirstmax = min ( jmax, jfirstmax ) <TAB> <TAB> i = randrange ( imin, ifirstmax ) <TAB> <TAB> j = randrange ( jmin, jfirstmax ) <TAB> <TAB> seqi. append ( i ) <TAB> <TAB> seqj. append ( j ) <TAB> <TAB> for n in range ( 100 ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> i = randrange ( maxint ) + randrange ( maxint ) <TAB> <TAB> else : <TAB> <TAB> <TAB> i = randrange ( imin, imax ) <TAB> <TAB> if not jmax : <TAB> <TAB> <TAB> j = randrange ( maxint ) + randrange ( maxint ) <TAB> <TAB> else : <TAB> <TAB> <TAB> j = randrange ( jmin, jmax ) <TAB> <TAB> seqi. append ( i ) <TAB> <TAB> seqj. append ( j ) <TAB> self. seqi = seqi <TAB> self. seqj = seqj",False,not imax,not imin,0.7007740139961243
|
||
|
4991,"def _savePictures ( self, object, folder ) : <TAB> hasPictures = False <TAB> for arcname, picturerec in object. Pictures. items ( ) : <TAB> <TAB> what_it_is, fileobj, mediatype = picturerec <TAB> <TAB> self. manifest. addElement ( <TAB> <TAB> <TAB> manifest. FileEntry ( fullpath = ""%s%s"" % ( folder, arcname ), mediatype = mediatype ) <TAB> <TAB> ) <TAB> <TAB> hasPictures = True <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. _z. write ( fileobj, arcname, zipfile. ZIP_STORED ) <TAB> <TAB> else : <TAB> <TAB> <TAB> zi = zipfile. ZipInfo ( str ( arcname ), self. _now ) <TAB> <TAB> <TAB> zi. compress_type = zipfile. ZIP_STORED <TAB> <TAB> <TAB> zi. external_attr = UNIXPERMS <TAB> <TAB> <TAB> self. _z. writestr ( zi, fileobj ) <TAB> <TAB> <TAB> <TAB> <TAB> subobjectnum = 1 <TAB> for subobject in object. childobjects : <TAB> <TAB> self. _savePictures ( subobject, ""%sObject %d/"" % ( folder, subobjectnum ) ) <TAB> <TAB> subobjectnum += 1",False,what_it_is == IS_FILENAME,hasPictures,0.6517028212547302
|
||
|
4992,"def test_signal_handling_multiprocessing_process_warning ( self ) : <TAB> <TAB> warnings. filterwarnings ( ""always"", """", DeprecationWarning, __name__ ) <TAB> fake_utcnow = datetime. date ( 2021, 1, 1 ) <TAB> proc = None <TAB> try : <TAB> <TAB> with patch ( <TAB> <TAB> <TAB> ""salt.utils.versions.warn_until_date"", <TAB> <TAB> <TAB> self. patched_warn_until_date ( fake_utcnow ), <TAB> <TAB> ) : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> with warnings. catch_warnings ( record = True ) as recorded_warnings : <TAB> <TAB> <TAB> <TAB> proc = salt. utils. process. SignalHandlingMultiprocessingProcess ( <TAB> <TAB> <TAB> <TAB> <TAB> target = self. process_target <TAB> <TAB> <TAB> <TAB> ) <TAB> <TAB> <TAB> <TAB> self. assertEqual ( <TAB> <TAB> <TAB> <TAB> <TAB> ""Please stop using'salt.utils.process.SignalHandlingMultiprocessingProcess' "" <TAB> <TAB> <TAB> <TAB> <TAB> ""and instead use'salt.utils.process.SignalHandlingProcess'. "" <TAB> <TAB> <TAB> <TAB> <TAB> ""'salt.utils.process.SignalHandlingMultiprocessingProcess' will go away "" <TAB> <TAB> <TAB> <TAB> <TAB> ""after 2022-01-01."", <TAB> <TAB> <TAB> <TAB> <TAB> six. text_type ( recorded_warnings [ 0 ]. message ), <TAB> <TAB> <TAB> <TAB> ) <TAB> finally : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> del proc",True,proc is not None,proc is not None,0.6624610424041748
|
||
|
4993,"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 rule. defaults. iteritems ( ) : <TAB> <TAB> <TAB> <TAB> <TAB> if isinstance ( value, basestring ) : <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, basestring ) : <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.6709610223770142
|
||
|
4994,"def __view_beside ( self, onsideof, ** kwargs ) : <TAB> bounds = self. info [ ""bounds"" ] <TAB> min_dist, found = - 1, None <TAB> for ui in UiObject ( self. session, Selector ( ** kwargs ) ) : <TAB> <TAB> dist = onsideof ( bounds, ui. info [ ""bounds"" ] ) <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> min_dist, found = dist, ui <TAB> return found",False,dist >= 0 and (min_dist < 0 or dist < min_dist),dist > min_dist,0.6525450348854065
|
||
|
4995,"def openEmptyWorkBook ( self ) : <TAB> """"""Open an empty frame and paste the contents of CheatSheet.leo into it."""""" <TAB> lm = self <TAB> <TAB> fn = lm. computeWorkbookFileName ( ) <TAB> c = lm. loadLocalFile ( fn, gui = g. app. gui, old_c = None ) <TAB> <TAB> if not g. app. batchMode and not g. os_path_exists ( fn ) : <TAB> <TAB> <TAB> <TAB> old_clipboard = g. app. gui. getTextFromClipboard ( ) <TAB> <TAB> <TAB> <TAB> c2 = c. openCheatSheet ( redraw = False ) <TAB> <TAB> if c2 : <TAB> <TAB> <TAB> for p2 in c2. rootPosition ( ). self_and_siblings ( ) : <TAB> <TAB> <TAB> <TAB> c2. selectPosition ( p2 ) <TAB> <TAB> <TAB> <TAB> c2. copyOutline ( ) <TAB> <TAB> <TAB> <TAB> p = c. pasteOutline ( ) <TAB> <TAB> <TAB> <TAB> c. selectPosition ( p ) <TAB> <TAB> <TAB> <TAB> p. contract ( ) <TAB> <TAB> <TAB> <TAB> p. clearDirty ( ) <TAB> <TAB> <TAB> c2. close ( new_c = c ) <TAB> <TAB> <TAB> root = c. rootPosition ( ) <TAB> <TAB> <TAB> if root. h == g. shortFileName ( fn ) : <TAB> <TAB> <TAB> <TAB> root. doDelete ( newNode = root. next ( ) ) <TAB> <TAB> <TAB> p = g. findNodeAnywhere ( c, ""Leo's cheat sheet"" ) <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> c. selectPosition ( p ) <TAB> <TAB> <TAB> <TAB> p. expand ( ) <TAB> <TAB> <TAB> c. target_language = ""rest"" <TAB> <TAB> <TAB> <TAB> <TAB>",True,p,p,0.6932766437530518
|
||
|
4996,"def one ( checks, state ) : <TAB> """"""Execute one loop iteration."""""" <TAB> disabled = options. disable is not None and os. path. exists ( options. disable ) <TAB> successful = disabled or check ( options. command, options. timeout ) <TAB> <TAB> if state!= states. DISABLED and disabled : <TAB> <TAB> state = trigger ( states. DISABLED ) <TAB> elif state == states. INIT : <TAB> <TAB> if successful and options. rise <= 1 : <TAB> <TAB> <TAB> state = trigger ( states. UP ) <TAB> <TAB> elif successful : <TAB> <TAB> <TAB> state = trigger ( states. RISING ) <TAB> <TAB> <TAB> checks = 1 <TAB> <TAB> else : <TAB> <TAB> <TAB> state = trigger ( states. FALLING ) <TAB> <TAB> <TAB> checks = 1 <TAB> elif state == states. DISABLED : <TAB> <TAB> if not disabled : <TAB> <TAB> <TAB> state = trigger ( states. INIT ) <TAB> elif state == states. RISING : <TAB> <TAB> if successful : <TAB> <TAB> <TAB> checks += 1 <TAB> <TAB> <TAB> if checks >= options. rise : <TAB> <TAB> <TAB> <TAB> state = trigger ( states. UP ) <TAB> <TAB> else : <TAB> <TAB> <TAB> state = trigger ( states. FALLING ) <TAB> <TAB> <TAB> checks = 1 <TAB> elif state == states. FALLING : <TAB> <TAB> if not successful : <TAB> <TAB> <TAB> checks += 1 <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> state = trigger ( states. DOWN ) <TAB> <TAB> else : <TAB> <TAB> <TAB> state = trigger ( states. RISING ) <TAB> <TAB> <TAB> checks = 1 <TAB> elif state == states. UP : <TAB> <TAB> if not successful : <TAB> <TAB> <TAB> state = trigger ( states. FALLING ) <TAB> <TAB> <TAB> checks",False,checks >= options.fall,checks >= options.rise,0.6624369621276855
|
||
|
4997,"def extract_subdomains ( file_name ) : <TAB> <TAB> global domain_match <TAB> subs = { } <TAB> sub_file = open ( file_name ). read ( ) <TAB> f_all = re. findall ( domain_match, sub_file ) <TAB> del sub_file <TAB> for i in f_all : <TAB> <TAB> if i. find ( ""."" ) >= 0 : <TAB> <TAB> <TAB> p = i. split ( ""."" ) [ 0 : - 1 ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> while p and len ( p [ - 1 ] ) <= 3 : <TAB> <TAB> <TAB> <TAB> p = p [ 0 : - 1 ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> p = p [ 0 : - 1 ] <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if len ( p ) >= 1 : <TAB> <TAB> <TAB> <TAB> trace ( str ( p ), "" : "", i ) <TAB> <TAB> <TAB> <TAB> for q in p : <TAB> <TAB> <TAB> <TAB> <TAB> if q : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> q = q. lower ( ) <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> subs [ q ] += 1 <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> <TAB> subs [ q ] = 1 <TAB> <TAB> del f_all <TAB> <TAB> subs_sorted = sorted ( subs. keys ( ), key = lambda x : subs [ x ], reverse = True ) <TAB> return subs_sorted",True,q in subs,q in subs,0.6791987419128418
|
||
|
4998,"def _get_children ( self, event = None ) : <TAB> with self. _run_lock : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> return <TAB> <TAB> try : <TAB> <TAB> <TAB> children = self. _client. retry ( <TAB> <TAB> <TAB> <TAB> self. _client. get_children, self. _path, self. _watcher <TAB> <TAB> <TAB> ) <TAB> <TAB> except NoNodeError : <TAB> <TAB> <TAB> self. _stopped = True <TAB> <TAB> <TAB> return <TAB> <TAB> if not self. _watch_established : <TAB> <TAB> <TAB> self. _watch_established = True <TAB> <TAB> <TAB> if self. _prior_children is not None and self. _prior_children == children : <TAB> <TAB> <TAB> <TAB> return <TAB> <TAB> self. _prior_children = children <TAB> <TAB> try : <TAB> <TAB> <TAB> if self. _send_event : <TAB> <TAB> <TAB> <TAB> result = self. _func ( children, event ) <TAB> <TAB> <TAB> else : <TAB> <TAB> <TAB> <TAB> result = self. _func ( children ) <TAB> <TAB> <TAB> if result is False : <TAB> <TAB> <TAB> <TAB> self. _stopped = True <TAB> <TAB> <TAB> <TAB> self. _func = None <TAB> <TAB> <TAB> <TAB> if self. _allow_session_lost : <TAB> <TAB> <TAB> <TAB> <TAB> self. _client. remove_listener ( self. _session_watcher ) <TAB> <TAB> except Exception as exc : <TAB> <TAB> <TAB> log. exception ( exc ) <TAB> <TAB> <TAB> raise",False,self._stopped,self._client is None,0.669532060623169
|
||
|
4999,"def _calculate ( self ) : <TAB> before = self. before. data <TAB> after = self. after. data <TAB> self. deleted = { } <TAB> self. updated = { } <TAB> self. created = after. copy ( ) <TAB> for path, f in before. items ( ) : <TAB> <TAB> if<mask> : <TAB> <TAB> <TAB> self. deleted [ path ] = f <TAB> <TAB> <TAB> continue <TAB> <TAB> del self. created [ path ] <TAB> <TAB> if f. mtime < after [ path ]. mtime : <TAB> <TAB> <TAB> self. updated [ path ] = after [ path ]",False,path not in after,path not in self.deleted,0.6693145036697388
|