repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
isogeo/isogeo-api-py-minsdk
isogeo_pysdk/utils.py
IsogeoUtils.set_base_url
def set_base_url(self, platform: str = "prod"): """Set Isogeo base URLs according to platform. :param str platform: platform to use. Options: * prod [DEFAULT] * qa * int """ platform = platform.lower() self.platform = platform if platform =...
python
def set_base_url(self, platform: str = "prod"): """Set Isogeo base URLs according to platform. :param str platform: platform to use. Options: * prod [DEFAULT] * qa * int """ platform = platform.lower() self.platform = platform if platform =...
[ "def", "set_base_url", "(", "self", ",", "platform", ":", "str", "=", "\"prod\"", ")", ":", "platform", "=", "platform", ".", "lower", "(", ")", "self", ".", "platform", "=", "platform", "if", "platform", "==", "\"prod\"", ":", "ssl", "=", "True", "log...
Set Isogeo base URLs according to platform. :param str platform: platform to use. Options: * prod [DEFAULT] * qa * int
[ "Set", "Isogeo", "base", "URLs", "according", "to", "platform", "." ]
train
https://github.com/isogeo/isogeo-api-py-minsdk/blob/57a604be92c7767b26abd247012cc1a584b386a0/isogeo_pysdk/utils.py#L121-L155
isogeo/isogeo-api-py-minsdk
isogeo_pysdk/utils.py
IsogeoUtils.convert_uuid
def convert_uuid(self, in_uuid: str = str, mode: bool = 0): """Convert a metadata UUID to its URI equivalent. And conversely. :param str in_uuid: UUID or URI to convert :param int mode: conversion direction. Options: * 0 to HEX * 1 to URN (RFC4122) * 2 to URN (Iso...
python
def convert_uuid(self, in_uuid: str = str, mode: bool = 0): """Convert a metadata UUID to its URI equivalent. And conversely. :param str in_uuid: UUID or URI to convert :param int mode: conversion direction. Options: * 0 to HEX * 1 to URN (RFC4122) * 2 to URN (Iso...
[ "def", "convert_uuid", "(", "self", ",", "in_uuid", ":", "str", "=", "str", ",", "mode", ":", "bool", "=", "0", ")", ":", "# parameters check", "if", "not", "isinstance", "(", "in_uuid", ",", "str", ")", ":", "raise", "TypeError", "(", "\"'in_uuid' expec...
Convert a metadata UUID to its URI equivalent. And conversely. :param str in_uuid: UUID or URI to convert :param int mode: conversion direction. Options: * 0 to HEX * 1 to URN (RFC4122) * 2 to URN (Isogeo specific style)
[ "Convert", "a", "metadata", "UUID", "to", "its", "URI", "equivalent", ".", "And", "conversely", "." ]
train
https://github.com/isogeo/isogeo-api-py-minsdk/blob/57a604be92c7767b26abd247012cc1a584b386a0/isogeo_pysdk/utils.py#L157-L196
isogeo/isogeo-api-py-minsdk
isogeo_pysdk/utils.py
IsogeoUtils.encoded_words_to_text
def encoded_words_to_text(self, in_encoded_words: str): """Pull out the character set, encoding, and encoded text from the input encoded words. Next, it decodes the encoded words into a byte string, using either the quopri module or base64 module as determined by the encoding. Finally, i...
python
def encoded_words_to_text(self, in_encoded_words: str): """Pull out the character set, encoding, and encoded text from the input encoded words. Next, it decodes the encoded words into a byte string, using either the quopri module or base64 module as determined by the encoding. Finally, i...
[ "def", "encoded_words_to_text", "(", "self", ",", "in_encoded_words", ":", "str", ")", ":", "# handle RFC2047 quoting", "if", "'\"'", "in", "in_encoded_words", ":", "in_encoded_words", "=", "in_encoded_words", ".", "strip", "(", "'\"'", ")", "# regex", "encoded_word...
Pull out the character set, encoding, and encoded text from the input encoded words. Next, it decodes the encoded words into a byte string, using either the quopri module or base64 module as determined by the encoding. Finally, it decodes the byte string using the character set and retur...
[ "Pull", "out", "the", "character", "set", "encoding", "and", "encoded", "text", "from", "the", "input", "encoded", "words", ".", "Next", "it", "decodes", "the", "encoded", "words", "into", "a", "byte", "string", "using", "either", "the", "quopri", "module", ...
train
https://github.com/isogeo/isogeo-api-py-minsdk/blob/57a604be92c7767b26abd247012cc1a584b386a0/isogeo_pysdk/utils.py#L198-L231
isogeo/isogeo-api-py-minsdk
isogeo_pysdk/utils.py
IsogeoUtils.get_isogeo_version
def get_isogeo_version(self, component: str = "api", prot: str = "https"): """Get Isogeo components versions. Authentication not required. :param str component: which platform component. Options: * api [default] * db * app """ # which component if...
python
def get_isogeo_version(self, component: str = "api", prot: str = "https"): """Get Isogeo components versions. Authentication not required. :param str component: which platform component. Options: * api [default] * db * app """ # which component if...
[ "def", "get_isogeo_version", "(", "self", ",", "component", ":", "str", "=", "\"api\"", ",", "prot", ":", "str", "=", "\"https\"", ")", ":", "# which component", "if", "component", "==", "\"api\"", ":", "version_url", "=", "\"{}://v1.{}.isogeo.com/about\"", ".",...
Get Isogeo components versions. Authentication not required. :param str component: which platform component. Options: * api [default] * db * app
[ "Get", "Isogeo", "components", "versions", ".", "Authentication", "not", "required", "." ]
train
https://github.com/isogeo/isogeo-api-py-minsdk/blob/57a604be92c7767b26abd247012cc1a584b386a0/isogeo_pysdk/utils.py#L233-L266
isogeo/isogeo-api-py-minsdk
isogeo_pysdk/utils.py
IsogeoUtils.get_edit_url
def get_edit_url( self, md_id: str = None, md_type: str = None, owner_id: str = None, tab: str = "identification", ): """Constructs the edition URL of a metadata. :param str md_id: metadata/resource UUID :param str owner_id: owner UUID :param ...
python
def get_edit_url( self, md_id: str = None, md_type: str = None, owner_id: str = None, tab: str = "identification", ): """Constructs the edition URL of a metadata. :param str md_id: metadata/resource UUID :param str owner_id: owner UUID :param ...
[ "def", "get_edit_url", "(", "self", ",", "md_id", ":", "str", "=", "None", ",", "md_type", ":", "str", "=", "None", ",", "owner_id", ":", "str", "=", "None", ",", "tab", ":", "str", "=", "\"identification\"", ",", ")", ":", "# checks inputs", "if", "...
Constructs the edition URL of a metadata. :param str md_id: metadata/resource UUID :param str owner_id: owner UUID :param str tab: target tab in the web form
[ "Constructs", "the", "edition", "URL", "of", "a", "metadata", "." ]
train
https://github.com/isogeo/isogeo-api-py-minsdk/blob/57a604be92c7767b26abd247012cc1a584b386a0/isogeo_pysdk/utils.py#L269-L295
isogeo/isogeo-api-py-minsdk
isogeo_pysdk/utils.py
IsogeoUtils.get_view_url
def get_view_url(self, webapp: str = "oc", **kwargs): """Constructs the view URL of a metadata. :param str webapp: web app destination :param dict kwargs: web app specific parameters. For example see WEBAPPS """ # build wbeapp URL depending on choosen webapp if webapp in...
python
def get_view_url(self, webapp: str = "oc", **kwargs): """Constructs the view URL of a metadata. :param str webapp: web app destination :param dict kwargs: web app specific parameters. For example see WEBAPPS """ # build wbeapp URL depending on choosen webapp if webapp in...
[ "def", "get_view_url", "(", "self", ",", "webapp", ":", "str", "=", "\"oc\"", ",", "*", "*", "kwargs", ")", ":", "# build wbeapp URL depending on choosen webapp", "if", "webapp", "in", "self", ".", "WEBAPPS", ":", "webapp_args", "=", "self", ".", "WEBAPPS", ...
Constructs the view URL of a metadata. :param str webapp: web app destination :param dict kwargs: web app specific parameters. For example see WEBAPPS
[ "Constructs", "the", "view", "URL", "of", "a", "metadata", "." ]
train
https://github.com/isogeo/isogeo-api-py-minsdk/blob/57a604be92c7767b26abd247012cc1a584b386a0/isogeo_pysdk/utils.py#L297-L323
isogeo/isogeo-api-py-minsdk
isogeo_pysdk/utils.py
IsogeoUtils.register_webapp
def register_webapp(self, webapp_name: str, webapp_args: list, webapp_url: str): """Register a new WEBAPP to use with the view URL builder. :param str webapp_name: name of the web app to register :param list webapp_args: dynamic arguments to complete the URL. Typically 'md_id'. ...
python
def register_webapp(self, webapp_name: str, webapp_args: list, webapp_url: str): """Register a new WEBAPP to use with the view URL builder. :param str webapp_name: name of the web app to register :param list webapp_args: dynamic arguments to complete the URL. Typically 'md_id'. ...
[ "def", "register_webapp", "(", "self", ",", "webapp_name", ":", "str", ",", "webapp_args", ":", "list", ",", "webapp_url", ":", "str", ")", ":", "# check parameters", "for", "arg", "in", "webapp_args", ":", "if", "arg", "not", "in", "webapp_url", ":", "rai...
Register a new WEBAPP to use with the view URL builder. :param str webapp_name: name of the web app to register :param list webapp_args: dynamic arguments to complete the URL. Typically 'md_id'. :param str webapp_url: URL of the web app to register with args tags to replace. E...
[ "Register", "a", "new", "WEBAPP", "to", "use", "with", "the", "view", "URL", "builder", "." ]
train
https://github.com/isogeo/isogeo-api-py-minsdk/blob/57a604be92c7767b26abd247012cc1a584b386a0/isogeo_pysdk/utils.py#L325-L345
isogeo/isogeo-api-py-minsdk
isogeo_pysdk/utils.py
IsogeoUtils.get_url_base_from_url_token
def get_url_base_from_url_token( self, url_api_token: str = "https://id.api.isogeo.com/oauth/token" ): """Returns the Isogeo API root URL (which is not included into credentials file) from the token URL (which is always included). :param url_api_token str: url to Isogeo API ID token...
python
def get_url_base_from_url_token( self, url_api_token: str = "https://id.api.isogeo.com/oauth/token" ): """Returns the Isogeo API root URL (which is not included into credentials file) from the token URL (which is always included). :param url_api_token str: url to Isogeo API ID token...
[ "def", "get_url_base_from_url_token", "(", "self", ",", "url_api_token", ":", "str", "=", "\"https://id.api.isogeo.com/oauth/token\"", ")", ":", "in_parsed", "=", "urlparse", "(", "url_api_token", ")", "api_url_base", "=", "in_parsed", ".", "_replace", "(", "path", ...
Returns the Isogeo API root URL (which is not included into credentials file) from the token URL (which is always included). :param url_api_token str: url to Isogeo API ID token generator
[ "Returns", "the", "Isogeo", "API", "root", "URL", "(", "which", "is", "not", "included", "into", "credentials", "file", ")", "from", "the", "token", "URL", "(", "which", "is", "always", "included", ")", "." ]
train
https://github.com/isogeo/isogeo-api-py-minsdk/blob/57a604be92c7767b26abd247012cc1a584b386a0/isogeo_pysdk/utils.py#L347-L359
isogeo/isogeo-api-py-minsdk
isogeo_pysdk/utils.py
IsogeoUtils.pages_counter
def pages_counter(self, total: int, page_size: int = 100) -> int: """Simple helper to handle pagination. Returns the number of pages for a given number of results. :param int total: count of metadata in a search request :param int page_size: count of metadata to display in each page ...
python
def pages_counter(self, total: int, page_size: int = 100) -> int: """Simple helper to handle pagination. Returns the number of pages for a given number of results. :param int total: count of metadata in a search request :param int page_size: count of metadata to display in each page ...
[ "def", "pages_counter", "(", "self", ",", "total", ":", "int", ",", "page_size", ":", "int", "=", "100", ")", "->", "int", ":", "if", "total", "<=", "page_size", ":", "count_pages", "=", "1", "else", ":", "if", "(", "total", "%", "page_size", ")", ...
Simple helper to handle pagination. Returns the number of pages for a given number of results. :param int total: count of metadata in a search request :param int page_size: count of metadata to display in each page
[ "Simple", "helper", "to", "handle", "pagination", ".", "Returns", "the", "number", "of", "pages", "for", "a", "given", "number", "of", "results", "." ]
train
https://github.com/isogeo/isogeo-api-py-minsdk/blob/57a604be92c7767b26abd247012cc1a584b386a0/isogeo_pysdk/utils.py#L362-L377
isogeo/isogeo-api-py-minsdk
isogeo_pysdk/utils.py
IsogeoUtils.tags_to_dict
def tags_to_dict(self, tags=dict, prev_query=dict, duplicated: str = "rename"): """Reverse search tags dictionary to values as keys. Useful to populate filters comboboxes for example. :param dict tags: tags dictionary from a search request :param dict prev_query: query parameters return...
python
def tags_to_dict(self, tags=dict, prev_query=dict, duplicated: str = "rename"): """Reverse search tags dictionary to values as keys. Useful to populate filters comboboxes for example. :param dict tags: tags dictionary from a search request :param dict prev_query: query parameters return...
[ "def", "tags_to_dict", "(", "self", ",", "tags", "=", "dict", ",", "prev_query", "=", "dict", ",", "duplicated", ":", "str", "=", "\"rename\"", ")", ":", "# for rename option, get workgroups", "if", "duplicated", "==", "\"rename\"", ":", "wgs", "=", "{", "k"...
Reverse search tags dictionary to values as keys. Useful to populate filters comboboxes for example. :param dict tags: tags dictionary from a search request :param dict prev_query: query parameters returned after a search request. Typically `search.get("query")`. :param str duplicated: ...
[ "Reverse", "search", "tags", "dictionary", "to", "values", "as", "keys", ".", "Useful", "to", "populate", "filters", "comboboxes", "for", "example", "." ]
train
https://github.com/isogeo/isogeo-api-py-minsdk/blob/57a604be92c7767b26abd247012cc1a584b386a0/isogeo_pysdk/utils.py#L379-L634
isogeo/isogeo-api-py-minsdk
isogeo_pysdk/utils.py
IsogeoUtils.share_extender
def share_extender(self, share: dict, results_filtered: dict): """Extend share model with additional informations. :param dict share: share returned by API :param dict results_filtered: filtered search result """ # add share administration URL creator_id = share.get("_cr...
python
def share_extender(self, share: dict, results_filtered: dict): """Extend share model with additional informations. :param dict share: share returned by API :param dict results_filtered: filtered search result """ # add share administration URL creator_id = share.get("_cr...
[ "def", "share_extender", "(", "self", ",", "share", ":", "dict", ",", "results_filtered", ":", "dict", ")", ":", "# add share administration URL", "creator_id", "=", "share", ".", "get", "(", "\"_creator\"", ")", ".", "get", "(", "\"_tag\"", ")", "[", "6", ...
Extend share model with additional informations. :param dict share: share returned by API :param dict results_filtered: filtered search result
[ "Extend", "share", "model", "with", "additional", "informations", "." ]
train
https://github.com/isogeo/isogeo-api-py-minsdk/blob/57a604be92c7767b26abd247012cc1a584b386a0/isogeo_pysdk/utils.py#L637-L659
isogeo/isogeo-api-py-minsdk
isogeo_pysdk/utils.py
IsogeoUtils.credentials_loader
def credentials_loader(self, in_credentials: str = "client_secrets.json") -> dict: """Loads API credentials from a file, JSON or INI. :param str in_credentials: path to the credentials file. By default, look for a client_secrets.json file. """ accepted_extensions = (".ini", "....
python
def credentials_loader(self, in_credentials: str = "client_secrets.json") -> dict: """Loads API credentials from a file, JSON or INI. :param str in_credentials: path to the credentials file. By default, look for a client_secrets.json file. """ accepted_extensions = (".ini", "....
[ "def", "credentials_loader", "(", "self", ",", "in_credentials", ":", "str", "=", "\"client_secrets.json\"", ")", "->", "dict", ":", "accepted_extensions", "=", "(", "\".ini\"", ",", "\".json\"", ")", "# checks", "if", "not", "path", ".", "isfile", "(", "in_cr...
Loads API credentials from a file, JSON or INI. :param str in_credentials: path to the credentials file. By default, look for a client_secrets.json file.
[ "Loads", "API", "credentials", "from", "a", "file", "JSON", "or", "INI", "." ]
train
https://github.com/isogeo/isogeo-api-py-minsdk/blob/57a604be92c7767b26abd247012cc1a584b386a0/isogeo_pysdk/utils.py#L662-L751
novopl/peltak
src/peltak/extra/pypi/commands.py
configure
def configure(username, password): # type: (str, str) -> None """ Generate .pypirc config with the given credentials. Example: $ peltak pypi configure my_pypi_user my_pypi_pass """ from peltak.extra.pypi import logic logic.gen_pypirc(username, password)
python
def configure(username, password): # type: (str, str) -> None """ Generate .pypirc config with the given credentials. Example: $ peltak pypi configure my_pypi_user my_pypi_pass """ from peltak.extra.pypi import logic logic.gen_pypirc(username, password)
[ "def", "configure", "(", "username", ",", "password", ")", ":", "# type: (str, str) -> None", "from", "peltak", ".", "extra", ".", "pypi", "import", "logic", "logic", ".", "gen_pypirc", "(", "username", ",", "password", ")" ]
Generate .pypirc config with the given credentials. Example: $ peltak pypi configure my_pypi_user my_pypi_pass
[ "Generate", ".", "pypirc", "config", "with", "the", "given", "credentials", "." ]
train
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/extra/pypi/commands.py#L58-L69
isogeo/isogeo-api-py-minsdk
isogeo_pysdk/translator.py
IsogeoTranslator.tr
def tr(self, subdomain: str, string_to_translate: str = "") -> str: """Returns translation of string passed. :param str subdomain: subpart of strings dictionary. Must be one of self.translations.keys() i.e. 'restrictions' :param str string_to_translate: string you want to translate ...
python
def tr(self, subdomain: str, string_to_translate: str = "") -> str: """Returns translation of string passed. :param str subdomain: subpart of strings dictionary. Must be one of self.translations.keys() i.e. 'restrictions' :param str string_to_translate: string you want to translate ...
[ "def", "tr", "(", "self", ",", "subdomain", ":", "str", ",", "string_to_translate", ":", "str", "=", "\"\"", ")", "->", "str", ":", "if", "subdomain", "not", "in", "self", ".", "translations", ".", "keys", "(", ")", ":", "raise", "ValueError", "(", "...
Returns translation of string passed. :param str subdomain: subpart of strings dictionary. Must be one of self.translations.keys() i.e. 'restrictions' :param str string_to_translate: string you want to translate
[ "Returns", "translation", "of", "string", "passed", "." ]
train
https://github.com/isogeo/isogeo-api-py-minsdk/blob/57a604be92c7767b26abd247012cc1a584b386a0/isogeo_pysdk/translator.py#L197-L217
praekeltfoundation/seed-identity-store
identities/models.py
optout_saved
def optout_saved(sender, instance, **kwargs): """ This is a duplicte of the view code for DRF to stop future internal Django implementations breaking. """ if instance.identity is None: # look up using the address_type and address identities = Identity.objects.filter_by_addr( ...
python
def optout_saved(sender, instance, **kwargs): """ This is a duplicte of the view code for DRF to stop future internal Django implementations breaking. """ if instance.identity is None: # look up using the address_type and address identities = Identity.objects.filter_by_addr( ...
[ "def", "optout_saved", "(", "sender", ",", "instance", ",", "*", "*", "kwargs", ")", ":", "if", "instance", ".", "identity", "is", "None", ":", "# look up using the address_type and address", "identities", "=", "Identity", ".", "objects", ".", "filter_by_addr", ...
This is a duplicte of the view code for DRF to stop future internal Django implementations breaking.
[ "This", "is", "a", "duplicte", "of", "the", "view", "code", "for", "DRF", "to", "stop", "future", "internal", "Django", "implementations", "breaking", "." ]
train
https://github.com/praekeltfoundation/seed-identity-store/blob/194e5756b5a74ebce9798c390de958cf5305b105/identities/models.py#L397-L408
cons3rt/pycons3rt
pycons3rt/awsapi/ec2util.py
get_ec2_client
def get_ec2_client(region_name=None, aws_access_key_id=None, aws_secret_access_key=None): """Gets an EC2 client :return: boto3.client object :raises: AWSAPIError """ log = logging.getLogger(mod_logger + '.get_ec2_client') # Connect to EC2 API try: client = boto3.client('ec2', region...
python
def get_ec2_client(region_name=None, aws_access_key_id=None, aws_secret_access_key=None): """Gets an EC2 client :return: boto3.client object :raises: AWSAPIError """ log = logging.getLogger(mod_logger + '.get_ec2_client') # Connect to EC2 API try: client = boto3.client('ec2', region...
[ "def", "get_ec2_client", "(", "region_name", "=", "None", ",", "aws_access_key_id", "=", "None", ",", "aws_secret_access_key", "=", "None", ")", ":", "log", "=", "logging", ".", "getLogger", "(", "mod_logger", "+", "'.get_ec2_client'", ")", "# Connect to EC2 API",...
Gets an EC2 client :return: boto3.client object :raises: AWSAPIError
[ "Gets", "an", "EC2", "client" ]
train
https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/ec2util.py#L954-L973
cons3rt/pycons3rt
pycons3rt/awsapi/ec2util.py
EC2Util.get_vpc_id
def get_vpc_id(self): """Gets the VPC ID for this EC2 instance :return: String instance ID or None """ log = logging.getLogger(self.cls_logger + '.get_vpc_id') # Exit if not running on AWS if not self.is_aws: log.info('This machine is not running in AWS, exi...
python
def get_vpc_id(self): """Gets the VPC ID for this EC2 instance :return: String instance ID or None """ log = logging.getLogger(self.cls_logger + '.get_vpc_id') # Exit if not running on AWS if not self.is_aws: log.info('This machine is not running in AWS, exi...
[ "def", "get_vpc_id", "(", "self", ")", ":", "log", "=", "logging", ".", "getLogger", "(", "self", ".", "cls_logger", "+", "'.get_vpc_id'", ")", "# Exit if not running on AWS", "if", "not", "self", ".", "is_aws", ":", "log", ".", "info", "(", "'This machine i...
Gets the VPC ID for this EC2 instance :return: String instance ID or None
[ "Gets", "the", "VPC", "ID", "for", "this", "EC2", "instance" ]
train
https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/ec2util.py#L73-L107
cons3rt/pycons3rt
pycons3rt/awsapi/ec2util.py
EC2Util.get_eni_id
def get_eni_id(self, interface=1): """Given an interface number, gets the AWS elastic network interface associated with the interface. :param interface: Integer associated to the interface/device number :return: String Elastic Network Interface ID or None if not found :raises OS...
python
def get_eni_id(self, interface=1): """Given an interface number, gets the AWS elastic network interface associated with the interface. :param interface: Integer associated to the interface/device number :return: String Elastic Network Interface ID or None if not found :raises OS...
[ "def", "get_eni_id", "(", "self", ",", "interface", "=", "1", ")", ":", "log", "=", "logging", ".", "getLogger", "(", "self", ".", "cls_logger", "+", "'.get_eni_id'", ")", "# Get the instance-id", "if", "self", ".", "instance_id", "is", "None", ":", "msg",...
Given an interface number, gets the AWS elastic network interface associated with the interface. :param interface: Integer associated to the interface/device number :return: String Elastic Network Interface ID or None if not found :raises OSError, AWSAPIError, EC2UtilError
[ "Given", "an", "interface", "number", "gets", "the", "AWS", "elastic", "network", "interface", "associated", "with", "the", "interface", "." ]
train
https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/ec2util.py#L109-L156
cons3rt/pycons3rt
pycons3rt/awsapi/ec2util.py
EC2Util.add_secondary_ip
def add_secondary_ip(self, ip_address, interface=1): """Adds an IP address as a secondary IP address :param ip_address: String IP address to add as a secondary IP :param interface: Integer associated to the interface/device number :return: None :raises: AWSAPIError, EC2UtilError...
python
def add_secondary_ip(self, ip_address, interface=1): """Adds an IP address as a secondary IP address :param ip_address: String IP address to add as a secondary IP :param interface: Integer associated to the interface/device number :return: None :raises: AWSAPIError, EC2UtilError...
[ "def", "add_secondary_ip", "(", "self", ",", "ip_address", ",", "interface", "=", "1", ")", ":", "log", "=", "logging", ".", "getLogger", "(", "self", ".", "cls_logger", "+", "'.add_secondary_ip'", ")", "# Get the ENI ID", "eni_id", "=", "self", ".", "get_en...
Adds an IP address as a secondary IP address :param ip_address: String IP address to add as a secondary IP :param interface: Integer associated to the interface/device number :return: None :raises: AWSAPIError, EC2UtilError
[ "Adds", "an", "IP", "address", "as", "a", "secondary", "IP", "address" ]
train
https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/ec2util.py#L158-L196
cons3rt/pycons3rt
pycons3rt/awsapi/ec2util.py
EC2Util.associate_elastic_ip
def associate_elastic_ip(self, allocation_id, interface=1, private_ip=None): """Given an elastic IP address and an interface number, associates the elastic IP to the interface number on this host. :param allocation_id: String ID for the elastic IP :param interface: Integer associated to...
python
def associate_elastic_ip(self, allocation_id, interface=1, private_ip=None): """Given an elastic IP address and an interface number, associates the elastic IP to the interface number on this host. :param allocation_id: String ID for the elastic IP :param interface: Integer associated to...
[ "def", "associate_elastic_ip", "(", "self", ",", "allocation_id", ",", "interface", "=", "1", ",", "private_ip", "=", "None", ")", ":", "log", "=", "logging", ".", "getLogger", "(", "self", ".", "cls_logger", "+", "'.associate_elastic_ip'", ")", "if", "priva...
Given an elastic IP address and an interface number, associates the elastic IP to the interface number on this host. :param allocation_id: String ID for the elastic IP :param interface: Integer associated to the interface/device number :param private_ip: String IP address of the private...
[ "Given", "an", "elastic", "IP", "address", "and", "an", "interface", "number", "associates", "the", "elastic", "IP", "to", "the", "interface", "number", "on", "this", "host", "." ]
train
https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/ec2util.py#L198-L254
cons3rt/pycons3rt
pycons3rt/awsapi/ec2util.py
EC2Util.allocate_elastic_ip
def allocate_elastic_ip(self): """Allocates an elastic IP address :return: Dict with allocation ID and Public IP that were created :raises: AWSAPIError, EC2UtilError """ log = logging.getLogger(self.cls_logger + '.allocate_elastic_ip') # Attempt to allocate a new elasti...
python
def allocate_elastic_ip(self): """Allocates an elastic IP address :return: Dict with allocation ID and Public IP that were created :raises: AWSAPIError, EC2UtilError """ log = logging.getLogger(self.cls_logger + '.allocate_elastic_ip') # Attempt to allocate a new elasti...
[ "def", "allocate_elastic_ip", "(", "self", ")", ":", "log", "=", "logging", ".", "getLogger", "(", "self", ".", "cls_logger", "+", "'.allocate_elastic_ip'", ")", "# Attempt to allocate a new elastic IP", "log", ".", "info", "(", "'Attempting to allocate an elastic IP......
Allocates an elastic IP address :return: Dict with allocation ID and Public IP that were created :raises: AWSAPIError, EC2UtilError
[ "Allocates", "an", "elastic", "IP", "address" ]
train
https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/ec2util.py#L256-L311
cons3rt/pycons3rt
pycons3rt/awsapi/ec2util.py
EC2Util.attach_new_eni
def attach_new_eni(self, subnet_name, security_group_ids, device_index=2, allocation_id=None, description=''): """Creates a new Elastic Network Interface on the Subnet matching the subnet_name, with Security Group identified by the security_group_name, then attaches an Elastic IP address ...
python
def attach_new_eni(self, subnet_name, security_group_ids, device_index=2, allocation_id=None, description=''): """Creates a new Elastic Network Interface on the Subnet matching the subnet_name, with Security Group identified by the security_group_name, then attaches an Elastic IP address ...
[ "def", "attach_new_eni", "(", "self", ",", "subnet_name", ",", "security_group_ids", ",", "device_index", "=", "2", ",", "allocation_id", "=", "None", ",", "description", "=", "''", ")", ":", "log", "=", "logging", ".", "getLogger", "(", "self", ".", "cls_...
Creates a new Elastic Network Interface on the Subnet matching the subnet_name, with Security Group identified by the security_group_name, then attaches an Elastic IP address if specified in the allocation_id parameter, and finally attaches the new ENI to the EC2 instance instance_id at ...
[ "Creates", "a", "new", "Elastic", "Network", "Interface", "on", "the", "Subnet", "matching", "the", "subnet_name", "with", "Security", "Group", "identified", "by", "the", "security_group_name", "then", "attaches", "an", "Elastic", "IP", "address", "if", "specified...
train
https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/ec2util.py#L313-L489
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" ]
train
https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/ec2util.py#L491-L546
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" ]
train
https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/ec2util.py#L548-L584
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" ]
train
https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/ec2util.py#L586-L667
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" ]
train
https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/ec2util.py#L669-L701
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", "." ]
train
https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/ec2util.py#L703-L810
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" ]
train
https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/ec2util.py#L812-L832
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", "." ]
train
https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/ec2util.py#L834-L903
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" ]
train
https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/ec2util.py#L905-L919
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", "." ]
train
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/commands/docs.py#L52-L88
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", "." ]
train
https://github.com/Josef-Friedrich/phrydy/blob/aa13755155977b4776e49f79984f9968ac1d74dc/phrydy/utils.py#L23-L39
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",...
train
https://github.com/Josef-Friedrich/phrydy/blob/aa13755155977b4776e49f79984f9968ac1d74dc/phrydy/utils.py#L42-L58
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"...
train
https://github.com/Josef-Friedrich/phrydy/blob/aa13755155977b4776e49f79984f9968ac1d74dc/phrydy/utils.py#L61-L92
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", "." ]
train
https://github.com/cfobel/pygtk3-helpers/blob/ae793cb34a5c1bbe40cc83bb8a6084f0eeed2519/pygtk3_helpers/ui/notebook.py#L52-L94
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", ...
train
https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/management/commands/bank_const_se.py#L11-L68
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", ...
train
https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/admin.py#L15-L55
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",...
train
https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/admin.py#L65-L73
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", "." ]
train
https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/admin.py#L75-L120
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...
train
https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/admin.py#L148-L161
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", "()" ]
train
https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/admin.py#L170-L181
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" ]
train
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/versioning.py#L76-L83
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", "." ]
train
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/versioning.py#L86-L113
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", "." ]
train
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/versioning.py#L116-L164
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", "." ]
train
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/versioning.py#L291-L303
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", "." ]
train
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/versioning.py#L220-L233
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", "." ]
train
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/versioning.py#L235-L248
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", "." ]
train
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/core/versioning.py#L253-L266
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", "." ]
train
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L945-L949
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", ")" ]
train
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L954-L972
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", "=...
train
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L977-L997
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...
train
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L1001-L1074
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", ")", "-", ...
train
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L173-L311
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...
train
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L343-L369
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", ")", "." ]
train
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L375-L388
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"...
train
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L391-L423
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", ...
train
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L426-L557
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...
train
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L559-L594
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...
train
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L598-L617
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", "." ]
train
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L626-L631
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...
train
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L633-L654
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", "." ]
train
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L656-L663
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", "." ]
train
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L665-L668
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", "." ]
train
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L670-L673
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", ...
train
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L675-L685
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" ]
train
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L688-L705
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", ...
train
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L708-L720
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", "." ]
train
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L722-L726
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", "!" ]
train
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L729-L741
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", ...
train
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L744-L765
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", "()", "." ]
train
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L769-L789
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", "." ]
train
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L816-L837
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", "." ]
train
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L841-L861
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", "." ]
train
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L865-L883
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"...
train
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L886-L925
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", "!" ]
train
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Astro_Libraries/f2n.py#L928-L937
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", "." ]
train
https://github.com/bitesofcode/pyramid_restful/blob/0f1eccb2c61b9bd6add03b461d4e4d7901c957da/pyramid_restful/api.py#L67-L87
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", "." ]
train
https://github.com/bitesofcode/pyramid_restful/blob/0f1eccb2c61b9bd6add03b461d4e4d7901c957da/pyramid_restful/api.py#L89-L132
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", "." ]
train
https://github.com/bitesofcode/pyramid_restful/blob/0f1eccb2c61b9bd6add03b461d4e4d7901c957da/pyramid_restful/api.py#L231-L283
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" ]
train
https://github.com/bitesofcode/pyramid_restful/blob/0f1eccb2c61b9bd6add03b461d4e4d7901c957da/pyramid_restful/api.py#L369-L398
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", "." ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L103-L122
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" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L125-L153
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" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L156-L177
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" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L199-L217
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" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L226-L267
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", "." ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L270-L312
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" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L315-L345
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" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L348-L378
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" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L425-L458
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" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L461-L479
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" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L482-L528
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" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L564-L588
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" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L591-L643
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" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L683-L698
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" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L708-L745
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" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L747-L764
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" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L851-L854
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" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L857-L861
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" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L864-L869
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" ]
train
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/__init__.py#L872-L876