repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
saltstack/salt
salt/modules/panos.py
get_uncommitted_changes
def get_uncommitted_changes(): ''' Retrieve a list of all uncommitted changes on the device. Requires PANOS version 8.0.0 or greater. CLI Example: .. code-block:: bash salt '*' panos.get_uncommitted_changes ''' _required_version = '8.0.0' if not __proxy__['panos.is_required_v...
python
def get_uncommitted_changes(): ''' Retrieve a list of all uncommitted changes on the device. Requires PANOS version 8.0.0 or greater. CLI Example: .. code-block:: bash salt '*' panos.get_uncommitted_changes ''' _required_version = '8.0.0' if not __proxy__['panos.is_required_v...
[ "def", "get_uncommitted_changes", "(", ")", ":", "_required_version", "=", "'8.0.0'", "if", "not", "__proxy__", "[", "'panos.is_required_version'", "]", "(", "_required_version", ")", ":", "return", "False", ",", "'The panos device requires version {0} or greater for this c...
Retrieve a list of all uncommitted changes on the device. Requires PANOS version 8.0.0 or greater. CLI Example: .. code-block:: bash salt '*' panos.get_uncommitted_changes
[ "Retrieve", "a", "list", "of", "all", "uncommitted", "changes", "on", "the", "device", ".", "Requires", "PANOS", "version", "8", ".", "0", ".", "0", "or", "greater", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/panos.py#L1260-L1279
train
saltstack/salt
salt/modules/panos.py
install_antivirus
def install_antivirus(version=None, latest=False, synch=False, skip_commit=False,): ''' Install anti-virus packages. Args: version(str): The version of the PANOS file to install. latest(bool): If true, the latest anti-virus file will be installed. The specified versio...
python
def install_antivirus(version=None, latest=False, synch=False, skip_commit=False,): ''' Install anti-virus packages. Args: version(str): The version of the PANOS file to install. latest(bool): If true, the latest anti-virus file will be installed. The specified versio...
[ "def", "install_antivirus", "(", "version", "=", "None", ",", "latest", "=", "False", ",", "synch", "=", "False", ",", "skip_commit", "=", "False", ",", ")", ":", "if", "not", "version", "and", "latest", "is", "False", ":", "raise", "CommandExecutionError"...
Install anti-virus packages. Args: version(str): The version of the PANOS file to install. latest(bool): If true, the latest anti-virus file will be installed. The specified version option will be ignored. synch(bool): If true, the anti-virus will synch to the peer u...
[ "Install", "anti", "-", "virus", "packages", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/panos.py#L1382-L1427
train
saltstack/salt
salt/modules/panos.py
refresh_fqdn_cache
def refresh_fqdn_cache(force=False): ''' Force refreshes all FQDNs used in rules. force Forces all fqdn refresh CLI Example: .. code-block:: bash salt '*' panos.refresh_fqdn_cache salt '*' panos.refresh_fqdn_cache force=True ''' if not isinstance(force, bool): ...
python
def refresh_fqdn_cache(force=False): ''' Force refreshes all FQDNs used in rules. force Forces all fqdn refresh CLI Example: .. code-block:: bash salt '*' panos.refresh_fqdn_cache salt '*' panos.refresh_fqdn_cache force=True ''' if not isinstance(force, bool): ...
[ "def", "refresh_fqdn_cache", "(", "force", "=", "False", ")", ":", "if", "not", "isinstance", "(", "force", ",", "bool", ")", ":", "raise", "CommandExecutionError", "(", "\"Force option must be boolean.\"", ")", "if", "force", ":", "query", "=", "{", "'type'",...
Force refreshes all FQDNs used in rules. force Forces all fqdn refresh CLI Example: .. code-block:: bash salt '*' panos.refresh_fqdn_cache salt '*' panos.refresh_fqdn_cache force=True
[ "Force", "refreshes", "all", "FQDNs", "used", "in", "rules", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/panos.py#L1486-L1510
train
saltstack/salt
salt/modules/panos.py
resolve_address
def resolve_address(address=None, vsys=None): ''' Resolve address to ip address. Required version 7.0.0 or greater. address Address name you want to resolve. vsys The vsys name. CLI Example: .. code-block:: bash salt '*' panos.resolve_address foo.bar.com ...
python
def resolve_address(address=None, vsys=None): ''' Resolve address to ip address. Required version 7.0.0 or greater. address Address name you want to resolve. vsys The vsys name. CLI Example: .. code-block:: bash salt '*' panos.resolve_address foo.bar.com ...
[ "def", "resolve_address", "(", "address", "=", "None", ",", "vsys", "=", "None", ")", ":", "_required_version", "=", "'7.0.0'", "if", "not", "__proxy__", "[", "'panos.is_required_version'", "]", "(", "_required_version", ")", ":", "return", "False", ",", "'The...
Resolve address to ip address. Required version 7.0.0 or greater. address Address name you want to resolve. vsys The vsys name. CLI Example: .. code-block:: bash salt '*' panos.resolve_address foo.bar.com salt '*' panos.resolve_address foo.bar.com vsys=2
[ "Resolve", "address", "to", "ip", "address", ".", "Required", "version", "7", ".", "0", ".", "0", "or", "greater", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/panos.py#L1529-L1563
train
saltstack/salt
salt/modules/panos.py
set_authentication_profile
def set_authentication_profile(profile=None, deploy=False): ''' Set the authentication profile of the Palo Alto proxy minion. A commit will be required before this is processed. CLI Example: Args: profile (str): The name of the authentication profile to set. deploy (bool): If true the...
python
def set_authentication_profile(profile=None, deploy=False): ''' Set the authentication profile of the Palo Alto proxy minion. A commit will be required before this is processed. CLI Example: Args: profile (str): The name of the authentication profile to set. deploy (bool): If true the...
[ "def", "set_authentication_profile", "(", "profile", "=", "None", ",", "deploy", "=", "False", ")", ":", "if", "not", "profile", ":", "raise", "CommandExecutionError", "(", "\"Profile name option must not be none.\"", ")", "ret", "=", "{", "}", "query", "=", "{"...
Set the authentication profile of the Palo Alto proxy minion. A commit will be required before this is processed. CLI Example: Args: profile (str): The name of the authentication profile to set. deploy (bool): If true then commit the full candidate configuration, if false only set pending cha...
[ "Set", "the", "authentication", "profile", "of", "the", "Palo", "Alto", "proxy", "minion", ".", "A", "commit", "will", "be", "required", "before", "this", "is", "processed", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/panos.py#L1604-L1638
train
saltstack/salt
salt/modules/panos.py
set_hostname
def set_hostname(hostname=None, deploy=False): ''' Set the hostname of the Palo Alto proxy minion. A commit will be required before this is processed. CLI Example: Args: hostname (str): The hostname to set deploy (bool): If true then commit the full candidate configuration, if false o...
python
def set_hostname(hostname=None, deploy=False): ''' Set the hostname of the Palo Alto proxy minion. A commit will be required before this is processed. CLI Example: Args: hostname (str): The hostname to set deploy (bool): If true then commit the full candidate configuration, if false o...
[ "def", "set_hostname", "(", "hostname", "=", "None", ",", "deploy", "=", "False", ")", ":", "if", "not", "hostname", ":", "raise", "CommandExecutionError", "(", "\"Hostname option must not be none.\"", ")", "ret", "=", "{", "}", "query", "=", "{", "'type'", ...
Set the hostname of the Palo Alto proxy minion. A commit will be required before this is processed. CLI Example: Args: hostname (str): The hostname to set deploy (bool): If true then commit the full candidate configuration, if false only set pending change. .. code-block:: bash ...
[ "Set", "the", "hostname", "of", "the", "Palo", "Alto", "proxy", "minion", ".", "A", "commit", "will", "be", "required", "before", "this", "is", "processed", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/panos.py#L1641-L1674
train
saltstack/salt
salt/modules/panos.py
set_management_icmp
def set_management_icmp(enabled=True, deploy=False): ''' Enables or disables the ICMP management service on the device. CLI Example: Args: enabled (bool): If true the service will be enabled. If false the service will be disabled. deploy (bool): If true then commit the full candidate ...
python
def set_management_icmp(enabled=True, deploy=False): ''' Enables or disables the ICMP management service on the device. CLI Example: Args: enabled (bool): If true the service will be enabled. If false the service will be disabled. deploy (bool): If true then commit the full candidate ...
[ "def", "set_management_icmp", "(", "enabled", "=", "True", ",", "deploy", "=", "False", ")", ":", "if", "enabled", "is", "True", ":", "value", "=", "\"no\"", "elif", "enabled", "is", "False", ":", "value", "=", "\"yes\"", "else", ":", "raise", "CommandEx...
Enables or disables the ICMP management service on the device. CLI Example: Args: enabled (bool): If true the service will be enabled. If false the service will be disabled. deploy (bool): If true then commit the full candidate configuration, if false only set pending change. .. code-blo...
[ "Enables", "or", "disables", "the", "ICMP", "management", "service", "on", "the", "device", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/panos.py#L1677-L1714
train
saltstack/salt
salt/modules/panos.py
set_ntp_authentication
def set_ntp_authentication(target=None, authentication_type=None, key_id=None, authentication_key=None, algorithm=None, deploy=False): ''' Set the NTP authentication of the Palo...
python
def set_ntp_authentication(target=None, authentication_type=None, key_id=None, authentication_key=None, algorithm=None, deploy=False): ''' Set the NTP authentication of the Palo...
[ "def", "set_ntp_authentication", "(", "target", "=", "None", ",", "authentication_type", "=", "None", ",", "key_id", "=", "None", ",", "authentication_key", "=", "None", ",", "algorithm", "=", "None", ",", "deploy", "=", "False", ")", ":", "ret", "=", "{",...
Set the NTP authentication of the Palo Alto proxy minion. A commit will be required before this is processed. CLI Example: Args: target(str): Determines the target of the authentication. Valid options are primary, secondary, or both. authentication_type(str): The authentication type to be use...
[ "Set", "the", "NTP", "authentication", "of", "the", "Palo", "Alto", "proxy", "minion", ".", "A", "commit", "will", "be", "required", "before", "this", "is", "processed", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/panos.py#L1957-L2066
train
saltstack/salt
salt/modules/panos.py
set_ntp_servers
def set_ntp_servers(primary_server=None, secondary_server=None, deploy=False): ''' Set the NTP servers of the Palo Alto proxy minion. A commit will be required before this is processed. CLI Example: Args: primary_server(str): The primary NTP server IP address or FQDN. secondary_server...
python
def set_ntp_servers(primary_server=None, secondary_server=None, deploy=False): ''' Set the NTP servers of the Palo Alto proxy minion. A commit will be required before this is processed. CLI Example: Args: primary_server(str): The primary NTP server IP address or FQDN. secondary_server...
[ "def", "set_ntp_servers", "(", "primary_server", "=", "None", ",", "secondary_server", "=", "None", ",", "deploy", "=", "False", ")", ":", "ret", "=", "{", "}", "if", "primary_server", ":", "query", "=", "{", "'type'", ":", "'config'", ",", "'action'", "...
Set the NTP servers of the Palo Alto proxy minion. A commit will be required before this is processed. CLI Example: Args: primary_server(str): The primary NTP server IP address or FQDN. secondary_server(str): The secondary NTP server IP address or FQDN. deploy (bool): If true then co...
[ "Set", "the", "NTP", "servers", "of", "the", "Palo", "Alto", "proxy", "minion", ".", "A", "commit", "will", "be", "required", "before", "this", "is", "processed", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/panos.py#L2069-L2110
train
saltstack/salt
salt/modules/panos.py
set_permitted_ip
def set_permitted_ip(address=None, deploy=False): ''' Add an IPv4 address or network to the permitted IP list. CLI Example: Args: address (str): The IPv4 address or network to allow access to add to the Palo Alto device. deploy (bool): If true then commit the full candidate configurat...
python
def set_permitted_ip(address=None, deploy=False): ''' Add an IPv4 address or network to the permitted IP list. CLI Example: Args: address (str): The IPv4 address or network to allow access to add to the Palo Alto device. deploy (bool): If true then commit the full candidate configurat...
[ "def", "set_permitted_ip", "(", "address", "=", "None", ",", "deploy", "=", "False", ")", ":", "if", "not", "address", ":", "raise", "CommandExecutionError", "(", "\"Address option must not be empty.\"", ")", "ret", "=", "{", "}", "query", "=", "{", "'type'", ...
Add an IPv4 address or network to the permitted IP list. CLI Example: Args: address (str): The IPv4 address or network to allow access to add to the Palo Alto device. deploy (bool): If true then commit the full candidate configuration, if false only set pending change. .. code-block:: ba...
[ "Add", "an", "IPv4", "address", "or", "network", "to", "the", "permitted", "IP", "list", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/panos.py#L2113-L2147
train
saltstack/salt
salt/modules/panos.py
set_timezone
def set_timezone(tz=None, deploy=False): ''' Set the timezone of the Palo Alto proxy minion. A commit will be required before this is processed. CLI Example: Args: tz (str): The name of the timezone to set. deploy (bool): If true then commit the full candidate configuration, if false ...
python
def set_timezone(tz=None, deploy=False): ''' Set the timezone of the Palo Alto proxy minion. A commit will be required before this is processed. CLI Example: Args: tz (str): The name of the timezone to set. deploy (bool): If true then commit the full candidate configuration, if false ...
[ "def", "set_timezone", "(", "tz", "=", "None", ",", "deploy", "=", "False", ")", ":", "if", "not", "tz", ":", "raise", "CommandExecutionError", "(", "\"Timezone name option must not be none.\"", ")", "ret", "=", "{", "}", "query", "=", "{", "'type'", ":", ...
Set the timezone of the Palo Alto proxy minion. A commit will be required before this is processed. CLI Example: Args: tz (str): The name of the timezone to set. deploy (bool): If true then commit the full candidate configuration, if false only set pending change. .. code-block:: bash ...
[ "Set", "the", "timezone", "of", "the", "Palo", "Alto", "proxy", "minion", ".", "A", "commit", "will", "be", "required", "before", "this", "is", "processed", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/panos.py#L2150-L2183
train
saltstack/salt
salt/states/vault.py
policy_present
def policy_present(name, rules): ''' Ensure a Vault policy with the given name and rules is present. name The name of the policy rules Rules formatted as in-line HCL .. code-block:: yaml demo-policy: vault.policy_present: - name: foo/bar ...
python
def policy_present(name, rules): ''' Ensure a Vault policy with the given name and rules is present. name The name of the policy rules Rules formatted as in-line HCL .. code-block:: yaml demo-policy: vault.policy_present: - name: foo/bar ...
[ "def", "policy_present", "(", "name", ",", "rules", ")", ":", "url", "=", "\"v1/sys/policy/{0}\"", ".", "format", "(", "name", ")", "response", "=", "__utils__", "[", "'vault.make_request'", "]", "(", "'GET'", ",", "url", ")", "try", ":", "if", "response",...
Ensure a Vault policy with the given name and rules is present. name The name of the policy rules Rules formatted as in-line HCL .. code-block:: yaml demo-policy: vault.policy_present: - name: foo/bar - rules: | path "secret/top-...
[ "Ensure", "a", "Vault", "policy", "with", "the", "given", "name", "and", "rules", "is", "present", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/vault.py#L21-L61
train
saltstack/salt
salt/returners/rawfile_json.py
returner
def returner(ret): ''' Write the return data to a file on the minion. ''' opts = _get_options(ret) try: with salt.utils.files.flopen(opts['filename'], 'a') as logfile: salt.utils.json.dump(ret, logfile) logfile.write(str('\n')) # future lint: disable=blacklisted-func...
python
def returner(ret): ''' Write the return data to a file on the minion. ''' opts = _get_options(ret) try: with salt.utils.files.flopen(opts['filename'], 'a') as logfile: salt.utils.json.dump(ret, logfile) logfile.write(str('\n')) # future lint: disable=blacklisted-func...
[ "def", "returner", "(", "ret", ")", ":", "opts", "=", "_get_options", "(", "ret", ")", "try", ":", "with", "salt", ".", "utils", ".", "files", ".", "flopen", "(", "opts", "[", "'filename'", "]", ",", "'a'", ")", "as", "logfile", ":", "salt", ".", ...
Write the return data to a file on the minion.
[ "Write", "the", "return", "data", "to", "a", "file", "on", "the", "minion", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/rawfile_json.py#L54-L65
train
saltstack/salt
salt/returners/rawfile_json.py
event_return
def event_return(events): ''' Write event data (return data and non-return data) to file on the master. ''' if not events: # events is an empty list. # Don't open the logfile in vain. return opts = _get_options({}) # Pass in empty ret, since this is a list of events try:...
python
def event_return(events): ''' Write event data (return data and non-return data) to file on the master. ''' if not events: # events is an empty list. # Don't open the logfile in vain. return opts = _get_options({}) # Pass in empty ret, since this is a list of events try:...
[ "def", "event_return", "(", "events", ")", ":", "if", "not", "events", ":", "# events is an empty list.", "# Don't open the logfile in vain.", "return", "opts", "=", "_get_options", "(", "{", "}", ")", "# Pass in empty ret, since this is a list of events", "try", ":", "...
Write event data (return data and non-return data) to file on the master.
[ "Write", "event", "data", "(", "return", "data", "and", "non", "-", "return", "data", ")", "to", "file", "on", "the", "master", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/rawfile_json.py#L68-L84
train
saltstack/salt
salt/states/zpool.py
_layout_to_vdev
def _layout_to_vdev(layout, device_dir=None): ''' Turn the layout data into usable vdevs spedcification We need to support 2 ways of passing the layout: .. code:: layout_new: - mirror: - disk0 - disk1 - mirror: - disk2 - disk3...
python
def _layout_to_vdev(layout, device_dir=None): ''' Turn the layout data into usable vdevs spedcification We need to support 2 ways of passing the layout: .. code:: layout_new: - mirror: - disk0 - disk1 - mirror: - disk2 - disk3...
[ "def", "_layout_to_vdev", "(", "layout", ",", "device_dir", "=", "None", ")", ":", "vdevs", "=", "[", "]", "# NOTE: check device_dir exists", "if", "device_dir", "and", "not", "os", ".", "path", ".", "exists", "(", "device_dir", ")", ":", "device_dir", "=", ...
Turn the layout data into usable vdevs spedcification We need to support 2 ways of passing the layout: .. code:: layout_new: - mirror: - disk0 - disk1 - mirror: - disk2 - disk3 .. code: layout_legacy: mirror-0: ...
[ "Turn", "the", "layout", "data", "into", "usable", "vdevs", "spedcification" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/zpool.py#L97-L167
train
saltstack/salt
salt/states/zpool.py
present
def present(name, properties=None, filesystem_properties=None, layout=None, config=None): ''' ensure storage pool is present on the system name : string name of storage pool properties : dict optional set of properties to set for the storage pool filesystem_properties : dict ...
python
def present(name, properties=None, filesystem_properties=None, layout=None, config=None): ''' ensure storage pool is present on the system name : string name of storage pool properties : dict optional set of properties to set for the storage pool filesystem_properties : dict ...
[ "def", "present", "(", "name", ",", "properties", "=", "None", ",", "filesystem_properties", "=", "None", ",", "layout", "=", "None", ",", "config", "=", "None", ")", ":", "ret", "=", "{", "'name'", ":", "name", ",", "'changes'", ":", "{", "}", ",", ...
ensure storage pool is present on the system name : string name of storage pool properties : dict optional set of properties to set for the storage pool filesystem_properties : dict optional set of filesystem properties to set for the storage pool (creation only) layout: dict ...
[ "ensure", "storage", "pool", "is", "present", "on", "the", "system" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/zpool.py#L170-L381
train
saltstack/salt
salt/states/zpool.py
absent
def absent(name, export=False, force=False): ''' ensure storage pool is absent on the system name : string name of storage pool export : boolean export instread of destroy the zpool if present force : boolean force destroy or export ''' ret = {'name': name, ...
python
def absent(name, export=False, force=False): ''' ensure storage pool is absent on the system name : string name of storage pool export : boolean export instread of destroy the zpool if present force : boolean force destroy or export ''' ret = {'name': name, ...
[ "def", "absent", "(", "name", ",", "export", "=", "False", ",", "force", "=", "False", ")", ":", "ret", "=", "{", "'name'", ":", "name", ",", "'changes'", ":", "{", "}", ",", "'result'", ":", "None", ",", "'comment'", ":", "''", "}", "# log configu...
ensure storage pool is absent on the system name : string name of storage pool export : boolean export instread of destroy the zpool if present force : boolean force destroy or export
[ "ensure", "storage", "pool", "is", "absent", "on", "the", "system" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/zpool.py#L384-L434
train
saltstack/salt
salt/utils/systemd.py
booted
def booted(context=None): ''' Return True if the system was booted with systemd, False otherwise. If the loader context dict ``__context__`` is passed, this function will set the ``salt.utils.systemd.booted`` key to represent if systemd is running and keep the logic below from needing to be run aga...
python
def booted(context=None): ''' Return True if the system was booted with systemd, False otherwise. If the loader context dict ``__context__`` is passed, this function will set the ``salt.utils.systemd.booted`` key to represent if systemd is running and keep the logic below from needing to be run aga...
[ "def", "booted", "(", "context", "=", "None", ")", ":", "contextkey", "=", "'salt.utils.systemd.booted'", "if", "isinstance", "(", "context", ",", "dict", ")", ":", "# Can't put this if block on the same line as the above if block,", "# because it willl break the elif below."...
Return True if the system was booted with systemd, False otherwise. If the loader context dict ``__context__`` is passed, this function will set the ``salt.utils.systemd.booted`` key to represent if systemd is running and keep the logic below from needing to be run again during the same salt run.
[ "Return", "True", "if", "the", "system", "was", "booted", "with", "systemd", "False", "otherwise", ".", "If", "the", "loader", "context", "dict", "__context__", "is", "passed", "this", "function", "will", "set", "the", "salt", ".", "utils", ".", "systemd", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/systemd.py#L19-L47
train
saltstack/salt
salt/utils/systemd.py
version
def version(context=None): ''' Attempts to run systemctl --version. Returns None if unable to determine version. ''' contextkey = 'salt.utils.systemd.version' if isinstance(context, dict): # Can't put this if block on the same line as the above if block, # because it will break t...
python
def version(context=None): ''' Attempts to run systemctl --version. Returns None if unable to determine version. ''' contextkey = 'salt.utils.systemd.version' if isinstance(context, dict): # Can't put this if block on the same line as the above if block, # because it will break t...
[ "def", "version", "(", "context", "=", "None", ")", ":", "contextkey", "=", "'salt.utils.systemd.version'", "if", "isinstance", "(", "context", ",", "dict", ")", ":", "# Can't put this if block on the same line as the above if block,", "# because it will break the elif below....
Attempts to run systemctl --version. Returns None if unable to determine version.
[ "Attempts", "to", "run", "systemctl", "--", "version", ".", "Returns", "None", "if", "unable", "to", "determine", "version", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/systemd.py#L50-L81
train
saltstack/salt
salt/utils/systemd.py
has_scope
def has_scope(context=None): ''' Scopes were introduced in systemd 205, this function returns a boolean which is true when the minion is systemd-booted and running systemd>=205. ''' if not booted(context): return False _sd_version = version(context) if _sd_version is None: re...
python
def has_scope(context=None): ''' Scopes were introduced in systemd 205, this function returns a boolean which is true when the minion is systemd-booted and running systemd>=205. ''' if not booted(context): return False _sd_version = version(context) if _sd_version is None: re...
[ "def", "has_scope", "(", "context", "=", "None", ")", ":", "if", "not", "booted", "(", "context", ")", ":", "return", "False", "_sd_version", "=", "version", "(", "context", ")", "if", "_sd_version", "is", "None", ":", "return", "False", "return", "_sd_v...
Scopes were introduced in systemd 205, this function returns a boolean which is true when the minion is systemd-booted and running systemd>=205.
[ "Scopes", "were", "introduced", "in", "systemd", "205", "this", "function", "returns", "a", "boolean", "which", "is", "true", "when", "the", "minion", "is", "systemd", "-", "booted", "and", "running", "systemd", ">", "=", "205", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/systemd.py#L84-L94
train
saltstack/salt
salt/returners/postgres_local_cache.py
_get_conn
def _get_conn(): ''' Return a postgres connection. ''' try: conn = psycopg2.connect( host=__opts__['master_job_cache.postgres.host'], user=__opts__['master_job_cache.postgres.user'], password=__opts__['master_job_cache.postgres.passwd'], ...
python
def _get_conn(): ''' Return a postgres connection. ''' try: conn = psycopg2.connect( host=__opts__['master_job_cache.postgres.host'], user=__opts__['master_job_cache.postgres.user'], password=__opts__['master_job_cache.postgres.passwd'], ...
[ "def", "_get_conn", "(", ")", ":", "try", ":", "conn", "=", "psycopg2", ".", "connect", "(", "host", "=", "__opts__", "[", "'master_job_cache.postgres.host'", "]", ",", "user", "=", "__opts__", "[", "'master_job_cache.postgres.user'", "]", ",", "password", "="...
Return a postgres connection.
[ "Return", "a", "postgres", "connection", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/postgres_local_cache.py#L139-L153
train
saltstack/salt
salt/returners/postgres_local_cache.py
_format_job_instance
def _format_job_instance(job): ''' Format the job instance correctly ''' ret = {'Function': job.get('fun', 'unknown-function'), 'Arguments': salt.utils.json.loads(job.get('arg', '[]')), # unlikely but safeguard from invalid returns 'Target': job.get('tgt', 'unknown-targe...
python
def _format_job_instance(job): ''' Format the job instance correctly ''' ret = {'Function': job.get('fun', 'unknown-function'), 'Arguments': salt.utils.json.loads(job.get('arg', '[]')), # unlikely but safeguard from invalid returns 'Target': job.get('tgt', 'unknown-targe...
[ "def", "_format_job_instance", "(", "job", ")", ":", "ret", "=", "{", "'Function'", ":", "job", ".", "get", "(", "'fun'", ",", "'unknown-function'", ")", ",", "'Arguments'", ":", "salt", ".", "utils", ".", "json", ".", "loads", "(", "job", ".", "get", ...
Format the job instance correctly
[ "Format", "the", "job", "instance", "correctly" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/postgres_local_cache.py#L164-L175
train
saltstack/salt
salt/returners/postgres_local_cache.py
_gen_jid
def _gen_jid(cur): ''' Generate an unique job id ''' jid = salt.utils.jid.gen_jid(__opts__) sql = '''SELECT jid FROM jids WHERE jid = %s''' cur.execute(sql, (jid,)) data = cur.fetchall() if not data: return jid return None
python
def _gen_jid(cur): ''' Generate an unique job id ''' jid = salt.utils.jid.gen_jid(__opts__) sql = '''SELECT jid FROM jids WHERE jid = %s''' cur.execute(sql, (jid,)) data = cur.fetchall() if not data: return jid return None
[ "def", "_gen_jid", "(", "cur", ")", ":", "jid", "=", "salt", ".", "utils", ".", "jid", ".", "gen_jid", "(", "__opts__", ")", "sql", "=", "'''SELECT jid FROM jids WHERE jid = %s'''", "cur", ".", "execute", "(", "sql", ",", "(", "jid", ",", ")", ")", "da...
Generate an unique job id
[ "Generate", "an", "unique", "job", "id" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/postgres_local_cache.py#L187-L197
train
saltstack/salt
salt/returners/postgres_local_cache.py
prep_jid
def prep_jid(nocache=False, passed_jid=None): ''' Return a job id and prepare the job id directory This is the function responsible for making sure jids don't collide (unless its passed a jid). So do what you have to do to make sure that stays the case ''' conn = _get_conn() if conn is N...
python
def prep_jid(nocache=False, passed_jid=None): ''' Return a job id and prepare the job id directory This is the function responsible for making sure jids don't collide (unless its passed a jid). So do what you have to do to make sure that stays the case ''' conn = _get_conn() if conn is N...
[ "def", "prep_jid", "(", "nocache", "=", "False", ",", "passed_jid", "=", "None", ")", ":", "conn", "=", "_get_conn", "(", ")", "if", "conn", "is", "None", ":", "return", "None", "cur", "=", "conn", ".", "cursor", "(", ")", "if", "passed_jid", "is", ...
Return a job id and prepare the job id directory This is the function responsible for making sure jids don't collide (unless its passed a jid). So do what you have to do to make sure that stays the case
[ "Return", "a", "job", "id", "and", "prepare", "the", "job", "id", "directory", "This", "is", "the", "function", "responsible", "for", "making", "sure", "jids", "don", "t", "collide", "(", "unless", "its", "passed", "a", "jid", ")", ".", "So", "do", "wh...
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/postgres_local_cache.py#L200-L221
train
saltstack/salt
salt/returners/postgres_local_cache.py
returner
def returner(load): ''' Return data to a postgres server ''' conn = _get_conn() if conn is None: return None cur = conn.cursor() sql = '''INSERT INTO salt_returns (fun, jid, return, id, success) VALUES (%s, %s, %s, %s, %s)''' try: ret = six.text_ty...
python
def returner(load): ''' Return data to a postgres server ''' conn = _get_conn() if conn is None: return None cur = conn.cursor() sql = '''INSERT INTO salt_returns (fun, jid, return, id, success) VALUES (%s, %s, %s, %s, %s)''' try: ret = six.text_ty...
[ "def", "returner", "(", "load", ")", ":", "conn", "=", "_get_conn", "(", ")", "if", "conn", "is", "None", ":", "return", "None", "cur", "=", "conn", ".", "cursor", "(", ")", "sql", "=", "'''INSERT INTO salt_returns\n (fun, jid, return, id, success)\n ...
Return data to a postgres server
[ "Return", "data", "to", "a", "postgres", "server" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/postgres_local_cache.py#L224-L253
train
saltstack/salt
salt/returners/postgres_local_cache.py
event_return
def event_return(events): ''' Return event to a postgres server Require that configuration be enabled via 'event_return' option in master config. ''' conn = _get_conn() if conn is None: return None cur = conn.cursor() for event in events: tag = event.get('tag', '') ...
python
def event_return(events): ''' Return event to a postgres server Require that configuration be enabled via 'event_return' option in master config. ''' conn = _get_conn() if conn is None: return None cur = conn.cursor() for event in events: tag = event.get('tag', '') ...
[ "def", "event_return", "(", "events", ")", ":", "conn", "=", "_get_conn", "(", ")", "if", "conn", "is", "None", ":", "return", "None", "cur", "=", "conn", ".", "cursor", "(", ")", "for", "event", "in", "events", ":", "tag", "=", "event", ".", "get"...
Return event to a postgres server Require that configuration be enabled via 'event_return' option in master config.
[ "Return", "event", "to", "a", "postgres", "server" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/postgres_local_cache.py#L256-L274
train
saltstack/salt
salt/returners/postgres_local_cache.py
save_load
def save_load(jid, clear_load, minions=None): ''' Save the load to the specified jid id ''' jid = _escape_jid(jid) conn = _get_conn() if conn is None: return None cur = conn.cursor() sql = '''INSERT INTO jids ''' \ '''(jid, started, tgt_type, cmd, tgt, kwargs, ret, user...
python
def save_load(jid, clear_load, minions=None): ''' Save the load to the specified jid id ''' jid = _escape_jid(jid) conn = _get_conn() if conn is None: return None cur = conn.cursor() sql = '''INSERT INTO jids ''' \ '''(jid, started, tgt_type, cmd, tgt, kwargs, ret, user...
[ "def", "save_load", "(", "jid", ",", "clear_load", ",", "minions", "=", "None", ")", ":", "jid", "=", "_escape_jid", "(", "jid", ")", "conn", "=", "_get_conn", "(", ")", "if", "conn", "is", "None", ":", "return", "None", "cur", "=", "conn", ".", "c...
Save the load to the specified jid id
[ "Save", "the", "load", "to", "the", "specified", "jid", "id" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/postgres_local_cache.py#L277-L306
train
saltstack/salt
salt/returners/postgres_local_cache.py
_escape_jid
def _escape_jid(jid): ''' Do proper formatting of the jid ''' jid = six.text_type(jid) jid = re.sub(r"'*", "", jid) return jid
python
def _escape_jid(jid): ''' Do proper formatting of the jid ''' jid = six.text_type(jid) jid = re.sub(r"'*", "", jid) return jid
[ "def", "_escape_jid", "(", "jid", ")", ":", "jid", "=", "six", ".", "text_type", "(", "jid", ")", "jid", "=", "re", ".", "sub", "(", "r\"'*\"", ",", "\"\"", ",", "jid", ")", "return", "jid" ]
Do proper formatting of the jid
[ "Do", "proper", "formatting", "of", "the", "jid" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/postgres_local_cache.py#L316-L322
train
saltstack/salt
salt/returners/postgres_local_cache.py
_build_dict
def _build_dict(data): ''' Rebuild dict ''' result = {} # TODO: Add Metadata support when it is merged from develop result["jid"] = data[0] result["tgt_type"] = data[1] result["cmd"] = data[2] result["tgt"] = data[3] result["kwargs"] = data[4] result["ret"] = data[5] resu...
python
def _build_dict(data): ''' Rebuild dict ''' result = {} # TODO: Add Metadata support when it is merged from develop result["jid"] = data[0] result["tgt_type"] = data[1] result["cmd"] = data[2] result["tgt"] = data[3] result["kwargs"] = data[4] result["ret"] = data[5] resu...
[ "def", "_build_dict", "(", "data", ")", ":", "result", "=", "{", "}", "# TODO: Add Metadata support when it is merged from develop", "result", "[", "\"jid\"", "]", "=", "data", "[", "0", "]", "result", "[", "\"tgt_type\"", "]", "=", "data", "[", "1", "]", "r...
Rebuild dict
[ "Rebuild", "dict" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/postgres_local_cache.py#L325-L340
train
saltstack/salt
salt/returners/postgres_local_cache.py
get_load
def get_load(jid): ''' Return the load data that marks a specified jid ''' jid = _escape_jid(jid) conn = _get_conn() if conn is None: return None cur = conn.cursor() sql = '''SELECT jid, tgt_type, cmd, tgt, kwargs, ret, username, arg,''' \ ''' fun FROM jids WHERE jid = ...
python
def get_load(jid): ''' Return the load data that marks a specified jid ''' jid = _escape_jid(jid) conn = _get_conn() if conn is None: return None cur = conn.cursor() sql = '''SELECT jid, tgt_type, cmd, tgt, kwargs, ret, username, arg,''' \ ''' fun FROM jids WHERE jid = ...
[ "def", "get_load", "(", "jid", ")", ":", "jid", "=", "_escape_jid", "(", "jid", ")", "conn", "=", "_get_conn", "(", ")", "if", "conn", "is", "None", ":", "return", "None", "cur", "=", "conn", ".", "cursor", "(", ")", "sql", "=", "'''SELECT jid, tgt_t...
Return the load data that marks a specified jid
[ "Return", "the", "load", "data", "that", "marks", "a", "specified", "jid" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/postgres_local_cache.py#L343-L359
train
saltstack/salt
salt/returners/postgres_local_cache.py
get_jid
def get_jid(jid): ''' Return the information returned when the specified job id was executed ''' jid = _escape_jid(jid) conn = _get_conn() if conn is None: return None cur = conn.cursor() sql = '''SELECT id, return FROM salt_returns WHERE jid = %s''' cur.execute(sql, (jid,))...
python
def get_jid(jid): ''' Return the information returned when the specified job id was executed ''' jid = _escape_jid(jid) conn = _get_conn() if conn is None: return None cur = conn.cursor() sql = '''SELECT id, return FROM salt_returns WHERE jid = %s''' cur.execute(sql, (jid,))...
[ "def", "get_jid", "(", "jid", ")", ":", "jid", "=", "_escape_jid", "(", "jid", ")", "conn", "=", "_get_conn", "(", ")", "if", "conn", "is", "None", ":", "return", "None", "cur", "=", "conn", ".", "cursor", "(", ")", "sql", "=", "'''SELECT id, return ...
Return the information returned when the specified job id was executed
[ "Return", "the", "information", "returned", "when", "the", "specified", "job", "id", "was", "executed" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/postgres_local_cache.py#L362-L385
train
saltstack/salt
salt/returners/postgres_local_cache.py
get_jids
def get_jids(): ''' Return a list of all job ids For master job cache this also formats the output and returns a string ''' conn = _get_conn() cur = conn.cursor() sql = '''SELECT ''' \ '''jid, tgt_type, cmd, tgt, kwargs, ret, username, arg, fun ''' \ '''FROM jids''' i...
python
def get_jids(): ''' Return a list of all job ids For master job cache this also formats the output and returns a string ''' conn = _get_conn() cur = conn.cursor() sql = '''SELECT ''' \ '''jid, tgt_type, cmd, tgt, kwargs, ret, username, arg, fun ''' \ '''FROM jids''' i...
[ "def", "get_jids", "(", ")", ":", "conn", "=", "_get_conn", "(", ")", "cur", "=", "conn", ".", "cursor", "(", ")", "sql", "=", "'''SELECT '''", "'''jid, tgt_type, cmd, tgt, kwargs, ret, username, arg, fun '''", "'''FROM jids'''", "if", "__opts__", "[", "'keep_jobs'"...
Return a list of all job ids For master job cache this also formats the output and returns a string
[ "Return", "a", "list", "of", "all", "job", "ids", "For", "master", "job", "cache", "this", "also", "formats", "the", "output", "and", "returns", "a", "string" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/postgres_local_cache.py#L388-L412
train
saltstack/salt
salt/modules/aix_shadow.py
login_failures
def login_failures(user): ''' Query for all accounts which have 3 or more login failures. CLI Example: .. code-block:: bash salt <minion_id> shadow.login_failures ALL ''' cmd = 'lsuser -a unsuccessful_login_count {0}'.format(user) cmd += " | grep -E 'unsuccessful_login_count=([3...
python
def login_failures(user): ''' Query for all accounts which have 3 or more login failures. CLI Example: .. code-block:: bash salt <minion_id> shadow.login_failures ALL ''' cmd = 'lsuser -a unsuccessful_login_count {0}'.format(user) cmd += " | grep -E 'unsuccessful_login_count=([3...
[ "def", "login_failures", "(", "user", ")", ":", "cmd", "=", "'lsuser -a unsuccessful_login_count {0}'", ".", "format", "(", "user", ")", "cmd", "+=", "\" | grep -E 'unsuccessful_login_count=([3-9]|[0-9][0-9]+)'\"", "out", "=", "__salt__", "[", "'cmd.run_all'", "]", "(",...
Query for all accounts which have 3 or more login failures. CLI Example: .. code-block:: bash salt <minion_id> shadow.login_failures ALL
[ "Query", "for", "all", "accounts", "which", "have", "3", "or", "more", "login", "failures", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/aix_shadow.py#L32-L54
train
saltstack/salt
salt/modules/aix_shadow.py
unlock
def unlock(user): ''' Unlock user for locked account CLI Example: .. code-block:: bash salt <minion_id> shadow.unlock user ''' cmd = 'chuser account_locked=false {0} | ' \ 'chsec -f /etc/security/lastlog -a "unsuccessful_login_count=0" -s {0}'.format(user) ret = __salt_...
python
def unlock(user): ''' Unlock user for locked account CLI Example: .. code-block:: bash salt <minion_id> shadow.unlock user ''' cmd = 'chuser account_locked=false {0} | ' \ 'chsec -f /etc/security/lastlog -a "unsuccessful_login_count=0" -s {0}'.format(user) ret = __salt_...
[ "def", "unlock", "(", "user", ")", ":", "cmd", "=", "'chuser account_locked=false {0} | '", "'chsec -f /etc/security/lastlog -a \"unsuccessful_login_count=0\" -s {0}'", ".", "format", "(", "user", ")", "ret", "=", "__salt__", "[", "'cmd.run_all'", "]", "(", "cmd", ",", ...
Unlock user for locked account CLI Example: .. code-block:: bash salt <minion_id> shadow.unlock user
[ "Unlock", "user", "for", "locked", "account" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/aix_shadow.py#L81-L96
train
saltstack/salt
salt/states/opsgenie.py
create_alert
def create_alert(name=None, api_key=None, reason=None, action_type="Create"): ''' Create an alert in OpsGenie. Example usage with Salt's requisites and other global state arguments could be found above. Required Parameters: api_key It's the API Key you've copied while adding integration in...
python
def create_alert(name=None, api_key=None, reason=None, action_type="Create"): ''' Create an alert in OpsGenie. Example usage with Salt's requisites and other global state arguments could be found above. Required Parameters: api_key It's the API Key you've copied while adding integration in...
[ "def", "create_alert", "(", "name", "=", "None", ",", "api_key", "=", "None", ",", "reason", "=", "None", ",", "action_type", "=", "\"Create\"", ")", ":", "_", ",", "_", ",", "_", ",", "values", "=", "inspect", ".", "getargvalues", "(", "inspect", "....
Create an alert in OpsGenie. Example usage with Salt's requisites and other global state arguments could be found above. Required Parameters: api_key It's the API Key you've copied while adding integration in OpsGenie. reason It will be used as alert's default message in OpsGenie. ...
[ "Create", "an", "alert", "in", "OpsGenie", ".", "Example", "usage", "with", "Salt", "s", "requisites", "and", "other", "global", "state", "arguments", "could", "be", "found", "above", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/opsgenie.py#L46-L119
train
saltstack/salt
salt/states/opsgenie.py
close_alert
def close_alert(name=None, api_key=None, reason="Conditions are met.", action_type="Close"): ''' Close an alert in OpsGenie. It's a wrapper function for create_alert. Example usage with Salt's requisites and other global state arguments could be found above. Required Parameters: ...
python
def close_alert(name=None, api_key=None, reason="Conditions are met.", action_type="Close"): ''' Close an alert in OpsGenie. It's a wrapper function for create_alert. Example usage with Salt's requisites and other global state arguments could be found above. Required Parameters: ...
[ "def", "close_alert", "(", "name", "=", "None", ",", "api_key", "=", "None", ",", "reason", "=", "\"Conditions are met.\"", ",", "action_type", "=", "\"Close\"", ")", ":", "if", "name", "is", "None", ":", "raise", "salt", ".", "exceptions", ".", "SaltInvoc...
Close an alert in OpsGenie. It's a wrapper function for create_alert. Example usage with Salt's requisites and other global state arguments could be found above. Required Parameters: name It will be used as alert's alias. If you want to use the close functionality you must provide name...
[ "Close", "an", "alert", "in", "OpsGenie", ".", "It", "s", "a", "wrapper", "function", "for", "create_alert", ".", "Example", "usage", "with", "Salt", "s", "requisites", "and", "other", "global", "state", "arguments", "could", "be", "found", "above", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/opsgenie.py#L122-L153
train
saltstack/salt
salt/states/probes.py
_expand_probes
def _expand_probes(probes, defaults): ''' Updates the probes dictionary with different levels of default values. ''' expected_probes = {} for probe_name, probe_test in six.iteritems(probes): if probe_name not in expected_probes.keys(): expected_probes[probe_name] = {} ...
python
def _expand_probes(probes, defaults): ''' Updates the probes dictionary with different levels of default values. ''' expected_probes = {} for probe_name, probe_test in six.iteritems(probes): if probe_name not in expected_probes.keys(): expected_probes[probe_name] = {} ...
[ "def", "_expand_probes", "(", "probes", ",", "defaults", ")", ":", "expected_probes", "=", "{", "}", "for", "probe_name", ",", "probe_test", "in", "six", ".", "iteritems", "(", "probes", ")", ":", "if", "probe_name", "not", "in", "expected_probes", ".", "k...
Updates the probes dictionary with different levels of default values.
[ "Updates", "the", "probes", "dictionary", "with", "different", "levels", "of", "default", "values", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/probes.py#L84-L105
train
saltstack/salt
salt/states/probes.py
_clean_probes
def _clean_probes(probes): ''' Will remove empty and useless values from the probes dictionary. ''' probes = _ordered_dict_to_dict(probes) # make sure we are working only with dict-type probes_copy = deepcopy(probes) for probe_name, probe_tests in six.iteritems(probes_copy): if not pr...
python
def _clean_probes(probes): ''' Will remove empty and useless values from the probes dictionary. ''' probes = _ordered_dict_to_dict(probes) # make sure we are working only with dict-type probes_copy = deepcopy(probes) for probe_name, probe_tests in six.iteritems(probes_copy): if not pr...
[ "def", "_clean_probes", "(", "probes", ")", ":", "probes", "=", "_ordered_dict_to_dict", "(", "probes", ")", "# make sure we are working only with dict-type", "probes_copy", "=", "deepcopy", "(", "probes", ")", "for", "probe_name", ",", "probe_tests", "in", "six", "...
Will remove empty and useless values from the probes dictionary.
[ "Will", "remove", "empty", "and", "useless", "values", "from", "the", "probes", "dictionary", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/probes.py#L108-L126
train
saltstack/salt
salt/states/probes.py
_compare_probes
def _compare_probes(configured_probes, expected_probes): ''' Compares configured probes on the device with the expected configuration and returns the differences. ''' new_probes = {} update_probes = {} remove_probes = {} # noth configured => configure with expected probes if not confi...
python
def _compare_probes(configured_probes, expected_probes): ''' Compares configured probes on the device with the expected configuration and returns the differences. ''' new_probes = {} update_probes = {} remove_probes = {} # noth configured => configure with expected probes if not confi...
[ "def", "_compare_probes", "(", "configured_probes", ",", "expected_probes", ")", ":", "new_probes", "=", "{", "}", "update_probes", "=", "{", "}", "remove_probes", "=", "{", "}", "# noth configured => configure with expected probes", "if", "not", "configured_probes", ...
Compares configured probes on the device with the expected configuration and returns the differences.
[ "Compares", "configured", "probes", "on", "the", "device", "with", "the", "expected", "configuration", "and", "returns", "the", "differences", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/probes.py#L129-L201
train
saltstack/salt
salt/states/probes.py
managed
def managed(name, probes, defaults=None): ''' Ensure the networks device is configured as specified in the state SLS file. Probes not specified will be removed, while probes not confiured as expected will trigger config updates. :param probes: Defines the probes as expected to be configured on the ...
python
def managed(name, probes, defaults=None): ''' Ensure the networks device is configured as specified in the state SLS file. Probes not specified will be removed, while probes not confiured as expected will trigger config updates. :param probes: Defines the probes as expected to be configured on the ...
[ "def", "managed", "(", "name", ",", "probes", ",", "defaults", "=", "None", ")", ":", "ret", "=", "_default_ret", "(", "name", ")", "result", "=", "True", "comment", "=", "''", "rpm_probes_config", "=", "_retrieve_rpm_probes", "(", ")", "# retrieves the RPM ...
Ensure the networks device is configured as specified in the state SLS file. Probes not specified will be removed, while probes not confiured as expected will trigger config updates. :param probes: Defines the probes as expected to be configured on the device. In order to ease the configuration and av...
[ "Ensure", "the", "networks", "device", "is", "configured", "as", "specified", "in", "the", "state", "SLS", "file", ".", "Probes", "not", "specified", "will", "be", "removed", "while", "probes", "not", "confiured", "as", "expected", "will", "trigger", "config",...
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/probes.py#L252-L454
train
saltstack/salt
salt/returners/smtp_return.py
returner
def returner(ret): ''' Send an email with the data ''' _options = _get_options(ret) from_addr = _options.get('from') to_addrs = _options.get('to').split(',') host = _options.get('host') port = _options.get('port') user = _options.get('username') passwd = _options.get('password')...
python
def returner(ret): ''' Send an email with the data ''' _options = _get_options(ret) from_addr = _options.get('from') to_addrs = _options.get('to').split(',') host = _options.get('host') port = _options.get('port') user = _options.get('username') passwd = _options.get('password')...
[ "def", "returner", "(", "ret", ")", ":", "_options", "=", "_get_options", "(", "ret", ")", "from_addr", "=", "_options", ".", "get", "(", "'from'", ")", "to_addrs", "=", "_options", ".", "get", "(", "'to'", ")", ".", "split", "(", "','", ")", "host",...
Send an email with the data
[ "Send", "an", "email", "with", "the", "data" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/smtp_return.py#L163-L260
train
saltstack/salt
salt/returners/smtp_return.py
event_return
def event_return(events): ''' Return event data via SMTP ''' for event in events: ret = event.get('data', False) if ret: returner(ret)
python
def event_return(events): ''' Return event data via SMTP ''' for event in events: ret = event.get('data', False) if ret: returner(ret)
[ "def", "event_return", "(", "events", ")", ":", "for", "event", "in", "events", ":", "ret", "=", "event", ".", "get", "(", "'data'", ",", "False", ")", "if", "ret", ":", "returner", "(", "ret", ")" ]
Return event data via SMTP
[ "Return", "event", "data", "via", "SMTP" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/smtp_return.py#L270-L279
train
saltstack/salt
salt/modules/incron.py
_render_tab
def _render_tab(lst): ''' Takes a tab list structure and renders it to a list for applying it to a file ''' ret = [] for pre in lst['pre']: ret.append('{0}\n'.format(pre)) for cron in lst['crons']: ret.append('{0} {1} {2} {3}\n'.format(cron['path'], ...
python
def _render_tab(lst): ''' Takes a tab list structure and renders it to a list for applying it to a file ''' ret = [] for pre in lst['pre']: ret.append('{0}\n'.format(pre)) for cron in lst['crons']: ret.append('{0} {1} {2} {3}\n'.format(cron['path'], ...
[ "def", "_render_tab", "(", "lst", ")", ":", "ret", "=", "[", "]", "for", "pre", "in", "lst", "[", "'pre'", "]", ":", "ret", ".", "append", "(", "'{0}\\n'", ".", "format", "(", "pre", ")", ")", "for", "cron", "in", "lst", "[", "'crons'", "]", ":...
Takes a tab list structure and renders it to a list for applying it to a file
[ "Takes", "a", "tab", "list", "structure", "and", "renders", "it", "to", "a", "list", "for", "applying", "it", "to", "a", "file" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/incron.py#L47-L62
train
saltstack/salt
salt/modules/incron.py
write_incron_file
def write_incron_file(user, path): ''' Writes the contents of a file to a user's incrontab CLI Example: .. code-block:: bash salt '*' incron.write_incron_file root /tmp/new_incron ''' return __salt__['cmd.retcode'](_get_incron_cmdstr(path), runas=user, python_shell=False) == 0
python
def write_incron_file(user, path): ''' Writes the contents of a file to a user's incrontab CLI Example: .. code-block:: bash salt '*' incron.write_incron_file root /tmp/new_incron ''' return __salt__['cmd.retcode'](_get_incron_cmdstr(path), runas=user, python_shell=False) == 0
[ "def", "write_incron_file", "(", "user", ",", "path", ")", ":", "return", "__salt__", "[", "'cmd.retcode'", "]", "(", "_get_incron_cmdstr", "(", "path", ")", ",", "runas", "=", "user", ",", "python_shell", "=", "False", ")", "==", "0" ]
Writes the contents of a file to a user's incrontab CLI Example: .. code-block:: bash salt '*' incron.write_incron_file root /tmp/new_incron
[ "Writes", "the", "contents", "of", "a", "file", "to", "a", "user", "s", "incrontab" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/incron.py#L72-L82
train
saltstack/salt
salt/modules/incron.py
write_incron_file_verbose
def write_incron_file_verbose(user, path): ''' Writes the contents of a file to a user's incrontab and return error message on error CLI Example: .. code-block:: bash salt '*' incron.write_incron_file_verbose root /tmp/new_incron ''' return __salt__['cmd.run_all'](_get_incron_cmdstr(p...
python
def write_incron_file_verbose(user, path): ''' Writes the contents of a file to a user's incrontab and return error message on error CLI Example: .. code-block:: bash salt '*' incron.write_incron_file_verbose root /tmp/new_incron ''' return __salt__['cmd.run_all'](_get_incron_cmdstr(p...
[ "def", "write_incron_file_verbose", "(", "user", ",", "path", ")", ":", "return", "__salt__", "[", "'cmd.run_all'", "]", "(", "_get_incron_cmdstr", "(", "path", ")", ",", "runas", "=", "user", ",", "python_shell", "=", "False", ")" ]
Writes the contents of a file to a user's incrontab and return error message on error CLI Example: .. code-block:: bash salt '*' incron.write_incron_file_verbose root /tmp/new_incron
[ "Writes", "the", "contents", "of", "a", "file", "to", "a", "user", "s", "incrontab", "and", "return", "error", "message", "on", "error" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/incron.py#L85-L95
train
saltstack/salt
salt/modules/incron.py
_write_incron_lines
def _write_incron_lines(user, lines): ''' Takes a list of lines to be committed to a user's incrontab and writes it ''' if user == 'system': ret = {} ret['retcode'] = _write_file(_INCRON_SYSTEM_TAB, 'salt', ''.join(lines)) return ret else: path = salt.utils.files.mkst...
python
def _write_incron_lines(user, lines): ''' Takes a list of lines to be committed to a user's incrontab and writes it ''' if user == 'system': ret = {} ret['retcode'] = _write_file(_INCRON_SYSTEM_TAB, 'salt', ''.join(lines)) return ret else: path = salt.utils.files.mkst...
[ "def", "_write_incron_lines", "(", "user", ",", "lines", ")", ":", "if", "user", "==", "'system'", ":", "ret", "=", "{", "}", "ret", "[", "'retcode'", "]", "=", "_write_file", "(", "_INCRON_SYSTEM_TAB", ",", "'salt'", ",", "''", ".", "join", "(", "line...
Takes a list of lines to be committed to a user's incrontab and writes it
[ "Takes", "a", "list", "of", "lines", "to", "be", "committed", "to", "a", "user", "s", "incrontab", "and", "writes", "it" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/incron.py#L98-L114
train
saltstack/salt
salt/modules/incron.py
_write_file
def _write_file(folder, filename, data): ''' Writes a file to disk ''' path = os.path.join(folder, filename) if not os.path.exists(folder): msg = '{0} cannot be written. {1} does not exist'.format(filename, folder) log.error(msg) raise AttributeError(six.text_type(msg)) w...
python
def _write_file(folder, filename, data): ''' Writes a file to disk ''' path = os.path.join(folder, filename) if not os.path.exists(folder): msg = '{0} cannot be written. {1} does not exist'.format(filename, folder) log.error(msg) raise AttributeError(six.text_type(msg)) w...
[ "def", "_write_file", "(", "folder", ",", "filename", ",", "data", ")", ":", "path", "=", "os", ".", "path", ".", "join", "(", "folder", ",", "filename", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "folder", ")", ":", "msg", "=", "'{...
Writes a file to disk
[ "Writes", "a", "file", "to", "disk" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/incron.py#L117-L129
train
saltstack/salt
salt/modules/incron.py
_read_file
def _read_file(folder, filename): ''' Reads and returns the contents of a file ''' path = os.path.join(folder, filename) try: with salt.utils.files.fopen(path, 'rb') as contents: return salt.utils.data.decode(contents.readlines()) except (OSError, IOError): return ''
python
def _read_file(folder, filename): ''' Reads and returns the contents of a file ''' path = os.path.join(folder, filename) try: with salt.utils.files.fopen(path, 'rb') as contents: return salt.utils.data.decode(contents.readlines()) except (OSError, IOError): return ''
[ "def", "_read_file", "(", "folder", ",", "filename", ")", ":", "path", "=", "os", ".", "path", ".", "join", "(", "folder", ",", "filename", ")", "try", ":", "with", "salt", ".", "utils", ".", "files", ".", "fopen", "(", "path", ",", "'rb'", ")", ...
Reads and returns the contents of a file
[ "Reads", "and", "returns", "the", "contents", "of", "a", "file" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/incron.py#L132-L141
train
saltstack/salt
salt/modules/incron.py
raw_incron
def raw_incron(user): ''' Return the contents of the user's incrontab CLI Example: .. code-block:: bash salt '*' incron.raw_incron root ''' if __grains__['os_family'] == 'Solaris': cmd = 'incrontab -l {0}'.format(user) else: cmd = 'incrontab -l -u {0}'.format(user)...
python
def raw_incron(user): ''' Return the contents of the user's incrontab CLI Example: .. code-block:: bash salt '*' incron.raw_incron root ''' if __grains__['os_family'] == 'Solaris': cmd = 'incrontab -l {0}'.format(user) else: cmd = 'incrontab -l -u {0}'.format(user)...
[ "def", "raw_incron", "(", "user", ")", ":", "if", "__grains__", "[", "'os_family'", "]", "==", "'Solaris'", ":", "cmd", "=", "'incrontab -l {0}'", ".", "format", "(", "user", ")", "else", ":", "cmd", "=", "'incrontab -l -u {0}'", ".", "format", "(", "user"...
Return the contents of the user's incrontab CLI Example: .. code-block:: bash salt '*' incron.raw_incron root
[ "Return", "the", "contents", "of", "the", "user", "s", "incrontab" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/incron.py#L159-L173
train
saltstack/salt
salt/modules/incron.py
list_tab
def list_tab(user): ''' Return the contents of the specified user's incrontab CLI Example: .. code-block:: bash salt '*' incron.list_tab root ''' if user == 'system': data = raw_system_incron() else: data = raw_incron(user) log.debug('incron user data %s', ...
python
def list_tab(user): ''' Return the contents of the specified user's incrontab CLI Example: .. code-block:: bash salt '*' incron.list_tab root ''' if user == 'system': data = raw_system_incron() else: data = raw_incron(user) log.debug('incron user data %s', ...
[ "def", "list_tab", "(", "user", ")", ":", "if", "user", "==", "'system'", ":", "data", "=", "raw_system_incron", "(", ")", "else", ":", "data", "=", "raw_incron", "(", "user", ")", "log", ".", "debug", "(", "'incron user data %s'", ",", "data", ")", "r...
Return the contents of the specified user's incrontab CLI Example: .. code-block:: bash salt '*' incron.list_tab root
[ "Return", "the", "contents", "of", "the", "specified", "user", "s", "incrontab" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/incron.py#L176-L214
train
saltstack/salt
salt/modules/incron.py
set_job
def set_job(user, path, mask, cmd): ''' Sets an incron job up for a specified user. CLI Example: .. code-block:: bash salt '*' incron.set_job root '/root' 'IN_MODIFY' 'echo "$$ $@ $# $% $&"' ''' # Scrub the types mask = six.text_type(mask).upper() # Check for valid mask types...
python
def set_job(user, path, mask, cmd): ''' Sets an incron job up for a specified user. CLI Example: .. code-block:: bash salt '*' incron.set_job root '/root' 'IN_MODIFY' 'echo "$$ $@ $# $% $&"' ''' # Scrub the types mask = six.text_type(mask).upper() # Check for valid mask types...
[ "def", "set_job", "(", "user", ",", "path", ",", "mask", ",", "cmd", ")", ":", "# Scrub the types", "mask", "=", "six", ".", "text_type", "(", "mask", ")", ".", "upper", "(", ")", "# Check for valid mask types", "for", "item", "in", "mask", ".", "split",...
Sets an incron job up for a specified user. CLI Example: .. code-block:: bash salt '*' incron.set_job root '/root' 'IN_MODIFY' 'echo "$$ $@ $# $% $&"'
[ "Sets", "an", "incron", "job", "up", "for", "a", "specified", "user", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/incron.py#L221-L276
train
saltstack/salt
salt/modules/incron.py
rm_job
def rm_job(user, path, mask, cmd): ''' Remove a incron job for a specified user. If any of the day/time params are specified, the job will only be removed if the specified params match. CLI Example: .. code-block:: bash salt '*' incron.rm_job root /path ...
python
def rm_job(user, path, mask, cmd): ''' Remove a incron job for a specified user. If any of the day/time params are specified, the job will only be removed if the specified params match. CLI Example: .. code-block:: bash salt '*' incron.rm_job root /path ...
[ "def", "rm_job", "(", "user", ",", "path", ",", "mask", ",", "cmd", ")", ":", "# Scrub the types", "mask", "=", "six", ".", "text_type", "(", "mask", ")", ".", "upper", "(", ")", "# Check for valid mask types", "for", "item", "in", "mask", ".", "split", ...
Remove a incron job for a specified user. If any of the day/time params are specified, the job will only be removed if the specified params match. CLI Example: .. code-block:: bash salt '*' incron.rm_job root /path
[ "Remove", "a", "incron", "job", "for", "a", "specified", "user", ".", "If", "any", "of", "the", "day", "/", "time", "params", "are", "specified", "the", "job", "will", "only", "be", "removed", "if", "the", "specified", "params", "match", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/incron.py#L279-L320
train
saltstack/salt
salt/engines/ircbot.py
start
def start(nick, host, port=6667, username=None, password=None, channels=None, use_ssl=False, use_sasl=False, char='!', allow_hosts=False, allow_nicks=False, disable_query=True): ''' IRC Bot for interacting with salt. nick Nickname of the connected Bot. host irc server (exampl...
python
def start(nick, host, port=6667, username=None, password=None, channels=None, use_ssl=False, use_sasl=False, char='!', allow_hosts=False, allow_nicks=False, disable_query=True): ''' IRC Bot for interacting with salt. nick Nickname of the connected Bot. host irc server (exampl...
[ "def", "start", "(", "nick", ",", "host", ",", "port", "=", "6667", ",", "username", "=", "None", ",", "password", "=", "None", ",", "channels", "=", "None", ",", "use_ssl", "=", "False", ",", "use_sasl", "=", "False", ",", "char", "=", "'!'", ",",...
IRC Bot for interacting with salt. nick Nickname of the connected Bot. host irc server (example - chat.freenode.net). port irc port. Default: 6667 password password for authenticating. If not provided, user will not authenticate on the irc server. channels ...
[ "IRC", "Bot", "for", "interacting", "with", "salt", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/engines/ircbot.py#L225-L285
train
saltstack/salt
salt/modules/suse_apache.py
check_mod_enabled
def check_mod_enabled(mod): ''' Checks to see if the specific apache mod is enabled. This will only be functional on operating systems that support `a2enmod -l` to list the enabled mods. CLI Example: .. code-block:: bash salt '*' apache.check_mod_enabled status ''' if mod.end...
python
def check_mod_enabled(mod): ''' Checks to see if the specific apache mod is enabled. This will only be functional on operating systems that support `a2enmod -l` to list the enabled mods. CLI Example: .. code-block:: bash salt '*' apache.check_mod_enabled status ''' if mod.end...
[ "def", "check_mod_enabled", "(", "mod", ")", ":", "if", "mod", ".", "endswith", "(", "'.load'", ")", "or", "mod", ".", "endswith", "(", "'.conf'", ")", ":", "mod_name", "=", "mod", "[", ":", "-", "5", "]", "else", ":", "mod_name", "=", "mod", "cmd"...
Checks to see if the specific apache mod is enabled. This will only be functional on operating systems that support `a2enmod -l` to list the enabled mods. CLI Example: .. code-block:: bash salt '*' apache.check_mod_enabled status
[ "Checks", "to", "see", "if", "the", "specific", "apache", "mod", "is", "enabled", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/suse_apache.py#L31-L55
train
saltstack/salt
salt/modules/boto_kms.py
create_alias
def create_alias(alias_name, target_key_id, region=None, key=None, keyid=None, profile=None): ''' Create a display name for a key. CLI example:: salt myminion boto_kms.create_alias 'alias/mykey' key_id ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profi...
python
def create_alias(alias_name, target_key_id, region=None, key=None, keyid=None, profile=None): ''' Create a display name for a key. CLI example:: salt myminion boto_kms.create_alias 'alias/mykey' key_id ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profi...
[ "def", "create_alias", "(", "alias_name", ",", "target_key_id", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "conn", "=", "_get_conn", "(", "region", "=", "region", ",", "key", ...
Create a display name for a key. CLI example:: salt myminion boto_kms.create_alias 'alias/mykey' key_id
[ "Create", "a", "display", "name", "for", "a", "key", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L80-L98
train
saltstack/salt
salt/modules/boto_kms.py
create_grant
def create_grant(key_id, grantee_principal, retiring_principal=None, operations=None, constraints=None, grant_tokens=None, region=None, key=None, keyid=None, profile=None): ''' Adds a grant to a key to specify who can access the key and under what conditions. CLI examp...
python
def create_grant(key_id, grantee_principal, retiring_principal=None, operations=None, constraints=None, grant_tokens=None, region=None, key=None, keyid=None, profile=None): ''' Adds a grant to a key to specify who can access the key and under what conditions. CLI examp...
[ "def", "create_grant", "(", "key_id", ",", "grantee_principal", ",", "retiring_principal", "=", "None", ",", "operations", "=", "None", ",", "constraints", "=", "None", ",", "grant_tokens", "=", "None", ",", "region", "=", "None", ",", "key", "=", "None", ...
Adds a grant to a key to specify who can access the key and under what conditions. CLI example:: salt myminion boto_kms.create_grant 'alias/mykey' 'arn:aws:iam::1111111:/role/myrole' operations='["Encrypt","Decrypt"]'
[ "Adds", "a", "grant", "to", "a", "key", "to", "specify", "who", "can", "access", "the", "key", "and", "under", "what", "conditions", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L101-L128
train
saltstack/salt
salt/modules/boto_kms.py
create_key
def create_key(policy=None, description=None, key_usage=None, region=None, key=None, keyid=None, profile=None): ''' Creates a master key. CLI example:: salt myminion boto_kms.create_key '{"Statement":...}' "My master key" ''' conn = _get_conn(region=region, key=key, keyid=ke...
python
def create_key(policy=None, description=None, key_usage=None, region=None, key=None, keyid=None, profile=None): ''' Creates a master key. CLI example:: salt myminion boto_kms.create_key '{"Statement":...}' "My master key" ''' conn = _get_conn(region=region, key=key, keyid=ke...
[ "def", "create_key", "(", "policy", "=", "None", ",", "description", "=", "None", ",", "key_usage", "=", "None", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "conn", "=", "_g...
Creates a master key. CLI example:: salt myminion boto_kms.create_key '{"Statement":...}' "My master key"
[ "Creates", "a", "master", "key", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L131-L153
train
saltstack/salt
salt/modules/boto_kms.py
decrypt
def decrypt(ciphertext_blob, encryption_context=None, grant_tokens=None, region=None, key=None, keyid=None, profile=None): ''' Decrypt ciphertext. CLI example:: salt myminion boto_kms.decrypt encrypted_ciphertext ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile...
python
def decrypt(ciphertext_blob, encryption_context=None, grant_tokens=None, region=None, key=None, keyid=None, profile=None): ''' Decrypt ciphertext. CLI example:: salt myminion boto_kms.decrypt encrypted_ciphertext ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile...
[ "def", "decrypt", "(", "ciphertext_blob", ",", "encryption_context", "=", "None", ",", "grant_tokens", "=", "None", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "conn", "=", "_ge...
Decrypt ciphertext. CLI example:: salt myminion boto_kms.decrypt encrypted_ciphertext
[ "Decrypt", "ciphertext", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L156-L177
train
saltstack/salt
salt/modules/boto_kms.py
key_exists
def key_exists(key_id, region=None, key=None, keyid=None, profile=None): ''' Check for the existence of a key. CLI example:: salt myminion boto_kms.key_exists 'alias/mykey' ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) r = {} try: key = conn.de...
python
def key_exists(key_id, region=None, key=None, keyid=None, profile=None): ''' Check for the existence of a key. CLI example:: salt myminion boto_kms.key_exists 'alias/mykey' ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) r = {} try: key = conn.de...
[ "def", "key_exists", "(", "key_id", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "conn", "=", "_get_conn", "(", "region", "=", "region", ",", "key", "=", "key", ",", "keyid",...
Check for the existence of a key. CLI example:: salt myminion boto_kms.key_exists 'alias/mykey'
[ "Check", "for", "the", "existence", "of", "a", "key", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L180-L200
train
saltstack/salt
salt/modules/boto_kms.py
_get_key_id
def _get_key_id(alias, region=None, key=None, keyid=None, profile=None): ''' From an alias, get a key_id. ''' key_metadata = describe_key( alias, region, key, keyid, profile )['key_metadata'] return key_metadata['KeyId']
python
def _get_key_id(alias, region=None, key=None, keyid=None, profile=None): ''' From an alias, get a key_id. ''' key_metadata = describe_key( alias, region, key, keyid, profile )['key_metadata'] return key_metadata['KeyId']
[ "def", "_get_key_id", "(", "alias", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "key_metadata", "=", "describe_key", "(", "alias", ",", "region", ",", "key", ",", "keyid", ","...
From an alias, get a key_id.
[ "From", "an", "alias", "get", "a", "key_id", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L203-L210
train
saltstack/salt
salt/modules/boto_kms.py
disable_key
def disable_key(key_id, region=None, key=None, keyid=None, profile=None): ''' Mark key as disabled. CLI example:: salt myminion boto_kms.disable_key 'alias/mykey' ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) r = {} try: key = conn.disable_key(...
python
def disable_key(key_id, region=None, key=None, keyid=None, profile=None): ''' Mark key as disabled. CLI example:: salt myminion boto_kms.disable_key 'alias/mykey' ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) r = {} try: key = conn.disable_key(...
[ "def", "disable_key", "(", "key_id", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "conn", "=", "_get_conn", "(", "region", "=", "region", ",", "key", "=", "key", ",", "keyid"...
Mark key as disabled. CLI example:: salt myminion boto_kms.disable_key 'alias/mykey'
[ "Mark", "key", "as", "disabled", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L233-L250
train
saltstack/salt
salt/modules/boto_kms.py
encrypt
def encrypt(key_id, plaintext, encryption_context=None, grant_tokens=None, region=None, key=None, keyid=None, profile=None): ''' Encrypt plaintext into cipher text using specified key. CLI example:: salt myminion boto_kms.encrypt 'alias/mykey' 'myplaindata' '{"aws:username":"myuser"}' ...
python
def encrypt(key_id, plaintext, encryption_context=None, grant_tokens=None, region=None, key=None, keyid=None, profile=None): ''' Encrypt plaintext into cipher text using specified key. CLI example:: salt myminion boto_kms.encrypt 'alias/mykey' 'myplaindata' '{"aws:username":"myuser"}' ...
[ "def", "encrypt", "(", "key_id", ",", "plaintext", ",", "encryption_context", "=", "None", ",", "grant_tokens", "=", "None", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "conn", ...
Encrypt plaintext into cipher text using specified key. CLI example:: salt myminion boto_kms.encrypt 'alias/mykey' 'myplaindata' '{"aws:username":"myuser"}'
[ "Encrypt", "plaintext", "into", "cipher", "text", "using", "specified", "key", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L315-L337
train
saltstack/salt
salt/modules/boto_kms.py
generate_data_key
def generate_data_key(key_id, encryption_context=None, number_of_bytes=None, key_spec=None, grant_tokens=None, region=None, key=None, keyid=None, profile=None): ''' Generate a secure data key. CLI example:: salt myminion boto_kms.generate_data_key 'alias...
python
def generate_data_key(key_id, encryption_context=None, number_of_bytes=None, key_spec=None, grant_tokens=None, region=None, key=None, keyid=None, profile=None): ''' Generate a secure data key. CLI example:: salt myminion boto_kms.generate_data_key 'alias...
[ "def", "generate_data_key", "(", "key_id", ",", "encryption_context", "=", "None", ",", "number_of_bytes", "=", "None", ",", "key_spec", "=", "None", ",", "grant_tokens", "=", "None", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", ...
Generate a secure data key. CLI example:: salt myminion boto_kms.generate_data_key 'alias/mykey' number_of_bytes=1024 key_spec=AES_128
[ "Generate", "a", "secure", "data", "key", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L340-L364
train
saltstack/salt
salt/modules/boto_kms.py
generate_random
def generate_random(number_of_bytes=None, region=None, key=None, keyid=None, profile=None): ''' Generate a random string. CLI example:: salt myminion boto_kms.generate_random number_of_bytes=1024 ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)...
python
def generate_random(number_of_bytes=None, region=None, key=None, keyid=None, profile=None): ''' Generate a random string. CLI example:: salt myminion boto_kms.generate_random number_of_bytes=1024 ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)...
[ "def", "generate_random", "(", "number_of_bytes", "=", "None", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "conn", "=", "_get_conn", "(", "region", "=", "region", ",", "key", ...
Generate a random string. CLI example:: salt myminion boto_kms.generate_random number_of_bytes=1024
[ "Generate", "a", "random", "string", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L395-L412
train
saltstack/salt
salt/modules/boto_kms.py
get_key_policy
def get_key_policy(key_id, policy_name, region=None, key=None, keyid=None, profile=None): ''' Get the policy for the specified key. CLI example:: salt myminion boto_kms.get_key_policy 'alias/mykey' mypolicy ''' conn = _get_conn(region=region, key=key, keyid=keyid, profil...
python
def get_key_policy(key_id, policy_name, region=None, key=None, keyid=None, profile=None): ''' Get the policy for the specified key. CLI example:: salt myminion boto_kms.get_key_policy 'alias/mykey' mypolicy ''' conn = _get_conn(region=region, key=key, keyid=keyid, profil...
[ "def", "get_key_policy", "(", "key_id", ",", "policy_name", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "conn", "=", "_get_conn", "(", "region", "=", "region", ",", "key", "="...
Get the policy for the specified key. CLI example:: salt myminion boto_kms.get_key_policy 'alias/mykey' mypolicy
[ "Get", "the", "policy", "for", "the", "specified", "key", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L415-L435
train
saltstack/salt
salt/modules/boto_kms.py
get_key_rotation_status
def get_key_rotation_status(key_id, region=None, key=None, keyid=None, profile=None): ''' Get status of whether or not key rotation is enabled for a key. CLI example:: salt myminion boto_kms.get_key_rotation_status 'alias/mykey' ''' conn = _get_conn(region=regio...
python
def get_key_rotation_status(key_id, region=None, key=None, keyid=None, profile=None): ''' Get status of whether or not key rotation is enabled for a key. CLI example:: salt myminion boto_kms.get_key_rotation_status 'alias/mykey' ''' conn = _get_conn(region=regio...
[ "def", "get_key_rotation_status", "(", "key_id", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "conn", "=", "_get_conn", "(", "region", "=", "region", ",", "key", "=", "key", ",...
Get status of whether or not key rotation is enabled for a key. CLI example:: salt myminion boto_kms.get_key_rotation_status 'alias/mykey'
[ "Get", "status", "of", "whether", "or", "not", "key", "rotation", "is", "enabled", "for", "a", "key", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L438-L455
train
saltstack/salt
salt/modules/boto_kms.py
list_grants
def list_grants(key_id, limit=None, marker=None, region=None, key=None, keyid=None, profile=None): ''' List grants for the specified key. CLI example:: salt myminion boto_kms.list_grants 'alias/mykey' ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile...
python
def list_grants(key_id, limit=None, marker=None, region=None, key=None, keyid=None, profile=None): ''' List grants for the specified key. CLI example:: salt myminion boto_kms.list_grants 'alias/mykey' ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile...
[ "def", "list_grants", "(", "key_id", ",", "limit", "=", "None", ",", "marker", "=", "None", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "conn", "=", "_get_conn", "(", "regio...
List grants for the specified key. CLI example:: salt myminion boto_kms.list_grants 'alias/mykey'
[ "List", "grants", "for", "the", "specified", "key", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L458-L490
train
saltstack/salt
salt/modules/boto_kms.py
list_key_policies
def list_key_policies(key_id, limit=None, marker=None, region=None, key=None, keyid=None, profile=None): ''' List key_policies for the specified key. CLI example:: salt myminion boto_kms.list_key_policies 'alias/mykey' ''' conn = _get_conn(region=region, key=key, keyi...
python
def list_key_policies(key_id, limit=None, marker=None, region=None, key=None, keyid=None, profile=None): ''' List key_policies for the specified key. CLI example:: salt myminion boto_kms.list_key_policies 'alias/mykey' ''' conn = _get_conn(region=region, key=key, keyi...
[ "def", "list_key_policies", "(", "key_id", ",", "limit", "=", "None", ",", "marker", "=", "None", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "conn", "=", "_get_conn", "(", ...
List key_policies for the specified key. CLI example:: salt myminion boto_kms.list_key_policies 'alias/mykey'
[ "List", "key_policies", "for", "the", "specified", "key", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L493-L517
train
saltstack/salt
salt/modules/boto_kms.py
put_key_policy
def put_key_policy(key_id, policy_name, policy, region=None, key=None, keyid=None, profile=None): ''' Attach a key policy to the specified key. CLI example:: salt myminion boto_kms.put_key_policy 'alias/mykey' default '{"Statement":...}' ''' conn = _get_conn(region=regio...
python
def put_key_policy(key_id, policy_name, policy, region=None, key=None, keyid=None, profile=None): ''' Attach a key policy to the specified key. CLI example:: salt myminion boto_kms.put_key_policy 'alias/mykey' default '{"Statement":...}' ''' conn = _get_conn(region=regio...
[ "def", "put_key_policy", "(", "key_id", ",", "policy_name", ",", "policy", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "conn", "=", "_get_conn", "(", "region", "=", "region", ...
Attach a key policy to the specified key. CLI example:: salt myminion boto_kms.put_key_policy 'alias/mykey' default '{"Statement":...}'
[ "Attach", "a", "key", "policy", "to", "the", "specified", "key", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L520-L538
train
saltstack/salt
salt/modules/boto_kms.py
re_encrypt
def re_encrypt(ciphertext_blob, destination_key_id, source_encryption_context=None, destination_encryption_context=None, grant_tokens=None, region=None, key=None, keyid=None, profile=None): ''' Reencrypt encrypted data with a new master key. CLI example:: ...
python
def re_encrypt(ciphertext_blob, destination_key_id, source_encryption_context=None, destination_encryption_context=None, grant_tokens=None, region=None, key=None, keyid=None, profile=None): ''' Reencrypt encrypted data with a new master key. CLI example:: ...
[ "def", "re_encrypt", "(", "ciphertext_blob", ",", "destination_key_id", ",", "source_encryption_context", "=", "None", ",", "destination_encryption_context", "=", "None", ",", "grant_tokens", "=", "None", ",", "region", "=", "None", ",", "key", "=", "None", ",", ...
Reencrypt encrypted data with a new master key. CLI example:: salt myminion boto_kms.re_encrypt 'encrypted_data' 'alias/mynewkey' default '{"Statement":...}'
[ "Reencrypt", "encrypted", "data", "with", "a", "new", "master", "key", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L541-L568
train
saltstack/salt
salt/modules/boto_kms.py
revoke_grant
def revoke_grant(key_id, grant_id, region=None, key=None, keyid=None, profile=None): ''' Revoke a grant from a key. CLI example:: salt myminion boto_kms.revoke_grant 'alias/mykey' 8u89hf-j09j... ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) ...
python
def revoke_grant(key_id, grant_id, region=None, key=None, keyid=None, profile=None): ''' Revoke a grant from a key. CLI example:: salt myminion boto_kms.revoke_grant 'alias/mykey' 8u89hf-j09j... ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) ...
[ "def", "revoke_grant", "(", "key_id", ",", "grant_id", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "conn", "=", "_get_conn", "(", "region", "=", "region", ",", "key", "=", "...
Revoke a grant from a key. CLI example:: salt myminion boto_kms.revoke_grant 'alias/mykey' 8u89hf-j09j...
[ "Revoke", "a", "grant", "from", "a", "key", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L571-L591
train
saltstack/salt
salt/utils/debug.py
_makepretty
def _makepretty(printout, stack): ''' Pretty print the stack trace and environment information for debugging those hard to reproduce user problems. :) ''' printout.write('======== Salt Debug Stack Trace =========\n') traceback.print_stack(stack, file=printout) printout.write('==============...
python
def _makepretty(printout, stack): ''' Pretty print the stack trace and environment information for debugging those hard to reproduce user problems. :) ''' printout.write('======== Salt Debug Stack Trace =========\n') traceback.print_stack(stack, file=printout) printout.write('==============...
[ "def", "_makepretty", "(", "printout", ",", "stack", ")", ":", "printout", ".", "write", "(", "'======== Salt Debug Stack Trace =========\\n'", ")", "traceback", ".", "print_stack", "(", "stack", ",", "file", "=", "printout", ")", "printout", ".", "write", "(", ...
Pretty print the stack trace and environment information for debugging those hard to reproduce user problems. :)
[ "Pretty", "print", "the", "stack", "trace", "and", "environment", "information", "for", "debugging", "those", "hard", "to", "reproduce", "user", "problems", ".", ":", ")" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/debug.py#L21-L28
train
saltstack/salt
salt/utils/debug.py
_handle_sigusr1
def _handle_sigusr1(sig, stack): ''' Signal handler for SIGUSR1, only available on Unix-like systems ''' # When running in the foreground, do the right thing # and spit out the debug info straight to the console if sys.stderr.isatty(): output = sys.stderr _makepretty(output, sta...
python
def _handle_sigusr1(sig, stack): ''' Signal handler for SIGUSR1, only available on Unix-like systems ''' # When running in the foreground, do the right thing # and spit out the debug info straight to the console if sys.stderr.isatty(): output = sys.stderr _makepretty(output, sta...
[ "def", "_handle_sigusr1", "(", "sig", ",", "stack", ")", ":", "# When running in the foreground, do the right thing", "# and spit out the debug info straight to the console", "if", "sys", ".", "stderr", ".", "isatty", "(", ")", ":", "output", "=", "sys", ".", "stderr",...
Signal handler for SIGUSR1, only available on Unix-like systems
[ "Signal", "handler", "for", "SIGUSR1", "only", "available", "on", "Unix", "-", "like", "systems" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/debug.py#L31-L44
train
saltstack/salt
salt/utils/debug.py
_handle_sigusr2
def _handle_sigusr2(sig, stack): ''' Signal handler for SIGUSR2, only available on Unix-like systems ''' try: import yappi except ImportError: return if yappi.is_running(): yappi.stop() filename = 'callgrind.salt-{0}-{1}'.format(int(time.time()), os.getpid()) ...
python
def _handle_sigusr2(sig, stack): ''' Signal handler for SIGUSR2, only available on Unix-like systems ''' try: import yappi except ImportError: return if yappi.is_running(): yappi.stop() filename = 'callgrind.salt-{0}-{1}'.format(int(time.time()), os.getpid()) ...
[ "def", "_handle_sigusr2", "(", "sig", ",", "stack", ")", ":", "try", ":", "import", "yappi", "except", "ImportError", ":", "return", "if", "yappi", ".", "is_running", "(", ")", ":", "yappi", ".", "stop", "(", ")", "filename", "=", "'callgrind.salt-{0}-{1}'...
Signal handler for SIGUSR2, only available on Unix-like systems
[ "Signal", "handler", "for", "SIGUSR2", "only", "available", "on", "Unix", "-", "like", "systems" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/debug.py#L47-L66
train
saltstack/salt
salt/utils/debug.py
enable_sig_handler
def enable_sig_handler(signal_name, handler): ''' Add signal handler for signal name if it exists on given platform ''' if hasattr(signal, signal_name): signal.signal(getattr(signal, signal_name), handler)
python
def enable_sig_handler(signal_name, handler): ''' Add signal handler for signal name if it exists on given platform ''' if hasattr(signal, signal_name): signal.signal(getattr(signal, signal_name), handler)
[ "def", "enable_sig_handler", "(", "signal_name", ",", "handler", ")", ":", "if", "hasattr", "(", "signal", ",", "signal_name", ")", ":", "signal", ".", "signal", "(", "getattr", "(", "signal", ",", "signal_name", ")", ",", "handler", ")" ]
Add signal handler for signal name if it exists on given platform
[ "Add", "signal", "handler", "for", "signal", "name", "if", "it", "exists", "on", "given", "platform" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/debug.py#L69-L74
train
saltstack/salt
salt/utils/debug.py
caller_name
def caller_name(skip=2, include_lineno=False): ''' Get a name of a caller in the format module.class.method `skip` specifies how many levels of stack to skip while getting caller name. skip=1 means "who calls me", skip=2 "who calls my caller" etc. An empty string is returned if skipped levels exce...
python
def caller_name(skip=2, include_lineno=False): ''' Get a name of a caller in the format module.class.method `skip` specifies how many levels of stack to skip while getting caller name. skip=1 means "who calls me", skip=2 "who calls my caller" etc. An empty string is returned if skipped levels exce...
[ "def", "caller_name", "(", "skip", "=", "2", ",", "include_lineno", "=", "False", ")", ":", "stack", "=", "inspect", ".", "stack", "(", ")", "start", "=", "0", "+", "skip", "if", "len", "(", "stack", ")", "<", "start", "+", "1", ":", "return", "'...
Get a name of a caller in the format module.class.method `skip` specifies how many levels of stack to skip while getting caller name. skip=1 means "who calls me", skip=2 "who calls my caller" etc. An empty string is returned if skipped levels exceed stack height Source: https://gist.github.com/techto...
[ "Get", "a", "name", "of", "a", "caller", "in", "the", "format", "module", ".", "class", ".", "method" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/debug.py#L102-L143
train
saltstack/salt
salt/states/nxos_upgrade.py
image_running
def image_running(name, system_image, kickstart_image=None, issu=True, **kwargs): ''' Ensure the NX-OS system image is running on the device. name Name of the salt state task system_image Name of the system image file on bootflash: kickstart_image Name of the kickstart ima...
python
def image_running(name, system_image, kickstart_image=None, issu=True, **kwargs): ''' Ensure the NX-OS system image is running on the device. name Name of the salt state task system_image Name of the system image file on bootflash: kickstart_image Name of the kickstart ima...
[ "def", "image_running", "(", "name", ",", "system_image", ",", "kickstart_image", "=", "None", ",", "issu", "=", "True", ",", "*", "*", "kwargs", ")", ":", "ret", "=", "{", "'name'", ":", "name", ",", "'result'", ":", "False", ",", "'changes'", ":", ...
Ensure the NX-OS system image is running on the device. name Name of the salt state task system_image Name of the system image file on bootflash: kickstart_image Name of the kickstart image file on bootflash: This is not needed if the system_image is a combined system and ...
[ "Ensure", "the", "NX", "-", "OS", "system", "image", "is", "running", "on", "the", "device", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/nxos_upgrade.py#L41-L107
train
saltstack/salt
salt/ext/vsan/vsanapiutils.py
WaitForTasks
def WaitForTasks(tasks, si): """ Given the service instance si and tasks, it returns after all the tasks are complete """ pc = si.content.propertyCollector taskList = [str(task) for task in tasks] # Create filter objSpecs = [vmodl.query.PropertyCollector.ObjectSpec(obj=task) ...
python
def WaitForTasks(tasks, si): """ Given the service instance si and tasks, it returns after all the tasks are complete """ pc = si.content.propertyCollector taskList = [str(task) for task in tasks] # Create filter objSpecs = [vmodl.query.PropertyCollector.ObjectSpec(obj=task) ...
[ "def", "WaitForTasks", "(", "tasks", ",", "si", ")", ":", "pc", "=", "si", ".", "content", ".", "propertyCollector", "taskList", "=", "[", "str", "(", "task", ")", "for", "task", "in", "tasks", "]", "# Create filter", "objSpecs", "=", "[", "vmodl", "."...
Given the service instance si and tasks, it returns after all the tasks are complete
[ "Given", "the", "service", "instance", "si", "and", "tasks", "it", "returns", "after", "all", "the", "tasks", "are", "complete" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/vsan/vsanapiutils.py#L116-L165
train
joke2k/faker
faker/providers/ssn/it_IT/__init__.py
checksum
def checksum(value): """ Calculates the checksum char used for the 16th char. Author: Vincenzo Palazzo """ return chr(65 + sum(CHECKSUM_TABLE[index % 2][ALPHANUMERICS_DICT[char]] for index, char in enumerate(value)) % 26)
python
def checksum(value): """ Calculates the checksum char used for the 16th char. Author: Vincenzo Palazzo """ return chr(65 + sum(CHECKSUM_TABLE[index % 2][ALPHANUMERICS_DICT[char]] for index, char in enumerate(value)) % 26)
[ "def", "checksum", "(", "value", ")", ":", "return", "chr", "(", "65", "+", "sum", "(", "CHECKSUM_TABLE", "[", "index", "%", "2", "]", "[", "ALPHANUMERICS_DICT", "[", "char", "]", "]", "for", "index", ",", "char", "in", "enumerate", "(", "value", ")"...
Calculates the checksum char used for the 16th char. Author: Vincenzo Palazzo
[ "Calculates", "the", "checksum", "char", "used", "for", "the", "16th", "char", ".", "Author", ":", "Vincenzo", "Palazzo" ]
965824b61132e52d92d1a6ce470396dbbe01c96c
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/ssn/it_IT/__init__.py#L18-L24
train
joke2k/faker
faker/providers/misc/__init__.py
Provider.binary
def binary(self, length=(1 * 1024 * 1024)): """ Returns random binary blob. Default blob size is 1 Mb. """ blob = [self.generator.random.randrange(256) for _ in range(length)] return bytes(blob) if sys.version_info[0] >= 3 else bytearray(blob)
python
def binary(self, length=(1 * 1024 * 1024)): """ Returns random binary blob. Default blob size is 1 Mb. """ blob = [self.generator.random.randrange(256) for _ in range(length)] return bytes(blob) if sys.version_info[0] >= 3 else bytearray(blob)
[ "def", "binary", "(", "self", ",", "length", "=", "(", "1", "*", "1024", "*", "1024", ")", ")", ":", "blob", "=", "[", "self", ".", "generator", ".", "random", ".", "randrange", "(", "256", ")", "for", "_", "in", "range", "(", "length", ")", "]...
Returns random binary blob. Default blob size is 1 Mb.
[ "Returns", "random", "binary", "blob", "." ]
965824b61132e52d92d1a6ce470396dbbe01c96c
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/misc/__init__.py#L23-L29
train
joke2k/faker
faker/providers/misc/__init__.py
Provider.md5
def md5(self, raw_output=False): """ Calculates the md5 hash of a given string :example 'cfcd208495d565ef66e7dff9f98764da' """ res = hashlib.md5(str(self.generator.random.random()).encode('utf-8')) if raw_output: return res.digest() return res.hexdiges...
python
def md5(self, raw_output=False): """ Calculates the md5 hash of a given string :example 'cfcd208495d565ef66e7dff9f98764da' """ res = hashlib.md5(str(self.generator.random.random()).encode('utf-8')) if raw_output: return res.digest() return res.hexdiges...
[ "def", "md5", "(", "self", ",", "raw_output", "=", "False", ")", ":", "res", "=", "hashlib", ".", "md5", "(", "str", "(", "self", ".", "generator", ".", "random", ".", "random", "(", ")", ")", ".", "encode", "(", "'utf-8'", ")", ")", "if", "raw_o...
Calculates the md5 hash of a given string :example 'cfcd208495d565ef66e7dff9f98764da'
[ "Calculates", "the", "md5", "hash", "of", "a", "given", "string", ":", "example", "cfcd208495d565ef66e7dff9f98764da" ]
965824b61132e52d92d1a6ce470396dbbe01c96c
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/misc/__init__.py#L31-L39
train
joke2k/faker
faker/providers/misc/__init__.py
Provider.uuid4
def uuid4(self, cast_to=str): """ Generates a random UUID4 string. :param cast_to: Specify what type the UUID should be cast to. Default is `str` :type cast_to: callable """ # Based on http://stackoverflow.com/q/41186818 return cast_to(uuid.UUID(int=self.generator...
python
def uuid4(self, cast_to=str): """ Generates a random UUID4 string. :param cast_to: Specify what type the UUID should be cast to. Default is `str` :type cast_to: callable """ # Based on http://stackoverflow.com/q/41186818 return cast_to(uuid.UUID(int=self.generator...
[ "def", "uuid4", "(", "self", ",", "cast_to", "=", "str", ")", ":", "# Based on http://stackoverflow.com/q/41186818", "return", "cast_to", "(", "uuid", ".", "UUID", "(", "int", "=", "self", ".", "generator", ".", "random", ".", "getrandbits", "(", "128", ")",...
Generates a random UUID4 string. :param cast_to: Specify what type the UUID should be cast to. Default is `str` :type cast_to: callable
[ "Generates", "a", "random", "UUID4", "string", ".", ":", "param", "cast_to", ":", "Specify", "what", "type", "the", "UUID", "should", "be", "cast", "to", ".", "Default", "is", "str", ":", "type", "cast_to", ":", "callable" ]
965824b61132e52d92d1a6ce470396dbbe01c96c
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/misc/__init__.py#L62-L69
train
joke2k/faker
faker/providers/misc/__init__.py
Provider.password
def password( self, length=10, special_chars=True, digits=True, upper_case=True, lower_case=True): """ Generates a random password. @param length: Integer. Length of a password @param special_chars: Boolean. Whether ...
python
def password( self, length=10, special_chars=True, digits=True, upper_case=True, lower_case=True): """ Generates a random password. @param length: Integer. Length of a password @param special_chars: Boolean. Whether ...
[ "def", "password", "(", "self", ",", "length", "=", "10", ",", "special_chars", "=", "True", ",", "digits", "=", "True", ",", "upper_case", "=", "True", ",", "lower_case", "=", "True", ")", ":", "choices", "=", "\"\"", "required_tokens", "=", "[", "]",...
Generates a random password. @param length: Integer. Length of a password @param special_chars: Boolean. Whether to use special characters !@#$%^&*()_+ @param digits: Boolean. Whether to use digits @param upper_case: Boolean. Whether to use upper letters @param lower_case: Boolea...
[ "Generates", "a", "random", "password", "." ]
965824b61132e52d92d1a6ce470396dbbe01c96c
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/misc/__init__.py#L71-L121
train
joke2k/faker
faker/providers/person/pl_PL/__init__.py
checksum_identity_card_number
def checksum_identity_card_number(characters): """ Calculates and returns a control digit for given list of characters basing on Identity Card Number standards. """ weights_for_check_digit = [7, 3, 1, 0, 7, 3, 1, 7, 3] check_digit = 0 for i in range(3): check_digit += weights_for_check_...
python
def checksum_identity_card_number(characters): """ Calculates and returns a control digit for given list of characters basing on Identity Card Number standards. """ weights_for_check_digit = [7, 3, 1, 0, 7, 3, 1, 7, 3] check_digit = 0 for i in range(3): check_digit += weights_for_check_...
[ "def", "checksum_identity_card_number", "(", "characters", ")", ":", "weights_for_check_digit", "=", "[", "7", ",", "3", ",", "1", ",", "0", ",", "7", ",", "3", ",", "1", ",", "7", ",", "3", "]", "check_digit", "=", "0", "for", "i", "in", "range", ...
Calculates and returns a control digit for given list of characters basing on Identity Card Number standards.
[ "Calculates", "and", "returns", "a", "control", "digit", "for", "given", "list", "of", "characters", "basing", "on", "Identity", "Card", "Number", "standards", "." ]
965824b61132e52d92d1a6ce470396dbbe01c96c
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/person/pl_PL/__init__.py#L6-L21
train
joke2k/faker
faker/providers/person/pl_PL/__init__.py
Provider.identity_card_number
def identity_card_number(self): """ Returns 9 character Polish Identity Card Number, Polish: Numer Dowodu Osobistego. The card number consists of 3 letters followed by 6 digits (for example, ABA300000), of which the first digit (at position 3) is the check digit. https:...
python
def identity_card_number(self): """ Returns 9 character Polish Identity Card Number, Polish: Numer Dowodu Osobistego. The card number consists of 3 letters followed by 6 digits (for example, ABA300000), of which the first digit (at position 3) is the check digit. https:...
[ "def", "identity_card_number", "(", "self", ")", ":", "identity", "=", "[", "]", "for", "_", "in", "range", "(", "3", ")", ":", "identity", ".", "append", "(", "self", ".", "random_letter", "(", ")", ".", "upper", "(", ")", ")", "# it will be overwritt...
Returns 9 character Polish Identity Card Number, Polish: Numer Dowodu Osobistego. The card number consists of 3 letters followed by 6 digits (for example, ABA300000), of which the first digit (at position 3) is the check digit. https://en.wikipedia.org/wiki/Polish_identity_card
[ "Returns", "9", "character", "Polish", "Identity", "Card", "Number", "Polish", ":", "Numer", "Dowodu", "Osobistego", "." ]
965824b61132e52d92d1a6ce470396dbbe01c96c
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/person/pl_PL/__init__.py#L681-L704
train
joke2k/faker
faker/cli.py
execute_from_command_line
def execute_from_command_line(argv=None): """A simple method that runs a Command.""" if sys.stdout.encoding is None: print('please set python env PYTHONIOENCODING=UTF-8, example: ' 'export PYTHONIOENCODING=UTF-8, when writing to stdout', file=sys.stderr) exit(1) ...
python
def execute_from_command_line(argv=None): """A simple method that runs a Command.""" if sys.stdout.encoding is None: print('please set python env PYTHONIOENCODING=UTF-8, example: ' 'export PYTHONIOENCODING=UTF-8, when writing to stdout', file=sys.stderr) exit(1) ...
[ "def", "execute_from_command_line", "(", "argv", "=", "None", ")", ":", "if", "sys", ".", "stdout", ".", "encoding", "is", "None", ":", "print", "(", "'please set python env PYTHONIOENCODING=UTF-8, example: '", "'export PYTHONIOENCODING=UTF-8, when writing to stdout'", ",",...
A simple method that runs a Command.
[ "A", "simple", "method", "that", "runs", "a", "Command", "." ]
965824b61132e52d92d1a6ce470396dbbe01c96c
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/cli.py#L267-L276
train
joke2k/faker
faker/cli.py
Command.execute
def execute(self): """ Given the command-line arguments, this creates a parser appropriate to that command, and runs it. """ # retrieve default language from system environment default_locale = os.environ.get('LANG', 'en_US').split('.')[0] if default_locale not i...
python
def execute(self): """ Given the command-line arguments, this creates a parser appropriate to that command, and runs it. """ # retrieve default language from system environment default_locale = os.environ.get('LANG', 'en_US').split('.')[0] if default_locale not i...
[ "def", "execute", "(", "self", ")", ":", "# retrieve default language from system environment", "default_locale", "=", "os", ".", "environ", ".", "get", "(", "'LANG'", ",", "'en_US'", ")", ".", "split", "(", "'.'", ")", "[", "0", "]", "if", "default_locale", ...
Given the command-line arguments, this creates a parser appropriate to that command, and runs it.
[ "Given", "the", "command", "-", "line", "arguments", "this", "creates", "a", "parser", "appropriate", "to", "that", "command", "and", "runs", "it", "." ]
965824b61132e52d92d1a6ce470396dbbe01c96c
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/cli.py#L127-L264
train
joke2k/faker
faker/providers/isbn/isbn.py
ISBN13._check_digit
def _check_digit(self): """ Calculate the check digit for ISBN-13. See https://en.wikipedia.org/wiki/International_Standard_Book_Number for calculation. """ weights = (1 if x % 2 == 0 else 3 for x in range(12)) body = ''.join([self.ean, self.group, self.registrant, ...
python
def _check_digit(self): """ Calculate the check digit for ISBN-13. See https://en.wikipedia.org/wiki/International_Standard_Book_Number for calculation. """ weights = (1 if x % 2 == 0 else 3 for x in range(12)) body = ''.join([self.ean, self.group, self.registrant, ...
[ "def", "_check_digit", "(", "self", ")", ":", "weights", "=", "(", "1", "if", "x", "%", "2", "==", "0", "else", "3", "for", "x", "in", "range", "(", "12", ")", ")", "body", "=", "''", ".", "join", "(", "[", "self", ".", "ean", ",", "self", ...
Calculate the check digit for ISBN-13. See https://en.wikipedia.org/wiki/International_Standard_Book_Number for calculation.
[ "Calculate", "the", "check", "digit", "for", "ISBN", "-", "13", ".", "See", "https", ":", "//", "en", ".", "wikipedia", ".", "org", "/", "wiki", "/", "International_Standard_Book_Number", "for", "calculation", "." ]
965824b61132e52d92d1a6ce470396dbbe01c96c
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/isbn/isbn.py#L25-L36
train
joke2k/faker
faker/providers/company/fr_FR/__init__.py
Provider._is_catch_phrase_valid
def _is_catch_phrase_valid(self, catch_phrase): """ Validates a french catch phrase. :param catch_phrase: The catch phrase to validate. """ for word in self.words_which_should_not_appear_twice: # Fastest way to check if a piece of word does not appear twice. ...
python
def _is_catch_phrase_valid(self, catch_phrase): """ Validates a french catch phrase. :param catch_phrase: The catch phrase to validate. """ for word in self.words_which_should_not_appear_twice: # Fastest way to check if a piece of word does not appear twice. ...
[ "def", "_is_catch_phrase_valid", "(", "self", ",", "catch_phrase", ")", ":", "for", "word", "in", "self", ".", "words_which_should_not_appear_twice", ":", "# Fastest way to check if a piece of word does not appear twice.", "begin_pos", "=", "catch_phrase", ".", "find", "(",...
Validates a french catch phrase. :param catch_phrase: The catch phrase to validate.
[ "Validates", "a", "french", "catch", "phrase", "." ]
965824b61132e52d92d1a6ce470396dbbe01c96c
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/company/fr_FR/__init__.py#L97-L111
train
joke2k/faker
faker/providers/company/fr_FR/__init__.py
Provider.siret
def siret(self, max_sequential_digits=2): """ Generates a siret number (14 digits). It is in fact the result of the concatenation of a siren number (9 digits), a sequential number (4 digits) and a control number (1 digit) concatenation. If $max_sequential_digits is invalid, it is...
python
def siret(self, max_sequential_digits=2): """ Generates a siret number (14 digits). It is in fact the result of the concatenation of a siren number (9 digits), a sequential number (4 digits) and a control number (1 digit) concatenation. If $max_sequential_digits is invalid, it is...
[ "def", "siret", "(", "self", ",", "max_sequential_digits", "=", "2", ")", ":", "if", "max_sequential_digits", ">", "4", "or", "max_sequential_digits", "<=", "0", ":", "max_sequential_digits", "=", "2", "sequential_number", "=", "str", "(", "self", ".", "random...
Generates a siret number (14 digits). It is in fact the result of the concatenation of a siren number (9 digits), a sequential number (4 digits) and a control number (1 digit) concatenation. If $max_sequential_digits is invalid, it is set to 2. :param max_sequential_digits The maximum nu...
[ "Generates", "a", "siret", "number", "(", "14", "digits", ")", ".", "It", "is", "in", "fact", "the", "result", "of", "the", "concatenation", "of", "a", "siren", "number", "(", "9", "digits", ")", "a", "sequential", "number", "(", "4", "digits", ")", ...
965824b61132e52d92d1a6ce470396dbbe01c96c
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/company/fr_FR/__init__.py#L119-L132
train
joke2k/faker
faker/providers/internet/el_GR/__init__.py
remove_accents
def remove_accents(value): """ Remove accents from characters in the given string. """ search = 'ΆΈΉΊΌΎΏάέήίόύώΪϊΐϋΰ' replace = 'ΑΕΗΙΟΥΩαεηιουωΙιιυυ' def replace_accented_character(match): matched = match.group(0) if matched in search: return replace[search.find(matc...
python
def remove_accents(value): """ Remove accents from characters in the given string. """ search = 'ΆΈΉΊΌΎΏάέήίόύώΪϊΐϋΰ' replace = 'ΑΕΗΙΟΥΩαεηιουωΙιιυυ' def replace_accented_character(match): matched = match.group(0) if matched in search: return replace[search.find(matc...
[ "def", "remove_accents", "(", "value", ")", ":", "search", "=", "'ΆΈΉΊΌΎΏάέήίόύώΪϊΐϋΰ'", "replace", "=", "'ΑΕΗΙΟΥΩαεηιουωΙιιυυ'", "def", "replace_accented_character", "(", "match", ")", ":", "matched", "=", "match", ".", "group", "(", "0", ")", "if", "matched", ...
Remove accents from characters in the given string.
[ "Remove", "accents", "from", "characters", "in", "the", "given", "string", "." ]
965824b61132e52d92d1a6ce470396dbbe01c96c
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/internet/el_GR/__init__.py#L32-L45
train
joke2k/faker
faker/providers/internet/el_GR/__init__.py
latinize
def latinize(value): """ Converts (transliterates) greek letters to latin equivalents. """ def replace_double_character(match): search = ('Θ Χ Ψ ' 'θ χ ψ ' 'ΟΥ ΑΥ ΕΥ ' 'Ου Αυ Ευ ' 'ου αυ ευ').split() replace = ('TH C...
python
def latinize(value): """ Converts (transliterates) greek letters to latin equivalents. """ def replace_double_character(match): search = ('Θ Χ Ψ ' 'θ χ ψ ' 'ΟΥ ΑΥ ΕΥ ' 'Ου Αυ Ευ ' 'ου αυ ευ').split() replace = ('TH C...
[ "def", "latinize", "(", "value", ")", ":", "def", "replace_double_character", "(", "match", ")", ":", "search", "=", "(", "'Θ Χ Ψ '", "'θ χ ψ '", "'ΟΥ ΑΥ ΕΥ '", "'Ου Αυ Ευ '", "'ου αυ ευ').spli", "t", "(", ")", "", "", "replace", "=", "(", "'TH CH PS '", "'t...
Converts (transliterates) greek letters to latin equivalents.
[ "Converts", "(", "transliterates", ")", "greek", "letters", "to", "latin", "equivalents", "." ]
965824b61132e52d92d1a6ce470396dbbe01c96c
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/internet/el_GR/__init__.py#L48-L80
train
joke2k/faker
faker/providers/ssn/he_IL/__init__.py
Provider.ssn
def ssn(self): """ Returns an Israeli identity number, known as Teudat Zehut ("tz"). https://en.wikipedia.org/wiki/Israeli_identity_card """ newID = str(self.generator.random.randrange(111111, 99999999)) newID = newID.zfill(8) theSum = 0 indexRange = [0,...
python
def ssn(self): """ Returns an Israeli identity number, known as Teudat Zehut ("tz"). https://en.wikipedia.org/wiki/Israeli_identity_card """ newID = str(self.generator.random.randrange(111111, 99999999)) newID = newID.zfill(8) theSum = 0 indexRange = [0,...
[ "def", "ssn", "(", "self", ")", ":", "newID", "=", "str", "(", "self", ".", "generator", ".", "random", ".", "randrange", "(", "111111", ",", "99999999", ")", ")", "newID", "=", "newID", ".", "zfill", "(", "8", ")", "theSum", "=", "0", "indexRange"...
Returns an Israeli identity number, known as Teudat Zehut ("tz"). https://en.wikipedia.org/wiki/Israeli_identity_card
[ "Returns", "an", "Israeli", "identity", "number", "known", "as", "Teudat", "Zehut", "(", "tz", ")", "." ]
965824b61132e52d92d1a6ce470396dbbe01c96c
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/ssn/he_IL/__init__.py#L9-L32
train
joke2k/faker
faker/providers/lorem/__init__.py
Provider.words
def words(self, nb=3, ext_word_list=None, unique=False): """ :returns: An array of random words. for example: ['Lorem', 'ipsum', 'dolor'] Keyword arguments: :param nb: how many words to return :param ext_word_list: a list of words you would like to have instead of 'L...
python
def words(self, nb=3, ext_word_list=None, unique=False): """ :returns: An array of random words. for example: ['Lorem', 'ipsum', 'dolor'] Keyword arguments: :param nb: how many words to return :param ext_word_list: a list of words you would like to have instead of 'L...
[ "def", "words", "(", "self", ",", "nb", "=", "3", ",", "ext_word_list", "=", "None", ",", "unique", "=", "False", ")", ":", "word_list", "=", "ext_word_list", "if", "ext_word_list", "else", "self", ".", "word_list", "if", "unique", ":", "return", "self",...
:returns: An array of random words. for example: ['Lorem', 'ipsum', 'dolor'] Keyword arguments: :param nb: how many words to return :param ext_word_list: a list of words you would like to have instead of 'Lorem ipsum' :param unique: If True, the returned word list will conta...
[ ":", "returns", ":", "An", "array", "of", "random", "words", ".", "for", "example", ":", "[", "Lorem", "ipsum", "dolor", "]" ]
965824b61132e52d92d1a6ce470396dbbe01c96c
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/lorem/__init__.py#L28-L43
train
joke2k/faker
faker/providers/lorem/__init__.py
Provider.sentence
def sentence(self, nb_words=6, variable_nb_words=True, ext_word_list=None): """ Generate a random sentence :example 'Lorem ipsum dolor sit amet.' :param nb_words: around how many words the sentence should contain :param variable_nb_words: set to false if you want exactly ``nb`` ...
python
def sentence(self, nb_words=6, variable_nb_words=True, ext_word_list=None): """ Generate a random sentence :example 'Lorem ipsum dolor sit amet.' :param nb_words: around how many words the sentence should contain :param variable_nb_words: set to false if you want exactly ``nb`` ...
[ "def", "sentence", "(", "self", ",", "nb_words", "=", "6", ",", "variable_nb_words", "=", "True", ",", "ext_word_list", "=", "None", ")", ":", "if", "nb_words", "<=", "0", ":", "return", "''", "if", "variable_nb_words", ":", "nb_words", "=", "self", ".",...
Generate a random sentence :example 'Lorem ipsum dolor sit amet.' :param nb_words: around how many words the sentence should contain :param variable_nb_words: set to false if you want exactly ``nb`` words returned, otherwise the result may include a number of words of ``...
[ "Generate", "a", "random", "sentence", ":", "example", "Lorem", "ipsum", "dolor", "sit", "amet", "." ]
965824b61132e52d92d1a6ce470396dbbe01c96c
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/lorem/__init__.py#L56-L79
train
joke2k/faker
faker/providers/lorem/__init__.py
Provider.sentences
def sentences(self, nb=3, ext_word_list=None): """ Generate an array of sentences :example ['Lorem ipsum dolor sit amet.', 'Consectetur adipisicing eli.'] Keyword arguments: :param nb: how many sentences to return :param ext_word_list: a list of words you would like to h...
python
def sentences(self, nb=3, ext_word_list=None): """ Generate an array of sentences :example ['Lorem ipsum dolor sit amet.', 'Consectetur adipisicing eli.'] Keyword arguments: :param nb: how many sentences to return :param ext_word_list: a list of words you would like to h...
[ "def", "sentences", "(", "self", ",", "nb", "=", "3", ",", "ext_word_list", "=", "None", ")", ":", "return", "[", "self", ".", "sentence", "(", "ext_word_list", "=", "ext_word_list", ")", "for", "_", "in", "range", "(", "0", ",", "nb", ")", "]" ]
Generate an array of sentences :example ['Lorem ipsum dolor sit amet.', 'Consectetur adipisicing eli.'] Keyword arguments: :param nb: how many sentences to return :param ext_word_list: a list of words you would like to have instead of 'Lorem ipsum'. :rtype: list
[ "Generate", "an", "array", "of", "sentences", ":", "example", "[", "Lorem", "ipsum", "dolor", "sit", "amet", ".", "Consectetur", "adipisicing", "eli", ".", "]" ]
965824b61132e52d92d1a6ce470396dbbe01c96c
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/lorem/__init__.py#L81-L94
train
joke2k/faker
faker/providers/lorem/__init__.py
Provider.paragraph
def paragraph( self, nb_sentences=3, variable_nb_sentences=True, ext_word_list=None): """ :returns: A single paragraph. For example: 'Sapiente sunt omnis. Ut pariatur ad autem ducimus et. Voluptas rem voluptas sint modi dolorem amet.' ...
python
def paragraph( self, nb_sentences=3, variable_nb_sentences=True, ext_word_list=None): """ :returns: A single paragraph. For example: 'Sapiente sunt omnis. Ut pariatur ad autem ducimus et. Voluptas rem voluptas sint modi dolorem amet.' ...
[ "def", "paragraph", "(", "self", ",", "nb_sentences", "=", "3", ",", "variable_nb_sentences", "=", "True", ",", "ext_word_list", "=", "None", ")", ":", "if", "nb_sentences", "<=", "0", ":", "return", "''", "if", "variable_nb_sentences", ":", "nb_sentences", ...
:returns: A single paragraph. For example: 'Sapiente sunt omnis. Ut pariatur ad autem ducimus et. Voluptas rem voluptas sint modi dolorem amet.' Keyword arguments: :param nb_sentences: around how many sentences the paragraph should contain :param variable_nb_sentences: set to false ...
[ ":", "returns", ":", "A", "single", "paragraph", ".", "For", "example", ":", "Sapiente", "sunt", "omnis", ".", "Ut", "pariatur", "ad", "autem", "ducimus", "et", ".", "Voluptas", "rem", "voluptas", "sint", "modi", "dolorem", "amet", "." ]
965824b61132e52d92d1a6ce470396dbbe01c96c
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/lorem/__init__.py#L96-L125
train
joke2k/faker
faker/providers/lorem/__init__.py
Provider.paragraphs
def paragraphs(self, nb=3, ext_word_list=None): """ Generate an array of paragraphs :example [paragraph1, paragraph2, paragraph3] :param nb: how many paragraphs to return :param ext_word_list: a list of words you would like to have instead of 'Lorem ipsum'. :...
python
def paragraphs(self, nb=3, ext_word_list=None): """ Generate an array of paragraphs :example [paragraph1, paragraph2, paragraph3] :param nb: how many paragraphs to return :param ext_word_list: a list of words you would like to have instead of 'Lorem ipsum'. :...
[ "def", "paragraphs", "(", "self", ",", "nb", "=", "3", ",", "ext_word_list", "=", "None", ")", ":", "return", "[", "self", ".", "paragraph", "(", "ext_word_list", "=", "ext_word_list", ")", "for", "_", "in", "range", "(", "0", ",", "nb", ")", "]" ]
Generate an array of paragraphs :example [paragraph1, paragraph2, paragraph3] :param nb: how many paragraphs to return :param ext_word_list: a list of words you would like to have instead of 'Lorem ipsum'. :rtype: list
[ "Generate", "an", "array", "of", "paragraphs", ":", "example", "[", "paragraph1", "paragraph2", "paragraph3", "]", ":", "param", "nb", ":", "how", "many", "paragraphs", "to", "return", ":", "param", "ext_word_list", ":", "a", "list", "of", "words", "you", ...
965824b61132e52d92d1a6ce470396dbbe01c96c
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/lorem/__init__.py#L127-L139
train
joke2k/faker
faker/providers/lorem/__init__.py
Provider.text
def text(self, max_nb_chars=200, ext_word_list=None): """ Generate a text string. Depending on the ``max_nb_chars, returns a string made of words, sentences, or paragraphs. :example 'Sapiente sunt omnis. Ut pariatur ad autem ducimus et. Voluptas rem voluptas sint modi dolorem amet.' ...
python
def text(self, max_nb_chars=200, ext_word_list=None): """ Generate a text string. Depending on the ``max_nb_chars, returns a string made of words, sentences, or paragraphs. :example 'Sapiente sunt omnis. Ut pariatur ad autem ducimus et. Voluptas rem voluptas sint modi dolorem amet.' ...
[ "def", "text", "(", "self", ",", "max_nb_chars", "=", "200", ",", "ext_word_list", "=", "None", ")", ":", "text", "=", "[", "]", "if", "max_nb_chars", "<", "5", ":", "raise", "ValueError", "(", "'text() can only generate text of at least 5 characters'", ")", "...
Generate a text string. Depending on the ``max_nb_chars, returns a string made of words, sentences, or paragraphs. :example 'Sapiente sunt omnis. Ut pariatur ad autem ducimus et. Voluptas rem voluptas sint modi dolorem amet.' Keyword arguments: :param max_nb_chars: Maximum number of cha...
[ "Generate", "a", "text", "string", ".", "Depending", "on", "the", "max_nb_chars", "returns", "a", "string", "made", "of", "words", "sentences", "or", "paragraphs", ".", ":", "example", "Sapiente", "sunt", "omnis", ".", "Ut", "pariatur", "ad", "autem", "ducim...
965824b61132e52d92d1a6ce470396dbbe01c96c
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/lorem/__init__.py#L141-L198
train
joke2k/faker
faker/providers/address/__init__.py
Provider.city
def city(self): """ :example 'Sashabury' """ pattern = self.random_element(self.city_formats) return self.generator.parse(pattern)
python
def city(self): """ :example 'Sashabury' """ pattern = self.random_element(self.city_formats) return self.generator.parse(pattern)
[ "def", "city", "(", "self", ")", ":", "pattern", "=", "self", ".", "random_element", "(", "self", ".", "city_formats", ")", "return", "self", ".", "generator", ".", "parse", "(", "pattern", ")" ]
:example 'Sashabury'
[ ":", "example", "Sashabury" ]
965824b61132e52d92d1a6ce470396dbbe01c96c
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/address/__init__.py#L45-L50
train