partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
returner
Return data to a postgres server
salt/returners/postgres_local_cache.py
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): ''' 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...
[ "Return", "data", "to", "a", "postgres", "server" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/postgres_local_cache.py#L224-L253
[ "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 ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
event_return
Return event to a postgres server Require that configuration be enabled via 'event_return' option in master config.
salt/returners/postgres_local_cache.py
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): ''' 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', '') ...
[ "Return", "event", "to", "a", "postgres", "server" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/postgres_local_cache.py#L256-L274
[ "def", "event_return", "(", "events", ")", ":", "conn", "=", "_get_conn", "(", ")", "if", "conn", "is", "None", ":", "return", "None", "cur", "=", "conn", ".", "cursor", "(", ")", "for", "event", "in", "events", ":", "tag", "=", "event", ".", "get"...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
save_load
Save the load to the specified jid id
salt/returners/postgres_local_cache.py
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): ''' 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...
[ "Save", "the", "load", "to", "the", "specified", "jid", "id" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/postgres_local_cache.py#L277-L306
[ "def", "save_load", "(", "jid", ",", "clear_load", ",", "minions", "=", "None", ")", ":", "jid", "=", "_escape_jid", "(", "jid", ")", "conn", "=", "_get_conn", "(", ")", "if", "conn", "is", "None", ":", "return", "None", "cur", "=", "conn", ".", "c...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_escape_jid
Do proper formatting of the jid
salt/returners/postgres_local_cache.py
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): ''' Do proper formatting of the jid ''' jid = six.text_type(jid) jid = re.sub(r"'*", "", jid) return jid
[ "Do", "proper", "formatting", "of", "the", "jid" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/postgres_local_cache.py#L316-L322
[ "def", "_escape_jid", "(", "jid", ")", ":", "jid", "=", "six", ".", "text_type", "(", "jid", ")", "jid", "=", "re", ".", "sub", "(", "r\"'*\"", ",", "\"\"", ",", "jid", ")", "return", "jid" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_build_dict
Rebuild dict
salt/returners/postgres_local_cache.py
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): ''' 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...
[ "Rebuild", "dict" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/postgres_local_cache.py#L325-L340
[ "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...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
get_load
Return the load data that marks a specified jid
salt/returners/postgres_local_cache.py
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): ''' 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 = ...
[ "Return", "the", "load", "data", "that", "marks", "a", "specified", "jid" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/postgres_local_cache.py#L343-L359
[ "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...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
get_jid
Return the information returned when the specified job id was executed
salt/returners/postgres_local_cache.py
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): ''' 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,))...
[ "Return", "the", "information", "returned", "when", "the", "specified", "job", "id", "was", "executed" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/postgres_local_cache.py#L362-L385
[ "def", "get_jid", "(", "jid", ")", ":", "jid", "=", "_escape_jid", "(", "jid", ")", "conn", "=", "_get_conn", "(", ")", "if", "conn", "is", "None", ":", "return", "None", "cur", "=", "conn", ".", "cursor", "(", ")", "sql", "=", "'''SELECT id, return ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
get_jids
Return a list of all job ids For master job cache this also formats the output and returns a string
salt/returners/postgres_local_cache.py
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(): ''' 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...
[ "Return", "a", "list", "of", "all", "job", "ids", "For", "master", "job", "cache", "this", "also", "formats", "the", "output", "and", "returns", "a", "string" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/postgres_local_cache.py#L388-L412
[ "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'"...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
login_failures
Query for all accounts which have 3 or more login failures. CLI Example: .. code-block:: bash salt <minion_id> shadow.login_failures ALL
salt/modules/aix_shadow.py
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): ''' 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...
[ "Query", "for", "all", "accounts", "which", "have", "3", "or", "more", "login", "failures", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/aix_shadow.py#L32-L54
[ "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'", "]", "(",...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
unlock
Unlock user for locked account CLI Example: .. code-block:: bash salt <minion_id> shadow.unlock user
salt/modules/aix_shadow.py
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): ''' 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_...
[ "Unlock", "user", "for", "locked", "account" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/aix_shadow.py#L81-L96
[ "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", ",", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
create_alert
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. ...
salt/states/opsgenie.py
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"): ''' 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...
[ "Create", "an", "alert", "in", "OpsGenie", ".", "Example", "usage", "with", "Salt", "s", "requisites", "and", "other", "global", "state", "arguments", "could", "be", "found", "above", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/opsgenie.py#L46-L119
[ "def", "create_alert", "(", "name", "=", "None", ",", "api_key", "=", "None", ",", "reason", "=", "None", ",", "action_type", "=", "\"Create\"", ")", ":", "_", ",", "_", ",", "_", ",", "values", "=", "inspect", ".", "getargvalues", "(", "inspect", "....
e8541fd6e744ab0df786c0f76102e41631f45d46
train
close_alert
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...
salt/states/opsgenie.py
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"): ''' 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: ...
[ "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", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/opsgenie.py#L122-L153
[ "def", "close_alert", "(", "name", "=", "None", ",", "api_key", "=", "None", ",", "reason", "=", "\"Conditions are met.\"", ",", "action_type", "=", "\"Close\"", ")", ":", "if", "name", "is", "None", ":", "raise", "salt", ".", "exceptions", ".", "SaltInvoc...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_expand_probes
Updates the probes dictionary with different levels of default values.
salt/states/probes.py
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): ''' 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] = {} ...
[ "Updates", "the", "probes", "dictionary", "with", "different", "levels", "of", "default", "values", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/probes.py#L84-L105
[ "def", "_expand_probes", "(", "probes", ",", "defaults", ")", ":", "expected_probes", "=", "{", "}", "for", "probe_name", ",", "probe_test", "in", "six", ".", "iteritems", "(", "probes", ")", ":", "if", "probe_name", "not", "in", "expected_probes", ".", "k...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_clean_probes
Will remove empty and useless values from the probes dictionary.
salt/states/probes.py
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): ''' 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...
[ "Will", "remove", "empty", "and", "useless", "values", "from", "the", "probes", "dictionary", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/probes.py#L108-L126
[ "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", "...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_compare_probes
Compares configured probes on the device with the expected configuration and returns the differences.
salt/states/probes.py
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): ''' 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...
[ "Compares", "configured", "probes", "on", "the", "device", "with", "the", "expected", "configuration", "and", "returns", "the", "differences", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/probes.py#L129-L201
[ "def", "_compare_probes", "(", "configured_probes", ",", "expected_probes", ")", ":", "new_probes", "=", "{", "}", "update_probes", "=", "{", "}", "remove_probes", "=", "{", "}", "# noth configured => configure with expected probes", "if", "not", "configured_probes", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
managed
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...
salt/states/probes.py
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): ''' 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 ...
[ "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",...
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/probes.py#L252-L454
[ "def", "managed", "(", "name", ",", "probes", ",", "defaults", "=", "None", ")", ":", "ret", "=", "_default_ret", "(", "name", ")", "result", "=", "True", "comment", "=", "''", "rpm_probes_config", "=", "_retrieve_rpm_probes", "(", ")", "# retrieves the RPM ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
returner
Send an email with the data
salt/returners/smtp_return.py
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): ''' 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')...
[ "Send", "an", "email", "with", "the", "data" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/smtp_return.py#L163-L260
[ "def", "returner", "(", "ret", ")", ":", "_options", "=", "_get_options", "(", "ret", ")", "from_addr", "=", "_options", ".", "get", "(", "'from'", ")", "to_addrs", "=", "_options", ".", "get", "(", "'to'", ")", ".", "split", "(", "','", ")", "host",...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
event_return
Return event data via SMTP
salt/returners/smtp_return.py
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): ''' Return event data via SMTP ''' for event in events: ret = event.get('data', False) if ret: returner(ret)
[ "Return", "event", "data", "via", "SMTP" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/smtp_return.py#L270-L279
[ "def", "event_return", "(", "events", ")", ":", "for", "event", "in", "events", ":", "ret", "=", "event", ".", "get", "(", "'data'", ",", "False", ")", "if", "ret", ":", "returner", "(", "ret", ")" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_render_tab
Takes a tab list structure and renders it to a list for applying it to a file
salt/modules/incron.py
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): ''' 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'], ...
[ "Takes", "a", "tab", "list", "structure", "and", "renders", "it", "to", "a", "list", "for", "applying", "it", "to", "a", "file" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/incron.py#L47-L62
[ "def", "_render_tab", "(", "lst", ")", ":", "ret", "=", "[", "]", "for", "pre", "in", "lst", "[", "'pre'", "]", ":", "ret", ".", "append", "(", "'{0}\\n'", ".", "format", "(", "pre", ")", ")", "for", "cron", "in", "lst", "[", "'crons'", "]", ":...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
write_incron_file
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
salt/modules/incron.py
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): ''' 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
[ "Writes", "the", "contents", "of", "a", "file", "to", "a", "user", "s", "incrontab" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/incron.py#L72-L82
[ "def", "write_incron_file", "(", "user", ",", "path", ")", ":", "return", "__salt__", "[", "'cmd.retcode'", "]", "(", "_get_incron_cmdstr", "(", "path", ")", ",", "runas", "=", "user", ",", "python_shell", "=", "False", ")", "==", "0" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
train
write_incron_file_verbose
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
salt/modules/incron.py
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): ''' 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...
[ "Writes", "the", "contents", "of", "a", "file", "to", "a", "user", "s", "incrontab", "and", "return", "error", "message", "on", "error" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/incron.py#L85-L95
[ "def", "write_incron_file_verbose", "(", "user", ",", "path", ")", ":", "return", "__salt__", "[", "'cmd.run_all'", "]", "(", "_get_incron_cmdstr", "(", "path", ")", ",", "runas", "=", "user", ",", "python_shell", "=", "False", ")" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_write_incron_lines
Takes a list of lines to be committed to a user's incrontab and writes it
salt/modules/incron.py
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): ''' 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...
[ "Takes", "a", "list", "of", "lines", "to", "be", "committed", "to", "a", "user", "s", "incrontab", "and", "writes", "it" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/incron.py#L98-L114
[ "def", "_write_incron_lines", "(", "user", ",", "lines", ")", ":", "if", "user", "==", "'system'", ":", "ret", "=", "{", "}", "ret", "[", "'retcode'", "]", "=", "_write_file", "(", "_INCRON_SYSTEM_TAB", ",", "'salt'", ",", "''", ".", "join", "(", "line...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_write_file
Writes a file to disk
salt/modules/incron.py
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): ''' 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...
[ "Writes", "a", "file", "to", "disk" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/incron.py#L117-L129
[ "def", "_write_file", "(", "folder", ",", "filename", ",", "data", ")", ":", "path", "=", "os", ".", "path", ".", "join", "(", "folder", ",", "filename", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "folder", ")", ":", "msg", "=", "'{...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_read_file
Reads and returns the contents of a file
salt/modules/incron.py
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): ''' 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 ''
[ "Reads", "and", "returns", "the", "contents", "of", "a", "file" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/incron.py#L132-L141
[ "def", "_read_file", "(", "folder", ",", "filename", ")", ":", "path", "=", "os", ".", "path", ".", "join", "(", "folder", ",", "filename", ")", "try", ":", "with", "salt", ".", "utils", ".", "files", ".", "fopen", "(", "path", ",", "'rb'", ")", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
raw_incron
Return the contents of the user's incrontab CLI Example: .. code-block:: bash salt '*' incron.raw_incron root
salt/modules/incron.py
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): ''' 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)...
[ "Return", "the", "contents", "of", "the", "user", "s", "incrontab" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/incron.py#L159-L173
[ "def", "raw_incron", "(", "user", ")", ":", "if", "__grains__", "[", "'os_family'", "]", "==", "'Solaris'", ":", "cmd", "=", "'incrontab -l {0}'", ".", "format", "(", "user", ")", "else", ":", "cmd", "=", "'incrontab -l -u {0}'", ".", "format", "(", "user"...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
list_tab
Return the contents of the specified user's incrontab CLI Example: .. code-block:: bash salt '*' incron.list_tab root
salt/modules/incron.py
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): ''' 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', ...
[ "Return", "the", "contents", "of", "the", "specified", "user", "s", "incrontab" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/incron.py#L176-L214
[ "def", "list_tab", "(", "user", ")", ":", "if", "user", "==", "'system'", ":", "data", "=", "raw_system_incron", "(", ")", "else", ":", "data", "=", "raw_incron", "(", "user", ")", "log", ".", "debug", "(", "'incron user data %s'", ",", "data", ")", "r...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
set_job
Sets an incron job up for a specified user. CLI Example: .. code-block:: bash salt '*' incron.set_job root '/root' 'IN_MODIFY' 'echo "$$ $@ $# $% $&"'
salt/modules/incron.py
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): ''' 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...
[ "Sets", "an", "incron", "job", "up", "for", "a", "specified", "user", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/incron.py#L221-L276
[ "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",...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
rm_job
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
salt/modules/incron.py
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): ''' 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", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/incron.py#L279-L320
[ "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", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
start
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 ...
salt/engines/ircbot.py
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='!', 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...
[ "IRC", "Bot", "for", "interacting", "with", "salt", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/engines/ircbot.py#L225-L285
[ "def", "start", "(", "nick", ",", "host", ",", "port", "=", "6667", ",", "username", "=", "None", ",", "password", "=", "None", ",", "channels", "=", "None", ",", "use_ssl", "=", "False", ",", "use_sasl", "=", "False", ",", "char", "=", "'!'", ",",...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
check_mod_enabled
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
salt/modules/suse_apache.py
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): ''' 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...
[ "Checks", "to", "see", "if", "the", "specific", "apache", "mod", "is", "enabled", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/suse_apache.py#L31-L55
[ "def", "check_mod_enabled", "(", "mod", ")", ":", "if", "mod", ".", "endswith", "(", "'.load'", ")", "or", "mod", ".", "endswith", "(", "'.conf'", ")", ":", "mod_name", "=", "mod", "[", ":", "-", "5", "]", "else", ":", "mod_name", "=", "mod", "cmd"...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
create_alias
Create a display name for a key. CLI example:: salt myminion boto_kms.create_alias 'alias/mykey' key_id
salt/modules/boto_kms.py
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): ''' 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...
[ "Create", "a", "display", "name", "for", "a", "key", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L80-L98
[ "def", "create_alias", "(", "alias_name", ",", "target_key_id", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "conn", "=", "_get_conn", "(", "region", "=", "region", ",", "key", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
create_grant
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"]'
salt/modules/boto_kms.py
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, keyid=None, profile=None): ''' Adds a grant to a key to specify who can access the key and under what conditions. CLI examp...
[ "Adds", "a", "grant", "to", "a", "key", "to", "specify", "who", "can", "access", "the", "key", "and", "under", "what", "conditions", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L101-L128
[ "def", "create_grant", "(", "key_id", ",", "grantee_principal", ",", "retiring_principal", "=", "None", ",", "operations", "=", "None", ",", "constraints", "=", "None", ",", "grant_tokens", "=", "None", ",", "region", "=", "None", ",", "key", "=", "None", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
create_key
Creates a master key. CLI example:: salt myminion boto_kms.create_key '{"Statement":...}' "My master key"
salt/modules/boto_kms.py
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): ''' 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...
[ "Creates", "a", "master", "key", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L131-L153
[ "def", "create_key", "(", "policy", "=", "None", ",", "description", "=", "None", ",", "key_usage", "=", "None", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "conn", "=", "_g...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
decrypt
Decrypt ciphertext. CLI example:: salt myminion boto_kms.decrypt encrypted_ciphertext
salt/modules/boto_kms.py
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): ''' Decrypt ciphertext. CLI example:: salt myminion boto_kms.decrypt encrypted_ciphertext ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile...
[ "Decrypt", "ciphertext", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L156-L177
[ "def", "decrypt", "(", "ciphertext_blob", ",", "encryption_context", "=", "None", ",", "grant_tokens", "=", "None", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "conn", "=", "_ge...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
key_exists
Check for the existence of a key. CLI example:: salt myminion boto_kms.key_exists 'alias/mykey'
salt/modules/boto_kms.py
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): ''' 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...
[ "Check", "for", "the", "existence", "of", "a", "key", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L180-L200
[ "def", "key_exists", "(", "key_id", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "conn", "=", "_get_conn", "(", "region", "=", "region", ",", "key", "=", "key", ",", "keyid",...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_get_key_id
From an alias, get a key_id.
salt/modules/boto_kms.py
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): ''' From an alias, get a key_id. ''' key_metadata = describe_key( alias, region, key, keyid, profile )['key_metadata'] return key_metadata['KeyId']
[ "From", "an", "alias", "get", "a", "key_id", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L203-L210
[ "def", "_get_key_id", "(", "alias", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "key_metadata", "=", "describe_key", "(", "alias", ",", "region", ",", "key", ",", "keyid", ","...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
disable_key
Mark key as disabled. CLI example:: salt myminion boto_kms.disable_key 'alias/mykey'
salt/modules/boto_kms.py
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): ''' 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(...
[ "Mark", "key", "as", "disabled", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L233-L250
[ "def", "disable_key", "(", "key_id", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "conn", "=", "_get_conn", "(", "region", "=", "region", ",", "key", "=", "key", ",", "keyid"...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
encrypt
Encrypt plaintext into cipher text using specified key. CLI example:: salt myminion boto_kms.encrypt 'alias/mykey' 'myplaindata' '{"aws:username":"myuser"}'
salt/modules/boto_kms.py
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): ''' 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", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L315-L337
[ "def", "encrypt", "(", "key_id", ",", "plaintext", ",", "encryption_context", "=", "None", ",", "grant_tokens", "=", "None", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "conn", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
generate_data_key
Generate a secure data key. CLI example:: salt myminion boto_kms.generate_data_key 'alias/mykey' number_of_bytes=1024 key_spec=AES_128
salt/modules/boto_kms.py
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=None, profile=None): ''' Generate a secure data key. CLI example:: salt myminion boto_kms.generate_data_key 'alias...
[ "Generate", "a", "secure", "data", "key", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L340-L364
[ "def", "generate_data_key", "(", "key_id", ",", "encryption_context", "=", "None", ",", "number_of_bytes", "=", "None", ",", "key_spec", "=", "None", ",", "grant_tokens", "=", "None", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
generate_random
Generate a random string. CLI example:: salt myminion boto_kms.generate_random number_of_bytes=1024
salt/modules/boto_kms.py
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): ''' 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)...
[ "Generate", "a", "random", "string", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L395-L412
[ "def", "generate_random", "(", "number_of_bytes", "=", "None", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "conn", "=", "_get_conn", "(", "region", "=", "region", ",", "key", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
get_key_policy
Get the policy for the specified key. CLI example:: salt myminion boto_kms.get_key_policy 'alias/mykey' mypolicy
salt/modules/boto_kms.py
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): ''' 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...
[ "Get", "the", "policy", "for", "the", "specified", "key", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L415-L435
[ "def", "get_key_policy", "(", "key_id", ",", "policy_name", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "conn", "=", "_get_conn", "(", "region", "=", "region", ",", "key", "="...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
get_key_rotation_status
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'
salt/modules/boto_kms.py
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): ''' 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...
[ "Get", "status", "of", "whether", "or", "not", "key", "rotation", "is", "enabled", "for", "a", "key", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L438-L455
[ "def", "get_key_rotation_status", "(", "key_id", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "conn", "=", "_get_conn", "(", "region", "=", "region", ",", "key", "=", "key", ",...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
list_grants
List grants for the specified key. CLI example:: salt myminion boto_kms.list_grants 'alias/mykey'
salt/modules/boto_kms.py
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): ''' 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...
[ "List", "grants", "for", "the", "specified", "key", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L458-L490
[ "def", "list_grants", "(", "key_id", ",", "limit", "=", "None", ",", "marker", "=", "None", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "conn", "=", "_get_conn", "(", "regio...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
list_key_policies
List key_policies for the specified key. CLI example:: salt myminion boto_kms.list_key_policies 'alias/mykey'
salt/modules/boto_kms.py
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): ''' 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...
[ "List", "key_policies", "for", "the", "specified", "key", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L493-L517
[ "def", "list_key_policies", "(", "key_id", ",", "limit", "=", "None", ",", "marker", "=", "None", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "conn", "=", "_get_conn", "(", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
put_key_policy
Attach a key policy to the specified key. CLI example:: salt myminion boto_kms.put_key_policy 'alias/mykey' default '{"Statement":...}'
salt/modules/boto_kms.py
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): ''' 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...
[ "Attach", "a", "key", "policy", "to", "the", "specified", "key", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L520-L538
[ "def", "put_key_policy", "(", "key_id", ",", "policy_name", ",", "policy", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "conn", "=", "_get_conn", "(", "region", "=", "region", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
re_encrypt
Reencrypt encrypted data with a new master key. CLI example:: salt myminion boto_kms.re_encrypt 'encrypted_data' 'alias/mynewkey' default '{"Statement":...}'
salt/modules/boto_kms.py
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, keyid=None, profile=None): ''' Reencrypt encrypted data with a new master key. CLI example:: ...
[ "Reencrypt", "encrypted", "data", "with", "a", "new", "master", "key", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L541-L568
[ "def", "re_encrypt", "(", "ciphertext_blob", ",", "destination_key_id", ",", "source_encryption_context", "=", "None", ",", "destination_encryption_context", "=", "None", ",", "grant_tokens", "=", "None", ",", "region", "=", "None", ",", "key", "=", "None", ",", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
revoke_grant
Revoke a grant from a key. CLI example:: salt myminion boto_kms.revoke_grant 'alias/mykey' 8u89hf-j09j...
salt/modules/boto_kms.py
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): ''' 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) ...
[ "Revoke", "a", "grant", "from", "a", "key", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L571-L591
[ "def", "revoke_grant", "(", "key_id", ",", "grant_id", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "conn", "=", "_get_conn", "(", "region", "=", "region", ",", "key", "=", "...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_makepretty
Pretty print the stack trace and environment information for debugging those hard to reproduce user problems. :)
salt/utils/debug.py
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): ''' 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('==============...
[ "Pretty", "print", "the", "stack", "trace", "and", "environment", "information", "for", "debugging", "those", "hard", "to", "reproduce", "user", "problems", ".", ":", ")" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/debug.py#L21-L28
[ "def", "_makepretty", "(", "printout", ",", "stack", ")", ":", "printout", ".", "write", "(", "'======== Salt Debug Stack Trace =========\\n'", ")", "traceback", ".", "print_stack", "(", "stack", ",", "file", "=", "printout", ")", "printout", ".", "write", "(", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_handle_sigusr1
Signal handler for SIGUSR1, only available on Unix-like systems
salt/utils/debug.py
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): ''' 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...
[ "Signal", "handler", "for", "SIGUSR1", "only", "available", "on", "Unix", "-", "like", "systems" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/debug.py#L31-L44
[ "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",...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_handle_sigusr2
Signal handler for SIGUSR2, only available on Unix-like systems
salt/utils/debug.py
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): ''' 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()) ...
[ "Signal", "handler", "for", "SIGUSR2", "only", "available", "on", "Unix", "-", "like", "systems" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/debug.py#L47-L66
[ "def", "_handle_sigusr2", "(", "sig", ",", "stack", ")", ":", "try", ":", "import", "yappi", "except", "ImportError", ":", "return", "if", "yappi", ".", "is_running", "(", ")", ":", "yappi", ".", "stop", "(", ")", "filename", "=", "'callgrind.salt-{0}-{1}'...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
enable_sig_handler
Add signal handler for signal name if it exists on given platform
salt/utils/debug.py
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): ''' Add signal handler for signal name if it exists on given platform ''' if hasattr(signal, signal_name): signal.signal(getattr(signal, signal_name), handler)
[ "Add", "signal", "handler", "for", "signal", "name", "if", "it", "exists", "on", "given", "platform" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/debug.py#L69-L74
[ "def", "enable_sig_handler", "(", "signal_name", ",", "handler", ")", ":", "if", "hasattr", "(", "signal", ",", "signal_name", ")", ":", "signal", ".", "signal", "(", "getattr", "(", "signal", ",", "signal_name", ")", ",", "handler", ")" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
train
caller_name
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...
salt/utils/debug.py
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): ''' 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...
[ "Get", "a", "name", "of", "a", "caller", "in", "the", "format", "module", ".", "class", ".", "method" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/debug.py#L102-L143
[ "def", "caller_name", "(", "skip", "=", "2", ",", "include_lineno", "=", "False", ")", ":", "stack", "=", "inspect", ".", "stack", "(", ")", "start", "=", "0", "+", "skip", "if", "len", "(", "stack", ")", "<", "start", "+", "1", ":", "return", "'...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
image_running
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 ...
salt/states/nxos_upgrade.py
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): ''' 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...
[ "Ensure", "the", "NX", "-", "OS", "system", "image", "is", "running", "on", "the", "device", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/nxos_upgrade.py#L41-L107
[ "def", "image_running", "(", "name", ",", "system_image", ",", "kickstart_image", "=", "None", ",", "issu", "=", "True", ",", "*", "*", "kwargs", ")", ":", "ret", "=", "{", "'name'", ":", "name", ",", "'result'", ":", "False", ",", "'changes'", ":", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
WaitForTasks
Given the service instance si and tasks, it returns after all the tasks are complete
salt/ext/vsan/vsanapiutils.py
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): """ 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) ...
[ "Given", "the", "service", "instance", "si", "and", "tasks", "it", "returns", "after", "all", "the", "tasks", "are", "complete" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/vsan/vsanapiutils.py#L116-L165
[ "def", "WaitForTasks", "(", "tasks", ",", "si", ")", ":", "pc", "=", "si", ".", "content", ".", "propertyCollector", "taskList", "=", "[", "str", "(", "task", ")", "for", "task", "in", "tasks", "]", "# Create filter", "objSpecs", "=", "[", "vmodl", "."...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
checksum
Calculates the checksum char used for the 16th char. Author: Vincenzo Palazzo
faker/providers/ssn/it_IT/__init__.py
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): """ 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)
[ "Calculates", "the", "checksum", "char", "used", "for", "the", "16th", "char", ".", "Author", ":", "Vincenzo", "Palazzo" ]
joke2k/faker
python
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/ssn/it_IT/__init__.py#L18-L24
[ "def", "checksum", "(", "value", ")", ":", "return", "chr", "(", "65", "+", "sum", "(", "CHECKSUM_TABLE", "[", "index", "%", "2", "]", "[", "ALPHANUMERICS_DICT", "[", "char", "]", "]", "for", "index", ",", "char", "in", "enumerate", "(", "value", ")"...
965824b61132e52d92d1a6ce470396dbbe01c96c
train
Provider.binary
Returns random binary blob. Default blob size is 1 Mb.
faker/providers/misc/__init__.py
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)): """ 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)
[ "Returns", "random", "binary", "blob", "." ]
joke2k/faker
python
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/misc/__init__.py#L23-L29
[ "def", "binary", "(", "self", ",", "length", "=", "(", "1", "*", "1024", "*", "1024", ")", ")", ":", "blob", "=", "[", "self", ".", "generator", ".", "random", ".", "randrange", "(", "256", ")", "for", "_", "in", "range", "(", "length", ")", "]...
965824b61132e52d92d1a6ce470396dbbe01c96c
train
Provider.md5
Calculates the md5 hash of a given string :example 'cfcd208495d565ef66e7dff9f98764da'
faker/providers/misc/__init__.py
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): """ 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...
[ "Calculates", "the", "md5", "hash", "of", "a", "given", "string", ":", "example", "cfcd208495d565ef66e7dff9f98764da" ]
joke2k/faker
python
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/misc/__init__.py#L31-L39
[ "def", "md5", "(", "self", ",", "raw_output", "=", "False", ")", ":", "res", "=", "hashlib", ".", "md5", "(", "str", "(", "self", ".", "generator", ".", "random", ".", "random", "(", ")", ")", ".", "encode", "(", "'utf-8'", ")", ")", "if", "raw_o...
965824b61132e52d92d1a6ce470396dbbe01c96c
train
Provider.uuid4
Generates a random UUID4 string. :param cast_to: Specify what type the UUID should be cast to. Default is `str` :type cast_to: callable
faker/providers/misc/__init__.py
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): """ 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...
[ "Generates", "a", "random", "UUID4", "string", ".", ":", "param", "cast_to", ":", "Specify", "what", "type", "the", "UUID", "should", "be", "cast", "to", ".", "Default", "is", "str", ":", "type", "cast_to", ":", "callable" ]
joke2k/faker
python
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/misc/__init__.py#L62-L69
[ "def", "uuid4", "(", "self", ",", "cast_to", "=", "str", ")", ":", "# Based on http://stackoverflow.com/q/41186818", "return", "cast_to", "(", "uuid", ".", "UUID", "(", "int", "=", "self", ".", "generator", ".", "random", ".", "getrandbits", "(", "128", ")",...
965824b61132e52d92d1a6ce470396dbbe01c96c
train
Provider.password
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...
faker/providers/misc/__init__.py
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): """ Generates a random password. @param length: Integer. Length of a password @param special_chars: Boolean. Whether ...
[ "Generates", "a", "random", "password", "." ]
joke2k/faker
python
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/misc/__init__.py#L71-L121
[ "def", "password", "(", "self", ",", "length", "=", "10", ",", "special_chars", "=", "True", ",", "digits", "=", "True", ",", "upper_case", "=", "True", ",", "lower_case", "=", "True", ")", ":", "choices", "=", "\"\"", "required_tokens", "=", "[", "]",...
965824b61132e52d92d1a6ce470396dbbe01c96c
train
checksum_identity_card_number
Calculates and returns a control digit for given list of characters basing on Identity Card Number standards.
faker/providers/person/pl_PL/__init__.py
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): """ 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_...
[ "Calculates", "and", "returns", "a", "control", "digit", "for", "given", "list", "of", "characters", "basing", "on", "Identity", "Card", "Number", "standards", "." ]
joke2k/faker
python
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/person/pl_PL/__init__.py#L6-L21
[ "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", ...
965824b61132e52d92d1a6ce470396dbbe01c96c
train
Provider.identity_card_number
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
faker/providers/person/pl_PL/__init__.py
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): """ 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:...
[ "Returns", "9", "character", "Polish", "Identity", "Card", "Number", "Polish", ":", "Numer", "Dowodu", "Osobistego", "." ]
joke2k/faker
python
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/person/pl_PL/__init__.py#L681-L704
[ "def", "identity_card_number", "(", "self", ")", ":", "identity", "=", "[", "]", "for", "_", "in", "range", "(", "3", ")", ":", "identity", ".", "append", "(", "self", ".", "random_letter", "(", ")", ".", "upper", "(", ")", ")", "# it will be overwritt...
965824b61132e52d92d1a6ce470396dbbe01c96c
train
execute_from_command_line
A simple method that runs a Command.
faker/cli.py
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): """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) ...
[ "A", "simple", "method", "that", "runs", "a", "Command", "." ]
joke2k/faker
python
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/cli.py#L267-L276
[ "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'", ",",...
965824b61132e52d92d1a6ce470396dbbe01c96c
train
Command.execute
Given the command-line arguments, this creates a parser appropriate to that command, and runs it.
faker/cli.py
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): """ 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...
[ "Given", "the", "command", "-", "line", "arguments", "this", "creates", "a", "parser", "appropriate", "to", "that", "command", "and", "runs", "it", "." ]
joke2k/faker
python
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/cli.py#L127-L264
[ "def", "execute", "(", "self", ")", ":", "# retrieve default language from system environment", "default_locale", "=", "os", ".", "environ", ".", "get", "(", "'LANG'", ",", "'en_US'", ")", ".", "split", "(", "'.'", ")", "[", "0", "]", "if", "default_locale", ...
965824b61132e52d92d1a6ce470396dbbe01c96c
train
ISBN13._check_digit
Calculate the check digit for ISBN-13. See https://en.wikipedia.org/wiki/International_Standard_Book_Number for calculation.
faker/providers/isbn/isbn.py
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): """ 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, ...
[ "Calculate", "the", "check", "digit", "for", "ISBN", "-", "13", ".", "See", "https", ":", "//", "en", ".", "wikipedia", ".", "org", "/", "wiki", "/", "International_Standard_Book_Number", "for", "calculation", "." ]
joke2k/faker
python
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/isbn/isbn.py#L25-L36
[ "def", "_check_digit", "(", "self", ")", ":", "weights", "=", "(", "1", "if", "x", "%", "2", "==", "0", "else", "3", "for", "x", "in", "range", "(", "12", ")", ")", "body", "=", "''", ".", "join", "(", "[", "self", ".", "ean", ",", "self", ...
965824b61132e52d92d1a6ce470396dbbe01c96c
train
Provider._is_catch_phrase_valid
Validates a french catch phrase. :param catch_phrase: The catch phrase to validate.
faker/providers/company/fr_FR/__init__.py
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): """ 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. ...
[ "Validates", "a", "french", "catch", "phrase", "." ]
joke2k/faker
python
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/company/fr_FR/__init__.py#L97-L111
[ "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", "(",...
965824b61132e52d92d1a6ce470396dbbe01c96c
train
Provider.siret
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...
faker/providers/company/fr_FR/__init__.py
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): """ 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...
[ "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", ")", ...
joke2k/faker
python
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/company/fr_FR/__init__.py#L119-L132
[ "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...
965824b61132e52d92d1a6ce470396dbbe01c96c
train
remove_accents
Remove accents from characters in the given string.
faker/providers/internet/el_GR/__init__.py
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): """ 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...
[ "Remove", "accents", "from", "characters", "in", "the", "given", "string", "." ]
joke2k/faker
python
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/internet/el_GR/__init__.py#L32-L45
[ "def", "remove_accents", "(", "value", ")", ":", "search", "=", "'ΆΈΉΊΌΎΏάέήίόύώΪϊΐϋΰ'", "replace", "=", "'ΑΕΗΙΟΥΩαεηιουωΙιιυυ'", "def", "replace_accented_character", "(", "match", ")", ":", "matched", "=", "match", ".", "group", "(", "0", ")", "if", "matched", ...
965824b61132e52d92d1a6ce470396dbbe01c96c
train
latinize
Converts (transliterates) greek letters to latin equivalents.
faker/providers/internet/el_GR/__init__.py
def latinize(value): """ Converts (transliterates) greek letters to latin equivalents. """ def replace_double_character(match): search = ('Θ Χ Ψ ' 'θ χ ψ ' 'ΟΥ ΑΥ ΕΥ ' 'Ου Αυ Ευ ' 'ου αυ ευ').split() replace = ('TH C...
def latinize(value): """ Converts (transliterates) greek letters to latin equivalents. """ def replace_double_character(match): search = ('Θ Χ Ψ ' 'θ χ ψ ' 'ΟΥ ΑΥ ΕΥ ' 'Ου Αυ Ευ ' 'ου αυ ευ').split() replace = ('TH C...
[ "Converts", "(", "transliterates", ")", "greek", "letters", "to", "latin", "equivalents", "." ]
joke2k/faker
python
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/internet/el_GR/__init__.py#L48-L80
[ "def", "latinize", "(", "value", ")", ":", "def", "replace_double_character", "(", "match", ")", ":", "search", "=", "(", "'Θ Χ Ψ '", "'θ χ ψ '", "'ΟΥ ΑΥ ΕΥ '", "'Ου Αυ Ευ '", "'ου αυ ευ').spli", "t", "(", ")", "", "", "replace", "=", "(", "'TH CH PS '", "'t...
965824b61132e52d92d1a6ce470396dbbe01c96c
train
Provider.ssn
Returns an Israeli identity number, known as Teudat Zehut ("tz"). https://en.wikipedia.org/wiki/Israeli_identity_card
faker/providers/ssn/he_IL/__init__.py
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): """ 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,...
[ "Returns", "an", "Israeli", "identity", "number", "known", "as", "Teudat", "Zehut", "(", "tz", ")", "." ]
joke2k/faker
python
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/ssn/he_IL/__init__.py#L9-L32
[ "def", "ssn", "(", "self", ")", ":", "newID", "=", "str", "(", "self", ".", "generator", ".", "random", ".", "randrange", "(", "111111", ",", "99999999", ")", ")", "newID", "=", "newID", ".", "zfill", "(", "8", ")", "theSum", "=", "0", "indexRange"...
965824b61132e52d92d1a6ce470396dbbe01c96c
train
Provider.words
: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...
faker/providers/lorem/__init__.py
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): """ :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...
[ ":", "returns", ":", "An", "array", "of", "random", "words", ".", "for", "example", ":", "[", "Lorem", "ipsum", "dolor", "]" ]
joke2k/faker
python
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/lorem/__init__.py#L28-L43
[ "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",...
965824b61132e52d92d1a6ce470396dbbe01c96c
train
Provider.sentence
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 ``...
faker/providers/lorem/__init__.py
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): """ 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`` ...
[ "Generate", "a", "random", "sentence", ":", "example", "Lorem", "ipsum", "dolor", "sit", "amet", "." ]
joke2k/faker
python
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/lorem/__init__.py#L56-L79
[ "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", ".",...
965824b61132e52d92d1a6ce470396dbbe01c96c
train
Provider.sentences
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
faker/providers/lorem/__init__.py
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): """ 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...
[ "Generate", "an", "array", "of", "sentences", ":", "example", "[", "Lorem", "ipsum", "dolor", "sit", "amet", ".", "Consectetur", "adipisicing", "eli", ".", "]" ]
joke2k/faker
python
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/lorem/__init__.py#L81-L94
[ "def", "sentences", "(", "self", ",", "nb", "=", "3", ",", "ext_word_list", "=", "None", ")", ":", "return", "[", "self", ".", "sentence", "(", "ext_word_list", "=", "ext_word_list", ")", "for", "_", "in", "range", "(", "0", ",", "nb", ")", "]" ]
965824b61132e52d92d1a6ce470396dbbe01c96c
train
Provider.paragraph
: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 ...
faker/providers/lorem/__init__.py
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): """ :returns: A single paragraph. For example: 'Sapiente sunt omnis. Ut pariatur ad autem ducimus et. Voluptas rem voluptas sint modi dolorem amet.' ...
[ ":", "returns", ":", "A", "single", "paragraph", ".", "For", "example", ":", "Sapiente", "sunt", "omnis", ".", "Ut", "pariatur", "ad", "autem", "ducimus", "et", ".", "Voluptas", "rem", "voluptas", "sint", "modi", "dolorem", "amet", "." ]
joke2k/faker
python
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/lorem/__init__.py#L96-L125
[ "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", ...
965824b61132e52d92d1a6ce470396dbbe01c96c
train
Provider.paragraphs
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
faker/providers/lorem/__init__.py
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): """ 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'. :...
[ "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", ...
joke2k/faker
python
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/lorem/__init__.py#L127-L139
[ "def", "paragraphs", "(", "self", ",", "nb", "=", "3", ",", "ext_word_list", "=", "None", ")", ":", "return", "[", "self", ".", "paragraph", "(", "ext_word_list", "=", "ext_word_list", ")", "for", "_", "in", "range", "(", "0", ",", "nb", ")", "]" ]
965824b61132e52d92d1a6ce470396dbbe01c96c
train
Provider.text
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...
faker/providers/lorem/__init__.py
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): """ 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.' ...
[ "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...
joke2k/faker
python
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/lorem/__init__.py#L141-L198
[ "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'", ")", "...
965824b61132e52d92d1a6ce470396dbbe01c96c
train
Provider.city
:example 'Sashabury'
faker/providers/address/__init__.py
def city(self): """ :example 'Sashabury' """ pattern = self.random_element(self.city_formats) return self.generator.parse(pattern)
def city(self): """ :example 'Sashabury' """ pattern = self.random_element(self.city_formats) return self.generator.parse(pattern)
[ ":", "example", "Sashabury" ]
joke2k/faker
python
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/address/__init__.py#L45-L50
[ "def", "city", "(", "self", ")", ":", "pattern", "=", "self", ".", "random_element", "(", "self", ".", "city_formats", ")", "return", "self", ".", "generator", ".", "parse", "(", "pattern", ")" ]
965824b61132e52d92d1a6ce470396dbbe01c96c
train
Provider.street_name
:example 'Crist Parks'
faker/providers/address/__init__.py
def street_name(self): """ :example 'Crist Parks' """ pattern = self.random_element(self.street_name_formats) return self.generator.parse(pattern)
def street_name(self): """ :example 'Crist Parks' """ pattern = self.random_element(self.street_name_formats) return self.generator.parse(pattern)
[ ":", "example", "Crist", "Parks" ]
joke2k/faker
python
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/address/__init__.py#L52-L57
[ "def", "street_name", "(", "self", ")", ":", "pattern", "=", "self", ".", "random_element", "(", "self", ".", "street_name_formats", ")", "return", "self", ".", "generator", ".", "parse", "(", "pattern", ")" ]
965824b61132e52d92d1a6ce470396dbbe01c96c
train
Provider.street_address
:example '791 Crist Parks'
faker/providers/address/__init__.py
def street_address(self): """ :example '791 Crist Parks' """ pattern = self.random_element(self.street_address_formats) return self.generator.parse(pattern)
def street_address(self): """ :example '791 Crist Parks' """ pattern = self.random_element(self.street_address_formats) return self.generator.parse(pattern)
[ ":", "example", "791", "Crist", "Parks" ]
joke2k/faker
python
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/address/__init__.py#L59-L64
[ "def", "street_address", "(", "self", ")", ":", "pattern", "=", "self", ".", "random_element", "(", "self", ".", "street_address_formats", ")", "return", "self", ".", "generator", ".", "parse", "(", "pattern", ")" ]
965824b61132e52d92d1a6ce470396dbbe01c96c
train
Provider.address
:example '791 Crist Parks, Sashabury, IL 86039-9874'
faker/providers/address/__init__.py
def address(self): """ :example '791 Crist Parks, Sashabury, IL 86039-9874' """ pattern = self.random_element(self.address_formats) return self.generator.parse(pattern)
def address(self): """ :example '791 Crist Parks, Sashabury, IL 86039-9874' """ pattern = self.random_element(self.address_formats) return self.generator.parse(pattern)
[ ":", "example", "791", "Crist", "Parks", "Sashabury", "IL", "86039", "-", "9874" ]
joke2k/faker
python
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/address/__init__.py#L72-L77
[ "def", "address", "(", "self", ")", ":", "pattern", "=", "self", ".", "random_element", "(", "self", ".", "address_formats", ")", "return", "self", ".", "generator", ".", "parse", "(", "pattern", ")" ]
965824b61132e52d92d1a6ce470396dbbe01c96c
train
slugify
Converts to lowercase, removes non-word characters (alphanumerics and underscores) and converts spaces to hyphens. Also strips leading and trailing whitespace. Modified to optionally allow dots. Adapted from Django 1.9
faker/utils/text.py
def slugify(value, allow_dots=False, allow_unicode=False): """ Converts to lowercase, removes non-word characters (alphanumerics and underscores) and converts spaces to hyphens. Also strips leading and trailing whitespace. Modified to optionally allow dots. Adapted from Django 1.9 """ if al...
def slugify(value, allow_dots=False, allow_unicode=False): """ Converts to lowercase, removes non-word characters (alphanumerics and underscores) and converts spaces to hyphens. Also strips leading and trailing whitespace. Modified to optionally allow dots. Adapted from Django 1.9 """ if al...
[ "Converts", "to", "lowercase", "removes", "non", "-", "word", "characters", "(", "alphanumerics", "and", "underscores", ")", "and", "converts", "spaces", "to", "hyphens", ".", "Also", "strips", "leading", "and", "trailing", "whitespace", ".", "Modified", "to", ...
joke2k/faker
python
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/utils/text.py#L14-L35
[ "def", "slugify", "(", "value", ",", "allow_dots", "=", "False", ",", "allow_unicode", "=", "False", ")", ":", "if", "allow_dots", ":", "pattern", "=", "_re_pattern_allow_dots", "else", ":", "pattern", "=", "_re_pattern", "value", "=", "six", ".", "text_type...
965824b61132e52d92d1a6ce470396dbbe01c96c
train
Provider.ban
:example '3番'
faker/providers/address/ja_JP/__init__.py
def ban(self): """ :example '3番' """ return "%d番" % self.generator.random.randint(1, 27)
def ban(self): """ :example '3番' """ return "%d番" % self.generator.random.randint(1, 27)
[ ":", "example", "3番" ]
joke2k/faker
python
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/address/ja_JP/__init__.py#L332-L336
[ "def", "ban", "(", "self", ")", ":", "return", "\"%d番\" %", "s", "lf.g", "e", "nerator.r", "a", "ndom.r", "a", "ndint(1", ",", " ", "2", ")", "" ]
965824b61132e52d92d1a6ce470396dbbe01c96c
train
Provider.postcode
:example '101-1212'
faker/providers/address/ja_JP/__init__.py
def postcode(self): """ :example '101-1212' """ return "%03d-%04d" % (self.generator.random.randint(0, 999), self.generator.random.randint(0, 9999))
def postcode(self): """ :example '101-1212' """ return "%03d-%04d" % (self.generator.random.randint(0, 999), self.generator.random.randint(0, 9999))
[ ":", "example", "101", "-", "1212" ]
joke2k/faker
python
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/address/ja_JP/__init__.py#L350-L355
[ "def", "postcode", "(", "self", ")", ":", "return", "\"%03d-%04d\"", "%", "(", "self", ".", "generator", ".", "random", ".", "randint", "(", "0", ",", "999", ")", ",", "self", ".", "generator", ".", "random", ".", "randint", "(", "0", ",", "9999", ...
965824b61132e52d92d1a6ce470396dbbe01c96c
train
Provider.postcode
Replaces all question mark ('?') occurrences with a random letter from postal_code_formats then passes result to numerify to insert numbers
faker/providers/address/en_CA/__init__.py
def postcode(self): """ Replaces all question mark ('?') occurrences with a random letter from postal_code_formats then passes result to numerify to insert numbers """ temp = re.sub(r'\?', lambda x: self.postal_code_letter(), se...
def postcode(self): """ Replaces all question mark ('?') occurrences with a random letter from postal_code_formats then passes result to numerify to insert numbers """ temp = re.sub(r'\?', lambda x: self.postal_code_letter(), se...
[ "Replaces", "all", "question", "mark", "(", "?", ")", "occurrences", "with", "a", "random", "letter", "from", "postal_code_formats", "then", "passes", "result", "to", "numerify", "to", "insert", "numbers" ]
joke2k/faker
python
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/address/en_CA/__init__.py#L319-L328
[ "def", "postcode", "(", "self", ")", ":", "temp", "=", "re", ".", "sub", "(", "r'\\?'", ",", "lambda", "x", ":", "self", ".", "postal_code_letter", "(", ")", ",", "self", ".", "random_element", "(", "self", ".", "postal_code_formats", ")", ")", "return...
965824b61132e52d92d1a6ce470396dbbe01c96c
train
regon_checksum
Calculates and returns a control digit for given list of digits basing on REGON standard.
faker/providers/company/pl_PL/__init__.py
def regon_checksum(digits): """ Calculates and returns a control digit for given list of digits basing on REGON standard. """ weights_for_check_digit = [8, 9, 2, 3, 4, 5, 6, 7] check_digit = 0 for i in range(0, 8): check_digit += weights_for_check_digit[i] * digits[i] check_digit %...
def regon_checksum(digits): """ Calculates and returns a control digit for given list of digits basing on REGON standard. """ weights_for_check_digit = [8, 9, 2, 3, 4, 5, 6, 7] check_digit = 0 for i in range(0, 8): check_digit += weights_for_check_digit[i] * digits[i] check_digit %...
[ "Calculates", "and", "returns", "a", "control", "digit", "for", "given", "list", "of", "digits", "basing", "on", "REGON", "standard", "." ]
joke2k/faker
python
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/company/pl_PL/__init__.py#L6-L21
[ "def", "regon_checksum", "(", "digits", ")", ":", "weights_for_check_digit", "=", "[", "8", ",", "9", ",", "2", ",", "3", ",", "4", ",", "5", ",", "6", ",", "7", "]", "check_digit", "=", "0", "for", "i", "in", "range", "(", "0", ",", "8", ")", ...
965824b61132e52d92d1a6ce470396dbbe01c96c
train
local_regon_checksum
Calculates and returns a control digit for given list of digits basing on local REGON standard.
faker/providers/company/pl_PL/__init__.py
def local_regon_checksum(digits): """ Calculates and returns a control digit for given list of digits basing on local REGON standard. """ weights_for_check_digit = [2, 4, 8, 5, 0, 9, 7, 3, 6, 1, 2, 4, 8] check_digit = 0 for i in range(0, 13): check_digit += weights_for_check_digit[i] * ...
def local_regon_checksum(digits): """ Calculates and returns a control digit for given list of digits basing on local REGON standard. """ weights_for_check_digit = [2, 4, 8, 5, 0, 9, 7, 3, 6, 1, 2, 4, 8] check_digit = 0 for i in range(0, 13): check_digit += weights_for_check_digit[i] * ...
[ "Calculates", "and", "returns", "a", "control", "digit", "for", "given", "list", "of", "digits", "basing", "on", "local", "REGON", "standard", "." ]
joke2k/faker
python
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/company/pl_PL/__init__.py#L24-L39
[ "def", "local_regon_checksum", "(", "digits", ")", ":", "weights_for_check_digit", "=", "[", "2", ",", "4", ",", "8", ",", "5", ",", "0", ",", "9", ",", "7", ",", "3", ",", "6", ",", "1", ",", "2", ",", "4", ",", "8", "]", "check_digit", "=", ...
965824b61132e52d92d1a6ce470396dbbe01c96c
train
company_vat_checksum
Calculates and returns a control digit for given list of digits basing on NIP standard.
faker/providers/company/pl_PL/__init__.py
def company_vat_checksum(digits): """ Calculates and returns a control digit for given list of digits basing on NIP standard. """ weights_for_check_digit = [6, 5, 7, 2, 3, 4, 5, 6, 7] check_digit = 0 for i in range(0, 9): check_digit += weights_for_check_digit[i] * digits[i] check_...
def company_vat_checksum(digits): """ Calculates and returns a control digit for given list of digits basing on NIP standard. """ weights_for_check_digit = [6, 5, 7, 2, 3, 4, 5, 6, 7] check_digit = 0 for i in range(0, 9): check_digit += weights_for_check_digit[i] * digits[i] check_...
[ "Calculates", "and", "returns", "a", "control", "digit", "for", "given", "list", "of", "digits", "basing", "on", "NIP", "standard", "." ]
joke2k/faker
python
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/company/pl_PL/__init__.py#L42-L54
[ "def", "company_vat_checksum", "(", "digits", ")", ":", "weights_for_check_digit", "=", "[", "6", ",", "5", ",", "7", ",", "2", ",", "3", ",", "4", ",", "5", ",", "6", ",", "7", "]", "check_digit", "=", "0", "for", "i", "in", "range", "(", "0", ...
965824b61132e52d92d1a6ce470396dbbe01c96c
train
Provider.regon
Returns 9 character Polish National Business Registry Number, Polish: Rejestr Gospodarki Narodowej - REGON. https://pl.wikipedia.org/wiki/REGON
faker/providers/company/pl_PL/__init__.py
def regon(self): """ Returns 9 character Polish National Business Registry Number, Polish: Rejestr Gospodarki Narodowej - REGON. https://pl.wikipedia.org/wiki/REGON """ voivodeship_number = self.random_int(0, 49) * 2 + 1 regon_digits = [int(voivodeship_number / 1...
def regon(self): """ Returns 9 character Polish National Business Registry Number, Polish: Rejestr Gospodarki Narodowej - REGON. https://pl.wikipedia.org/wiki/REGON """ voivodeship_number = self.random_int(0, 49) * 2 + 1 regon_digits = [int(voivodeship_number / 1...
[ "Returns", "9", "character", "Polish", "National", "Business", "Registry", "Number", "Polish", ":", "Rejestr", "Gospodarki", "Narodowej", "-", "REGON", "." ]
joke2k/faker
python
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/company/pl_PL/__init__.py#L77-L92
[ "def", "regon", "(", "self", ")", ":", "voivodeship_number", "=", "self", ".", "random_int", "(", "0", ",", "49", ")", "*", "2", "+", "1", "regon_digits", "=", "[", "int", "(", "voivodeship_number", "/", "10", ")", ",", "voivodeship_number", "%", "10",...
965824b61132e52d92d1a6ce470396dbbe01c96c
train
Provider.local_regon
Returns 14 character Polish National Business Registry Number, local entity number. https://pl.wikipedia.org/wiki/REGON
faker/providers/company/pl_PL/__init__.py
def local_regon(self): """ Returns 14 character Polish National Business Registry Number, local entity number. https://pl.wikipedia.org/wiki/REGON """ regon_digits = [int(digit) for digit in list(self.regon())] for _ in range(4): regon_digits.append(...
def local_regon(self): """ Returns 14 character Polish National Business Registry Number, local entity number. https://pl.wikipedia.org/wiki/REGON """ regon_digits = [int(digit) for digit in list(self.regon())] for _ in range(4): regon_digits.append(...
[ "Returns", "14", "character", "Polish", "National", "Business", "Registry", "Number", "local", "entity", "number", "." ]
joke2k/faker
python
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/company/pl_PL/__init__.py#L94-L108
[ "def", "local_regon", "(", "self", ")", ":", "regon_digits", "=", "[", "int", "(", "digit", ")", "for", "digit", "in", "list", "(", "self", ".", "regon", "(", ")", ")", "]", "for", "_", "in", "range", "(", "4", ")", ":", "regon_digits", ".", "app...
965824b61132e52d92d1a6ce470396dbbe01c96c
train
Provider.company_vat
Returns 10 character tax identification number, Polish: Numer identyfikacji podatkowej. https://pl.wikipedia.org/wiki/NIP
faker/providers/company/pl_PL/__init__.py
def company_vat(self): """ Returns 10 character tax identification number, Polish: Numer identyfikacji podatkowej. https://pl.wikipedia.org/wiki/NIP """ vat_digits = [] for _ in range(3): vat_digits.append(self.random_digit_not_null()) for _...
def company_vat(self): """ Returns 10 character tax identification number, Polish: Numer identyfikacji podatkowej. https://pl.wikipedia.org/wiki/NIP """ vat_digits = [] for _ in range(3): vat_digits.append(self.random_digit_not_null()) for _...
[ "Returns", "10", "character", "tax", "identification", "number", "Polish", ":", "Numer", "identyfikacji", "podatkowej", "." ]
joke2k/faker
python
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/company/pl_PL/__init__.py#L110-L134
[ "def", "company_vat", "(", "self", ")", ":", "vat_digits", "=", "[", "]", "for", "_", "in", "range", "(", "3", ")", ":", "vat_digits", ".", "append", "(", "self", ".", "random_digit_not_null", "(", ")", ")", "for", "_", "in", "range", "(", "6", ")"...
965824b61132e52d92d1a6ce470396dbbe01c96c
train
checksum
Returns the checksum of CPF digits. References to the algorithm: https://pt.wikipedia.org/wiki/Cadastro_de_pessoas_f%C3%ADsicas#Algoritmo https://metacpan.org/source/MAMAWE/Algorithm-CheckDigits-v1.3.0/lib/Algorithm/CheckDigits/M11_004.pm
faker/providers/ssn/pt_BR/__init__.py
def checksum(digits): """ Returns the checksum of CPF digits. References to the algorithm: https://pt.wikipedia.org/wiki/Cadastro_de_pessoas_f%C3%ADsicas#Algoritmo https://metacpan.org/source/MAMAWE/Algorithm-CheckDigits-v1.3.0/lib/Algorithm/CheckDigits/M11_004.pm """ s = 0 p = len(digit...
def checksum(digits): """ Returns the checksum of CPF digits. References to the algorithm: https://pt.wikipedia.org/wiki/Cadastro_de_pessoas_f%C3%ADsicas#Algoritmo https://metacpan.org/source/MAMAWE/Algorithm-CheckDigits-v1.3.0/lib/Algorithm/CheckDigits/M11_004.pm """ s = 0 p = len(digit...
[ "Returns", "the", "checksum", "of", "CPF", "digits", ".", "References", "to", "the", "algorithm", ":", "https", ":", "//", "pt", ".", "wikipedia", ".", "org", "/", "wiki", "/", "Cadastro_de_pessoas_f%C3%ADsicas#Algoritmo", "https", ":", "//", "metacpan", ".", ...
joke2k/faker
python
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/ssn/pt_BR/__init__.py#L8-L25
[ "def", "checksum", "(", "digits", ")", ":", "s", "=", "0", "p", "=", "len", "(", "digits", ")", "+", "1", "for", "i", "in", "range", "(", "0", ",", "len", "(", "digits", ")", ")", ":", "s", "+=", "digits", "[", "i", "]", "*", "p", "p", "-...
965824b61132e52d92d1a6ce470396dbbe01c96c
train
Provider.rg
Brazilian RG, return plain numbers. Check: https://www.ngmatematica.com/2014/02/como-determinar-o-digito-verificador-do.html
faker/providers/ssn/pt_BR/__init__.py
def rg(self): """ Brazilian RG, return plain numbers. Check: https://www.ngmatematica.com/2014/02/como-determinar-o-digito-verificador-do.html """ digits = self.generator.random.sample(range(0, 9), 8) checksum = sum(i * digits[i - 2] for i in range(2, 10)) last_...
def rg(self): """ Brazilian RG, return plain numbers. Check: https://www.ngmatematica.com/2014/02/como-determinar-o-digito-verificador-do.html """ digits = self.generator.random.sample(range(0, 9), 8) checksum = sum(i * digits[i - 2] for i in range(2, 10)) last_...
[ "Brazilian", "RG", "return", "plain", "numbers", ".", "Check", ":", "https", ":", "//", "www", ".", "ngmatematica", ".", "com", "/", "2014", "/", "02", "/", "como", "-", "determinar", "-", "o", "-", "digito", "-", "verificador", "-", "do", ".", "html...
joke2k/faker
python
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/ssn/pt_BR/__init__.py#L49-L66
[ "def", "rg", "(", "self", ")", ":", "digits", "=", "self", ".", "generator", ".", "random", ".", "sample", "(", "range", "(", "0", ",", "9", ")", ",", "8", ")", "checksum", "=", "sum", "(", "i", "*", "digits", "[", "i", "-", "2", "]", "for", ...
965824b61132e52d92d1a6ce470396dbbe01c96c
train
Provider._body
Generate the information required to create an ISBN-10 or ISBN-13.
faker/providers/isbn/__init__.py
def _body(self): """ Generate the information required to create an ISBN-10 or ISBN-13. """ ean = self.random_element(RULES.keys()) reg_group = self.random_element(RULES[ean].keys()) # Given the chosen ean/group, decide how long the # registrant/publication str...
def _body(self): """ Generate the information required to create an ISBN-10 or ISBN-13. """ ean = self.random_element(RULES.keys()) reg_group = self.random_element(RULES[ean].keys()) # Given the chosen ean/group, decide how long the # registrant/publication str...
[ "Generate", "the", "information", "required", "to", "create", "an", "ISBN", "-", "10", "or", "ISBN", "-", "13", "." ]
joke2k/faker
python
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/isbn/__init__.py#L23-L42
[ "def", "_body", "(", "self", ")", ":", "ean", "=", "self", ".", "random_element", "(", "RULES", ".", "keys", "(", ")", ")", "reg_group", "=", "self", ".", "random_element", "(", "RULES", "[", "ean", "]", ".", "keys", "(", ")", ")", "# Given the chose...
965824b61132e52d92d1a6ce470396dbbe01c96c
train
Provider._registrant_publication
Separate the registration from the publication in a given string. :param reg_pub: A string of digits representing a registration and publication. :param rules: A list of RegistrantRules which designate where to separate the values in the string. :returns: A (regis...
faker/providers/isbn/__init__.py
def _registrant_publication(reg_pub, rules): """ Separate the registration from the publication in a given string. :param reg_pub: A string of digits representing a registration and publication. :param rules: A list of RegistrantRules which designate where to sepa...
def _registrant_publication(reg_pub, rules): """ Separate the registration from the publication in a given string. :param reg_pub: A string of digits representing a registration and publication. :param rules: A list of RegistrantRules which designate where to sepa...
[ "Separate", "the", "registration", "from", "the", "publication", "in", "a", "given", "string", ".", ":", "param", "reg_pub", ":", "A", "string", "of", "digits", "representing", "a", "registration", "and", "publication", ".", ":", "param", "rules", ":", "A", ...
joke2k/faker
python
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/isbn/__init__.py#L45-L62
[ "def", "_registrant_publication", "(", "reg_pub", ",", "rules", ")", ":", "for", "rule", "in", "rules", ":", "if", "rule", ".", "min", "<=", "reg_pub", "<=", "rule", ".", "max", ":", "reg_len", "=", "rule", ".", "registrant_length", "break", "else", ":",...
965824b61132e52d92d1a6ce470396dbbe01c96c
train
Provider.ssn
Ukrainian "Реєстраційний номер облікової картки платника податків" also known as "Ідентифікаційний номер фізичної особи".
faker/providers/ssn/uk_UA/__init__.py
def ssn(self): """ Ukrainian "Реєстраційний номер облікової картки платника податків" also known as "Ідентифікаційний номер фізичної особи". """ digits = [] # Number of days between 1899-12-31 and a birth date for digit in str((self.generator.date_object() - ...
def ssn(self): """ Ukrainian "Реєстраційний номер облікової картки платника податків" also known as "Ідентифікаційний номер фізичної особи". """ digits = [] # Number of days between 1899-12-31 and a birth date for digit in str((self.generator.date_object() - ...
[ "Ukrainian", "Реєстраційний", "номер", "облікової", "картки", "платника", "податків", "also", "known", "as", "Ідентифікаційний", "номер", "фізичної", "особи", "." ]
joke2k/faker
python
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/ssn/uk_UA/__init__.py#L10-L32
[ "def", "ssn", "(", "self", ")", ":", "digits", "=", "[", "]", "# Number of days between 1899-12-31 and a birth date", "for", "digit", "in", "str", "(", "(", "self", ".", "generator", ".", "date_object", "(", ")", "-", "date", "(", "1899", ",", "12", ",", ...
965824b61132e52d92d1a6ce470396dbbe01c96c
train
Provider.state_abbr
:returns: A random state or territory abbreviation. :param include_territories: If True, territories will be included. If False, only states will be returned.
faker/providers/address/en_US/__init__.py
def state_abbr(self, include_territories=True): """ :returns: A random state or territory abbreviation. :param include_territories: If True, territories will be included. If False, only states will be returned. """ if include_territories: self.random_elem...
def state_abbr(self, include_territories=True): """ :returns: A random state or territory abbreviation. :param include_territories: If True, territories will be included. If False, only states will be returned. """ if include_territories: self.random_elem...
[ ":", "returns", ":", "A", "random", "state", "or", "territory", "abbreviation", "." ]
joke2k/faker
python
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/address/en_US/__init__.py#L358-L367
[ "def", "state_abbr", "(", "self", ",", "include_territories", "=", "True", ")", ":", "if", "include_territories", ":", "self", ".", "random_element", "(", "self", ".", "states_and_territories_abbr", ")", "return", "self", ".", "random_element", "(", "self", ".",...
965824b61132e52d92d1a6ce470396dbbe01c96c
train
Provider.pystr
Generates a random string of upper and lowercase letters. :type min_chars: int :type max_chars: int :return: String. Random of random length between min and max characters.
faker/providers/python/__init__.py
def pystr(self, min_chars=None, max_chars=20): """ Generates a random string of upper and lowercase letters. :type min_chars: int :type max_chars: int :return: String. Random of random length between min and max characters. """ if min_chars is None: re...
def pystr(self, min_chars=None, max_chars=20): """ Generates a random string of upper and lowercase letters. :type min_chars: int :type max_chars: int :return: String. Random of random length between min and max characters. """ if min_chars is None: re...
[ "Generates", "a", "random", "string", "of", "upper", "and", "lowercase", "letters", ".", ":", "type", "min_chars", ":", "int", ":", "type", "max_chars", ":", "int", ":", "return", ":", "String", ".", "Random", "of", "random", "length", "between", "min", ...
joke2k/faker
python
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/python/__init__.py#L17-L33
[ "def", "pystr", "(", "self", ",", "min_chars", "=", "None", ",", "max_chars", "=", "20", ")", ":", "if", "min_chars", "is", "None", ":", "return", "\"\"", ".", "join", "(", "self", ".", "random_letters", "(", "length", "=", "max_chars", ")", ")", "el...
965824b61132e52d92d1a6ce470396dbbe01c96c
train
Provider.pydict
Returns a dictionary. :nb_elements: number of elements for dictionary :variable_nb_elements: is use variable number of elements for dictionary :value_types: type of dictionary values
faker/providers/python/__init__.py
def pydict(self, nb_elements=10, variable_nb_elements=True, *value_types): """ Returns a dictionary. :nb_elements: number of elements for dictionary :variable_nb_elements: is use variable number of elements for dictionary :value_types: type of dictionary values """ ...
def pydict(self, nb_elements=10, variable_nb_elements=True, *value_types): """ Returns a dictionary. :nb_elements: number of elements for dictionary :variable_nb_elements: is use variable number of elements for dictionary :value_types: type of dictionary values """ ...
[ "Returns", "a", "dictionary", "." ]
joke2k/faker
python
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/python/__init__.py#L141-L155
[ "def", "pydict", "(", "self", ",", "nb_elements", "=", "10", ",", "variable_nb_elements", "=", "True", ",", "*", "value_types", ")", ":", "if", "variable_nb_elements", ":", "nb_elements", "=", "self", ".", "randomize_nb_elements", "(", "nb_elements", ",", "min...
965824b61132e52d92d1a6ce470396dbbe01c96c
train
Provider.postcode
See http://web.archive.org/web/20090930140939/http://www.govtalk.gov.uk/gdsc/html/noframes/PostCode-2-1-Release.htm
faker/providers/address/en_GB/__init__.py
def postcode(self): """ See http://web.archive.org/web/20090930140939/http://www.govtalk.gov.uk/gdsc/html/noframes/PostCode-2-1-Release.htm """ postcode = '' pattern = self.random_element(self.postcode_formats) for placeholder in pattern: postcode += s...
def postcode(self): """ See http://web.archive.org/web/20090930140939/http://www.govtalk.gov.uk/gdsc/html/noframes/PostCode-2-1-Release.htm """ postcode = '' pattern = self.random_element(self.postcode_formats) for placeholder in pattern: postcode += s...
[ "See", "http", ":", "//", "web", ".", "archive", ".", "org", "/", "web", "/", "20090930140939", "/", "http", ":", "//", "www", ".", "govtalk", ".", "gov", ".", "uk", "/", "gdsc", "/", "html", "/", "noframes", "/", "PostCode", "-", "2", "-", "1", ...
joke2k/faker
python
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/address/en_GB/__init__.py#L317-L326
[ "def", "postcode", "(", "self", ")", ":", "postcode", "=", "''", "pattern", "=", "self", ".", "random_element", "(", "self", ".", "postcode_formats", ")", "for", "placeholder", "in", "pattern", ":", "postcode", "+=", "self", ".", "random_element", "(", "se...
965824b61132e52d92d1a6ce470396dbbe01c96c
train
Provider.ssn
Generates Hungarian SSN equivalent (személyazonosító szám or, colloquially, személyi szám) :param dob: date of birth as a "YYMMDD" string - this determines the checksum regime and is also encoded in the személyazonosító szám. :type dob: str :param gender: gender of the person - "F" ...
faker/providers/ssn/hu_HU/__init__.py
def ssn(self, dob=None, gender=None): """ Generates Hungarian SSN equivalent (személyazonosító szám or, colloquially, személyi szám) :param dob: date of birth as a "YYMMDD" string - this determines the checksum regime and is also encoded in the személyazonosító szám. :type d...
def ssn(self, dob=None, gender=None): """ Generates Hungarian SSN equivalent (személyazonosító szám or, colloquially, személyi szám) :param dob: date of birth as a "YYMMDD" string - this determines the checksum regime and is also encoded in the személyazonosító szám. :type d...
[ "Generates", "Hungarian", "SSN", "equivalent", "(", "személyazonosító", "szám", "or", "colloquially", "személyi", "szám", ")" ]
joke2k/faker
python
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/ssn/hu_HU/__init__.py#L16-L130
[ "def", "ssn", "(", "self", ",", "dob", "=", "None", ",", "gender", "=", "None", ")", ":", "# Hungarian SSNs consist of 11 decimal characters, of the following", "# schema:", "#", "# M EEHHNN SSSK", "# ↑ ↑ ↑ ↑", "# gender bday ser check digit", "#", "#", ...
965824b61132e52d92d1a6ce470396dbbe01c96c
train
Provider.postcode_in_state
:example '4703'
faker/providers/address/hy_AM/__init__.py
def postcode_in_state(self, state_abbr=None): """ :example '4703' """ if state_abbr is None: state_abbr = self.random_element(self.states_abbr) if state_abbr in self.states_abbr: postcode = "%d" % (self.generator.random.randint( ...
def postcode_in_state(self, state_abbr=None): """ :example '4703' """ if state_abbr is None: state_abbr = self.random_element(self.states_abbr) if state_abbr in self.states_abbr: postcode = "%d" % (self.generator.random.randint( ...
[ ":", "example", "4703" ]
joke2k/faker
python
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/address/hy_AM/__init__.py#L622-L640
[ "def", "postcode_in_state", "(", "self", ",", "state_abbr", "=", "None", ")", ":", "if", "state_abbr", "is", "None", ":", "state_abbr", "=", "self", ".", "random_element", "(", "self", ".", "states_abbr", ")", "if", "state_abbr", "in", "self", ".", "states...
965824b61132e52d92d1a6ce470396dbbe01c96c