idx int64 0 252k | question stringlengths 48 5.28k | target stringlengths 5 1.23k |
|---|---|---|
8,100 | def _fix_up_fields ( cls ) : cls . _arguments = dict ( ) if cls . __module__ == __name__ : return for name in set ( dir ( cls ) ) : attr = getattr ( cls , name , None ) if isinstance ( attr , BaseArgument ) : if name . startswith ( '_' ) : raise TypeError ( "Endpoint argument %s cannot begin with " "an underscore, as t... | Add names to all of the Endpoint s Arguments . |
8,101 | def _execute ( self , request , ** kwargs ) : try : self . _create_context ( request ) self . _authenticate ( ) context = get_current_context ( ) self . _parse_args ( ) if hasattr ( self , '_before_handlers' ) and isinstance ( self . _before_handlers , ( list , tuple ) ) : for handler in self . _before_handlers : handl... | The top - level execute function for the endpoint . |
8,102 | def construct_concierge_header ( self , url ) : concierge_request_header = ( etree . Element ( etree . QName ( XHTML_NAMESPACE , "ConciergeRequestHeader" ) , nsmap = { 'sch' : XHTML_NAMESPACE } ) ) if self . session_id : session = ( etree . SubElement ( concierge_request_header , etree . QName ( XHTML_NAMESPACE , "Sess... | Constructs the Concierge Request Header lxml object to be used as the _soapheaders argument for WSDL methods . |
8,103 | def options_string_builder ( option_mapping , args ) : options_string = "" for option , flag in option_mapping . items ( ) : if option in args : options_string += str ( " %s %s" % ( flag , str ( args [ option ] ) ) ) return options_string | Return arguments for CLI invocation of kal . |
8,104 | def build_kal_scan_band_string ( kal_bin , band , args ) : option_mapping = { "gain" : "-g" , "device" : "-d" , "error" : "-e" } if not sanity . scan_band_is_valid ( band ) : err_txt = "Unsupported band designation: %" % band raise ValueError ( err_txt ) base_string = "%s -v -s %s" % ( kal_bin , band ) base_string += o... | Return string for CLI invocation of kal for band scan . |
8,105 | def build_kal_scan_channel_string ( kal_bin , channel , args ) : option_mapping = { "gain" : "-g" , "device" : "-d" , "error" : "-e" } base_string = "%s -v -c %s" % ( kal_bin , channel ) base_string += options_string_builder ( option_mapping , args ) return ( base_string ) | Return string for CLI invocation of kal for channel scan . |
8,106 | def determine_final_freq ( base , direction , modifier ) : result = 0 if direction == "+" : result = base + modifier elif direction == "-" : result = base - modifier return ( result ) | Return integer for frequency . |
8,107 | def to_eng ( num_in ) : x = decimal . Decimal ( str ( num_in ) ) eng_not = x . normalize ( ) . to_eng_string ( ) return ( eng_not ) | Return number in engineering notation . |
8,108 | def determine_device ( kal_out ) : device = "" while device == "" : for line in kal_out . splitlines ( ) : if "Using device " in line : device = str ( line . split ( ' ' , 2 ) [ - 1 ] ) if device == "" : device = None return device | Extract and return device from scan results . |
8,109 | def extract_value_from_output ( canary , split_offset , kal_out ) : retval = "" while retval == "" : for line in kal_out . splitlines ( ) : if canary in line : retval = str ( line . split ( ) [ split_offset ] ) if retval == "" : retval = None return retval | Return value parsed from output . |
8,110 | def determine_chan_detect_threshold ( kal_out ) : channel_detect_threshold = "" while channel_detect_threshold == "" : for line in kal_out . splitlines ( ) : if "channel detect threshold: " in line : channel_detect_threshold = str ( line . split ( ) [ - 1 ] ) if channel_detect_threshold == "" : print ( "Unable to parse... | Return channel detect threshold from kal output . |
8,111 | def determine_band_channel ( kal_out ) : band = "" channel = "" tgt_freq = "" while band == "" : for line in kal_out . splitlines ( ) : if "Using " in line and " channel " in line : band = str ( line . split ( ) [ 1 ] ) channel = str ( line . split ( ) [ 3 ] ) tgt_freq = str ( line . split ( ) [ 4 ] ) . replace ( "(" ,... | Return band channel target frequency from kal output . |
8,112 | def parse_kal_scan ( kal_out ) : kal_data = [ ] scan_band = determine_scan_band ( kal_out ) scan_gain = determine_scan_gain ( kal_out ) scan_device = determine_device ( kal_out ) sample_rate = determine_sample_rate ( kal_out ) chan_detect_threshold = determine_chan_detect_threshold ( kal_out ) for line in kal_out . spl... | Parse kal band scan output . |
8,113 | def parse_kal_channel ( kal_out ) : scan_band , scan_channel , tgt_freq = determine_band_channel ( kal_out ) kal_data = { "device" : determine_device ( kal_out ) , "sample_rate" : determine_sample_rate ( kal_out ) , "gain" : determine_scan_gain ( kal_out ) , "band" : scan_band , "channel" : scan_channel , "frequency" :... | Parse kal channel scan output . |
8,114 | def get_measurements_from_kal_scan ( kal_out ) : result = [ ] for line in kal_out . splitlines ( ) : if "offset " in line : p_line = line . split ( ' ' ) result . append ( p_line [ - 1 ] ) return result | Return a list of all measurements from kalibrate channel scan . |
8,115 | def render ( self , obj , name , context ) : if self . value_lambda is not None : val = self . value_lambda ( obj ) else : attr_name = name if self . property_name is not None : attr_name = self . property_name if isinstance ( obj , dict ) : val = obj . get ( attr_name , None ) else : val = getattr ( obj , attr_name , ... | The default field renderer . |
8,116 | def doc_dict ( self ) : doc = { 'type' : self . value_type , 'description' : self . description , 'extended_description' : self . details } return doc | Generate the documentation for this field . |
8,117 | def capability ( self , cap_name ) : if cap_name in self . __class_capabilities__ : function_name = self . __class_capabilities__ [ cap_name ] return getattr ( self , function_name ) | Return capability by its name |
8,118 | def has_capabilities ( self , * cap_names ) : for name in cap_names : if name not in self . __class_capabilities__ : return False return True | Check if class has all of the specified capabilities |
8,119 | def add_entity_errors ( self , property_name , direct_errors = None , schema_errors = None ) : if direct_errors is None and schema_errors is None : return self if direct_errors is not None : if property_name not in self . errors : self . errors [ property_name ] = dict ( ) if 'direct' not in self . errors [ property_na... | Attach nested entity errors Accepts a list errors coming from validators attached directly or a dict of errors produced by a nested schema . |
8,120 | def add_collection_errors ( self , property_name , direct_errors = None , collection_errors = None ) : if direct_errors is None and collection_errors is None : return self if direct_errors is not None : if type ( direct_errors ) is not list : direct_errors = [ direct_errors ] if property_name not in self . errors : sel... | Add collection errors Accepts a list errors coming from validators attached directly or a list of schema results for each item in the collection . |
8,121 | def merge_errors ( self , errors_local , errors_remote ) : for prop in errors_remote : if prop not in errors_local : errors_local [ prop ] = errors_remote [ prop ] continue local = errors_local [ prop ] local = local . errors if isinstance ( local , Result ) else local remote = errors_remote [ prop ] remote = remote . ... | Merge errors Recursively traverses error graph to merge remote errors into local errors to return a new joined graph . |
8,122 | def merge ( self , another ) : if isinstance ( another , Result ) : another = another . errors self . errors = self . merge_errors ( self . errors , another ) | Merges another validation result graph into itself |
8,123 | def get_messages ( self , locale = None ) : if locale is None : locale = self . locale if self . translator : def translate ( error ) : return self . translator . translate ( error , locale ) else : def translate ( error ) : return error errors = deepcopy ( self . errors ) errors = self . _translate_errors ( errors , t... | Get a dictionary of translated messages |
8,124 | def _translate_errors ( self , errors , translate ) : for prop in errors : prop_errors = errors [ prop ] if type ( prop_errors ) is list : for index , error in enumerate ( prop_errors ) : message = translate ( error . message ) message = self . format_error ( message , error . kwargs ) errors [ prop ] [ index ] = messa... | Recursively apply translate callback to each error message |
8,125 | def make_url ( self , path , api_root = u'/v2/' ) : return urljoin ( urljoin ( self . url , api_root ) , path ) | Gets a full URL from just path . |
8,126 | def make_key_url ( self , key ) : if type ( key ) is bytes : key = key . decode ( 'utf-8' ) buf = io . StringIO ( ) buf . write ( u'keys' ) if not key . startswith ( u'/' ) : buf . write ( u'/' ) buf . write ( key ) return self . make_url ( buf . getvalue ( ) ) | Gets a URL for a key . |
8,127 | def get ( self , key , recursive = False , sorted = False , quorum = False , wait = False , wait_index = None , timeout = None ) : url = self . make_key_url ( key ) params = self . build_args ( { 'recursive' : ( bool , recursive or None ) , 'sorted' : ( bool , sorted or None ) , 'quorum' : ( bool , quorum or None ) , '... | Requests to get a node by the given key . |
8,128 | def delete ( self , key , dir = False , recursive = False , prev_value = None , prev_index = None , timeout = None ) : url = self . make_key_url ( key ) params = self . build_args ( { 'dir' : ( bool , dir or None ) , 'recursive' : ( bool , recursive or None ) , 'prevValue' : ( six . text_type , prev_value ) , 'prevInde... | Requests to delete a node by the given key . |
8,129 | def login_to_portal ( username , password , client , retries = 2 , delay = 0 ) : if not client . session_id : client . request_session ( ) concierge_request_header = client . construct_concierge_header ( url = ( "http://membersuite.com/contracts/IConciergeAPIService/" "LoginToPortal" ) ) attempts = 0 while attempts < r... | Log username into the MemberSuite Portal . |
8,130 | def logout ( client ) : if not client . session_id : client . request_session ( ) concierge_request_header = client . construct_concierge_header ( url = ( "http://membersuite.com/contracts/IConciergeAPIService/" "Logout" ) ) logout_result = client . client . service . Logout ( _soapheaders = [ concierge_request_header ... | Log out the currently logged - in user . |
8,131 | def get_user_for_membersuite_entity ( membersuite_entity ) : user = None user_created = False user_username = generate_username ( membersuite_entity ) try : user = User . objects . get ( username = user_username ) except User . DoesNotExist : pass if not user : try : user = User . objects . filter ( email = membersuite... | Returns a User for membersuite_entity . |
8,132 | def add_validator ( self , validator ) : if not isinstance ( validator , AbstractValidator ) : err = 'Validator must be of type {}' . format ( AbstractValidator ) raise InvalidValidator ( err ) self . validators . append ( validator ) return self | Add validator to property |
8,133 | def filter ( self , value = None , model = None , context = None ) : if value is None : return value for filter_obj in self . filters : value = filter_obj . filter ( value = value , model = model , context = context if self . use_context else None ) return value | Sequentially applies all the filters to provided value |
8,134 | def validate ( self , value = None , model = None , context = None ) : errors = [ ] for validator in self . validators : if value is None and not isinstance ( validator , Required ) : continue error = validator . run ( value = value , model = model , context = context if self . use_context else None ) if error : errors... | Sequentially apply each validator to value and collect errors . |
8,135 | def filter_with_schema ( self , model = None , context = None ) : if model is None or self . schema is None : return self . _schema . filter ( model = model , context = context if self . use_context else None ) | Perform model filtering with schema |
8,136 | def validate_with_schema ( self , model = None , context = None ) : if self . _schema is None or model is None : return result = self . _schema . validate ( model = model , context = context if self . use_context else None ) return result | Perform model validation with schema |
8,137 | def filter_with_schema ( self , collection = None , context = None ) : if collection is None or self . schema is None : return try : for item in collection : self . _schema . filter ( model = item , context = context if self . use_context else None ) except TypeError : pass | Perform collection items filtering with schema |
8,138 | def validate_with_schema ( self , collection = None , context = None ) : if self . _schema is None or not collection : return result = [ ] try : for index , item in enumerate ( collection ) : item_result = self . _schema . validate ( model = item , context = context if self . use_context else None ) result . append ( i... | Validate each item in collection with our schema |
8,139 | def json_based_stable_hash ( obj ) : encoded_str = json . dumps ( obj = obj , skipkeys = False , ensure_ascii = False , check_circular = True , allow_nan = True , cls = None , indent = 0 , separators = ( ',' , ':' ) , default = None , sort_keys = True , ) . encode ( 'utf-8' ) return hashlib . sha256 ( encoded_str ) . h... | Computes a cross - kernel stable hash value for the given object . |
8,140 | def read_request_line ( self , request_line ) : request = self . __request_cls . parse_request_line ( self , request_line ) protocol_version = self . protocol_version ( ) if protocol_version == '0.9' : if request . method ( ) != 'GET' : raise Exception ( 'HTTP/0.9 standard violation' ) elif protocol_version == '1.0' or... | Read HTTP - request line |
8,141 | def metaclass ( * metaclasses ) : def _inner ( cls ) : metabases = tuple ( collections . OrderedDict ( ( c , None ) for c in ( metaclasses + ( type ( cls ) , ) ) ) . keys ( ) ) _Meta = metabases [ 0 ] for base in metabases [ 1 : ] : class _Meta ( base , _Meta ) : pass return six . add_metaclass ( _Meta ) ( cls ) return... | Create the class using all metaclasses . |
8,142 | def get_attrition_in_years ( self ) : attrition_of_nets = self . itn . find ( "attritionOfNets" ) function = attrition_of_nets . attrib [ "function" ] if function != "step" : return None L = attrition_of_nets . attrib [ "L" ] return L | Function for the Basic UI |
8,143 | def add ( self , intervention , name = None ) : if self . et is None : return assert isinstance ( intervention , six . string_types ) et = ElementTree . fromstring ( intervention ) vector_pop = VectorPopIntervention ( et ) assert isinstance ( vector_pop . name , six . string_types ) if name is not None : assert isinsta... | Add an intervention to vectorPop section . intervention is either ElementTree or xml snippet |
8,144 | def add ( self , value ) : index = len ( self . __history ) self . __history . append ( value ) return index | Add new record to history . Record will be added to the end |
8,145 | def start_session ( self ) : self . __current_row = '' self . __history_mode = False self . __editable_history = deepcopy ( self . __history ) self . __prompt_show = True self . refresh_window ( ) | Start new session and prepare environment for new row editing process |
8,146 | def fin_session ( self ) : self . __prompt_show = False self . __history . add ( self . row ( ) ) self . exec ( self . row ( ) ) | Finalize current session |
8,147 | def data ( self , previous_data = False , prompt = False , console_row = False , console_row_to_cursor = False , console_row_from_cursor = False ) : result = '' if previous_data : result += self . __previous_data if prompt or console_row or console_row_to_cursor : result += self . console ( ) . prompt ( ) if console_ro... | Return output data . Flags specifies what data to append . If no flags was specified nul - length string returned |
8,148 | def write_data ( self , data , start_position = 0 ) : if len ( data ) > self . height ( ) : raise ValueError ( 'Data too long (too many strings)' ) for i in range ( len ( data ) ) : self . write_line ( start_position + i , data [ i ] ) | Write data from the specified line |
8,149 | def write_feedback ( self , feedback , cr = True ) : self . __previous_data += feedback if cr is True : self . __previous_data += '\n' | Store feedback . Keep specified feedback as previous output |
8,150 | def refresh ( self , prompt_show = True ) : self . clear ( ) for drawer in self . __drawers : if drawer . suitable ( self , prompt_show = prompt_show ) : drawer . draw ( self , prompt_show = prompt_show ) return raise RuntimeError ( 'No suitable drawer was found' ) | Refresh current window . Clear current window and redraw it with one of drawers |
8,151 | def is_dir ( path ) : try : return path . expanduser ( ) . absolute ( ) . is_dir ( ) except AttributeError : return os . path . isdir ( os . path . abspath ( os . path . expanduser ( str ( path ) ) ) ) | Determine if a Path or string is a directory on the file system . |
8,152 | def is_file ( path ) : try : return path . expanduser ( ) . absolute ( ) . is_file ( ) except AttributeError : return os . path . isfile ( os . path . abspath ( os . path . expanduser ( str ( path ) ) ) ) | Determine if a Path or string is a file on the file system . |
8,153 | def exists ( path ) : try : return path . expanduser ( ) . absolute ( ) . exists ( ) except AttributeError : return os . path . exists ( os . path . abspath ( os . path . expanduser ( str ( path ) ) ) ) | Determine if a Path or string is an existing path on the file system . |
8,154 | def enableHook ( self , msgObj ) : self . killListIdx = len ( qte_global . kill_list ) - 2 self . qteMain . qtesigKeyseqComplete . connect ( self . disableHook ) | Enable yank - pop . |
8,155 | def cursorPositionChangedEvent ( self ) : qteWidget = self . sender ( ) tc = qteWidget . textCursor ( ) origin = tc . position ( ) qteWidget . cursorPositionChanged . disconnect ( self . cursorPositionChangedEvent ) self . qteRemoveHighlighting ( qteWidget ) qteWidget . cursorPositionChanged . connect ( self . cursorPo... | Update the highlighting . |
8,156 | def qteRemoveHighlighting ( self , widgetObj ) : data = self . qteMacroData ( widgetObj ) if not data : return if not data . matchingPositions : return self . highlightCharacters ( widgetObj , data . matchingPositions , QtCore . Qt . black , 50 , data . oldCharFormats ) data . matchingPositions = None data . oldCharFor... | Remove the highlighting from previously highlighted characters . |
8,157 | def highlightCharacters ( self , widgetObj , setPos , colorCode , fontWeight , charFormat = None ) : textCursor = widgetObj . textCursor ( ) oldPos = textCursor . position ( ) retVal = [ ] for ii , pos in enumerate ( setPos ) : pos = setPos [ ii ] if pos < 0 : retVal . append ( None ) continue textCursor . setPosition ... | Change the character format of one or more characters . |
8,158 | def scenarios ( self , generate_seed = False ) : seed = prime_numbers ( 1000 ) sweeps_all = self . experiment [ "sweeps" ] . keys ( ) if "combinations" in self . experiment : if isinstance ( self . experiment [ "combinations" ] , list ) : combinations_in_experiment = { " " : self . experiment [ "combinations" ] } else ... | Generator function . Spits out scenarios for this experiment |
8,159 | def lvm_info ( self , name = None ) : cmd = [ ] if self . sudo ( ) is False else [ 'sudo' ] cmd . extend ( [ self . command ( ) , '-c' ] ) if name is not None : cmd . append ( name ) output = subprocess . check_output ( cmd , timeout = self . cmd_timeout ( ) ) output = output . decode ( ) result = [ ] fields_count = se... | Call a program |
8,160 | def uuid ( self ) : uuid_file = '/sys/block/%s/dm/uuid' % os . path . basename ( os . path . realpath ( self . volume_path ( ) ) ) lv_uuid = open ( uuid_file ) . read ( ) . strip ( ) if lv_uuid . startswith ( 'LVM-' ) is True : return lv_uuid [ 4 : ] return lv_uuid | Return UUID of logical volume |
8,161 | def create_snapshot ( self , snapshot_size , snapshot_suffix ) : size_extent = math . ceil ( self . extents_count ( ) * snapshot_size ) size_kb = self . volume_group ( ) . extent_size ( ) * size_extent snapshot_name = self . volume_name ( ) + snapshot_suffix lvcreate_cmd = [ 'sudo' ] if self . lvm_command ( ) . sudo ( ... | Create snapshot for this logical volume . |
8,162 | def remove_volume ( self ) : lvremove_cmd = [ 'sudo' ] if self . lvm_command ( ) . sudo ( ) is True else [ ] lvremove_cmd . extend ( [ 'lvremove' , '-f' , self . volume_path ( ) ] ) subprocess . check_output ( lvremove_cmd , timeout = self . __class__ . __lvm_snapshot_remove_cmd_timeout__ ) | Remove this volume |
8,163 | def logical_volume ( cls , file_path , sudo = False ) : mp = WMountPoint . mount_point ( file_path ) if mp is not None : name_file = '/sys/block/%s/dm/name' % mp . device_name ( ) if os . path . exists ( name_file ) : lv_path = '/dev/mapper/%s' % open ( name_file ) . read ( ) . strip ( ) return WLogicalVolume ( lv_path... | Return logical volume that stores the given path |
8,164 | def write ( self , b ) : self . __buffer += bytes ( b ) bytes_written = 0 while len ( self . __buffer ) >= self . __cipher_block_size : io . BufferedWriter . write ( self , self . __cipher . encrypt_block ( self . __buffer [ : self . __cipher_block_size ] ) ) self . __buffer = self . __buffer [ self . __cipher_block_si... | Encrypt and write data |
8,165 | def reset_component ( self , component ) : if isinstance ( component , str ) is True : component = WURI . Component ( component ) self . __components [ component ] = None | Unset component in this URI |
8,166 | def parse ( cls , uri ) : uri_components = urlsplit ( uri ) adapter_fn = lambda x : x if x is not None and ( isinstance ( x , str ) is False or len ( x ) ) > 0 else None return cls ( scheme = adapter_fn ( uri_components . scheme ) , username = adapter_fn ( uri_components . username ) , password = adapter_fn ( uri_compo... | Parse URI - string and return WURI object |
8,167 | def add_parameter ( self , name , value = None ) : if name not in self . __query : self . __query [ name ] = [ value ] else : self . __query [ name ] . append ( value ) | Add new parameter value to this query . New value will be appended to previously added values . |
8,168 | def remove_parameter ( self , name ) : if name in self . __query : self . __query . pop ( name ) | Remove the specified parameter from this query |
8,169 | def parse ( cls , query_str ) : parsed_query = parse_qs ( query_str , keep_blank_values = True , strict_parsing = True ) result = cls ( ) for parameter_name in parsed_query . keys ( ) : for parameter_value in parsed_query [ parameter_name ] : result . add_parameter ( parameter_name , parameter_value if len ( parameter_... | Parse string that represent query component from URI |
8,170 | def add_specification ( self , specification ) : name = specification . name ( ) if name in self . __specs : raise ValueError ( 'WStrictURIQuery object already has specification for parameter "%s" ' % name ) self . __specs [ name ] = specification | Add a new query parameter specification . If this object already has a specification for the specified parameter - exception is raised . No checks for the specified or any parameter are made regarding specification appending |
8,171 | def remove_specification ( self , name ) : if name in self . __specs : self . __specs . pop ( name ) | Remove a specification that matches a query parameter . No checks for the specified or any parameter are made regarding specification removing |
8,172 | def replace_parameter ( self , name , value = None ) : spec = self . __specs [ name ] if name in self . __specs else None if self . extra_parameters ( ) is False and spec is None : raise ValueError ( 'Extra parameters are forbidden for this WStrictURIQuery object' ) if spec is not None and spec . nullable ( ) is False ... | Replace a query parameter values with a new value . If a new value does not match current specifications then exception is raised |
8,173 | def remove_parameter ( self , name ) : spec = self . __specs [ name ] if name in self . __specs else None if spec is not None and spec . optional ( ) is False : raise ValueError ( 'Unable to remove a required parameter "%s"' % name ) WURIQuery . remove_parameter ( self , name ) | Remove parameter from this query . If a parameter is mandatory then exception is raised |
8,174 | def validate ( self , uri ) : requirement = self . requirement ( ) uri_component = uri . component ( self . component ( ) ) if uri_component is None : return requirement != WURIComponentVerifier . Requirement . required if requirement == WURIComponentVerifier . Requirement . unsupported : return False re_obj = self . r... | Check an URI for compatibility with this specification . Return True if the URI is compatible . |
8,175 | def validate ( self , uri ) : if WURIComponentVerifier . validate ( self , uri ) is False : return False try : WStrictURIQuery ( WURIQuery . parse ( uri . component ( self . component ( ) ) ) , * self . __specs , extra_parameters = self . __extra_parameters ) except ValueError : return False return True | Check that an query part of an URI is compatible with this descriptor . Return True if the URI is compatible . |
8,176 | def is_compatible ( self , uri ) : for component , component_value in uri : if self . verifier ( component ) . validate ( uri ) is False : return False return True | Check if URI is compatible with this specification . Compatible URI has scheme name that matches specification scheme name has all of the required components does not have unsupported components and may have optional components |
8,177 | def handler ( self , scheme_name = None ) : if scheme_name is None : return self . __default_handler_cls for handler in self . __handlers_cls : if handler . scheme_specification ( ) . scheme_name ( ) == scheme_name : return handler | Return handler which scheme name matches the specified one |
8,178 | def open ( self , uri , ** kwargs ) : handler = self . handler ( uri . scheme ( ) ) if handler is None : raise WSchemeCollection . NoHandlerFound ( uri ) if uri . scheme ( ) is None : uri . component ( 'scheme' , handler . scheme_specification ( ) . scheme_name ( ) ) if handler . scheme_specification ( ) . is_compatibl... | Return handler instance that matches the specified URI . WSchemeCollection . NoHandlerFound and WSchemeCollection . SchemeIncompatible may be raised . |
8,179 | def loadFile ( self , fileName ) : self . fileName = fileName self . qteWeb . load ( QtCore . QUrl ( fileName ) ) | Load the URL fileName . |
8,180 | def render_to_response ( self , context , ** response_kwargs ) : context [ "ajax_form_id" ] = self . ajax_form_id return self . response_class ( request = self . request , template = self . get_template_names ( ) , context = context , ** response_kwargs ) | Returns a response with a template rendered with the given context . |
8,181 | def to_python ( self , value , resource ) : if value is None : return self . _transform ( value ) if isinstance ( value , six . text_type ) : return self . _transform ( value ) if self . encoding is None and isinstance ( value , ( six . text_type , six . binary_type ) ) : return self . _transform ( value ) if self . en... | Converts to unicode if self . encoding ! = None otherwise returns input without attempting to decode |
8,182 | def to_python ( self , value , resource ) : if isinstance ( value , dict ) : d = { self . aliases . get ( k , k ) : self . to_python ( v , resource ) if isinstance ( v , ( dict , list ) ) else v for k , v in six . iteritems ( value ) } return type ( self . class_name , ( ) , d ) elif isinstance ( value , list ) : retur... | Dictionary to Python object |
8,183 | def to_value ( self , obj , resource , visited = set ( ) ) : if id ( obj ) in visited : raise ValueError ( 'Circular reference detected when attempting to serialize object' ) if isinstance ( obj , ( list , tuple , set ) ) : return [ self . to_value ( x , resource ) if hasattr ( x , '__dict__' ) else x for x in obj ] el... | Python object to dictionary |
8,184 | def hello_message ( self , invert_hello = False ) : if invert_hello is False : return self . __gouverneur_message hello_message = [ ] for i in range ( len ( self . __gouverneur_message ) - 1 , - 1 , - 1 ) : hello_message . append ( self . __gouverneur_message [ i ] ) return bytes ( hello_message ) | Return message header . |
8,185 | def _message_address_parse ( self , message , invert_hello = False ) : message_header = self . hello_message ( invert_hello = invert_hello ) if message [ : len ( message_header ) ] != message_header : raise ValueError ( 'Invalid message header' ) message = message [ len ( message_header ) : ] message_parts = message . ... | Read address from beacon message . If no address is specified then nullable WIPV4SocketInfo returns |
8,186 | def cipher ( self ) : cipher = Cipher ( * self . mode ( ) . aes_args ( ) , ** self . mode ( ) . aes_kwargs ( ) ) return WAES . WAESCipher ( cipher ) | Generate AES - cipher |
8,187 | def encrypt ( self , data ) : padding = self . mode ( ) . padding ( ) if padding is not None : data = padding . pad ( data , WAESMode . __data_padding_length__ ) return self . cipher ( ) . encrypt_block ( data ) | Encrypt the given data with cipher that is got from AES . cipher call . |
8,188 | def decrypt ( self , data , decode = False ) : result = self . cipher ( ) . decrypt_block ( data ) padding = self . mode ( ) . padding ( ) if padding is not None : result = padding . reverse_pad ( result , WAESMode . __data_padding_length__ ) return result . decode ( ) if decode else result | Decrypt the given data with cipher that is got from AES . cipher call . |
8,189 | def thread_tracker_exception ( self , raised_exception ) : print ( 'Thread tracker execution was stopped by the exception. Exception: %s' % str ( raised_exception ) ) print ( 'Traceback:' ) print ( traceback . format_exc ( ) ) | Method is called whenever an exception is raised during registering a event |
8,190 | def __store_record ( self , record ) : if isinstance ( record , WSimpleTrackerStorage . Record ) is False : raise TypeError ( 'Invalid record type was' ) limit = self . record_limit ( ) if limit is not None and len ( self . __registry ) >= limit : self . __registry . pop ( 0 ) self . __registry . append ( record ) | Save record in a internal storage |
8,191 | def put_nested_val ( dict_obj , key_tuple , value ) : current_dict = dict_obj for key in key_tuple [ : - 1 ] : try : current_dict = current_dict [ key ] except KeyError : current_dict [ key ] = { } current_dict = current_dict [ key ] current_dict [ key_tuple [ - 1 ] ] = value | Put a value into nested dicts by the order of the given keys tuple . |
8,192 | def get_alternative_nested_val ( key_tuple , dict_obj ) : top_keys = key_tuple [ 0 ] if isinstance ( key_tuple [ 0 ] , ( list , tuple ) ) else [ key_tuple [ 0 ] ] for key in top_keys : try : if len ( key_tuple ) < 2 : return dict_obj [ key ] return get_alternative_nested_val ( key_tuple [ 1 : ] , dict_obj [ key ] ) exc... | Return a value from nested dicts by any path in the given keys tuple . |
8,193 | def subdict_by_keys ( dict_obj , keys ) : return { k : dict_obj [ k ] for k in set ( keys ) . intersection ( dict_obj . keys ( ) ) } | Returns a sub - dict composed solely of the given keys . |
8,194 | def add_to_dict_val_set ( dict_obj , key , val ) : try : dict_obj [ key ] . add ( val ) except KeyError : dict_obj [ key ] = set ( [ val ] ) | Adds the given val to the set mapped by the given key . If the key is missing from the dict the given mapping is added . |
8,195 | def add_many_to_dict_val_set ( dict_obj , key , val_list ) : try : dict_obj [ key ] . update ( val_list ) except KeyError : dict_obj [ key ] = set ( val_list ) | Adds the given value list to the set mapped by the given key . If the key is missing from the dict the given mapping is added . |
8,196 | def add_many_to_dict_val_list ( dict_obj , key , val_list ) : try : dict_obj [ key ] . extend ( val_list ) except KeyError : dict_obj [ key ] = list ( val_list ) | Adds the given value list to the list mapped by the given key . If the key is missing from the dict the given mapping is added . |
8,197 | def get_keys_of_max_n ( dict_obj , n ) : return sorted ( [ item [ 0 ] for item in sorted ( dict_obj . items ( ) , key = lambda item : item [ 1 ] , reverse = True ) [ : n ] ] ) | Returns the keys that maps to the top n max values in the given dict . |
8,198 | def deep_merge_dict ( base , priority ) : if not isinstance ( base , dict ) or not isinstance ( priority , dict ) : return priority result = copy . deepcopy ( base ) for key in priority . keys ( ) : if key in base : result [ key ] = deep_merge_dict ( base [ key ] , priority [ key ] ) else : result [ key ] = priority [ ... | Recursively merges the two given dicts into a single dict . |
8,199 | def norm_int_dict ( int_dict ) : norm_dict = int_dict . copy ( ) val_sum = sum ( norm_dict . values ( ) ) for key in norm_dict : norm_dict [ key ] = norm_dict [ key ] / val_sum return norm_dict | Normalizes values in the given dict with int values . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.