idx int64 0 63k | question stringlengths 53 5.28k | target stringlengths 5 805 |
|---|---|---|
59,600 | def get_alias ( self ) : alias = None if self . alias : alias = self . alias elif self . auto_alias : alias = self . auto_alias return alias | Gets the alias for the table or the auto_alias if one is set . If there isn t any kind of alias None is returned . |
59,601 | def add_field ( self , field ) : field = FieldFactory ( field , ) field . set_table ( self ) field_name = field . get_name ( ) for existing_field in self . fields : if existing_field . get_name ( ) == field_name : return None self . before_add_field ( field ) field . before_add ( ) if field . ignore is False : self . f... | Adds a field to this table |
59,602 | def remove_field ( self , field ) : new_field = FieldFactory ( field , ) new_field . set_table ( self ) new_field_identifier = new_field . get_identifier ( ) for field in self . fields : if field . get_identifier ( ) == new_field_identifier : self . fields . remove ( field ) return field return None | Removes a field from this table |
59,603 | def add_fields ( self , fields ) : if isinstance ( fields , string_types ) : fields = [ fields ] elif type ( fields ) is tuple : fields = list ( fields ) field_objects = [ self . add_field ( field ) for field in fields ] return field_objects | Adds all of the passed fields to the table s current field list |
59,604 | def find_field ( self , field = None , alias = None ) : if alias : field = alias field = FieldFactory ( field , table = self , alias = alias ) identifier = field . get_identifier ( ) for field in self . fields : if field . get_identifier ( ) == identifier : return field return None | Finds a field by name or alias . |
59,605 | def init_defaults ( self ) : super ( SimpleTable , self ) . init_defaults ( ) self . name = self . table | Sets the name of the table to the passed in table value |
59,606 | def init_defaults ( self ) : super ( ModelTable , self ) . init_defaults ( ) self . model = self . table self . name = self . model . _meta . db_table | Sets a model instance variable to the table value and sets the name to the table name as determined from the model class |
59,607 | def init_defaults ( self ) : super ( QueryTable , self ) . init_defaults ( ) self . query = self . table self . query . is_inner = True | Sets a query instance variable to the table value |
59,608 | def run_command ( cmd_to_run ) : with tempfile . TemporaryFile ( ) as stdout_file , tempfile . TemporaryFile ( ) as stderr_file : popen = subprocess . Popen ( cmd_to_run , stdout = stdout_file , stderr = stderr_file ) popen . wait ( ) stderr_file . seek ( 0 ) stdout_file . seek ( 0 ) stderr = stderr_file . read ( ) std... | Wrapper around subprocess that pipes the stderr and stdout from cmd_to_run to temporary files . Using the temporary files gets around subprocess . PIPE s issues with handling large buffers . |
59,609 | def log ( self , level , prefix = '' ) : logging . log ( level , "%sname: %s" , prefix , self . __name ) logging . log ( level , "%soptions: %s" , prefix , self . __options ) | Writes the contents of the Extension to the logging system . |
59,610 | def specbits ( self ) : bits = [ ] for opt in sorted ( self . __options ) : m = re . match ( r'^! (.*)' , opt ) if m : bits . extend ( [ '!' , "--%s" % m . group ( 1 ) ] ) else : bits . append ( "--%s" % opt ) optval = self . __options [ opt ] if isinstance ( optval , list ) : bits . extend ( optval ) else : bits . app... | Returns the array of arguments that would be given to iptables for the current Extension . |
59,611 | def log ( self , level , prefix = '' ) : logging . log ( level , "%sin interface: %s" , prefix , self . in_interface ) logging . log ( level , "%sout interface: %s" , prefix , self . out_interface ) logging . log ( level , "%ssource: %s" , prefix , self . source ) logging . log ( level , "%sdestination: %s" , prefix , ... | Writes the contents of the Rule to the logging system . |
59,612 | def specbits ( self ) : def host_bits ( opt , optval ) : m = re . match ( r'^!\s*(.*)' , optval ) if m : return [ '!' , opt , m . group ( 1 ) ] else : return [ opt , optval ] bits = [ ] if self . protocol : bits . extend ( host_bits ( '-p' , self . protocol ) ) if self . in_interface : bits . extend ( host_bits ( '-i' ... | Returns the array of arguments that would be given to iptables for the current Rule . |
59,613 | def parse_chains ( data ) : chains = odict ( ) for line in data . splitlines ( True ) : m = re_chain . match ( line ) if m : policy = None if m . group ( 2 ) != '-' : policy = m . group ( 2 ) chains [ m . group ( 1 ) ] = { 'policy' : policy , 'packets' : int ( m . group ( 3 ) ) , 'bytes' : int ( m . group ( 4 ) ) , } r... | Parse the chain definitions . |
59,614 | def parse_rules ( data , chain ) : rules = [ ] for line in data . splitlines ( True ) : m = re_rule . match ( line ) if m and m . group ( 3 ) == chain : rule = parse_rule ( m . group ( 4 ) ) rule . packets = int ( m . group ( 1 ) ) rule . bytes = int ( m . group ( 2 ) ) rules . append ( rule ) return rules | Parse the rules for the specified chain . |
59,615 | def _get_new_connection ( self , conn_params ) : self . __connection_string = conn_params . get ( 'connection_string' , '' ) conn = self . Database . connect ( ** conn_params ) return conn | Opens a connection to the database . |
59,616 | def get_connection_params ( self ) : from django . conf import settings settings_dict = self . settings_dict options = settings_dict . get ( 'OPTIONS' , { } ) autocommit = options . get ( 'autocommit' , False ) conn_params = { 'server' : settings_dict [ 'HOST' ] , 'database' : settings_dict [ 'NAME' ] , 'user' : settin... | Returns a dict of parameters suitable for get_new_connection . |
59,617 | def create_cursor ( self , name = None ) : cursor = self . connection . cursor ( ) cursor . tzinfo_factory = self . tzinfo_factory return cursor | Creates a cursor . Assumes that a connection is established . |
59,618 | def __get_dbms_version ( self , make_connection = True ) : major , minor , _ , _ = self . get_server_version ( make_connection = make_connection ) return '{}.{}' . format ( major , minor ) | Returns the DBMS Version string |
59,619 | def get_buffer ( self ) : buffer = [ ] for table in self . __tables : buffer . extend ( table . get_buffer ( ) ) return buffer | Get the change buffers . |
59,620 | def start ( self ) : self . clear ( ) self . setDefaultPolicy ( ) self . acceptIcmp ( ) self . acceptInput ( 'lo' ) | Start the firewall . |
59,621 | def list_rules ( self , chainname ) : data = self . __run ( [ self . __iptables_save , '-t' , self . __name , '-c' ] ) return netfilter . parser . parse_rules ( data , chainname ) | Returns a list of Rules in the specified chain . |
59,622 | def commit ( self ) : while len ( self . __buffer ) > 0 : self . __run ( self . __buffer . pop ( 0 ) ) | Commits any buffered commands . This is only useful if auto_commit is False . |
59,623 | async def numbered_page ( self ) : to_delete = [ ] to_delete . append ( await self . bot . send_message ( self . message . channel , 'What page do you want to go to?' ) ) msg = await self . bot . wait_for_message ( author = self . author , channel = self . message . channel , check = lambda m : m . content . isdigit ( ... | lets you type a page number to go to |
59,624 | async def show_help ( self ) : e = discord . Embed ( ) messages = [ 'Welcome to the interactive paginator!\n' ] messages . append ( 'This interactively allows you to see pages of text by navigating with ' 'reactions. They are as follows:\n' ) for ( emoji , func ) in self . reaction_emojis : messages . append ( '%s %s' ... | shows this message |
59,625 | async def stop_pages ( self ) : await self . bot . delete_message ( self . message ) self . paginating = False | stops the interactive pagination session |
59,626 | async def paginate ( self ) : await self . show_page ( 1 , first = True ) while self . paginating : react = await self . bot . wait_for_reaction ( message = self . message , check = self . react_check , timeout = 120.0 ) if react is None : self . paginating = False try : await self . bot . clear_reactions ( self . mess... | Actually paginate the entries and run the interactive loop if necessary . |
59,627 | async def _senddms ( self ) : data = self . bot . config . get ( "meta" , { } ) tosend = data . get ( 'send_dms' , True ) data [ 'send_dms' ] = not tosend await self . bot . config . put ( 'meta' , data ) await self . bot . responses . toggle ( message = "Forwarding of DMs to owner has been {status}." , success = data ... | Toggles sending DMs to owner . |
59,628 | async def _quit ( self ) : await self . bot . responses . failure ( message = "Bot shutting down" ) await self . bot . logout ( ) | Quits the bot . |
59,629 | async def _setcolor ( self , * , color : discord . Colour ) : data = self . bot . config . get ( "meta" , { } ) data [ 'default_color' ] = str ( color ) await self . bot . config . put ( 'meta' , data ) await self . bot . responses . basic ( message = "The default color has been updated." ) | Sets the default color of embeds . |
59,630 | async def _do ( self , ctx , times : int , * , command ) : msg = copy . copy ( ctx . message ) msg . content = command for i in range ( times ) : await self . bot . process_commands ( msg ) | Repeats a command a specified number of times . |
59,631 | async def disable ( self , ctx , * , command : str ) : command = command . lower ( ) if command in ( 'enable' , 'disable' ) : return await self . bot . responses . failure ( message = 'Cannot disable that command.' ) if command not in self . bot . commands : return await self . bot . responses . failure ( message = 'Co... | Disables a command for this server . |
59,632 | async def enable ( self , ctx , * , command : str ) : command = command . lower ( ) guild_id = ctx . message . server . id cmds = self . config . get ( 'commands' , { } ) entries = cmds . get ( guild_id , [ ] ) try : entries . remove ( command ) except KeyError : await self . bot . responses . failure ( message = 'The ... | Enables a command for this server . |
59,633 | async def ignore ( self , ctx ) : if ctx . invoked_subcommand is None : await self . bot . say ( 'Invalid subcommand passed: {0.subcommand_passed}' . format ( ctx ) ) | Handles the bot s ignore lists . |
59,634 | async def ignore_list ( self , ctx ) : ignored = self . config . get ( 'ignored' , [ ] ) channel_ids = set ( c . id for c in ctx . message . server . channels ) result = [ ] for channel in ignored : if channel in channel_ids : result . append ( '<#{}>' . format ( channel ) ) if result : await self . bot . responses . b... | Tells you what channels are currently ignored in this server . |
59,635 | async def channel_cmd ( self , ctx , * , channel : discord . Channel = None ) : if channel is None : channel = ctx . message . channel ignored = self . config . get ( 'ignored' , [ ] ) if channel . id in ignored : await self . bot . responses . failure ( message = 'That channel is already ignored.' ) return ignored . a... | Ignores a specific channel from being processed . |
59,636 | async def _all ( self , ctx ) : ignored = self . config . get ( 'ignored' , [ ] ) channels = ctx . message . server . channels ignored . extend ( c . id for c in channels if c . type == discord . ChannelType . text ) await self . config . put ( 'ignored' , list ( set ( ignored ) ) ) await self . bot . responses . succe... | Ignores every channel in the server from being processed . |
59,637 | async def unignore ( self , ctx , * channels : discord . Channel ) : if len ( channels ) == 0 : channels = ( ctx . message . channel , ) ignored = self . config . get ( 'ignored' , [ ] ) result = [ ] for channel in channels : try : ignored . remove ( channel . id ) except ValueError : pass else : result . append ( '<#{... | Unignores channels from being processed . |
59,638 | async def unignore_all ( self , ctx ) : channels = [ c for c in ctx . message . server . channels if c . type is discord . ChannelType . text ] await ctx . invoke ( self . unignore , * channels ) | Unignores all channels in this server from being processed . |
59,639 | async def cleanup ( self , ctx , search : int = 100 ) : spammers = Counter ( ) channel = ctx . message . channel prefixes = self . bot . command_prefix if callable ( prefixes ) : prefixes = prefixes ( self . bot , ctx . message ) def is_possible_command_invoke ( entry ) : valid_call = any ( entry . content . startswith... | Cleans up the bot s messages from the channel . |
59,640 | async def plonk ( self , ctx , * , member : discord . Member ) : plonks = self . config . get ( 'plonks' , { } ) guild_id = ctx . message . server . id db = plonks . get ( guild_id , [ ] ) if member . id in db : await self . bot . responses . failure ( message = 'That user is already bot banned in this server.' ) retur... | Bans a user from using the bot . |
59,641 | async def plonks ( self , ctx ) : plonks = self . config . get ( 'plonks' , { } ) guild = ctx . message . server db = plonks . get ( guild . id , [ ] ) members = '\n' . join ( map ( str , filter ( None , map ( guild . get_member , db ) ) ) ) if members : await self . bot . responses . basic ( title = "Plonked Users:" ,... | Shows members banned from the bot . |
59,642 | async def unplonk ( self , ctx , * , member : discord . Member ) : plonks = self . config . get ( 'plonks' , { } ) guild_id = ctx . message . server . id db = plonks . get ( guild_id , [ ] ) try : db . remove ( member . id ) except ValueError : await self . bot . responses . failure ( message = '%s is not banned from u... | Unbans a user from using the bot . |
59,643 | async def join ( self , ctx ) : perms = discord . Permissions . none ( ) perms . read_messages = True perms . send_messages = True perms . manage_messages = True perms . embed_links = True perms . read_message_history = True perms . attach_files = True perms . add_reactions = True await self . bot . send_message ( ctx ... | Sends you the bot invite link . |
59,644 | async def info ( self , ctx , * , member : discord . Member = None ) : channel = ctx . message . channel if member is None : member = ctx . message . author e = discord . Embed ( ) roles = [ role . name . replace ( '@' , '@\u200b' ) for role in member . roles ] shared = sum ( 1 for m in self . bot . get_all_members ( )... | Shows info about a member . |
59,645 | async def put ( self , key , value , * args ) : self . _db [ key ] = value await self . save ( ) | Edits a data entry . |
59,646 | async def addreaction ( self , ctx , * , reactor = "" ) : if not reactor : await self . bot . say ( "What should I react to?" ) response = await self . bot . wait_for_message ( author = ctx . message . author ) reactor = response . content data = self . config . get ( ctx . message . server . id , { } ) keyword = data ... | Interactively adds a custom reaction |
59,647 | async def listreactions ( self , ctx ) : data = self . config . get ( ctx . message . server . id , { } ) if not data : await self . bot . responses . failure ( message = "There are no reactions on this server." ) return try : pager = Pages ( self . bot , message = ctx . message , entries = list ( data . keys ( ) ) ) p... | Lists all the reactions for the server |
59,648 | async def viewreaction ( self , ctx , * , reactor : str ) : data = self . config . get ( ctx . message . server . id , { } ) keyword = data . get ( reactor , { } ) if not keyword : await self . bot . responses . failure ( message = "Reaction '{}' was not found." . format ( reactor ) ) return response = data . get ( rea... | Views a specific reaction |
59,649 | async def _default_help_command ( ctx , * commands : str ) : bot = ctx . bot destination = ctx . message . author if bot . pm_help else ctx . message . channel def repl ( obj ) : return _mentions_transforms . get ( obj . group ( 0 ) , '' ) if len ( commands ) == 0 : pages = bot . formatter . format_help_for ( ctx , bot... | Shows this message . |
59,650 | def nla_ok ( nla , remaining ) : return remaining . value >= nla . SIZEOF and nla . SIZEOF <= nla . nla_len <= remaining . value | Check if the attribute header and payload can be accessed safely . |
59,651 | def nla_next ( nla , remaining ) : totlen = int ( NLA_ALIGN ( nla . nla_len ) ) remaining . value -= totlen return nlattr ( bytearray_ptr ( nla . bytearray , totlen ) ) | Return next attribute in a stream of attributes . |
59,652 | def nla_parse ( tb , maxtype , head , len_ , policy ) : rem = c_int ( ) for nla in nla_for_each_attr ( head , len_ , rem ) : type_ = nla_type ( nla ) if type_ > maxtype : continue if policy : err = validate_nla ( nla , maxtype , policy ) if err < 0 : return err if type_ in tb and tb [ type_ ] : _LOGGER . debug ( 'Attri... | Create attribute index based on a stream of attributes . |
59,653 | def nla_for_each_attr ( head , len_ , rem ) : pos = head rem . value = len_ while nla_ok ( pos , rem ) : yield pos pos = nla_next ( pos , rem ) | Iterate over a stream of attributes . |
59,654 | def nla_for_each_nested ( nla , rem ) : pos = nlattr ( nla_data ( nla ) ) rem . value = nla_len ( nla ) while nla_ok ( pos , rem ) : yield pos pos = nla_next ( pos , rem ) | Iterate over a stream of nested attributes . |
59,655 | def nla_find ( head , len_ , attrtype ) : rem = c_int ( ) for nla in nla_for_each_attr ( head , len_ , rem ) : if nla_type ( nla ) == attrtype : return nla return None | Find a single attribute in a stream of attributes . |
59,656 | def nla_reserve ( msg , attrtype , attrlen ) : tlen = NLMSG_ALIGN ( msg . nm_nlh . nlmsg_len ) + nla_total_size ( attrlen ) if tlen > msg . nm_size : return None nla = nlattr ( nlmsg_tail ( msg . nm_nlh ) ) nla . nla_type = attrtype nla . nla_len = nla_attr_size ( attrlen ) if attrlen : padlen = nla_padlen ( attrlen ) ... | Reserve space for an attribute . |
59,657 | def nla_put ( msg , attrtype , datalen , data ) : nla = nla_reserve ( msg , attrtype , datalen ) if not nla : return - NLE_NOMEM if datalen <= 0 : return 0 nla_data ( nla ) [ : datalen ] = data [ : datalen ] _LOGGER . debug ( 'msg 0x%x: attr <0x%x> %d: Wrote %d bytes at offset +%d' , id ( msg ) , id ( nla ) , nla . nla... | Add a unspecific attribute to Netlink message . |
59,658 | def nla_put_data ( msg , attrtype , data ) : return nla_put ( msg , attrtype , len ( data ) , data ) | Add abstract data as unspecific attribute to Netlink message . |
59,659 | def nla_put_u8 ( msg , attrtype , value ) : data = bytearray ( value if isinstance ( value , c_uint8 ) else c_uint8 ( value ) ) return nla_put ( msg , attrtype , SIZEOF_U8 , data ) | Add 8 bit integer attribute to Netlink message . |
59,660 | def nla_put_u16 ( msg , attrtype , value ) : data = bytearray ( value if isinstance ( value , c_uint16 ) else c_uint16 ( value ) ) return nla_put ( msg , attrtype , SIZEOF_U16 , data ) | Add 16 bit integer attribute to Netlink message . |
59,661 | def nla_put_u32 ( msg , attrtype , value ) : data = bytearray ( value if isinstance ( value , c_uint32 ) else c_uint32 ( value ) ) return nla_put ( msg , attrtype , SIZEOF_U32 , data ) | Add 32 bit integer attribute to Netlink message . |
59,662 | def nla_put_u64 ( msg , attrtype , value ) : data = bytearray ( value if isinstance ( value , c_uint64 ) else c_uint64 ( value ) ) return nla_put ( msg , attrtype , SIZEOF_U64 , data ) | Add 64 bit integer attribute to Netlink message . |
59,663 | def nla_put_string ( msg , attrtype , value ) : data = bytearray ( value ) + bytearray ( b'\0' ) return nla_put ( msg , attrtype , len ( data ) , data ) | Add string attribute to Netlink message . |
59,664 | def nla_put_msecs ( msg , attrtype , msecs ) : if isinstance ( msecs , c_uint64 ) : pass elif isinstance ( msecs , c_ulong ) : msecs = c_uint64 ( msecs . value ) else : msecs = c_uint64 ( msecs ) return nla_put_u64 ( msg , attrtype , msecs ) | Add msecs Netlink attribute to Netlink message . |
59,665 | def nla_put_nested ( msg , attrtype , nested ) : _LOGGER . debug ( 'msg 0x%x: attr <> %d: adding msg 0x%x as nested attribute' , id ( msg ) , attrtype , id ( nested ) ) return nla_put ( msg , attrtype , nlmsg_datalen ( nested . nm_nlh ) , nlmsg_data ( nested . nm_nlh ) ) | Add nested attributes to Netlink message . |
59,666 | def nla_parse_nested ( tb , maxtype , nla , policy ) : return nla_parse ( tb , maxtype , nlattr ( nla_data ( nla ) ) , nla_len ( nla ) , policy ) | Create attribute index based on nested attribute . |
59,667 | def genl_send_simple ( sk , family , cmd , version , flags ) : hdr = genlmsghdr ( cmd = cmd , version = version ) return int ( nl_send_simple ( sk , family , flags , hdr , hdr . SIZEOF ) ) | Send a Generic Netlink message consisting only of a header . |
59,668 | def genlmsg_valid_hdr ( nlh , hdrlen ) : if not nlmsg_valid_hdr ( nlh , GENL_HDRLEN ) : return False ghdr = genlmsghdr ( nlmsg_data ( nlh ) ) if genlmsg_len ( ghdr ) < NLMSG_ALIGN ( hdrlen ) : return False return True | Validate Generic Netlink message headers . |
59,669 | def genlmsg_parse ( nlh , hdrlen , tb , maxtype , policy ) : if not genlmsg_valid_hdr ( nlh , hdrlen ) : return - NLE_MSG_TOOSHORT ghdr = genlmsghdr ( nlmsg_data ( nlh ) ) return int ( nla_parse ( tb , maxtype , genlmsg_attrdata ( ghdr , hdrlen ) , genlmsg_attrlen ( ghdr , hdrlen ) , policy ) ) | Parse Generic Netlink message including attributes . |
59,670 | def genlmsg_len ( gnlh ) : nlh = nlmsghdr ( bytearray_ptr ( gnlh . bytearray , - NLMSG_HDRLEN , oob = True ) ) return nlh . nlmsg_len - GENL_HDRLEN - NLMSG_HDRLEN | Return length of message payload including user header . |
59,671 | def genlmsg_put ( msg , port , seq , family , hdrlen , flags , cmd , version ) : hdr = genlmsghdr ( cmd = cmd , version = version ) nlh = nlmsg_put ( msg , port , seq , family , GENL_HDRLEN + hdrlen , flags ) if nlh is None : return None nlmsg_data ( nlh ) [ : hdr . SIZEOF ] = hdr . bytearray [ : hdr . SIZEOF ] _LOGGER... | Add Generic Netlink headers to Netlink message . |
59,672 | def nl_cb_call ( cb , type_ , msg ) : cb . cb_active = type_ ret = cb . cb_set [ type_ ] ( msg , cb . cb_args [ type_ ] ) cb . cb_active = 10 + 1 return int ( ret ) | Call a callback function . |
59,673 | def nl_pad ( self , value ) : self . bytearray [ self . _get_slicers ( 1 ) ] = bytearray ( c_ushort ( value or 0 ) ) | Pad setter . |
59,674 | def nl_groups ( self , value ) : self . bytearray [ self . _get_slicers ( 3 ) ] = bytearray ( c_uint32 ( value or 0 ) ) | Group setter . |
59,675 | def nlmsg_type ( self , value ) : self . bytearray [ self . _get_slicers ( 1 ) ] = bytearray ( c_uint16 ( value or 0 ) ) | Message content setter . |
59,676 | def nlmsg_seq ( self , value ) : self . bytearray [ self . _get_slicers ( 3 ) ] = bytearray ( c_uint32 ( value or 0 ) ) | Sequence setter . |
59,677 | def nl_socket_alloc ( cb = None ) : cb = cb or nl_cb_alloc ( default_cb ) if not cb : return None sk = nl_sock ( ) sk . s_cb = cb sk . s_local . nl_family = getattr ( socket , 'AF_NETLINK' , - 1 ) sk . s_peer . nl_family = getattr ( socket , 'AF_NETLINK' , - 1 ) sk . s_seq_expect = sk . s_seq_next = int ( time . time (... | Allocate new Netlink socket . Does not yet actually open a socket . |
59,678 | def nl_socket_add_memberships ( sk , * group ) : if sk . s_fd == - 1 : return - NLE_BAD_SOCK for grp in group : if not grp : break if grp < 0 : return - NLE_INVAL try : sk . socket_instance . setsockopt ( SOL_NETLINK , NETLINK_ADD_MEMBERSHIP , grp ) except OSError as exc : return - nl_syserr2nlerr ( exc . errno ) retur... | Join groups . |
59,679 | def nl_socket_drop_memberships ( sk , * group ) : if sk . s_fd == - 1 : return - NLE_BAD_SOCK for grp in group : if not grp : break if grp < 0 : return - NLE_INVAL try : sk . socket_instance . setsockopt ( SOL_NETLINK , NETLINK_DROP_MEMBERSHIP , grp ) except OSError as exc : return - nl_syserr2nlerr ( exc . errno ) ret... | Leave groups . |
59,680 | def nl_socket_modify_cb ( sk , type_ , kind , func , arg ) : return int ( nl_cb_set ( sk . s_cb , type_ , kind , func , arg ) ) | Modify the callback handler associated with the socket . |
59,681 | def nl_socket_modify_err_cb ( sk , kind , func , arg ) : return int ( nl_cb_err ( sk . s_cb , kind , func , arg ) ) | Modify the error callback handler associated with the socket . |
59,682 | def nl_socket_set_buffer_size ( sk , rxbuf , txbuf ) : rxbuf = 32768 if rxbuf <= 0 else rxbuf txbuf = 32768 if txbuf <= 0 else txbuf if sk . s_fd == - 1 : return - NLE_BAD_SOCK try : sk . socket_instance . setsockopt ( socket . SOL_SOCKET , socket . SO_SNDBUF , txbuf ) except OSError as exc : return - nl_syserr2nlerr (... | Set socket buffer size of Netlink socket . |
59,683 | def cmd ( self , value ) : self . bytearray [ self . _get_slicers ( 0 ) ] = bytearray ( c_uint8 ( value or 0 ) ) | Command setter . |
59,684 | def version ( self , value ) : self . bytearray [ self . _get_slicers ( 1 ) ] = bytearray ( c_uint8 ( value or 0 ) ) | Version setter . |
59,685 | def reserved ( self , value ) : self . bytearray [ self . _get_slicers ( 2 ) ] = bytearray ( c_uint16 ( value or 0 ) ) | Reserved setter . |
59,686 | def _get ( out_parsed , in_bss , key , parser_func ) : short_key = key [ 12 : ] . lower ( ) key_integer = getattr ( nl80211 , key ) if in_bss . get ( key_integer ) is None : return dict ( ) data = parser_func ( in_bss [ key_integer ] ) if parser_func == libnl . attr . nla_data : data = data [ : libnl . attr . nla_len (... | Handle calling the parser function to convert bytearray data into Python data types . |
59,687 | def _fetch ( in_parsed , * keys ) : for ie in ( 'information_elements' , 'beacon_ies' ) : target = in_parsed . get ( ie , { } ) for key in keys : target = target . get ( key , { } ) if target : return target return None | Retrieve nested dict data from either information elements or beacon IES dicts . |
59,688 | def nl_cb_alloc ( kind ) : if kind < 0 or kind > NL_CB_KIND_MAX : return None cb = nl_cb ( ) cb . cb_active = NL_CB_TYPE_MAX + 1 for i in range ( NL_CB_TYPE_MAX ) : nl_cb_set ( cb , i , kind , None , None ) nl_cb_err ( cb , kind , None , None ) return cb | Allocate a new callback handle . |
59,689 | def nl_cb_set ( cb , type_ , kind , func , arg ) : if type_ < 0 or type_ > NL_CB_TYPE_MAX or kind < 0 or kind > NL_CB_KIND_MAX : return - NLE_RANGE if kind == NL_CB_CUSTOM : cb . cb_set [ type_ ] = func cb . cb_args [ type_ ] = arg else : cb . cb_set [ type_ ] = cb_def [ type_ ] [ kind ] cb . cb_args [ type_ ] = arg re... | Set up a callback . Updates cb in place . |
59,690 | def nl_cb_err ( cb , kind , func , arg ) : if kind < 0 or kind > NL_CB_KIND_MAX : return - NLE_RANGE if kind == NL_CB_CUSTOM : cb . cb_err = func cb . cb_err_arg = arg else : cb . cb_err = cb_err_def [ kind ] cb . cb_err_arg = arg return 0 | Set up an error callback . Updates cb in place . |
59,691 | def ifi_index ( self , value ) : self . bytearray [ self . _get_slicers ( 3 ) ] = bytearray ( c_int ( value or 0 ) ) | Index setter . |
59,692 | def ifi_change ( self , value ) : self . bytearray [ self . _get_slicers ( 5 ) ] = bytearray ( c_uint ( value or 0 ) ) | Change setter . |
59,693 | def _class_factory ( base ) : class ClsPyPy ( base ) : def __repr__ ( self ) : return repr ( base ( super ( ClsPyPy , self ) . value ) ) @ classmethod def from_buffer ( cls , ba ) : try : integer = struct . unpack_from ( getattr ( cls , '_type_' ) , ba ) [ 0 ] except struct . error : len_ = len ( ba ) size = struct . c... | Create subclasses of ctypes . |
59,694 | def pid ( self , value ) : self . bytearray [ self . _get_slicers ( 0 ) ] = bytearray ( c_int32 ( value or 0 ) ) | Process ID setter . |
59,695 | def uid ( self , value ) : self . bytearray [ self . _get_slicers ( 1 ) ] = bytearray ( c_int32 ( value or 0 ) ) | User ID setter . |
59,696 | def gid ( self , value ) : self . bytearray [ self . _get_slicers ( 2 ) ] = bytearray ( c_int32 ( value or 0 ) ) | Group ID setter . |
59,697 | def put_skeleton_files_on_disk ( metadata_type , where , github_template = None , params = { } ) : api_name = params [ "api_name" ] file_name = github_template [ "file_name" ] template_source = config . connection . get_plugin_client_setting ( 'mm_template_source' , 'joeferraro/MavensMate-Templates/master' ) template_l... | Generates file based on jinja2 templates |
59,698 | def genl_ctrl_probe_by_name ( sk , name ) : ret = genl_family_alloc ( ) if not ret : return None genl_family_set_name ( ret , name ) msg = nlmsg_alloc ( ) orig = nl_socket_get_cb ( sk ) cb = nl_cb_clone ( orig ) genlmsg_put ( msg , NL_AUTO_PORT , NL_AUTO_SEQ , GENL_ID_CTRL , 0 , 0 , CTRL_CMD_GETFAMILY , 1 ) nla_put_str... | Look up generic Netlink family by family name querying the kernel directly . |
59,699 | def genl_ctrl_resolve ( sk , name ) : family = genl_ctrl_probe_by_name ( sk , name ) if family is None : return - NLE_OBJ_NOTFOUND return int ( genl_family_get_id ( family ) ) | Resolve Generic Netlink family name to numeric identifier . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.