repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
cons3rt/pycons3rt
pycons3rt/awsapi/ec2util.py
EC2Util.get_elastic_ips
def get_elastic_ips(self): """Returns the elastic IP info for this instance any are attached :return: (dict) Info about the Elastic IPs :raises AWSAPIError """ log = logging.getLogger(self.cls_logger + '.get_elastic_ips') instance_id = get_instance_id() i...
python
def get_elastic_ips(self): """Returns the elastic IP info for this instance any are attached :return: (dict) Info about the Elastic IPs :raises AWSAPIError """ log = logging.getLogger(self.cls_logger + '.get_elastic_ips') instance_id = get_instance_id() i...
[ "def", "get_elastic_ips", "(", "self", ")", ":", "log", "=", "logging", ".", "getLogger", "(", "self", ".", "cls_logger", "+", "'.get_elastic_ips'", ")", "instance_id", "=", "get_instance_id", "(", ")", "if", "instance_id", "is", "None", ":", "log", ".", "...
Returns the elastic IP info for this instance any are attached :return: (dict) Info about the Elastic IPs :raises AWSAPIError
[ "Returns", "the", "elastic", "IP", "info", "for", "this", "instance", "any", "are", "attached" ]
f004ab3a35c5bff2f698131fef3b2a8ed5a7596d
https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/ec2util.py#L491-L546
train
cons3rt/pycons3rt
pycons3rt/awsapi/ec2util.py
EC2Util.disassociate_elastic_ips
def disassociate_elastic_ips(self): """For each attached Elastic IP, disassociate it :return: None :raises AWSAPIError """ log = logging.getLogger(self.cls_logger + '.disassociate_elastic_ips') try: address_info = self.get_elastic_ips() except AWSAPI...
python
def disassociate_elastic_ips(self): """For each attached Elastic IP, disassociate it :return: None :raises AWSAPIError """ log = logging.getLogger(self.cls_logger + '.disassociate_elastic_ips') try: address_info = self.get_elastic_ips() except AWSAPI...
[ "def", "disassociate_elastic_ips", "(", "self", ")", ":", "log", "=", "logging", ".", "getLogger", "(", "self", ".", "cls_logger", "+", "'.disassociate_elastic_ips'", ")", "try", ":", "address_info", "=", "self", ".", "get_elastic_ips", "(", ")", "except", "AW...
For each attached Elastic IP, disassociate it :return: None :raises AWSAPIError
[ "For", "each", "attached", "Elastic", "IP", "disassociate", "it" ]
f004ab3a35c5bff2f698131fef3b2a8ed5a7596d
https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/ec2util.py#L548-L584
train
cons3rt/pycons3rt
pycons3rt/awsapi/ec2util.py
EC2Util.create_security_group
def create_security_group(self, name, description='', vpc_id=None): """Creates a new Security Group with the specified name, description, in the specified vpc_id if provided. If vpc_id is not provided, use self.vpc_id :param name: (str) Security Group Name :param description: (...
python
def create_security_group(self, name, description='', vpc_id=None): """Creates a new Security Group with the specified name, description, in the specified vpc_id if provided. If vpc_id is not provided, use self.vpc_id :param name: (str) Security Group Name :param description: (...
[ "def", "create_security_group", "(", "self", ",", "name", ",", "description", "=", "''", ",", "vpc_id", "=", "None", ")", ":", "log", "=", "logging", ".", "getLogger", "(", "self", ".", "cls_logger", "+", "'.create_security_group'", ")", "# Validate args", "...
Creates a new Security Group with the specified name, description, in the specified vpc_id if provided. If vpc_id is not provided, use self.vpc_id :param name: (str) Security Group Name :param description: (str) Security Group Description :param vpc_id: (str) VPC ID to create t...
[ "Creates", "a", "new", "Security", "Group", "with", "the", "specified", "name", "description", "in", "the", "specified", "vpc_id", "if", "provided", ".", "If", "vpc_id", "is", "not", "provided", "use", "self", ".", "vpc_id" ]
f004ab3a35c5bff2f698131fef3b2a8ed5a7596d
https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/ec2util.py#L586-L667
train
cons3rt/pycons3rt
pycons3rt/awsapi/ec2util.py
EC2Util.list_security_groups_in_vpc
def list_security_groups_in_vpc(self, vpc_id=None): """Lists security groups in the VPC. If vpc_id is not provided, use self.vpc_id :param vpc_id: (str) VPC ID to list security groups for :return: (list) Security Group info :raises: AWSAPIError, EC2UtilError """ log = l...
python
def list_security_groups_in_vpc(self, vpc_id=None): """Lists security groups in the VPC. If vpc_id is not provided, use self.vpc_id :param vpc_id: (str) VPC ID to list security groups for :return: (list) Security Group info :raises: AWSAPIError, EC2UtilError """ log = l...
[ "def", "list_security_groups_in_vpc", "(", "self", ",", "vpc_id", "=", "None", ")", ":", "log", "=", "logging", ".", "getLogger", "(", "self", ".", "cls_logger", "+", "'.list_security_groups_in_vpc'", ")", "if", "vpc_id", "is", "None", "and", "self", ".", "v...
Lists security groups in the VPC. If vpc_id is not provided, use self.vpc_id :param vpc_id: (str) VPC ID to list security groups for :return: (list) Security Group info :raises: AWSAPIError, EC2UtilError
[ "Lists", "security", "groups", "in", "the", "VPC", ".", "If", "vpc_id", "is", "not", "provided", "use", "self", ".", "vpc_id" ]
f004ab3a35c5bff2f698131fef3b2a8ed5a7596d
https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/ec2util.py#L669-L701
train
cons3rt/pycons3rt
pycons3rt/awsapi/ec2util.py
EC2Util.configure_security_group_ingress
def configure_security_group_ingress(self, security_group_id, port, desired_cidr_blocks): """Configures the security group ID allowing access only to the specified CIDR blocks, for the specified port number. :param security_group_id: (str) Security Group ID :param port: (str) TC...
python
def configure_security_group_ingress(self, security_group_id, port, desired_cidr_blocks): """Configures the security group ID allowing access only to the specified CIDR blocks, for the specified port number. :param security_group_id: (str) Security Group ID :param port: (str) TC...
[ "def", "configure_security_group_ingress", "(", "self", ",", "security_group_id", ",", "port", ",", "desired_cidr_blocks", ")", ":", "log", "=", "logging", ".", "getLogger", "(", "self", ".", "cls_logger", "+", "'.configure_security_group_ingress'", ")", "# Validate a...
Configures the security group ID allowing access only to the specified CIDR blocks, for the specified port number. :param security_group_id: (str) Security Group ID :param port: (str) TCP Port number :param desired_cidr_blocks: (list) List of desired CIDR blocks, ...
[ "Configures", "the", "security", "group", "ID", "allowing", "access", "only", "to", "the", "specified", "CIDR", "blocks", "for", "the", "specified", "port", "number", "." ]
f004ab3a35c5bff2f698131fef3b2a8ed5a7596d
https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/ec2util.py#L703-L810
train
cons3rt/pycons3rt
pycons3rt/awsapi/ec2util.py
EC2Util.revoke_security_group_ingress
def revoke_security_group_ingress(self, security_group_id, ingress_rules): """Revokes all ingress rules for a security group bu ID :param security_group_id: (str) Security Group ID :param port: (str) TCP Port number :param ingress_rules: (list) List of IP permissions (see AWS API docs r...
python
def revoke_security_group_ingress(self, security_group_id, ingress_rules): """Revokes all ingress rules for a security group bu ID :param security_group_id: (str) Security Group ID :param port: (str) TCP Port number :param ingress_rules: (list) List of IP permissions (see AWS API docs r...
[ "def", "revoke_security_group_ingress", "(", "self", ",", "security_group_id", ",", "ingress_rules", ")", ":", "log", "=", "logging", ".", "getLogger", "(", "self", ".", "cls_logger", "+", "'.revoke_security_group_ingress'", ")", "log", ".", "info", "(", "'Revokin...
Revokes all ingress rules for a security group bu ID :param security_group_id: (str) Security Group ID :param port: (str) TCP Port number :param ingress_rules: (list) List of IP permissions (see AWS API docs re: IpPermissions) :return: None :raises: AWSAPIError, EC2UtilError
[ "Revokes", "all", "ingress", "rules", "for", "a", "security", "group", "bu", "ID" ]
f004ab3a35c5bff2f698131fef3b2a8ed5a7596d
https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/ec2util.py#L812-L832
train
cons3rt/pycons3rt
pycons3rt/awsapi/ec2util.py
EC2Util.launch_instance
def launch_instance(self, ami_id, key_name, subnet_id, security_group_id=None, security_group_list=None, user_data_script_path=None, instance_type='t2.small', root_device_name='/dev/xvda'): """Launches an EC2 instance with the specified parameters, intended to launch an instance ...
python
def launch_instance(self, ami_id, key_name, subnet_id, security_group_id=None, security_group_list=None, user_data_script_path=None, instance_type='t2.small', root_device_name='/dev/xvda'): """Launches an EC2 instance with the specified parameters, intended to launch an instance ...
[ "def", "launch_instance", "(", "self", ",", "ami_id", ",", "key_name", ",", "subnet_id", ",", "security_group_id", "=", "None", ",", "security_group_list", "=", "None", ",", "user_data_script_path", "=", "None", ",", "instance_type", "=", "'t2.small'", ",", "roo...
Launches an EC2 instance with the specified parameters, intended to launch an instance for creation of a CONS3RT template. :param ami_id: (str) ID of the AMI to launch from :param key_name: (str) Name of the key-pair to use :param subnet_id: (str) IF of the VPC subnet to attach the inst...
[ "Launches", "an", "EC2", "instance", "with", "the", "specified", "parameters", "intended", "to", "launch", "an", "instance", "for", "creation", "of", "a", "CONS3RT", "template", "." ]
f004ab3a35c5bff2f698131fef3b2a8ed5a7596d
https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/ec2util.py#L834-L903
train
cons3rt/pycons3rt
pycons3rt/awsapi/ec2util.py
EC2Util.get_ec2_instances
def get_ec2_instances(self): """Describes the EC2 instances :return: dict containing EC2 instance data :raises: EC2UtilError """ log = logging.getLogger(self.cls_logger + '.get_ec2_instances') log.info('Describing EC2 instances...') try: response = se...
python
def get_ec2_instances(self): """Describes the EC2 instances :return: dict containing EC2 instance data :raises: EC2UtilError """ log = logging.getLogger(self.cls_logger + '.get_ec2_instances') log.info('Describing EC2 instances...') try: response = se...
[ "def", "get_ec2_instances", "(", "self", ")", ":", "log", "=", "logging", ".", "getLogger", "(", "self", ".", "cls_logger", "+", "'.get_ec2_instances'", ")", "log", ".", "info", "(", "'Describing EC2 instances...'", ")", "try", ":", "response", "=", "self", ...
Describes the EC2 instances :return: dict containing EC2 instance data :raises: EC2UtilError
[ "Describes", "the", "EC2", "instances" ]
f004ab3a35c5bff2f698131fef3b2a8ed5a7596d
https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/ec2util.py#L905-L919
train
novopl/peltak
src/peltak/commands/docs.py
docs_cli
def docs_cli(ctx, recreate, gen_index, run_doctests): # type: (click.Context, bool, bool, bool) -> None """ Build project documentation. This command will run sphinx-refdoc first to generate the reference documentation for the code base. Then it will run sphinx to generate the final docs. You can c...
python
def docs_cli(ctx, recreate, gen_index, run_doctests): # type: (click.Context, bool, bool, bool) -> None """ Build project documentation. This command will run sphinx-refdoc first to generate the reference documentation for the code base. Then it will run sphinx to generate the final docs. You can c...
[ "def", "docs_cli", "(", "ctx", ",", "recreate", ",", "gen_index", ",", "run_doctests", ")", ":", "# type: (click.Context, bool, bool, bool) -> None", "if", "ctx", ".", "invoked_subcommand", ":", "return", "from", "peltak", ".", "logic", "import", "docs", "docs", "...
Build project documentation. This command will run sphinx-refdoc first to generate the reference documentation for the code base. Then it will run sphinx to generate the final docs. You can configure the directory that stores the docs source (index.rst, conf.py, etc.) using the DOC_SRC_PATH conf variab...
[ "Build", "project", "documentation", "." ]
b627acc019e3665875fe76cdca0a14773b69beaa
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/commands/docs.py#L52-L88
train
Josef-Friedrich/phrydy
phrydy/utils.py
as_string
def as_string(value): """Convert a value to a Unicode object for matching with a query. None becomes the empty string. Bytestrings are silently decoded. """ if six.PY2: buffer_types = buffer, memoryview # noqa: F821 else: buffer_types = memoryview if value is None: retu...
python
def as_string(value): """Convert a value to a Unicode object for matching with a query. None becomes the empty string. Bytestrings are silently decoded. """ if six.PY2: buffer_types = buffer, memoryview # noqa: F821 else: buffer_types = memoryview if value is None: retu...
[ "def", "as_string", "(", "value", ")", ":", "if", "six", ".", "PY2", ":", "buffer_types", "=", "buffer", ",", "memoryview", "# noqa: F821", "else", ":", "buffer_types", "=", "memoryview", "if", "value", "is", "None", ":", "return", "u''", "elif", "isinstan...
Convert a value to a Unicode object for matching with a query. None becomes the empty string. Bytestrings are silently decoded.
[ "Convert", "a", "value", "to", "a", "Unicode", "object", "for", "matching", "with", "a", "query", ".", "None", "becomes", "the", "empty", "string", ".", "Bytestrings", "are", "silently", "decoded", "." ]
aa13755155977b4776e49f79984f9968ac1d74dc
https://github.com/Josef-Friedrich/phrydy/blob/aa13755155977b4776e49f79984f9968ac1d74dc/phrydy/utils.py#L23-L39
train
Josef-Friedrich/phrydy
phrydy/utils.py
displayable_path
def displayable_path(path, separator=u'; '): """Attempts to decode a bytestring path to a unicode object for the purpose of displaying it to the user. If the `path` argument is a list or a tuple, the elements are joined with `separator`. """ if isinstance(path, (list, tuple)): return separat...
python
def displayable_path(path, separator=u'; '): """Attempts to decode a bytestring path to a unicode object for the purpose of displaying it to the user. If the `path` argument is a list or a tuple, the elements are joined with `separator`. """ if isinstance(path, (list, tuple)): return separat...
[ "def", "displayable_path", "(", "path", ",", "separator", "=", "u'; '", ")", ":", "if", "isinstance", "(", "path", ",", "(", "list", ",", "tuple", ")", ")", ":", "return", "separator", ".", "join", "(", "displayable_path", "(", "p", ")", "for", "p", ...
Attempts to decode a bytestring path to a unicode object for the purpose of displaying it to the user. If the `path` argument is a list or a tuple, the elements are joined with `separator`.
[ "Attempts", "to", "decode", "a", "bytestring", "path", "to", "a", "unicode", "object", "for", "the", "purpose", "of", "displaying", "it", "to", "the", "user", ".", "If", "the", "path", "argument", "is", "a", "list", "or", "a", "tuple", "the", "elements",...
aa13755155977b4776e49f79984f9968ac1d74dc
https://github.com/Josef-Friedrich/phrydy/blob/aa13755155977b4776e49f79984f9968ac1d74dc/phrydy/utils.py#L42-L58
train
Josef-Friedrich/phrydy
phrydy/utils.py
syspath
def syspath(path, prefix=True): """Convert a path for use by the operating system. In particular, paths on Windows must receive a magic prefix and must be converted to Unicode before they are sent to the OS. To disable the magic prefix on Windows, set `prefix` to False---but only do this if you *rea...
python
def syspath(path, prefix=True): """Convert a path for use by the operating system. In particular, paths on Windows must receive a magic prefix and must be converted to Unicode before they are sent to the OS. To disable the magic prefix on Windows, set `prefix` to False---but only do this if you *rea...
[ "def", "syspath", "(", "path", ",", "prefix", "=", "True", ")", ":", "# Don't do anything if we're not on windows", "if", "os", ".", "path", ".", "__name__", "!=", "'ntpath'", ":", "return", "path", "if", "not", "isinstance", "(", "path", ",", "six", ".", ...
Convert a path for use by the operating system. In particular, paths on Windows must receive a magic prefix and must be converted to Unicode before they are sent to the OS. To disable the magic prefix on Windows, set `prefix` to False---but only do this if you *really* know what you're doing.
[ "Convert", "a", "path", "for", "use", "by", "the", "operating", "system", ".", "In", "particular", "paths", "on", "Windows", "must", "receive", "a", "magic", "prefix", "and", "must", "be", "converted", "to", "Unicode", "before", "they", "are", "sent", "to"...
aa13755155977b4776e49f79984f9968ac1d74dc
https://github.com/Josef-Friedrich/phrydy/blob/aa13755155977b4776e49f79984f9968ac1d74dc/phrydy/utils.py#L61-L92
train
cfobel/pygtk3-helpers
pygtk3_helpers/ui/notebook.py
NotebookManagerView.on_new
def on_new(self, button): ''' Copy selected notebook template to notebook directory. ## Notes ## - An exception is raised if the parent of the selected file is the notebook directory. - If notebook with same name already exists in notebook directory, off...
python
def on_new(self, button): ''' Copy selected notebook template to notebook directory. ## Notes ## - An exception is raised if the parent of the selected file is the notebook directory. - If notebook with same name already exists in notebook directory, off...
[ "def", "on_new", "(", "self", ",", "button", ")", ":", "buttons", "=", "(", "Gtk", ".", "STOCK_CANCEL", ",", "Gtk", ".", "ResponseType", ".", "CANCEL", ",", "Gtk", ".", "STOCK_OPEN", ",", "Gtk", ".", "ResponseType", ".", "OK", ")", "dialog", "=", "Gt...
Copy selected notebook template to notebook directory. ## Notes ## - An exception is raised if the parent of the selected file is the notebook directory. - If notebook with same name already exists in notebook directory, offer is made to overwrite (the new copy of the f...
[ "Copy", "selected", "notebook", "template", "to", "notebook", "directory", "." ]
ae793cb34a5c1bbe40cc83bb8a6084f0eeed2519
https://github.com/cfobel/pygtk3-helpers/blob/ae793cb34a5c1bbe40cc83bb8a6084f0eeed2519/pygtk3_helpers/ui/notebook.py#L52-L94
train
kajala/django-jutil
jutil/management/commands/bank_const_se.py
se_iban_load_map
def se_iban_load_map(filename: str) -> list: """ Loads Swedish monetary institution codes in CSV format. :param filename: CSV file name of the BIC definitions. Columns: Institution Name, Range Begin-Range End (inclusive), Account digits count :return: List of (bank name, clearing code begin, clearin...
python
def se_iban_load_map(filename: str) -> list: """ Loads Swedish monetary institution codes in CSV format. :param filename: CSV file name of the BIC definitions. Columns: Institution Name, Range Begin-Range End (inclusive), Account digits count :return: List of (bank name, clearing code begin, clearin...
[ "def", "se_iban_load_map", "(", "filename", ":", "str", ")", "->", "list", ":", "out", "=", "[", "]", "name_repl", "=", "{", "'BNP Paribas Fortis SA/NV, Bankfilial Sverige'", ":", "'BNP Paribas Fortis SA/NV'", ",", "'Citibank International Plc, Sweden Branch'", ":", "'C...
Loads Swedish monetary institution codes in CSV format. :param filename: CSV file name of the BIC definitions. Columns: Institution Name, Range Begin-Range End (inclusive), Account digits count :return: List of (bank name, clearing code begin, clearing code end, account digits)
[ "Loads", "Swedish", "monetary", "institution", "codes", "in", "CSV", "format", ".", ":", "param", "filename", ":", "CSV", "file", "name", "of", "the", "BIC", "definitions", ".", "Columns", ":", "Institution", "Name", "Range", "Begin", "-", "Range", "End", ...
2abd93ebad51042744eaeb1ee1074ed0eb55ad0c
https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/management/commands/bank_const_se.py#L11-L68
train
kajala/django-jutil
jutil/admin.py
admin_log
def admin_log(instances, msg: str, who: User=None, **kw): """ Logs an entry to admin logs of model(s). :param instances: Model instance or list of instances :param msg: Message to log :param who: Who did the change :param kw: Optional key-value attributes to append to message :return: None ...
python
def admin_log(instances, msg: str, who: User=None, **kw): """ Logs an entry to admin logs of model(s). :param instances: Model instance or list of instances :param msg: Message to log :param who: Who did the change :param kw: Optional key-value attributes to append to message :return: None ...
[ "def", "admin_log", "(", "instances", ",", "msg", ":", "str", ",", "who", ":", "User", "=", "None", ",", "*", "*", "kw", ")", ":", "from", "django", ".", "contrib", ".", "admin", ".", "models", "import", "LogEntry", ",", "CHANGE", "from", "django", ...
Logs an entry to admin logs of model(s). :param instances: Model instance or list of instances :param msg: Message to log :param who: Who did the change :param kw: Optional key-value attributes to append to message :return: None
[ "Logs", "an", "entry", "to", "admin", "logs", "of", "model", "(", "s", ")", ".", ":", "param", "instances", ":", "Model", "instance", "or", "list", "of", "instances", ":", "param", "msg", ":", "Message", "to", "log", ":", "param", "who", ":", "Who", ...
2abd93ebad51042744eaeb1ee1074ed0eb55ad0c
https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/admin.py#L15-L55
train
kajala/django-jutil
jutil/admin.py
ModelAdminBase.kw_changelist_view
def kw_changelist_view(self, request: HttpRequest, extra_context=None, **kw): """ Changelist view which allow key-value arguments. :param request: HttpRequest :param extra_context: Extra context dict :param kw: Key-value dict :return: See changelist_view() """ ...
python
def kw_changelist_view(self, request: HttpRequest, extra_context=None, **kw): """ Changelist view which allow key-value arguments. :param request: HttpRequest :param extra_context: Extra context dict :param kw: Key-value dict :return: See changelist_view() """ ...
[ "def", "kw_changelist_view", "(", "self", ",", "request", ":", "HttpRequest", ",", "extra_context", "=", "None", ",", "*", "*", "kw", ")", ":", "return", "self", ".", "changelist_view", "(", "request", ",", "extra_context", ")" ]
Changelist view which allow key-value arguments. :param request: HttpRequest :param extra_context: Extra context dict :param kw: Key-value dict :return: See changelist_view()
[ "Changelist", "view", "which", "allow", "key", "-", "value", "arguments", ".", ":", "param", "request", ":", "HttpRequest", ":", "param", "extra_context", ":", "Extra", "context", "dict", ":", "param", "kw", ":", "Key", "-", "value", "dict", ":", "return",...
2abd93ebad51042744eaeb1ee1074ed0eb55ad0c
https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/admin.py#L65-L73
train
kajala/django-jutil
jutil/admin.py
ModelAdminBase.history_view
def history_view(self, request, object_id, extra_context=None): from django.template.response import TemplateResponse from django.contrib.admin.options import get_content_type_for_model from django.contrib.admin.utils import unquote from django.core.exceptions import PermissionDenied ...
python
def history_view(self, request, object_id, extra_context=None): from django.template.response import TemplateResponse from django.contrib.admin.options import get_content_type_for_model from django.contrib.admin.utils import unquote from django.core.exceptions import PermissionDenied ...
[ "def", "history_view", "(", "self", ",", "request", ",", "object_id", ",", "extra_context", "=", "None", ")", ":", "from", "django", ".", "template", ".", "response", "import", "TemplateResponse", "from", "django", ".", "contrib", ".", "admin", ".", "options...
The 'history' admin view for this model.
[ "The", "history", "admin", "view", "for", "this", "model", "." ]
2abd93ebad51042744eaeb1ee1074ed0eb55ad0c
https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/admin.py#L75-L120
train
kajala/django-jutil
jutil/admin.py
AdminFileDownloadMixin.get_object_by_filename
def get_object_by_filename(self, request, filename): """ Returns owner object by filename (to be downloaded). This can be used to implement custom permission checks. :param request: HttpRequest :param filename: File name of the downloaded object. :return: owner object ...
python
def get_object_by_filename(self, request, filename): """ Returns owner object by filename (to be downloaded). This can be used to implement custom permission checks. :param request: HttpRequest :param filename: File name of the downloaded object. :return: owner object ...
[ "def", "get_object_by_filename", "(", "self", ",", "request", ",", "filename", ")", ":", "kw", "=", "dict", "(", ")", "kw", "[", "self", ".", "file_field", "]", "=", "filename", "obj", "=", "self", ".", "get_queryset", "(", "request", ")", ".", "filter...
Returns owner object by filename (to be downloaded). This can be used to implement custom permission checks. :param request: HttpRequest :param filename: File name of the downloaded object. :return: owner object
[ "Returns", "owner", "object", "by", "filename", "(", "to", "be", "downloaded", ")", ".", "This", "can", "be", "used", "to", "implement", "custom", "permission", "checks", ".", ":", "param", "request", ":", "HttpRequest", ":", "param", "filename", ":", "Fil...
2abd93ebad51042744eaeb1ee1074ed0eb55ad0c
https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/admin.py#L148-L161
train
kajala/django-jutil
jutil/admin.py
AdminFileDownloadMixin.get_download_urls
def get_download_urls(self): """ Use like this: def get_urls(self): return self.get_download_urls() + super().get_urls() Returns: File download URLs for this model. """ info = self.model._meta.app_label, self.model._meta.model_name return [ ...
python
def get_download_urls(self): """ Use like this: def get_urls(self): return self.get_download_urls() + super().get_urls() Returns: File download URLs for this model. """ info = self.model._meta.app_label, self.model._meta.model_name return [ ...
[ "def", "get_download_urls", "(", "self", ")", ":", "info", "=", "self", ".", "model", ".", "_meta", ".", "app_label", ",", "self", ".", "model", ".", "_meta", ".", "model_name", "return", "[", "url", "(", "r'^.+('", "+", "self", ".", "upload_to", "+", ...
Use like this: def get_urls(self): return self.get_download_urls() + super().get_urls() Returns: File download URLs for this model.
[ "Use", "like", "this", ":", "def", "get_urls", "(", "self", ")", ":", "return", "self", ".", "get_download_urls", "()", "+", "super", "()", ".", "get_urls", "()" ]
2abd93ebad51042744eaeb1ee1074ed0eb55ad0c
https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/admin.py#L170-L181
train
novopl/peltak
src/peltak/core/versioning.py
write
def write(version): # type: (str) -> None """ Write the given version to the VERSION_FILE """ if not is_valid(version): raise ValueError("Invalid version: ".format(version)) storage = get_version_storage() storage.write(version)
python
def write(version): # type: (str) -> None """ Write the given version to the VERSION_FILE """ if not is_valid(version): raise ValueError("Invalid version: ".format(version)) storage = get_version_storage() storage.write(version)
[ "def", "write", "(", "version", ")", ":", "# type: (str) -> None", "if", "not", "is_valid", "(", "version", ")", ":", "raise", "ValueError", "(", "\"Invalid version: \"", ".", "format", "(", "version", ")", ")", "storage", "=", "get_version_storage", "(", ")",...
Write the given version to the VERSION_FILE
[ "Write", "the", "given", "version", "to", "the", "VERSION_FILE" ]
b627acc019e3665875fe76cdca0a14773b69beaa
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/versioning.py#L76-L83
train
novopl/peltak
src/peltak/core/versioning.py
bump
def bump(component='patch', exact=None): # type: (str, str) -> Tuple[str, str] """ Bump the given version component. Args: component (str): What part of the version should be bumped. Can be one of: - major - minor - patch exact (str): ...
python
def bump(component='patch', exact=None): # type: (str, str) -> Tuple[str, str] """ Bump the given version component. Args: component (str): What part of the version should be bumped. Can be one of: - major - minor - patch exact (str): ...
[ "def", "bump", "(", "component", "=", "'patch'", ",", "exact", "=", "None", ")", ":", "# type: (str, str) -> Tuple[str, str]", "old_ver", "=", "current", "(", ")", "if", "exact", "is", "None", ":", "new_ver", "=", "_bump_version", "(", "old_ver", ",", "compo...
Bump the given version component. Args: component (str): What part of the version should be bumped. Can be one of: - major - minor - patch exact (str): The exact version that should be set instead of bumping the current one. ...
[ "Bump", "the", "given", "version", "component", "." ]
b627acc019e3665875fe76cdca0a14773b69beaa
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/versioning.py#L86-L113
train
novopl/peltak
src/peltak/core/versioning.py
_bump_version
def _bump_version(version, component='patch'): # type: (str, str) -> str """ Bump the given version component. Args: version (str): The current version. The format is: MAJOR.MINOR[.PATCH]. component (str): What part of the version should be bumped. Can be one of: ...
python
def _bump_version(version, component='patch'): # type: (str, str) -> str """ Bump the given version component. Args: version (str): The current version. The format is: MAJOR.MINOR[.PATCH]. component (str): What part of the version should be bumped. Can be one of: ...
[ "def", "_bump_version", "(", "version", ",", "component", "=", "'patch'", ")", ":", "# type: (str, str) -> str", "if", "component", "not", "in", "(", "'major'", ",", "'minor'", ",", "'patch'", ")", ":", "raise", "ValueError", "(", "\"Invalid version component: {}\...
Bump the given version component. Args: version (str): The current version. The format is: MAJOR.MINOR[.PATCH]. component (str): What part of the version should be bumped. Can be one of: - major - minor - patch Returns: str: ...
[ "Bump", "the", "given", "version", "component", "." ]
b627acc019e3665875fe76cdca0a14773b69beaa
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/versioning.py#L116-L164
train
novopl/peltak
src/peltak/core/versioning.py
get_version_storage
def get_version_storage(): # type: () -> VersionStorage """ Get version storage for the given version file. The storage engine used depends on the extension of the *version_file*. """ version_file = conf.get_path('version_file', 'VERSION') if version_file.endswith('.py'): return PyVersi...
python
def get_version_storage(): # type: () -> VersionStorage """ Get version storage for the given version file. The storage engine used depends on the extension of the *version_file*. """ version_file = conf.get_path('version_file', 'VERSION') if version_file.endswith('.py'): return PyVersi...
[ "def", "get_version_storage", "(", ")", ":", "# type: () -> VersionStorage", "version_file", "=", "conf", ".", "get_path", "(", "'version_file'", ",", "'VERSION'", ")", "if", "version_file", ".", "endswith", "(", "'.py'", ")", ":", "return", "PyVersionStorage", "(...
Get version storage for the given version file. The storage engine used depends on the extension of the *version_file*.
[ "Get", "version", "storage", "for", "the", "given", "version", "file", "." ]
b627acc019e3665875fe76cdca0a14773b69beaa
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/versioning.py#L291-L303
train
novopl/peltak
src/peltak/core/versioning.py
PyVersionStorage.read
def read(self): # type: () -> Optional[str] """ Read the project version from .py file. This will regex search in the file for a ``__version__ = VERSION_STRING`` and read the version string. """ with open(self.version_file) as fp: content = fp.read() ...
python
def read(self): # type: () -> Optional[str] """ Read the project version from .py file. This will regex search in the file for a ``__version__ = VERSION_STRING`` and read the version string. """ with open(self.version_file) as fp: content = fp.read() ...
[ "def", "read", "(", "self", ")", ":", "# type: () -> Optional[str]", "with", "open", "(", "self", ".", "version_file", ")", "as", "fp", ":", "content", "=", "fp", ".", "read", "(", ")", "m", "=", "RE_PY_VERSION", ".", "search", "(", "content", ")", "if...
Read the project version from .py file. This will regex search in the file for a ``__version__ = VERSION_STRING`` and read the version string.
[ "Read", "the", "project", "version", "from", ".", "py", "file", "." ]
b627acc019e3665875fe76cdca0a14773b69beaa
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/versioning.py#L220-L233
train
novopl/peltak
src/peltak/core/versioning.py
PyVersionStorage.write
def write(self, version): # type: (str) -> None """ Write the project version to .py file. This will regex search in the file for a ``__version__ = VERSION_STRING`` and substitute the version string for the new version. """ with open(self.version_file) as fp: ...
python
def write(self, version): # type: (str) -> None """ Write the project version to .py file. This will regex search in the file for a ``__version__ = VERSION_STRING`` and substitute the version string for the new version. """ with open(self.version_file) as fp: ...
[ "def", "write", "(", "self", ",", "version", ")", ":", "# type: (str) -> None", "with", "open", "(", "self", ".", "version_file", ")", "as", "fp", ":", "content", "=", "fp", ".", "read", "(", ")", "ver_statement", "=", "\"__version__ = '{}'\"", ".", "forma...
Write the project version to .py file. This will regex search in the file for a ``__version__ = VERSION_STRING`` and substitute the version string for the new version.
[ "Write", "the", "project", "version", "to", ".", "py", "file", "." ]
b627acc019e3665875fe76cdca0a14773b69beaa
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/versioning.py#L235-L248
train
novopl/peltak
src/peltak/core/versioning.py
RawVersionStorage.read
def read(self): # type: () -> Optional[str] """ Read the project version from .py file. This will regex search in the file for a ``__version__ = VERSION_STRING`` and read the version string. """ with open(self.version_file) as fp: version = fp.read().strip() ...
python
def read(self): # type: () -> Optional[str] """ Read the project version from .py file. This will regex search in the file for a ``__version__ = VERSION_STRING`` and read the version string. """ with open(self.version_file) as fp: version = fp.read().strip() ...
[ "def", "read", "(", "self", ")", ":", "# type: () -> Optional[str]", "with", "open", "(", "self", ".", "version_file", ")", "as", "fp", ":", "version", "=", "fp", ".", "read", "(", ")", ".", "strip", "(", ")", "if", "is_valid", "(", "version", ")", "...
Read the project version from .py file. This will regex search in the file for a ``__version__ = VERSION_STRING`` and read the version string.
[ "Read", "the", "project", "version", "from", ".", "py", "file", "." ]
b627acc019e3665875fe76cdca0a14773b69beaa
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/versioning.py#L253-L266
train
Vital-Fernandez/dazer
bin/lib/Astro_Libraries/f2n.py
loggray
def loggray(x, a, b): """Auxiliary function that specifies the logarithmic gray scale. a and b are the cutoffs.""" linval = 10.0 + 990.0 * (x-float(a))/(b-a) return (np.log10(linval)-1.0)*0.5 * 255.0
python
def loggray(x, a, b): """Auxiliary function that specifies the logarithmic gray scale. a and b are the cutoffs.""" linval = 10.0 + 990.0 * (x-float(a))/(b-a) return (np.log10(linval)-1.0)*0.5 * 255.0
[ "def", "loggray", "(", "x", ",", "a", ",", "b", ")", ":", "linval", "=", "10.0", "+", "990.0", "*", "(", "x", "-", "float", "(", "a", ")", ")", "/", "(", "b", "-", "a", ")", "return", "(", "np", ".", "log10", "(", "linval", ")", "-", "1.0...
Auxiliary function that specifies the logarithmic gray scale. a and b are the cutoffs.
[ "Auxiliary", "function", "that", "specifies", "the", "logarithmic", "gray", "scale", ".", "a", "and", "b", "are", "the", "cutoffs", "." ]
3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L945-L949
train
Vital-Fernandez/dazer
bin/lib/Astro_Libraries/f2n.py
fromfits
def fromfits(infile, hdu = 0, verbose = True): """ Factory function that reads a FITS file and returns a f2nimage object. Use hdu to specify which HDU you want (primary = 0) """ pixelarray, hdr = ft.getdata(infile, hdu, header=True) pixelarray = np.asarray(pixelarray).transpose() #print...
python
def fromfits(infile, hdu = 0, verbose = True): """ Factory function that reads a FITS file and returns a f2nimage object. Use hdu to specify which HDU you want (primary = 0) """ pixelarray, hdr = ft.getdata(infile, hdu, header=True) pixelarray = np.asarray(pixelarray).transpose() #print...
[ "def", "fromfits", "(", "infile", ",", "hdu", "=", "0", ",", "verbose", "=", "True", ")", ":", "pixelarray", ",", "hdr", "=", "ft", ".", "getdata", "(", "infile", ",", "hdu", ",", "header", "=", "True", ")", "pixelarray", "=", "np", ".", "asarray",...
Factory function that reads a FITS file and returns a f2nimage object. Use hdu to specify which HDU you want (primary = 0)
[ "Factory", "function", "that", "reads", "a", "FITS", "file", "and", "returns", "a", "f2nimage", "object", ".", "Use", "hdu", "to", "specify", "which", "HDU", "you", "want", "(", "primary", "=", "0", ")" ]
3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L954-L972
train
Vital-Fernandez/dazer
bin/lib/Astro_Libraries/f2n.py
rebin
def rebin(a, newshape): """ Auxiliary function to rebin ndarray data. Source : http://www.scipy.org/Cookbook/Rebinning example usage: >>> a=rand(6,4); b=rebin(a,(3,2)) """ shape = a.shape lenShape = len(shape) factor = np.asarray(shape)/np.asarray(newshape) ...
python
def rebin(a, newshape): """ Auxiliary function to rebin ndarray data. Source : http://www.scipy.org/Cookbook/Rebinning example usage: >>> a=rand(6,4); b=rebin(a,(3,2)) """ shape = a.shape lenShape = len(shape) factor = np.asarray(shape)/np.asarray(newshape) ...
[ "def", "rebin", "(", "a", ",", "newshape", ")", ":", "shape", "=", "a", ".", "shape", "lenShape", "=", "len", "(", "shape", ")", "factor", "=", "np", ".", "asarray", "(", "shape", ")", "/", "np", ".", "asarray", "(", "newshape", ")", "#print factor...
Auxiliary function to rebin ndarray data. Source : http://www.scipy.org/Cookbook/Rebinning example usage: >>> a=rand(6,4); b=rebin(a,(3,2))
[ "Auxiliary", "function", "to", "rebin", "ndarray", "data", ".", "Source", ":", "http", ":", "//", "www", ".", "scipy", ".", "org", "/", "Cookbook", "/", "Rebinning", "example", "usage", ":", ">>>", "a", "=", "rand", "(", "6", "4", ")", ";", "b", "=...
3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L977-L997
train
Vital-Fernandez/dazer
bin/lib/Astro_Libraries/f2n.py
compose
def compose(f2nimages, outfile): """ Takes f2nimages and writes them into one single png file, side by side. f2nimages is a list of horizontal lines, where each line is a list of f2nimages. For instance : [ [image1, image2], [image3, image4] ] The sizes of these images have to "match...
python
def compose(f2nimages, outfile): """ Takes f2nimages and writes them into one single png file, side by side. f2nimages is a list of horizontal lines, where each line is a list of f2nimages. For instance : [ [image1, image2], [image3, image4] ] The sizes of these images have to "match...
[ "def", "compose", "(", "f2nimages", ",", "outfile", ")", ":", "# We start by doing some checks, and try to print out helpfull error messages.", "verbosity", "=", "[", "]", "colourmodes", "=", "[", "]", "for", "i", ",", "line", "in", "enumerate", "(", "f2nimages", ")...
Takes f2nimages and writes them into one single png file, side by side. f2nimages is a list of horizontal lines, where each line is a list of f2nimages. For instance : [ [image1, image2], [image3, image4] ] The sizes of these images have to "match", so that the final result is rectangular. ...
[ "Takes", "f2nimages", "and", "writes", "them", "into", "one", "single", "png", "file", "side", "by", "side", ".", "f2nimages", "is", "a", "list", "of", "horizontal", "lines", "where", "each", "line", "is", "a", "list", "of", "f2nimages", ".", "For", "ins...
3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L1001-L1074
train
Vital-Fernandez/dazer
bin/lib/Astro_Libraries/f2n.py
f2nimage.setzscale
def setzscale(self, z1="auto", z2="auto", nsig=3, samplesizelimit = 10000, border=300): """ We set z1 and z2, according to different algorithms or arguments. For both z1 and z2, give either : - "auto" (default automatic, different between z1 and z2) - "e...
python
def setzscale(self, z1="auto", z2="auto", nsig=3, samplesizelimit = 10000, border=300): """ We set z1 and z2, according to different algorithms or arguments. For both z1 and z2, give either : - "auto" (default automatic, different between z1 and z2) - "e...
[ "def", "setzscale", "(", "self", ",", "z1", "=", "\"auto\"", ",", "z2", "=", "\"auto\"", ",", "nsig", "=", "3", ",", "samplesizelimit", "=", "10000", ",", "border", "=", "300", ")", ":", "if", "self", ".", "pilimage", "!=", "None", ":", "raise", "R...
We set z1 and z2, according to different algorithms or arguments. For both z1 and z2, give either : - "auto" (default automatic, different between z1 and z2) - "ex" (extrema) - "flat" ("sigma-cuts" around median value, well-suited for flatfields) ...
[ "We", "set", "z1", "and", "z2", "according", "to", "different", "algorithms", "or", "arguments", ".", "For", "both", "z1", "and", "z2", "give", "either", ":", "-", "auto", "(", "default", "automatic", "different", "between", "z1", "and", "z2", ")", "-", ...
3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L173-L311
train
Vital-Fernandez/dazer
bin/lib/Astro_Libraries/f2n.py
f2nimage.crop
def crop(self, xa, xb, ya, yb): """ Crops the image. Two points : - We use numpy conventions xa = 200 and xb = 400 will give you a width of 200 pixels ! - We crop relative to the current array (i.e. not necessarily to the original array !) ...
python
def crop(self, xa, xb, ya, yb): """ Crops the image. Two points : - We use numpy conventions xa = 200 and xb = 400 will give you a width of 200 pixels ! - We crop relative to the current array (i.e. not necessarily to the original array !) ...
[ "def", "crop", "(", "self", ",", "xa", ",", "xb", ",", "ya", ",", "yb", ")", ":", "if", "self", ".", "pilimage", "!=", "None", ":", "raise", "RuntimeError", ",", "\"Cannot crop anymore, PIL image already exists !\"", "if", "self", ".", "verbose", ":", "pri...
Crops the image. Two points : - We use numpy conventions xa = 200 and xb = 400 will give you a width of 200 pixels ! - We crop relative to the current array (i.e. not necessarily to the original array !) This means you can crop several times in a row wit...
[ "Crops", "the", "image", ".", "Two", "points", ":", "-", "We", "use", "numpy", "conventions", "xa", "=", "200", "and", "xb", "=", "400", "will", "give", "you", "a", "width", "of", "200", "pixels", "!", "-", "We", "crop", "relative", "to", "the", "c...
3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L343-L369
train
Vital-Fernandez/dazer
bin/lib/Astro_Libraries/f2n.py
f2nimage.irafcrop
def irafcrop(self, irafcropstring): """ This is a wrapper around crop(), similar to iraf imcopy, using iraf conventions (100:199 will be 100 pixels, not 99). """ irafcropstring = irafcropstring[1:-1] # removing the [ ] ranges = irafcropstring.split(",") xr = range...
python
def irafcrop(self, irafcropstring): """ This is a wrapper around crop(), similar to iraf imcopy, using iraf conventions (100:199 will be 100 pixels, not 99). """ irafcropstring = irafcropstring[1:-1] # removing the [ ] ranges = irafcropstring.split(",") xr = range...
[ "def", "irafcrop", "(", "self", ",", "irafcropstring", ")", ":", "irafcropstring", "=", "irafcropstring", "[", "1", ":", "-", "1", "]", "# removing the [ ]", "ranges", "=", "irafcropstring", ".", "split", "(", "\",\"", ")", "xr", "=", "ranges", "[", "0", ...
This is a wrapper around crop(), similar to iraf imcopy, using iraf conventions (100:199 will be 100 pixels, not 99).
[ "This", "is", "a", "wrapper", "around", "crop", "()", "similar", "to", "iraf", "imcopy", "using", "iraf", "conventions", "(", "100", ":", "199", "will", "be", "100", "pixels", "not", "99", ")", "." ]
3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L375-L388
train
Vital-Fernandez/dazer
bin/lib/Astro_Libraries/f2n.py
f2nimage.rebin
def rebin(self, factor): """ I robustly rebin your image by a given factor. You simply specify a factor, and I will eventually take care of a crop to bring the image to interger-multiple-of-your-factor dimensions. Note that if you crop your image before, you must directly crop to...
python
def rebin(self, factor): """ I robustly rebin your image by a given factor. You simply specify a factor, and I will eventually take care of a crop to bring the image to interger-multiple-of-your-factor dimensions. Note that if you crop your image before, you must directly crop to...
[ "def", "rebin", "(", "self", ",", "factor", ")", ":", "if", "self", ".", "pilimage", "!=", "None", ":", "raise", "RuntimeError", ",", "\"Cannot rebin anymore, PIL image already exists !\"", "if", "type", "(", "factor", ")", "!=", "type", "(", "0", ")", ":", ...
I robustly rebin your image by a given factor. You simply specify a factor, and I will eventually take care of a crop to bring the image to interger-multiple-of-your-factor dimensions. Note that if you crop your image before, you must directly crop to compatible dimensions ! We update th...
[ "I", "robustly", "rebin", "your", "image", "by", "a", "given", "factor", ".", "You", "simply", "specify", "a", "factor", "and", "I", "will", "eventually", "take", "care", "of", "a", "crop", "to", "bring", "the", "image", "to", "interger", "-", "multiple"...
3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L391-L423
train
Vital-Fernandez/dazer
bin/lib/Astro_Libraries/f2n.py
f2nimage.makepilimage
def makepilimage(self, scale = "log", negative = False): """ Makes a PIL image out of the array, respecting the z1 and z2 cutoffs. By default we use a log scaling identical to iraf's, and produce an image of mode "L", i.e. grayscale. But some drawings or colourscales will change the mode...
python
def makepilimage(self, scale = "log", negative = False): """ Makes a PIL image out of the array, respecting the z1 and z2 cutoffs. By default we use a log scaling identical to iraf's, and produce an image of mode "L", i.e. grayscale. But some drawings or colourscales will change the mode...
[ "def", "makepilimage", "(", "self", ",", "scale", "=", "\"log\"", ",", "negative", "=", "False", ")", ":", "if", "scale", "==", "\"log\"", "or", "scale", "==", "\"lin\"", ":", "self", ".", "negative", "=", "negative", "numpyarrayshape", "=", "self", ".",...
Makes a PIL image out of the array, respecting the z1 and z2 cutoffs. By default we use a log scaling identical to iraf's, and produce an image of mode "L", i.e. grayscale. But some drawings or colourscales will change the mode to "RGB" later, if you choose your own colours. If you choose scale ...
[ "Makes", "a", "PIL", "image", "out", "of", "the", "array", "respecting", "the", "z1", "and", "z2", "cutoffs", ".", "By", "default", "we", "use", "a", "log", "scaling", "identical", "to", "iraf", "s", "and", "produce", "an", "image", "of", "mode", "L", ...
3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L426-L557
train
Vital-Fernandez/dazer
bin/lib/Astro_Libraries/f2n.py
f2nimage.drawmask
def drawmask(self, maskarray, colour = 128): """ I draw a mask on the image. Give me a numpy "maskarray" of same size as mine, and I draw on the pilimage all pixels of the maskarray that are True in the maskcolour. By default, colour is gray, to avoid switching to RGB. Bu...
python
def drawmask(self, maskarray, colour = 128): """ I draw a mask on the image. Give me a numpy "maskarray" of same size as mine, and I draw on the pilimage all pixels of the maskarray that are True in the maskcolour. By default, colour is gray, to avoid switching to RGB. Bu...
[ "def", "drawmask", "(", "self", ",", "maskarray", ",", "colour", "=", "128", ")", ":", "self", ".", "checkforpilimage", "(", ")", "self", ".", "changecolourmode", "(", "colour", ")", "self", ".", "makedraw", "(", ")", "# Checking size of maskarray :", "if", ...
I draw a mask on the image. Give me a numpy "maskarray" of same size as mine, and I draw on the pilimage all pixels of the maskarray that are True in the maskcolour. By default, colour is gray, to avoid switching to RGB. But if you give for instance (255, 0, 0), I will do the switch.
[ "I", "draw", "a", "mask", "on", "the", "image", ".", "Give", "me", "a", "numpy", "maskarray", "of", "same", "size", "as", "mine", "and", "I", "draw", "on", "the", "pilimage", "all", "pixels", "of", "the", "maskarray", "that", "are", "True", "in", "th...
3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L559-L594
train
Vital-Fernandez/dazer
bin/lib/Astro_Libraries/f2n.py
f2nimage.showcutoffs
def showcutoffs(self, redblue = False): """ We use drawmask to visualize pixels above and below the z cutoffs. By default this is done in black (above) and white (below) (and adapts to negative images). But if you choose redblue = True, I use red for above z2 and blue for below z1. ...
python
def showcutoffs(self, redblue = False): """ We use drawmask to visualize pixels above and below the z cutoffs. By default this is done in black (above) and white (below) (and adapts to negative images). But if you choose redblue = True, I use red for above z2 and blue for below z1. ...
[ "def", "showcutoffs", "(", "self", ",", "redblue", "=", "False", ")", ":", "highmask", "=", "self", ".", "numpyarray", ">", "self", ".", "z2", "lowmask", "=", "self", ".", "numpyarray", "<", "self", ".", "z1", "if", "redblue", "==", "False", ":", "if...
We use drawmask to visualize pixels above and below the z cutoffs. By default this is done in black (above) and white (below) (and adapts to negative images). But if you choose redblue = True, I use red for above z2 and blue for below z1.
[ "We", "use", "drawmask", "to", "visualize", "pixels", "above", "and", "below", "the", "z", "cutoffs", ".", "By", "default", "this", "is", "done", "in", "black", "(", "above", ")", "and", "white", "(", "below", ")", "(", "and", "adapts", "to", "negative...
3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L598-L617
train
Vital-Fernandez/dazer
bin/lib/Astro_Libraries/f2n.py
f2nimage.makedraw
def makedraw(self): """Auxiliary method to make a draw object if not yet done. This is also called by changecolourmode, when we go from L to RGB, to get a new draw object. """ if self.draw == None: self.draw = imdw.Draw(self.pilimage)
python
def makedraw(self): """Auxiliary method to make a draw object if not yet done. This is also called by changecolourmode, when we go from L to RGB, to get a new draw object. """ if self.draw == None: self.draw = imdw.Draw(self.pilimage)
[ "def", "makedraw", "(", "self", ")", ":", "if", "self", ".", "draw", "==", "None", ":", "self", ".", "draw", "=", "imdw", ".", "Draw", "(", "self", ".", "pilimage", ")" ]
Auxiliary method to make a draw object if not yet done. This is also called by changecolourmode, when we go from L to RGB, to get a new draw object.
[ "Auxiliary", "method", "to", "make", "a", "draw", "object", "if", "not", "yet", "done", ".", "This", "is", "also", "called", "by", "changecolourmode", "when", "we", "go", "from", "L", "to", "RGB", "to", "get", "a", "new", "draw", "object", "." ]
3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L626-L631
train
Vital-Fernandez/dazer
bin/lib/Astro_Libraries/f2n.py
f2nimage.defaultcolour
def defaultcolour(self, colour): """ Auxiliary method to choose a default colour. Give me a user provided colour : if it is None, I change it to the default colour, respecting negative. Plus, if the image is in RGB mode and you give me 128 for a gray, I translate this to the expected (12...
python
def defaultcolour(self, colour): """ Auxiliary method to choose a default colour. Give me a user provided colour : if it is None, I change it to the default colour, respecting negative. Plus, if the image is in RGB mode and you give me 128 for a gray, I translate this to the expected (12...
[ "def", "defaultcolour", "(", "self", ",", "colour", ")", ":", "if", "colour", "==", "None", ":", "if", "self", ".", "negative", "==", "True", ":", "if", "self", ".", "pilimage", ".", "mode", "==", "\"L\"", ":", "return", "0", "else", ":", "return", ...
Auxiliary method to choose a default colour. Give me a user provided colour : if it is None, I change it to the default colour, respecting negative. Plus, if the image is in RGB mode and you give me 128 for a gray, I translate this to the expected (128, 128, 128) ...
[ "Auxiliary", "method", "to", "choose", "a", "default", "colour", ".", "Give", "me", "a", "user", "provided", "colour", ":", "if", "it", "is", "None", "I", "change", "it", "to", "the", "default", "colour", "respecting", "negative", ".", "Plus", "if", "the...
3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L633-L654
train
Vital-Fernandez/dazer
bin/lib/Astro_Libraries/f2n.py
f2nimage.loadtitlefont
def loadtitlefont(self): """Auxiliary method to load font if not yet done.""" if self.titlefont == None: # print 'the bloody fonts dir is????', fontsdir # print 'pero esto que hace??', os.path.join(fontsdir, "courR18.pil") # /home/vital/Workspace/pyResources/Scientifi...
python
def loadtitlefont(self): """Auxiliary method to load font if not yet done.""" if self.titlefont == None: # print 'the bloody fonts dir is????', fontsdir # print 'pero esto que hace??', os.path.join(fontsdir, "courR18.pil") # /home/vital/Workspace/pyResources/Scientifi...
[ "def", "loadtitlefont", "(", "self", ")", ":", "if", "self", ".", "titlefont", "==", "None", ":", "# print 'the bloody fonts dir is????', fontsdir", "# print 'pero esto que hace??', os.path.join(fontsdir, \"courR18.pil\")", "# /home/vital/Workspace/p...
Auxiliary method to load font if not yet done.
[ "Auxiliary", "method", "to", "load", "font", "if", "not", "yet", "done", "." ]
3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L656-L663
train
Vital-Fernandez/dazer
bin/lib/Astro_Libraries/f2n.py
f2nimage.loadinfofont
def loadinfofont(self): """Auxiliary method to load font if not yet done.""" if self.infofont == None: self.infofont = imft.load_path(os.path.join(fontsdir, "courR10.pil"))
python
def loadinfofont(self): """Auxiliary method to load font if not yet done.""" if self.infofont == None: self.infofont = imft.load_path(os.path.join(fontsdir, "courR10.pil"))
[ "def", "loadinfofont", "(", "self", ")", ":", "if", "self", ".", "infofont", "==", "None", ":", "self", ".", "infofont", "=", "imft", ".", "load_path", "(", "os", ".", "path", ".", "join", "(", "fontsdir", ",", "\"courR10.pil\"", ")", ")" ]
Auxiliary method to load font if not yet done.
[ "Auxiliary", "method", "to", "load", "font", "if", "not", "yet", "done", "." ]
3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L665-L668
train
Vital-Fernandez/dazer
bin/lib/Astro_Libraries/f2n.py
f2nimage.loadlabelfont
def loadlabelfont(self): """Auxiliary method to load font if not yet done.""" if self.labelfont == None: self.labelfont = imft.load_path(os.path.join(fontsdir, "courR10.pil"))
python
def loadlabelfont(self): """Auxiliary method to load font if not yet done.""" if self.labelfont == None: self.labelfont = imft.load_path(os.path.join(fontsdir, "courR10.pil"))
[ "def", "loadlabelfont", "(", "self", ")", ":", "if", "self", ".", "labelfont", "==", "None", ":", "self", ".", "labelfont", "=", "imft", ".", "load_path", "(", "os", ".", "path", ".", "join", "(", "fontsdir", ",", "\"courR10.pil\"", ")", ")" ]
Auxiliary method to load font if not yet done.
[ "Auxiliary", "method", "to", "load", "font", "if", "not", "yet", "done", "." ]
3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L670-L673
train
Vital-Fernandez/dazer
bin/lib/Astro_Libraries/f2n.py
f2nimage.changecolourmode
def changecolourmode(self, newcolour): """Auxiliary method to change the colour mode. Give me a colour (either an int, or a 3-tuple, values 0 to 255) and I decide if the image mode has to be switched from "L" to "RGB". """ if type(newcolour) != type(0) and self.pilimage.mode != "...
python
def changecolourmode(self, newcolour): """Auxiliary method to change the colour mode. Give me a colour (either an int, or a 3-tuple, values 0 to 255) and I decide if the image mode has to be switched from "L" to "RGB". """ if type(newcolour) != type(0) and self.pilimage.mode != "...
[ "def", "changecolourmode", "(", "self", ",", "newcolour", ")", ":", "if", "type", "(", "newcolour", ")", "!=", "type", "(", "0", ")", "and", "self", ".", "pilimage", ".", "mode", "!=", "\"RGB\"", ":", "if", "self", ".", "verbose", ":", "print", "\"Sw...
Auxiliary method to change the colour mode. Give me a colour (either an int, or a 3-tuple, values 0 to 255) and I decide if the image mode has to be switched from "L" to "RGB".
[ "Auxiliary", "method", "to", "change", "the", "colour", "mode", ".", "Give", "me", "a", "colour", "(", "either", "an", "int", "or", "a", "3", "-", "tuple", "values", "0", "to", "255", ")", "and", "I", "decide", "if", "the", "image", "mode", "has", ...
3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L675-L685
train
Vital-Fernandez/dazer
bin/lib/Astro_Libraries/f2n.py
f2nimage.upsample
def upsample(self, factor): """ The inverse operation of rebin, applied on the PIL image. Do this before writing text or drawing on the image ! The coordinates will be automatically converted for you """ self.checkforpilimage() if type(factor) !=...
python
def upsample(self, factor): """ The inverse operation of rebin, applied on the PIL image. Do this before writing text or drawing on the image ! The coordinates will be automatically converted for you """ self.checkforpilimage() if type(factor) !=...
[ "def", "upsample", "(", "self", ",", "factor", ")", ":", "self", ".", "checkforpilimage", "(", ")", "if", "type", "(", "factor", ")", "!=", "type", "(", "0", ")", ":", "raise", "RuntimeError", ",", "\"Upsample factor must be an integer !\"", "if", "self", ...
The inverse operation of rebin, applied on the PIL image. Do this before writing text or drawing on the image ! The coordinates will be automatically converted for you
[ "The", "inverse", "operation", "of", "rebin", "applied", "on", "the", "PIL", "image", ".", "Do", "this", "before", "writing", "text", "or", "drawing", "on", "the", "image", "!", "The", "coordinates", "will", "be", "automatically", "converted", "for", "you" ]
3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L688-L705
train
Vital-Fernandez/dazer
bin/lib/Astro_Libraries/f2n.py
f2nimage.pilcoords
def pilcoords(self, (x,y)): """ Converts the coordinates (x,y) of the original array or FITS file to the current coordinates of the PIL image, respecting cropping, rebinning, and upsampling. This is only used once the PIL image is available, for drawing. Note that we also have to...
python
def pilcoords(self, (x,y)): """ Converts the coordinates (x,y) of the original array or FITS file to the current coordinates of the PIL image, respecting cropping, rebinning, and upsampling. This is only used once the PIL image is available, for drawing. Note that we also have to...
[ "def", "pilcoords", "(", "self", ",", "(", "x", ",", "y", ")", ")", ":", "pilx", "=", "int", "(", "(", "x", "-", "1", "-", "self", ".", "xa", ")", "*", "float", "(", "self", ".", "upsamplefactor", ")", "/", "float", "(", "self", ".", "binfact...
Converts the coordinates (x,y) of the original array or FITS file to the current coordinates of the PIL image, respecting cropping, rebinning, and upsampling. This is only used once the PIL image is available, for drawing. Note that we also have to take care about the different origin convention...
[ "Converts", "the", "coordinates", "(", "x", "y", ")", "of", "the", "original", "array", "or", "FITS", "file", "to", "the", "current", "coordinates", "of", "the", "PIL", "image", "respecting", "cropping", "rebinning", "and", "upsampling", ".", "This", "is", ...
3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L708-L720
train
Vital-Fernandez/dazer
bin/lib/Astro_Libraries/f2n.py
f2nimage.pilscale
def pilscale(self, r): """ Converts a "scale" (like an aperture radius) of the original array or FITS file to the current PIL coordinates. """ return r * float(self.upsamplefactor) / float(self.binfactor)
python
def pilscale(self, r): """ Converts a "scale" (like an aperture radius) of the original array or FITS file to the current PIL coordinates. """ return r * float(self.upsamplefactor) / float(self.binfactor)
[ "def", "pilscale", "(", "self", ",", "r", ")", ":", "return", "r", "*", "float", "(", "self", ".", "upsamplefactor", ")", "/", "float", "(", "self", ".", "binfactor", ")" ]
Converts a "scale" (like an aperture radius) of the original array or FITS file to the current PIL coordinates.
[ "Converts", "a", "scale", "(", "like", "an", "aperture", "radius", ")", "of", "the", "original", "array", "or", "FITS", "file", "to", "the", "current", "PIL", "coordinates", "." ]
3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L722-L726
train
Vital-Fernandez/dazer
bin/lib/Astro_Libraries/f2n.py
f2nimage.drawpoint
def drawpoint(self, x, y, colour = None): """ Most elementary drawing, single pixel, used mainly for testing purposes. Coordinates are those of your initial image ! """ self.checkforpilimage() colour = self.defaultcolour(colour) self.changecolourmode(colour) ...
python
def drawpoint(self, x, y, colour = None): """ Most elementary drawing, single pixel, used mainly for testing purposes. Coordinates are those of your initial image ! """ self.checkforpilimage() colour = self.defaultcolour(colour) self.changecolourmode(colour) ...
[ "def", "drawpoint", "(", "self", ",", "x", ",", "y", ",", "colour", "=", "None", ")", ":", "self", ".", "checkforpilimage", "(", ")", "colour", "=", "self", ".", "defaultcolour", "(", "colour", ")", "self", ".", "changecolourmode", "(", "colour", ")", ...
Most elementary drawing, single pixel, used mainly for testing purposes. Coordinates are those of your initial image !
[ "Most", "elementary", "drawing", "single", "pixel", "used", "mainly", "for", "testing", "purposes", ".", "Coordinates", "are", "those", "of", "your", "initial", "image", "!" ]
3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L729-L741
train
Vital-Fernandez/dazer
bin/lib/Astro_Libraries/f2n.py
f2nimage.drawcircle
def drawcircle(self, x, y, r = 10, colour = None, label = None): """ Draws a circle centered on (x, y) with radius r. All these are in the coordinates of your initial image ! You give these x and y in the usual ds9 pixels, (0,0) is bottom left. I will convert this into the right PIL coor...
python
def drawcircle(self, x, y, r = 10, colour = None, label = None): """ Draws a circle centered on (x, y) with radius r. All these are in the coordinates of your initial image ! You give these x and y in the usual ds9 pixels, (0,0) is bottom left. I will convert this into the right PIL coor...
[ "def", "drawcircle", "(", "self", ",", "x", ",", "y", ",", "r", "=", "10", ",", "colour", "=", "None", ",", "label", "=", "None", ")", ":", "self", ".", "checkforpilimage", "(", ")", "colour", "=", "self", ".", "defaultcolour", "(", "colour", ")", ...
Draws a circle centered on (x, y) with radius r. All these are in the coordinates of your initial image ! You give these x and y in the usual ds9 pixels, (0,0) is bottom left. I will convert this into the right PIL coordiates.
[ "Draws", "a", "circle", "centered", "on", "(", "x", "y", ")", "with", "radius", "r", ".", "All", "these", "are", "in", "the", "coordinates", "of", "your", "initial", "image", "!", "You", "give", "these", "x", "and", "y", "in", "the", "usual", "ds9", ...
3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L744-L765
train
Vital-Fernandez/dazer
bin/lib/Astro_Libraries/f2n.py
f2nimage.drawrectangle
def drawrectangle(self, xa, xb, ya, yb, colour=None, label = None): """ Draws a 1-pixel wide frame AROUND the region you specify. Same convention as for crop(). """ self.checkforpilimage() colour = self.defaultcolour(colour) self.changecolourmode(colour) ...
python
def drawrectangle(self, xa, xb, ya, yb, colour=None, label = None): """ Draws a 1-pixel wide frame AROUND the region you specify. Same convention as for crop(). """ self.checkforpilimage() colour = self.defaultcolour(colour) self.changecolourmode(colour) ...
[ "def", "drawrectangle", "(", "self", ",", "xa", ",", "xb", ",", "ya", ",", "yb", ",", "colour", "=", "None", ",", "label", "=", "None", ")", ":", "self", ".", "checkforpilimage", "(", ")", "colour", "=", "self", ".", "defaultcolour", "(", "colour", ...
Draws a 1-pixel wide frame AROUND the region you specify. Same convention as for crop().
[ "Draws", "a", "1", "-", "pixel", "wide", "frame", "AROUND", "the", "region", "you", "specify", ".", "Same", "convention", "as", "for", "crop", "()", "." ]
3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L769-L789
train
Vital-Fernandez/dazer
bin/lib/Astro_Libraries/f2n.py
f2nimage.writetitle
def writetitle(self, titlestring, colour = None): """ We write a title, centered below the image. """ self.checkforpilimage() colour = self.defaultcolour(colour) self.changecolourmode(colour) self.makedraw() self.loadtitlefont() ...
python
def writetitle(self, titlestring, colour = None): """ We write a title, centered below the image. """ self.checkforpilimage() colour = self.defaultcolour(colour) self.changecolourmode(colour) self.makedraw() self.loadtitlefont() ...
[ "def", "writetitle", "(", "self", ",", "titlestring", ",", "colour", "=", "None", ")", ":", "self", ".", "checkforpilimage", "(", ")", "colour", "=", "self", ".", "defaultcolour", "(", "colour", ")", "self", ".", "changecolourmode", "(", "colour", ")", "...
We write a title, centered below the image.
[ "We", "write", "a", "title", "centered", "below", "the", "image", "." ]
3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L816-L837
train
Vital-Fernandez/dazer
bin/lib/Astro_Libraries/f2n.py
f2nimage.writeinfo
def writeinfo(self, linelist, colour = None): """ We add a longer chunk of text on the upper left corner of the image. Provide linelist, a list of strings that will be written one below the other. """ self.checkforpilimage() colour = self.defaultcolour(colour) ...
python
def writeinfo(self, linelist, colour = None): """ We add a longer chunk of text on the upper left corner of the image. Provide linelist, a list of strings that will be written one below the other. """ self.checkforpilimage() colour = self.defaultcolour(colour) ...
[ "def", "writeinfo", "(", "self", ",", "linelist", ",", "colour", "=", "None", ")", ":", "self", ".", "checkforpilimage", "(", ")", "colour", "=", "self", ".", "defaultcolour", "(", "colour", ")", "self", ".", "changecolourmode", "(", "colour", ")", "self...
We add a longer chunk of text on the upper left corner of the image. Provide linelist, a list of strings that will be written one below the other.
[ "We", "add", "a", "longer", "chunk", "of", "text", "on", "the", "upper", "left", "corner", "of", "the", "image", ".", "Provide", "linelist", "a", "list", "of", "strings", "that", "will", "be", "written", "one", "below", "the", "other", "." ]
3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L841-L861
train
Vital-Fernandez/dazer
bin/lib/Astro_Libraries/f2n.py
f2nimage.drawstarslist
def drawstarslist(self, dictlist, r = 10, colour = None): """ Calls drawcircle and writelable for an list of stars. Provide a list of dictionnaries, where each dictionnary contains "name", "x", and "y". """ self.checkforpilimage() colour = self.defaultco...
python
def drawstarslist(self, dictlist, r = 10, colour = None): """ Calls drawcircle and writelable for an list of stars. Provide a list of dictionnaries, where each dictionnary contains "name", "x", and "y". """ self.checkforpilimage() colour = self.defaultco...
[ "def", "drawstarslist", "(", "self", ",", "dictlist", ",", "r", "=", "10", ",", "colour", "=", "None", ")", ":", "self", ".", "checkforpilimage", "(", ")", "colour", "=", "self", ".", "defaultcolour", "(", "colour", ")", "self", ".", "changecolourmode", ...
Calls drawcircle and writelable for an list of stars. Provide a list of dictionnaries, where each dictionnary contains "name", "x", and "y".
[ "Calls", "drawcircle", "and", "writelable", "for", "an", "list", "of", "stars", ".", "Provide", "a", "list", "of", "dictionnaries", "where", "each", "dictionnary", "contains", "name", "x", "and", "y", "." ]
3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L865-L883
train
Vital-Fernandez/dazer
bin/lib/Astro_Libraries/f2n.py
f2nimage.drawstarsfile
def drawstarsfile(self, filename, r = 10, colour = None): """ Same as drawstarlist but we read the stars from a file. Here we read a text file of hand picked stars. Same format as for cosmouline, that is : # comment starA 23.4 45.6 [other stuff...] Then we pass t...
python
def drawstarsfile(self, filename, r = 10, colour = None): """ Same as drawstarlist but we read the stars from a file. Here we read a text file of hand picked stars. Same format as for cosmouline, that is : # comment starA 23.4 45.6 [other stuff...] Then we pass t...
[ "def", "drawstarsfile", "(", "self", ",", "filename", ",", "r", "=", "10", ",", "colour", "=", "None", ")", ":", "if", "not", "os", ".", "path", ".", "isfile", "(", "filename", ")", ":", "print", "\"File does not exist :\"", "print", "filename", "print",...
Same as drawstarlist but we read the stars from a file. Here we read a text file of hand picked stars. Same format as for cosmouline, that is : # comment starA 23.4 45.6 [other stuff...] Then we pass this to drawstarlist,
[ "Same", "as", "drawstarlist", "but", "we", "read", "the", "stars", "from", "a", "file", ".", "Here", "we", "read", "a", "text", "file", "of", "hand", "picked", "stars", ".", "Same", "format", "as", "for", "cosmouline", "that", "is", ":", "#", "comment"...
3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L886-L925
train
Vital-Fernandez/dazer
bin/lib/Astro_Libraries/f2n.py
f2nimage.tonet
def tonet(self, outfile): """ Writes the PIL image into a png. We do not want to flip the image at this stage, as you might have written on it ! """ self.checkforpilimage() if self.verbose : print "Writing image to %s...\n%i x %i pixels, mode %s" % (o...
python
def tonet(self, outfile): """ Writes the PIL image into a png. We do not want to flip the image at this stage, as you might have written on it ! """ self.checkforpilimage() if self.verbose : print "Writing image to %s...\n%i x %i pixels, mode %s" % (o...
[ "def", "tonet", "(", "self", ",", "outfile", ")", ":", "self", ".", "checkforpilimage", "(", ")", "if", "self", ".", "verbose", ":", "print", "\"Writing image to %s...\\n%i x %i pixels, mode %s\"", "%", "(", "outfile", ",", "self", ".", "pilimage", ".", "size"...
Writes the PIL image into a png. We do not want to flip the image at this stage, as you might have written on it !
[ "Writes", "the", "PIL", "image", "into", "a", "png", ".", "We", "do", "not", "want", "to", "flip", "the", "image", "at", "this", "stage", "as", "you", "might", "have", "written", "on", "it", "!" ]
3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L928-L937
train
bitesofcode/pyramid_restful
pyramid_restful/api.py
ApiFactory.cors_setup
def cors_setup(self, request): """ Sets up the CORS headers response based on the settings used for the API. :param request: <pyramid.request.Request> """ def cors_headers(request, response): if request.method.lower() == 'options': response.headers.up...
python
def cors_setup(self, request): """ Sets up the CORS headers response based on the settings used for the API. :param request: <pyramid.request.Request> """ def cors_headers(request, response): if request.method.lower() == 'options': response.headers.up...
[ "def", "cors_setup", "(", "self", ",", "request", ")", ":", "def", "cors_headers", "(", "request", ",", "response", ")", ":", "if", "request", ".", "method", ".", "lower", "(", ")", "==", "'options'", ":", "response", ".", "headers", ".", "update", "("...
Sets up the CORS headers response based on the settings used for the API. :param request: <pyramid.request.Request>
[ "Sets", "up", "the", "CORS", "headers", "response", "based", "on", "the", "settings", "used", "for", "the", "API", "." ]
0f1eccb2c61b9bd6add03b461d4e4d7901c957da
https://github.com/bitesofcode/pyramid_restful/blob/0f1eccb2c61b9bd6add03b461d4e4d7901c957da/pyramid_restful/api.py#L67-L87
train
bitesofcode/pyramid_restful
pyramid_restful/api.py
ApiFactory.factory
def factory(self, request, parent=None, name=None): """ Returns a new service for the given request. :param request | <pyramid.request.Request> :return <pyramid_restful.services.AbstractService> """ traverse = request.matchdict['traverse'] # show docum...
python
def factory(self, request, parent=None, name=None): """ Returns a new service for the given request. :param request | <pyramid.request.Request> :return <pyramid_restful.services.AbstractService> """ traverse = request.matchdict['traverse'] # show docum...
[ "def", "factory", "(", "self", ",", "request", ",", "parent", "=", "None", ",", "name", "=", "None", ")", ":", "traverse", "=", "request", ".", "matchdict", "[", "'traverse'", "]", "# show documentation at the root path", "if", "not", "traverse", ":", "retur...
Returns a new service for the given request. :param request | <pyramid.request.Request> :return <pyramid_restful.services.AbstractService>
[ "Returns", "a", "new", "service", "for", "the", "given", "request", "." ]
0f1eccb2c61b9bd6add03b461d4e4d7901c957da
https://github.com/bitesofcode/pyramid_restful/blob/0f1eccb2c61b9bd6add03b461d4e4d7901c957da/pyramid_restful/api.py#L89-L132
train
bitesofcode/pyramid_restful
pyramid_restful/api.py
ApiFactory.register
def register(self, service, name=''): """ Exposes a given service to this API. """ # expose a sub-factory if isinstance(service, ApiFactory): self.services[name] = (service.factory, None) # expose a module dynamically as a service elif inspect.ismodul...
python
def register(self, service, name=''): """ Exposes a given service to this API. """ # expose a sub-factory if isinstance(service, ApiFactory): self.services[name] = (service.factory, None) # expose a module dynamically as a service elif inspect.ismodul...
[ "def", "register", "(", "self", ",", "service", ",", "name", "=", "''", ")", ":", "# expose a sub-factory", "if", "isinstance", "(", "service", ",", "ApiFactory", ")", ":", "self", ".", "services", "[", "name", "]", "=", "(", "service", ".", "factory", ...
Exposes a given service to this API.
[ "Exposes", "a", "given", "service", "to", "this", "API", "." ]
0f1eccb2c61b9bd6add03b461d4e4d7901c957da
https://github.com/bitesofcode/pyramid_restful/blob/0f1eccb2c61b9bd6add03b461d4e4d7901c957da/pyramid_restful/api.py#L231-L283
train
bitesofcode/pyramid_restful
pyramid_restful/api.py
ApiFactory.serve
def serve(self, config, path, route_name=None, permission=None, **view_options): """ Serves this API from the inputted root path """ route_name = route_name or path.replace('/', '.').strip('.') path = path.strip('/') + '*traverse' self.route_name = route_name sel...
python
def serve(self, config, path, route_name=None, permission=None, **view_options): """ Serves this API from the inputted root path """ route_name = route_name or path.replace('/', '.').strip('.') path = path.strip('/') + '*traverse' self.route_name = route_name sel...
[ "def", "serve", "(", "self", ",", "config", ",", "path", ",", "route_name", "=", "None", ",", "permission", "=", "None", ",", "*", "*", "view_options", ")", ":", "route_name", "=", "route_name", "or", "path", ".", "replace", "(", "'/'", ",", "'.'", "...
Serves this API from the inputted root path
[ "Serves", "this", "API", "from", "the", "inputted", "root", "path" ]
0f1eccb2c61b9bd6add03b461d4e4d7901c957da
https://github.com/bitesofcode/pyramid_restful/blob/0f1eccb2c61b9bd6add03b461d4e4d7901c957da/pyramid_restful/api.py#L369-L398
train
jaredLunde/vital-tools
vital/debug/__init__.py
line
def line(separator="-·-", color=None, padding=None, num=1): """ Prints a line separator the full width of the terminal. @separator: the #str chars to create the line from @color: line color from :mod:vital.debug.colors @padding: adds extra lines to either the top, bottom or both ...
python
def line(separator="-·-", color=None, padding=None, num=1): """ Prints a line separator the full width of the terminal. @separator: the #str chars to create the line from @color: line color from :mod:vital.debug.colors @padding: adds extra lines to either the top, bottom or both ...
[ "def", "line", "(", "separator", "=", "\"-·-\",", " ", "olor=", "N", "one,", " ", "adding=", "N", "one,", " ", "um=", "1", ")", ":", "", "for", "x", "in", "range", "(", "num", ")", ":", "columns", "=", "get_terminal_width", "(", ")", "separator", "...
Prints a line separator the full width of the terminal. @separator: the #str chars to create the line from @color: line color from :mod:vital.debug.colors @padding: adds extra lines to either the top, bottom or both of the line via :func:padd @num: #int number of lines to pr...
[ "Prints", "a", "line", "separator", "the", "full", "width", "of", "the", "terminal", "." ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L103-L122
train
jaredLunde/vital-tools
vital/debug/__init__.py
padd
def padd(text, padding="top", size=1): """ Adds extra new lines to the top, bottom or both of a String @text: #str text to pad @padding: #str 'top', 'bottom' or 'all' @size: #int number of new lines -> #str padded @text .. from vital.debug import * ...
python
def padd(text, padding="top", size=1): """ Adds extra new lines to the top, bottom or both of a String @text: #str text to pad @padding: #str 'top', 'bottom' or 'all' @size: #int number of new lines -> #str padded @text .. from vital.debug import * ...
[ "def", "padd", "(", "text", ",", "padding", "=", "\"top\"", ",", "size", "=", "1", ")", ":", "if", "padding", ":", "padding", "=", "padding", ".", "lower", "(", ")", "pad_all", "=", "padding", "==", "'all'", "padding_top", "=", "\"\"", "if", "padding...
Adds extra new lines to the top, bottom or both of a String @text: #str text to pad @padding: #str 'top', 'bottom' or 'all' @size: #int number of new lines -> #str padded @text .. from vital.debug import * padd("Hello world") # -> '\\nHello ...
[ "Adds", "extra", "new", "lines", "to", "the", "top", "bottom", "or", "both", "of", "a", "String" ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L125-L153
train
jaredLunde/vital-tools
vital/debug/__init__.py
colorize
def colorize(text, color="BLUE", close=True): """ Colorizes text for terminal outputs @text: #str to colorize @color: #str color from :mod:colors @close: #bool whether or not to reset the color -> #str colorized @text .. from vital.debug import colorize ...
python
def colorize(text, color="BLUE", close=True): """ Colorizes text for terminal outputs @text: #str to colorize @color: #str color from :mod:colors @close: #bool whether or not to reset the color -> #str colorized @text .. from vital.debug import colorize ...
[ "def", "colorize", "(", "text", ",", "color", "=", "\"BLUE\"", ",", "close", "=", "True", ")", ":", "if", "color", ":", "color", "=", "getattr", "(", "colors", ",", "color", ".", "upper", "(", ")", ")", "return", "color", "+", "uncolorize", "(", "s...
Colorizes text for terminal outputs @text: #str to colorize @color: #str color from :mod:colors @close: #bool whether or not to reset the color -> #str colorized @text .. from vital.debug import colorize colorize("Hello world", "blue") # -> ...
[ "Colorizes", "text", "for", "terminal", "outputs" ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L156-L177
train
jaredLunde/vital-tools
vital/debug/__init__.py
bold
def bold(text, close=True): """ Bolds text for terminal outputs @text: #str to bold @close: #bool whether or not to reset the bold flag -> #str bolded @text .. from vital.debug import bold bold("Hello world") # -> '\x1b[1mHello world\x1b[1;m' ...
python
def bold(text, close=True): """ Bolds text for terminal outputs @text: #str to bold @close: #bool whether or not to reset the bold flag -> #str bolded @text .. from vital.debug import bold bold("Hello world") # -> '\x1b[1mHello world\x1b[1;m' ...
[ "def", "bold", "(", "text", ",", "close", "=", "True", ")", ":", "return", "getattr", "(", "colors", ",", "\"BOLD\"", ")", "+", "str", "(", "text", ")", "+", "(", "colors", ".", "RESET", "if", "close", "else", "\"\"", ")" ]
Bolds text for terminal outputs @text: #str to bold @close: #bool whether or not to reset the bold flag -> #str bolded @text .. from vital.debug import bold bold("Hello world") # -> '\x1b[1mHello world\x1b[1;m' bold("Hello world", close...
[ "Bolds", "text", "for", "terminal", "outputs" ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L199-L217
train
jaredLunde/vital-tools
vital/debug/__init__.py
cut
def cut(text, length=50, replace_with="…"): """ Shortens text to @length, appends @replace_with to end of string if the string length is > @length @text: #str text to shortens @length: #int max length of string @replace_with: #str to replace chars beyond @length with .. ...
python
def cut(text, length=50, replace_with="…"): """ Shortens text to @length, appends @replace_with to end of string if the string length is > @length @text: #str text to shortens @length: #int max length of string @replace_with: #str to replace chars beyond @length with .. ...
[ "def", "cut", "(", "text", ",", "length", "=", "50", ",", "replace_with", "=", "\"…\"):", "", "", "text_len", "=", "len", "(", "uncolorize", "(", "text", ")", ")", "if", "text_len", ">", "length", ":", "replace_len", "=", "len", "(", "replace_with", ...
Shortens text to @length, appends @replace_with to end of string if the string length is > @length @text: #str text to shortens @length: #int max length of string @replace_with: #str to replace chars beyond @length with .. from vital.debug import cut cut...
[ "Shortens", "text", "to", "@length", "appends", "@replace_with", "to", "end", "of", "string", "if", "the", "string", "length", "is", ">", "@length" ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L226-L267
train
jaredLunde/vital-tools
vital/debug/__init__.py
flag
def flag(text=None, color=None, padding=None, show=True, brackets='⸨⸩'): """ Wraps @text in parentheses (), optionally colors and pads and prints the text. @text: #str text to (flag) @color: #str color to :func:colorize the text within @padding: #str location of padding from :func:p...
python
def flag(text=None, color=None, padding=None, show=True, brackets='⸨⸩'): """ Wraps @text in parentheses (), optionally colors and pads and prints the text. @text: #str text to (flag) @color: #str color to :func:colorize the text within @padding: #str location of padding from :func:p...
[ "def", "flag", "(", "text", "=", "None", ",", "color", "=", "None", ",", "padding", "=", "None", ",", "show", "=", "True", ",", "brackets", "=", "'⸨⸩'):", "", "", "_flag", "=", "None", "if", "text", ":", "_flag", "=", "padd", "(", "\"{}{}{}\"", "...
Wraps @text in parentheses (), optionally colors and pads and prints the text. @text: #str text to (flag) @color: #str color to :func:colorize the text within @padding: #str location of padding from :func:padd @show: #bool whether or not to print the text in addition to returnin...
[ "Wraps", "@text", "in", "parentheses", "()", "optionally", "colors", "and", "pads", "and", "prints", "the", "text", "." ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L270-L312
train
jaredLunde/vital-tools
vital/debug/__init__.py
table_mapping
def table_mapping(data, padding=1, separator=" "): """ Pretty prints a one-dimensional key: value mapping @data: #dict data to pretty print @padding: #int number of spaces to pad the left side of the key with @separator: #str chars to separate the key and value pair with -> #str pr...
python
def table_mapping(data, padding=1, separator=" "): """ Pretty prints a one-dimensional key: value mapping @data: #dict data to pretty print @padding: #int number of spaces to pad the left side of the key with @separator: #str chars to separate the key and value pair with -> #str pr...
[ "def", "table_mapping", "(", "data", ",", "padding", "=", "1", ",", "separator", "=", "\" \"", ")", ":", "if", "data", ":", "ml", "=", "max", "(", "len", "(", "k", ")", "for", "k", "in", "data", ".", "keys", "(", ")", ")", "+", "1", "return", ...
Pretty prints a one-dimensional key: value mapping @data: #dict data to pretty print @padding: #int number of spaces to pad the left side of the key with @separator: #str chars to separate the key and value pair with -> #str pretty one dimensional table .. from vita...
[ "Pretty", "prints", "a", "one", "-", "dimensional", "key", ":", "value", "mapping" ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L315-L345
train
jaredLunde/vital-tools
vital/debug/__init__.py
gen_rand_str
def gen_rand_str(*size, use=None, keyspace=None): """ Generates a random string using random module specified in @use within the @keyspace @*size: #int size range for the length of the string @use: the random module to use @keyspace: #str chars allowed in the random string ....
python
def gen_rand_str(*size, use=None, keyspace=None): """ Generates a random string using random module specified in @use within the @keyspace @*size: #int size range for the length of the string @use: the random module to use @keyspace: #str chars allowed in the random string ....
[ "def", "gen_rand_str", "(", "*", "size", ",", "use", "=", "None", ",", "keyspace", "=", "None", ")", ":", "keyspace", "=", "keyspace", "or", "(", "string", ".", "ascii_letters", "+", "string", ".", "digits", ")", "keyspace", "=", "[", "char", "for", ...
Generates a random string using random module specified in @use within the @keyspace @*size: #int size range for the length of the string @use: the random module to use @keyspace: #str chars allowed in the random string .. from vital.debug import gen_rand_str ...
[ "Generates", "a", "random", "string", "using", "random", "module", "specified", "in", "@use", "within", "the", "@keyspace" ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L348-L378
train
jaredLunde/vital-tools
vital/debug/__init__.py
get_parent_name
def get_parent_name(obj): """ Gets the name of the object containing @obj and returns as a string @obj: any python object -> #str parent object name or None .. from vital.debug import get_parent_name get_parent_name(get_parent_name) # -> 'vital.debug' ...
python
def get_parent_name(obj): """ Gets the name of the object containing @obj and returns as a string @obj: any python object -> #str parent object name or None .. from vital.debug import get_parent_name get_parent_name(get_parent_name) # -> 'vital.debug' ...
[ "def", "get_parent_name", "(", "obj", ")", ":", "parent_obj", "=", "get_parent_obj", "(", "obj", ")", "parent_name", "=", "get_obj_name", "(", "parent_obj", ")", "if", "parent_obj", "else", "None", "n", "=", "0", "while", "parent_obj", "and", "n", "<", "25...
Gets the name of the object containing @obj and returns as a string @obj: any python object -> #str parent object name or None .. from vital.debug import get_parent_name get_parent_name(get_parent_name) # -> 'vital.debug' get_parent_name(vital....
[ "Gets", "the", "name", "of", "the", "object", "containing", "@obj", "and", "returns", "as", "a", "string" ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L425-L458
train
jaredLunde/vital-tools
vital/debug/__init__.py
get_class_that_defined_method
def get_class_that_defined_method(meth): """ Gets the class object which defined a given method @meth: a class method -> owner class object """ if inspect.ismethod(meth): for cls in inspect.getmro(meth.__self__.__class__): if cls.__dict__.get(meth.__name__) is meth: ...
python
def get_class_that_defined_method(meth): """ Gets the class object which defined a given method @meth: a class method -> owner class object """ if inspect.ismethod(meth): for cls in inspect.getmro(meth.__self__.__class__): if cls.__dict__.get(meth.__name__) is meth: ...
[ "def", "get_class_that_defined_method", "(", "meth", ")", ":", "if", "inspect", ".", "ismethod", "(", "meth", ")", ":", "for", "cls", "in", "inspect", ".", "getmro", "(", "meth", ".", "__self__", ".", "__class__", ")", ":", "if", "cls", ".", "__dict__", ...
Gets the class object which defined a given method @meth: a class method -> owner class object
[ "Gets", "the", "class", "object", "which", "defined", "a", "given", "method" ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L461-L479
train
jaredLunde/vital-tools
vital/debug/__init__.py
get_parent_obj
def get_parent_obj(obj): """ Gets the name of the object containing @obj and returns as a string @obj: any python object -> #str parent object name or None .. from vital.debug import get_parent_obj get_parent_obj(get_parent_obj) # -> <module 'vital.debu...
python
def get_parent_obj(obj): """ Gets the name of the object containing @obj and returns as a string @obj: any python object -> #str parent object name or None .. from vital.debug import get_parent_obj get_parent_obj(get_parent_obj) # -> <module 'vital.debu...
[ "def", "get_parent_obj", "(", "obj", ")", ":", "try", ":", "cls", "=", "get_class_that_defined_method", "(", "obj", ")", "if", "cls", "and", "cls", "!=", "obj", ":", "return", "cls", "except", "AttributeError", ":", "pass", "if", "hasattr", "(", "obj", "...
Gets the name of the object containing @obj and returns as a string @obj: any python object -> #str parent object name or None .. from vital.debug import get_parent_obj get_parent_obj(get_parent_obj) # -> <module 'vital.debug' from> ..
[ "Gets", "the", "name", "of", "the", "object", "containing", "@obj", "and", "returns", "as", "a", "string" ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L482-L528
train
jaredLunde/vital-tools
vital/debug/__init__.py
format_obj_name
def format_obj_name(obj, delim="<>"): """ Formats the object name in a pretty way @obj: any python object @delim: the characters to wrap a parent object name in -> #str formatted name .. from vital.debug import format_obj_name format_obj_name(vital.debug.Ti...
python
def format_obj_name(obj, delim="<>"): """ Formats the object name in a pretty way @obj: any python object @delim: the characters to wrap a parent object name in -> #str formatted name .. from vital.debug import format_obj_name format_obj_name(vital.debug.Ti...
[ "def", "format_obj_name", "(", "obj", ",", "delim", "=", "\"<>\"", ")", ":", "pname", "=", "\"\"", "parent_name", "=", "get_parent_name", "(", "obj", ")", "if", "parent_name", ":", "pname", "=", "\"{}{}{}\"", ".", "format", "(", "delim", "[", "0", "]", ...
Formats the object name in a pretty way @obj: any python object @delim: the characters to wrap a parent object name in -> #str formatted name .. from vital.debug import format_obj_name format_obj_name(vital.debug.Timer) # -> 'Timer<vital.debug>' ...
[ "Formats", "the", "object", "name", "in", "a", "pretty", "way" ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L564-L588
train
jaredLunde/vital-tools
vital/debug/__init__.py
preprX
def preprX(*attributes, address=True, full_name=False, pretty=False, keyless=False, **kwargs): """ `Creates prettier object representations` @*attributes: (#str) instance attributes within the object you wish to display. Attributes can be recursive e.g. |one.two.three| fo...
python
def preprX(*attributes, address=True, full_name=False, pretty=False, keyless=False, **kwargs): """ `Creates prettier object representations` @*attributes: (#str) instance attributes within the object you wish to display. Attributes can be recursive e.g. |one.two.three| fo...
[ "def", "preprX", "(", "*", "attributes", ",", "address", "=", "True", ",", "full_name", "=", "False", ",", "pretty", "=", "False", ",", "keyless", "=", "False", ",", "*", "*", "kwargs", ")", ":", "def", "_format", "(", "obj", ",", "attribute", ")", ...
`Creates prettier object representations` @*attributes: (#str) instance attributes within the object you wish to display. Attributes can be recursive e.g. |one.two.three| for access to |self.one.two.three| @address: (#bool) |True| to include the memory address @full_name...
[ "Creates", "prettier", "object", "representations" ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L591-L643
train
jaredLunde/vital-tools
vital/debug/__init__.py
prepr.add_attrs
def add_attrs(self, *args, _order=[], **kwargs): """ Adds attributes to the __repr__ string @order: optional #list containing order to display kwargs """ for arg in args: if isinstance(arg, (tuple, list)): key, color = arg self.attrs[key] =...
python
def add_attrs(self, *args, _order=[], **kwargs): """ Adds attributes to the __repr__ string @order: optional #list containing order to display kwargs """ for arg in args: if isinstance(arg, (tuple, list)): key, color = arg self.attrs[key] =...
[ "def", "add_attrs", "(", "self", ",", "*", "args", ",", "_order", "=", "[", "]", ",", "*", "*", "kwargs", ")", ":", "for", "arg", "in", "args", ":", "if", "isinstance", "(", "arg", ",", "(", "tuple", ",", "list", ")", ")", ":", "key", ",", "c...
Adds attributes to the __repr__ string @order: optional #list containing order to display kwargs
[ "Adds", "attributes", "to", "the", "__repr__", "string" ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L683-L698
train
jaredLunde/vital-tools
vital/debug/__init__.py
prepr._format_attrs
def _format_attrs(self): """ Formats the self.attrs #OrderedDict """ _bold = bold _colorize = colorize if not self.pretty: _bold = lambda x: x _colorize = lambda x, c: x attrs = [] add_attr = attrs.append if self.doc and hasattr(self.obj, "...
python
def _format_attrs(self): """ Formats the self.attrs #OrderedDict """ _bold = bold _colorize = colorize if not self.pretty: _bold = lambda x: x _colorize = lambda x, c: x attrs = [] add_attr = attrs.append if self.doc and hasattr(self.obj, "...
[ "def", "_format_attrs", "(", "self", ")", ":", "_bold", "=", "bold", "_colorize", "=", "colorize", "if", "not", "self", ".", "pretty", ":", "_bold", "=", "lambda", "x", ":", "x", "_colorize", "=", "lambda", "x", ",", "c", ":", "x", "attrs", "=", "[...
Formats the self.attrs #OrderedDict
[ "Formats", "the", "self", ".", "attrs", "#OrderedDict" ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L708-L745
train
jaredLunde/vital-tools
vital/debug/__init__.py
prepr.format
def format(self): """ Formats the __repr__ string -> #str containing __repr__ output """ _bold = bold _break = "\n " if not self.pretty: _bold = lambda x: x # Attach memory address and return _attrs = self._format_attrs() parent_...
python
def format(self): """ Formats the __repr__ string -> #str containing __repr__ output """ _bold = bold _break = "\n " if not self.pretty: _bold = lambda x: x # Attach memory address and return _attrs = self._format_attrs() parent_...
[ "def", "format", "(", "self", ")", ":", "_bold", "=", "bold", "_break", "=", "\"\\n \"", "if", "not", "self", ".", "pretty", ":", "_bold", "=", "lambda", "x", ":", "x", "# Attach memory address and return", "_attrs", "=", "self", ".", "_format_attrs", "...
Formats the __repr__ string -> #str containing __repr__ output
[ "Formats", "the", "__repr__", "string", "-", ">", "#str", "containing", "__repr__", "output" ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L747-L764
train
jaredLunde/vital-tools
vital/debug/__init__.py
RandData.randstr
def randstr(self): """ -> #str result of :func:gen_rand_str """ return gen_rand_str( 4, 10, use=self.random, keyspace=list(string.ascii_letters))
python
def randstr(self): """ -> #str result of :func:gen_rand_str """ return gen_rand_str( 4, 10, use=self.random, keyspace=list(string.ascii_letters))
[ "def", "randstr", "(", "self", ")", ":", "return", "gen_rand_str", "(", "4", ",", "10", ",", "use", "=", "self", ".", "random", ",", "keyspace", "=", "list", "(", "string", ".", "ascii_letters", ")", ")" ]
-> #str result of :func:gen_rand_str
[ "-", ">", "#str", "result", "of", ":", "func", ":", "gen_rand_str" ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L851-L854
train
jaredLunde/vital-tools
vital/debug/__init__.py
RandData.randbytes
def randbytes(self): """ -> #bytes result of bytes-encoded :func:gen_rand_str """ return gen_rand_str( 10, 30, use=self.random, keyspace=list(self.keyspace) ).encode("utf-8")
python
def randbytes(self): """ -> #bytes result of bytes-encoded :func:gen_rand_str """ return gen_rand_str( 10, 30, use=self.random, keyspace=list(self.keyspace) ).encode("utf-8")
[ "def", "randbytes", "(", "self", ")", ":", "return", "gen_rand_str", "(", "10", ",", "30", ",", "use", "=", "self", ".", "random", ",", "keyspace", "=", "list", "(", "self", ".", "keyspace", ")", ")", ".", "encode", "(", "\"utf-8\"", ")" ]
-> #bytes result of bytes-encoded :func:gen_rand_str
[ "-", ">", "#bytes", "result", "of", "bytes", "-", "encoded", ":", "func", ":", "gen_rand_str" ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L857-L861
train
jaredLunde/vital-tools
vital/debug/__init__.py
RandData.randdomain
def randdomain(self): """ -> a randomized domain-like name """ return '.'.join( rand_readable(3, 6, use=self.random, density=3) for _ in range(self.random.randint(1, 2)) ).lower()
python
def randdomain(self): """ -> a randomized domain-like name """ return '.'.join( rand_readable(3, 6, use=self.random, density=3) for _ in range(self.random.randint(1, 2)) ).lower()
[ "def", "randdomain", "(", "self", ")", ":", "return", "'.'", ".", "join", "(", "rand_readable", "(", "3", ",", "6", ",", "use", "=", "self", ".", "random", ",", "density", "=", "3", ")", "for", "_", "in", "range", "(", "self", ".", "random", ".",...
-> a randomized domain-like name
[ "-", ">", "a", "randomized", "domain", "-", "like", "name" ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L864-L869
train
jaredLunde/vital-tools
vital/debug/__init__.py
RandData.randpath
def randpath(self): """ -> a random URI-like #str path """ return '/'.join( gen_rand_str(3, 10, use=self.random, keyspace=list(self.keyspace)) for _ in range(self.random.randint(0, 3)))
python
def randpath(self): """ -> a random URI-like #str path """ return '/'.join( gen_rand_str(3, 10, use=self.random, keyspace=list(self.keyspace)) for _ in range(self.random.randint(0, 3)))
[ "def", "randpath", "(", "self", ")", ":", "return", "'/'", ".", "join", "(", "gen_rand_str", "(", "3", ",", "10", ",", "use", "=", "self", ".", "random", ",", "keyspace", "=", "list", "(", "self", ".", "keyspace", ")", ")", "for", "_", "in", "ran...
-> a random URI-like #str path
[ "-", ">", "a", "random", "URI", "-", "like", "#str", "path" ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L872-L876
train
jaredLunde/vital-tools
vital/debug/__init__.py
RandData.randtld
def randtld(self): """ -> a random #str tld via :mod:tlds """ self.tlds = tuple(tlds.tlds) if not self.tlds else self.tlds return self.random.choice(self.tlds)
python
def randtld(self): """ -> a random #str tld via :mod:tlds """ self.tlds = tuple(tlds.tlds) if not self.tlds else self.tlds return self.random.choice(self.tlds)
[ "def", "randtld", "(", "self", ")", ":", "self", ".", "tlds", "=", "tuple", "(", "tlds", ".", "tlds", ")", "if", "not", "self", ".", "tlds", "else", "self", ".", "tlds", "return", "self", ".", "random", ".", "choice", "(", "self", ".", "tlds", ")...
-> a random #str tld via :mod:tlds
[ "-", ">", "a", "random", "#str", "tld", "via", ":", "mod", ":", "tlds" ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L879-L882
train
jaredLunde/vital-tools
vital/debug/__init__.py
RandData.randurl
def randurl(self): """ -> a random url-like #str via :prop:randdomain, :prop:randtld, and :prop:randpath """ return "{}://{}.{}/{}".format( self.random.choice(("http", "https")), self.randdomain, self.randtld, self.randpath)
python
def randurl(self): """ -> a random url-like #str via :prop:randdomain, :prop:randtld, and :prop:randpath """ return "{}://{}.{}/{}".format( self.random.choice(("http", "https")), self.randdomain, self.randtld, self.randpath)
[ "def", "randurl", "(", "self", ")", ":", "return", "\"{}://{}.{}/{}\"", ".", "format", "(", "self", ".", "random", ".", "choice", "(", "(", "\"http\"", ",", "\"https\"", ")", ")", ",", "self", ".", "randdomain", ",", "self", ".", "randtld", ",", "self"...
-> a random url-like #str via :prop:randdomain, :prop:randtld, and :prop:randpath
[ "-", ">", "a", "random", "url", "-", "like", "#str", "via", ":", "prop", ":", "randdomain", ":", "prop", ":", "randtld", "and", ":", "prop", ":", "randpath" ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L885-L891
train
jaredLunde/vital-tools
vital/debug/__init__.py
RandData.randtuple
def randtuple(self): """ -> a #tuple of random #int """ return tuple( self.randint for x in range(0, self.random.randint(3, 10)))
python
def randtuple(self): """ -> a #tuple of random #int """ return tuple( self.randint for x in range(0, self.random.randint(3, 10)))
[ "def", "randtuple", "(", "self", ")", ":", "return", "tuple", "(", "self", ".", "randint", "for", "x", "in", "range", "(", "0", ",", "self", ".", "random", ".", "randint", "(", "3", ",", "10", ")", ")", ")" ]
-> a #tuple of random #int
[ "-", ">", "a", "#tuple", "of", "random", "#int" ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L926-L930
train
jaredLunde/vital-tools
vital/debug/__init__.py
RandData.randdeque
def randdeque(self): """ -> a :class:collections.deque of random #int """ return deque( self.randint for x in range(0, self.random.randint(3, 10)))
python
def randdeque(self): """ -> a :class:collections.deque of random #int """ return deque( self.randint for x in range(0, self.random.randint(3, 10)))
[ "def", "randdeque", "(", "self", ")", ":", "return", "deque", "(", "self", ".", "randint", "for", "x", "in", "range", "(", "0", ",", "self", ".", "random", ".", "randint", "(", "3", ",", "10", ")", ")", ")" ]
-> a :class:collections.deque of random #int
[ "-", ">", "a", ":", "class", ":", "collections", ".", "deque", "of", "random", "#int" ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L933-L937
train
jaredLunde/vital-tools
vital/debug/__init__.py
RandData.randdict
def randdict(self): """ -> a #dict of |{random_string: random_int}| """ return { self.randstr: self._map_type(int) for x in range(self.random.randint(3, 10))}
python
def randdict(self): """ -> a #dict of |{random_string: random_int}| """ return { self.randstr: self._map_type(int) for x in range(self.random.randint(3, 10))}
[ "def", "randdict", "(", "self", ")", ":", "return", "{", "self", ".", "randstr", ":", "self", ".", "_map_type", "(", "int", ")", "for", "x", "in", "range", "(", "self", ".", "random", ".", "randint", "(", "3", ",", "10", ")", ")", "}" ]
-> a #dict of |{random_string: random_int}|
[ "-", ">", "a", "#dict", "of", "|", "{", "random_string", ":", "random_int", "}", "|" ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L940-L944
train
jaredLunde/vital-tools
vital/debug/__init__.py
RandData.randset
def randset(self): """ -> a #set of random integers """ return { self._map_type(int) for x in range(self.random.randint(3, 10))}
python
def randset(self): """ -> a #set of random integers """ return { self._map_type(int) for x in range(self.random.randint(3, 10))}
[ "def", "randset", "(", "self", ")", ":", "return", "{", "self", ".", "_map_type", "(", "int", ")", "for", "x", "in", "range", "(", "self", ".", "random", ".", "randint", "(", "3", ",", "10", ")", ")", "}" ]
-> a #set of random integers
[ "-", ">", "a", "#set", "of", "random", "integers" ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L947-L951
train
jaredLunde/vital-tools
vital/debug/__init__.py
RandData._to_tuple
def _to_tuple(self, _list): """ Recursively converts lists to tuples """ result = list() for l in _list: if isinstance(l, list): result.append(tuple(self._to_tuple(l))) else: result.append(l) return tuple(result)
python
def _to_tuple(self, _list): """ Recursively converts lists to tuples """ result = list() for l in _list: if isinstance(l, list): result.append(tuple(self._to_tuple(l))) else: result.append(l) return tuple(result)
[ "def", "_to_tuple", "(", "self", ",", "_list", ")", ":", "result", "=", "list", "(", ")", "for", "l", "in", "_list", ":", "if", "isinstance", "(", "l", ",", "list", ")", ":", "result", ".", "append", "(", "tuple", "(", "self", ".", "_to_tuple", "...
Recursively converts lists to tuples
[ "Recursively", "converts", "lists", "to", "tuples" ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L959-L967
train
jaredLunde/vital-tools
vital/debug/__init__.py
RandData.dict
def dict(self, key_depth=1000, tree_depth=1): """ Creates a random #dict @key_depth: #int number of keys per @tree_depth to generate random values for @tree_depth: #int dict tree dimensions size, i.e. 1=|{key: value}| 2=|{key: {key: value}...
python
def dict(self, key_depth=1000, tree_depth=1): """ Creates a random #dict @key_depth: #int number of keys per @tree_depth to generate random values for @tree_depth: #int dict tree dimensions size, i.e. 1=|{key: value}| 2=|{key: {key: value}...
[ "def", "dict", "(", "self", ",", "key_depth", "=", "1000", ",", "tree_depth", "=", "1", ")", ":", "if", "not", "tree_depth", ":", "return", "self", ".", "_map_type", "(", ")", "return", "{", "self", ".", "randstr", ":", "self", ".", "dict", "(", "k...
Creates a random #dict @key_depth: #int number of keys per @tree_depth to generate random values for @tree_depth: #int dict tree dimensions size, i.e. 1=|{key: value}| 2=|{key: {key: value}, key2: {key2: value2}}| -> random #dict
[ "Creates", "a", "random", "#dict" ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L975-L990
train
jaredLunde/vital-tools
vital/debug/__init__.py
RandData.defaultdict
def defaultdict(self, key_depth=1000, tree_depth=1): """ Creates a random :class:collections.defaultdict @key_depth: #int number of keys per @tree_depth to generate random values for @tree_depth: #int dict tree dimensions size, i.e. 1=|{key: value}| ...
python
def defaultdict(self, key_depth=1000, tree_depth=1): """ Creates a random :class:collections.defaultdict @key_depth: #int number of keys per @tree_depth to generate random values for @tree_depth: #int dict tree dimensions size, i.e. 1=|{key: value}| ...
[ "def", "defaultdict", "(", "self", ",", "key_depth", "=", "1000", ",", "tree_depth", "=", "1", ")", ":", "if", "not", "tree_depth", ":", "return", "self", ".", "_map_type", "(", ")", "_dict", "=", "defaultdict", "(", ")", "_dict", ".", "update", "(", ...
Creates a random :class:collections.defaultdict @key_depth: #int number of keys per @tree_depth to generate random values for @tree_depth: #int dict tree dimensions size, i.e. 1=|{key: value}| 2=|{key: {key: value}, key2: {key2: value2}}| ...
[ "Creates", "a", "random", ":", "class", ":", "collections", ".", "defaultdict" ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L992-L1009
train
jaredLunde/vital-tools
vital/debug/__init__.py
RandData.tuple
def tuple(self, size=1000, tree_depth=1): """ Creates a random #tuple @size: #int number of random values to include in each @tree_depth @tree_depth: #int dict tree dimensions size, i.e. 1=|(value1, value2)| 2=|((value1, value2), (value1, value2))| ...
python
def tuple(self, size=1000, tree_depth=1): """ Creates a random #tuple @size: #int number of random values to include in each @tree_depth @tree_depth: #int dict tree dimensions size, i.e. 1=|(value1, value2)| 2=|((value1, value2), (value1, value2))| ...
[ "def", "tuple", "(", "self", ",", "size", "=", "1000", ",", "tree_depth", "=", "1", ")", ":", "if", "not", "tree_depth", ":", "return", "self", ".", "_map_type", "(", ")", "return", "tuple", "(", "self", ".", "tuple", "(", "size", ",", "tree_depth", ...
Creates a random #tuple @size: #int number of random values to include in each @tree_depth @tree_depth: #int dict tree dimensions size, i.e. 1=|(value1, value2)| 2=|((value1, value2), (value1, value2))| -> random #tuple
[ "Creates", "a", "random", "#tuple" ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1011-L1023
train
jaredLunde/vital-tools
vital/debug/__init__.py
RandData.generator
def generator(self, size=1000, tree_depth=1): """ Creates a random #generator @size: #int number of random values to include in each @tree_depth @tree_depth: #int dict tree dimensions size, i.e. 1=|(value1, value2)| 2=|((value1, value2), (value1, value2))...
python
def generator(self, size=1000, tree_depth=1): """ Creates a random #generator @size: #int number of random values to include in each @tree_depth @tree_depth: #int dict tree dimensions size, i.e. 1=|(value1, value2)| 2=|((value1, value2), (value1, value2))...
[ "def", "generator", "(", "self", ",", "size", "=", "1000", ",", "tree_depth", "=", "1", ")", ":", "if", "not", "tree_depth", ":", "return", "self", ".", "_map_type", "(", ")", "return", "(", "self", ".", "generator", "(", "size", ",", "tree_depth", "...
Creates a random #generator @size: #int number of random values to include in each @tree_depth @tree_depth: #int dict tree dimensions size, i.e. 1=|(value1, value2)| 2=|((value1, value2), (value1, value2))| -> random :class:collections.deque
[ "Creates", "a", "random", "#generator" ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1062-L1074
train
jaredLunde/vital-tools
vital/debug/__init__.py
RandData.sequence
def sequence(self, struct, size=1000, tree_depth=1, append_callable=None): """ Generates random values for sequence-like objects @struct: the sequence-like structure you want to fill with random data @size: #int number of random values to include in each @tree_depth ...
python
def sequence(self, struct, size=1000, tree_depth=1, append_callable=None): """ Generates random values for sequence-like objects @struct: the sequence-like structure you want to fill with random data @size: #int number of random values to include in each @tree_depth ...
[ "def", "sequence", "(", "self", ",", "struct", ",", "size", "=", "1000", ",", "tree_depth", "=", "1", ",", "append_callable", "=", "None", ")", ":", "if", "not", "tree_depth", ":", "return", "self", ".", "_map_type", "(", ")", "_struct", "=", "struct",...
Generates random values for sequence-like objects @struct: the sequence-like structure you want to fill with random data @size: #int number of random values to include in each @tree_depth @tree_depth: #int dict tree dimensions size, i.e. 1=|(value1, v...
[ "Generates", "random", "values", "for", "sequence", "-", "like", "objects" ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1076-L1111
train
jaredLunde/vital-tools
vital/debug/__init__.py
RandData.mapping
def mapping(self, struct, key_depth=1000, tree_depth=1, update_callable=None): """ Generates random values for dict-like objects @struct: the dict-like structure you want to fill with random data @size: #int number of random values to include in each @tree_depth ...
python
def mapping(self, struct, key_depth=1000, tree_depth=1, update_callable=None): """ Generates random values for dict-like objects @struct: the dict-like structure you want to fill with random data @size: #int number of random values to include in each @tree_depth ...
[ "def", "mapping", "(", "self", ",", "struct", ",", "key_depth", "=", "1000", ",", "tree_depth", "=", "1", ",", "update_callable", "=", "None", ")", ":", "if", "not", "tree_depth", ":", "return", "self", ".", "_map_type", "(", ")", "_struct", "=", "stru...
Generates random values for dict-like objects @struct: the dict-like structure you want to fill with random data @size: #int number of random values to include in each @tree_depth @tree_depth: #int dict tree dimensions size, i.e. 1=|{key: value}| 2=|{...
[ "Generates", "random", "values", "for", "dict", "-", "like", "objects" ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1113-L1153
train
jaredLunde/vital-tools
vital/debug/__init__.py
Look._dict_prefix
def _dict_prefix(self, key, value, i, dj=0, color=None, separator=":"): just = self._justify if i > 0 else dj key = cut(str(key), self._key_maxlen).rjust(just) key = colorize(key, color=color) pref = "{}{} {}".format(key, separator, value) """pref = "{}{} {}".format(colorize(str(...
python
def _dict_prefix(self, key, value, i, dj=0, color=None, separator=":"): just = self._justify if i > 0 else dj key = cut(str(key), self._key_maxlen).rjust(just) key = colorize(key, color=color) pref = "{}{} {}".format(key, separator, value) """pref = "{}{} {}".format(colorize(str(...
[ "def", "_dict_prefix", "(", "self", ",", "key", ",", "value", ",", "i", ",", "dj", "=", "0", ",", "color", "=", "None", ",", "separator", "=", "\":\"", ")", ":", "just", "=", "self", ".", "_justify", "if", "i", ">", "0", "else", "dj", "key", "=...
pref = "{}{} {}".format(colorize(str(key)[:self._key_maxlen]\ .rjust(just), color=color), separator, value)
[ "pref", "=", "{}", "{}", "{}", ".", "format", "(", "colorize", "(", "str", "(", "key", ")", "[", ":", "self", ".", "_key_maxlen", "]", "\\", ".", "rjust", "(", "just", ")", "color", "=", "color", ")", "separator", "value", ")" ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1208-L1215
train
jaredLunde/vital-tools
vital/debug/__init__.py
Look._format_numeric_sequence
def _format_numeric_sequence(self, _sequence, separator="."): """ Length of the highest index in chars = justification size """ if not _sequence: return colorize(_sequence, "purple") _sequence = _sequence if _sequence is not None else self.obj minus = (2 if self._depth > 0 el...
python
def _format_numeric_sequence(self, _sequence, separator="."): """ Length of the highest index in chars = justification size """ if not _sequence: return colorize(_sequence, "purple") _sequence = _sequence if _sequence is not None else self.obj minus = (2 if self._depth > 0 el...
[ "def", "_format_numeric_sequence", "(", "self", ",", "_sequence", ",", "separator", "=", "\".\"", ")", ":", "if", "not", "_sequence", ":", "return", "colorize", "(", "_sequence", ",", "\"purple\"", ")", "_sequence", "=", "_sequence", "if", "_sequence", "is", ...
Length of the highest index in chars = justification size
[ "Length", "of", "the", "highest", "index", "in", "chars", "=", "justification", "size" ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1238-L1256
train
jaredLunde/vital-tools
vital/debug/__init__.py
Look.objname
def objname(self, obj=None): """ Formats object names in a pretty fashion """ obj = obj or self.obj _objname = self.pretty_objname(obj, color=None) _objname = "'{}'".format(colorize(_objname, "blue")) return _objname
python
def objname(self, obj=None): """ Formats object names in a pretty fashion """ obj = obj or self.obj _objname = self.pretty_objname(obj, color=None) _objname = "'{}'".format(colorize(_objname, "blue")) return _objname
[ "def", "objname", "(", "self", ",", "obj", "=", "None", ")", ":", "obj", "=", "obj", "or", "self", ".", "obj", "_objname", "=", "self", ".", "pretty_objname", "(", "obj", ",", "color", "=", "None", ")", "_objname", "=", "\"'{}'\"", ".", "format", "...
Formats object names in a pretty fashion
[ "Formats", "object", "names", "in", "a", "pretty", "fashion" ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1347-L1352
train
jaredLunde/vital-tools
vital/debug/__init__.py
Look.pretty
def pretty(self, obj=None, display=True): """ Formats @obj or :prop:obj @obj: the object you'd like to prettify -> #str pretty object """ ret = self._format_obj(obj if obj is not None else self.obj) if display: print(ret) else: re...
python
def pretty(self, obj=None, display=True): """ Formats @obj or :prop:obj @obj: the object you'd like to prettify -> #str pretty object """ ret = self._format_obj(obj if obj is not None else self.obj) if display: print(ret) else: re...
[ "def", "pretty", "(", "self", ",", "obj", "=", "None", ",", "display", "=", "True", ")", ":", "ret", "=", "self", ".", "_format_obj", "(", "obj", "if", "obj", "is", "not", "None", "else", "self", ".", "obj", ")", "if", "display", ":", "print", "(...
Formats @obj or :prop:obj @obj: the object you'd like to prettify -> #str pretty object
[ "Formats", "@obj", "or", ":", "prop", ":", "obj" ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1354-L1365
train
jaredLunde/vital-tools
vital/debug/__init__.py
Look._format_obj
def _format_obj(self, item=None): """ Determines the type of the object and maps it to the correct formatter """ # Order here matters, odd behavior with tuples if item is None: return getattr(self, 'number')(item) elif isinstance(item, self.str_): ...
python
def _format_obj(self, item=None): """ Determines the type of the object and maps it to the correct formatter """ # Order here matters, odd behavior with tuples if item is None: return getattr(self, 'number')(item) elif isinstance(item, self.str_): ...
[ "def", "_format_obj", "(", "self", ",", "item", "=", "None", ")", ":", "# Order here matters, odd behavior with tuples", "if", "item", "is", "None", ":", "return", "getattr", "(", "self", ",", "'number'", ")", "(", "item", ")", "elif", "isinstance", "(", "it...
Determines the type of the object and maps it to the correct formatter
[ "Determines", "the", "type", "of", "the", "object", "and", "maps", "it", "to", "the", "correct", "formatter" ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1367-L1405
train
jaredLunde/vital-tools
vital/debug/__init__.py
Look.pretty_objname
def pretty_objname(self, obj=None, maxlen=50, color="boldcyan"): """ Pretty prints object name @obj: the object whose name you want to pretty print @maxlen: #int maximum length of an object name to print @color: your choice of :mod:colors or |None| -> #str prett...
python
def pretty_objname(self, obj=None, maxlen=50, color="boldcyan"): """ Pretty prints object name @obj: the object whose name you want to pretty print @maxlen: #int maximum length of an object name to print @color: your choice of :mod:colors or |None| -> #str prett...
[ "def", "pretty_objname", "(", "self", ",", "obj", "=", "None", ",", "maxlen", "=", "50", ",", "color", "=", "\"boldcyan\"", ")", ":", "parent_name", "=", "lambda_sub", "(", "\"\"", ",", "get_parent_name", "(", "obj", ")", "or", "\"\"", ")", "objname", ...
Pretty prints object name @obj: the object whose name you want to pretty print @maxlen: #int maximum length of an object name to print @color: your choice of :mod:colors or |None| -> #str pretty object name .. from vital.debug import Look ...
[ "Pretty", "prints", "object", "name" ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1408-L1432
train
jaredLunde/vital-tools
vital/debug/__init__.py
Logg.set_level
def set_level(self, level): """ Sets :attr:loglevel to @level @level: #str one or several :attr:levels """ if not level: return None self.levelmap = set() for char in level: self.levelmap = self.levelmap.union(self.levels[char]) self.l...
python
def set_level(self, level): """ Sets :attr:loglevel to @level @level: #str one or several :attr:levels """ if not level: return None self.levelmap = set() for char in level: self.levelmap = self.levelmap.union(self.levels[char]) self.l...
[ "def", "set_level", "(", "self", ",", "level", ")", ":", "if", "not", "level", ":", "return", "None", "self", ".", "levelmap", "=", "set", "(", ")", "for", "char", "in", "level", ":", "self", ".", "levelmap", "=", "self", ".", "levelmap", ".", "uni...
Sets :attr:loglevel to @level @level: #str one or several :attr:levels
[ "Sets", ":", "attr", ":", "loglevel", "to", "@level" ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1567-L1578
train
jaredLunde/vital-tools
vital/debug/__init__.py
Logg.log
def log(self, flag_message=None, padding=None, color=None, force=False): """ Log Level: :attr:LOG @flag_message: #str flags the message with the given text using :func:flag @padding: #str 'top', 'bottom' or 'all', adds a new line to the specified area wit...
python
def log(self, flag_message=None, padding=None, color=None, force=False): """ Log Level: :attr:LOG @flag_message: #str flags the message with the given text using :func:flag @padding: #str 'top', 'bottom' or 'all', adds a new line to the specified area wit...
[ "def", "log", "(", "self", ",", "flag_message", "=", "None", ",", "padding", "=", "None", ",", "color", "=", "None", ",", "force", "=", "False", ")", ":", "if", "self", ".", "should_log", "(", "self", ".", "LOG", ")", "or", "force", ":", "self", ...
Log Level: :attr:LOG @flag_message: #str flags the message with the given text using :func:flag @padding: #str 'top', 'bottom' or 'all', adds a new line to the specified area with :func:padd @color: #str colorizes @flag_message using :func:colorize ...
[ "Log", "Level", ":", ":", "attr", ":", "LOG" ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1588-L1613
train
jaredLunde/vital-tools
vital/debug/__init__.py
Logg.success
def success(self, flag_message="Success", padding=None, force=False): """ Log Level: :attr:SUCCESS @flag_message: #str flags the message with the given text using :func:flag @padding: #str 'top', 'bottom' or 'all', adds a new line to the specified area wi...
python
def success(self, flag_message="Success", padding=None, force=False): """ Log Level: :attr:SUCCESS @flag_message: #str flags the message with the given text using :func:flag @padding: #str 'top', 'bottom' or 'all', adds a new line to the specified area wi...
[ "def", "success", "(", "self", ",", "flag_message", "=", "\"Success\"", ",", "padding", "=", "None", ",", "force", "=", "False", ")", ":", "if", "self", ".", "should_log", "(", "self", ".", "SUCCESS", ")", "or", "force", ":", "self", ".", "_print_messa...
Log Level: :attr:SUCCESS @flag_message: #str flags the message with the given text using :func:flag @padding: #str 'top', 'bottom' or 'all', adds a new line to the specified area with :func:padd @color: #str colorizes @flag_message using :func:coloriz...
[ "Log", "Level", ":", ":", "attr", ":", "SUCCESS" ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L1615-L1640
train