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 | get_mac_address | Returns the Mac Address given a device index
:param device_index: (int) Device index
:return: (str) Mac address or None | pycons3rt/bash.py | def get_mac_address(device_index=0):
"""Returns the Mac Address given a device index
:param device_index: (int) Device index
:return: (str) Mac address or None
"""
log = logging.getLogger(mod_logger + '.get_mac_address')
command = ['ip', 'addr', 'show', 'eth{d}'.format(d=device_index)]
log.... | def get_mac_address(device_index=0):
"""Returns the Mac Address given a device index
:param device_index: (int) Device index
:return: (str) Mac address or None
"""
log = logging.getLogger(mod_logger + '.get_mac_address')
command = ['ip', 'addr', 'show', 'eth{d}'.format(d=device_index)]
log.... | [
"Returns",
"the",
"Mac",
"Address",
"given",
"a",
"device",
"index"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/bash.py#L270-L298 | [
"def",
"get_mac_address",
"(",
"device_index",
"=",
"0",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.get_mac_address'",
")",
"command",
"=",
"[",
"'ip'",
",",
"'addr'",
",",
"'show'",
",",
"'eth{d}'",
".",
"format",
"(",
... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | chmod | Emulates bash chmod command
This method sets the file permissions to the specified mode.
:param path: (str) Full path to the file or directory
:param mode: (str) Mode to be set (e.g. 0755)
:param recursive: (bool) Set True to make a recursive call
:return: int exit code of the chmod command
:r... | pycons3rt/bash.py | def chmod(path, mode, recursive=False):
"""Emulates bash chmod command
This method sets the file permissions to the specified mode.
:param path: (str) Full path to the file or directory
:param mode: (str) Mode to be set (e.g. 0755)
:param recursive: (bool) Set True to make a recursive call
:re... | def chmod(path, mode, recursive=False):
"""Emulates bash chmod command
This method sets the file permissions to the specified mode.
:param path: (str) Full path to the file or directory
:param mode: (str) Mode to be set (e.g. 0755)
:param recursive: (bool) Set True to make a recursive call
:re... | [
"Emulates",
"bash",
"chmod",
"command"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/bash.py#L301-L342 | [
"def",
"chmod",
"(",
"path",
",",
"mode",
",",
"recursive",
"=",
"False",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.chmod'",
")",
"# Validate args",
"if",
"not",
"isinstance",
"(",
"path",
",",
"basestring",
")",
":",
... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | mkdir_p | Emulates 'mkdir -p' in bash
:param path: (str) Path to create
:return: None
:raises CommandError | pycons3rt/bash.py | def mkdir_p(path):
"""Emulates 'mkdir -p' in bash
:param path: (str) Path to create
:return: None
:raises CommandError
"""
log = logging.getLogger(mod_logger + '.mkdir_p')
if not isinstance(path, basestring):
msg = 'path argument is not a string'
log.error(msg)
raise... | def mkdir_p(path):
"""Emulates 'mkdir -p' in bash
:param path: (str) Path to create
:return: None
:raises CommandError
"""
log = logging.getLogger(mod_logger + '.mkdir_p')
if not isinstance(path, basestring):
msg = 'path argument is not a string'
log.error(msg)
raise... | [
"Emulates",
"mkdir",
"-",
"p",
"in",
"bash"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/bash.py#L345-L366 | [
"def",
"mkdir_p",
"(",
"path",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.mkdir_p'",
")",
"if",
"not",
"isinstance",
"(",
"path",
",",
"basestring",
")",
":",
"msg",
"=",
"'path argument is not a string'",
"log",
".",
"er... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | source | Emulates 'source' command in bash
:param script: (str) Full path to the script to source
:return: Updated environment
:raises CommandError | pycons3rt/bash.py | def source(script):
"""Emulates 'source' command in bash
:param script: (str) Full path to the script to source
:return: Updated environment
:raises CommandError
"""
log = logging.getLogger(mod_logger + '.source')
if not isinstance(script, basestring):
msg = 'script argument must be... | def source(script):
"""Emulates 'source' command in bash
:param script: (str) Full path to the script to source
:return: Updated environment
:raises CommandError
"""
log = logging.getLogger(mod_logger + '.source')
if not isinstance(script, basestring):
msg = 'script argument must be... | [
"Emulates",
"source",
"command",
"in",
"bash"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/bash.py#L369-L417 | [
"def",
"source",
"(",
"script",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.source'",
")",
"if",
"not",
"isinstance",
"(",
"script",
",",
"basestring",
")",
":",
"msg",
"=",
"'script argument must be a string'",
"log",
".",
... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | yum_update | Run a yum update on this system
This public method runs the yum -y update command to update
packages from yum. If downloadonly is set to true, the yum
updates will be downloaded to the specified dest_dir.
:param dest_dir: (str) Full path to the download directory
:param downloadonly: Boolean
:... | pycons3rt/bash.py | def yum_update(downloadonly=False, dest_dir='/tmp'):
"""Run a yum update on this system
This public method runs the yum -y update command to update
packages from yum. If downloadonly is set to true, the yum
updates will be downloaded to the specified dest_dir.
:param dest_dir: (str) Full path to t... | def yum_update(downloadonly=False, dest_dir='/tmp'):
"""Run a yum update on this system
This public method runs the yum -y update command to update
packages from yum. If downloadonly is set to true, the yum
updates will be downloaded to the specified dest_dir.
:param dest_dir: (str) Full path to t... | [
"Run",
"a",
"yum",
"update",
"on",
"this",
"system"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/bash.py#L420-L473 | [
"def",
"yum_update",
"(",
"downloadonly",
"=",
"False",
",",
"dest_dir",
"=",
"'/tmp'",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.yum_update'",
")",
"# Type checks on the args",
"if",
"not",
"isinstance",
"(",
"dest_dir",
",... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | yum_install | Installs (or downloads) a list of packages from yum
This public method installs a list of packages from yum or
downloads the packages to the specified destination directory using
the yum-downloadonly yum plugin.
:param downloadonly: Boolean, set to only download the package and
not install it
... | pycons3rt/bash.py | def yum_install(packages, downloadonly=False, dest_dir='/tmp'):
"""Installs (or downloads) a list of packages from yum
This public method installs a list of packages from yum or
downloads the packages to the specified destination directory using
the yum-downloadonly yum plugin.
:param downloadonly... | def yum_install(packages, downloadonly=False, dest_dir='/tmp'):
"""Installs (or downloads) a list of packages from yum
This public method installs a list of packages from yum or
downloads the packages to the specified destination directory using
the yum-downloadonly yum plugin.
:param downloadonly... | [
"Installs",
"(",
"or",
"downloads",
")",
"a",
"list",
"of",
"packages",
"from",
"yum"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/bash.py#L476-L546 | [
"def",
"yum_install",
"(",
"packages",
",",
"downloadonly",
"=",
"False",
",",
"dest_dir",
"=",
"'/tmp'",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.yum_install'",
")",
"# Type checks on the args",
"if",
"not",
"isinstance",
... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | rpm_install | This method installs all RPM files in a specific dir
:param install_dir: (str) Full path to the directory
:return int exit code form the rpm command
:raises CommandError | pycons3rt/bash.py | def rpm_install(install_dir):
"""This method installs all RPM files in a specific dir
:param install_dir: (str) Full path to the directory
:return int exit code form the rpm command
:raises CommandError
"""
log = logging.getLogger(mod_logger + '.rpm_install')
# Type checks on the args
... | def rpm_install(install_dir):
"""This method installs all RPM files in a specific dir
:param install_dir: (str) Full path to the directory
:return int exit code form the rpm command
:raises CommandError
"""
log = logging.getLogger(mod_logger + '.rpm_install')
# Type checks on the args
... | [
"This",
"method",
"installs",
"all",
"RPM",
"files",
"in",
"a",
"specific",
"dir"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/bash.py#L549-L580 | [
"def",
"rpm_install",
"(",
"install_dir",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.rpm_install'",
")",
"# Type checks on the args",
"if",
"not",
"isinstance",
"(",
"install_dir",
",",
"basestring",
")",
":",
"msg",
"=",
"'i... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | sed | Python impl of the bash sed command
This method emulates the functionality of a bash sed command.
:param file_path: (str) Full path to the file to be edited
:param pattern: (str) Search pattern to replace as a regex
:param replace_str: (str) String to replace the pattern
:param g: (int) Whether to... | pycons3rt/bash.py | def sed(file_path, pattern, replace_str, g=0):
"""Python impl of the bash sed command
This method emulates the functionality of a bash sed command.
:param file_path: (str) Full path to the file to be edited
:param pattern: (str) Search pattern to replace as a regex
:param replace_str: (str) String... | def sed(file_path, pattern, replace_str, g=0):
"""Python impl of the bash sed command
This method emulates the functionality of a bash sed command.
:param file_path: (str) Full path to the file to be edited
:param pattern: (str) Search pattern to replace as a regex
:param replace_str: (str) String... | [
"Python",
"impl",
"of",
"the",
"bash",
"sed",
"command"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/bash.py#L583-L627 | [
"def",
"sed",
"(",
"file_path",
",",
"pattern",
",",
"replace_str",
",",
"g",
"=",
"0",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.sed'",
")",
"# Type checks on the args",
"if",
"not",
"isinstance",
"(",
"file_path",
",",... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | zip_dir | Creates a zip file of a directory tree
This method creates a zip archive using the directory tree dir_path
and adds to zip_file output.
:param dir_path: (str) Full path to directory to be zipped
:param zip_file: (str) Full path to the output zip file
:return: None
:raises CommandError | pycons3rt/bash.py | def zip_dir(dir_path, zip_file):
"""Creates a zip file of a directory tree
This method creates a zip archive using the directory tree dir_path
and adds to zip_file output.
:param dir_path: (str) Full path to directory to be zipped
:param zip_file: (str) Full path to the output zip file
:return... | def zip_dir(dir_path, zip_file):
"""Creates a zip file of a directory tree
This method creates a zip archive using the directory tree dir_path
and adds to zip_file output.
:param dir_path: (str) Full path to directory to be zipped
:param zip_file: (str) Full path to the output zip file
:return... | [
"Creates",
"a",
"zip",
"file",
"of",
"a",
"directory",
"tree"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/bash.py#L630-L674 | [
"def",
"zip_dir",
"(",
"dir_path",
",",
"zip_file",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.zip_dir'",
")",
"# Validate args",
"if",
"not",
"isinstance",
"(",
"dir_path",
",",
"basestring",
")",
":",
"msg",
"=",
"'dir_... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | get_ip | This method return the IP address
:param interface: (int) Interface number (e.g. 0 for eth0)
:return: (str) IP address or None | pycons3rt/bash.py | def get_ip(interface=0):
"""This method return the IP address
:param interface: (int) Interface number (e.g. 0 for eth0)
:return: (str) IP address or None
"""
log = logging.getLogger(mod_logger + '.get_ip')
log.info('Getting the IP address for this system...')
ip_address = None
try:
... | def get_ip(interface=0):
"""This method return the IP address
:param interface: (int) Interface number (e.g. 0 for eth0)
:return: (str) IP address or None
"""
log = logging.getLogger(mod_logger + '.get_ip')
log.info('Getting the IP address for this system...')
ip_address = None
try:
... | [
"This",
"method",
"return",
"the",
"IP",
"address"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/bash.py#L677-L719 | [
"def",
"get_ip",
"(",
"interface",
"=",
"0",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.get_ip'",
")",
"log",
".",
"info",
"(",
"'Getting the IP address for this system...'",
")",
"ip_address",
"=",
"None",
"try",
":",
"log... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | update_hosts_file | Updates the /etc/hosts file for the specified ip
This method updates the /etc/hosts file for the specified IP
address with the specified entry.
:param ip: (str) IP address to be added or updated
:param entry: (str) Hosts file entry to be added
:return: None
:raises CommandError | pycons3rt/bash.py | def update_hosts_file(ip, entry):
"""Updates the /etc/hosts file for the specified ip
This method updates the /etc/hosts file for the specified IP
address with the specified entry.
:param ip: (str) IP address to be added or updated
:param entry: (str) Hosts file entry to be added
:return: None... | def update_hosts_file(ip, entry):
"""Updates the /etc/hosts file for the specified ip
This method updates the /etc/hosts file for the specified IP
address with the specified entry.
:param ip: (str) IP address to be added or updated
:param entry: (str) Hosts file entry to be added
:return: None... | [
"Updates",
"the",
"/",
"etc",
"/",
"hosts",
"file",
"for",
"the",
"specified",
"ip"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/bash.py#L722-L776 | [
"def",
"update_hosts_file",
"(",
"ip",
",",
"entry",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.update_hosts_file'",
")",
"# Validate args",
"if",
"not",
"isinstance",
"(",
"ip",
",",
"basestring",
")",
":",
"msg",
"=",
"... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | set_hostname | Sets this hosts hostname
This method updates /etc/sysconfig/network and calls the hostname
command to set a hostname on a Linux system.
:param new_hostname: (str) New hostname
:param pretty_hostname: (str) new pretty hostname, set to the same as
new_hostname if not provided
:return (int) e... | pycons3rt/bash.py | def set_hostname(new_hostname, pretty_hostname=None):
"""Sets this hosts hostname
This method updates /etc/sysconfig/network and calls the hostname
command to set a hostname on a Linux system.
:param new_hostname: (str) New hostname
:param pretty_hostname: (str) new pretty hostname, set to the sam... | def set_hostname(new_hostname, pretty_hostname=None):
"""Sets this hosts hostname
This method updates /etc/sysconfig/network and calls the hostname
command to set a hostname on a Linux system.
:param new_hostname: (str) New hostname
:param pretty_hostname: (str) new pretty hostname, set to the sam... | [
"Sets",
"this",
"hosts",
"hostname"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/bash.py#L779-L847 | [
"def",
"set_hostname",
"(",
"new_hostname",
",",
"pretty_hostname",
"=",
"None",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.set_hostname'",
")",
"# Ensure the hostname is a str",
"if",
"not",
"isinstance",
"(",
"new_hostname",
",... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | set_ntp_server | Sets the NTP server on Linux
:param server: (str) NTP server IP or hostname
:return: None
:raises CommandError | pycons3rt/bash.py | def set_ntp_server(server):
"""Sets the NTP server on Linux
:param server: (str) NTP server IP or hostname
:return: None
:raises CommandError
"""
log = logging.getLogger(mod_logger + '.set_ntp_server')
# Ensure the hostname is a str
if not isinstance(server, basestring):
msg = ... | def set_ntp_server(server):
"""Sets the NTP server on Linux
:param server: (str) NTP server IP or hostname
:return: None
:raises CommandError
"""
log = logging.getLogger(mod_logger + '.set_ntp_server')
# Ensure the hostname is a str
if not isinstance(server, basestring):
msg = ... | [
"Sets",
"the",
"NTP",
"server",
"on",
"Linux"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/bash.py#L850-L882 | [
"def",
"set_ntp_server",
"(",
"server",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.set_ntp_server'",
")",
"# Ensure the hostname is a str",
"if",
"not",
"isinstance",
"(",
"server",
",",
"basestring",
")",
":",
"msg",
"=",
"'... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | copy_ifcfg_file | Copies an existing ifcfg network script to another
:param source_interface: String (e.g. 1)
:param dest_interface: String (e.g. 0:0)
:return: None
:raises TypeError, OSError | pycons3rt/bash.py | def copy_ifcfg_file(source_interface, dest_interface):
"""Copies an existing ifcfg network script to another
:param source_interface: String (e.g. 1)
:param dest_interface: String (e.g. 0:0)
:return: None
:raises TypeError, OSError
"""
log = logging.getLogger(mod_logger + '.copy_ifcfg_file'... | def copy_ifcfg_file(source_interface, dest_interface):
"""Copies an existing ifcfg network script to another
:param source_interface: String (e.g. 1)
:param dest_interface: String (e.g. 0:0)
:return: None
:raises TypeError, OSError
"""
log = logging.getLogger(mod_logger + '.copy_ifcfg_file'... | [
"Copies",
"an",
"existing",
"ifcfg",
"network",
"script",
"to",
"another"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/bash.py#L885-L955 | [
"def",
"copy_ifcfg_file",
"(",
"source_interface",
",",
"dest_interface",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.copy_ifcfg_file'",
")",
"# Validate args",
"if",
"not",
"isinstance",
"(",
"source_interface",
",",
"basestring",
... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | remove_ifcfg_file | Removes the ifcfg file at the specified device index
and restarts the network service
:param device_index: (int) Device Index
:return: None
:raises CommandError | pycons3rt/bash.py | def remove_ifcfg_file(device_index='0'):
"""Removes the ifcfg file at the specified device index
and restarts the network service
:param device_index: (int) Device Index
:return: None
:raises CommandError
"""
log = logging.getLogger(mod_logger + '.remove_ifcfg_file')
if not isinstance(d... | def remove_ifcfg_file(device_index='0'):
"""Removes the ifcfg file at the specified device index
and restarts the network service
:param device_index: (int) Device Index
:return: None
:raises CommandError
"""
log = logging.getLogger(mod_logger + '.remove_ifcfg_file')
if not isinstance(d... | [
"Removes",
"the",
"ifcfg",
"file",
"at",
"the",
"specified",
"device",
"index",
"and",
"restarts",
"the",
"network",
"service"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/bash.py#L958-L998 | [
"def",
"remove_ifcfg_file",
"(",
"device_index",
"=",
"'0'",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.remove_ifcfg_file'",
")",
"if",
"not",
"isinstance",
"(",
"device_index",
",",
"basestring",
")",
":",
"msg",
"=",
"'de... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | add_nat_rule | Adds a NAT rule to iptables
:param port: String or int port number
:param source_interface: String (e.g. 1)
:param dest_interface: String (e.g. 0:0)
:return: None
:raises: TypeError, OSError | pycons3rt/bash.py | def add_nat_rule(port, source_interface, dest_interface):
"""Adds a NAT rule to iptables
:param port: String or int port number
:param source_interface: String (e.g. 1)
:param dest_interface: String (e.g. 0:0)
:return: None
:raises: TypeError, OSError
"""
log = logging.getLogger(mod_log... | def add_nat_rule(port, source_interface, dest_interface):
"""Adds a NAT rule to iptables
:param port: String or int port number
:param source_interface: String (e.g. 1)
:param dest_interface: String (e.g. 0:0)
:return: None
:raises: TypeError, OSError
"""
log = logging.getLogger(mod_log... | [
"Adds",
"a",
"NAT",
"rule",
"to",
"iptables"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/bash.py#L1001-L1052 | [
"def",
"add_nat_rule",
"(",
"port",
",",
"source_interface",
",",
"dest_interface",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.add_nat_rule'",
")",
"# Validate args",
"if",
"not",
"isinstance",
"(",
"source_interface",
",",
"ba... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | service_network_restart | Restarts the network service on linux
:return: None
:raises CommandError | pycons3rt/bash.py | def service_network_restart():
"""Restarts the network service on linux
:return: None
:raises CommandError
"""
log = logging.getLogger(mod_logger + '.service_network_restart')
command = ['service', 'network', 'restart']
time.sleep(5)
try:
result = run_command(command)
tim... | def service_network_restart():
"""Restarts the network service on linux
:return: None
:raises CommandError
"""
log = logging.getLogger(mod_logger + '.service_network_restart')
command = ['service', 'network', 'restart']
time.sleep(5)
try:
result = run_command(command)
tim... | [
"Restarts",
"the",
"network",
"service",
"on",
"linux",
":",
"return",
":",
"None",
":",
"raises",
"CommandError"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/bash.py#L1055-L1076 | [
"def",
"service_network_restart",
"(",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.service_network_restart'",
")",
"command",
"=",
"[",
"'service'",
",",
"'network'",
",",
"'restart'",
"]",
"time",
".",
"sleep",
"(",
"5",
")... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | save_iptables | Saves iptables rules to the provided rules file
:return: None
:raises OSError | pycons3rt/bash.py | def save_iptables(rules_file='/etc/sysconfig/iptables'):
"""Saves iptables rules to the provided rules file
:return: None
:raises OSError
"""
log = logging.getLogger(mod_logger + '.save_iptables')
# Run iptables-save to get the output
command = ['iptables-save']
log.debug('Running comm... | def save_iptables(rules_file='/etc/sysconfig/iptables'):
"""Saves iptables rules to the provided rules file
:return: None
:raises OSError
"""
log = logging.getLogger(mod_logger + '.save_iptables')
# Run iptables-save to get the output
command = ['iptables-save']
log.debug('Running comm... | [
"Saves",
"iptables",
"rules",
"to",
"the",
"provided",
"rules",
"file"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/bash.py#L1079-L1112 | [
"def",
"save_iptables",
"(",
"rules_file",
"=",
"'/etc/sysconfig/iptables'",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.save_iptables'",
")",
"# Run iptables-save to get the output",
"command",
"=",
"[",
"'iptables-save'",
"]",
"log"... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | get_remote_host_environment_variable | Retrieves the value of an environment variable of a
remote host over SSH
:param host: (str) host to query
:param environment_variable: (str) variable to query
:return: (str) value of the environment variable
:raises: TypeError, CommandError | pycons3rt/bash.py | def get_remote_host_environment_variable(host, environment_variable):
"""Retrieves the value of an environment variable of a
remote host over SSH
:param host: (str) host to query
:param environment_variable: (str) variable to query
:return: (str) value of the environment variable
:raises: TypeE... | def get_remote_host_environment_variable(host, environment_variable):
"""Retrieves the value of an environment variable of a
remote host over SSH
:param host: (str) host to query
:param environment_variable: (str) variable to query
:return: (str) value of the environment variable
:raises: TypeE... | [
"Retrieves",
"the",
"value",
"of",
"an",
"environment",
"variable",
"of",
"a",
"remote",
"host",
"over",
"SSH"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/bash.py#L1115-L1149 | [
"def",
"get_remote_host_environment_variable",
"(",
"host",
",",
"environment_variable",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.get_remote_host_environment_variable'",
")",
"if",
"not",
"isinstance",
"(",
"host",
",",
"basestring... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | set_remote_host_environment_variable | Sets an environment variable on the remote host in the
specified environment file
:param host: (str) host to set environment variable on
:param variable_name: (str) name of the variable
:param variable_value: (str) value of the variable
:param env_file: (str) full path to the environment file to se... | pycons3rt/bash.py | def set_remote_host_environment_variable(host, variable_name, variable_value, env_file='/etc/bashrc'):
"""Sets an environment variable on the remote host in the
specified environment file
:param host: (str) host to set environment variable on
:param variable_name: (str) name of the variable
:param ... | def set_remote_host_environment_variable(host, variable_name, variable_value, env_file='/etc/bashrc'):
"""Sets an environment variable on the remote host in the
specified environment file
:param host: (str) host to set environment variable on
:param variable_name: (str) name of the variable
:param ... | [
"Sets",
"an",
"environment",
"variable",
"on",
"the",
"remote",
"host",
"in",
"the",
"specified",
"environment",
"file"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/bash.py#L1152-L1223 | [
"def",
"set_remote_host_environment_variable",
"(",
"host",
",",
"variable_name",
",",
"variable_value",
",",
"env_file",
"=",
"'/etc/bashrc'",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.set_remote_host_environment_variable'",
")",
"... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | run_remote_command | Retrieves the value of an environment variable of a
remote host over SSH
:param host: (str) host to query
:param command: (str) command
:param timeout_sec (float) seconds to wait before killing the command.
:return: (str) command output
:raises: TypeError, CommandError | pycons3rt/bash.py | def run_remote_command(host, command, timeout_sec=5.0):
"""Retrieves the value of an environment variable of a
remote host over SSH
:param host: (str) host to query
:param command: (str) command
:param timeout_sec (float) seconds to wait before killing the command.
:return: (str) command output... | def run_remote_command(host, command, timeout_sec=5.0):
"""Retrieves the value of an environment variable of a
remote host over SSH
:param host: (str) host to query
:param command: (str) command
:param timeout_sec (float) seconds to wait before killing the command.
:return: (str) command output... | [
"Retrieves",
"the",
"value",
"of",
"an",
"environment",
"variable",
"of",
"a",
"remote",
"host",
"over",
"SSH"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/bash.py#L1226-L1262 | [
"def",
"run_remote_command",
"(",
"host",
",",
"command",
",",
"timeout_sec",
"=",
"5.0",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.run_remote_command'",
")",
"if",
"not",
"isinstance",
"(",
"host",
",",
"basestring",
")",... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | check_remote_host_marker_file | Queries a remote host over SSH to check for existence
of a marker file
:param host: (str) host to query
:param file_path: (str) path to the marker file
:return: (bool) True if the marker file exists
:raises: TypeError, CommandError | pycons3rt/bash.py | def check_remote_host_marker_file(host, file_path):
"""Queries a remote host over SSH to check for existence
of a marker file
:param host: (str) host to query
:param file_path: (str) path to the marker file
:return: (bool) True if the marker file exists
:raises: TypeError, CommandError
"""
... | def check_remote_host_marker_file(host, file_path):
"""Queries a remote host over SSH to check for existence
of a marker file
:param host: (str) host to query
:param file_path: (str) path to the marker file
:return: (bool) True if the marker file exists
:raises: TypeError, CommandError
"""
... | [
"Queries",
"a",
"remote",
"host",
"over",
"SSH",
"to",
"check",
"for",
"existence",
"of",
"a",
"marker",
"file"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/bash.py#L1265-L1302 | [
"def",
"check_remote_host_marker_file",
"(",
"host",
",",
"file_path",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.check_remote_host_marker_file'",
")",
"if",
"not",
"isinstance",
"(",
"host",
",",
"basestring",
")",
":",
"msg",... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | restore_iptables | Restores and saves firewall rules from the firewall_rules file
:param firewall_rules: (str) Full path to the firewall rules file
:return: None
:raises OSError | pycons3rt/bash.py | def restore_iptables(firewall_rules):
"""Restores and saves firewall rules from the firewall_rules file
:param firewall_rules: (str) Full path to the firewall rules file
:return: None
:raises OSError
"""
log = logging.getLogger(mod_logger + '.restore_iptables')
log.info('Restoring firewall ... | def restore_iptables(firewall_rules):
"""Restores and saves firewall rules from the firewall_rules file
:param firewall_rules: (str) Full path to the firewall rules file
:return: None
:raises OSError
"""
log = logging.getLogger(mod_logger + '.restore_iptables')
log.info('Restoring firewall ... | [
"Restores",
"and",
"saves",
"firewall",
"rules",
"from",
"the",
"firewall_rules",
"file"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/bash.py#L1339-L1377 | [
"def",
"restore_iptables",
"(",
"firewall_rules",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.restore_iptables'",
")",
"log",
".",
"info",
"(",
"'Restoring firewall rules from file: {f}'",
".",
"format",
"(",
"f",
"=",
"firewall_r... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | remove_default_gateway | Removes Default Gateway configuration from /etc/sysconfig/network
and restarts networking
:return: None
:raises: OSError | pycons3rt/bash.py | def remove_default_gateway():
"""Removes Default Gateway configuration from /etc/sysconfig/network
and restarts networking
:return: None
:raises: OSError
"""
log = logging.getLogger(mod_logger + '.remove_default_gateway')
# Ensure the network script exists
network_script = '/etc/sy... | def remove_default_gateway():
"""Removes Default Gateway configuration from /etc/sysconfig/network
and restarts networking
:return: None
:raises: OSError
"""
log = logging.getLogger(mod_logger + '.remove_default_gateway')
# Ensure the network script exists
network_script = '/etc/sy... | [
"Removes",
"Default",
"Gateway",
"configuration",
"from",
"/",
"etc",
"/",
"sysconfig",
"/",
"network",
"and",
"restarts",
"networking",
":",
"return",
":",
"None",
":",
"raises",
":",
"OSError"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/bash.py#L1380-L1416 | [
"def",
"remove_default_gateway",
"(",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.remove_default_gateway'",
")",
"# Ensure the network script exists",
"network_script",
"=",
"'/etc/sysconfig/network'",
"if",
"not",
"os",
".",
"path",
... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | is_systemd | Determines whether this system uses systemd
:return: (bool) True if this distro has systemd | pycons3rt/bash.py | def is_systemd():
"""Determines whether this system uses systemd
:return: (bool) True if this distro has systemd
"""
os_family = platform.system()
if os_family != 'Linux':
raise OSError('This method is only supported on Linux, found OS: {o}'.format(o=os_family))
linux_distro, linux_vers... | def is_systemd():
"""Determines whether this system uses systemd
:return: (bool) True if this distro has systemd
"""
os_family = platform.system()
if os_family != 'Linux':
raise OSError('This method is only supported on Linux, found OS: {o}'.format(o=os_family))
linux_distro, linux_vers... | [
"Determines",
"whether",
"this",
"system",
"uses",
"systemd"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/bash.py#L1419-L1437 | [
"def",
"is_systemd",
"(",
")",
":",
"os_family",
"=",
"platform",
".",
"system",
"(",
")",
"if",
"os_family",
"!=",
"'Linux'",
":",
"raise",
"OSError",
"(",
"'This method is only supported on Linux, found OS: {o}'",
".",
"format",
"(",
"o",
"=",
"os_family",
")"... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | manage_service | Use to run Linux sysv or systemd service commands
:param service_name (str) name of the service to start
:param service_action (str) action to perform on the service
:param systemd (bool) True if the command should use systemd
:param output (bool) True to print output
:return: None
:raises: OSE... | pycons3rt/bash.py | def manage_service(service_name, service_action='status', systemd=None, output=True):
"""Use to run Linux sysv or systemd service commands
:param service_name (str) name of the service to start
:param service_action (str) action to perform on the service
:param systemd (bool) True if the command should... | def manage_service(service_name, service_action='status', systemd=None, output=True):
"""Use to run Linux sysv or systemd service commands
:param service_name (str) name of the service to start
:param service_action (str) action to perform on the service
:param systemd (bool) True if the command should... | [
"Use",
"to",
"run",
"Linux",
"sysv",
"or",
"systemd",
"service",
"commands"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/bash.py#L1440-L1511 | [
"def",
"manage_service",
"(",
"service_name",
",",
"service_action",
"=",
"'status'",
",",
"systemd",
"=",
"None",
",",
"output",
"=",
"True",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.manage_service'",
")",
"# Ensure the se... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | system_reboot | Reboots the system after a specified wait time. Must be run as root
:param wait_time_sec: (int) number of sec to wait before performing the reboot
:return: None
:raises: SystemRebootError, SystemRebootTimeoutError | pycons3rt/bash.py | def system_reboot(wait_time_sec=20):
"""Reboots the system after a specified wait time. Must be run as root
:param wait_time_sec: (int) number of sec to wait before performing the reboot
:return: None
:raises: SystemRebootError, SystemRebootTimeoutError
"""
log = logging.getLogger(mod_logger +... | def system_reboot(wait_time_sec=20):
"""Reboots the system after a specified wait time. Must be run as root
:param wait_time_sec: (int) number of sec to wait before performing the reboot
:return: None
:raises: SystemRebootError, SystemRebootTimeoutError
"""
log = logging.getLogger(mod_logger +... | [
"Reboots",
"the",
"system",
"after",
"a",
"specified",
"wait",
"time",
".",
"Must",
"be",
"run",
"as",
"root"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/bash.py#L1514-L1548 | [
"def",
"system_reboot",
"(",
"wait_time_sec",
"=",
"20",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.system_reboot'",
")",
"try",
":",
"wait_time_sec",
"=",
"int",
"(",
"wait_time_sec",
")",
"except",
"ValueError",
":",
"rai... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | main | Sample usage for this python module
This main method simply illustrates sample usage for this python
module.
:return: None | pycons3rt/bash.py | def main():
"""Sample usage for this python module
This main method simply illustrates sample usage for this python
module.
:return: None
"""
mkdir_p('/tmp/test/test')
source('/root/.bash_profile')
yum_install(['httpd', 'git'])
yum_install(['httpd', 'git'], dest_dir='/tmp/test/test... | def main():
"""Sample usage for this python module
This main method simply illustrates sample usage for this python
module.
:return: None
"""
mkdir_p('/tmp/test/test')
source('/root/.bash_profile')
yum_install(['httpd', 'git'])
yum_install(['httpd', 'git'], dest_dir='/tmp/test/test... | [
"Sample",
"usage",
"for",
"this",
"python",
"module"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/bash.py#L1551-L1567 | [
"def",
"main",
"(",
")",
":",
"mkdir_p",
"(",
"'/tmp/test/test'",
")",
"source",
"(",
"'/root/.bash_profile'",
")",
"yum_install",
"(",
"[",
"'httpd'",
",",
"'git'",
"]",
")",
"yum_install",
"(",
"[",
"'httpd'",
",",
"'git'",
"]",
",",
"dest_dir",
"=",
"... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | log_event | Logs consistent event for easy parsing/analysis.
:param name: Name of the event. Will be logged as EVENT_XXX with XXX in capitals.
:param request: Django REST framework Request (optional)
:param data: Even data (optional)
:param ip: Even IP (optional) | jutil/logs.py | def log_event(name: str, request: Request=None, data=None, ip=None):
"""
Logs consistent event for easy parsing/analysis.
:param name: Name of the event. Will be logged as EVENT_XXX with XXX in capitals.
:param request: Django REST framework Request (optional)
:param data: Even data (optional)
:... | def log_event(name: str, request: Request=None, data=None, ip=None):
"""
Logs consistent event for easy parsing/analysis.
:param name: Name of the event. Will be logged as EVENT_XXX with XXX in capitals.
:param request: Django REST framework Request (optional)
:param data: Even data (optional)
:... | [
"Logs",
"consistent",
"event",
"for",
"easy",
"parsing",
"/",
"analysis",
".",
":",
"param",
"name",
":",
"Name",
"of",
"the",
"event",
".",
"Will",
"be",
"logged",
"as",
"EVENT_XXX",
"with",
"XXX",
"in",
"capitals",
".",
":",
"param",
"request",
":",
... | kajala/django-jutil | python | https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/logs.py#L10-L27 | [
"def",
"log_event",
"(",
"name",
":",
"str",
",",
"request",
":",
"Request",
"=",
"None",
",",
"data",
"=",
"None",
",",
"ip",
"=",
"None",
")",
":",
"log_data",
"=",
"{",
"}",
"if",
"not",
"ip",
"and",
"request",
":",
"ip",
"=",
"get_real_ip",
"... | 2abd93ebad51042744eaeb1ee1074ed0eb55ad0c |
train | aes_b64_encrypt | AES encrypt @value with @secret using the |CFB| mode of AES
with a cryptographically secure initialization vector.
-> (#str) AES encrypted @value
..
from vital.security import aes_encrypt, aes_decrypt
aes_encrypt("Hello, world",
"aLWEFlwgwlreWELF... | vital/security/__init__.py | def aes_b64_encrypt(value, secret, block_size=AES.block_size):
""" AES encrypt @value with @secret using the |CFB| mode of AES
with a cryptographically secure initialization vector.
-> (#str) AES encrypted @value
..
from vital.security import aes_encrypt, aes_decrypt
... | def aes_b64_encrypt(value, secret, block_size=AES.block_size):
""" AES encrypt @value with @secret using the |CFB| mode of AES
with a cryptographically secure initialization vector.
-> (#str) AES encrypted @value
..
from vital.security import aes_encrypt, aes_decrypt
... | [
"AES",
"encrypt",
"@value",
"with",
"@secret",
"using",
"the",
"|CFB|",
"mode",
"of",
"AES",
"with",
"a",
"cryptographically",
"secure",
"initialization",
"vector",
"."
] | jaredLunde/vital-tools | python | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/security/__init__.py#L31-L52 | [
"def",
"aes_b64_encrypt",
"(",
"value",
",",
"secret",
",",
"block_size",
"=",
"AES",
".",
"block_size",
")",
":",
"# iv = randstr(block_size * 2, rng=random)",
"iv",
"=",
"randstr",
"(",
"block_size",
"*",
"2",
")",
"cipher",
"=",
"AES",
".",
"new",
"(",
"s... | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 |
train | aes_b64_decrypt | AES decrypt @value with @secret using the |CFB| mode of AES
with a cryptographically secure initialization vector.
-> (#str) AES decrypted @value
..
from vital.security import aes_encrypt, aes_decrypt
aes_encrypt("Hello, world",
"aLWEFlwgwlreWELF... | vital/security/__init__.py | def aes_b64_decrypt(value, secret, block_size=AES.block_size):
""" AES decrypt @value with @secret using the |CFB| mode of AES
with a cryptographically secure initialization vector.
-> (#str) AES decrypted @value
..
from vital.security import aes_encrypt, aes_decrypt
... | def aes_b64_decrypt(value, secret, block_size=AES.block_size):
""" AES decrypt @value with @secret using the |CFB| mode of AES
with a cryptographically secure initialization vector.
-> (#str) AES decrypted @value
..
from vital.security import aes_encrypt, aes_decrypt
... | [
"AES",
"decrypt",
"@value",
"with",
"@secret",
"using",
"the",
"|CFB|",
"mode",
"of",
"AES",
"with",
"a",
"cryptographically",
"secure",
"initialization",
"vector",
"."
] | jaredLunde/vital-tools | python | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/security/__init__.py#L55-L76 | [
"def",
"aes_b64_decrypt",
"(",
"value",
",",
"secret",
",",
"block_size",
"=",
"AES",
".",
"block_size",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"iv",
"=",
"value",
"[",
":",
"block_size",
"]",
"cipher",
"=",
"AES",
".",
"new",
"(",
"secre... | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 |
train | aes_encrypt | AES encrypt @value with @secret using the |CFB| mode of AES
with a cryptographically secure initialization vector.
-> (#bytes) AES encrypted @value
..
from vital.security import aes_encrypt, aes_decrypt
aes_encrypt("Hello, world",
"aLWEFlwgwlreWE... | vital/security/__init__.py | def aes_encrypt(value, secret, block_size=AES.block_size):
""" AES encrypt @value with @secret using the |CFB| mode of AES
with a cryptographically secure initialization vector.
-> (#bytes) AES encrypted @value
..
from vital.security import aes_encrypt, aes_decrypt
... | def aes_encrypt(value, secret, block_size=AES.block_size):
""" AES encrypt @value with @secret using the |CFB| mode of AES
with a cryptographically secure initialization vector.
-> (#bytes) AES encrypted @value
..
from vital.security import aes_encrypt, aes_decrypt
... | [
"AES",
"encrypt",
"@value",
"with",
"@secret",
"using",
"the",
"|CFB|",
"mode",
"of",
"AES",
"with",
"a",
"cryptographically",
"secure",
"initialization",
"vector",
"."
] | jaredLunde/vital-tools | python | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/security/__init__.py#L79-L98 | [
"def",
"aes_encrypt",
"(",
"value",
",",
"secret",
",",
"block_size",
"=",
"AES",
".",
"block_size",
")",
":",
"iv",
"=",
"os",
".",
"urandom",
"(",
"block_size",
"*",
"2",
")",
"cipher",
"=",
"AES",
".",
"new",
"(",
"secret",
"[",
":",
"32",
"]",
... | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 |
train | aes_decrypt | AES decrypt @value with @secret using the |CFB| mode of AES
with a cryptographically secure initialization vector.
-> (#str) AES decrypted @value
..
from vital.security import aes_encrypt, aes_decrypt
aes_encrypt("Hello, world",
"aLWEFlwgwlreWELF... | vital/security/__init__.py | def aes_decrypt(value, secret, block_size=AES.block_size):
""" AES decrypt @value with @secret using the |CFB| mode of AES
with a cryptographically secure initialization vector.
-> (#str) AES decrypted @value
..
from vital.security import aes_encrypt, aes_decrypt
ae... | def aes_decrypt(value, secret, block_size=AES.block_size):
""" AES decrypt @value with @secret using the |CFB| mode of AES
with a cryptographically secure initialization vector.
-> (#str) AES decrypted @value
..
from vital.security import aes_encrypt, aes_decrypt
ae... | [
"AES",
"decrypt",
"@value",
"with",
"@secret",
"using",
"the",
"|CFB|",
"mode",
"of",
"AES",
"with",
"a",
"cryptographically",
"secure",
"initialization",
"vector",
"."
] | jaredLunde/vital-tools | python | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/security/__init__.py#L101-L120 | [
"def",
"aes_decrypt",
"(",
"value",
",",
"secret",
",",
"block_size",
"=",
"AES",
".",
"block_size",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"cipher",
"=",
"AES",
".",
"new",
"(",
"secret",
"[",
":",
"32",
"]",
",",
"AES",
".",
"MODE_CFB... | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 |
train | aes_pad | Adds padding to get the correct block sizes for AES encryption
@s: #str being AES encrypted or decrypted
@block_size: the AES block size
@padding: character to pad with
-> padded #str
..
from vital.security import aes_pad
aes_pad("swing")
# ... | vital/security/__init__.py | def aes_pad(s, block_size=32, padding='{'):
""" Adds padding to get the correct block sizes for AES encryption
@s: #str being AES encrypted or decrypted
@block_size: the AES block size
@padding: character to pad with
-> padded #str
..
from vital.security import... | def aes_pad(s, block_size=32, padding='{'):
""" Adds padding to get the correct block sizes for AES encryption
@s: #str being AES encrypted or decrypted
@block_size: the AES block size
@padding: character to pad with
-> padded #str
..
from vital.security import... | [
"Adds",
"padding",
"to",
"get",
"the",
"correct",
"block",
"sizes",
"for",
"AES",
"encryption"
] | jaredLunde/vital-tools | python | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/security/__init__.py#L123-L138 | [
"def",
"aes_pad",
"(",
"s",
",",
"block_size",
"=",
"32",
",",
"padding",
"=",
"'{'",
")",
":",
"return",
"s",
"+",
"(",
"block_size",
"-",
"len",
"(",
"s",
")",
"%",
"block_size",
")",
"*",
"padding"
] | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 |
train | lscmp | Compares two strings in a cryptographically safe way:
Runtime is not affected by length of common prefix, so this
is helpful against timing attacks.
..
from vital.security import lscmp
lscmp("ringo", "starr")
# -> False
lscmp("ringo", "ringo")
... | vital/security/__init__.py | def lscmp(a, b):
""" Compares two strings in a cryptographically safe way:
Runtime is not affected by length of common prefix, so this
is helpful against timing attacks.
..
from vital.security import lscmp
lscmp("ringo", "starr")
# -> False
ls... | def lscmp(a, b):
""" Compares two strings in a cryptographically safe way:
Runtime is not affected by length of common prefix, so this
is helpful against timing attacks.
..
from vital.security import lscmp
lscmp("ringo", "starr")
# -> False
ls... | [
"Compares",
"two",
"strings",
"in",
"a",
"cryptographically",
"safe",
"way",
":",
"Runtime",
"is",
"not",
"affected",
"by",
"length",
"of",
"common",
"prefix",
"so",
"this",
"is",
"helpful",
"against",
"timing",
"attacks",
"."
] | jaredLunde/vital-tools | python | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/security/__init__.py#L159-L173 | [
"def",
"lscmp",
"(",
"a",
",",
"b",
")",
":",
"l",
"=",
"len",
"return",
"not",
"sum",
"(",
"0",
"if",
"x",
"==",
"y",
"else",
"1",
"for",
"x",
",",
"y",
"in",
"zip",
"(",
"a",
",",
"b",
")",
")",
"and",
"l",
"(",
"a",
")",
"==",
"l",
... | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 |
train | cookie | Encodes or decodes a signed cookie.
@data: cookie data
@key_salt: HMAC key signing salt
@secret: HMAC signing secret key
@digestmod: hashing algorithm to sign with, recommended >=sha256
-> HMAC signed or unsigned cookie data
..
from vital.security import coo... | vital/security/__init__.py | def cookie(data, key_salt='', secret=None, digestmod=None):
""" Encodes or decodes a signed cookie.
@data: cookie data
@key_salt: HMAC key signing salt
@secret: HMAC signing secret key
@digestmod: hashing algorithm to sign with, recommended >=sha256
-> HMAC signed or unsigne... | def cookie(data, key_salt='', secret=None, digestmod=None):
""" Encodes or decodes a signed cookie.
@data: cookie data
@key_salt: HMAC key signing salt
@secret: HMAC signing secret key
@digestmod: hashing algorithm to sign with, recommended >=sha256
-> HMAC signed or unsigne... | [
"Encodes",
"or",
"decodes",
"a",
"signed",
"cookie",
".",
"@data",
":",
"cookie",
"data",
"@key_salt",
":",
"HMAC",
"key",
"signing",
"salt",
"@secret",
":",
"HMAC",
"signing",
"secret",
"key",
"@digestmod",
":",
"hashing",
"algorithm",
"to",
"sign",
"with",... | jaredLunde/vital-tools | python | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/security/__init__.py#L179-L222 | [
"def",
"cookie",
"(",
"data",
",",
"key_salt",
"=",
"''",
",",
"secret",
"=",
"None",
",",
"digestmod",
"=",
"None",
")",
":",
"digestmod",
"=",
"digestmod",
"or",
"sha256",
"if",
"not",
"data",
":",
"return",
"None",
"try",
":",
"# Decode signed cookie"... | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 |
train | strkey | Converts integers to a sequence of strings, and reverse.
This is not intended to obfuscate numbers in any kind of
cryptographically secure way, in fact it's the opposite. It's
for predictable, reversable, obfuscation. It can also be used to
transform a random bit integer to a string of t... | vital/security/__init__.py | def strkey(val, chaffify=1, keyspace=string.ascii_letters + string.digits):
""" Converts integers to a sequence of strings, and reverse.
This is not intended to obfuscate numbers in any kind of
cryptographically secure way, in fact it's the opposite. It's
for predictable, reversable, obfusca... | def strkey(val, chaffify=1, keyspace=string.ascii_letters + string.digits):
""" Converts integers to a sequence of strings, and reverse.
This is not intended to obfuscate numbers in any kind of
cryptographically secure way, in fact it's the opposite. It's
for predictable, reversable, obfusca... | [
"Converts",
"integers",
"to",
"a",
"sequence",
"of",
"strings",
"and",
"reverse",
".",
"This",
"is",
"not",
"intended",
"to",
"obfuscate",
"numbers",
"in",
"any",
"kind",
"of",
"cryptographically",
"secure",
"way",
"in",
"fact",
"it",
"s",
"the",
"opposite",... | jaredLunde/vital-tools | python | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/security/__init__.py#L241-L302 | [
"def",
"strkey",
"(",
"val",
",",
"chaffify",
"=",
"1",
",",
"keyspace",
"=",
"string",
".",
"ascii_letters",
"+",
"string",
".",
"digits",
")",
":",
"chaffify",
"=",
"chaffify",
"or",
"1",
"keylen",
"=",
"len",
"(",
"keyspace",
")",
"try",
":",
"# I... | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 |
train | chars_in | ..
log2(keyspace^x_chars) = bits
log(keyspace^x_chars) = log(2) * bits
exp(log(keyspace^x_chars)) = exp(log(2) * bits)
x_chars = log(exp(log(2) * bits)) / log(keyspace)
..
-> (#int) number of characters in @bits of entropy given the @keyspace | vital/security/__init__.py | def chars_in(bits, keyspace):
""" ..
log2(keyspace^x_chars) = bits
log(keyspace^x_chars) = log(2) * bits
exp(log(keyspace^x_chars)) = exp(log(2) * bits)
x_chars = log(exp(log(2) * bits)) / log(keyspace)
..
-> (#int) number of characters in @bits of entropy given the @... | def chars_in(bits, keyspace):
""" ..
log2(keyspace^x_chars) = bits
log(keyspace^x_chars) = log(2) * bits
exp(log(keyspace^x_chars)) = exp(log(2) * bits)
x_chars = log(exp(log(2) * bits)) / log(keyspace)
..
-> (#int) number of characters in @bits of entropy given the @... | [
"..",
"log2",
"(",
"keyspace^x_chars",
")",
"=",
"bits",
"log",
"(",
"keyspace^x_chars",
")",
"=",
"log",
"(",
"2",
")",
"*",
"bits",
"exp",
"(",
"log",
"(",
"keyspace^x_chars",
"))",
"=",
"exp",
"(",
"log",
"(",
"2",
")",
"*",
"bits",
")",
"x_char... | jaredLunde/vital-tools | python | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/security/__init__.py#L327-L351 | [
"def",
"chars_in",
"(",
"bits",
",",
"keyspace",
")",
":",
"keyspace",
"=",
"len",
"(",
"keyspace",
")",
"if",
"keyspace",
"<",
"2",
":",
"raise",
"ValueError",
"(",
"\"Keyspace size must be >1\"",
")",
"bits_per_cycle",
"=",
"512",
"if",
"bits",
">",
"bit... | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 |
train | bits_in | |log2(keyspace^length) = bits|
-> (#float) number of bits of entropy in @length of characters for
a given a @keyspace | vital/security/__init__.py | def bits_in(length, keyspace):
""" |log2(keyspace^length) = bits|
-> (#float) number of bits of entropy in @length of characters for
a given a @keyspace
"""
keyspace = len(keyspace)
length_per_cycle = 64
if length > length_per_cycle:
bits = 0
length_processed = 0
... | def bits_in(length, keyspace):
""" |log2(keyspace^length) = bits|
-> (#float) number of bits of entropy in @length of characters for
a given a @keyspace
"""
keyspace = len(keyspace)
length_per_cycle = 64
if length > length_per_cycle:
bits = 0
length_processed = 0
... | [
"|log2",
"(",
"keyspace^length",
")",
"=",
"bits|",
"-",
">",
"(",
"#float",
")",
"number",
"of",
"bits",
"of",
"entropy",
"in"
] | jaredLunde/vital-tools | python | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/security/__init__.py#L360-L378 | [
"def",
"bits_in",
"(",
"length",
",",
"keyspace",
")",
":",
"keyspace",
"=",
"len",
"(",
"keyspace",
")",
"length_per_cycle",
"=",
"64",
"if",
"length",
">",
"length_per_cycle",
":",
"bits",
"=",
"0",
"length_processed",
"=",
"0",
"cycles",
"=",
"ceil",
... | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 |
train | iter_random_chars | Yields a cryptographically secure random key of desired @bits of
entropy within @keyspace using :class:random.SystemRandom
@bits: (#int) minimum bits of entropy
@keyspace: (#str) or iterable allowed output chars
..
from vital.security import iter_rand
for char ... | vital/security/__init__.py | def iter_random_chars(bits,
keyspace=string.ascii_letters + string.digits + '#/.',
rng=None):
""" Yields a cryptographically secure random key of desired @bits of
entropy within @keyspace using :class:random.SystemRandom
@bits: (#int) minimum bits of entr... | def iter_random_chars(bits,
keyspace=string.ascii_letters + string.digits + '#/.',
rng=None):
""" Yields a cryptographically secure random key of desired @bits of
entropy within @keyspace using :class:random.SystemRandom
@bits: (#int) minimum bits of entr... | [
"Yields",
"a",
"cryptographically",
"secure",
"random",
"key",
"of",
"desired",
"@bits",
"of",
"entropy",
"within",
"@keyspace",
"using",
":",
"class",
":",
"random",
".",
"SystemRandom"
] | jaredLunde/vital-tools | python | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/security/__init__.py#L381-L402 | [
"def",
"iter_random_chars",
"(",
"bits",
",",
"keyspace",
"=",
"string",
".",
"ascii_letters",
"+",
"string",
".",
"digits",
"+",
"'#/.'",
",",
"rng",
"=",
"None",
")",
":",
"if",
"bits",
"<",
"8",
":",
"raise",
"ValueError",
"(",
"'Bits cannot be <8'",
... | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 |
train | randkey | Returns a cryptographically secure random key of desired @bits of
entropy within @keyspace using :class:random.SystemRandom
@bits: (#int) minimum bits of entropy
@keyspace: (#str) or iterable allowed output chars
@rng: the random number generator to use. Defaults to
:class:r... | vital/security/__init__.py | def randkey(bits, keyspace=string.ascii_letters + string.digits + '#/.',
rng=None):
""" Returns a cryptographically secure random key of desired @bits of
entropy within @keyspace using :class:random.SystemRandom
@bits: (#int) minimum bits of entropy
@keyspace: (#str) or iterable... | def randkey(bits, keyspace=string.ascii_letters + string.digits + '#/.',
rng=None):
""" Returns a cryptographically secure random key of desired @bits of
entropy within @keyspace using :class:random.SystemRandom
@bits: (#int) minimum bits of entropy
@keyspace: (#str) or iterable... | [
"Returns",
"a",
"cryptographically",
"secure",
"random",
"key",
"of",
"desired",
"@bits",
"of",
"entropy",
"within",
"@keyspace",
"using",
":",
"class",
":",
"random",
".",
"SystemRandom"
] | jaredLunde/vital-tools | python | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/security/__init__.py#L405-L430 | [
"def",
"randkey",
"(",
"bits",
",",
"keyspace",
"=",
"string",
".",
"ascii_letters",
"+",
"string",
".",
"digits",
"+",
"'#/.'",
",",
"rng",
"=",
"None",
")",
":",
"return",
"\"\"",
".",
"join",
"(",
"char",
"for",
"char",
"in",
"iter_random_chars",
"(... | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 |
train | randstr | Returns a cryptographically secure random string of desired @size
(in character length) within @keyspace using :class:random.SystemRandom
@size: (#int) number of random characters to generate
@keyspace: (#str) or iterable allowed output chars
@rng: the random number generator to use. De... | vital/security/__init__.py | def randstr(size, keyspace=string.ascii_letters + string.digits, rng=None):
""" Returns a cryptographically secure random string of desired @size
(in character length) within @keyspace using :class:random.SystemRandom
@size: (#int) number of random characters to generate
@keyspace: (#str) o... | def randstr(size, keyspace=string.ascii_letters + string.digits, rng=None):
""" Returns a cryptographically secure random string of desired @size
(in character length) within @keyspace using :class:random.SystemRandom
@size: (#int) number of random characters to generate
@keyspace: (#str) o... | [
"Returns",
"a",
"cryptographically",
"secure",
"random",
"string",
"of",
"desired",
"@size",
"(",
"in",
"character",
"length",
")",
"within",
"@keyspace",
"using",
":",
"class",
":",
"random",
".",
"SystemRandom"
] | jaredLunde/vital-tools | python | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/security/__init__.py#L433-L452 | [
"def",
"randstr",
"(",
"size",
",",
"keyspace",
"=",
"string",
".",
"ascii_letters",
"+",
"string",
".",
"digits",
",",
"rng",
"=",
"None",
")",
":",
"rng",
"=",
"rng",
"or",
"random",
".",
"SystemRandom",
"(",
")",
"return",
"\"\"",
".",
"join",
"("... | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 |
train | parse_requirements | load requirements from a pip requirements file | setup.py | def parse_requirements(filename):
""" load requirements from a pip requirements file """
lineiter = (line.strip() for line in open(filename))
return (line for line in lineiter if line and not line.startswith("#")) | def parse_requirements(filename):
""" load requirements from a pip requirements file """
lineiter = (line.strip() for line in open(filename))
return (line for line in lineiter if line and not line.startswith("#")) | [
"load",
"requirements",
"from",
"a",
"pip",
"requirements",
"file"
] | jaredLunde/vital-tools | python | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/setup.py#L24-L27 | [
"def",
"parse_requirements",
"(",
"filename",
")",
":",
"lineiter",
"=",
"(",
"line",
".",
"strip",
"(",
")",
"for",
"line",
"in",
"open",
"(",
"filename",
")",
")",
"return",
"(",
"line",
"for",
"line",
"in",
"lineiter",
"if",
"line",
"and",
"not",
... | ea924c9bbb6ec22aa66f8095f018b1ee0099ac04 |
train | round_sig | round floating point x to n significant figures | bin/lib/Plotting_Libraries/sigfig.py | def round_sig(x, n, scien_notation = False):
if x < 0:
x = x * -1
symbol = '-'
else:
symbol = ''
'''round floating point x to n significant figures'''
if type(n) is not types.IntType:
raise TypeError, "n must be an integer"
try:
x = float(x)
exce... | def round_sig(x, n, scien_notation = False):
if x < 0:
x = x * -1
symbol = '-'
else:
symbol = ''
'''round floating point x to n significant figures'''
if type(n) is not types.IntType:
raise TypeError, "n must be an integer"
try:
x = float(x)
exce... | [
"round",
"floating",
"point",
"x",
"to",
"n",
"significant",
"figures"
] | Vital-Fernandez/dazer | python | https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Plotting_Libraries/sigfig.py#L7-L60 | [
"def",
"round_sig",
"(",
"x",
",",
"n",
",",
"scien_notation",
"=",
"False",
")",
":",
"if",
"x",
"<",
"0",
":",
"x",
"=",
"x",
"*",
"-",
"1",
"symbol",
"=",
"'-'",
"else",
":",
"symbol",
"=",
"''",
"if",
"type",
"(",
"n",
")",
"is",
"not",
... | 3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244 |
train | round_sig_error | Find ex rounded to n sig-figs and make the floating point x
match the number of decimals. If [paren], the string is
returned as quantity(error) format | bin/lib/Plotting_Libraries/sigfig.py | def round_sig_error(x, ex, n, paren=False):
'''Find ex rounded to n sig-figs and make the floating point x
match the number of decimals. If [paren], the string is
returned as quantity(error) format'''
stex = round_sig(ex,n)
if stex.find('.') < 0:
extra_zeros = len(stex) - n
sigfigs ... | def round_sig_error(x, ex, n, paren=False):
'''Find ex rounded to n sig-figs and make the floating point x
match the number of decimals. If [paren], the string is
returned as quantity(error) format'''
stex = round_sig(ex,n)
if stex.find('.') < 0:
extra_zeros = len(stex) - n
sigfigs ... | [
"Find",
"ex",
"rounded",
"to",
"n",
"sig",
"-",
"figs",
"and",
"make",
"the",
"floating",
"point",
"x",
"match",
"the",
"number",
"of",
"decimals",
".",
"If",
"[",
"paren",
"]",
"the",
"string",
"is",
"returned",
"as",
"quantity",
"(",
"error",
")",
... | Vital-Fernandez/dazer | python | https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Plotting_Libraries/sigfig.py#L62-L78 | [
"def",
"round_sig_error",
"(",
"x",
",",
"ex",
",",
"n",
",",
"paren",
"=",
"False",
")",
":",
"stex",
"=",
"round_sig",
"(",
"ex",
",",
"n",
")",
"if",
"stex",
".",
"find",
"(",
"'.'",
")",
"<",
"0",
":",
"extra_zeros",
"=",
"len",
"(",
"stex"... | 3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244 |
train | format_table | Format a table such that the errors have n significant
figures. [cols] and [errors] should be a list of 1D arrays
that correspond to data and errors in columns. [n] is the number of
significant figures to keep in the errors. [labels] is an optional
column of strings that will be in the first column. ... | bin/lib/Plotting_Libraries/sigfig.py | def format_table(cols, errors, n, labels=None, headers=None, latex=False):
'''Format a table such that the errors have n significant
figures. [cols] and [errors] should be a list of 1D arrays
that correspond to data and errors in columns. [n] is the number of
significant figures to keep in the errors.... | def format_table(cols, errors, n, labels=None, headers=None, latex=False):
'''Format a table such that the errors have n significant
figures. [cols] and [errors] should be a list of 1D arrays
that correspond to data and errors in columns. [n] is the number of
significant figures to keep in the errors.... | [
"Format",
"a",
"table",
"such",
"that",
"the",
"errors",
"have",
"n",
"significant",
"figures",
".",
"[",
"cols",
"]",
"and",
"[",
"errors",
"]",
"should",
"be",
"a",
"list",
"of",
"1D",
"arrays",
"that",
"correspond",
"to",
"data",
"and",
"errors",
"i... | Vital-Fernandez/dazer | python | https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Plotting_Libraries/sigfig.py#L80-L149 | [
"def",
"format_table",
"(",
"cols",
",",
"errors",
",",
"n",
",",
"labels",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"latex",
"=",
"False",
")",
":",
"if",
"len",
"(",
"cols",
")",
"!=",
"len",
"(",
"errors",
")",
":",
"raise",
"ValueError",
... | 3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244 |
train | round_sig_error2 | Find min(ex1,ex2) rounded to n sig-figs and make the floating point x
and max(ex,ex2) match the number of decimals. | bin/lib/Plotting_Libraries/sigfig.py | def round_sig_error2(x, ex1, ex2, n):
'''Find min(ex1,ex2) rounded to n sig-figs and make the floating point x
and max(ex,ex2) match the number of decimals.'''
minerr = min(ex1,ex2)
minstex = round_sig(minerr,n)
if minstex.find('.') < 0:
extra_zeros = len(minstex) - n
sigfigs = len(s... | def round_sig_error2(x, ex1, ex2, n):
'''Find min(ex1,ex2) rounded to n sig-figs and make the floating point x
and max(ex,ex2) match the number of decimals.'''
minerr = min(ex1,ex2)
minstex = round_sig(minerr,n)
if minstex.find('.') < 0:
extra_zeros = len(minstex) - n
sigfigs = len(s... | [
"Find",
"min",
"(",
"ex1",
"ex2",
")",
"rounded",
"to",
"n",
"sig",
"-",
"figs",
"and",
"make",
"the",
"floating",
"point",
"x",
"and",
"max",
"(",
"ex",
"ex2",
")",
"match",
"the",
"number",
"of",
"decimals",
"."
] | Vital-Fernandez/dazer | python | https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Plotting_Libraries/sigfig.py#L151-L168 | [
"def",
"round_sig_error2",
"(",
"x",
",",
"ex1",
",",
"ex2",
",",
"n",
")",
":",
"minerr",
"=",
"min",
"(",
"ex1",
",",
"ex2",
")",
"minstex",
"=",
"round_sig",
"(",
"minerr",
",",
"n",
")",
"if",
"minstex",
".",
"find",
"(",
"'.'",
")",
"<",
"... | 3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244 |
train | send_to_azure_multi_threads | data = {
"table_name" : 'name_of_the_azure_schema' + '.' + 'name_of_the_azure_table' #Must already exist,
"columns_name" : [first_column_name,second_column_name,...,last_column_name],
"rows" : [[first_raw_value,second_raw_value,...,last_raw_value],...]
} | pyzure/send/send_multi_threads.py | def send_to_azure_multi_threads(instance, data, nb_threads=4, replace=True, types=None, primary_key=(),
sub_commit=False):
"""
data = {
"table_name" : 'name_of_the_azure_schema' + '.' + 'name_of_the_azure_table' #Must already exist,
"columns_name" : [first_colum... | def send_to_azure_multi_threads(instance, data, nb_threads=4, replace=True, types=None, primary_key=(),
sub_commit=False):
"""
data = {
"table_name" : 'name_of_the_azure_schema' + '.' + 'name_of_the_azure_table' #Must already exist,
"columns_name" : [first_colum... | [
"data",
"=",
"{",
"table_name",
":",
"name_of_the_azure_schema",
"+",
".",
"+",
"name_of_the_azure_table",
"#Must",
"already",
"exist",
"columns_name",
":",
"[",
"first_column_name",
"second_column_name",
"...",
"last_column_name",
"]",
"rows",
":",
"[[",
"first_raw_v... | dacker-team/pyzure | python | https://github.com/dacker-team/pyzure/blob/1e6d202f91ca0f080635adc470d9d18585056d53/pyzure/send/send_multi_threads.py#L26-L113 | [
"def",
"send_to_azure_multi_threads",
"(",
"instance",
",",
"data",
",",
"nb_threads",
"=",
"4",
",",
"replace",
"=",
"True",
",",
"types",
"=",
"None",
",",
"primary_key",
"=",
"(",
")",
",",
"sub_commit",
"=",
"False",
")",
":",
"# Time initialization",
... | 1e6d202f91ca0f080635adc470d9d18585056d53 |
train | send_to_azure | data = {
"table_name" : 'name_of_the_azure_schema' + '.' + 'name_of_the_azure_table' #Must already exist,
"columns_name" : [first_column_name,second_column_name,...,last_column_name],
"rows" : [[first_raw_value,second_raw_value,...,last_raw_value],...]
} | pyzure/send/send_multi_threads.py | def send_to_azure(instance, data, thread_number, sub_commit, table_info, nb_threads):
"""
data = {
"table_name" : 'name_of_the_azure_schema' + '.' + 'name_of_the_azure_table' #Must already exist,
"columns_name" : [first_column_name,second_column_name,...,last_column_name],
"rows" : [[... | def send_to_azure(instance, data, thread_number, sub_commit, table_info, nb_threads):
"""
data = {
"table_name" : 'name_of_the_azure_schema' + '.' + 'name_of_the_azure_table' #Must already exist,
"columns_name" : [first_column_name,second_column_name,...,last_column_name],
"rows" : [[... | [
"data",
"=",
"{",
"table_name",
":",
"name_of_the_azure_schema",
"+",
".",
"+",
"name_of_the_azure_table",
"#Must",
"already",
"exist",
"columns_name",
":",
"[",
"first_column_name",
"second_column_name",
"...",
"last_column_name",
"]",
"rows",
":",
"[[",
"first_raw_v... | dacker-team/pyzure | python | https://github.com/dacker-team/pyzure/blob/1e6d202f91ca0f080635adc470d9d18585056d53/pyzure/send/send_multi_threads.py#L116-L182 | [
"def",
"send_to_azure",
"(",
"instance",
",",
"data",
",",
"thread_number",
",",
"sub_commit",
",",
"table_info",
",",
"nb_threads",
")",
":",
"rows",
"=",
"data",
"[",
"\"rows\"",
"]",
"if",
"not",
"rows",
":",
"return",
"0",
"columns_name",
"=",
"data",
... | 1e6d202f91ca0f080635adc470d9d18585056d53 |
train | Invoice.create | Adds the items to the invoice
Format of 'items':
[
InvoiceItem(
name="VIP Ticket",
quantity= 2,
unit_price= "3500",
total_price= "7000",
description= "VIP Tickets for the Party"
}
,...
] | paydunya/invoice.py | def create(self, items=[], taxes=[], custom_data=[]):
"""Adds the items to the invoice
Format of 'items':
[
InvoiceItem(
name="VIP Ticket",
quantity= 2,
unit_price= "3500",
total_price= "7000",
description= "VIP Tickets f... | def create(self, items=[], taxes=[], custom_data=[]):
"""Adds the items to the invoice
Format of 'items':
[
InvoiceItem(
name="VIP Ticket",
quantity= 2,
unit_price= "3500",
total_price= "7000",
description= "VIP Tickets f... | [
"Adds",
"the",
"items",
"to",
"the",
"invoice"
] | paydunya/paydunya-python | python | https://github.com/paydunya/paydunya-python/blob/bb55791e2814788aec74162d9d78970815f37c30/paydunya/invoice.py#L31-L49 | [
"def",
"create",
"(",
"self",
",",
"items",
"=",
"[",
"]",
",",
"taxes",
"=",
"[",
"]",
",",
"custom_data",
"=",
"[",
"]",
")",
":",
"self",
".",
"add_items",
"(",
"items",
")",
"self",
".",
"add_taxes",
"(",
"taxes",
")",
"self",
".",
"add_custo... | bb55791e2814788aec74162d9d78970815f37c30 |
train | Invoice.confirm | Returns the status of the invoice
STATUSES: pending, completed, cancelled | paydunya/invoice.py | def confirm(self, token=None):
"""Returns the status of the invoice
STATUSES: pending, completed, cancelled
"""
_token = token if token else self._response.get("token")
return self._process('checkout-invoice/confirm/' + str(_token)) | def confirm(self, token=None):
"""Returns the status of the invoice
STATUSES: pending, completed, cancelled
"""
_token = token if token else self._response.get("token")
return self._process('checkout-invoice/confirm/' + str(_token)) | [
"Returns",
"the",
"status",
"of",
"the",
"invoice"
] | paydunya/paydunya-python | python | https://github.com/paydunya/paydunya-python/blob/bb55791e2814788aec74162d9d78970815f37c30/paydunya/invoice.py#L51-L57 | [
"def",
"confirm",
"(",
"self",
",",
"token",
"=",
"None",
")",
":",
"_token",
"=",
"token",
"if",
"token",
"else",
"self",
".",
"_response",
".",
"get",
"(",
"\"token\"",
")",
"return",
"self",
".",
"_process",
"(",
"'checkout-invoice/confirm/'",
"+",
"s... | bb55791e2814788aec74162d9d78970815f37c30 |
train | Invoice.add_taxes | Appends the data to the 'taxes' key in the request object
'taxes' should be in format: [("tax_name", "tax_amount")]
For example:
[("Other TAX", 700), ("VAT", 5000)] | paydunya/invoice.py | def add_taxes(self, taxes):
"""Appends the data to the 'taxes' key in the request object
'taxes' should be in format: [("tax_name", "tax_amount")]
For example:
[("Other TAX", 700), ("VAT", 5000)]
"""
# fixme: how to resolve duplicate tax names
_idx = len(self.tax... | def add_taxes(self, taxes):
"""Appends the data to the 'taxes' key in the request object
'taxes' should be in format: [("tax_name", "tax_amount")]
For example:
[("Other TAX", 700), ("VAT", 5000)]
"""
# fixme: how to resolve duplicate tax names
_idx = len(self.tax... | [
"Appends",
"the",
"data",
"to",
"the",
"taxes",
"key",
"in",
"the",
"request",
"object"
] | paydunya/paydunya-python | python | https://github.com/paydunya/paydunya-python/blob/bb55791e2814788aec74162d9d78970815f37c30/paydunya/invoice.py#L59-L70 | [
"def",
"add_taxes",
"(",
"self",
",",
"taxes",
")",
":",
"# fixme: how to resolve duplicate tax names",
"_idx",
"=",
"len",
"(",
"self",
".",
"taxes",
")",
"# current index to prevent overwriting",
"for",
"idx",
",",
"tax",
"in",
"enumerate",
"(",
"taxes",
")",
... | bb55791e2814788aec74162d9d78970815f37c30 |
train | Invoice.add_item | Updates the list of items in the current transaction | paydunya/invoice.py | def add_item(self, item):
"""Updates the list of items in the current transaction"""
_idx = len(self.items)
self.items.update({"item_" + str(_idx + 1): item}) | def add_item(self, item):
"""Updates the list of items in the current transaction"""
_idx = len(self.items)
self.items.update({"item_" + str(_idx + 1): item}) | [
"Updates",
"the",
"list",
"of",
"items",
"in",
"the",
"current",
"transaction"
] | paydunya/paydunya-python | python | https://github.com/paydunya/paydunya-python/blob/bb55791e2814788aec74162d9d78970815f37c30/paydunya/invoice.py#L79-L82 | [
"def",
"add_item",
"(",
"self",
",",
"item",
")",
":",
"_idx",
"=",
"len",
"(",
"self",
".",
"items",
")",
"self",
".",
"items",
".",
"update",
"(",
"{",
"\"item_\"",
"+",
"str",
"(",
"_idx",
"+",
"1",
")",
":",
"item",
"}",
")"
] | bb55791e2814788aec74162d9d78970815f37c30 |
train | Invoice._prepare_data | Formats the data in the current transaction for processing | paydunya/invoice.py | def _prepare_data(self):
"""Formats the data in the current transaction for processing"""
total_amount = self.total_amount or self.calculate_total_amt()
self._data = {
"invoice": {
"items": self.__encode_items(self.items),
"taxes": self.taxes,
... | def _prepare_data(self):
"""Formats the data in the current transaction for processing"""
total_amount = self.total_amount or self.calculate_total_amt()
self._data = {
"invoice": {
"items": self.__encode_items(self.items),
"taxes": self.taxes,
... | [
"Formats",
"the",
"data",
"in",
"the",
"current",
"transaction",
"for",
"processing"
] | paydunya/paydunya-python | python | https://github.com/paydunya/paydunya-python/blob/bb55791e2814788aec74162d9d78970815f37c30/paydunya/invoice.py#L97-L116 | [
"def",
"_prepare_data",
"(",
"self",
")",
":",
"total_amount",
"=",
"self",
".",
"total_amount",
"or",
"self",
".",
"calculate_total_amt",
"(",
")",
"self",
".",
"_data",
"=",
"{",
"\"invoice\"",
":",
"{",
"\"items\"",
":",
"self",
".",
"__encode_items",
"... | bb55791e2814788aec74162d9d78970815f37c30 |
train | Invoice.calculate_total_amt | Returns the total amount/cost of items in the current invoice | paydunya/invoice.py | def calculate_total_amt(self, items={}):
"""Returns the total amount/cost of items in the current invoice"""
_items = items.items() or self.items.items()
return sum(float(x[1].total_price) for x in _items) | def calculate_total_amt(self, items={}):
"""Returns the total amount/cost of items in the current invoice"""
_items = items.items() or self.items.items()
return sum(float(x[1].total_price) for x in _items) | [
"Returns",
"the",
"total",
"amount",
"/",
"cost",
"of",
"items",
"in",
"the",
"current",
"invoice"
] | paydunya/paydunya-python | python | https://github.com/paydunya/paydunya-python/blob/bb55791e2814788aec74162d9d78970815f37c30/paydunya/invoice.py#L118-L121 | [
"def",
"calculate_total_amt",
"(",
"self",
",",
"items",
"=",
"{",
"}",
")",
":",
"_items",
"=",
"items",
".",
"items",
"(",
")",
"or",
"self",
".",
"items",
".",
"items",
"(",
")",
"return",
"sum",
"(",
"float",
"(",
"x",
"[",
"1",
"]",
".",
"... | bb55791e2814788aec74162d9d78970815f37c30 |
train | Invoice.__encode_items | Encodes the InvoiceItems into a JSON serializable format
items = [('item_1',InvoiceItem(name='VIP Ticket', quantity=2,
unit_price='3500', total_price='7000',
description='VIP Tickets for party')),...] | paydunya/invoice.py | def __encode_items(self, items):
"""Encodes the InvoiceItems into a JSON serializable format
items = [('item_1',InvoiceItem(name='VIP Ticket', quantity=2,
unit_price='3500', total_price='7000',
description='VIP Tickets for party')),...]
... | def __encode_items(self, items):
"""Encodes the InvoiceItems into a JSON serializable format
items = [('item_1',InvoiceItem(name='VIP Ticket', quantity=2,
unit_price='3500', total_price='7000',
description='VIP Tickets for party')),...]
... | [
"Encodes",
"the",
"InvoiceItems",
"into",
"a",
"JSON",
"serializable",
"format"
] | paydunya/paydunya-python | python | https://github.com/paydunya/paydunya-python/blob/bb55791e2814788aec74162d9d78970815f37c30/paydunya/invoice.py#L123-L131 | [
"def",
"__encode_items",
"(",
"self",
",",
"items",
")",
":",
"xs",
"=",
"[",
"item",
".",
"_asdict",
"(",
")",
"for",
"(",
"_key",
",",
"item",
")",
"in",
"items",
".",
"items",
"(",
")",
"]",
"return",
"list",
"(",
"map",
"(",
"lambda",
"x",
... | bb55791e2814788aec74162d9d78970815f37c30 |
train | main | Sample usage for this python module
This main method simply illustrates sample usage for this python
module.
:return: None | pycons3rt/deployment.py | def main():
"""Sample usage for this python module
This main method simply illustrates sample usage for this python
module.
:return: None
"""
log = logging.getLogger(mod_logger + '.main')
parser = argparse.ArgumentParser(description='cons3rt deployment CLI')
parser.add_argument('comman... | def main():
"""Sample usage for this python module
This main method simply illustrates sample usage for this python
module.
:return: None
"""
log = logging.getLogger(mod_logger + '.main')
parser = argparse.ArgumentParser(description='cons3rt deployment CLI')
parser.add_argument('comman... | [
"Sample",
"usage",
"for",
"this",
"python",
"module"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/deployment.py#L704-L744 | [
"def",
"main",
"(",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.main'",
")",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"'cons3rt deployment CLI'",
")",
"parser",
".",
"add_argument",
"(",
"'c... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | Deployment.set_deployment_home | Sets self.deployment_home
This method finds and sets deployment home, primarily based on
the DEPLOYMENT_HOME environment variable. If not set, this
method will attempt to determine deployment home.
:return: None | pycons3rt/deployment.py | def set_deployment_home(self):
"""Sets self.deployment_home
This method finds and sets deployment home, primarily based on
the DEPLOYMENT_HOME environment variable. If not set, this
method will attempt to determine deployment home.
:return: None
"""
log = loggin... | def set_deployment_home(self):
"""Sets self.deployment_home
This method finds and sets deployment home, primarily based on
the DEPLOYMENT_HOME environment variable. If not set, this
method will attempt to determine deployment home.
:return: None
"""
log = loggin... | [
"Sets",
"self",
".",
"deployment_home"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/deployment.py#L115-L164 | [
"def",
"set_deployment_home",
"(",
"self",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.set_deployment_home'",
")",
"try",
":",
"self",
".",
"deployment_home",
"=",
"os",
".",
"environ",
"[",
"'DEPLOYMENT_HOME'",
... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | Deployment.read_deployment_properties | Reads the deployment properties file
This method reads the deployment properties file into the
"properties" dictionary object.
:return: None
:raises: DeploymentError | pycons3rt/deployment.py | def read_deployment_properties(self):
"""Reads the deployment properties file
This method reads the deployment properties file into the
"properties" dictionary object.
:return: None
:raises: DeploymentError
"""
log = logging.getLogger(self.cls_logger + '.read_de... | def read_deployment_properties(self):
"""Reads the deployment properties file
This method reads the deployment properties file into the
"properties" dictionary object.
:return: None
:raises: DeploymentError
"""
log = logging.getLogger(self.cls_logger + '.read_de... | [
"Reads",
"the",
"deployment",
"properties",
"file"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/deployment.py#L166-L217 | [
"def",
"read_deployment_properties",
"(",
"self",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.read_deployment_properties'",
")",
"# Ensure deployment properties file exists",
"self",
".",
"properties_file",
"=",
"os",
"."... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | Deployment.get_property | Gets the name of a specific property
This public method is passed a regular expression and
returns the matching property name. If either the property
is not found or if the passed string matches more than one
property, this function will return None.
:param regex: Regular expre... | pycons3rt/deployment.py | def get_property(self, regex):
"""Gets the name of a specific property
This public method is passed a regular expression and
returns the matching property name. If either the property
is not found or if the passed string matches more than one
property, this function will return ... | def get_property(self, regex):
"""Gets the name of a specific property
This public method is passed a regular expression and
returns the matching property name. If either the property
is not found or if the passed string matches more than one
property, this function will return ... | [
"Gets",
"the",
"name",
"of",
"a",
"specific",
"property"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/deployment.py#L219-L255 | [
"def",
"get_property",
"(",
"self",
",",
"regex",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.get_property'",
")",
"if",
"not",
"isinstance",
"(",
"regex",
",",
"basestring",
")",
":",
"log",
".",
"error",
... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | Deployment.get_matching_property_names | Returns a list of property names matching the provided
regular expression
:param regex: Regular expression to search on
:return: (list) of property names matching the regex | pycons3rt/deployment.py | def get_matching_property_names(self, regex):
"""Returns a list of property names matching the provided
regular expression
:param regex: Regular expression to search on
:return: (list) of property names matching the regex
"""
log = logging.getLogger(self.cls_logger + '.g... | def get_matching_property_names(self, regex):
"""Returns a list of property names matching the provided
regular expression
:param regex: Regular expression to search on
:return: (list) of property names matching the regex
"""
log = logging.getLogger(self.cls_logger + '.g... | [
"Returns",
"a",
"list",
"of",
"property",
"names",
"matching",
"the",
"provided",
"regular",
"expression"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/deployment.py#L257-L274 | [
"def",
"get_matching_property_names",
"(",
"self",
",",
"regex",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.get_matching_property_names'",
")",
"prop_list_matched",
"=",
"[",
"]",
"if",
"not",
"isinstance",
"(",
... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | Deployment.get_value | Returns the value associated to the passed property
This public method is passed a specific property as a string
and returns the value of that property. If the property is not
found, None will be returned.
:param property_name (str) The name of the property
:return: (str) value... | pycons3rt/deployment.py | def get_value(self, property_name):
"""Returns the value associated to the passed property
This public method is passed a specific property as a string
and returns the value of that property. If the property is not
found, None will be returned.
:param property_name (str) The na... | def get_value(self, property_name):
"""Returns the value associated to the passed property
This public method is passed a specific property as a string
and returns the value of that property. If the property is not
found, None will be returned.
:param property_name (str) The na... | [
"Returns",
"the",
"value",
"associated",
"to",
"the",
"passed",
"property"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/deployment.py#L276-L297 | [
"def",
"get_value",
"(",
"self",
",",
"property_name",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.get_value'",
")",
"if",
"not",
"isinstance",
"(",
"property_name",
",",
"basestring",
")",
":",
"log",
".",
... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | Deployment.set_cons3rt_role_name | Set the cons3rt_role_name member for this system
:return: None
:raises: DeploymentError | pycons3rt/deployment.py | def set_cons3rt_role_name(self):
"""Set the cons3rt_role_name member for this system
:return: None
:raises: DeploymentError
"""
log = logging.getLogger(self.cls_logger + '.set_cons3rt_role_name')
try:
self.cons3rt_role_name = os.environ['CONS3RT_ROLE_NAME']
... | def set_cons3rt_role_name(self):
"""Set the cons3rt_role_name member for this system
:return: None
:raises: DeploymentError
"""
log = logging.getLogger(self.cls_logger + '.set_cons3rt_role_name')
try:
self.cons3rt_role_name = os.environ['CONS3RT_ROLE_NAME']
... | [
"Set",
"the",
"cons3rt_role_name",
"member",
"for",
"this",
"system"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/deployment.py#L299-L322 | [
"def",
"set_cons3rt_role_name",
"(",
"self",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.set_cons3rt_role_name'",
")",
"try",
":",
"self",
".",
"cons3rt_role_name",
"=",
"os",
".",
"environ",
"[",
"'CONS3RT_ROLE_N... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | Deployment.determine_cons3rt_role_name_linux | Determines the CONS3RT_ROLE_NAME for this Linux system, and
Set the cons3rt_role_name member for this system
This method determines the CONS3RT_ROLE_NAME for this system
in the deployment by first checking for the environment
variable, if not set, determining the value from the
... | pycons3rt/deployment.py | def determine_cons3rt_role_name_linux(self):
"""Determines the CONS3RT_ROLE_NAME for this Linux system, and
Set the cons3rt_role_name member for this system
This method determines the CONS3RT_ROLE_NAME for this system
in the deployment by first checking for the environment
varia... | def determine_cons3rt_role_name_linux(self):
"""Determines the CONS3RT_ROLE_NAME for this Linux system, and
Set the cons3rt_role_name member for this system
This method determines the CONS3RT_ROLE_NAME for this system
in the deployment by first checking for the environment
varia... | [
"Determines",
"the",
"CONS3RT_ROLE_NAME",
"for",
"this",
"Linux",
"system",
"and",
"Set",
"the",
"cons3rt_role_name",
"member",
"for",
"this",
"system"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/deployment.py#L324-L399 | [
"def",
"determine_cons3rt_role_name_linux",
"(",
"self",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.determine_cons3rt_role_name_linux'",
")",
"# Determine IP addresses for this system",
"log",
".",
"info",
"(",
"'Determini... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | Deployment.set_asset_dir | Returns the ASSET_DIR environment variable
This method gets the ASSET_DIR environment variable for the
current asset install. It returns either the string value if
set or None if it is not set.
:return: None | pycons3rt/deployment.py | def set_asset_dir(self):
"""Returns the ASSET_DIR environment variable
This method gets the ASSET_DIR environment variable for the
current asset install. It returns either the string value if
set or None if it is not set.
:return: None
"""
log = logging.getLogge... | def set_asset_dir(self):
"""Returns the ASSET_DIR environment variable
This method gets the ASSET_DIR environment variable for the
current asset install. It returns either the string value if
set or None if it is not set.
:return: None
"""
log = logging.getLogge... | [
"Returns",
"the",
"ASSET_DIR",
"environment",
"variable"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/deployment.py#L401-L416 | [
"def",
"set_asset_dir",
"(",
"self",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.get_asset_dir'",
")",
"try",
":",
"self",
".",
"asset_dir",
"=",
"os",
".",
"environ",
"[",
"'ASSET_DIR'",
"]",
"except",
"Key... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | Deployment.set_scenario_role_names | Populates the list of scenario role names in this deployment and
populates the scenario_master with the master role
Gets a list of deployment properties containing "isMaster" because
there is exactly one per scenario host, containing the role name
:return: | pycons3rt/deployment.py | def set_scenario_role_names(self):
"""Populates the list of scenario role names in this deployment and
populates the scenario_master with the master role
Gets a list of deployment properties containing "isMaster" because
there is exactly one per scenario host, containing the role name
... | def set_scenario_role_names(self):
"""Populates the list of scenario role names in this deployment and
populates the scenario_master with the master role
Gets a list of deployment properties containing "isMaster" because
there is exactly one per scenario host, containing the role name
... | [
"Populates",
"the",
"list",
"of",
"scenario",
"role",
"names",
"in",
"this",
"deployment",
"and",
"populates",
"the",
"scenario_master",
"with",
"the",
"master",
"role"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/deployment.py#L418-L438 | [
"def",
"set_scenario_role_names",
"(",
"self",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.set_scenario_role_names'",
")",
"is_master_props",
"=",
"self",
".",
"get_matching_property_names",
"(",
"'isMaster'",
")",
"f... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | Deployment.set_scenario_network_info | Populates a list of network info for each scenario host from
deployment properties
:return: None | pycons3rt/deployment.py | def set_scenario_network_info(self):
"""Populates a list of network info for each scenario host from
deployment properties
:return: None
"""
log = logging.getLogger(self.cls_logger + '.set_scenario_network_info')
for scenario_host in self.scenario_role_names:
... | def set_scenario_network_info(self):
"""Populates a list of network info for each scenario host from
deployment properties
:return: None
"""
log = logging.getLogger(self.cls_logger + '.set_scenario_network_info')
for scenario_host in self.scenario_role_names:
... | [
"Populates",
"a",
"list",
"of",
"network",
"info",
"for",
"each",
"scenario",
"host",
"from",
"deployment",
"properties"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/deployment.py#L440-L498 | [
"def",
"set_scenario_network_info",
"(",
"self",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.set_scenario_network_info'",
")",
"for",
"scenario_host",
"in",
"self",
".",
"scenario_role_names",
":",
"scenario_host_networ... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | Deployment.set_deployment_name | Sets the deployment name from deployment properties
:return: None | pycons3rt/deployment.py | def set_deployment_name(self):
"""Sets the deployment name from deployment properties
:return: None
"""
log = logging.getLogger(self.cls_logger + '.set_deployment_name')
self.deployment_name = self.get_value('cons3rt.deployment.name')
log.info('Found deployment name: {n}... | def set_deployment_name(self):
"""Sets the deployment name from deployment properties
:return: None
"""
log = logging.getLogger(self.cls_logger + '.set_deployment_name')
self.deployment_name = self.get_value('cons3rt.deployment.name')
log.info('Found deployment name: {n}... | [
"Sets",
"the",
"deployment",
"name",
"from",
"deployment",
"properties"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/deployment.py#L500-L507 | [
"def",
"set_deployment_name",
"(",
"self",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.set_deployment_name'",
")",
"self",
".",
"deployment_name",
"=",
"self",
".",
"get_value",
"(",
"'cons3rt.deployment.name'",
")"... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | Deployment.set_deployment_id | Sets the deployment ID from deployment properties
:return: None | pycons3rt/deployment.py | def set_deployment_id(self):
"""Sets the deployment ID from deployment properties
:return: None
"""
log = logging.getLogger(self.cls_logger + '.set_deployment_id')
deployment_id_val = self.get_value('cons3rt.deployment.id')
if not deployment_id_val:
log.debug... | def set_deployment_id(self):
"""Sets the deployment ID from deployment properties
:return: None
"""
log = logging.getLogger(self.cls_logger + '.set_deployment_id')
deployment_id_val = self.get_value('cons3rt.deployment.id')
if not deployment_id_val:
log.debug... | [
"Sets",
"the",
"deployment",
"ID",
"from",
"deployment",
"properties"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/deployment.py#L509-L525 | [
"def",
"set_deployment_id",
"(",
"self",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.set_deployment_id'",
")",
"deployment_id_val",
"=",
"self",
".",
"get_value",
"(",
"'cons3rt.deployment.id'",
")",
"if",
"not",
... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | Deployment.set_deployment_run_name | Sets the deployment run name from deployment properties
:return: None | pycons3rt/deployment.py | def set_deployment_run_name(self):
"""Sets the deployment run name from deployment properties
:return: None
"""
log = logging.getLogger(self.cls_logger + '.set_deployment_run_name')
self.deployment_run_name = self.get_value('cons3rt.deploymentRun.name')
log.info('Found d... | def set_deployment_run_name(self):
"""Sets the deployment run name from deployment properties
:return: None
"""
log = logging.getLogger(self.cls_logger + '.set_deployment_run_name')
self.deployment_run_name = self.get_value('cons3rt.deploymentRun.name')
log.info('Found d... | [
"Sets",
"the",
"deployment",
"run",
"name",
"from",
"deployment",
"properties"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/deployment.py#L527-L534 | [
"def",
"set_deployment_run_name",
"(",
"self",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.set_deployment_run_name'",
")",
"self",
".",
"deployment_run_name",
"=",
"self",
".",
"get_value",
"(",
"'cons3rt.deploymentRu... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | Deployment.set_deployment_run_id | Sets the deployment run ID from deployment properties
:return: None | pycons3rt/deployment.py | def set_deployment_run_id(self):
"""Sets the deployment run ID from deployment properties
:return: None
"""
log = logging.getLogger(self.cls_logger + '.set_deployment_run_id')
deployment_run_id_val = self.get_value('cons3rt.deploymentRun.id')
if not deployment_run_id_val... | def set_deployment_run_id(self):
"""Sets the deployment run ID from deployment properties
:return: None
"""
log = logging.getLogger(self.cls_logger + '.set_deployment_run_id')
deployment_run_id_val = self.get_value('cons3rt.deploymentRun.id')
if not deployment_run_id_val... | [
"Sets",
"the",
"deployment",
"run",
"ID",
"from",
"deployment",
"properties"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/deployment.py#L536-L552 | [
"def",
"set_deployment_run_id",
"(",
"self",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.set_deployment_run_id'",
")",
"deployment_run_id_val",
"=",
"self",
".",
"get_value",
"(",
"'cons3rt.deploymentRun.id'",
")",
"i... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | Deployment.set_virtualization_realm_type | Sets the virtualization realm type from deployment properties
:return: None | pycons3rt/deployment.py | def set_virtualization_realm_type(self):
"""Sets the virtualization realm type from deployment properties
:return: None
"""
log = logging.getLogger(self.cls_logger + '.set_virtualization_realm_type')
self.virtualization_realm_type = self.get_value('cons3rt.deploymentRun.virtReal... | def set_virtualization_realm_type(self):
"""Sets the virtualization realm type from deployment properties
:return: None
"""
log = logging.getLogger(self.cls_logger + '.set_virtualization_realm_type')
self.virtualization_realm_type = self.get_value('cons3rt.deploymentRun.virtReal... | [
"Sets",
"the",
"virtualization",
"realm",
"type",
"from",
"deployment",
"properties"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/deployment.py#L554-L561 | [
"def",
"set_virtualization_realm_type",
"(",
"self",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.set_virtualization_realm_type'",
")",
"self",
".",
"virtualization_realm_type",
"=",
"self",
".",
"get_value",
"(",
"'co... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | Deployment.update_hosts_file | Updated the hosts file depending on the OS
:param ip: (str) IP address to update
:param entry: (str) entry to associate to the IP address
:return: None | pycons3rt/deployment.py | def update_hosts_file(self, ip, entry):
"""Updated the hosts file depending on the OS
:param ip: (str) IP address to update
:param entry: (str) entry to associate to the IP address
:return: None
"""
log = logging.getLogger(self.cls_logger + '.update_hosts_file')
... | def update_hosts_file(self, ip, entry):
"""Updated the hosts file depending on the OS
:param ip: (str) IP address to update
:param entry: (str) entry to associate to the IP address
:return: None
"""
log = logging.getLogger(self.cls_logger + '.update_hosts_file')
... | [
"Updated",
"the",
"hosts",
"file",
"depending",
"on",
"the",
"OS"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/deployment.py#L563-L577 | [
"def",
"update_hosts_file",
"(",
"self",
",",
"ip",
",",
"entry",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.update_hosts_file'",
")",
"if",
"get_os",
"(",
")",
"in",
"[",
"'Linux'",
",",
"'Darwin'",
"]",
... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | Deployment.set_scenario_hosts_file | Adds hosts file entries for each system in the scenario
for the specified network_name provided
:param network_name: (str) Name of the network to add to the hosts file
:param domain_name: (str) Domain name to include in the hosts file entries if provided
:return: None | pycons3rt/deployment.py | def set_scenario_hosts_file(self, network_name='user-net', domain_name=None):
"""Adds hosts file entries for each system in the scenario
for the specified network_name provided
:param network_name: (str) Name of the network to add to the hosts file
:param domain_name: (str) Domain name ... | def set_scenario_hosts_file(self, network_name='user-net', domain_name=None):
"""Adds hosts file entries for each system in the scenario
for the specified network_name provided
:param network_name: (str) Name of the network to add to the hosts file
:param domain_name: (str) Domain name ... | [
"Adds",
"hosts",
"file",
"entries",
"for",
"each",
"system",
"in",
"the",
"scenario",
"for",
"the",
"specified",
"network_name",
"provided"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/deployment.py#L579-L597 | [
"def",
"set_scenario_hosts_file",
"(",
"self",
",",
"network_name",
"=",
"'user-net'",
",",
"domain_name",
"=",
"None",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.set_scenario_hosts_file'",
")",
"log",
".",
"info... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | Deployment.set_hosts_file_entry_for_role | Adds an entry to the hosts file for a scenario host given
the role name and network name
:param role_name: (str) role name of the host to add
:param network_name: (str) Name of the network to add to the hosts file
:param fqdn: (str) Fully qualified domain name to use in the hosts file e... | pycons3rt/deployment.py | def set_hosts_file_entry_for_role(self, role_name, network_name='user-net', fqdn=None, domain_name=None):
"""Adds an entry to the hosts file for a scenario host given
the role name and network name
:param role_name: (str) role name of the host to add
:param network_name: (str) Name of t... | def set_hosts_file_entry_for_role(self, role_name, network_name='user-net', fqdn=None, domain_name=None):
"""Adds an entry to the hosts file for a scenario host given
the role name and network name
:param role_name: (str) role name of the host to add
:param network_name: (str) Name of t... | [
"Adds",
"an",
"entry",
"to",
"the",
"hosts",
"file",
"for",
"a",
"scenario",
"host",
"given",
"the",
"role",
"name",
"and",
"network",
"name"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/deployment.py#L599-L625 | [
"def",
"set_hosts_file_entry_for_role",
"(",
"self",
",",
"role_name",
",",
"network_name",
"=",
"'user-net'",
",",
"fqdn",
"=",
"None",
",",
"domain_name",
"=",
"None",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | Deployment.get_ip_on_network | Given a network name, returns the IP address
:param network_name: (str) Name of the network to search for
:return: (str) IP address on the specified network or None | pycons3rt/deployment.py | def get_ip_on_network(self, network_name):
"""Given a network name, returns the IP address
:param network_name: (str) Name of the network to search for
:return: (str) IP address on the specified network or None
"""
return self.get_scenario_host_ip_on_network(
scenari... | def get_ip_on_network(self, network_name):
"""Given a network name, returns the IP address
:param network_name: (str) Name of the network to search for
:return: (str) IP address on the specified network or None
"""
return self.get_scenario_host_ip_on_network(
scenari... | [
"Given",
"a",
"network",
"name",
"returns",
"the",
"IP",
"address"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/deployment.py#L627-L636 | [
"def",
"get_ip_on_network",
"(",
"self",
",",
"network_name",
")",
":",
"return",
"self",
".",
"get_scenario_host_ip_on_network",
"(",
"scenario_role_name",
"=",
"self",
".",
"cons3rt_role_name",
",",
"network_name",
"=",
"network_name",
")"
] | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | Deployment.get_scenario_host_ip_on_network | Given a network name, returns the IP address
:param network_name: (str) Name of the network to search for
:param scenario_role_name: (str) role name to return the IP address for
:return: (str) IP address on the specified network or None | pycons3rt/deployment.py | def get_scenario_host_ip_on_network(self, scenario_role_name, network_name):
"""Given a network name, returns the IP address
:param network_name: (str) Name of the network to search for
:param scenario_role_name: (str) role name to return the IP address for
:return: (str) IP address on ... | def get_scenario_host_ip_on_network(self, scenario_role_name, network_name):
"""Given a network name, returns the IP address
:param network_name: (str) Name of the network to search for
:param scenario_role_name: (str) role name to return the IP address for
:return: (str) IP address on ... | [
"Given",
"a",
"network",
"name",
"returns",
"the",
"IP",
"address"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/deployment.py#L638-L665 | [
"def",
"get_scenario_host_ip_on_network",
"(",
"self",
",",
"scenario_role_name",
",",
"network_name",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.get_scenario_host_ip_on_network'",
")",
"# Determine the network info for this... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | Deployment.get_device_for_network_linux | Given a cons3rt network name, return the network interface name
on this Linux system
:param network_name: (str) Name of the network to search for
:return: (str) name of the network interface device or None | pycons3rt/deployment.py | def get_device_for_network_linux(self, network_name):
"""Given a cons3rt network name, return the network interface name
on this Linux system
:param network_name: (str) Name of the network to search for
:return: (str) name of the network interface device or None
"""
log ... | def get_device_for_network_linux(self, network_name):
"""Given a cons3rt network name, return the network interface name
on this Linux system
:param network_name: (str) Name of the network to search for
:return: (str) name of the network interface device or None
"""
log ... | [
"Given",
"a",
"cons3rt",
"network",
"name",
"return",
"the",
"network",
"interface",
"name",
"on",
"this",
"Linux",
"system"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/deployment.py#L667-L701 | [
"def",
"get_device_for_network_linux",
"(",
"self",
",",
"network_name",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.get_device_for_network_linux'",
")",
"if",
"get_os",
"(",
")",
"not",
"in",
"[",
"'Linux'",
"]",... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | require_auth | Returns authenticated User.
:param request: HttpRequest
:param exceptions: Raise (NotAuthenticated) exception. Default is True.
:return: User | jutil/auth.py | def require_auth(request: Request, exceptions: bool=True) -> User:
"""
Returns authenticated User.
:param request: HttpRequest
:param exceptions: Raise (NotAuthenticated) exception. Default is True.
:return: User
"""
if not request.user or not request.user.is_authenticated:
if except... | def require_auth(request: Request, exceptions: bool=True) -> User:
"""
Returns authenticated User.
:param request: HttpRequest
:param exceptions: Raise (NotAuthenticated) exception. Default is True.
:return: User
"""
if not request.user or not request.user.is_authenticated:
if except... | [
"Returns",
"authenticated",
"User",
".",
":",
"param",
"request",
":",
"HttpRequest",
":",
"param",
"exceptions",
":",
"Raise",
"(",
"NotAuthenticated",
")",
"exception",
".",
"Default",
"is",
"True",
".",
":",
"return",
":",
"User"
] | kajala/django-jutil | python | https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/auth.py#L7-L18 | [
"def",
"require_auth",
"(",
"request",
":",
"Request",
",",
"exceptions",
":",
"bool",
"=",
"True",
")",
"->",
"User",
":",
"if",
"not",
"request",
".",
"user",
"or",
"not",
"request",
".",
"user",
".",
"is_authenticated",
":",
"if",
"exceptions",
":",
... | 2abd93ebad51042744eaeb1ee1074ed0eb55ad0c |
train | IPTables.insertSaneDefaults | Add sane defaults rules to the raw and filter tables | libnfldap.py | def insertSaneDefaults(self):
""" Add sane defaults rules to the raw and filter tables """
self.raw.insert(0, '-A OUTPUT -o lo -j NOTRACK')
self.raw.insert(1, '-A PREROUTING -i lo -j NOTRACK')
self.filters.insert(0, '-A INPUT -i lo -j ACCEPT')
self.filters.insert(1, '-A OUTPUT -o lo -j ACCEPT')
self.filters... | def insertSaneDefaults(self):
""" Add sane defaults rules to the raw and filter tables """
self.raw.insert(0, '-A OUTPUT -o lo -j NOTRACK')
self.raw.insert(1, '-A PREROUTING -i lo -j NOTRACK')
self.filters.insert(0, '-A INPUT -i lo -j ACCEPT')
self.filters.insert(1, '-A OUTPUT -o lo -j ACCEPT')
self.filters... | [
"Add",
"sane",
"defaults",
"rules",
"to",
"the",
"raw",
"and",
"filter",
"tables"
] | mozilla/libnfldap | python | https://github.com/mozilla/libnfldap/blob/27407a6ed6bfd07d1eba2824398c77e2fe98f968/libnfldap.py#L92-L100 | [
"def",
"insertSaneDefaults",
"(",
"self",
")",
":",
"self",
".",
"raw",
".",
"insert",
"(",
"0",
",",
"'-A OUTPUT -o lo -j NOTRACK'",
")",
"self",
".",
"raw",
".",
"insert",
"(",
"1",
",",
"'-A PREROUTING -i lo -j NOTRACK'",
")",
"self",
".",
"filters",
".",... | 27407a6ed6bfd07d1eba2824398c77e2fe98f968 |
train | IPTables.appendDefaultDrop | Add a DROP policy at the end of the rules | libnfldap.py | def appendDefaultDrop(self):
""" Add a DROP policy at the end of the rules """
self.filters.append('-A INPUT -j DROP')
self.filters.append('-A OUTPUT -j DROP')
self.filters.append('-A FORWARD -j DROP')
return self | def appendDefaultDrop(self):
""" Add a DROP policy at the end of the rules """
self.filters.append('-A INPUT -j DROP')
self.filters.append('-A OUTPUT -j DROP')
self.filters.append('-A FORWARD -j DROP')
return self | [
"Add",
"a",
"DROP",
"policy",
"at",
"the",
"end",
"of",
"the",
"rules"
] | mozilla/libnfldap | python | https://github.com/mozilla/libnfldap/blob/27407a6ed6bfd07d1eba2824398c77e2fe98f968/libnfldap.py#L102-L107 | [
"def",
"appendDefaultDrop",
"(",
"self",
")",
":",
"self",
".",
"filters",
".",
"append",
"(",
"'-A INPUT -j DROP'",
")",
"self",
".",
"filters",
".",
"append",
"(",
"'-A OUTPUT -j DROP'",
")",
"self",
".",
"filters",
".",
"append",
"(",
"'-A FORWARD -j DROP'"... | 27407a6ed6bfd07d1eba2824398c77e2fe98f968 |
train | IPTables.template | Create a rules file in iptables-restore format | libnfldap.py | def template(self):
""" Create a rules file in iptables-restore format """
s = Template(self._IPTABLES_TEMPLATE)
return s.substitute(filtertable='\n'.join(self.filters),
rawtable='\n'.join(self.raw),
mangletable='\n'.join(self.mangle),
nattable='\n'.join(self.nat),
date=datetime.today(... | def template(self):
""" Create a rules file in iptables-restore format """
s = Template(self._IPTABLES_TEMPLATE)
return s.substitute(filtertable='\n'.join(self.filters),
rawtable='\n'.join(self.raw),
mangletable='\n'.join(self.mangle),
nattable='\n'.join(self.nat),
date=datetime.today(... | [
"Create",
"a",
"rules",
"file",
"in",
"iptables",
"-",
"restore",
"format"
] | mozilla/libnfldap | python | https://github.com/mozilla/libnfldap/blob/27407a6ed6bfd07d1eba2824398c77e2fe98f968/libnfldap.py#L155-L162 | [
"def",
"template",
"(",
"self",
")",
":",
"s",
"=",
"Template",
"(",
"self",
".",
"_IPTABLES_TEMPLATE",
")",
"return",
"s",
".",
"substitute",
"(",
"filtertable",
"=",
"'\\n'",
".",
"join",
"(",
"self",
".",
"filters",
")",
",",
"rawtable",
"=",
"'\\n'... | 27407a6ed6bfd07d1eba2824398c77e2fe98f968 |
train | IPset.template | Create a rules file in ipset --restore format | libnfldap.py | def template(self):
""" Create a rules file in ipset --restore format """
s = Template(self._IPSET_TEMPLATE)
return s.substitute(sets='\n'.join(self.sets),
date=datetime.today()) | def template(self):
""" Create a rules file in ipset --restore format """
s = Template(self._IPSET_TEMPLATE)
return s.substitute(sets='\n'.join(self.sets),
date=datetime.today()) | [
"Create",
"a",
"rules",
"file",
"in",
"ipset",
"--",
"restore",
"format"
] | mozilla/libnfldap | python | https://github.com/mozilla/libnfldap/blob/27407a6ed6bfd07d1eba2824398c77e2fe98f968/libnfldap.py#L210-L214 | [
"def",
"template",
"(",
"self",
")",
":",
"s",
"=",
"Template",
"(",
"self",
".",
"_IPSET_TEMPLATE",
")",
"return",
"s",
".",
"substitute",
"(",
"sets",
"=",
"'\\n'",
".",
"join",
"(",
"self",
".",
"sets",
")",
",",
"date",
"=",
"datetime",
".",
"t... | 27407a6ed6bfd07d1eba2824398c77e2fe98f968 |
train | LDAP.query | wrapper to search_s | libnfldap.py | def query(self, base, filterstr, attrlist=None):
""" wrapper to search_s """
return self.conn.search_s(base, ldap.SCOPE_SUBTREE, filterstr, attrlist) | def query(self, base, filterstr, attrlist=None):
""" wrapper to search_s """
return self.conn.search_s(base, ldap.SCOPE_SUBTREE, filterstr, attrlist) | [
"wrapper",
"to",
"search_s"
] | mozilla/libnfldap | python | https://github.com/mozilla/libnfldap/blob/27407a6ed6bfd07d1eba2824398c77e2fe98f968/libnfldap.py#L228-L230 | [
"def",
"query",
"(",
"self",
",",
"base",
",",
"filterstr",
",",
"attrlist",
"=",
"None",
")",
":",
"return",
"self",
".",
"conn",
".",
"search_s",
"(",
"base",
",",
"ldap",
".",
"SCOPE_SUBTREE",
",",
"filterstr",
",",
"attrlist",
")"
] | 27407a6ed6bfd07d1eba2824398c77e2fe98f968 |
train | LDAP.getUserByNumber | search for a user in LDAP and return its DN and uid | libnfldap.py | def getUserByNumber(self, base, uidNumber):
""" search for a user in LDAP and return its DN and uid """
res = self.query(base, "uidNumber="+str(uidNumber), ['uid'])
if len(res) > 1:
raise InputError(uidNumber, "Multiple users found. Expecting one.")
return res[0][0], res[0][1]['uid'][0] | def getUserByNumber(self, base, uidNumber):
""" search for a user in LDAP and return its DN and uid """
res = self.query(base, "uidNumber="+str(uidNumber), ['uid'])
if len(res) > 1:
raise InputError(uidNumber, "Multiple users found. Expecting one.")
return res[0][0], res[0][1]['uid'][0] | [
"search",
"for",
"a",
"user",
"in",
"LDAP",
"and",
"return",
"its",
"DN",
"and",
"uid"
] | mozilla/libnfldap | python | https://github.com/mozilla/libnfldap/blob/27407a6ed6bfd07d1eba2824398c77e2fe98f968/libnfldap.py#L232-L237 | [
"def",
"getUserByNumber",
"(",
"self",
",",
"base",
",",
"uidNumber",
")",
":",
"res",
"=",
"self",
".",
"query",
"(",
"base",
",",
"\"uidNumber=\"",
"+",
"str",
"(",
"uidNumber",
")",
",",
"[",
"'uid'",
"]",
")",
"if",
"len",
"(",
"res",
")",
">",... | 27407a6ed6bfd07d1eba2824398c77e2fe98f968 |
train | LDAP.getACLs | Query LDAP to obtain the network ACLs of a given user,
parse the ACLs, and return the results in a dict of the form
acls[group][cidr] = description | libnfldap.py | def getACLs(self, base, searchstr):
"""
Query LDAP to obtain the network ACLs of a given user,
parse the ACLs, and return the results in a dict of the form
acls[group][cidr] = description
"""
acls = dict()
res = self.query(base, searchstr, ['cn', 'ipHostNumber'])
for dn,attr in res:
cn = attr['cn'... | def getACLs(self, base, searchstr):
"""
Query LDAP to obtain the network ACLs of a given user,
parse the ACLs, and return the results in a dict of the form
acls[group][cidr] = description
"""
acls = dict()
res = self.query(base, searchstr, ['cn', 'ipHostNumber'])
for dn,attr in res:
cn = attr['cn'... | [
"Query",
"LDAP",
"to",
"obtain",
"the",
"network",
"ACLs",
"of",
"a",
"given",
"user",
"parse",
"the",
"ACLs",
"and",
"return",
"the",
"results",
"in",
"a",
"dict",
"of",
"the",
"form",
"acls",
"[",
"group",
"]",
"[",
"cidr",
"]",
"=",
"description"
] | mozilla/libnfldap | python | https://github.com/mozilla/libnfldap/blob/27407a6ed6bfd07d1eba2824398c77e2fe98f968/libnfldap.py#L239-L262 | [
"def",
"getACLs",
"(",
"self",
",",
"base",
",",
"searchstr",
")",
":",
"acls",
"=",
"dict",
"(",
")",
"res",
"=",
"self",
".",
"query",
"(",
"base",
",",
"searchstr",
",",
"[",
"'cn'",
",",
"'ipHostNumber'",
"]",
")",
"for",
"dn",
",",
"attr",
"... | 27407a6ed6bfd07d1eba2824398c77e2fe98f968 |
train | splitValues | Splits a comma-separated number sequence into a list (of floats). | src/python/pipelines_utils/parameter_utils.py | def splitValues(textStr):
"""Splits a comma-separated number sequence into a list (of floats).
"""
vals = textStr.split(",")
nums = []
for v in vals:
nums.append(float(v))
return nums | def splitValues(textStr):
"""Splits a comma-separated number sequence into a list (of floats).
"""
vals = textStr.split(",")
nums = []
for v in vals:
nums.append(float(v))
return nums | [
"Splits",
"a",
"comma",
"-",
"separated",
"number",
"sequence",
"into",
"a",
"list",
"(",
"of",
"floats",
")",
"."
] | InformaticsMatters/pipelines-utils | python | https://github.com/InformaticsMatters/pipelines-utils/blob/058aa6eceeff28c4ae402f6f58c58720bff0298e/src/python/pipelines_utils/parameter_utils.py#L49-L56 | [
"def",
"splitValues",
"(",
"textStr",
")",
":",
"vals",
"=",
"textStr",
".",
"split",
"(",
"\",\"",
")",
"nums",
"=",
"[",
"]",
"for",
"v",
"in",
"vals",
":",
"nums",
".",
"append",
"(",
"float",
"(",
"v",
")",
")",
"return",
"nums"
] | 058aa6eceeff28c4ae402f6f58c58720bff0298e |
train | expandParameters | Expands parameters (presented as tuples of lists and symbolic names)
so that each is returned in a new list where each contains the same number
of values.
Each `arg` is a tuple containing two items: a list of values and a
symbolic name. | src/python/pipelines_utils/parameter_utils.py | def expandParameters(*args):
"""Expands parameters (presented as tuples of lists and symbolic names)
so that each is returned in a new list where each contains the same number
of values.
Each `arg` is a tuple containing two items: a list of values and a
symbolic name.
"""
count = 1
for ... | def expandParameters(*args):
"""Expands parameters (presented as tuples of lists and symbolic names)
so that each is returned in a new list where each contains the same number
of values.
Each `arg` is a tuple containing two items: a list of values and a
symbolic name.
"""
count = 1
for ... | [
"Expands",
"parameters",
"(",
"presented",
"as",
"tuples",
"of",
"lists",
"and",
"symbolic",
"names",
")",
"so",
"that",
"each",
"is",
"returned",
"in",
"a",
"new",
"list",
"where",
"each",
"contains",
"the",
"same",
"number",
"of",
"values",
"."
] | InformaticsMatters/pipelines-utils | python | https://github.com/InformaticsMatters/pipelines-utils/blob/058aa6eceeff28c4ae402f6f58c58720bff0298e/src/python/pipelines_utils/parameter_utils.py#L59-L73 | [
"def",
"expandParameters",
"(",
"*",
"args",
")",
":",
"count",
"=",
"1",
"for",
"arg",
"in",
"args",
":",
"count",
"=",
"max",
"(",
"len",
"(",
"arg",
"[",
"0",
"]",
")",
",",
"count",
")",
"results",
"=",
"[",
"]",
"for",
"arg",
"in",
"args",... | 058aa6eceeff28c4ae402f6f58c58720bff0298e |
train | expandValues | Returns the input list with the length of `count`. If the
list is [1] and the count is 3. [1,1,1] is returned. The list
must be the count length or 1. Normally called from `expandParameters()`
where `name` is the symbolic name of the input. | src/python/pipelines_utils/parameter_utils.py | def expandValues(inputs, count, name):
"""Returns the input list with the length of `count`. If the
list is [1] and the count is 3. [1,1,1] is returned. The list
must be the count length or 1. Normally called from `expandParameters()`
where `name` is the symbolic name of the input.
"""
if len(in... | def expandValues(inputs, count, name):
"""Returns the input list with the length of `count`. If the
list is [1] and the count is 3. [1,1,1] is returned. The list
must be the count length or 1. Normally called from `expandParameters()`
where `name` is the symbolic name of the input.
"""
if len(in... | [
"Returns",
"the",
"input",
"list",
"with",
"the",
"length",
"of",
"count",
".",
"If",
"the",
"list",
"is",
"[",
"1",
"]",
"and",
"the",
"count",
"is",
"3",
".",
"[",
"1",
"1",
"1",
"]",
"is",
"returned",
".",
"The",
"list",
"must",
"be",
"the",
... | InformaticsMatters/pipelines-utils | python | https://github.com/InformaticsMatters/pipelines-utils/blob/058aa6eceeff28c4ae402f6f58c58720bff0298e/src/python/pipelines_utils/parameter_utils.py#L76-L88 | [
"def",
"expandValues",
"(",
"inputs",
",",
"count",
",",
"name",
")",
":",
"if",
"len",
"(",
"inputs",
")",
"==",
"count",
":",
"expanded",
"=",
"inputs",
"elif",
"len",
"(",
"inputs",
")",
"==",
"1",
":",
"expanded",
"=",
"inputs",
"*",
"count",
"... | 058aa6eceeff28c4ae402f6f58c58720bff0298e |
train | get_geo_ip | Returns geo IP info or empty dict if geoip query fails at http://ipstack.com.
requires settings.IPSTACK_TOKEN set as valid access token to the API.
Example replies:
{'country_name': 'United States', 'country_code': 'US', 'region_code': 'TX', 'region_name': 'Texas', 'ip': '76.184.236.184', 'latitude': 33.15... | jutil/request.py | def get_geo_ip(ip: str, exceptions: bool=False, timeout: int=10) -> dict:
"""
Returns geo IP info or empty dict if geoip query fails at http://ipstack.com.
requires settings.IPSTACK_TOKEN set as valid access token to the API.
Example replies:
{'country_name': 'United States', 'country_code': 'US', ... | def get_geo_ip(ip: str, exceptions: bool=False, timeout: int=10) -> dict:
"""
Returns geo IP info or empty dict if geoip query fails at http://ipstack.com.
requires settings.IPSTACK_TOKEN set as valid access token to the API.
Example replies:
{'country_name': 'United States', 'country_code': 'US', ... | [
"Returns",
"geo",
"IP",
"info",
"or",
"empty",
"dict",
"if",
"geoip",
"query",
"fails",
"at",
"http",
":",
"//",
"ipstack",
".",
"com",
".",
"requires",
"settings",
".",
"IPSTACK_TOKEN",
"set",
"as",
"valid",
"access",
"token",
"to",
"the",
"API",
"."
] | kajala/django-jutil | python | https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/request.py#L8-L36 | [
"def",
"get_geo_ip",
"(",
"ip",
":",
"str",
",",
"exceptions",
":",
"bool",
"=",
"False",
",",
"timeout",
":",
"int",
"=",
"10",
")",
"->",
"dict",
":",
"import",
"requests",
"import",
"traceback",
"try",
":",
"res",
"=",
"requests",
".",
"get",
"(",... | 2abd93ebad51042744eaeb1ee1074ed0eb55ad0c |
train | get_ip_info | Returns (ip, country_code, host) tuple of the IP address.
:param ip: IP address
:param exceptions: Raise Exception or not
:param timeout: Timeout in seconds. Note that timeout only affects geo IP part, not getting host name.
:return: (ip, country_code, host) | jutil/request.py | def get_ip_info(ip: str, exceptions: bool=False, timeout: int=10) -> tuple:
"""
Returns (ip, country_code, host) tuple of the IP address.
:param ip: IP address
:param exceptions: Raise Exception or not
:param timeout: Timeout in seconds. Note that timeout only affects geo IP part, not getting host n... | def get_ip_info(ip: str, exceptions: bool=False, timeout: int=10) -> tuple:
"""
Returns (ip, country_code, host) tuple of the IP address.
:param ip: IP address
:param exceptions: Raise Exception or not
:param timeout: Timeout in seconds. Note that timeout only affects geo IP part, not getting host n... | [
"Returns",
"(",
"ip",
"country_code",
"host",
")",
"tuple",
"of",
"the",
"IP",
"address",
".",
":",
"param",
"ip",
":",
"IP",
"address",
":",
"param",
"exceptions",
":",
"Raise",
"Exception",
"or",
"not",
":",
"param",
"timeout",
":",
"Timeout",
"in",
... | kajala/django-jutil | python | https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/request.py#L39-L61 | [
"def",
"get_ip_info",
"(",
"ip",
":",
"str",
",",
"exceptions",
":",
"bool",
"=",
"False",
",",
"timeout",
":",
"int",
"=",
"10",
")",
"->",
"tuple",
":",
"import",
"traceback",
"import",
"socket",
"if",
"not",
"ip",
":",
"# localhost",
"return",
"None... | 2abd93ebad51042744eaeb1ee1074ed0eb55ad0c |
train | is_aws | Determines if this system is on AWS
:return: bool True if this system is running on AWS | pycons3rt/awsapi/metadata.py | def is_aws():
"""Determines if this system is on AWS
:return: bool True if this system is running on AWS
"""
log = logging.getLogger(mod_logger + '.is_aws')
log.info('Querying AWS meta data URL: {u}'.format(u=metadata_url))
# Re-try logic for checking the AWS meta data URL
retry_time_sec =... | def is_aws():
"""Determines if this system is on AWS
:return: bool True if this system is running on AWS
"""
log = logging.getLogger(mod_logger + '.is_aws')
log.info('Querying AWS meta data URL: {u}'.format(u=metadata_url))
# Re-try logic for checking the AWS meta data URL
retry_time_sec =... | [
"Determines",
"if",
"this",
"system",
"is",
"on",
"AWS"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/metadata.py#L44-L79 | [
"def",
"is_aws",
"(",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.is_aws'",
")",
"log",
".",
"info",
"(",
"'Querying AWS meta data URL: {u}'",
".",
"format",
"(",
"u",
"=",
"metadata_url",
")",
")",
"# Re-try logic for checkin... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | get_instance_id | Gets the instance ID of this EC2 instance
:return: String instance ID or None | pycons3rt/awsapi/metadata.py | def get_instance_id():
"""Gets the instance ID of this EC2 instance
:return: String instance ID or None
"""
log = logging.getLogger(mod_logger + '.get_instance_id')
# Exit if not running on AWS
if not is_aws():
log.info('This machine is not running in AWS, exiting...')
return
... | def get_instance_id():
"""Gets the instance ID of this EC2 instance
:return: String instance ID or None
"""
log = logging.getLogger(mod_logger + '.get_instance_id')
# Exit if not running on AWS
if not is_aws():
log.info('This machine is not running in AWS, exiting...')
return
... | [
"Gets",
"the",
"instance",
"ID",
"of",
"this",
"EC2",
"instance"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/metadata.py#L82-L110 | [
"def",
"get_instance_id",
"(",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.get_instance_id'",
")",
"# Exit if not running on AWS",
"if",
"not",
"is_aws",
"(",
")",
":",
"log",
".",
"info",
"(",
"'This machine is not running in AWS... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | get_vpc_id_from_mac_address | Gets the VPC ID for this EC2 instance
:return: String instance ID or None | pycons3rt/awsapi/metadata.py | def get_vpc_id_from_mac_address():
"""Gets the VPC ID for this EC2 instance
:return: String instance ID or None
"""
log = logging.getLogger(mod_logger + '.get_vpc_id')
# Exit if not running on AWS
if not is_aws():
log.info('This machine is not running in AWS, exiting...')
retur... | def get_vpc_id_from_mac_address():
"""Gets the VPC ID for this EC2 instance
:return: String instance ID or None
"""
log = logging.getLogger(mod_logger + '.get_vpc_id')
# Exit if not running on AWS
if not is_aws():
log.info('This machine is not running in AWS, exiting...')
retur... | [
"Gets",
"the",
"VPC",
"ID",
"for",
"this",
"EC2",
"instance"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/metadata.py#L113-L151 | [
"def",
"get_vpc_id_from_mac_address",
"(",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.get_vpc_id'",
")",
"# Exit if not running on AWS",
"if",
"not",
"is_aws",
"(",
")",
":",
"log",
".",
"info",
"(",
"'This machine is not running... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | get_availability_zone | Gets the AWS Availability Zone ID for this system
:return: (str) Availability Zone ID where this system lives | pycons3rt/awsapi/metadata.py | def get_availability_zone():
"""Gets the AWS Availability Zone ID for this system
:return: (str) Availability Zone ID where this system lives
"""
log = logging.getLogger(mod_logger + '.get_availability_zone')
# Exit if not running on AWS
if not is_aws():
log.info('This machine is not r... | def get_availability_zone():
"""Gets the AWS Availability Zone ID for this system
:return: (str) Availability Zone ID where this system lives
"""
log = logging.getLogger(mod_logger + '.get_availability_zone')
# Exit if not running on AWS
if not is_aws():
log.info('This machine is not r... | [
"Gets",
"the",
"AWS",
"Availability",
"Zone",
"ID",
"for",
"this",
"system"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/metadata.py#L195-L222 | [
"def",
"get_availability_zone",
"(",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.get_availability_zone'",
")",
"# Exit if not running on AWS",
"if",
"not",
"is_aws",
"(",
")",
":",
"log",
".",
"info",
"(",
"'This machine is not ru... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | get_region | Gets the AWS Region ID for this system
:return: (str) AWS Region ID where this system lives | pycons3rt/awsapi/metadata.py | def get_region():
"""Gets the AWS Region ID for this system
:return: (str) AWS Region ID where this system lives
"""
log = logging.getLogger(mod_logger + '.get_region')
# First get the availability zone
availability_zone = get_availability_zone()
if availability_zone is None:
msg ... | def get_region():
"""Gets the AWS Region ID for this system
:return: (str) AWS Region ID where this system lives
"""
log = logging.getLogger(mod_logger + '.get_region')
# First get the availability zone
availability_zone = get_availability_zone()
if availability_zone is None:
msg ... | [
"Gets",
"the",
"AWS",
"Region",
"ID",
"for",
"this",
"system"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/metadata.py#L225-L242 | [
"def",
"get_region",
"(",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.get_region'",
")",
"# First get the availability zone",
"availability_zone",
"=",
"get_availability_zone",
"(",
")",
"if",
"availability_zone",
"is",
"None",
":",... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | get_primary_mac_address | Determines the MAC address to use for querying the AWS
meta data service for network related queries
:return: (str) MAC address for the eth0 interface
:raises: AWSMetaDataError | pycons3rt/awsapi/metadata.py | def get_primary_mac_address():
"""Determines the MAC address to use for querying the AWS
meta data service for network related queries
:return: (str) MAC address for the eth0 interface
:raises: AWSMetaDataError
"""
log = logging.getLogger(mod_logger + '.get_primary_mac_address')
log.debug('... | def get_primary_mac_address():
"""Determines the MAC address to use for querying the AWS
meta data service for network related queries
:return: (str) MAC address for the eth0 interface
:raises: AWSMetaDataError
"""
log = logging.getLogger(mod_logger + '.get_primary_mac_address')
log.debug('... | [
"Determines",
"the",
"MAC",
"address",
"to",
"use",
"for",
"querying",
"the",
"AWS",
"meta",
"data",
"service",
"for",
"network",
"related",
"queries"
] | cons3rt/pycons3rt | python | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/metadata.py#L245-L261 | [
"def",
"get_primary_mac_address",
"(",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.get_primary_mac_address'",
")",
"log",
".",
"debug",
"(",
"'Attempting to determine the MAC address for eth0...'",
")",
"try",
":",
"mac_address",
"=",... | f004ab3a35c5bff2f698131fef3b2a8ed5a7596d |
train | BaseSqlaParser.attr_sep | Set the new value for the attribute separator.
When the new value is assigned a new tree is generated. | src/sqla_filters/parser/base/base_sqla_parser.py | def attr_sep(self, new_sep: str) -> None:
"""Set the new value for the attribute separator.
When the new value is assigned a new tree is generated.
"""
self._attr_sep = new_sep
self._filters_tree = self._generate_filters_tree() | def attr_sep(self, new_sep: str) -> None:
"""Set the new value for the attribute separator.
When the new value is assigned a new tree is generated.
"""
self._attr_sep = new_sep
self._filters_tree = self._generate_filters_tree() | [
"Set",
"the",
"new",
"value",
"for",
"the",
"attribute",
"separator",
".",
"When",
"the",
"new",
"value",
"is",
"assigned",
"a",
"new",
"tree",
"is",
"generated",
"."
] | MarcAureleCoste/sqla-filters | python | https://github.com/MarcAureleCoste/sqla-filters/blob/a9596f660a11d275bf0e831ecd9e502b0af2a087/src/sqla_filters/parser/base/base_sqla_parser.py#L23-L29 | [
"def",
"attr_sep",
"(",
"self",
",",
"new_sep",
":",
"str",
")",
"->",
"None",
":",
"self",
".",
"_attr_sep",
"=",
"new_sep",
"self",
".",
"_filters_tree",
"=",
"self",
".",
"_generate_filters_tree",
"(",
")"
] | a9596f660a11d275bf0e831ecd9e502b0af2a087 |
train | url_equals | Compares two URLs/paths and returns True if they point to same URI.
For example, querystring parameters can be different order but URLs are still equal.
:param a: URL/path
:param b: URL/path
:return: True if URLs/paths are equal | jutil/urls.py | def url_equals(a: str, b: str) -> bool:
"""
Compares two URLs/paths and returns True if they point to same URI.
For example, querystring parameters can be different order but URLs are still equal.
:param a: URL/path
:param b: URL/path
:return: True if URLs/paths are equal
"""
from urllib... | def url_equals(a: str, b: str) -> bool:
"""
Compares two URLs/paths and returns True if they point to same URI.
For example, querystring parameters can be different order but URLs are still equal.
:param a: URL/path
:param b: URL/path
:return: True if URLs/paths are equal
"""
from urllib... | [
"Compares",
"two",
"URLs",
"/",
"paths",
"and",
"returns",
"True",
"if",
"they",
"point",
"to",
"same",
"URI",
".",
"For",
"example",
"querystring",
"parameters",
"can",
"be",
"different",
"order",
"but",
"URLs",
"are",
"still",
"equal",
".",
":",
"param",... | kajala/django-jutil | python | https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/urls.py#L1-L14 | [
"def",
"url_equals",
"(",
"a",
":",
"str",
",",
"b",
":",
"str",
")",
"->",
"bool",
":",
"from",
"urllib",
".",
"parse",
"import",
"urlparse",
",",
"parse_qsl",
"a2",
"=",
"list",
"(",
"urlparse",
"(",
"a",
")",
")",
"b2",
"=",
"list",
"(",
"urlp... | 2abd93ebad51042744eaeb1ee1074ed0eb55ad0c |
train | url_mod | Modifies existing URL by setting/overriding specified query string parameters.
Note: Does not support multiple querystring parameters with identical name.
:param url: Base URL/path to modify
:param new_params: Querystring parameters to set/override (dict)
:return: New URL/path | jutil/urls.py | def url_mod(url: str, new_params: dict) -> str:
"""
Modifies existing URL by setting/overriding specified query string parameters.
Note: Does not support multiple querystring parameters with identical name.
:param url: Base URL/path to modify
:param new_params: Querystring parameters to set/override... | def url_mod(url: str, new_params: dict) -> str:
"""
Modifies existing URL by setting/overriding specified query string parameters.
Note: Does not support multiple querystring parameters with identical name.
:param url: Base URL/path to modify
:param new_params: Querystring parameters to set/override... | [
"Modifies",
"existing",
"URL",
"by",
"setting",
"/",
"overriding",
"specified",
"query",
"string",
"parameters",
".",
"Note",
":",
"Does",
"not",
"support",
"multiple",
"querystring",
"parameters",
"with",
"identical",
"name",
".",
":",
"param",
"url",
":",
"B... | kajala/django-jutil | python | https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/urls.py#L17-L35 | [
"def",
"url_mod",
"(",
"url",
":",
"str",
",",
"new_params",
":",
"dict",
")",
"->",
"str",
":",
"from",
"urllib",
".",
"parse",
"import",
"urlparse",
",",
"parse_qsl",
",",
"urlunparse",
",",
"urlencode",
"res",
"=",
"urlparse",
"(",
"url",
")",
"quer... | 2abd93ebad51042744eaeb1ee1074ed0eb55ad0c |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.