repo
stringclasses
85 values
path
stringlengths
8
121
func_name
stringlengths
1
82
original_string
stringlengths
112
65.5k
language
stringclasses
1 value
code
stringlengths
112
65.5k
code_tokens
listlengths
20
4.09k
docstring
stringlengths
3
46.3k
docstring_tokens
listlengths
1
564
sha
stringclasses
85 values
url
stringlengths
93
218
partition
stringclasses
1 value
saltstack/salt
salt/utils/virtualbox.py
vb_list_machines
def vb_list_machines(**kwargs): ''' Which machines does the hypervisor have @param kwargs: Passed to vb_xpcom_to_attribute_dict to filter the attributes @type kwargs: dict @return: Untreated dicts of the machines known to the hypervisor @rtype: [{}] ''' manager = vb_get_manager() mac...
python
def vb_list_machines(**kwargs): ''' Which machines does the hypervisor have @param kwargs: Passed to vb_xpcom_to_attribute_dict to filter the attributes @type kwargs: dict @return: Untreated dicts of the machines known to the hypervisor @rtype: [{}] ''' manager = vb_get_manager() mac...
[ "def", "vb_list_machines", "(", "*", "*", "kwargs", ")", ":", "manager", "=", "vb_get_manager", "(", ")", "machines", "=", "manager", ".", "getArray", "(", "vb_get_box", "(", ")", ",", "'machines'", ")", "return", "[", "vb_xpcom_to_attribute_dict", "(", "mac...
Which machines does the hypervisor have @param kwargs: Passed to vb_xpcom_to_attribute_dict to filter the attributes @type kwargs: dict @return: Untreated dicts of the machines known to the hypervisor @rtype: [{}]
[ "Which", "machines", "does", "the", "hypervisor", "have" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/virtualbox.py#L329-L342
train
saltstack/salt
salt/utils/virtualbox.py
vb_create_machine
def vb_create_machine(name=None): ''' Creates a machine on the virtualbox hypervisor TODO pass more params to customize machine creation @param name: @type name: str @return: Representation of the created machine @rtype: dict ''' vbox = vb_get_box() log.info('Create virtualbox m...
python
def vb_create_machine(name=None): ''' Creates a machine on the virtualbox hypervisor TODO pass more params to customize machine creation @param name: @type name: str @return: Representation of the created machine @rtype: dict ''' vbox = vb_get_box() log.info('Create virtualbox m...
[ "def", "vb_create_machine", "(", "name", "=", "None", ")", ":", "vbox", "=", "vb_get_box", "(", ")", "log", ".", "info", "(", "'Create virtualbox machine %s '", ",", "name", ")", "groups", "=", "None", "os_type_id", "=", "'Other'", "new_machine", "=", "vbox"...
Creates a machine on the virtualbox hypervisor TODO pass more params to customize machine creation @param name: @type name: str @return: Representation of the created machine @rtype: dict
[ "Creates", "a", "machine", "on", "the", "virtualbox", "hypervisor" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/virtualbox.py#L345-L368
train
saltstack/salt
salt/utils/virtualbox.py
vb_clone_vm
def vb_clone_vm( name=None, clone_from=None, clone_mode=0, timeout=10000, **kwargs ): ''' Tells virtualbox to create a VM by cloning from an existing one @param name: Name for the new VM @type name: str @param clone_from: @type clone_from: str @param timeout: maximum tim...
python
def vb_clone_vm( name=None, clone_from=None, clone_mode=0, timeout=10000, **kwargs ): ''' Tells virtualbox to create a VM by cloning from an existing one @param name: Name for the new VM @type name: str @param clone_from: @type clone_from: str @param timeout: maximum tim...
[ "def", "vb_clone_vm", "(", "name", "=", "None", ",", "clone_from", "=", "None", ",", "clone_mode", "=", "0", ",", "timeout", "=", "10000", ",", "*", "*", "kwargs", ")", ":", "vbox", "=", "vb_get_box", "(", ")", "log", ".", "info", "(", "'Clone virtua...
Tells virtualbox to create a VM by cloning from an existing one @param name: Name for the new VM @type name: str @param clone_from: @type clone_from: str @param timeout: maximum time in milliseconds to wait or -1 to wait indefinitely @type timeout: int @return dict of resulting VM
[ "Tells", "virtualbox", "to", "create", "a", "VM", "by", "cloning", "from", "an", "existing", "one" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/virtualbox.py#L371-L415
train
saltstack/salt
salt/utils/virtualbox.py
_start_machine
def _start_machine(machine, session): ''' Helper to try and start machines @param machine: @type machine: IMachine @param session: @type session: ISession @return: @rtype: IProgress or None ''' try: return machine.launchVMProcess(session, '', '') except Exception as ...
python
def _start_machine(machine, session): ''' Helper to try and start machines @param machine: @type machine: IMachine @param session: @type session: ISession @return: @rtype: IProgress or None ''' try: return machine.launchVMProcess(session, '', '') except Exception as ...
[ "def", "_start_machine", "(", "machine", ",", "session", ")", ":", "try", ":", "return", "machine", ".", "launchVMProcess", "(", "session", ",", "''", ",", "''", ")", "except", "Exception", "as", "e", ":", "log", ".", "debug", "(", "e", ".", "message",...
Helper to try and start machines @param machine: @type machine: IMachine @param session: @type session: ISession @return: @rtype: IProgress or None
[ "Helper", "to", "try", "and", "start", "machines" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/virtualbox.py#L418-L433
train
saltstack/salt
salt/utils/virtualbox.py
vb_start_vm
def vb_start_vm(name=None, timeout=10000, **kwargs): ''' Tells Virtualbox to start up a VM. Blocking function! @param name: @type name: str @param timeout: Maximum time in milliseconds to wait or -1 to wait indefinitely @type timeout: int @return untreated dict of started VM ''' ...
python
def vb_start_vm(name=None, timeout=10000, **kwargs): ''' Tells Virtualbox to start up a VM. Blocking function! @param name: @type name: str @param timeout: Maximum time in milliseconds to wait or -1 to wait indefinitely @type timeout: int @return untreated dict of started VM ''' ...
[ "def", "vb_start_vm", "(", "name", "=", "None", ",", "timeout", "=", "10000", ",", "*", "*", "kwargs", ")", ":", "# Time tracking", "start_time", "=", "time", ".", "time", "(", ")", "timeout_in_seconds", "=", "timeout", "/", "1000", "max_time", "=", "sta...
Tells Virtualbox to start up a VM. Blocking function! @param name: @type name: str @param timeout: Maximum time in milliseconds to wait or -1 to wait indefinitely @type timeout: int @return untreated dict of started VM
[ "Tells", "Virtualbox", "to", "start", "up", "a", "VM", ".", "Blocking", "function!" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/virtualbox.py#L436-L475
train
saltstack/salt
salt/utils/virtualbox.py
vb_stop_vm
def vb_stop_vm(name=None, timeout=10000, **kwargs): ''' Tells Virtualbox to stop a VM. This is a blocking function! @param name: @type name: str @param timeout: Maximum time in milliseconds to wait or -1 to wait indefinitely @type timeout: int @return untreated dict of stopped VM ''...
python
def vb_stop_vm(name=None, timeout=10000, **kwargs): ''' Tells Virtualbox to stop a VM. This is a blocking function! @param name: @type name: str @param timeout: Maximum time in milliseconds to wait or -1 to wait indefinitely @type timeout: int @return untreated dict of stopped VM ''...
[ "def", "vb_stop_vm", "(", "name", "=", "None", ",", "timeout", "=", "10000", ",", "*", "*", "kwargs", ")", ":", "vbox", "=", "vb_get_box", "(", ")", "machine", "=", "vbox", ".", "findMachine", "(", "name", ")", "log", ".", "info", "(", "'Stopping mac...
Tells Virtualbox to stop a VM. This is a blocking function! @param name: @type name: str @param timeout: Maximum time in milliseconds to wait or -1 to wait indefinitely @type timeout: int @return untreated dict of stopped VM
[ "Tells", "Virtualbox", "to", "stop", "a", "VM", ".", "This", "is", "a", "blocking", "function!" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/virtualbox.py#L478-L501
train
saltstack/salt
salt/utils/virtualbox.py
vb_destroy_machine
def vb_destroy_machine(name=None, timeout=10000): ''' Attempts to get rid of a machine and all its files from the hypervisor @param name: @type name: str @param timeout int timeout in milliseconds ''' vbox = vb_get_box() log.info('Destroying machine %s', name) machine = vbox.findMach...
python
def vb_destroy_machine(name=None, timeout=10000): ''' Attempts to get rid of a machine and all its files from the hypervisor @param name: @type name: str @param timeout int timeout in milliseconds ''' vbox = vb_get_box() log.info('Destroying machine %s', name) machine = vbox.findMach...
[ "def", "vb_destroy_machine", "(", "name", "=", "None", ",", "timeout", "=", "10000", ")", ":", "vbox", "=", "vb_get_box", "(", ")", "log", ".", "info", "(", "'Destroying machine %s'", ",", "name", ")", "machine", "=", "vbox", ".", "findMachine", "(", "na...
Attempts to get rid of a machine and all its files from the hypervisor @param name: @type name: str @param timeout int timeout in milliseconds
[ "Attempts", "to", "get", "rid", "of", "a", "machine", "and", "all", "its", "files", "from", "the", "hypervisor" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/virtualbox.py#L504-L517
train
saltstack/salt
salt/utils/virtualbox.py
vb_xpcom_to_attribute_dict
def vb_xpcom_to_attribute_dict(xpcom, interface_name=None, attributes=None, excluded_attributes=None, extra_attributes=None ): ''' Attempts to build a dict f...
python
def vb_xpcom_to_attribute_dict(xpcom, interface_name=None, attributes=None, excluded_attributes=None, extra_attributes=None ): ''' Attempts to build a dict f...
[ "def", "vb_xpcom_to_attribute_dict", "(", "xpcom", ",", "interface_name", "=", "None", ",", "attributes", "=", "None", ",", "excluded_attributes", "=", "None", ",", "extra_attributes", "=", "None", ")", ":", "# Check the interface", "if", "interface_name", ":", "m...
Attempts to build a dict from an XPCOM object. Attributes that don't exist in the object return an empty string. attribute_list = list of str or tuple(str,<a class>) e.g attributes=[('bad_attribute', list)] --> { 'bad_attribute': [] } @param xpcom: @type xpcom: @param interface_name: Which in...
[ "Attempts", "to", "build", "a", "dict", "from", "an", "XPCOM", "object", ".", "Attributes", "that", "don", "t", "exist", "in", "the", "object", "return", "an", "empty", "string", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/virtualbox.py#L520-L573
train
saltstack/salt
salt/utils/virtualbox.py
treat_machine_dict
def treat_machine_dict(machine): ''' Make machine presentable for outside world. !!!Modifies the input machine!!! @param machine: @type machine: dict @return: the modified input machine @rtype: dict ''' machine.update({ 'id': machine.get('id', ''), 'image': machine....
python
def treat_machine_dict(machine): ''' Make machine presentable for outside world. !!!Modifies the input machine!!! @param machine: @type machine: dict @return: the modified input machine @rtype: dict ''' machine.update({ 'id': machine.get('id', ''), 'image': machine....
[ "def", "treat_machine_dict", "(", "machine", ")", ":", "machine", ".", "update", "(", "{", "'id'", ":", "machine", ".", "get", "(", "'id'", ",", "''", ")", ",", "'image'", ":", "machine", ".", "get", "(", "'image'", ",", "''", ")", ",", "'size'", "...
Make machine presentable for outside world. !!!Modifies the input machine!!! @param machine: @type machine: dict @return: the modified input machine @rtype: dict
[ "Make", "machine", "presentable", "for", "outside", "world", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/virtualbox.py#L576-L599
train
saltstack/salt
salt/utils/virtualbox.py
vb_machine_exists
def vb_machine_exists(name): ''' Checks in with the hypervisor to see if the machine with the given name is known @param name: @type name: @return: @rtype: ''' try: vbox = vb_get_box() vbox.findMachine(name) return True except Exception as e: if isinst...
python
def vb_machine_exists(name): ''' Checks in with the hypervisor to see if the machine with the given name is known @param name: @type name: @return: @rtype: ''' try: vbox = vb_get_box() vbox.findMachine(name) return True except Exception as e: if isinst...
[ "def", "vb_machine_exists", "(", "name", ")", ":", "try", ":", "vbox", "=", "vb_get_box", "(", ")", "vbox", ".", "findMachine", "(", "name", ")", "return", "True", "except", "Exception", "as", "e", ":", "if", "isinstance", "(", "e", ".", "message", ","...
Checks in with the hypervisor to see if the machine with the given name is known @param name: @type name: @return: @rtype:
[ "Checks", "in", "with", "the", "hypervisor", "to", "see", "if", "the", "machine", "with", "the", "given", "name", "is", "known" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/virtualbox.py#L652-L674
train
saltstack/salt
salt/utils/virtualbox.py
vb_get_machine
def vb_get_machine(name, **kwargs): ''' Attempts to fetch a machine from Virtualbox and convert it to a dict @param name: The unique name of the machine @type name: @param kwargs: To be passed to vb_xpcom_to_attribute_dict @type kwargs: @return: @rtype: dict ''' vbox = vb_get_bo...
python
def vb_get_machine(name, **kwargs): ''' Attempts to fetch a machine from Virtualbox and convert it to a dict @param name: The unique name of the machine @type name: @param kwargs: To be passed to vb_xpcom_to_attribute_dict @type kwargs: @return: @rtype: dict ''' vbox = vb_get_bo...
[ "def", "vb_get_machine", "(", "name", ",", "*", "*", "kwargs", ")", ":", "vbox", "=", "vb_get_box", "(", ")", "machine", "=", "vbox", ".", "findMachine", "(", "name", ")", "return", "vb_xpcom_to_attribute_dict", "(", "machine", ",", "'IMachine'", ",", "*",...
Attempts to fetch a machine from Virtualbox and convert it to a dict @param name: The unique name of the machine @type name: @param kwargs: To be passed to vb_xpcom_to_attribute_dict @type kwargs: @return: @rtype: dict
[ "Attempts", "to", "fetch", "a", "machine", "from", "Virtualbox", "and", "convert", "it", "to", "a", "dict" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/virtualbox.py#L677-L690
train
saltstack/salt
salt/utils/data.py
compare_dicts
def compare_dicts(old=None, new=None): ''' Compare before and after results from various salt functions, returning a dict describing the changes that were made. ''' ret = {} for key in set((new or {})).union((old or {})): if key not in old: # New key ret[key] = {'...
python
def compare_dicts(old=None, new=None): ''' Compare before and after results from various salt functions, returning a dict describing the changes that were made. ''' ret = {} for key in set((new or {})).union((old or {})): if key not in old: # New key ret[key] = {'...
[ "def", "compare_dicts", "(", "old", "=", "None", ",", "new", "=", "None", ")", ":", "ret", "=", "{", "}", "for", "key", "in", "set", "(", "(", "new", "or", "{", "}", ")", ")", ".", "union", "(", "(", "old", "or", "{", "}", ")", ")", ":", ...
Compare before and after results from various salt functions, returning a dict describing the changes that were made.
[ "Compare", "before", "and", "after", "results", "from", "various", "salt", "functions", "returning", "a", "dict", "describing", "the", "changes", "that", "were", "made", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/data.py#L124-L143
train
saltstack/salt
salt/utils/data.py
compare_lists
def compare_lists(old=None, new=None): ''' Compare before and after results from various salt functions, returning a dict describing the changes that were made ''' ret = dict() for item in new: if item not in old: ret['new'] = item for item in old: if item not in ...
python
def compare_lists(old=None, new=None): ''' Compare before and after results from various salt functions, returning a dict describing the changes that were made ''' ret = dict() for item in new: if item not in old: ret['new'] = item for item in old: if item not in ...
[ "def", "compare_lists", "(", "old", "=", "None", ",", "new", "=", "None", ")", ":", "ret", "=", "dict", "(", ")", "for", "item", "in", "new", ":", "if", "item", "not", "in", "old", ":", "ret", "[", "'new'", "]", "=", "item", "for", "item", "in"...
Compare before and after results from various salt functions, returning a dict describing the changes that were made
[ "Compare", "before", "and", "after", "results", "from", "various", "salt", "functions", "returning", "a", "dict", "describing", "the", "changes", "that", "were", "made" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/data.py#L147-L159
train
saltstack/salt
salt/utils/data.py
decode
def decode(data, encoding=None, errors='strict', keep=False, normalize=False, preserve_dict_class=False, preserve_tuples=False, to_str=False): ''' Generic function which will decode whichever type is passed, if necessary. Optionally use to_str=True to ensure strings are str types and n...
python
def decode(data, encoding=None, errors='strict', keep=False, normalize=False, preserve_dict_class=False, preserve_tuples=False, to_str=False): ''' Generic function which will decode whichever type is passed, if necessary. Optionally use to_str=True to ensure strings are str types and n...
[ "def", "decode", "(", "data", ",", "encoding", "=", "None", ",", "errors", "=", "'strict'", ",", "keep", "=", "False", ",", "normalize", "=", "False", ",", "preserve_dict_class", "=", "False", ",", "preserve_tuples", "=", "False", ",", "to_str", "=", "Fa...
Generic function which will decode whichever type is passed, if necessary. Optionally use to_str=True to ensure strings are str types and not unicode on Python 2. If `strict` is True, and `keep` is False, and we fail to decode, a UnicodeDecodeError will be raised. Passing `keep` as True allows for the ...
[ "Generic", "function", "which", "will", "decode", "whichever", "type", "is", "passed", "if", "necessary", ".", "Optionally", "use", "to_str", "=", "True", "to", "ensure", "strings", "are", "str", "types", "and", "not", "unicode", "on", "Python", "2", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/data.py#L162-L218
train
saltstack/salt
salt/utils/data.py
decode_dict
def decode_dict(data, encoding=None, errors='strict', keep=False, normalize=False, preserve_dict_class=False, preserve_tuples=False, to_str=False): ''' Decode all string values to Unicode. Optionally use to_str=True to ensure strings are str types and not unicode on Python 2....
python
def decode_dict(data, encoding=None, errors='strict', keep=False, normalize=False, preserve_dict_class=False, preserve_tuples=False, to_str=False): ''' Decode all string values to Unicode. Optionally use to_str=True to ensure strings are str types and not unicode on Python 2....
[ "def", "decode_dict", "(", "data", ",", "encoding", "=", "None", ",", "errors", "=", "'strict'", ",", "keep", "=", "False", ",", "normalize", "=", "False", ",", "preserve_dict_class", "=", "False", ",", "preserve_tuples", "=", "False", ",", "to_str", "=", ...
Decode all string values to Unicode. Optionally use to_str=True to ensure strings are str types and not unicode on Python 2.
[ "Decode", "all", "string", "values", "to", "Unicode", ".", "Optionally", "use", "to_str", "=", "True", "to", "ensure", "strings", "are", "str", "types", "and", "not", "unicode", "on", "Python", "2", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/data.py#L221-L277
train
saltstack/salt
salt/utils/data.py
decode_tuple
def decode_tuple(data, encoding=None, errors='strict', keep=False, normalize=False, preserve_dict_class=False, to_str=False): ''' Decode all string values to Unicode. Optionally use to_str=True to ensure strings are str types and not unicode on Python 2. ''' return tuple( de...
python
def decode_tuple(data, encoding=None, errors='strict', keep=False, normalize=False, preserve_dict_class=False, to_str=False): ''' Decode all string values to Unicode. Optionally use to_str=True to ensure strings are str types and not unicode on Python 2. ''' return tuple( de...
[ "def", "decode_tuple", "(", "data", ",", "encoding", "=", "None", ",", "errors", "=", "'strict'", ",", "keep", "=", "False", ",", "normalize", "=", "False", ",", "preserve_dict_class", "=", "False", ",", "to_str", "=", "False", ")", ":", "return", "tuple...
Decode all string values to Unicode. Optionally use to_str=True to ensure strings are str types and not unicode on Python 2.
[ "Decode", "all", "string", "values", "to", "Unicode", ".", "Optionally", "use", "to_str", "=", "True", "to", "ensure", "strings", "are", "str", "types", "and", "not", "unicode", "on", "Python", "2", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/data.py#L320-L329
train
saltstack/salt
salt/utils/data.py
encode
def encode(data, encoding=None, errors='strict', keep=False, preserve_dict_class=False, preserve_tuples=False): ''' Generic function which will encode whichever type is passed, if necessary If `strict` is True, and `keep` is False, and we fail to encode, a UnicodeEncodeError will be raised. ...
python
def encode(data, encoding=None, errors='strict', keep=False, preserve_dict_class=False, preserve_tuples=False): ''' Generic function which will encode whichever type is passed, if necessary If `strict` is True, and `keep` is False, and we fail to encode, a UnicodeEncodeError will be raised. ...
[ "def", "encode", "(", "data", ",", "encoding", "=", "None", ",", "errors", "=", "'strict'", ",", "keep", "=", "False", ",", "preserve_dict_class", "=", "False", ",", "preserve_tuples", "=", "False", ")", ":", "if", "isinstance", "(", "data", ",", "Mappin...
Generic function which will encode whichever type is passed, if necessary If `strict` is True, and `keep` is False, and we fail to encode, a UnicodeEncodeError will be raised. Passing `keep` as True allows for the original value to silently be returned in cases where encoding fails. This can be useful ...
[ "Generic", "function", "which", "will", "encode", "whichever", "type", "is", "passed", "if", "necessary" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/data.py#L332-L365
train
saltstack/salt
salt/utils/data.py
encode_dict
def encode_dict(data, encoding=None, errors='strict', keep=False, preserve_dict_class=False, preserve_tuples=False): ''' Encode all string values to bytes ''' rv = data.__class__() if preserve_dict_class else {} for key, value in six.iteritems(data): if isinstance(key, tuple)...
python
def encode_dict(data, encoding=None, errors='strict', keep=False, preserve_dict_class=False, preserve_tuples=False): ''' Encode all string values to bytes ''' rv = data.__class__() if preserve_dict_class else {} for key, value in six.iteritems(data): if isinstance(key, tuple)...
[ "def", "encode_dict", "(", "data", ",", "encoding", "=", "None", ",", "errors", "=", "'strict'", ",", "keep", "=", "False", ",", "preserve_dict_class", "=", "False", ",", "preserve_tuples", "=", "False", ")", ":", "rv", "=", "data", ".", "__class__", "("...
Encode all string values to bytes
[ "Encode", "all", "string", "values", "to", "bytes" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/data.py#L370-L418
train
saltstack/salt
salt/utils/data.py
encode_list
def encode_list(data, encoding=None, errors='strict', keep=False, preserve_dict_class=False, preserve_tuples=False): ''' Encode all string values to bytes ''' rv = [] for item in data: if isinstance(item, list): item = encode_list(item, encoding, errors, keep, ...
python
def encode_list(data, encoding=None, errors='strict', keep=False, preserve_dict_class=False, preserve_tuples=False): ''' Encode all string values to bytes ''' rv = [] for item in data: if isinstance(item, list): item = encode_list(item, encoding, errors, keep, ...
[ "def", "encode_list", "(", "data", ",", "encoding", "=", "None", ",", "errors", "=", "'strict'", ",", "keep", "=", "False", ",", "preserve_dict_class", "=", "False", ",", "preserve_tuples", "=", "False", ")", ":", "rv", "=", "[", "]", "for", "item", "i...
Encode all string values to bytes
[ "Encode", "all", "string", "values", "to", "bytes" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/data.py#L423-L454
train
saltstack/salt
salt/utils/data.py
encode_tuple
def encode_tuple(data, encoding=None, errors='strict', keep=False, preserve_dict_class=False): ''' Encode all string values to Unicode ''' return tuple( encode_list(data, encoding, errors, keep, preserve_dict_class, True))
python
def encode_tuple(data, encoding=None, errors='strict', keep=False, preserve_dict_class=False): ''' Encode all string values to Unicode ''' return tuple( encode_list(data, encoding, errors, keep, preserve_dict_class, True))
[ "def", "encode_tuple", "(", "data", ",", "encoding", "=", "None", ",", "errors", "=", "'strict'", ",", "keep", "=", "False", ",", "preserve_dict_class", "=", "False", ")", ":", "return", "tuple", "(", "encode_list", "(", "data", ",", "encoding", ",", "er...
Encode all string values to Unicode
[ "Encode", "all", "string", "values", "to", "Unicode" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/data.py#L457-L463
train
saltstack/salt
salt/utils/data.py
filter_by
def filter_by(lookup_dict, lookup, traverse, merge=None, default='default', base=None): ''' Common code to filter data structures like grains and pillar ''' ret = None # Default value would be an empty list if lookup not found ...
python
def filter_by(lookup_dict, lookup, traverse, merge=None, default='default', base=None): ''' Common code to filter data structures like grains and pillar ''' ret = None # Default value would be an empty list if lookup not found ...
[ "def", "filter_by", "(", "lookup_dict", ",", "lookup", ",", "traverse", ",", "merge", "=", "None", ",", "default", "=", "'default'", ",", "base", "=", "None", ")", ":", "ret", "=", "None", "# Default value would be an empty list if lookup not found", "val", "=",...
Common code to filter data structures like grains and pillar
[ "Common", "code", "to", "filter", "data", "structures", "like", "grains", "and", "pillar" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/data.py#L484-L536
train
saltstack/salt
salt/utils/data.py
traverse_dict
def traverse_dict(data, key, default=None, delimiter=DEFAULT_TARGET_DELIM): ''' Traverse a dict using a colon-delimited (or otherwise delimited, using the 'delimiter' param) target string. The target 'foo:bar:baz' will return data['foo']['bar']['baz'] if this value exists, and will otherwise return ...
python
def traverse_dict(data, key, default=None, delimiter=DEFAULT_TARGET_DELIM): ''' Traverse a dict using a colon-delimited (or otherwise delimited, using the 'delimiter' param) target string. The target 'foo:bar:baz' will return data['foo']['bar']['baz'] if this value exists, and will otherwise return ...
[ "def", "traverse_dict", "(", "data", ",", "key", ",", "default", "=", "None", ",", "delimiter", "=", "DEFAULT_TARGET_DELIM", ")", ":", "ptr", "=", "data", "try", ":", "for", "each", "in", "key", ".", "split", "(", "delimiter", ")", ":", "ptr", "=", "...
Traverse a dict using a colon-delimited (or otherwise delimited, using the 'delimiter' param) target string. The target 'foo:bar:baz' will return data['foo']['bar']['baz'] if this value exists, and will otherwise return the dict in the default argument.
[ "Traverse", "a", "dict", "using", "a", "colon", "-", "delimited", "(", "or", "otherwise", "delimited", "using", "the", "delimiter", "param", ")", "target", "string", ".", "The", "target", "foo", ":", "bar", ":", "baz", "will", "return", "data", "[", "foo...
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/data.py#L539-L553
train
saltstack/salt
salt/utils/data.py
traverse_dict_and_list
def traverse_dict_and_list(data, key, default=None, delimiter=DEFAULT_TARGET_DELIM): ''' Traverse a dict or list using a colon-delimited (or otherwise delimited, using the 'delimiter' param) target string. The target 'foo:bar:0' will return data['foo']['bar'][0] if this value exists, and will otherwise ...
python
def traverse_dict_and_list(data, key, default=None, delimiter=DEFAULT_TARGET_DELIM): ''' Traverse a dict or list using a colon-delimited (or otherwise delimited, using the 'delimiter' param) target string. The target 'foo:bar:0' will return data['foo']['bar'][0] if this value exists, and will otherwise ...
[ "def", "traverse_dict_and_list", "(", "data", ",", "key", ",", "default", "=", "None", ",", "delimiter", "=", "DEFAULT_TARGET_DELIM", ")", ":", "ptr", "=", "data", "for", "each", "in", "key", ".", "split", "(", "delimiter", ")", ":", "if", "isinstance", ...
Traverse a dict or list using a colon-delimited (or otherwise delimited, using the 'delimiter' param) target string. The target 'foo:bar:0' will return data['foo']['bar'][0] if this value exists, and will otherwise return the dict in the default argument. Function will automatically determine the target...
[ "Traverse", "a", "dict", "or", "list", "using", "a", "colon", "-", "delimited", "(", "or", "otherwise", "delimited", "using", "the", "delimiter", "param", ")", "target", "string", ".", "The", "target", "foo", ":", "bar", ":", "0", "will", "return", "data...
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/data.py#L557-L596
train
saltstack/salt
salt/utils/data.py
subdict_match
def subdict_match(data, expr, delimiter=DEFAULT_TARGET_DELIM, regex_match=False, exact_match=False): ''' Check for a match in a dictionary using a delimiter character to denote levels of subdicts, and also allowing the delimiter charact...
python
def subdict_match(data, expr, delimiter=DEFAULT_TARGET_DELIM, regex_match=False, exact_match=False): ''' Check for a match in a dictionary using a delimiter character to denote levels of subdicts, and also allowing the delimiter charact...
[ "def", "subdict_match", "(", "data", ",", "expr", ",", "delimiter", "=", "DEFAULT_TARGET_DELIM", ",", "regex_match", "=", "False", ",", "exact_match", "=", "False", ")", ":", "def", "_match", "(", "target", ",", "pattern", ",", "regex_match", "=", "False", ...
Check for a match in a dictionary using a delimiter character to denote levels of subdicts, and also allowing the delimiter character to be matched. Thus, 'foo:bar:baz' will match data['foo'] == 'bar:baz' and data['foo']['bar'] == 'baz'. The latter would take priority over the former, as more deeply-nes...
[ "Check", "for", "a", "match", "in", "a", "dictionary", "using", "a", "delimiter", "character", "to", "denote", "levels", "of", "subdicts", "and", "also", "allowing", "the", "delimiter", "character", "to", "be", "matched", ".", "Thus", "foo", ":", "bar", ":...
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/data.py#L599-L733
train
saltstack/salt
salt/utils/data.py
is_dictlist
def is_dictlist(data): ''' Returns True if data is a list of one-element dicts (as found in many SLS schemas), otherwise returns False ''' if isinstance(data, list): for element in data: if isinstance(element, dict): if len(element) != 1: retur...
python
def is_dictlist(data): ''' Returns True if data is a list of one-element dicts (as found in many SLS schemas), otherwise returns False ''' if isinstance(data, list): for element in data: if isinstance(element, dict): if len(element) != 1: retur...
[ "def", "is_dictlist", "(", "data", ")", ":", "if", "isinstance", "(", "data", ",", "list", ")", ":", "for", "element", "in", "data", ":", "if", "isinstance", "(", "element", ",", "dict", ")", ":", "if", "len", "(", "element", ")", "!=", "1", ":", ...
Returns True if data is a list of one-element dicts (as found in many SLS schemas), otherwise returns False
[ "Returns", "True", "if", "data", "is", "a", "list", "of", "one", "-", "element", "dicts", "(", "as", "found", "in", "many", "SLS", "schemas", ")", "otherwise", "returns", "False" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/data.py#L745-L758
train
saltstack/salt
salt/utils/data.py
repack_dictlist
def repack_dictlist(data, strict=False, recurse=False, key_cb=None, val_cb=None): ''' Takes a list of one-element dicts (as found in many SLS schemas) and repacks into a single dictionary. ''' if isinstance(data, six.str...
python
def repack_dictlist(data, strict=False, recurse=False, key_cb=None, val_cb=None): ''' Takes a list of one-element dicts (as found in many SLS schemas) and repacks into a single dictionary. ''' if isinstance(data, six.str...
[ "def", "repack_dictlist", "(", "data", ",", "strict", "=", "False", ",", "recurse", "=", "False", ",", "key_cb", "=", "None", ",", "val_cb", "=", "None", ")", ":", "if", "isinstance", "(", "data", ",", "six", ".", "string_types", ")", ":", "try", ":"...
Takes a list of one-element dicts (as found in many SLS schemas) and repacks into a single dictionary.
[ "Takes", "a", "list", "of", "one", "-", "element", "dicts", "(", "as", "found", "in", "many", "SLS", "schemas", ")", "and", "repacks", "into", "a", "single", "dictionary", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/data.py#L761-L828
train
saltstack/salt
salt/utils/data.py
is_iter
def is_iter(y, ignore=six.string_types): ''' Test if an object is iterable, but not a string type. Test if an object is an iterator or is iterable itself. By default this does not return True for string objects. The `ignore` argument defaults to a list of string types that are not considered i...
python
def is_iter(y, ignore=six.string_types): ''' Test if an object is iterable, but not a string type. Test if an object is an iterator or is iterable itself. By default this does not return True for string objects. The `ignore` argument defaults to a list of string types that are not considered i...
[ "def", "is_iter", "(", "y", ",", "ignore", "=", "six", ".", "string_types", ")", ":", "if", "ignore", "and", "isinstance", "(", "y", ",", "ignore", ")", ":", "return", "False", "try", ":", "iter", "(", "y", ")", "return", "True", "except", "TypeError...
Test if an object is iterable, but not a string type. Test if an object is an iterator or is iterable itself. By default this does not return True for string objects. The `ignore` argument defaults to a list of string types that are not considered iterable. This can be used to also exclude things like...
[ "Test", "if", "an", "object", "is", "iterable", "but", "not", "a", "string", "type", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/data.py#L840-L860
train
saltstack/salt
salt/utils/data.py
is_true
def is_true(value=None): ''' Returns a boolean value representing the "truth" of the value passed. The rules for what is a "True" value are: 1. Integer/float values greater than 0 2. The string values "True" and "true" 3. Any object for which bool(obj) returns True ''' # Fir...
python
def is_true(value=None): ''' Returns a boolean value representing the "truth" of the value passed. The rules for what is a "True" value are: 1. Integer/float values greater than 0 2. The string values "True" and "true" 3. Any object for which bool(obj) returns True ''' # Fir...
[ "def", "is_true", "(", "value", "=", "None", ")", ":", "# First, try int/float conversion", "try", ":", "value", "=", "int", "(", "value", ")", "except", "(", "ValueError", ",", "TypeError", ")", ":", "pass", "try", ":", "value", "=", "float", "(", "valu...
Returns a boolean value representing the "truth" of the value passed. The rules for what is a "True" value are: 1. Integer/float values greater than 0 2. The string values "True" and "true" 3. Any object for which bool(obj) returns True
[ "Returns", "a", "boolean", "value", "representing", "the", "truth", "of", "the", "value", "passed", ".", "The", "rules", "for", "what", "is", "a", "True", "value", "are", ":" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/data.py#L878-L903
train
saltstack/salt
salt/utils/data.py
mysql_to_dict
def mysql_to_dict(data, key): ''' Convert MySQL-style output to a python dictionary ''' ret = {} headers = [''] for line in data: if not line: continue if line.startswith('+'): continue comps = line.split('|') for comp in range(len(comps)):...
python
def mysql_to_dict(data, key): ''' Convert MySQL-style output to a python dictionary ''' ret = {} headers = [''] for line in data: if not line: continue if line.startswith('+'): continue comps = line.split('|') for comp in range(len(comps)):...
[ "def", "mysql_to_dict", "(", "data", ",", "key", ")", ":", "ret", "=", "{", "}", "headers", "=", "[", "''", "]", "for", "line", "in", "data", ":", "if", "not", "line", ":", "continue", "if", "line", ".", "startswith", "(", "'+'", ")", ":", "conti...
Convert MySQL-style output to a python dictionary
[ "Convert", "MySQL", "-", "style", "output", "to", "a", "python", "dictionary" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/data.py#L907-L932
train
saltstack/salt
salt/utils/data.py
simple_types_filter
def simple_types_filter(data): ''' Convert the data list, dictionary into simple types, i.e., int, float, string, bool, etc. ''' if data is None: return data simpletypes_keys = (six.string_types, six.text_type, six.integer_types, float, bool) simpletypes_values = tuple(list(simplety...
python
def simple_types_filter(data): ''' Convert the data list, dictionary into simple types, i.e., int, float, string, bool, etc. ''' if data is None: return data simpletypes_keys = (six.string_types, six.text_type, six.integer_types, float, bool) simpletypes_values = tuple(list(simplety...
[ "def", "simple_types_filter", "(", "data", ")", ":", "if", "data", "is", "None", ":", "return", "data", "simpletypes_keys", "=", "(", "six", ".", "string_types", ",", "six", ".", "text_type", ",", "six", ".", "integer_types", ",", "float", ",", "bool", "...
Convert the data list, dictionary into simple types, i.e., int, float, string, bool, etc.
[ "Convert", "the", "data", "list", "dictionary", "into", "simple", "types", "i", ".", "e", ".", "int", "float", "string", "bool", "etc", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/data.py#L935-L969
train
saltstack/salt
salt/utils/data.py
stringify
def stringify(data): ''' Given an iterable, returns its items as a list, with any non-string items converted to unicode strings. ''' ret = [] for item in data: if six.PY2 and isinstance(item, str): item = salt.utils.stringutils.to_unicode(item) elif not isinstance(ite...
python
def stringify(data): ''' Given an iterable, returns its items as a list, with any non-string items converted to unicode strings. ''' ret = [] for item in data: if six.PY2 and isinstance(item, str): item = salt.utils.stringutils.to_unicode(item) elif not isinstance(ite...
[ "def", "stringify", "(", "data", ")", ":", "ret", "=", "[", "]", "for", "item", "in", "data", ":", "if", "six", ".", "PY2", "and", "isinstance", "(", "item", ",", "str", ")", ":", "item", "=", "salt", ".", "utils", ".", "stringutils", ".", "to_un...
Given an iterable, returns its items as a list, with any non-string items converted to unicode strings.
[ "Given", "an", "iterable", "returns", "its", "items", "as", "a", "list", "with", "any", "non", "-", "string", "items", "converted", "to", "unicode", "strings", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/data.py#L972-L984
train
saltstack/salt
salt/utils/data.py
json_query
def json_query(data, expr): ''' Query data using JMESPath language (http://jmespath.org). ''' if jmespath is None: err = 'json_query requires jmespath module installed' log.error(err) raise RuntimeError(err) return jmespath.search(expr, data)
python
def json_query(data, expr): ''' Query data using JMESPath language (http://jmespath.org). ''' if jmespath is None: err = 'json_query requires jmespath module installed' log.error(err) raise RuntimeError(err) return jmespath.search(expr, data)
[ "def", "json_query", "(", "data", ",", "expr", ")", ":", "if", "jmespath", "is", "None", ":", "err", "=", "'json_query requires jmespath module installed'", "log", ".", "error", "(", "err", ")", "raise", "RuntimeError", "(", "err", ")", "return", "jmespath", ...
Query data using JMESPath language (http://jmespath.org).
[ "Query", "data", "using", "JMESPath", "language", "(", "http", ":", "//", "jmespath", ".", "org", ")", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/data.py#L988-L996
train
saltstack/salt
salt/utils/data.py
_is_not_considered_falsey
def _is_not_considered_falsey(value, ignore_types=()): ''' Helper function for filter_falsey to determine if something is not to be considered falsey. :param any value: The value to consider :param list ignore_types: The types to ignore when considering the value. :return bool ''' retu...
python
def _is_not_considered_falsey(value, ignore_types=()): ''' Helper function for filter_falsey to determine if something is not to be considered falsey. :param any value: The value to consider :param list ignore_types: The types to ignore when considering the value. :return bool ''' retu...
[ "def", "_is_not_considered_falsey", "(", "value", ",", "ignore_types", "=", "(", ")", ")", ":", "return", "isinstance", "(", "value", ",", "bool", ")", "or", "type", "(", "value", ")", "in", "ignore_types", "or", "value" ]
Helper function for filter_falsey to determine if something is not to be considered falsey. :param any value: The value to consider :param list ignore_types: The types to ignore when considering the value. :return bool
[ "Helper", "function", "for", "filter_falsey", "to", "determine", "if", "something", "is", "not", "to", "be", "considered", "falsey", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/data.py#L999-L1009
train
saltstack/salt
salt/utils/data.py
filter_falsey
def filter_falsey(data, recurse_depth=None, ignore_types=()): ''' Helper function to remove items from an iterable with falsey value. Removes ``None``, ``{}`` and ``[]``, 0, '' (but does not remove ``False``). Recurses into sub-iterables if ``recurse`` is set to ``True``. :param dict/list data: Sou...
python
def filter_falsey(data, recurse_depth=None, ignore_types=()): ''' Helper function to remove items from an iterable with falsey value. Removes ``None``, ``{}`` and ``[]``, 0, '' (but does not remove ``False``). Recurses into sub-iterables if ``recurse`` is set to ``True``. :param dict/list data: Sou...
[ "def", "filter_falsey", "(", "data", ",", "recurse_depth", "=", "None", ",", "ignore_types", "=", "(", ")", ")", ":", "filter_element", "=", "(", "functools", ".", "partial", "(", "filter_falsey", ",", "recurse_depth", "=", "recurse_depth", "-", "1", ",", ...
Helper function to remove items from an iterable with falsey value. Removes ``None``, ``{}`` and ``[]``, 0, '' (but does not remove ``False``). Recurses into sub-iterables if ``recurse`` is set to ``True``. :param dict/list data: Source iterable (dict, OrderedDict, list, set, ...) to process. :param in...
[ "Helper", "function", "to", "remove", "items", "from", "an", "iterable", "with", "falsey", "value", ".", "Removes", "None", "{}", "and", "[]", "0", "(", "but", "does", "not", "remove", "False", ")", ".", "Recurses", "into", "sub", "-", "iterables", "if",...
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/data.py#L1012-L1048
train
saltstack/salt
salt/utils/data.py
CaseInsensitiveDict.items_lower
def items_lower(self): ''' Returns a generator iterating over keys and values, with the keys all being lowercase. ''' return ((key, val[1]) for key, val in six.iteritems(self._data))
python
def items_lower(self): ''' Returns a generator iterating over keys and values, with the keys all being lowercase. ''' return ((key, val[1]) for key, val in six.iteritems(self._data))
[ "def", "items_lower", "(", "self", ")", ":", "return", "(", "(", "key", ",", "val", "[", "1", "]", ")", "for", "key", ",", "val", "in", "six", ".", "iteritems", "(", "self", ".", "_data", ")", ")" ]
Returns a generator iterating over keys and values, with the keys all being lowercase.
[ "Returns", "a", "generator", "iterating", "over", "keys", "and", "values", "with", "the", "keys", "all", "being", "lowercase", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/data.py#L80-L85
train
saltstack/salt
salt/states/macdefaults.py
write
def write(name, domain, value, vtype='string', user=None): ''' Write a default to the system name The key of the given domain to write to domain The name of the domain to write to value The value to write to the given key vtype The type of value to be written,...
python
def write(name, domain, value, vtype='string', user=None): ''' Write a default to the system name The key of the given domain to write to domain The name of the domain to write to value The value to write to the given key vtype The type of value to be written,...
[ "def", "write", "(", "name", ",", "domain", ",", "value", ",", "vtype", "=", "'string'", ",", "user", "=", "None", ")", ":", "ret", "=", "{", "'name'", ":", "name", ",", "'result'", ":", "True", ",", "'comment'", ":", "''", ",", "'changes'", ":", ...
Write a default to the system name The key of the given domain to write to domain The name of the domain to write to value The value to write to the given key vtype The type of value to be written, valid types are string, data, int[eger], float, bool[ean], dat...
[ "Write", "a", "default", "to", "the", "system" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/macdefaults.py#L28-L78
train
saltstack/salt
salt/states/macdefaults.py
absent
def absent(name, domain, user=None): ''' Make sure the defaults value is absent name The key of the given domain to remove domain The name of the domain to remove from user The user to write the defaults to ''' ret = {'name': name, 'result': True, ...
python
def absent(name, domain, user=None): ''' Make sure the defaults value is absent name The key of the given domain to remove domain The name of the domain to remove from user The user to write the defaults to ''' ret = {'name': name, 'result': True, ...
[ "def", "absent", "(", "name", ",", "domain", ",", "user", "=", "None", ")", ":", "ret", "=", "{", "'name'", ":", "name", ",", "'result'", ":", "True", ",", "'comment'", ":", "''", ",", "'changes'", ":", "{", "}", "}", "out", "=", "__salt__", "[",...
Make sure the defaults value is absent name The key of the given domain to remove domain The name of the domain to remove from user The user to write the defaults to
[ "Make", "sure", "the", "defaults", "value", "is", "absent" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/macdefaults.py#L81-L108
train
saltstack/salt
salt/modules/win_shadow.py
info
def info(name): ''' Return information for the specified user This is just returns dummy data so that salt states can work. :param str name: The name of the user account to show. CLI Example: .. code-block:: bash salt '*' shadow.info root ''' info = __salt__['user.info'](name...
python
def info(name): ''' Return information for the specified user This is just returns dummy data so that salt states can work. :param str name: The name of the user account to show. CLI Example: .. code-block:: bash salt '*' shadow.info root ''' info = __salt__['user.info'](name...
[ "def", "info", "(", "name", ")", ":", "info", "=", "__salt__", "[", "'user.info'", "]", "(", "name", "=", "name", ")", "ret", "=", "{", "'name'", ":", "name", ",", "'passwd'", ":", "''", ",", "'lstchg'", ":", "''", ",", "'min'", ":", "''", ",", ...
Return information for the specified user This is just returns dummy data so that salt states can work. :param str name: The name of the user account to show. CLI Example: .. code-block:: bash salt '*' shadow.info root
[ "Return", "information", "for", "the", "specified", "user", "This", "is", "just", "returns", "dummy", "data", "so", "that", "salt", "states", "can", "work", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_shadow.py#L30-L64
train
saltstack/salt
salt/utils/saltclass.py
get_class_paths
def get_class_paths(_class, saltclass_path): ''' Converts the dotted notation of a saltclass class to its possible file counterparts. :param str _class: Dotted notation of the class :param str saltclass_path: Root to saltclass storage :return: 3-tuple of possible file counterparts :rtype: tuple...
python
def get_class_paths(_class, saltclass_path): ''' Converts the dotted notation of a saltclass class to its possible file counterparts. :param str _class: Dotted notation of the class :param str saltclass_path: Root to saltclass storage :return: 3-tuple of possible file counterparts :rtype: tuple...
[ "def", "get_class_paths", "(", "_class", ",", "saltclass_path", ")", ":", "straight", "=", "os", ".", "path", ".", "join", "(", "saltclass_path", ",", "'classes'", ",", "'{0}.yml'", ".", "format", "(", "_class", ")", ")", "sub_straight", "=", "os", ".", ...
Converts the dotted notation of a saltclass class to its possible file counterparts. :param str _class: Dotted notation of the class :param str saltclass_path: Root to saltclass storage :return: 3-tuple of possible file counterparts :rtype: tuple(str)
[ "Converts", "the", "dotted", "notation", "of", "a", "saltclass", "class", "to", "its", "possible", "file", "counterparts", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/saltclass.py#L64-L83
train
saltstack/salt
salt/utils/saltclass.py
get_class_from_file
def get_class_from_file(_file, saltclass_path): ''' Converts the absolute path to a saltclass file back to the dotted notation. .. code-block:: python print(get_class_from_file('/srv/saltclass/classes/services/nginx/init.yml', '/srv/saltclass')) # services.nginx :param str _file: Absolu...
python
def get_class_from_file(_file, saltclass_path): ''' Converts the absolute path to a saltclass file back to the dotted notation. .. code-block:: python print(get_class_from_file('/srv/saltclass/classes/services/nginx/init.yml', '/srv/saltclass')) # services.nginx :param str _file: Absolu...
[ "def", "get_class_from_file", "(", "_file", ",", "saltclass_path", ")", ":", "# remove classes path prefix", "_file", "=", "_file", "[", "len", "(", "os", ".", "path", ".", "join", "(", "saltclass_path", ",", "'classes'", ")", ")", "+", "len", "(", "os", "...
Converts the absolute path to a saltclass file back to the dotted notation. .. code-block:: python print(get_class_from_file('/srv/saltclass/classes/services/nginx/init.yml', '/srv/saltclass')) # services.nginx :param str _file: Absolute path to file :param str saltclass_path: Root to saltc...
[ "Converts", "the", "absolute", "path", "to", "a", "saltclass", "file", "back", "to", "the", "dotted", "notation", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/saltclass.py#L86-L109
train
saltstack/salt
salt/utils/saltclass.py
match_class_glob
def match_class_glob(_class, saltclass_path): ''' Takes a class name possibly including `*` or `?` wildcards (or any other wildcards supportet by `glob.glob`) and returns a list of expanded class names without wildcards. .. code-block:: python classes = match_class_glob('services.*', '/srv/salt...
python
def match_class_glob(_class, saltclass_path): ''' Takes a class name possibly including `*` or `?` wildcards (or any other wildcards supportet by `glob.glob`) and returns a list of expanded class names without wildcards. .. code-block:: python classes = match_class_glob('services.*', '/srv/salt...
[ "def", "match_class_glob", "(", "_class", ",", "saltclass_path", ")", ":", "straight", ",", "sub_init", ",", "sub_straight", "=", "get_class_paths", "(", "_class", ",", "saltclass_path", ")", "classes", "=", "[", "]", "matches", "=", "[", "]", "matches", "."...
Takes a class name possibly including `*` or `?` wildcards (or any other wildcards supportet by `glob.glob`) and returns a list of expanded class names without wildcards. .. code-block:: python classes = match_class_glob('services.*', '/srv/saltclass') print(classes) # services.mariadb ...
[ "Takes", "a", "class", "name", "possibly", "including", "*", "or", "?", "wildcards", "(", "or", "any", "other", "wildcards", "supportet", "by", "glob", ".", "glob", ")", "and", "returns", "a", "list", "of", "expanded", "class", "names", "without", "wildcar...
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/saltclass.py#L231-L260
train
saltstack/salt
salt/utils/saltclass.py
expand_classes_glob
def expand_classes_glob(classes, salt_data): ''' Expand the list of `classes` to no longer include any globbing. :param iterable(str) classes: Iterable of classes :param dict salt_data: configuration data :return: Expanded list of classes with resolved globbing :rtype: list(str) ''' all...
python
def expand_classes_glob(classes, salt_data): ''' Expand the list of `classes` to no longer include any globbing. :param iterable(str) classes: Iterable of classes :param dict salt_data: configuration data :return: Expanded list of classes with resolved globbing :rtype: list(str) ''' all...
[ "def", "expand_classes_glob", "(", "classes", ",", "salt_data", ")", ":", "all_classes", "=", "[", "]", "expanded_classes", "=", "[", "]", "saltclass_path", "=", "salt_data", "[", "'path'", "]", "for", "_class", "in", "classes", ":", "all_classes", ".", "ext...
Expand the list of `classes` to no longer include any globbing. :param iterable(str) classes: Iterable of classes :param dict salt_data: configuration data :return: Expanded list of classes with resolved globbing :rtype: list(str)
[ "Expand", "the", "list", "of", "classes", "to", "no", "longer", "include", "any", "globbing", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/saltclass.py#L263-L283
train
saltstack/salt
salt/modules/syslog_ng.py
_is_simple_type
def _is_simple_type(value): ''' Returns True, if the given parameter value is an instance of either int, str, float or bool. ''' return isinstance(value, six.string_types) or isinstance(value, int) or isinstance(value, float) or isinstance(value, bool)
python
def _is_simple_type(value): ''' Returns True, if the given parameter value is an instance of either int, str, float or bool. ''' return isinstance(value, six.string_types) or isinstance(value, int) or isinstance(value, float) or isinstance(value, bool)
[ "def", "_is_simple_type", "(", "value", ")", ":", "return", "isinstance", "(", "value", ",", "six", ".", "string_types", ")", "or", "isinstance", "(", "value", ",", "int", ")", "or", "isinstance", "(", "value", ",", "float", ")", "or", "isinstance", "(",...
Returns True, if the given parameter value is an instance of either int, str, float or bool.
[ "Returns", "True", "if", "the", "given", "parameter", "value", "is", "an", "instance", "of", "either", "int", "str", "float", "or", "bool", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L425-L430
train
saltstack/salt
salt/modules/syslog_ng.py
_get_type_id_options
def _get_type_id_options(name, configuration): ''' Returns the type, id and option of a configuration object. ''' # it's in a form of source.name if '.' in name: type_, sep, id_ = name.partition('.') options = configuration else: type_ = next(six.iterkeys(configuration)) ...
python
def _get_type_id_options(name, configuration): ''' Returns the type, id and option of a configuration object. ''' # it's in a form of source.name if '.' in name: type_, sep, id_ = name.partition('.') options = configuration else: type_ = next(six.iterkeys(configuration)) ...
[ "def", "_get_type_id_options", "(", "name", ",", "configuration", ")", ":", "# it's in a form of source.name", "if", "'.'", "in", "name", ":", "type_", ",", "sep", ",", "id_", "=", "name", ".", "partition", "(", "'.'", ")", "options", "=", "configuration", "...
Returns the type, id and option of a configuration object.
[ "Returns", "the", "type", "id", "and", "option", "of", "a", "configuration", "object", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L433-L446
train
saltstack/salt
salt/modules/syslog_ng.py
_expand_one_key_dictionary
def _expand_one_key_dictionary(_dict): ''' Returns the only one key and it's value from a dictionary. ''' key = next(six.iterkeys(_dict)) value = _dict[key] return key, value
python
def _expand_one_key_dictionary(_dict): ''' Returns the only one key and it's value from a dictionary. ''' key = next(six.iterkeys(_dict)) value = _dict[key] return key, value
[ "def", "_expand_one_key_dictionary", "(", "_dict", ")", ":", "key", "=", "next", "(", "six", ".", "iterkeys", "(", "_dict", ")", ")", "value", "=", "_dict", "[", "key", "]", "return", "key", ",", "value" ]
Returns the only one key and it's value from a dictionary.
[ "Returns", "the", "only", "one", "key", "and", "it", "s", "value", "from", "a", "dictionary", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L449-L455
train
saltstack/salt
salt/modules/syslog_ng.py
_parse_typed_parameter_typed_value
def _parse_typed_parameter_typed_value(values): ''' Creates Arguments in a TypedParametervalue. ''' type_, value = _expand_one_key_dictionary(values) _current_parameter_value.type = type_ if _is_simple_type(value): arg = Argument(value) _current_parameter_value.add_argument(arg)...
python
def _parse_typed_parameter_typed_value(values): ''' Creates Arguments in a TypedParametervalue. ''' type_, value = _expand_one_key_dictionary(values) _current_parameter_value.type = type_ if _is_simple_type(value): arg = Argument(value) _current_parameter_value.add_argument(arg)...
[ "def", "_parse_typed_parameter_typed_value", "(", "values", ")", ":", "type_", ",", "value", "=", "_expand_one_key_dictionary", "(", "values", ")", "_current_parameter_value", ".", "type", "=", "type_", "if", "_is_simple_type", "(", "value", ")", ":", "arg", "=", ...
Creates Arguments in a TypedParametervalue.
[ "Creates", "Arguments", "in", "a", "TypedParametervalue", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L458-L471
train
saltstack/salt
salt/modules/syslog_ng.py
_parse_typed_parameter
def _parse_typed_parameter(param): ''' Parses a TypedParameter and fills it with values. ''' global _current_parameter_value type_, value = _expand_one_key_dictionary(param) _current_parameter.type = type_ if _is_simple_type(value) and value != '': _current_parameter_value = SimpleP...
python
def _parse_typed_parameter(param): ''' Parses a TypedParameter and fills it with values. ''' global _current_parameter_value type_, value = _expand_one_key_dictionary(param) _current_parameter.type = type_ if _is_simple_type(value) and value != '': _current_parameter_value = SimpleP...
[ "def", "_parse_typed_parameter", "(", "param", ")", ":", "global", "_current_parameter_value", "type_", ",", "value", "=", "_expand_one_key_dictionary", "(", "param", ")", "_current_parameter", ".", "type", "=", "type_", "if", "_is_simple_type", "(", "value", ")", ...
Parses a TypedParameter and fills it with values.
[ "Parses", "a", "TypedParameter", "and", "fills", "it", "with", "values", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L474-L493
train
saltstack/salt
salt/modules/syslog_ng.py
_create_and_add_parameters
def _create_and_add_parameters(params): ''' Parses the configuration and creates Parameter instances. ''' global _current_parameter if _is_simple_type(params): _current_parameter = SimpleParameter(params) _current_option.add_parameter(_current_parameter) else: # must be a...
python
def _create_and_add_parameters(params): ''' Parses the configuration and creates Parameter instances. ''' global _current_parameter if _is_simple_type(params): _current_parameter = SimpleParameter(params) _current_option.add_parameter(_current_parameter) else: # must be a...
[ "def", "_create_and_add_parameters", "(", "params", ")", ":", "global", "_current_parameter", "if", "_is_simple_type", "(", "params", ")", ":", "_current_parameter", "=", "SimpleParameter", "(", "params", ")", "_current_option", ".", "add_parameter", "(", "_current_pa...
Parses the configuration and creates Parameter instances.
[ "Parses", "the", "configuration", "and", "creates", "Parameter", "instances", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L496-L512
train
saltstack/salt
salt/modules/syslog_ng.py
_create_and_add_option
def _create_and_add_option(option): ''' Parses the configuration and creates an Option instance. ''' global _current_option _current_option = Option() type_, params = _expand_one_key_dictionary(option) _current_option.type = type_ _create_and_add_parameters(params) _current_statemen...
python
def _create_and_add_option(option): ''' Parses the configuration and creates an Option instance. ''' global _current_option _current_option = Option() type_, params = _expand_one_key_dictionary(option) _current_option.type = type_ _create_and_add_parameters(params) _current_statemen...
[ "def", "_create_and_add_option", "(", "option", ")", ":", "global", "_current_option", "_current_option", "=", "Option", "(", ")", "type_", ",", "params", "=", "_expand_one_key_dictionary", "(", "option", ")", "_current_option", ".", "type", "=", "type_", "_create...
Parses the configuration and creates an Option instance.
[ "Parses", "the", "configuration", "and", "creates", "an", "Option", "instance", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L515-L525
train
saltstack/salt
salt/modules/syslog_ng.py
_is_reference
def _is_reference(arg): ''' Return True, if arg is a reference to a previously defined statement. ''' return isinstance(arg, dict) and len(arg) == 1 and isinstance(next(six.itervalues(arg)), six.string_types)
python
def _is_reference(arg): ''' Return True, if arg is a reference to a previously defined statement. ''' return isinstance(arg, dict) and len(arg) == 1 and isinstance(next(six.itervalues(arg)), six.string_types)
[ "def", "_is_reference", "(", "arg", ")", ":", "return", "isinstance", "(", "arg", ",", "dict", ")", "and", "len", "(", "arg", ")", "==", "1", "and", "isinstance", "(", "next", "(", "six", ".", "itervalues", "(", "arg", ")", ")", ",", "six", ".", ...
Return True, if arg is a reference to a previously defined statement.
[ "Return", "True", "if", "arg", "is", "a", "reference", "to", "a", "previously", "defined", "statement", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L536-L540
train
saltstack/salt
salt/modules/syslog_ng.py
_is_junction
def _is_junction(arg): ''' Return True, if arg is a junction statement. ''' return isinstance(arg, dict) and len(arg) == 1 and next(six.iterkeys(arg)) == 'junction'
python
def _is_junction(arg): ''' Return True, if arg is a junction statement. ''' return isinstance(arg, dict) and len(arg) == 1 and next(six.iterkeys(arg)) == 'junction'
[ "def", "_is_junction", "(", "arg", ")", ":", "return", "isinstance", "(", "arg", ",", "dict", ")", "and", "len", "(", "arg", ")", "==", "1", "and", "next", "(", "six", ".", "iterkeys", "(", "arg", ")", ")", "==", "'junction'" ]
Return True, if arg is a junction statement.
[ "Return", "True", "if", "arg", "is", "a", "junction", "statement", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L543-L547
train
saltstack/salt
salt/modules/syslog_ng.py
_add_reference
def _add_reference(reference, statement): ''' Adds a reference to statement. ''' type_, value = _expand_one_key_dictionary(reference) opt = Option(type_) param = SimpleParameter(value) opt.add_parameter(param) statement.add_child(opt)
python
def _add_reference(reference, statement): ''' Adds a reference to statement. ''' type_, value = _expand_one_key_dictionary(reference) opt = Option(type_) param = SimpleParameter(value) opt.add_parameter(param) statement.add_child(opt)
[ "def", "_add_reference", "(", "reference", ",", "statement", ")", ":", "type_", ",", "value", "=", "_expand_one_key_dictionary", "(", "reference", ")", "opt", "=", "Option", "(", "type_", ")", "param", "=", "SimpleParameter", "(", "value", ")", "opt", ".", ...
Adds a reference to statement.
[ "Adds", "a", "reference", "to", "statement", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L550-L558
train
saltstack/salt
salt/modules/syslog_ng.py
_is_inline_definition
def _is_inline_definition(arg): ''' Returns True, if arg is an inline definition of a statement. ''' return isinstance(arg, dict) and len(arg) == 1 and isinstance(next(six.itervalues(arg)), list)
python
def _is_inline_definition(arg): ''' Returns True, if arg is an inline definition of a statement. ''' return isinstance(arg, dict) and len(arg) == 1 and isinstance(next(six.itervalues(arg)), list)
[ "def", "_is_inline_definition", "(", "arg", ")", ":", "return", "isinstance", "(", "arg", ",", "dict", ")", "and", "len", "(", "arg", ")", "==", "1", "and", "isinstance", "(", "next", "(", "six", ".", "itervalues", "(", "arg", ")", ")", ",", "list", ...
Returns True, if arg is an inline definition of a statement.
[ "Returns", "True", "if", "arg", "is", "an", "inline", "definition", "of", "a", "statement", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L561-L565
train
saltstack/salt
salt/modules/syslog_ng.py
_add_inline_definition
def _add_inline_definition(item, statement): ''' Adds an inline definition to statement. ''' global _current_statement backup = _current_statement type_, options = _expand_one_key_dictionary(item) _current_statement = UnnamedStatement(type=type_) _parse_statement(options) statement....
python
def _add_inline_definition(item, statement): ''' Adds an inline definition to statement. ''' global _current_statement backup = _current_statement type_, options = _expand_one_key_dictionary(item) _current_statement = UnnamedStatement(type=type_) _parse_statement(options) statement....
[ "def", "_add_inline_definition", "(", "item", ",", "statement", ")", ":", "global", "_current_statement", "backup", "=", "_current_statement", "type_", ",", "options", "=", "_expand_one_key_dictionary", "(", "item", ")", "_current_statement", "=", "UnnamedStatement", ...
Adds an inline definition to statement.
[ "Adds", "an", "inline", "definition", "to", "statement", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L568-L580
train
saltstack/salt
salt/modules/syslog_ng.py
_add_junction
def _add_junction(item): ''' Adds a junction to the _current_statement. ''' type_, channels = _expand_one_key_dictionary(item) junction = UnnamedStatement(type='junction') for item in channels: type_, value = _expand_one_key_dictionary(item) channel = UnnamedStatement(type='chann...
python
def _add_junction(item): ''' Adds a junction to the _current_statement. ''' type_, channels = _expand_one_key_dictionary(item) junction = UnnamedStatement(type='junction') for item in channels: type_, value = _expand_one_key_dictionary(item) channel = UnnamedStatement(type='chann...
[ "def", "_add_junction", "(", "item", ")", ":", "type_", ",", "channels", "=", "_expand_one_key_dictionary", "(", "item", ")", "junction", "=", "UnnamedStatement", "(", "type", "=", "'junction'", ")", "for", "item", "in", "channels", ":", "type_", ",", "value...
Adds a junction to the _current_statement.
[ "Adds", "a", "junction", "to", "the", "_current_statement", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L583-L598
train
saltstack/salt
salt/modules/syslog_ng.py
_parse_log_statement
def _parse_log_statement(options): ''' Parses a log path. ''' for i in options: if _is_reference(i): _add_reference(i, _current_statement) elif _is_junction(i): _add_junction(i) elif _is_inline_definition(i): _add_inline_definition(i, _current_...
python
def _parse_log_statement(options): ''' Parses a log path. ''' for i in options: if _is_reference(i): _add_reference(i, _current_statement) elif _is_junction(i): _add_junction(i) elif _is_inline_definition(i): _add_inline_definition(i, _current_...
[ "def", "_parse_log_statement", "(", "options", ")", ":", "for", "i", "in", "options", ":", "if", "_is_reference", "(", "i", ")", ":", "_add_reference", "(", "i", ",", "_current_statement", ")", "elif", "_is_junction", "(", "i", ")", ":", "_add_junction", "...
Parses a log path.
[ "Parses", "a", "log", "path", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L601-L611
train
saltstack/salt
salt/modules/syslog_ng.py
_build_config_tree
def _build_config_tree(name, configuration): ''' Build the configuration tree. The root object is _current_statement. ''' type_, id_, options = _get_type_id_options(name, configuration) global _INDENT, _current_statement _INDENT = '' if type_ == 'config': _current_statement = Gi...
python
def _build_config_tree(name, configuration): ''' Build the configuration tree. The root object is _current_statement. ''' type_, id_, options = _get_type_id_options(name, configuration) global _INDENT, _current_statement _INDENT = '' if type_ == 'config': _current_statement = Gi...
[ "def", "_build_config_tree", "(", "name", ",", "configuration", ")", ":", "type_", ",", "id_", ",", "options", "=", "_get_type_id_options", "(", "name", ",", "configuration", ")", "global", "_INDENT", ",", "_current_statement", "_INDENT", "=", "''", "if", "typ...
Build the configuration tree. The root object is _current_statement.
[ "Build", "the", "configuration", "tree", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L614-L633
train
saltstack/salt
salt/modules/syslog_ng.py
config
def config(name, config, write=True): ''' Builds syslog-ng configuration. This function is intended to be used from the state module, users should not use it directly! name : the id of the Salt document or it is the format of <statement name>.id config : the parsed YAML code ...
python
def config(name, config, write=True): ''' Builds syslog-ng configuration. This function is intended to be used from the state module, users should not use it directly! name : the id of the Salt document or it is the format of <statement name>.id config : the parsed YAML code ...
[ "def", "config", "(", "name", ",", "config", ",", "write", "=", "True", ")", ":", "_build_config_tree", "(", "name", ",", "config", ")", "configs", "=", "_render_configuration", "(", ")", "if", "__opts__", ".", "get", "(", "'test'", ",", "False", ")", ...
Builds syslog-ng configuration. This function is intended to be used from the state module, users should not use it directly! name : the id of the Salt document or it is the format of <statement name>.id config : the parsed YAML code write : if True, it writes the config into the configuration file, ...
[ "Builds", "syslog", "-", "ng", "configuration", ".", "This", "function", "is", "intended", "to", "be", "used", "from", "the", "state", "module", "users", "should", "not", "use", "it", "directly!" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L645-L680
train
saltstack/salt
salt/modules/syslog_ng.py
set_binary_path
def set_binary_path(name): ''' Sets the path, where the syslog-ng binary can be found. This function is intended to be used from states. If syslog-ng is installed via a package manager, users don't need to use this function. CLI Example: .. code-block:: bash salt '*' syslog_ng.se...
python
def set_binary_path(name): ''' Sets the path, where the syslog-ng binary can be found. This function is intended to be used from states. If syslog-ng is installed via a package manager, users don't need to use this function. CLI Example: .. code-block:: bash salt '*' syslog_ng.se...
[ "def", "set_binary_path", "(", "name", ")", ":", "global", "__SYSLOG_NG_BINARY_PATH", "old", "=", "__SYSLOG_NG_BINARY_PATH", "__SYSLOG_NG_BINARY_PATH", "=", "name", "changes", "=", "_format_changes", "(", "old", ",", "name", ")", "return", "_format_state_result", "(",...
Sets the path, where the syslog-ng binary can be found. This function is intended to be used from states. If syslog-ng is installed via a package manager, users don't need to use this function. CLI Example: .. code-block:: bash salt '*' syslog_ng.set_binary_path name=/usr/sbin
[ "Sets", "the", "path", "where", "the", "syslog", "-", "ng", "binary", "can", "be", "found", ".", "This", "function", "is", "intended", "to", "be", "used", "from", "states", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L683-L702
train
saltstack/salt
salt/modules/syslog_ng.py
set_config_file
def set_config_file(name): ''' Sets the configuration's name. This function is intended to be used from states. CLI Example: .. code-block:: bash salt '*' syslog_ng.set_config_file name=/etc/syslog-ng ''' global __SYSLOG_NG_CONFIG_FILE old = __SYSLOG_NG_CONFIG_FILE __SYSL...
python
def set_config_file(name): ''' Sets the configuration's name. This function is intended to be used from states. CLI Example: .. code-block:: bash salt '*' syslog_ng.set_config_file name=/etc/syslog-ng ''' global __SYSLOG_NG_CONFIG_FILE old = __SYSLOG_NG_CONFIG_FILE __SYSL...
[ "def", "set_config_file", "(", "name", ")", ":", "global", "__SYSLOG_NG_CONFIG_FILE", "old", "=", "__SYSLOG_NG_CONFIG_FILE", "__SYSLOG_NG_CONFIG_FILE", "=", "name", "changes", "=", "_format_changes", "(", "old", ",", "name", ")", "return", "_format_state_result", "(",...
Sets the configuration's name. This function is intended to be used from states. CLI Example: .. code-block:: bash salt '*' syslog_ng.set_config_file name=/etc/syslog-ng
[ "Sets", "the", "configuration", "s", "name", ".", "This", "function", "is", "intended", "to", "be", "used", "from", "states", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L705-L721
train
saltstack/salt
salt/modules/syslog_ng.py
_run_command
def _run_command(cmd, options=(), env=None): ''' Runs the command cmd with options as its CLI parameters and returns the result as a dictionary. ''' params = [cmd] params.extend(options) return __salt__['cmd.run_all'](params, env=env, python_shell=False)
python
def _run_command(cmd, options=(), env=None): ''' Runs the command cmd with options as its CLI parameters and returns the result as a dictionary. ''' params = [cmd] params.extend(options) return __salt__['cmd.run_all'](params, env=env, python_shell=False)
[ "def", "_run_command", "(", "cmd", ",", "options", "=", "(", ")", ",", "env", "=", "None", ")", ":", "params", "=", "[", "cmd", "]", "params", ".", "extend", "(", "options", ")", "return", "__salt__", "[", "'cmd.run_all'", "]", "(", "params", ",", ...
Runs the command cmd with options as its CLI parameters and returns the result as a dictionary.
[ "Runs", "the", "command", "cmd", "with", "options", "as", "its", "CLI", "parameters", "and", "returns", "the", "result", "as", "a", "dictionary", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L738-L745
train
saltstack/salt
salt/modules/syslog_ng.py
set_parameters
def set_parameters(version=None, binary_path=None, config_file=None, *args, **kwargs): ''' Sets variables. CLI Example: .. code-block:: bash salt '*' syslog_ng.set_parameters version='3.6' salt '*' syslog_ng.s...
python
def set_parameters(version=None, binary_path=None, config_file=None, *args, **kwargs): ''' Sets variables. CLI Example: .. code-block:: bash salt '*' syslog_ng.set_parameters version='3.6' salt '*' syslog_ng.s...
[ "def", "set_parameters", "(", "version", "=", "None", ",", "binary_path", "=", "None", ",", "config_file", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "binary_path", ":", "set_binary_path", "(", "binary_path", ")", "if", "conf...
Sets variables. CLI Example: .. code-block:: bash salt '*' syslog_ng.set_parameters version='3.6' salt '*' syslog_ng.set_parameters binary_path=/home/user/install/syslog-ng/sbin config_file=/home/user/install/syslog-ng/etc/syslog-ng.conf
[ "Sets", "variables", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L761-L785
train
saltstack/salt
salt/modules/syslog_ng.py
_run_command_in_extended_path
def _run_command_in_extended_path(syslog_ng_sbin_dir, command, params): ''' Runs the specified command with the syslog_ng_sbin_dir in the PATH ''' orig_path = os.environ.get('PATH', '') env = None if syslog_ng_sbin_dir: # Custom environment variables should be str types. This code ...
python
def _run_command_in_extended_path(syslog_ng_sbin_dir, command, params): ''' Runs the specified command with the syslog_ng_sbin_dir in the PATH ''' orig_path = os.environ.get('PATH', '') env = None if syslog_ng_sbin_dir: # Custom environment variables should be str types. This code ...
[ "def", "_run_command_in_extended_path", "(", "syslog_ng_sbin_dir", ",", "command", ",", "params", ")", ":", "orig_path", "=", "os", ".", "environ", ".", "get", "(", "'PATH'", ",", "''", ")", "env", "=", "None", "if", "syslog_ng_sbin_dir", ":", "# Custom enviro...
Runs the specified command with the syslog_ng_sbin_dir in the PATH
[ "Runs", "the", "specified", "command", "with", "the", "syslog_ng_sbin_dir", "in", "the", "PATH" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L788-L807
train
saltstack/salt
salt/modules/syslog_ng.py
_format_return_data
def _format_return_data(retcode, stdout=None, stderr=None): ''' Creates a dictionary from the parameters, which can be used to return data to Salt. ''' ret = {'retcode': retcode} if stdout is not None: ret['stdout'] = stdout if stderr is not None: ret['stderr'] = stderr r...
python
def _format_return_data(retcode, stdout=None, stderr=None): ''' Creates a dictionary from the parameters, which can be used to return data to Salt. ''' ret = {'retcode': retcode} if stdout is not None: ret['stdout'] = stdout if stderr is not None: ret['stderr'] = stderr r...
[ "def", "_format_return_data", "(", "retcode", ",", "stdout", "=", "None", ",", "stderr", "=", "None", ")", ":", "ret", "=", "{", "'retcode'", ":", "retcode", "}", "if", "stdout", "is", "not", "None", ":", "ret", "[", "'stdout'", "]", "=", "stdout", "...
Creates a dictionary from the parameters, which can be used to return data to Salt.
[ "Creates", "a", "dictionary", "from", "the", "parameters", "which", "can", "be", "used", "to", "return", "data", "to", "Salt", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L810-L820
train
saltstack/salt
salt/modules/syslog_ng.py
version
def version(syslog_ng_sbin_dir=None): ''' Returns the version of the installed syslog-ng. If syslog_ng_sbin_dir is specified, it is added to the PATH during the execution of the command syslog-ng. CLI Example: .. code-block:: bash salt '*' syslog_ng.version salt '*' syslog_ng....
python
def version(syslog_ng_sbin_dir=None): ''' Returns the version of the installed syslog-ng. If syslog_ng_sbin_dir is specified, it is added to the PATH during the execution of the command syslog-ng. CLI Example: .. code-block:: bash salt '*' syslog_ng.version salt '*' syslog_ng....
[ "def", "version", "(", "syslog_ng_sbin_dir", "=", "None", ")", ":", "try", ":", "ret", "=", "_run_command_in_extended_path", "(", "syslog_ng_sbin_dir", ",", "'syslog-ng'", ",", "(", "'-V'", ",", ")", ")", "except", "CommandExecutionError", "as", "err", ":", "r...
Returns the version of the installed syslog-ng. If syslog_ng_sbin_dir is specified, it is added to the PATH during the execution of the command syslog-ng. CLI Example: .. code-block:: bash salt '*' syslog_ng.version salt '*' syslog_ng.version /home/user/install/syslog-ng/sbin
[ "Returns", "the", "version", "of", "the", "installed", "syslog", "-", "ng", ".", "If", "syslog_ng_sbin_dir", "is", "specified", "it", "is", "added", "to", "the", "PATH", "during", "the", "execution", "of", "the", "command", "syslog", "-", "ng", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L853-L884
train
saltstack/salt
salt/modules/syslog_ng.py
modules
def modules(syslog_ng_sbin_dir=None): ''' Returns the available modules. If syslog_ng_sbin_dir is specified, it is added to the PATH during the execution of the command syslog-ng. CLI Example: .. code-block:: bash salt '*' syslog_ng.modules salt '*' syslog_ng.modules /home/user/in...
python
def modules(syslog_ng_sbin_dir=None): ''' Returns the available modules. If syslog_ng_sbin_dir is specified, it is added to the PATH during the execution of the command syslog-ng. CLI Example: .. code-block:: bash salt '*' syslog_ng.modules salt '*' syslog_ng.modules /home/user/in...
[ "def", "modules", "(", "syslog_ng_sbin_dir", "=", "None", ")", ":", "try", ":", "ret", "=", "_run_command_in_extended_path", "(", "syslog_ng_sbin_dir", ",", "'syslog-ng'", ",", "(", "'-V'", ",", ")", ")", "except", "CommandExecutionError", "as", "err", ":", "r...
Returns the available modules. If syslog_ng_sbin_dir is specified, it is added to the PATH during the execution of the command syslog-ng. CLI Example: .. code-block:: bash salt '*' syslog_ng.modules salt '*' syslog_ng.modules /home/user/install/syslog-ng/sbin
[ "Returns", "the", "available", "modules", ".", "If", "syslog_ng_sbin_dir", "is", "specified", "it", "is", "added", "to", "the", "PATH", "during", "the", "execution", "of", "the", "command", "syslog", "-", "ng", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L887-L917
train
saltstack/salt
salt/modules/syslog_ng.py
stats
def stats(syslog_ng_sbin_dir=None): ''' Returns statistics from the running syslog-ng instance. If syslog_ng_sbin_dir is specified, it is added to the PATH during the execution of the command syslog-ng-ctl. CLI Example: .. code-block:: bash salt '*' syslog_ng.stats salt '*' sy...
python
def stats(syslog_ng_sbin_dir=None): ''' Returns statistics from the running syslog-ng instance. If syslog_ng_sbin_dir is specified, it is added to the PATH during the execution of the command syslog-ng-ctl. CLI Example: .. code-block:: bash salt '*' syslog_ng.stats salt '*' sy...
[ "def", "stats", "(", "syslog_ng_sbin_dir", "=", "None", ")", ":", "try", ":", "ret", "=", "_run_command_in_extended_path", "(", "syslog_ng_sbin_dir", ",", "'syslog-ng-ctl'", ",", "(", "'stats'", ",", ")", ")", "except", "CommandExecutionError", "as", "err", ":",...
Returns statistics from the running syslog-ng instance. If syslog_ng_sbin_dir is specified, it is added to the PATH during the execution of the command syslog-ng-ctl. CLI Example: .. code-block:: bash salt '*' syslog_ng.stats salt '*' syslog_ng.stats /home/user/install/syslog-ng/sbin
[ "Returns", "statistics", "from", "the", "running", "syslog", "-", "ng", "instance", ".", "If", "syslog_ng_sbin_dir", "is", "specified", "it", "is", "added", "to", "the", "PATH", "during", "the", "execution", "of", "the", "command", "syslog", "-", "ng", "-", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L920-L942
train
saltstack/salt
salt/modules/syslog_ng.py
_format_state_result
def _format_state_result(name, result, changes=None, comment=''): ''' Creates the state result dictionary. ''' if changes is None: changes = {'old': '', 'new': ''} return {'name': name, 'result': result, 'changes': changes, 'comment': comment}
python
def _format_state_result(name, result, changes=None, comment=''): ''' Creates the state result dictionary. ''' if changes is None: changes = {'old': '', 'new': ''} return {'name': name, 'result': result, 'changes': changes, 'comment': comment}
[ "def", "_format_state_result", "(", "name", ",", "result", ",", "changes", "=", "None", ",", "comment", "=", "''", ")", ":", "if", "changes", "is", "None", ":", "changes", "=", "{", "'old'", ":", "''", ",", "'new'", ":", "''", "}", "return", "{", "...
Creates the state result dictionary.
[ "Creates", "the", "state", "result", "dictionary", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L949-L956
train
saltstack/salt
salt/modules/syslog_ng.py
_add_cli_param
def _add_cli_param(params, key, value): ''' Adds key and value as a command line parameter to params. ''' if value is not None: params.append('--{0}={1}'.format(key, value))
python
def _add_cli_param(params, key, value): ''' Adds key and value as a command line parameter to params. ''' if value is not None: params.append('--{0}={1}'.format(key, value))
[ "def", "_add_cli_param", "(", "params", ",", "key", ",", "value", ")", ":", "if", "value", "is", "not", "None", ":", "params", ".", "append", "(", "'--{0}={1}'", ".", "format", "(", "key", ",", "value", ")", ")" ]
Adds key and value as a command line parameter to params.
[ "Adds", "key", "and", "value", "as", "a", "command", "line", "parameter", "to", "params", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L959-L964
train
saltstack/salt
salt/modules/syslog_ng.py
_add_boolean_cli_param
def _add_boolean_cli_param(params, key, value): ''' Adds key as a command line parameter to params. ''' if value is True: params.append('--{0}'.format(key))
python
def _add_boolean_cli_param(params, key, value): ''' Adds key as a command line parameter to params. ''' if value is True: params.append('--{0}'.format(key))
[ "def", "_add_boolean_cli_param", "(", "params", ",", "key", ",", "value", ")", ":", "if", "value", "is", "True", ":", "params", ".", "append", "(", "'--{0}'", ".", "format", "(", "key", ")", ")" ]
Adds key as a command line parameter to params.
[ "Adds", "key", "as", "a", "command", "line", "parameter", "to", "params", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L967-L972
train
saltstack/salt
salt/modules/syslog_ng.py
stop
def stop(name=None): ''' Kills syslog-ng. This function is intended to be used from the state module. Users shouldn't use this function, if the service module is available on their system. If :mod:`syslog_ng.set_config_file <salt.modules.syslog_ng.set_binary_path>` is called before, this function ...
python
def stop(name=None): ''' Kills syslog-ng. This function is intended to be used from the state module. Users shouldn't use this function, if the service module is available on their system. If :mod:`syslog_ng.set_config_file <salt.modules.syslog_ng.set_binary_path>` is called before, this function ...
[ "def", "stop", "(", "name", "=", "None", ")", ":", "pids", "=", "__salt__", "[", "'ps.pgrep'", "]", "(", "pattern", "=", "'syslog-ng'", ")", "if", "not", "pids", ":", "return", "_format_state_result", "(", "name", ",", "result", "=", "False", ",", "com...
Kills syslog-ng. This function is intended to be used from the state module. Users shouldn't use this function, if the service module is available on their system. If :mod:`syslog_ng.set_config_file <salt.modules.syslog_ng.set_binary_path>` is called before, this function will use the set binary path....
[ "Kills", "syslog", "-", "ng", ".", "This", "function", "is", "intended", "to", "be", "used", "from", "the", "state", "module", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L975-L1009
train
saltstack/salt
salt/modules/syslog_ng.py
start
def start(name=None, user=None, group=None, chroot=None, caps=None, no_caps=False, pidfile=None, enable_core=False, fd_limit=None, verbose=False, debug=False, trace=False, yydebug=False, per...
python
def start(name=None, user=None, group=None, chroot=None, caps=None, no_caps=False, pidfile=None, enable_core=False, fd_limit=None, verbose=False, debug=False, trace=False, yydebug=False, per...
[ "def", "start", "(", "name", "=", "None", ",", "user", "=", "None", ",", "group", "=", "None", ",", "chroot", "=", "None", ",", "caps", "=", "None", ",", "no_caps", "=", "False", ",", "pidfile", "=", "None", ",", "enable_core", "=", "False", ",", ...
Ensures, that syslog-ng is started via the given parameters. This function is intended to be used from the state module. Users shouldn't use this function, if the service module is available on their system. If :mod:`syslog_ng.set_config_file <salt.modules.syslog_ng.set_binary_path>`, is called before,...
[ "Ensures", "that", "syslog", "-", "ng", "is", "started", "via", "the", "given", "parameters", ".", "This", "function", "is", "intended", "to", "be", "used", "from", "the", "state", "module", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L1012-L1086
train
saltstack/salt
salt/modules/syslog_ng.py
reload_
def reload_(name): ''' Reloads syslog-ng. This function is intended to be used from states. If :mod:`syslog_ng.set_config_file <salt.modules.syslog_ng.set_binary_path>`, is called before, this function will use the set binary path. CLI Example: .. code-block:: bash salt '*' syslo...
python
def reload_(name): ''' Reloads syslog-ng. This function is intended to be used from states. If :mod:`syslog_ng.set_config_file <salt.modules.syslog_ng.set_binary_path>`, is called before, this function will use the set binary path. CLI Example: .. code-block:: bash salt '*' syslo...
[ "def", "reload_", "(", "name", ")", ":", "if", "__SYSLOG_NG_BINARY_PATH", ":", "syslog_ng_ctl_binary", "=", "os", ".", "path", ".", "join", "(", "__SYSLOG_NG_BINARY_PATH", ",", "'syslog-ng-ctl'", ")", "command", "=", "[", "syslog_ng_ctl_binary", ",", "'reload'", ...
Reloads syslog-ng. This function is intended to be used from states. If :mod:`syslog_ng.set_config_file <salt.modules.syslog_ng.set_binary_path>`, is called before, this function will use the set binary path. CLI Example: .. code-block:: bash salt '*' syslog_ng.reload
[ "Reloads", "syslog", "-", "ng", ".", "This", "function", "is", "intended", "to", "be", "used", "from", "states", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L1089-L1114
train
saltstack/salt
salt/modules/syslog_ng.py
write_config
def write_config(config, newlines=2): ''' Writes the given parameter config into the config file. This function is intended to be used from states. If :mod:`syslog_ng.set_config_file <salt.modules.syslog_ng.set_config_file>`, is called before, this function will use the set config file. CL...
python
def write_config(config, newlines=2): ''' Writes the given parameter config into the config file. This function is intended to be used from states. If :mod:`syslog_ng.set_config_file <salt.modules.syslog_ng.set_config_file>`, is called before, this function will use the set config file. CL...
[ "def", "write_config", "(", "config", ",", "newlines", "=", "2", ")", ":", "succ", "=", "_write_config", "(", "config", ",", "newlines", ")", "changes", "=", "_format_changes", "(", "new", "=", "config", ")", "return", "_format_state_result", "(", "name", ...
Writes the given parameter config into the config file. This function is intended to be used from states. If :mod:`syslog_ng.set_config_file <salt.modules.syslog_ng.set_config_file>`, is called before, this function will use the set config file. CLI Example: .. code-block:: bash salt...
[ "Writes", "the", "given", "parameter", "config", "into", "the", "config", "file", ".", "This", "function", "is", "intended", "to", "be", "used", "from", "states", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L1125-L1143
train
saltstack/salt
salt/modules/syslog_ng.py
_write_config
def _write_config(config, newlines=2): ''' Writes the given parameter config into the config file. ''' text = config if isinstance(config, dict) and len(list(list(config.keys()))) == 1: key = next(six.iterkeys(config)) text = config[key] try: with salt.utils.files.fopen(...
python
def _write_config(config, newlines=2): ''' Writes the given parameter config into the config file. ''' text = config if isinstance(config, dict) and len(list(list(config.keys()))) == 1: key = next(six.iterkeys(config)) text = config[key] try: with salt.utils.files.fopen(...
[ "def", "_write_config", "(", "config", ",", "newlines", "=", "2", ")", ":", "text", "=", "config", "if", "isinstance", "(", "config", ",", "dict", ")", "and", "len", "(", "list", "(", "list", "(", "config", ".", "keys", "(", ")", ")", ")", ")", "...
Writes the given parameter config into the config file.
[ "Writes", "the", "given", "parameter", "config", "into", "the", "config", "file", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L1146-L1164
train
saltstack/salt
salt/modules/syslog_ng.py
write_version
def write_version(name): ''' Removes the previous configuration file, then creates a new one and writes the name line. This function is intended to be used from states. If :mod:`syslog_ng.set_config_file <salt.modules.syslog_ng.set_config_file>`, is called before, this function will use the set...
python
def write_version(name): ''' Removes the previous configuration file, then creates a new one and writes the name line. This function is intended to be used from states. If :mod:`syslog_ng.set_config_file <salt.modules.syslog_ng.set_config_file>`, is called before, this function will use the set...
[ "def", "write_version", "(", "name", ")", ":", "line", "=", "'@version: {0}'", ".", "format", "(", "name", ")", "try", ":", "if", "os", ".", "path", ".", "exists", "(", "__SYSLOG_NG_CONFIG_FILE", ")", ":", "log", ".", "debug", "(", "'Removing previous conf...
Removes the previous configuration file, then creates a new one and writes the name line. This function is intended to be used from states. If :mod:`syslog_ng.set_config_file <salt.modules.syslog_ng.set_config_file>`, is called before, this function will use the set config file. CLI Example: ...
[ "Removes", "the", "previous", "configuration", "file", "then", "creates", "a", "new", "one", "and", "writes", "the", "name", "line", ".", "This", "function", "is", "intended", "to", "be", "used", "from", "states", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L1167-L1203
train
saltstack/salt
salt/modules/syslog_ng.py
Buildable.build_body
def build_body(self): ''' Builds the body of a syslog-ng configuration object. ''' _increase_indent() body_array = [x.build() for x in self.iterable] nl = '\n' if self.append_extra_newline else '' if len(self.iterable) >= 1: body = self.join_body_on....
python
def build_body(self): ''' Builds the body of a syslog-ng configuration object. ''' _increase_indent() body_array = [x.build() for x in self.iterable] nl = '\n' if self.append_extra_newline else '' if len(self.iterable) >= 1: body = self.join_body_on....
[ "def", "build_body", "(", "self", ")", ":", "_increase_indent", "(", ")", "body_array", "=", "[", "x", ".", "build", "(", ")", "for", "x", "in", "self", ".", "iterable", "]", "nl", "=", "'\\n'", "if", "self", ".", "append_extra_newline", "else", "''", ...
Builds the body of a syslog-ng configuration object.
[ "Builds", "the", "body", "of", "a", "syslog", "-", "ng", "configuration", "object", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L130-L145
train
saltstack/salt
salt/modules/syslog_ng.py
Buildable.build
def build(self): ''' Builds the textual representation of the whole configuration object with it's children. ''' header = self.build_header() body = self.build_body() tail = self.build_tail() return header + body + tail
python
def build(self): ''' Builds the textual representation of the whole configuration object with it's children. ''' header = self.build_header() body = self.build_body() tail = self.build_tail() return header + body + tail
[ "def", "build", "(", "self", ")", ":", "header", "=", "self", ".", "build_header", "(", ")", "body", "=", "self", ".", "build_body", "(", ")", "tail", "=", "self", ".", "build_tail", "(", ")", "return", "header", "+", "body", "+", "tail" ]
Builds the textual representation of the whole configuration object with it's children.
[ "Builds", "the", "textual", "representation", "of", "the", "whole", "configuration", "object", "with", "it", "s", "children", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/syslog_ng.py#L147-L155
train
saltstack/salt
salt/modules/localemod.py
_parse_dbus_locale
def _parse_dbus_locale(): ''' Get the 'System Locale' parameters from dbus ''' bus = dbus.SystemBus() localed = bus.get_object('org.freedesktop.locale1', '/org/freedesktop/locale1') properties = dbus.Interface(localed, 'org.freedesktop.DBus.Properties') system_lo...
python
def _parse_dbus_locale(): ''' Get the 'System Locale' parameters from dbus ''' bus = dbus.SystemBus() localed = bus.get_object('org.freedesktop.locale1', '/org/freedesktop/locale1') properties = dbus.Interface(localed, 'org.freedesktop.DBus.Properties') system_lo...
[ "def", "_parse_dbus_locale", "(", ")", ":", "bus", "=", "dbus", ".", "SystemBus", "(", ")", "localed", "=", "bus", ".", "get_object", "(", "'org.freedesktop.locale1'", ",", "'/org/freedesktop/locale1'", ")", "properties", "=", "dbus", ".", "Interface", "(", "l...
Get the 'System Locale' parameters from dbus
[ "Get", "the", "System", "Locale", "parameters", "from", "dbus" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/localemod.py#L41-L62
train
saltstack/salt
salt/modules/localemod.py
_localectl_status
def _localectl_status(): ''' Parse localectl status into a dict. :return: dict ''' if salt.utils.path.which('localectl') is None: raise CommandExecutionError('Unable to find "localectl"') ret = {} locale_ctl_out = (__salt__['cmd.run']('localectl status') or '').strip() ctl_key =...
python
def _localectl_status(): ''' Parse localectl status into a dict. :return: dict ''' if salt.utils.path.which('localectl') is None: raise CommandExecutionError('Unable to find "localectl"') ret = {} locale_ctl_out = (__salt__['cmd.run']('localectl status') or '').strip() ctl_key =...
[ "def", "_localectl_status", "(", ")", ":", "if", "salt", ".", "utils", ".", "path", ".", "which", "(", "'localectl'", ")", "is", "None", ":", "raise", "CommandExecutionError", "(", "'Unable to find \"localectl\"'", ")", "ret", "=", "{", "}", "locale_ctl_out", ...
Parse localectl status into a dict. :return: dict
[ "Parse", "localectl", "status", "into", "a", "dict", ".", ":", "return", ":", "dict" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/localemod.py#L65-L97
train
saltstack/salt
salt/modules/localemod.py
_localectl_set
def _localectl_set(locale=''): ''' Use systemd's localectl command to set the LANG locale parameter, making sure not to trample on other params that have been set. ''' locale_params = _parse_dbus_locale() if dbus is not None else _localectl_status().get('system_locale', {}) locale_params['LANG']...
python
def _localectl_set(locale=''): ''' Use systemd's localectl command to set the LANG locale parameter, making sure not to trample on other params that have been set. ''' locale_params = _parse_dbus_locale() if dbus is not None else _localectl_status().get('system_locale', {}) locale_params['LANG']...
[ "def", "_localectl_set", "(", "locale", "=", "''", ")", ":", "locale_params", "=", "_parse_dbus_locale", "(", ")", "if", "dbus", "is", "not", "None", "else", "_localectl_status", "(", ")", ".", "get", "(", "'system_locale'", ",", "{", "}", ")", "locale_par...
Use systemd's localectl command to set the LANG locale parameter, making sure not to trample on other params that have been set.
[ "Use", "systemd", "s", "localectl", "command", "to", "set", "the", "LANG", "locale", "parameter", "making", "sure", "not", "to", "trample", "on", "other", "params", "that", "have", "been", "set", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/localemod.py#L100-L108
train
saltstack/salt
salt/modules/localemod.py
get_locale
def get_locale(): ''' Get the current system locale CLI Example: .. code-block:: bash salt '*' locale.get_locale ''' ret = '' lc_ctl = salt.utils.systemd.booted(__context__) # localectl on SLE12 is installed but the integration is still broken in latest SP3 due to # config...
python
def get_locale(): ''' Get the current system locale CLI Example: .. code-block:: bash salt '*' locale.get_locale ''' ret = '' lc_ctl = salt.utils.systemd.booted(__context__) # localectl on SLE12 is installed but the integration is still broken in latest SP3 due to # config...
[ "def", "get_locale", "(", ")", ":", "ret", "=", "''", "lc_ctl", "=", "salt", ".", "utils", ".", "systemd", ".", "booted", "(", "__context__", ")", "# localectl on SLE12 is installed but the integration is still broken in latest SP3 due to", "# config is rewritten by by many...
Get the current system locale CLI Example: .. code-block:: bash salt '*' locale.get_locale
[ "Get", "the", "current", "system", "locale" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/localemod.py#L124-L163
train
saltstack/salt
salt/modules/localemod.py
set_locale
def set_locale(locale): ''' Sets the current system locale CLI Example: .. code-block:: bash salt '*' locale.set_locale 'en_US.UTF-8' ''' lc_ctl = salt.utils.systemd.booted(__context__) # localectl on SLE12 is installed but the integration is broken -- config is rewritten by YaST2...
python
def set_locale(locale): ''' Sets the current system locale CLI Example: .. code-block:: bash salt '*' locale.set_locale 'en_US.UTF-8' ''' lc_ctl = salt.utils.systemd.booted(__context__) # localectl on SLE12 is installed but the integration is broken -- config is rewritten by YaST2...
[ "def", "set_locale", "(", "locale", ")", ":", "lc_ctl", "=", "salt", ".", "utils", ".", "systemd", ".", "booted", "(", "__context__", ")", "# localectl on SLE12 is installed but the integration is broken -- config is rewritten by YaST2", "if", "lc_ctl", "and", "not", "(...
Sets the current system locale CLI Example: .. code-block:: bash salt '*' locale.set_locale 'en_US.UTF-8'
[ "Sets", "the", "current", "system", "locale" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/localemod.py#L166-L228
train
saltstack/salt
salt/modules/localemod.py
avail
def avail(locale): ''' Check if a locale is available. .. versionadded:: 2014.7.0 CLI Example: .. code-block:: bash salt '*' locale.avail 'en_US.UTF-8' ''' try: normalized_locale = salt.utils.locales.normalize_locale(locale) except IndexError: log.error('Unabl...
python
def avail(locale): ''' Check if a locale is available. .. versionadded:: 2014.7.0 CLI Example: .. code-block:: bash salt '*' locale.avail 'en_US.UTF-8' ''' try: normalized_locale = salt.utils.locales.normalize_locale(locale) except IndexError: log.error('Unabl...
[ "def", "avail", "(", "locale", ")", ":", "try", ":", "normalized_locale", "=", "salt", ".", "utils", ".", "locales", ".", "normalize_locale", "(", "locale", ")", "except", "IndexError", ":", "log", ".", "error", "(", "'Unable to validate locale \"%s\"'", ",", ...
Check if a locale is available. .. versionadded:: 2014.7.0 CLI Example: .. code-block:: bash salt '*' locale.avail 'en_US.UTF-8'
[ "Check", "if", "a", "locale", "is", "available", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/localemod.py#L231-L251
train
saltstack/salt
salt/modules/localemod.py
gen_locale
def gen_locale(locale, **kwargs): ''' Generate a locale. Options: .. versionadded:: 2014.7.0 :param locale: Any locale listed in /usr/share/i18n/locales or /usr/share/i18n/SUPPORTED for Debian and Gentoo based distributions, which require the charmap to be specified as part of the loca...
python
def gen_locale(locale, **kwargs): ''' Generate a locale. Options: .. versionadded:: 2014.7.0 :param locale: Any locale listed in /usr/share/i18n/locales or /usr/share/i18n/SUPPORTED for Debian and Gentoo based distributions, which require the charmap to be specified as part of the loca...
[ "def", "gen_locale", "(", "locale", ",", "*", "*", "kwargs", ")", ":", "on_debian", "=", "__grains__", ".", "get", "(", "'os'", ")", "==", "'Debian'", "on_ubuntu", "=", "__grains__", ".", "get", "(", "'os'", ")", "==", "'Ubuntu'", "on_gentoo", "=", "__...
Generate a locale. Options: .. versionadded:: 2014.7.0 :param locale: Any locale listed in /usr/share/i18n/locales or /usr/share/i18n/SUPPORTED for Debian and Gentoo based distributions, which require the charmap to be specified as part of the locale when generating it. verbose ...
[ "Generate", "a", "locale", ".", "Options", ":" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/localemod.py#L254-L357
train
saltstack/salt
salt/states/heat.py
_parse_template
def _parse_template(tmpl_str): ''' Parsing template ''' tmpl_str = tmpl_str.strip() if tmpl_str.startswith('{'): tpl = salt.utils.json.loads(tmpl_str) else: try: tpl = salt.utils.yaml.safe_load(tmpl_str) except salt.utils.yaml.YAMLError as exc: rai...
python
def _parse_template(tmpl_str): ''' Parsing template ''' tmpl_str = tmpl_str.strip() if tmpl_str.startswith('{'): tpl = salt.utils.json.loads(tmpl_str) else: try: tpl = salt.utils.yaml.safe_load(tmpl_str) except salt.utils.yaml.YAMLError as exc: rai...
[ "def", "_parse_template", "(", "tmpl_str", ")", ":", "tmpl_str", "=", "tmpl_str", ".", "strip", "(", ")", "if", "tmpl_str", ".", "startswith", "(", "'{'", ")", ":", "tpl", "=", "salt", ".", "utils", ".", "json", ".", "loads", "(", "tmpl_str", ")", "e...
Parsing template
[ "Parsing", "template" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/heat.py#L80-L99
train
saltstack/salt
salt/states/heat.py
deployed
def deployed(name, template=None, environment=None, params=None, poll=5, rollback=False, timeout=60, update=False, profile=None, **connection_args): ''' Deploy stack with the specified properties name The name of the stack template File of template enviro...
python
def deployed(name, template=None, environment=None, params=None, poll=5, rollback=False, timeout=60, update=False, profile=None, **connection_args): ''' Deploy stack with the specified properties name The name of the stack template File of template enviro...
[ "def", "deployed", "(", "name", ",", "template", "=", "None", ",", "environment", "=", "None", ",", "params", "=", "None", ",", "poll", "=", "5", ",", "rollback", "=", "False", ",", "timeout", "=", "60", ",", "update", "=", "False", ",", "profile", ...
Deploy stack with the specified properties name The name of the stack template File of template environment File of environment params Parameter dict used to create the stack poll Poll (in sec.) and report events until stack complete rollback ...
[ "Deploy", "stack", "with", "the", "specified", "properties" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/heat.py#L102-L281
train
saltstack/salt
salt/states/heat.py
absent
def absent(name, poll=5, timeout=60, profile=None): ''' Ensure that the named stack is absent name The name of the stack to remove poll Poll(in sec.) and report events until stack complete timeout Stack creation timeout in minutes profile Profile to use '...
python
def absent(name, poll=5, timeout=60, profile=None): ''' Ensure that the named stack is absent name The name of the stack to remove poll Poll(in sec.) and report events until stack complete timeout Stack creation timeout in minutes profile Profile to use '...
[ "def", "absent", "(", "name", ",", "poll", "=", "5", ",", "timeout", "=", "60", ",", "profile", "=", "None", ")", ":", "log", ".", "debug", "(", "'Absent with (%s, %s %s)'", ",", "name", ",", "poll", ",", "profile", ")", "ret", "=", "{", "'name'", ...
Ensure that the named stack is absent name The name of the stack to remove poll Poll(in sec.) and report events until stack complete timeout Stack creation timeout in minutes profile Profile to use
[ "Ensure", "that", "the", "named", "stack", "is", "absent" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/heat.py#L284-L331
train
saltstack/salt
salt/grains/minion_process.py
_username
def _username(): ''' Grain for the minion username ''' if pwd: username = pwd.getpwuid(os.getuid()).pw_name else: username = getpass.getuser() return username
python
def _username(): ''' Grain for the minion username ''' if pwd: username = pwd.getpwuid(os.getuid()).pw_name else: username = getpass.getuser() return username
[ "def", "_username", "(", ")", ":", "if", "pwd", ":", "username", "=", "pwd", ".", "getpwuid", "(", "os", ".", "getuid", "(", ")", ")", ".", "pw_name", "else", ":", "username", "=", "getpass", ".", "getuser", "(", ")", "return", "username" ]
Grain for the minion username
[ "Grain", "for", "the", "minion", "username" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/grains/minion_process.py#L34-L43
train
saltstack/salt
salt/grains/minion_process.py
_groupname
def _groupname(): ''' Grain for the minion groupname ''' if grp: try: groupname = grp.getgrgid(os.getgid()).gr_name except KeyError: groupname = '' else: groupname = '' return groupname
python
def _groupname(): ''' Grain for the minion groupname ''' if grp: try: groupname = grp.getgrgid(os.getgid()).gr_name except KeyError: groupname = '' else: groupname = '' return groupname
[ "def", "_groupname", "(", ")", ":", "if", "grp", ":", "try", ":", "groupname", "=", "grp", ".", "getgrgid", "(", "os", ".", "getgid", "(", ")", ")", ".", "gr_name", "except", "KeyError", ":", "groupname", "=", "''", "else", ":", "groupname", "=", "...
Grain for the minion groupname
[ "Grain", "for", "the", "minion", "groupname" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/grains/minion_process.py#L55-L67
train
saltstack/salt
salt/payload.py
unpackage
def unpackage(package_): ''' Unpackages a payload ''' return salt.utils.msgpack.loads(package_, use_list=True, _msgpack_module=msgpack)
python
def unpackage(package_): ''' Unpackages a payload ''' return salt.utils.msgpack.loads(package_, use_list=True, _msgpack_module=msgpack)
[ "def", "unpackage", "(", "package_", ")", ":", "return", "salt", ".", "utils", ".", "msgpack", ".", "loads", "(", "package_", ",", "use_list", "=", "True", ",", "_msgpack_module", "=", "msgpack", ")" ]
Unpackages a payload
[ "Unpackages", "a", "payload" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/payload.py#L89-L94
train
saltstack/salt
salt/payload.py
format_payload
def format_payload(enc, **kwargs): ''' Pass in the required arguments for a payload, the enc type and the cmd, then a list of keyword args to generate the body of the load dict. ''' payload = {'enc': enc} load = {} for key in kwargs: load[key] = kwargs[key] payload['load'] = load...
python
def format_payload(enc, **kwargs): ''' Pass in the required arguments for a payload, the enc type and the cmd, then a list of keyword args to generate the body of the load dict. ''' payload = {'enc': enc} load = {} for key in kwargs: load[key] = kwargs[key] payload['load'] = load...
[ "def", "format_payload", "(", "enc", ",", "*", "*", "kwargs", ")", ":", "payload", "=", "{", "'enc'", ":", "enc", "}", "load", "=", "{", "}", "for", "key", "in", "kwargs", ":", "load", "[", "key", "]", "=", "kwargs", "[", "key", "]", "payload", ...
Pass in the required arguments for a payload, the enc type and the cmd, then a list of keyword args to generate the body of the load dict.
[ "Pass", "in", "the", "required", "arguments", "for", "a", "payload", "the", "enc", "type", "and", "the", "cmd", "then", "a", "list", "of", "keyword", "args", "to", "generate", "the", "body", "of", "the", "load", "dict", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/payload.py#L97-L107
train
saltstack/salt
salt/payload.py
Serial.loads
def loads(self, msg, encoding=None, raw=False): ''' Run the correct loads serialization format :param encoding: Useful for Python 3 support. If the msgpack data was encoded using "use_bin_type=True", this will differentiate between the 'bytes' t...
python
def loads(self, msg, encoding=None, raw=False): ''' Run the correct loads serialization format :param encoding: Useful for Python 3 support. If the msgpack data was encoded using "use_bin_type=True", this will differentiate between the 'bytes' t...
[ "def", "loads", "(", "self", ",", "msg", ",", "encoding", "=", "None", ",", "raw", "=", "False", ")", ":", "try", ":", "def", "ext_type_decoder", "(", "code", ",", "data", ")", ":", "if", "code", "==", "78", ":", "data", "=", "salt", ".", "utils"...
Run the correct loads serialization format :param encoding: Useful for Python 3 support. If the msgpack data was encoded using "use_bin_type=True", this will differentiate between the 'bytes' type and the 'str' type by decoding contents...
[ "Run", "the", "correct", "loads", "serialization", "format" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/payload.py#L123-L179
train
saltstack/salt
salt/payload.py
Serial.load
def load(self, fn_): ''' Run the correct serialization to load a file ''' data = fn_.read() fn_.close() if data: if six.PY3: return self.loads(data, encoding='utf-8') else: return self.loads(data)
python
def load(self, fn_): ''' Run the correct serialization to load a file ''' data = fn_.read() fn_.close() if data: if six.PY3: return self.loads(data, encoding='utf-8') else: return self.loads(data)
[ "def", "load", "(", "self", ",", "fn_", ")", ":", "data", "=", "fn_", ".", "read", "(", ")", "fn_", ".", "close", "(", ")", "if", "data", ":", "if", "six", ".", "PY3", ":", "return", "self", ".", "loads", "(", "data", ",", "encoding", "=", "'...
Run the correct serialization to load a file
[ "Run", "the", "correct", "serialization", "to", "load", "a", "file" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/payload.py#L181-L191
train
saltstack/salt
salt/payload.py
Serial.dumps
def dumps(self, msg, use_bin_type=False): ''' Run the correct dumps serialization format :param use_bin_type: Useful for Python 3 support. Tells msgpack to differentiate between 'str' and 'bytes' types by encoding them differently. ...
python
def dumps(self, msg, use_bin_type=False): ''' Run the correct dumps serialization format :param use_bin_type: Useful for Python 3 support. Tells msgpack to differentiate between 'str' and 'bytes' types by encoding them differently. ...
[ "def", "dumps", "(", "self", ",", "msg", ",", "use_bin_type", "=", "False", ")", ":", "def", "ext_type_encoder", "(", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "six", ".", "integer_types", ")", ":", "# msgpack can't handle the very long Python long...
Run the correct dumps serialization format :param use_bin_type: Useful for Python 3 support. Tells msgpack to differentiate between 'str' and 'bytes' types by encoding them differently. Since this changes the wire protocol, ...
[ "Run", "the", "correct", "dumps", "serialization", "format" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/payload.py#L193-L272
train
saltstack/salt
salt/payload.py
Serial.dump
def dump(self, msg, fn_): ''' Serialize the correct data into the named file object ''' if six.PY2: fn_.write(self.dumps(msg)) else: # When using Python 3, write files in such a way # that the 'bytes' and 'str' types are distinguishable ...
python
def dump(self, msg, fn_): ''' Serialize the correct data into the named file object ''' if six.PY2: fn_.write(self.dumps(msg)) else: # When using Python 3, write files in such a way # that the 'bytes' and 'str' types are distinguishable ...
[ "def", "dump", "(", "self", ",", "msg", ",", "fn_", ")", ":", "if", "six", ".", "PY2", ":", "fn_", ".", "write", "(", "self", ".", "dumps", "(", "msg", ")", ")", "else", ":", "# When using Python 3, write files in such a way", "# that the 'bytes' and 'str' t...
Serialize the correct data into the named file object
[ "Serialize", "the", "correct", "data", "into", "the", "named", "file", "object" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/payload.py#L274-L285
train
saltstack/salt
salt/payload.py
SREQ.socket
def socket(self): ''' Lazily create the socket. ''' if not hasattr(self, '_socket'): # create a new one self._socket = self.context.socket(zmq.REQ) if hasattr(zmq, 'RECONNECT_IVL_MAX'): self._socket.setsockopt( zmq.R...
python
def socket(self): ''' Lazily create the socket. ''' if not hasattr(self, '_socket'): # create a new one self._socket = self.context.socket(zmq.REQ) if hasattr(zmq, 'RECONNECT_IVL_MAX'): self._socket.setsockopt( zmq.R...
[ "def", "socket", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'_socket'", ")", ":", "# create a new one", "self", ".", "_socket", "=", "self", ".", "context", ".", "socket", "(", "zmq", ".", "REQ", ")", "if", "hasattr", "(", "zmq...
Lazily create the socket.
[ "Lazily", "create", "the", "socket", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/payload.py#L302-L325
train
saltstack/salt
salt/payload.py
SREQ.clear_socket
def clear_socket(self): ''' delete socket if you have it ''' if hasattr(self, '_socket'): if isinstance(self.poller.sockets, dict): sockets = list(self.poller.sockets.keys()) for socket in sockets: log.trace('Unregistering s...
python
def clear_socket(self): ''' delete socket if you have it ''' if hasattr(self, '_socket'): if isinstance(self.poller.sockets, dict): sockets = list(self.poller.sockets.keys()) for socket in sockets: log.trace('Unregistering s...
[ "def", "clear_socket", "(", "self", ")", ":", "if", "hasattr", "(", "self", ",", "'_socket'", ")", ":", "if", "isinstance", "(", "self", ".", "poller", ".", "sockets", ",", "dict", ")", ":", "sockets", "=", "list", "(", "self", ".", "poller", ".", ...
delete socket if you have it
[ "delete", "socket", "if", "you", "have", "it" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/payload.py#L346-L360
train
saltstack/salt
salt/payload.py
SREQ.send
def send(self, enc, load, tries=1, timeout=60): ''' Takes two arguments, the encryption type and the base payload ''' payload = {'enc': enc} payload['load'] = load pkg = self.serial.dumps(payload) self.socket.send(pkg) self.poller.register(self.socket, zmq...
python
def send(self, enc, load, tries=1, timeout=60): ''' Takes two arguments, the encryption type and the base payload ''' payload = {'enc': enc} payload['load'] = load pkg = self.serial.dumps(payload) self.socket.send(pkg) self.poller.register(self.socket, zmq...
[ "def", "send", "(", "self", ",", "enc", ",", "load", ",", "tries", "=", "1", ",", "timeout", "=", "60", ")", ":", "payload", "=", "{", "'enc'", ":", "enc", "}", "payload", "[", "'load'", "]", "=", "load", "pkg", "=", "self", ".", "serial", ".",...
Takes two arguments, the encryption type and the base payload
[ "Takes", "two", "arguments", "the", "encryption", "type", "and", "the", "base", "payload" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/payload.py#L362-L388
train
saltstack/salt
salt/payload.py
SREQ.send_auto
def send_auto(self, payload, tries=1, timeout=60): ''' Detect the encryption type based on the payload ''' enc = payload.get('enc', 'clear') load = payload.get('load', {}) return self.send(enc, load, tries, timeout)
python
def send_auto(self, payload, tries=1, timeout=60): ''' Detect the encryption type based on the payload ''' enc = payload.get('enc', 'clear') load = payload.get('load', {}) return self.send(enc, load, tries, timeout)
[ "def", "send_auto", "(", "self", ",", "payload", ",", "tries", "=", "1", ",", "timeout", "=", "60", ")", ":", "enc", "=", "payload", ".", "get", "(", "'enc'", ",", "'clear'", ")", "load", "=", "payload", ".", "get", "(", "'load'", ",", "{", "}", ...
Detect the encryption type based on the payload
[ "Detect", "the", "encryption", "type", "based", "on", "the", "payload" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/payload.py#L390-L396
train