idx int64 0 63k | question stringlengths 53 5.28k | target stringlengths 5 805 |
|---|---|---|
24,200 | def get_repo_info ( loader , sha , prov_g ) : user_repo = loader . getFullName ( ) repo_title = loader . getRepoTitle ( ) contact_name = loader . getContactName ( ) contact_url = loader . getContactUrl ( ) commit_list = loader . getCommitList ( ) licence_url = loader . getLicenceURL ( ) if prov_g : prov_g . add_used_en... | Generate swagger information from the repo being used . |
24,201 | def buildPaginationHeader ( resultCount , resultsPerPage , pageArg , url ) : lastPage = resultCount / resultsPerPage if pageArg : page = int ( pageArg ) next_url = re . sub ( "page=[0-9]+" , "page={}" . format ( page + 1 ) , url ) prev_url = re . sub ( "page=[0-9]+" , "page={}" . format ( page - 1 ) , url ) first_url =... | Build link header for result pagination |
24,202 | def format_directive ( module , package = None ) : directive = '.. automodule:: %s\n' % makename ( package , module ) for option in OPTIONS : directive += ' :%s:\n' % option return directive | Create the automodule directive and add the options . |
24,203 | def extract_summary ( obj ) : try : doc = inspect . getdoc ( obj ) . split ( "\n" ) except AttributeError : doc = '' while doc and not doc [ 0 ] . strip ( ) : doc . pop ( 0 ) for i , piece in enumerate ( doc ) : if not piece . strip ( ) : doc = doc [ : i ] break sentences = periods_re . split ( " " . join ( doc ) ) if ... | Extract summary from docstring . |
24,204 | def _get_member_ref_str ( name , obj , role = 'obj' , known_refs = None ) : if known_refs is not None : if name in known_refs : return known_refs [ name ] ref = _get_fullname ( name , obj ) return ":%s:`%s <%s>`" % ( role , name , ref ) | generate a ReST - formmated reference link to the given obj of type role using name as the link text |
24,205 | def _get_mod_ns ( name , fullname , includeprivate ) : ns = { 'name' : name , 'fullname' : fullname , 'members' : [ ] , 'functions' : [ ] , 'classes' : [ ] , 'exceptions' : [ ] , 'subpackages' : [ ] , 'submodules' : [ ] , 'doc' : None } p = 0 if includeprivate : p = 1 mod = importlib . import_module ( fullname ) ns [ '... | Return the template context of module identified by fullname as a dict |
24,206 | def get_all_for ( self , key ) : if not isinstance ( key , _string_type ) : raise TypeError ( "Key needs to be a string." ) return [ self [ ( idx , key ) ] for idx in _range ( self . __kcount [ key ] ) ] | Returns all values of the given key |
24,207 | def remove_all_for ( self , key ) : if not isinstance ( key , _string_type ) : raise TypeError ( "Key need to be a string." ) for idx in _range ( self . __kcount [ key ] ) : super ( VDFDict , self ) . __delitem__ ( ( idx , key ) ) self . __omap = list ( filter ( lambda x : x [ 1 ] != key , self . __omap ) ) del self . ... | Removes all items with the given key |
24,208 | def has_duplicates ( self ) : for n in getattr ( self . __kcount , _iter_values ) ( ) : if n != 1 : return True def dict_recurse ( obj ) : for v in getattr ( obj , _iter_values ) ( ) : if isinstance ( v , VDFDict ) and v . has_duplicates ( ) : return True elif isinstance ( v , dict ) : return dict_recurse ( v ) return ... | Returns True if the dict contains keys with duplicates . Recurses through any all keys with value that is VDFDict . |
24,209 | def dumps ( obj , pretty = False , escaped = True ) : if not isinstance ( obj , dict ) : raise TypeError ( "Expected data to be an instance of``dict``" ) if not isinstance ( pretty , bool ) : raise TypeError ( "Expected pretty to be of type bool" ) if not isinstance ( escaped , bool ) : raise TypeError ( "Expected esca... | Serialize obj to a VDF formatted str . |
24,210 | def binary_dumps ( obj , alt_format = False ) : return b'' . join ( _binary_dump_gen ( obj , alt_format = alt_format ) ) | Serialize obj to a binary VDF formatted bytes . |
24,211 | def vbkv_loads ( s , mapper = dict , merge_duplicate_keys = True ) : if s [ : 4 ] != b'VBKV' : raise ValueError ( "Invalid header" ) checksum , = struct . unpack ( '<i' , s [ 4 : 8 ] ) if checksum != crc32 ( s [ 8 : ] ) : raise ValueError ( "Invalid checksum" ) return binary_loads ( s [ 8 : ] , mapper , merge_duplicate... | Deserialize s ( bytes containing a VBKV to a Python object . |
24,212 | def vbkv_dumps ( obj ) : data = b'' . join ( _binary_dump_gen ( obj , alt_format = True ) ) checksum = crc32 ( data ) return b'VBKV' + struct . pack ( '<i' , checksum ) + data | Serialize obj to a VBKV formatted bytes . |
24,213 | def signature_validate ( signature , error = None ) : "is signature a valid sequence of zero or more complete types." error , my_error = _get_error ( error ) result = dbus . dbus_signature_validate ( signature . encode ( ) , error . _dbobj ) != 0 my_error . raise_if_set ( ) return result | is signature a valid sequence of zero or more complete types . |
24,214 | def unparse_signature ( signature ) : "converts a signature from parsed form to string form." signature = parse_signature ( signature ) if not isinstance ( signature , ( tuple , list ) ) : signature = [ signature ] return DBUS . Signature ( "" . join ( t . signature for t in signature ) ) | converts a signature from parsed form to string form . |
24,215 | def signature_validate_single ( signature , error = None ) : "is signature a single valid type." error , my_error = _get_error ( error ) result = dbus . dbus_signature_validate_single ( signature . encode ( ) , error . _dbobj ) != 0 my_error . raise_if_set ( ) return result | is signature a single valid type . |
24,216 | def split_path ( path ) : "convenience routine for splitting a path into a list of components." if isinstance ( path , ( tuple , list ) ) : result = path elif path == "/" : result = [ ] else : if not path . startswith ( "/" ) or path . endswith ( "/" ) : raise DBusError ( DBUS . ERROR_INVALID_ARGS , "invalid path %s" %... | convenience routine for splitting a path into a list of components . |
24,217 | def validate_utf8 ( alleged_utf8 , error = None ) : "alleged_utf8 must be null-terminated bytes." error , my_error = _get_error ( error ) result = dbus . dbus_validate_utf8 ( alleged_utf8 , error . _dbobj ) != 0 my_error . raise_if_set ( ) return result | alleged_utf8 must be null - terminated bytes . |
24,218 | def int_subtype ( i , bits , signed ) : "returns integer i after checking that it fits in the given number of bits." if not isinstance ( i , int ) : raise TypeError ( "value is not int: %s" % repr ( i ) ) if signed : lo = - 1 << bits - 1 hi = ( 1 << bits - 1 ) - 1 else : lo = 0 hi = ( 1 << bits ) - 1 if i < lo or i > h... | returns integer i after checking that it fits in the given number of bits . |
24,219 | def server_id ( self ) : "asks the server at the other end for its unique id." c_result = dbus . dbus_connection_get_server_id ( self . _dbobj ) result = ct . cast ( c_result , ct . c_char_p ) . value . decode ( ) dbus . dbus_free ( c_result ) return result | asks the server at the other end for its unique id . |
24,220 | def send ( self , message ) : "puts a message in the outgoing queue." if not isinstance ( message , Message ) : raise TypeError ( "message must be a Message" ) serial = ct . c_uint ( ) if not dbus . dbus_connection_send ( self . _dbobj , message . _dbobj , ct . byref ( serial ) ) : raise CallFailed ( "dbus_connection_s... | puts a message in the outgoing queue . |
24,221 | def send_with_reply_and_block ( self , message , timeout = DBUS . TIMEOUT_USE_DEFAULT , error = None ) : "sends a message, blocks the thread until the reply is available, and returns it." if not isinstance ( message , Message ) : raise TypeError ( "message must be a Message" ) error , my_error = _get_error ( error ) re... | sends a message blocks the thread until the reply is available and returns it . |
24,222 | def list_registered ( self , parent_path ) : "lists all the object paths for which you have ObjectPathVTable handlers registered." child_entries = ct . POINTER ( ct . c_char_p ) ( ) if not dbus . dbus_connection_list_registered ( self . _dbobj , parent_path . encode ( ) , ct . byref ( child_entries ) ) : raise CallFail... | lists all the object paths for which you have ObjectPathVTable handlers registered . |
24,223 | def bus_get ( celf , type , private , error = None ) : "returns a Connection to one of the predefined D-Bus buses; type is a BUS_xxx value." error , my_error = _get_error ( error ) result = ( dbus . dbus_bus_get , dbus . dbus_bus_get_private ) [ private ] ( type , error . _dbobj ) my_error . raise_if_set ( ) if result ... | returns a Connection to one of the predefined D - Bus buses ; type is a BUS_xxx value . |
24,224 | def become_monitor ( self , rules ) : "turns the connection into one that can only receive monitoring messages." message = Message . new_method_call ( destination = DBUS . SERVICE_DBUS , path = DBUS . PATH_DBUS , iface = DBUS . INTERFACE_MONITORING , method = "BecomeMonitor" ) message . append_objects ( "asu" , ( list ... | turns the connection into one that can only receive monitoring messages . |
24,225 | def send ( self , message ) : "alternative to Connection.send_preallocated." if not isinstance ( message , Message ) : raise TypeError ( "message must be a Message" ) assert not self . _sent , "preallocated has already been sent" serial = ct . c_uint ( ) dbus . dbus_connection_send_preallocated ( self . _parent . _dbob... | alternative to Connection . send_preallocated . |
24,226 | def new_error ( self , name , message ) : "creates a new DBUS.MESSAGE_TYPE_ERROR message that is a reply to this Message." result = dbus . dbus_message_new_error ( self . _dbobj , name . encode ( ) , ( lambda : None , lambda : message . encode ( ) ) [ message != None ] ( ) ) if result == None : raise CallFailed ( "dbus... | creates a new DBUS . MESSAGE_TYPE_ERROR message that is a reply to this Message . |
24,227 | def new_method_call ( celf , destination , path , iface , method ) : "creates a new DBUS.MESSAGE_TYPE_METHOD_CALL message." result = dbus . dbus_message_new_method_call ( ( lambda : None , lambda : destination . encode ( ) ) [ destination != None ] ( ) , path . encode ( ) , ( lambda : None , lambda : iface . encode ( )... | creates a new DBUS . MESSAGE_TYPE_METHOD_CALL message . |
24,228 | def new_method_return ( self ) : "creates a new DBUS.MESSAGE_TYPE_METHOD_RETURN that is a reply to this Message." result = dbus . dbus_message_new_method_return ( self . _dbobj ) if result == None : raise CallFailed ( "dbus_message_new_method_return" ) return type ( self ) ( result ) | creates a new DBUS . MESSAGE_TYPE_METHOD_RETURN that is a reply to this Message . |
24,229 | def new_signal ( celf , path , iface , name ) : "creates a new DBUS.MESSAGE_TYPE_SIGNAL message." result = dbus . dbus_message_new_signal ( path . encode ( ) , iface . encode ( ) , name . encode ( ) ) if result == None : raise CallFailed ( "dbus_message_new_signal" ) return celf ( result ) | creates a new DBUS . MESSAGE_TYPE_SIGNAL message . |
24,230 | def copy ( self ) : "creates a copy of this Message." result = dbus . dbus_message_copy ( self . _dbobj ) if result == None : raise CallFailed ( "dbus_message_copy" ) return type ( self ) ( result ) | creates a copy of this Message . |
24,231 | def iter_init ( self ) : "creates an iterator for extracting the arguments of the Message." iter = self . ExtractIter ( None ) if dbus . dbus_message_iter_init ( self . _dbobj , iter . _dbobj ) == 0 : iter . _nulliter = True return iter | creates an iterator for extracting the arguments of the Message . |
24,232 | def iter_init_append ( self ) : "creates a Message.AppendIter for appending arguments to the Message." iter = self . AppendIter ( None ) dbus . dbus_message_iter_init_append ( self . _dbobj , iter . _dbobj ) return iter | creates a Message . AppendIter for appending arguments to the Message . |
24,233 | def error_name ( self ) : "the error name for a DBUS.MESSAGE_TYPE_ERROR message." result = dbus . dbus_message_get_error_name ( self . _dbobj ) if result != None : result = result . decode ( ) return result | the error name for a DBUS . MESSAGE_TYPE_ERROR message . |
24,234 | def destination ( self ) : "the bus name that the message is to be sent to." result = dbus . dbus_message_get_destination ( self . _dbobj ) if result != None : result = result . decode ( ) return result | the bus name that the message is to be sent to . |
24,235 | def marshal ( self ) : "serializes this Message into the wire protocol format and returns a bytes object." buf = ct . POINTER ( ct . c_ubyte ) ( ) nr_bytes = ct . c_int ( ) if not dbus . dbus_message_marshal ( self . _dbobj , ct . byref ( buf ) , ct . byref ( nr_bytes ) ) : raise CallFailed ( "dbus_message_marshal" ) r... | serializes this Message into the wire protocol format and returns a bytes object . |
24,236 | def cancel ( self ) : "tells libdbus you no longer care about the pending incoming message." dbus . dbus_pending_call_cancel ( self . _dbobj ) if self . _awaiting != None : self . _awaiting . cancel ( ) | tells libdbus you no longer care about the pending incoming message . |
24,237 | def set ( self , name , msg ) : "fills in the error name and message." dbus . dbus_set_error ( self . _dbobj , name . encode ( ) , b"%s" , msg . encode ( ) ) | fills in the error name and message . |
24,238 | def parse ( celf , s ) : "generates an Introspection tree from the given XML string description." def from_string_elts ( celf , attrs , tree ) : elts = dict ( ( k , attrs [ k ] ) for k in attrs ) child_tags = dict ( ( childclass . tag_name , childclass ) for childclass in tuple ( celf . tag_elts . values ( ) ) + ( Intr... | generates an Introspection tree from the given XML string description . |
24,239 | def unparse ( self , indent_step = 4 , max_linelen = 72 ) : "returns an XML string description of this Introspection tree." out = io . StringIO ( ) def to_string ( obj , indent ) : tag_name = obj . tag_name attrs = [ ] for attrname in obj . tag_attrs : attr = getattr ( obj , attrname ) if attr != None : if isinstance (... | returns an XML string description of this Introspection tree . |
24,240 | def as_error ( self ) : "fills in and returns an Error object that reports the specified error name and message." result = dbus . Error . init ( ) result . set ( self . args [ 0 ] , self . args [ 1 ] ) return result | fills in and returns an Error object that reports the specified error name and message . |
24,241 | async def release_name_async ( self , bus_name , error = None , timeout = DBUS . TIMEOUT_USE_DEFAULT ) : "releases a registered bus name." assert self . loop != None , "no event loop to attach coroutine to" return await self . connection . bus_release_name_async ( bus_name , error = error , timeout = timeout ) | releases a registered bus name . |
24,242 | def DefaultAdapter ( self ) : default_adapter = None for obj in mockobject . objects . keys ( ) : if obj . startswith ( '/org/bluez/' ) and 'dev_' not in obj : default_adapter = obj if default_adapter : return dbus . ObjectPath ( default_adapter , variant_level = 1 ) else : raise dbus . exceptions . DBusException ( 'No... | Retrieve the default adapter |
24,243 | def ListAdapters ( self ) : adapters = [ ] for obj in mockobject . objects . keys ( ) : if obj . startswith ( '/org/bluez/' ) and 'dev_' not in obj : adapters . append ( dbus . ObjectPath ( obj , variant_level = 1 ) ) return dbus . Array ( adapters , variant_level = 1 ) | List all known adapters |
24,244 | def CreateDevice ( self , device_address ) : device_name = 'dev_' + device_address . replace ( ':' , '_' ) . upper ( ) adapter_path = self . path path = adapter_path + '/' + device_name if path not in mockobject . objects : raise dbus . exceptions . DBusException ( 'Could not create device for %s.' % device_address , n... | Create a new device |
24,245 | def AddDevice ( self , adapter_device_name , device_address , alias ) : device_name = 'dev_' + device_address . replace ( ':' , '_' ) . upper ( ) adapter_path = '/org/bluez/' + adapter_device_name path = adapter_path + '/' + device_name if adapter_path not in mockobject . objects : raise dbus . exceptions . DBusExcepti... | Convenience method to add a Bluetooth device |
24,246 | def ListDevices ( self ) : devices = [ ] for obj in mockobject . objects . keys ( ) : if obj . startswith ( '/org/bluez/' ) and 'dev_' in obj : devices . append ( dbus . ObjectPath ( obj , variant_level = 1 ) ) return dbus . Array ( devices , variant_level = 1 ) | List all known devices |
24,247 | def FindDevice ( self , address ) : for obj in mockobject . objects . keys ( ) : if obj . startswith ( '/org/bluez/' ) and 'dev_' in obj : o = mockobject . objects [ obj ] if o . props [ DEVICE_IFACE ] [ 'Address' ] == dbus . String ( address , variant_level = 1 ) : return obj raise dbus . exceptions . DBusException ( ... | Find a specific device by bluetooth address . |
24,248 | def Connect ( self ) : device_path = self . path if device_path not in mockobject . objects : raise dbus . exceptions . DBusException ( 'No such device.' , name = 'org.bluez.Error.NoSuchDevice' ) device = mockobject . objects [ device_path ] device . props [ AUDIO_IFACE ] [ 'State' ] = dbus . String ( "connected" , var... | Connect a device |
24,249 | def Disconnect ( self ) : device_path = self . path if device_path not in mockobject . objects : raise dbus . exceptions . DBusException ( 'No such device.' , name = 'org.bluez.Error.NoSuchDevice' ) device = mockobject . objects [ device_path ] try : device . props [ AUDIO_IFACE ] [ 'State' ] = dbus . String ( "disconn... | Disconnect a device |
24,250 | def AddEthernetDevice ( self , device_name , iface_name , state ) : path = '/org/freedesktop/NetworkManager/Devices/' + device_name wired_props = { 'Carrier' : False , 'HwAddress' : dbus . String ( '78:DD:08:D2:3D:43' ) , 'PermHwAddress' : dbus . String ( '78:DD:08:D2:3D:43' ) , 'Speed' : dbus . UInt32 ( 0 ) } self . A... | Add an ethernet device . |
24,251 | def AddWiFiDevice ( self , device_name , iface_name , state ) : path = '/org/freedesktop/NetworkManager/Devices/' + device_name self . AddObject ( path , WIRELESS_DEVICE_IFACE , { 'HwAddress' : dbus . String ( '11:22:33:44:55:66' ) , 'PermHwAddress' : dbus . String ( '11:22:33:44:55:66' ) , 'Bitrate' : dbus . UInt32 ( ... | Add a WiFi Device . |
24,252 | def AddAccessPoint ( self , dev_path , ap_name , ssid , hw_address , mode , frequency , rate , strength , security ) : dev_obj = dbusmock . get_object ( dev_path ) ap_path = '/org/freedesktop/NetworkManager/AccessPoint/' + ap_name if ap_path in dev_obj . access_points : raise dbus . exceptions . DBusException ( 'Access... | Add an access point to an existing WiFi device . |
24,253 | def AddWiFiConnection ( self , dev_path , connection_name , ssid_name , key_mgmt ) : dev_obj = dbusmock . get_object ( dev_path ) connection_path = '/org/freedesktop/NetworkManager/Settings/' + connection_name connections = dev_obj . Get ( DEVICE_IFACE , 'AvailableConnections' ) settings_obj = dbusmock . get_object ( S... | Add an available connection to an existing WiFi device and access point . |
24,254 | def AddActiveConnection ( self , devices , connection_device , specific_object , name , state ) : conn_obj = dbusmock . get_object ( connection_device ) settings = conn_obj . settings conn_uuid = settings [ 'connection' ] [ 'uuid' ] conn_type = settings [ 'connection' ] [ 'type' ] device_objects = [ dbus . ObjectPath (... | Add an active connection to an existing WiFi device . |
24,255 | def RemoveAccessPoint ( self , dev_path , ap_path ) : dev_obj = dbusmock . get_object ( dev_path ) aps = dev_obj . Get ( WIRELESS_DEVICE_IFACE , 'AccessPoints' ) aps . remove ( ap_path ) dev_obj . Set ( WIRELESS_DEVICE_IFACE , 'AccessPoints' , aps ) dev_obj . access_points . remove ( ap_path ) dev_obj . EmitSignal ( WI... | Remove the specified access point . |
24,256 | def RemoveWifiConnection ( self , dev_path , connection_path ) : dev_obj = dbusmock . get_object ( dev_path ) settings_obj = dbusmock . get_object ( SETTINGS_OBJ ) connections = dev_obj . Get ( DEVICE_IFACE , 'AvailableConnections' ) main_connections = settings_obj . ListConnections ( ) if connection_path not in connec... | Remove the specified WiFi connection . |
24,257 | def RemoveActiveConnection ( self , dev_path , active_connection_path ) : self . SetDeviceDisconnected ( dev_path ) NM = dbusmock . get_object ( MANAGER_OBJ ) active_connections = NM . Get ( MANAGER_IFACE , 'ActiveConnections' ) if active_connection_path not in active_connections : return active_connections . remove ( ... | Remove the specified ActiveConnection . |
24,258 | def SettingsAddConnection ( self , connection_settings ) : if 'uuid' not in connection_settings [ 'connection' ] : connection_settings [ 'connection' ] [ 'uuid' ] = str ( uuid . uuid4 ( ) ) NM = dbusmock . get_object ( MANAGER_OBJ ) settings_obj = dbusmock . get_object ( SETTINGS_OBJ ) main_connections = settings_obj .... | Add a connection . |
24,259 | def ConnectionUpdate ( self , settings ) : connection_path = self . connection_path NM = dbusmock . get_object ( MANAGER_OBJ ) settings_obj = dbusmock . get_object ( SETTINGS_OBJ ) main_connections = settings_obj . ListConnections ( ) if connection_path not in main_connections : raise dbus . exceptions . DBusException ... | Update settings on a connection . |
24,260 | def ConnectionDelete ( self ) : connection_path = self . connection_path NM = dbusmock . get_object ( MANAGER_OBJ ) settings_obj = dbusmock . get_object ( SETTINGS_OBJ ) active_connections = NM . Get ( MANAGER_IFACE , 'ActiveConnections' ) associated_active_connections = [ ] for ac in active_connections : ac_obj = dbus... | Deletes a connection . |
24,261 | def AddAC ( self , device_name , model_name ) : path = '/org/freedesktop/UPower/devices/' + device_name self . AddObject ( path , DEVICE_IFACE , { 'PowerSupply' : dbus . Boolean ( True , variant_level = 1 ) , 'Model' : dbus . String ( model_name , variant_level = 1 ) , 'Online' : dbus . Boolean ( True , variant_level =... | Convenience method to add an AC object |
24,262 | def AddDischargingBattery ( self , device_name , model_name , percentage , seconds_to_empty ) : path = '/org/freedesktop/UPower/devices/' + device_name self . AddObject ( path , DEVICE_IFACE , { 'PowerSupply' : dbus . Boolean ( True , variant_level = 1 ) , 'IsPresent' : dbus . Boolean ( True , variant_level = 1 ) , 'Mo... | Convenience method to add a discharging battery object |
24,263 | def SetupDisplayDevice ( self , type , state , percentage , energy , energy_full , energy_rate , time_to_empty , time_to_full , is_present , icon_name , warning_level ) : if not self . api1 : raise dbus . exceptions . DBusException ( 'SetupDisplayDevice() can only be used with the 1.0 API' , name = MOCK_IFACE + '.APIVe... | Convenience method to configure DisplayDevice properties |
24,264 | def SetDeviceProperties ( self , object_path , properties ) : device = dbusmock . get_object ( object_path ) for key , value in properties . items ( ) : device . Set ( DEVICE_IFACE , key , value ) if not self . api1 : self . EmitSignal ( MAIN_IFACE , 'DeviceChanged' , 's' , [ object_path ] ) | Convenience method to Set a device s properties . |
24,265 | def AddSeat ( self , seat ) : seat_path = '/org/freedesktop/login1/seat/' + seat if seat_path in mockobject . objects : raise dbus . exceptions . DBusException ( 'Seat %s already exists' % seat , name = MOCK_IFACE + '.SeatExists' ) self . AddObject ( seat_path , 'org.freedesktop.login1.Seat' , { 'Sessions' : dbus . Arr... | Convenience method to add a seat . |
24,266 | def AddUser ( self , uid , username , active ) : user_path = '/org/freedesktop/login1/user/%i' % uid if user_path in mockobject . objects : raise dbus . exceptions . DBusException ( 'User %i already exists' % uid , name = MOCK_IFACE + '.UserExists' ) self . AddObject ( user_path , 'org.freedesktop.login1.User' , { 'Ses... | Convenience method to add a user . |
24,267 | def AddSession ( self , session_id , seat , uid , username , active ) : seat_path = dbus . ObjectPath ( '/org/freedesktop/login1/seat/' + seat ) if seat_path not in mockobject . objects : self . AddSeat ( seat ) user_path = dbus . ObjectPath ( '/org/freedesktop/login1/user/%i' % uid ) if user_path not in mockobject . o... | Convenience method to add a session . |
24,268 | def _set_up_object_manager ( self ) : if self . path == '/' : cond = 'k != \'/\'' else : cond = 'k.startswith(\'%s/\')' % self . path self . AddMethod ( OBJECT_MANAGER_IFACE , 'GetManagedObjects' , '' , 'a{oa{sa{sv}}}' , 'ret = {dbus.ObjectPath(k): objects[k].props ' + ' for k in objects.keys() if ' + cond + '}' ) sel... | Set up this mock object as a D - Bus ObjectManager . |
24,269 | def Get ( self , interface_name , property_name ) : self . log ( 'Get %s.%s' % ( interface_name , property_name ) ) if not interface_name : interface_name = self . interface try : return self . GetAll ( interface_name ) [ property_name ] except KeyError : raise dbus . exceptions . DBusException ( 'no such property ' + ... | Standard D - Bus API for getting a property value |
24,270 | def GetAll ( self , interface_name , * args , ** kwargs ) : self . log ( 'GetAll ' + interface_name ) if not interface_name : interface_name = self . interface try : return self . props [ interface_name ] except KeyError : raise dbus . exceptions . DBusException ( 'no such interface ' + interface_name , name = self . i... | Standard D - Bus API for getting all property values |
24,271 | def Set ( self , interface_name , property_name , value , * args , ** kwargs ) : self . log ( 'Set %s.%s%s' % ( interface_name , property_name , self . format_args ( ( value , ) ) ) ) try : iface_props = self . props [ interface_name ] except KeyError : raise dbus . exceptions . DBusException ( 'no such interface ' + i... | Standard D - Bus API for setting a property value |
24,272 | def AddObject ( self , path , interface , properties , methods ) : if path in objects : raise dbus . exceptions . DBusException ( 'object %s already exists' % path , name = 'org.freedesktop.DBus.Mock.NameError' ) obj = DBusMockObject ( self . bus_name , path , interface , properties ) obj . logfile = self . logfile obj... | Add a new D - Bus object to the mock |
24,273 | def RemoveObject ( self , path ) : try : objects [ path ] . remove_from_connection ( ) del objects [ path ] except KeyError : raise dbus . exceptions . DBusException ( 'object %s does not exist' % path , name = 'org.freedesktop.DBus.Mock.NameError' ) | Remove a D - Bus object from the mock |
24,274 | def Reset ( self ) : for obj_name , obj in objects . items ( ) : if obj_name != self . path : obj . remove_from_connection ( ) objects . clear ( ) for method_name in self . methods [ self . interface ] : try : delattr ( self . __class__ , method_name ) except AttributeError : pass self . _reset ( { } ) if self . _templ... | Reset the mock object state . |
24,275 | def AddMethod ( self , interface , name , in_sig , out_sig , code ) : if not interface : interface = self . interface n_args = len ( dbus . Signature ( in_sig ) ) method = lambda self , * args , ** kwargs : DBusMockObject . mock_method ( self , interface , name , in_sig , * args , ** kwargs ) dbus_method = dbus . servi... | Add a method to this object |
24,276 | def AddMethods ( self , interface , methods ) : for method in methods : self . AddMethod ( interface , * method ) | Add several methods to this object |
24,277 | def AddProperty ( self , interface , name , value ) : if not interface : interface = self . interface try : self . props [ interface ] [ name ] raise dbus . exceptions . DBusException ( 'property %s already exists' % name , name = self . interface + '.PropertyExists' ) except KeyError : pass if not ( isinstance ( value... | Add property to this object |
24,278 | def AddProperties ( self , interface , properties ) : for k , v in properties . items ( ) : self . AddProperty ( interface , k , v ) | Add several properties to this object |
24,279 | def AddTemplate ( self , template , parameters ) : try : module = load_module ( template ) except ImportError as e : raise dbus . exceptions . DBusException ( 'Cannot add template %s: %s' % ( template , str ( e ) ) , name = 'org.freedesktop.DBus.Mock.TemplateError' ) if hasattr ( module , 'IS_OBJECT_MANAGER' ) and modu... | Load a template into the mock . |
24,280 | def EmitSignal ( self , interface , name , signature , args ) : if not interface : interface = self . interface if signature == '' and len ( args ) > 0 : raise TypeError ( 'Fewer items found in D-Bus signature than in Python arguments' ) m = dbus . connection . MethodCallMessage ( 'a.b' , '/a' , 'a.b' , 'a' ) m . appen... | Emit a signal from the object . |
24,281 | def GetMethodCalls ( self , method ) : return [ ( row [ 0 ] , row [ 2 ] ) for row in self . call_log if row [ 1 ] == method ] | List all the logged calls of a particular method . |
24,282 | def mock_method ( self , interface , dbus_method , in_signature , * args , ** kwargs ) : if in_signature == '' and len ( args ) > 0 : raise TypeError ( 'Fewer items found in D-Bus signature than in Python arguments' ) m = dbus . connection . MethodCallMessage ( 'a.b' , '/a' , 'a.b' , 'a' ) m . append ( signature = in_s... | Master mock method . |
24,283 | def format_args ( self , args ) : def format_arg ( a ) : if isinstance ( a , dbus . Boolean ) : return str ( bool ( a ) ) if isinstance ( a , dbus . Byte ) : return str ( int ( a ) ) if isinstance ( a , int ) or isinstance ( a , long ) : return str ( a ) if isinstance ( a , str ) : return '"' + str ( a ) + '"' if isins... | Format a D - Bus argument tuple into an appropriate logging string . |
24,284 | def log ( self , msg ) : if self . logfile : fd = self . logfile . fileno ( ) else : fd = sys . stdout . fileno ( ) os . write ( fd , ( '%.3f %s\n' % ( time . time ( ) , msg ) ) . encode ( 'UTF-8' ) ) | Log a message prefixed with a timestamp . |
24,285 | def Introspect ( self , object_path , connection ) : cls = self . __class__ . __module__ + '.' + self . __class__ . __name__ orig_interfaces = self . _dbus_class_table [ cls ] mock_interfaces = orig_interfaces . copy ( ) for interface , methods in self . methods . items ( ) : for method in methods : mock_interfaces . s... | Return XML description of this object s interfaces methods and signals . |
24,286 | def CreateSession ( self , destination , args ) : if 'Target' not in args or args [ 'Target' ] . upper ( ) != 'PBAP' : raise dbus . exceptions . DBusException ( 'Non-PBAP targets are not currently supported by this python-dbusmock template.' , name = OBEX_MOCK_IFACE + '.Unsupported' ) client_path = '/org/bluez/obex/cli... | OBEX method to create a new transfer session . |
24,287 | def RemoveSession ( self , session_path ) : manager = mockobject . objects [ '/' ] transfer_id = 0 while session_path + '/transfer' + str ( transfer_id ) in mockobject . objects : transfer_path = session_path + '/transfer' + str ( transfer_id ) transfer_id += 1 self . RemoveObject ( transfer_path ) manager . EmitSignal... | OBEX method to remove an existing transfer session . |
24,288 | def PullAll ( self , target_file , filters ) : session_path = self . path transfer_id = 0 while session_path + '/transfer' + str ( transfer_id ) in mockobject . objects : transfer_id += 1 transfer_path = session_path + '/transfer' + str ( transfer_id ) temp_file = tempfile . NamedTemporaryFile ( suffix = '.vcf' , prefi... | OBEX method to start a pull transfer of a phone book . |
24,289 | def UpdateStatus ( self , is_complete ) : status = 'complete' if is_complete else 'active' transferred = os . path . getsize ( self . props [ TRANSFER_IFACE ] [ 'Filename' ] ) self . props [ TRANSFER_IFACE ] [ 'Status' ] = status self . props [ TRANSFER_IFACE ] [ 'Transferred' ] = dbus . UInt64 ( transferred , variant_... | Mock method to update the transfer status . |
24,290 | def AddModem ( self , name , properties ) : path = '/' + name self . AddObject ( path , 'org.ofono.Modem' , { 'Online' : dbus . Boolean ( True , variant_level = 1 ) , 'Powered' : dbus . Boolean ( True , variant_level = 1 ) , 'Lockdown' : dbus . Boolean ( False , variant_level = 1 ) , 'Emergency' : dbus . Boolean ( Fals... | Convenience method to add a modem |
24,291 | def add_voice_call_api ( mock ) : mock . AddProperty ( 'org.ofono.VoiceCallManager' , 'EmergencyNumbers' , [ '911' , '13373' ] ) mock . calls = [ ] mock . AddMethods ( 'org.ofono.VoiceCallManager' , [ ( 'GetProperties' , '' , 'a{sv}' , 'ret = self.GetAll("org.ofono.VoiceCallManager")' ) , ( 'Transfer' , '' , '' , '' ) ... | Add org . ofono . VoiceCallManager API to a mock |
24,292 | def add_netreg_api ( mock ) : mock . AddProperties ( 'org.ofono.NetworkRegistration' , { 'Mode' : 'auto' , 'Status' : 'registered' , 'LocationAreaCode' : _parameters . get ( 'LocationAreaCode' , 987 ) , 'CellId' : _parameters . get ( 'CellId' , 10203 ) , 'MobileCountryCode' : _parameters . get ( 'MobileCountryCode' , '... | Add org . ofono . NetworkRegistration API to a mock |
24,293 | def add_simmanager_api ( self , mock ) : iface = 'org.ofono.SimManager' mock . AddProperties ( iface , { 'BarredDialing' : _parameters . get ( 'BarredDialing' , False ) , 'CardIdentifier' : _parameters . get ( 'CardIdentifier' , new_iccid ( self ) ) , 'FixedDialing' : _parameters . get ( 'FixedDialing' , False ) , 'Loc... | Add org . ofono . SimManager API to a mock |
24,294 | def add_connectionmanager_api ( mock ) : iface = 'org.ofono.ConnectionManager' mock . AddProperties ( iface , { 'Attached' : _parameters . get ( 'Attached' , True ) , 'Bearer' : _parameters . get ( 'Bearer' , 'gprs' ) , 'RoamingAllowed' : _parameters . get ( 'RoamingAllowed' , False ) , 'Powered' : _parameters . get ( ... | Add org . ofono . ConnectionManager API to a mock |
24,295 | def BlockDevice ( self , adapter_device_name , device_address ) : device_name = 'dev_' + device_address . replace ( ':' , '_' ) . upper ( ) adapter_path = '/org/bluez/' + adapter_device_name device_path = adapter_path + '/' + device_name if adapter_path not in mockobject . objects : raise dbus . exceptions . DBusExcept... | Convenience method to mark an existing device as blocked . |
24,296 | def create ( self , instance , errors ) : if errors : return self . errors ( errors ) return self . created ( instance ) | Create an instance of a model . |
24,297 | def patch ( self , instance , errors ) : if errors : return self . errors ( errors ) return self . updated ( instance ) | Partially update a model instance . |
24,298 | def put ( self , instance , errors ) : if errors : return self . errors ( errors ) return self . updated ( instance ) | Update a model instance . |
24,299 | def before_init_app ( self , app : FlaskUnchained ) : from . templates import ( UnchainedJinjaEnvironment , UnchainedJinjaLoader ) app . jinja_environment = UnchainedJinjaEnvironment app . jinja_options = { ** app . jinja_options , 'loader' : UnchainedJinjaLoader ( app ) } app . jinja_env . globals [ 'url_for' ] = url_... | Configure the Jinja environment and template loader . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.